备份高德代码

This commit is contained in:
lulz1 2024-04-30 09:28:17 +08:00
parent c941d23b80
commit 2ccf1e2158
11 changed files with 146 additions and 55 deletions

View File

@ -14,6 +14,8 @@ import java.util.List;
public class AmapRouteRelationship implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@Id
private Long id;
private String applyRecordId;
private String outApplyRecordId;
}

View File

@ -0,0 +1,54 @@
package com.chint.domain.factoriy.order_detail;
import com.chint.domain.aggregates.order.*;
import lombok.Data;
import org.springframework.stereotype.Component;
@Component
public class AmapOrderExtensionFactoryImpl implements OrderExtensionFactory{
@Override
public CarOrderDetail createCarOrderDetail(Object carOrderDetailData) {
return null;
}
@Override
public CarOrderDetail updateCarOrderDetailData(CarOrderDetail carOrderDetail, Object carOrderDetailData) {
return null;
}
@Override
public TrainOrderDetail createTrainOrderDetail(Object trainOrderDetailData) {
return null;
}
@Override
public TrainOrderDetail updateTrainOrderDetailData(TrainOrderDetail flightOrderDetail, Object trainOrderInfo) {
return null;
}
@Override
public FlightOrderDetail createFlightOrderDetail(Object flightOrderDetailData) {
return null;
}
@Override
public FlightOrderDetail updateFlightOrderDetailData(FlightOrderDetail flightOrderDetail, Object flightOrderInfo) {
return null;
}
@Override
public HotelOrderDetail createHotelOrderDetail(Object hotelOrderDetailData) {
return null;
}
@Override
public HotelOrderDetail updateHotelOrderDetailData(HotelOrderDetail hotelOrderDetail, Object hotelOrderInfo) {
return null;
}
@Override
public OtherOrderDetail createOtherOrderDetail(Object otherOrderDetailData) {
return null;
}
}

View File

@ -713,7 +713,7 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
case BELONG_SYS_CODE_H3BPM -> BELONG_SYS_TYPE_H3BPM;
case BELONG_SYS_CODE_XNFSSC -> BELONG_SYS_TYPE_XNFSSC;
case BELONG_SYS_CODE_ANFSSC -> BELONG_SYS_TYPE_ANFSSC;
default -> null;
default -> BELONG_SYS_TYPE_NULL;
};
}

View File

@ -27,6 +27,7 @@ public class RanksFactoryImpl implements RanksFactory {
case STANDARD_LEVEL_YB_CODE -> STANDARD_LEVEL_YB;
case STANDARD_LEVEL_WL_CODE -> STANDARD_LEVEL_WL;
case STANDARD_LEVEL_AN_CODE -> STANDARD_LEVEL_AN;
case STANDARD_LEVEL_GY_CODE -> STANDARD_LEVEL_GY;
// case STANDARD_LEVEL_SZKJ_CODE -> STANDARD_LEVEL_SZKJ;
case STANDARD_LEVEL_SDZN_CODE -> STANDARD_LEVEL_SDZN;
// case STANDARD_LEVEL_DQXS_CODE -> STANDARD_LEVEL_DQXS;

View File

@ -103,6 +103,8 @@ public class RouteRequestDomainService {
routeRequest.addEvent(RouteRequestEvent.sync(syncLegData.getSupplierName()));
//通过保存聚合根来保存差旅申请单
routeRepository.save(routeOrder);
} else {
throw new CommandException("同步差旅申请单失败,联系管理员");
}
return routeRequest;
}

View File

