|
@@ -4,15 +4,13 @@ import com.zfire.jiasm.syncdata.base.BaseService;
|
|
|
import com.zfire.jiasm.syncdata.dao.mapper.AssignDownloadMapper;
|
|
|
import com.zfire.jiasm.syncdata.dao.mapper.DetailOrderRepairMapper;
|
|
|
import com.zfire.jiasm.syncdata.dao.mapper.RepairDownloadMapper;
|
|
|
+import com.zfire.jiasm.syncdata.dao.mapper.RepairMxDownloadMapper;
|
|
|
import com.zfire.jiasm.syncdata.parameter.OrderPar;
|
|
|
-import com.zfire.jiasm.syncdata.plus.entity.Brand;
|
|
|
-import com.zfire.jiasm.syncdata.plus.entity.ItfTblAssignDownload;
|
|
|
-import com.zfire.jiasm.syncdata.plus.entity.OrderApplyDispatch;
|
|
|
-import com.zfire.jiasm.syncdata.plus.entity.OrderBase;
|
|
|
-import com.zfire.jiasm.syncdata.plus.service.ItfTblAssignDownloadService;
|
|
|
-import com.zfire.jiasm.syncdata.plus.service.OrderApplyDispatchService;
|
|
|
-import com.zfire.jiasm.syncdata.plus.service.OrderBaseService;
|
|
|
+import com.zfire.jiasm.syncdata.plus.entity.*;
|
|
|
+import com.zfire.jiasm.syncdata.plus.service.*;
|
|
|
+import com.zfire.jiasm.syncdata.response.WebsitSH;
|
|
|
import com.zfire.jiasm.syncdata.service.OrderService;
|
|
|
+import com.zfire.jiasm.syncdata.service.PublicService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Component;
|
|
@@ -20,9 +18,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 格力品牌维修工单下载后落本地数据表
|
|
@@ -46,11 +42,21 @@ public class RepairBusiness {
|
|
|
@Resource
|
|
|
OrderService orderService;
|
|
|
@Resource
|
|
|
- DetailOrderRepairMapper detailOrderRepairMapper;
|
|
|
- @Resource
|
|
|
OrderApplyDispatchService orderApplyDispatchService;
|
|
|
@Resource
|
|
|
AssignDownloadMapper assignDownloadMapper;
|
|
|
+ @Resource
|
|
|
+ ItfTblAssignMxDownloadService itfTblAssignMxDownloadService;
|
|
|
+ @Resource
|
|
|
+ RepairMxDownloadMapper repairMxDownloadMapper;
|
|
|
+ @Resource
|
|
|
+ PublicService publicService;
|
|
|
+ @Resource
|
|
|
+ OrderInstallService orderInstallService;
|
|
|
+ @Resource
|
|
|
+ OrderProductService orderProductService;
|
|
|
+ @Resource
|
|
|
+ ItfTblAssignFkmxDownloadService itfTblAssignFkmxDownloadService;
|
|
|
|
|
|
|
|
|
// 1:工单落入本地表
|
|
@@ -70,6 +76,14 @@ public class RepairBusiness {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ // 提取品牌商对应的大类信息
|
|
|
+ Map<String, List<SysDictRef>> sysDictRefDLMap = publicService.getStringListMap(brand);
|
|
|
+ // 提取品牌商对应的小类信息
|
|
|
+ Map<String, List<SysDictRef>> sysDictRefXLMap = publicService.getListMap(brand);
|
|
|
+ // 提取品牌商对应的系列信息
|
|
|
+ Map<String, List<SysDictRef>> sysDictRefXiLieMap = publicService.getMap(brand);
|
|
|
+
|
|
|
+
|
|
|
// 提取待落本地表的数据
|
|
|
repairRec = itfTblAssignDownloadService.lambdaQuery()
|
|
|
.eq(ItfTblAssignDownload::getSynStatus,0)
|
|
@@ -87,15 +101,148 @@ public class RepairBusiness {
|
|
|
for (ItfTblAssignDownload item: repairRec){
|
|
|
|
|
|
// 新增
|
|
|
- repairBusiness.addOrder(brand, item);
|
|
|
+ repairBusiness.addOrder(brand, item, sysDictRefDLMap, sysDictRefXLMap, sysDictRefXiLieMap);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void addOrder(Brand brand, ItfTblAssignDownload item) {
|
|
|
+ public void addOrder(Brand brand, ItfTblAssignDownload item,
|
|
|
+ Map<String, List<SysDictRef>> sysDictRefDLMap,
|
|
|
+ Map<String, List<SysDictRef>> sysDictRefXLMap,
|
|
|
+ Map<String, List<SysDictRef>> sysDictRefXiLieMap) {
|
|
|
// 新增 TL_SynDataFrom_tbl_assign_batch
|
|
|
// TL_SynDataFrom_tbl_assign 主单的 syn_req_id
|
|
|
- // 生成维修工单主表数据
|
|
|
+
|
|
|
+ // 处理维修工单主表数据
|
|
|
+ OrderBase order = generateOrder(brand, item);
|
|
|
+ // 处理工单师傅
|
|
|
+ OrderWorker orderWorker = publicService.getOrderWorker(order);
|
|
|
+ // 获取工单扩展信息
|
|
|
+ getOrderInstall(item, order);
|
|
|
+
|
|
|
+ // 处理维修单明细表 TL_SynDataFrom_tbl_assign_mx
|
|
|
+ generateMx(brand, item, order, sysDictRefDLMap, sysDictRefXLMap, sysDictRefXiLieMap);
|
|
|
+
|
|
|
+
|
|
|
+ // 处理维修单过程反馈表 放入操作日志表
|
|
|
+ List<ItfTblAssignFkmxDownload> fkmxRec = new ArrayList<>();
|
|
|
+ List<OrderRepairOperatingLog> orol = new ArrayList<>();
|
|
|
+ List<ItfTblAssignFkmxDownload> ups = new ArrayList<>();
|
|
|
+
|
|
|
+ fkmxRec = itfTblAssignFkmxDownloadService.lambdaQuery()
|
|
|
+ .eq(ItfTblAssignFkmxDownload::getDownloadTaskNo,item.getDownloadTaskNo())
|
|
|
+ .eq(ItfTblAssignFkmxDownload::getSynStatus,0)
|
|
|
+ .orderByAsc(ItfTblAssignFkmxDownload::getCreatedDate,ItfTblAssignFkmxDownload::getFkid)
|
|
|
+ .list();
|
|
|
+ for (ItfTblAssignFkmxDownload fkmx :fkmxRec){
|
|
|
+ // 查看是否存在,存在为修改
|
|
|
+ // 新增时是不会存在的,所以这里只做新增
|
|
|
+ OrderRepairOperatingLog add = new OrderRepairOperatingLog();
|
|
|
+ add.setWebsitName(order.getWebsitName());
|
|
|
+ add.setWebsitId(order.getWebsitId());
|
|
|
+ add.setOrderBaseId(order.getId());
|
|
|
+ add.setCustomerName(order.getUserName());
|
|
|
+ add.setCustomerPhone(order.getUserMobile());
|
|
|
+ add.setType(fkmx.getFklb());
|
|
|
+ add.setContent(fkmx.getFknr());
|
|
|
+ add.setFeedback(fkmx.getFkjg());
|
|
|
+ add.setOperator(fkmx.getFkren());
|
|
|
+ add.setOperatorNumber(fkmx.getFkrenmc());
|
|
|
+ WebsitSH websitSH = publicService.WebsitToSH(fkmx.getFkwdno(),brand.getBrandId());
|
|
|
+ add.setOperateWebsit(websitSH.getWdmc());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getOrderInstall(ItfTblAssignDownload item, OrderBase order) {
|
|
|
+ OrderInstall oit = new OrderInstall();
|
|
|
+ oit.setOrderBaseId(order.getId());
|
|
|
+ oit.setExtendField1(item.getExtjson1());
|
|
|
+ oit.setExtendField2(item.getExtjson2());
|
|
|
+ oit.setExtendField3(item.getExtjson3());
|
|
|
+ oit.setExtendField4(item.getExtjson4());
|
|
|
+ oit.setExtendField5(item.getExtjson5());
|
|
|
+ oit.setCreateBy(order.getCreateBy());
|
|
|
+ oit.setCreateTime(order.getCreateTime());
|
|
|
+ oit.setUpdateBy(order.getUpdateBy());
|
|
|
+ oit.setUpdateTime(order.getUpdateTime());
|
|
|
+ orderInstallService.save(oit);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void generateMx(Brand brand, ItfTblAssignDownload item, OrderBase order,
|
|
|
+ Map<String, List<SysDictRef>> sysDictRefDLMap,
|
|
|
+ Map<String, List<SysDictRef>> sysDictRefXLMap,
|
|
|
+ Map<String, List<SysDictRef>> sysDictRefXiLieMap) {
|
|
|
+ List<ItfTblAssignMxDownload> mxRec = new ArrayList<>();
|
|
|
+ List<OrderProduct> addmx = new ArrayList<>();
|
|
|
+ List<ItfTblAssignMxDownload> ups = new ArrayList<>();
|
|
|
+
|
|
|
+
|
|
|
+ // 明取明细表数据
|
|
|
+ mxRec = itfTblAssignMxDownloadService.lambdaQuery()
|
|
|
+ .eq(ItfTblAssignMxDownload::getDownloadTaskNo, item.getDownloadTaskNo())
|
|
|
+ .eq(ItfTblAssignMxDownload::getSynStatus,0)
|
|
|
+ .orderByAsc(ItfTblAssignMxDownload::getSynStatus)
|
|
|
+ .list();
|
|
|
+ for (ItfTblAssignMxDownload rec:mxRec){
|
|
|
+ // 提取维修工单明细数据对象
|
|
|
+ OrderPar mxreq = new OrderPar();
|
|
|
+ mxreq.setSynReqId(Long.valueOf(rec.getSynReqId()));
|
|
|
+ mxreq.setBrandId(brand.getBrandId());
|
|
|
+ OrderProduct op = repairMxDownloadMapper.getMx(mxreq);
|
|
|
+
|
|
|
+ // 其他部分参数赋值
|
|
|
+ op.setOrderBaseId(order.getId());
|
|
|
+ op.setPgguid(item.getPgguid());
|
|
|
+ op.setMainId(order.getMainId());
|
|
|
+ op.setMainName(order.getMainName());
|
|
|
+ op.setMainId(sysDictRefDLMap.get(String.valueOf(rec.getSpid())).get(0).getDictCode());
|
|
|
+ op.setMainName(sysDictRefDLMap.get(String.valueOf(rec.getSpid())).get(0).getDictValue());
|
|
|
+ if (!rec.getXlid().equals(0L)){
|
|
|
+ op.setSmallId(sysDictRefXLMap.get(String.valueOf(rec.getXlid())).get(0).getDictCode());
|
|
|
+ op.setSmallName(sysDictRefXLMap.get(String.valueOf(rec.getXlid())).get(0).getDictValue());
|
|
|
+ } else {
|
|
|
+ op.setSmallId(String.valueOf(rec.getXlid()));
|
|
|
+ op.setSmallName(rec.getXlmc());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!rec.getXiid().equals("0")){
|
|
|
+ op.setSeriesId(sysDictRefXiLieMap.get(rec.getXiid()).get(0).getDictCode());
|
|
|
+ op.setSeriesName(sysDictRefXiLieMap.get(rec.getXiid()).get(0).getDictValue());
|
|
|
+ } else {
|
|
|
+ op.setSeriesId(rec.getXiid());
|
|
|
+ op.setSeriesName(rec.getXimc());
|
|
|
+ }
|
|
|
+ addmx.add(op);
|
|
|
+
|
|
|
+ ItfTblAssignMxDownload up = new ItfTblAssignMxDownload();
|
|
|
+ up.setSynReqId(rec.getSynReqId());
|
|
|
+ up.setSynStatus(1);
|
|
|
+ up.setSynReqTime(new Date());
|
|
|
+ ups.add(up);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (addmx.size()>0){
|
|
|
+ orderProductService.saveBatch(addmx);
|
|
|
+ addmx.clear();
|
|
|
+ itfTblAssignMxDownloadService.updateBatchById(ups);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private OrderBase generateOrder(Brand brand, ItfTblAssignDownload item) {
|
|
|
OrderBase order = saveOrderBase(brand, item);
|
|
|
|
|
|
// 更新 修改时更新 新增时无需此操作 可以先放进来,是修改不到数据的
|
|
@@ -103,9 +250,9 @@ public class RepairBusiness {
|
|
|
// order_product 无维修网点信息,所以不用做
|
|
|
|
|
|
// 采集表需要做上面的操作 order_repair_detail 新增时也无需操作,加上也不会出错
|
|
|
- OrderPar request = new OrderPar();
|
|
|
+ /*OrderPar request = new OrderPar();
|
|
|
request.setOrderNo(order.getId());
|
|
|
- detailOrderRepairMapper.updateWebsitMessage(request);
|
|
|
+ detailOrderRepairMapper.updateWebsitMessage(request);*/
|
|
|
|
|
|
|
|
|
// 新增或是修改都要加 新增是一定要做的
|
|
@@ -128,6 +275,8 @@ public class RepairBusiness {
|
|
|
|
|
|
// 修改同步状态
|
|
|
upItfTblAssignDownloadStatus(item, order);
|
|
|
+
|
|
|
+ return order;
|
|
|
}
|
|
|
|
|
|
private OrderBase saveOrderBase(Brand brand, ItfTblAssignDownload item) {
|
|
@@ -158,6 +307,8 @@ public class RepairBusiness {
|
|
|
}
|
|
|
|
|
|
private void generateDispatch(OrderBase order) {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
List<String> parame = new ArrayList<>();
|
|
|
parame.add(order.getWebsitId());
|
|
|
parame.add(order.getReceWebsitId());
|
|
@@ -179,7 +330,7 @@ public class RepairBusiness {
|
|
|
addn.setUserName(order.getUserName());
|
|
|
addn.setUserMobile(order.getUserMobile());
|
|
|
addn.setReserveTime(order.getAppointmentTime());
|
|
|
- addn.setReservePeriod(String.valueOf(order.getAppointmentTime()));
|
|
|
+ addn.setReservePeriod(sdf.format(order.getAppointmentTime()));
|
|
|
addn.setMainId(Integer.valueOf(order.getMainId()));
|
|
|
addn.setMainName(order.getMainName());
|
|
|
addn.setCreateTime(order.getCreateTime());
|