|
@@ -2,6 +2,8 @@ package com.zfire.jiasm.syncdata.download.order.repair;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.zfire.jiasm.syncdata.base.BaseService;
|
|
|
+import com.zfire.jiasm.syncdata.constant.OrderStatusEnum;
|
|
|
+import com.zfire.jiasm.syncdata.constant.OrderTypeEnum;
|
|
|
import com.zfire.jiasm.syncdata.dao.mapper.*;
|
|
|
import com.zfire.jiasm.syncdata.parameter.OrderPar;
|
|
|
import com.zfire.jiasm.syncdata.parameter.ReAppointment;
|
|
@@ -75,6 +77,10 @@ public class RepairBusiness {
|
|
|
OrderInformationService orderInformationService;
|
|
|
@Resource
|
|
|
ItfTblAssignAppointmentDownloadService itfTblAssignAppointmentDownloadService;
|
|
|
+ @Resource
|
|
|
+ CustomerInformationWebsitService customerInformationWebsitService;
|
|
|
+ @Resource
|
|
|
+ WebsitOrderSignService websitOrderSignService;
|
|
|
|
|
|
|
|
|
|
|
@@ -129,12 +135,21 @@ public class RepairBusiness {
|
|
|
// 按任务号download_task_no,按单来处理
|
|
|
for (ItfTblAssignDownload item: repairRec){
|
|
|
try{
|
|
|
- if (orderBaselist.contains(item.getPgid())){
|
|
|
+ if (orderBaselist.contains(String.valueOf(item.getPgid()))){
|
|
|
// 修改
|
|
|
+ log.info("修改:");
|
|
|
+
|
|
|
+
|
|
|
+ // 处理维修工单主表数据
|
|
|
+ modifyOrderBase(brand, sysDictRefDLMap, item);
|
|
|
+
|
|
|
|
|
|
} else {
|
|
|
// 新增
|
|
|
+ log.info("新增:");
|
|
|
repairBusiness.addOrder(brand, item, sysDictRefDLMap, sysDictRefXLMap, sysDictRefXiLieMap);
|
|
|
+ orderBaselist.add(String.valueOf(item.getPgid()));
|
|
|
+
|
|
|
}
|
|
|
}catch (Exception ex) {
|
|
|
ex.printStackTrace();
|
|
@@ -145,6 +160,133 @@ public class RepairBusiness {
|
|
|
log.info("维修工单落本地表处理完成: {}",sdf.format(new Date()));
|
|
|
}
|
|
|
|
|
|
+ private void modifyOrderBase(Brand brand, Map<String, List<SysDictRef>> sysDictRefDLMap, ItfTblAssignDownload item) {
|
|
|
+ // TL_SynDataFrom_tbl_assign_batch
|
|
|
+ // TL_SynDataFrom_tbl_assign 主单的 syn_req_id
|
|
|
+ // 提取基础表数据
|
|
|
+ OrderBase oldOrder = orderBaseService.lambdaQuery()
|
|
|
+ .eq(OrderBase::getPgid, item.getPgid())
|
|
|
+ .eq(OrderBase::getOrderType, OrderTypeEnum.ORDER_TYPE_REPAIR.getCode()).one();
|
|
|
+ // 批量关闭的工单 同步下载无需再修改
|
|
|
+ if (oldOrder.getOrderStatus().equals(OrderStatusEnum.REPAIR_STATUS_R13.getCode())){
|
|
|
+ upItfTblAssignDownload(item.getSynReqId(),99,"last_modified_by = CLIENT__autoapp 本地已作废/关闭,忽略下载处理");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 基础表数据同步 总部的修改时间必须晚于本地系统时间才可以修改
|
|
|
+ if (item.getLastModifiedDate().compareTo(oldOrder.getUpdateTime())>0){
|
|
|
+ upOrderBase(brand, item, oldOrder.getId());
|
|
|
+ }
|
|
|
+ // 网点信息更新
|
|
|
+ updateWebsit(brand, sysDictRefDLMap, item, oldOrder);
|
|
|
+ // 预约时间信息更新 如何判断工单已预约 首次预约人信息不为空即为已预约
|
|
|
+ if (StringUtils.isEmpty(oldOrder.getFirstAppointmentId())){
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updateWebsit(Brand brand, Map<String, List<SysDictRef>> sysDictRefDLMap, ItfTblAssignDownload item, OrderBase oldOrder) {
|
|
|
+ // 看网点更新的条件
|
|
|
+ Boolean flag = getaBoolean(sysDictRefDLMap, item, oldOrder);
|
|
|
+ // 更新网点信息
|
|
|
+ if (flag){
|
|
|
+ // 字段赋值
|
|
|
+ OrderBase upOrder = getOrderBase(brand, item, oldOrder);
|
|
|
+ orderBaseService.updateById(upOrder);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @NotNull
|
|
|
+ private OrderBase getOrderBase(Brand brand, ItfTblAssignDownload item, OrderBase oldOrder) {
|
|
|
+ OrderBase upOrder = new OrderBase();
|
|
|
+ upOrder.setId(oldOrder.getId());
|
|
|
+ if (StringUtils.isNotEmpty(item.getXxlb())){
|
|
|
+ upOrder.setInfoType(item.getXxlb());
|
|
|
+ } else {
|
|
|
+ upOrder.setInfoType("");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(String.valueOf(item.getXxlbid()))){
|
|
|
+ upOrder.setInfoTypeId(String.valueOf(item.getXxlbid()));
|
|
|
+ } else {
|
|
|
+ upOrder.setInfoTypeId("101");
|
|
|
+ }
|
|
|
+ // 维修网点
|
|
|
+ String wdno ="";
|
|
|
+ if (StringUtils.isEmpty(item.getWxwdno())){
|
|
|
+ wdno = item.getXjwdno();
|
|
|
+ } else {
|
|
|
+ wdno = item.getWxwdno();
|
|
|
+ }
|
|
|
+ WebsitSH resultData = publicService.WebsitToSH(wdno, brand.getBrandId());
|
|
|
+ upOrder.setWebsitId(resultData.getWdId());
|
|
|
+ upOrder.setWebsitName(resultData.getWdmc());
|
|
|
+ if (StringUtils.isNotEmpty(item.getXjwdno())){
|
|
|
+ WebsitSH res = publicService.WebsitToSH(item.getXjwdno(), brand.getBrandId());
|
|
|
+ upOrder.setReceWebsitId(res.getWdId());
|
|
|
+ upOrder.setReceWebsitName(res.getWdmc());
|
|
|
+ } else {
|
|
|
+ upOrder.setReceWebsitId("");
|
|
|
+ upOrder.setReceWebsitName("");
|
|
|
+ }
|
|
|
+ return upOrder;
|
|
|
+ }
|
|
|
+
|
|
|
+ @NotNull
|
|
|
+ private Boolean getaBoolean(Map<String, List<SysDictRef>> sysDictRefDLMap, ItfTblAssignDownload item, OrderBase oldOrder) {
|
|
|
+ Boolean flag = Boolean.FALSE;
|
|
|
+ if ((oldOrder.getOrderStatus().equals(OrderStatusEnum.REPAIR_STATUS_R1.getCode()) ||
|
|
|
+ oldOrder.getOrderStatus().equals(OrderStatusEnum.REPAIR_STATUS_R2.getCode()) ||
|
|
|
+ oldOrder.getOrderStatus().equals(OrderStatusEnum.REPAIR_STATUS_R3.getCode()) ||
|
|
|
+ oldOrder.getOrderStatus().equals(OrderStatusEnum.REPAIR_STATUS_R4.getCode()) ||
|
|
|
+ oldOrder.getOrderStatus().equals(OrderStatusEnum.REPAIR_STATUS_R5.getCode()) ||
|
|
|
+ oldOrder.getOrderStatus().equals(OrderStatusEnum.REPAIR_STATUS_R6.getCode())) ||
|
|
|
+ (oldOrder.getOrderStatus().equals(OrderStatusEnum.REPAIR_STATUS_R7.getCode()) &&
|
|
|
+ !oldOrder.getDispatchStatus().equals("YCJ") &&
|
|
|
+ !oldOrder.getDispatchStatus().equals("YBWG"))){
|
|
|
+ flag = Boolean.TRUE;
|
|
|
+ }
|
|
|
+ if ((!oldOrder.getOrderStatus().equals(OrderStatusEnum.REPAIR_STATUS_R1.getCode()) &&
|
|
|
+ !oldOrder.getOrderStatus().equals(OrderStatusEnum.REPAIR_STATUS_R2.getCode()) &&
|
|
|
+ !oldOrder.getOrderStatus().equals(OrderStatusEnum.REPAIR_STATUS_R3.getCode())) && item.getStat() == 2){
|
|
|
+ flag = Boolean.FALSE;
|
|
|
+ }
|
|
|
+ // op.setMainId(sysDictRefDLMap.get(String.valueOf(rec.getSpid())).get(0).getDictCode());
|
|
|
+ if (StringUtils.isNotEmpty(oldOrder.getMainId()) && StringUtils.isNotEmpty(String.valueOf(item.getSpid())) &&
|
|
|
+ !oldOrder.getMainId().equals(sysDictRefDLMap.get(String.valueOf(item.getSpid())).get(0).getDictCode())){
|
|
|
+ flag = Boolean.TRUE;
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void upOrderBase(Brand brand, ItfTblAssignDownload item, String id) {
|
|
|
+ // 获取维修工单主表要修改的数据
|
|
|
+ OrderBase upOrder = getUpOrderBase(brand, item, id);
|
|
|
+ // 省市区单独处理
|
|
|
+ orderService.getPCAS(upOrder);
|
|
|
+ orderBaseService.updateById(upOrder);
|
|
|
+ }
|
|
|
+
|
|
|
+ @NotNull
|
|
|
+ private OrderBase getUpOrderBase(Brand brand, ItfTblAssignDownload item, String id) {
|
|
|
+ OrderPar orderPar = new OrderPar();
|
|
|
+ orderPar.setSynReqId(item.getSynReqId());
|
|
|
+ orderPar.setBrandId(brand.getBrandId());
|
|
|
+ OrderBase upOrder = repairDownloadMapper.getUpOrderBase(orderPar);
|
|
|
+ upOrder.setId(id);
|
|
|
+ upOrder.setOutUpdateSynReqId(item.getSynReqId());
|
|
|
+ upOrder.setOutUpdateSynReqTime(new Date());
|
|
|
+ upOrder.setUpdateTime(new Date());
|
|
|
+ return upOrder;
|
|
|
+ }
|
|
|
+
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void addOrder(Brand brand, ItfTblAssignDownload item,
|
|
|
Map<String, List<SysDictRef>> sysDictRefDLMap,
|
|
@@ -570,12 +712,7 @@ public class RepairBusiness {
|
|
|
}
|
|
|
|
|
|
public void upItfTblAssignDownloadStatus(ItfTblAssignDownload item, OrderBase order){
|
|
|
- ItfTblAssignDownload up = new ItfTblAssignDownload();
|
|
|
- up.setSynReqId(item.getSynReqId());
|
|
|
- up.setSynStatus(1);
|
|
|
- up.setSynTime(new Date());
|
|
|
- up.setSynErrMsg("成功");
|
|
|
- itfTblAssignDownloadService.updateById(up);
|
|
|
+ upItfTblAssignDownload(item.getSynReqId(),1,"成功");
|
|
|
|
|
|
OrderPar prepar = new OrderPar();
|
|
|
prepar.setSynReqId(item.getSynReqId());
|
|
@@ -583,6 +720,15 @@ public class RepairBusiness {
|
|
|
assignDownloadMapper.updateStatus(prepar);
|
|
|
}
|
|
|
|
|
|
+ private void upItfTblAssignDownload(Long synReqId, Integer synStatus, String synErrMsg) {
|
|
|
+ ItfTblAssignDownload up = new ItfTblAssignDownload();
|
|
|
+ up.setSynReqId(synReqId);
|
|
|
+ up.setSynStatus(synStatus);
|
|
|
+ up.setSynTime(new Date());
|
|
|
+ up.setSynErrMsg(synErrMsg);
|
|
|
+ itfTblAssignDownloadService.updateById(up);
|
|
|
+ }
|
|
|
+
|
|
|
private void generateDispatch(OrderBase order) {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|