@ -6,17 +6,18 @@ import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.UserRepository;
import com.chint.domain.service.LegDomainService;
import com.chint.infrastructure.repository.jdbc.JdbcAmapRouteRelationshipRepository;
import com.chint.infrastructure.util.DateTimeUtil;
import com.chint.interfaces.rest.amap.AmapLocationRequest;
import com.chint.interfaces.rest.amap.dto.travelapplication.ProcessContent;
import com.chint.interfaces.rest.amap.dto.travelapplication.TravelApplicationDto;
import com.chint.interfaces.rest.amap.dto.travelapplication.TravelApplicationDtoResponse;
import com.chint.interfaces.rest.amap.request.TravelApplicationRequest;
import com.chint.interfaces.rest.ctrip.dto.approval.ApprovalRequest;
import com.google.gson.Gson;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
@ -25,7 +26,7 @@ import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_TAXI;
@Slf4j
@Component
public class AmapOrderSyncAdapter implements SupplierOrderSync{
public class AmapOrderSyncAdapter implements SupplierOrderSync {
@Autowired
private UserRepository userRepository;
@ -42,6 +43,8 @@ public class AmapOrderSyncAdapter implements SupplierOrderSync{
@Autowired
private LegDomainService legDomainService;
private Gson gson = new Gson();
@Override
public boolean syncSupplierOrder(RouteOrder order) {
return false;
@ -49,58 +52,71 @@ public class AmapOrderSyncAdapter implements SupplierOrderSync{
@Override
public boolean syncRouteRequest(RouteRequest routeRequest) {
TravelApplicationDto dto=new TravelApplicationDto();
TravelApplicationDto dto = new TravelApplicationDto();
RouteRequestFields routeRequestFields = routeRequest.getRouteRequestFields();
TravelApplicationDto travelApplicationDto=generateTravelApplicationInfo(dto,routeRequest,routeRequestFields);
TravelApplicationDtoResponse response=travelApplicationRequest.apply(travelApplicationDto);
if (!response.getCode().equals(1)){
TravelApplicationDto travelApplicationDto = generateTravelApplicationInfo(dto, routeRequest, routeRequestFields);
TravelApplicationDtoResponse response = travelApplicationRequest.apply(travelApplicationDto);
if (!response.getCode().equals(1)) {
Gson gson = new Gson();
log.error(gson.toJson(response));
return false;
}
//存入关联表
AmapRouteRelationship amapRouteRelationship=new AmapRouteRelationship();
AmapRouteRelationship amapRouteRelationship = new AmapRouteRelationship();
amapRouteRelationship.setApplyRecordId(response.getData());
amapRouteRelationship.setOutApplyRecordId(routeRequest.getRouteRequestNo());
jdbcAmapRouteRelationshipRepository.save(amapRouteRelationship);
return response.getCode().equals(1);
}
private TravelApplicationDto generateTravelApplicationInfo(TravelApplicationDto dto, RouteRequest routeRequest,RouteRequestFields routeRequestFields) {
private TravelApplicationDto generateTravelApplicationInfo(TravelApplicationDto dto, RouteRequest routeRequest, RouteRequestFields routeRequestFields) {
dto.setOutApplyRecordId(routeRequest.getRouteRequestNo());
//公司信息写入备注
dto.setRemark(routeRequestFields.getAccountCompanyName()+"-"
+routeRequestFields.getAccountCompanyCode()+"-"
+routeRequestFields.getProjectName()+"-"
+routeRequestFields.getCostCenter()+"-"
+routeRequestFields.getSysCode()+"-"
+routeRequestFields.getActualOrderNo());
dto.setRemark(routeRequestFields.getAccountCompanyName() + "-"
+ routeRequestFields.getAccountCompanyCode() + "-"
+ routeRequestFields.getProjectName() + "-"
+ routeRequestFields.getCostCenter() + "-"
+ routeRequestFields.getSysCode() + "-"
+ routeRequestFields.getActualOrderNo());
dto.setApplyEUserId(routeRequestFields.getUserId());
User user=userRepository.findByUserEmployeeNo(routeRequestFields.getUserId());
User user = userRepository.findByUserEmployeeNo(routeRequestFields.getUserId());
dto.setApplyMobile(user.getPhoneNumber());
dto.setApplyName(user.getName());
//审批单
List<Leg> legList=routeRequest.getRouteRequestLegList().stream().map(RouteRequestLeg::getLeg).toList();
legList=legList.stream().filter(u->u.getLegType().equals(LEG_TYPE_TAXI)).toList();
List<Leg> legList = routeRequest.getRouteRequestLegList().stream().map(RouteRequestLeg::getLeg).toList();
legList = legList.stream().filter(u -> u.getLegType().equals(LEG_TYPE_TAXI)).toList();
dto.setTemplateCode("travel");
ProcessContent processContent=new ProcessContent();
processContent.setStartTime(legList.stream().sorted(Comparator.comparing(Leg::getStartTime)).toList().get(0).getStartTime().toString());
processContent.setEndTime(legList.stream().sorted(Comparator.comparing(Leg::getEndTime).reversed()).toList().get(0).getEndTime().toString());
ProcessContent processContent = new ProcessContent();
LocalDateTime startTime = legList
.stream()
.sorted(Comparator.comparing(Leg::getStartTime))
.toList()
.get(0)
.getStartTime();
processContent.setStartTime(DateTimeUtil.timeToStr(startTime));
LocalDateTime endTime = legList.stream()
.sorted(Comparator.comparing(Leg::getEndTime).reversed())
.toList()
.get(0)
.getEndTime();
processContent.setEndTime(DateTimeUtil.timeToStr(endTime));
//areacode处理
List<LegExtensionField> legExtensionFields=legDomainService.queryLocation(legList).stream().map(Leg::getLegExtensionField).toList();
List<Location> locationList=new ArrayList<>();
for (LegExtensionField leg:legExtensionFields){
List<LegExtensionField> legExtensionFields = legDomainService.queryLocation(legList).stream().map(Leg::getLegExtensionField).toList();
List<Location> locationList = new ArrayList<>();
for (LegExtensionField leg : legExtensionFields) {
locationList.addAll(leg.getLocationList());
}
List<String> areaCodes=new ArrayList<>();
for (Location location:locationList){
List<String> areaCodes = new ArrayList<>();
for (Location location : locationList) {
areaCodes.add(amapLocationRequest.getACodeByLocationName(location.getLocationName()));
}
processContent.setValidCityList(areaCodes);
processContent.setAmountLimited(1);
processContent.setAllowCrossCity(1);
dto.setProcessContent(processContent);
dto.setStatus(routeRequest.getStatus().toString());
dto.setProcessContent(gson.toJson(processContent));
dto.setStatus("1");
return dto;
}
@ -111,17 +127,18 @@ public class AmapOrderSyncAdapter implements SupplierOrderSync{
@Override
public boolean cancelRouteRequest(RouteRequest routeRequest) {
TravelApplicationDto dto=new TravelApplicationDto();
TravelApplicationDto dto = new TravelApplicationDto();
RouteRequestFields routeRequestFields = routeRequest.getRouteRequestFields();
TravelApplicationDto travelApplicationDto=generateTravelApplicationInfo(dto,routeRequest,routeRequestFields);
TravelApplicationDto travelApplicationDto = generateTravelApplicationInfo(dto, routeRequest, routeRequestFields);
travelApplicationDto.setStatus("0");
//查询关联表
AmapRouteRelationship amapRouteRelationship=jdbcAmapRouteRelationshipRepository.findAmapRouteRelationshipByApplyRecordId(routeRequest.getRouteRequestNo());
if (amapRouteRelationship==null){
log.info("无企业订单信息",dto.getOutApplyRecordId());
AmapRouteRelationship amapRouteRelationship = jdbcAmapRouteRelationshipRepository.findAmapRouteRelationshipByApplyRecordId(routeRequest.getRouteRequestNo());
if (amapRouteRelationship == null) {
log.info("无企业订单信息", dto.getOutApplyRecordId());
return false;
}
travelApplicationDto.setApplyRecordId(amapRouteRelationship.getApplyRecordId());
TravelApplicationDtoResponse response=travelApplicationRequest.modify(travelApplicationDto);
TravelApplicationDtoResponse response = travelApplicationRequest.modify(travelApplicationDto);
return response.getCode().equals(1);
}
}

View File

@ -3,11 +3,13 @@ package com.chint.domain.service.order_sync;
import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.aggregates.order.RouteRequest;
import com.chint.domain.factoriy.order.RouteOrderFactory;
public interface SupplierOrderSync {
boolean syncSupplierOrder(RouteOrder order);
boolean syncRouteRequest(RouteRequest routeRequest);
boolean cancelSyncSupplierOrder(RouteOrder order);
boolean cancelRouteRequest(RouteRequest routeRequest);
}

View File

@ -9,9 +9,11 @@ public class RankConstant {
public static final String STANDARD_LEVEL_YB_CODE = "A10160001";//仪表编号
public static final String STANDARD_LEVEL_WL_CODE = "A70000059";//仪表编号
public static final String STANDARD_LEVEL_AN_CODE = "A70000021";//仪表编号
public static final String STANDARD_LEVEL_GY_CODE = "A20000001";//正泰电气股份有限公司
public static final String STANDARD_LEVEL_YB = "YB_";//浙江正泰仪器仪表有限责任公司
public static final String STANDARD_LEVEL_WL = "WL_";//浙江正泰仪器仪表有限责任公司
public static final String STANDARD_LEVEL_AN = "AN_";//浙江正泰仪器仪表有限责任公司
public static final String STANDARD_LEVEL_GY = "GY_";//正泰电气股份有限公司
public static final String STANDARD_LEVEL_SZKJ_CODE = "";//数智科技编号
public static final String STANDARD_LEVEL_SZKJ = "SZKJ_";//数智科技
public static final String STANDARD_LEVEL_SDZN_CODE = "A70000067";//山东智能编号
@ -56,4 +58,16 @@ public class RankConstant {
public static final String STANDARD_LEVEL_TWO_WL = "WL_STANDARD_LEVEL_TWO";//差标2
public static final String STANDARD_LEVEL_THREE_WL = "WL_STANDARD_LEVEL_THREE";//差标3
public static final String STANDARD_LEVEL_FOUR_WL = "WL_STANDARD_LEVEL_FOUR";//差标4
//安能
public static final String STANDARD_LEVEL_ONE_AN = "AN_STANDARD_LEVEL_ONE";//差标1
public static final String STANDARD_LEVEL_TWO_AN = "AN_STANDARD_LEVEL_TWO";//差标2
public static final String STANDARD_LEVEL_THREE_AN = "AN_STANDARD_LEVEL_THREE";//差标3
public static final String STANDARD_LEVEL_FOUR_AN = "AN_STANDARD_LEVEL_FOUR";//差标4
//高压
public static final String STANDARD_LEVEL_ONE_GY = "GY_STANDARD_LEVEL_ONE";//差标1
public static final String STANDARD_LEVEL_TWO_GY = "GY_STANDARD_LEVEL_TWO";//差标2
public static final String STANDARD_LEVEL_THREE_GY = "GY_STANDARD_LEVEL_THREE";//差标3
public static final String STANDARD_LEVEL_FOUR_GY = "GY_STANDARD_LEVEL_FOUR";//差标4
}

View File

@ -27,7 +27,7 @@ public class TravelApplicationDto extends BaseRequestParam {
//审批模板Code travel
private String templateCode;
//申请单审批模板内容(JSON格式)
private ProcessContent processContent;
private String processContent;
//审批状态 1有效 0无效
private String status;
@ -73,4 +73,5 @@ public class TravelApplicationDto extends BaseRequestParam {
private String customSceneLabel;
//同行人信息(具体字段见同行人信息)
private List<Companions> companions;
}

View File

@ -54,7 +54,7 @@ public class CTripNoteController {
private SupplierCallBackLogRepository supplierCallBackLogRepository;
@Autowired
public RedisTemplate<String,String> redisTemplate;
public RedisTemplate<String, String> redisTemplate;
private static final String NO_ETA_AVAILABLE = "暂无";
@ -91,13 +91,13 @@ public class CTripNoteController {
Integer legType = translateLegType(productType);
String orderStatus = cTripStatusNotification.getOrderStatus();
if(legType == LEG_TYPE_AIRPLANE && !CTripUtils.checkFlightStatus(orderStatus)) {
if (legType == LEG_TYPE_AIRPLANE && !CTripUtils.checkFlightStatus(orderStatus)) {
return Result.Success(ORDER_STATUS_REFUSE_MSG);
}
if(legType == LEG_TYPE_HOTEL && !CTripUtils.checkHotelStatus(orderStatus)) {
if (legType == LEG_TYPE_HOTEL && !CTripUtils.checkHotelStatus(orderStatus)) {
return Result.Success(ORDER_STATUS_REFUSE_MSG);
}
if(legType == LEG_TYPE_TAXI && !CTripUtils.checkCarStatus(orderStatus)) {
if (legType == LEG_TYPE_TAXI && !CTripUtils.checkCarStatus(orderStatus)) {
return Result.Success(ORDER_STATUS_REFUSE_MSG);
}
@ -107,13 +107,13 @@ public class CTripNoteController {
return Result.error("sign错误");
}
if (orderStatus != null && orderId != null) {
CtripBack notification=new CtripBack();
CtripBack notification = new CtripBack();
notification.setOrderStatus(orderStatus);
notification.setOrderId(orderId);
notification.setLegType(legType);
String ctripBack = gson.toJson(notification);
log.info("存入Redis{}",ctripBack);
redisTemplate.opsForList().leftPush(CTripConstant.C_TRIP_BACK,ctripBack);
log.info("存入Redis{}", ctripBack);
redisTemplate.opsForList().leftPush(CTripConstant.C_TRIP_BACK, ctripBack);
return Result.Success("成功收到消息");
// return handlerData(orderId, orderStatus, legType);
}
@ -121,19 +121,19 @@ public class CTripNoteController {
}
@Scheduled(cron="0/10 * * * * ?")
@Scheduled(cron = "0/10 * * * * ?")
@Async
public void scanCtripPendingMsg() {
int i=0;
int i = 0;
while (true) {
Object object = redisTemplate.opsForList().rightPop(CTripConstant.C_TRIP_BACK, 1, TimeUnit.SECONDS);
if (null == object) {
return;
}
CtripBack notification=gson.fromJson(String.valueOf(object),CtripBack.class);
handlerData(notification.getOrderId(),notification.getOrderStatus(),notification.getLegType());
CtripBack notification = gson.fromJson(String.valueOf(object), CtripBack.class);
handlerData(notification.getOrderId(), notification.getOrderStatus(), notification.getLegType());
i++;
if (i>5){
if (i > 5) {
log.info("CtripBack处理结束");
return;
}
@ -141,7 +141,7 @@ public class CTripNoteController {
}
public Result<String> handlerData(String orderId, String orderStatus, Integer legType ) {
public Result<String> handlerData(String orderId, String orderStatus, Integer legType) {
SupplierCallbackData supplierCallbackData =
SupplierCallbackData.of(SUPPLIER_C_TRIP);
SearchOrderResponse response = cTripOrderSearchRequest

View File

@ -1200,16 +1200,15 @@ class RouteApplicationTests {
// @Test
void addRanks() {
RanksData ranksData = new RanksData();
ranksData.setIndustry("正泰安能数字能源(浙江)股份有限公司");
ranksData.setCompanyCode("A70000021");
ranksData.setIndustry("正泰电气股份有限公司");
ranksData.setCompanyCode("A20000001");
for (int i = 1; i < 13; i++) {
if (i <= 1) {
ranksData.setLevel(4);
ranksData.setLevel(3);
} else if (i <= 4) {
ranksData.setLevel(3);
} else if (i <= 7) {
} else if (i <= 8) {
ranksData.setLevel(2);
} else {
ranksData.setLevel(1);
@ -1227,7 +1226,6 @@ class RouteApplicationTests {
ranksData.setRankName("PR" + i);
rankController.saveRanks(ranksData);
}
}
// @Test