|
@@ -1,25 +1,29 @@
|
|
|
package com.zfire.jiasm.syncdata.upload.order;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.zfire.jiasm.syncdata.constant.GDAppointStatusEnum;
|
|
|
import com.zfire.jiasm.syncdata.constant.GDOrderStatusEnum;
|
|
|
import com.zfire.jiasm.syncdata.constant.OrderTypeEnum;
|
|
|
+import com.zfire.jiasm.syncdata.dao.mapper.OrderInformationNewMapper;
|
|
|
+import com.zfire.jiasm.syncdata.data.Token;
|
|
|
+import com.zfire.jiasm.syncdata.parameter.OrderPar;
|
|
|
import com.zfire.jiasm.syncdata.plus.entity.*;
|
|
|
import com.zfire.jiasm.syncdata.plus.service.*;
|
|
|
import com.zfire.jiasm.syncdata.service.PrepareService;
|
|
|
import com.zfire.jiasm.syncdata.service.PublicService;
|
|
|
-import com.zfire.jiasm.syncdata.utils.PrepareTaskLog;
|
|
|
+import com.zfire.jiasm.syncdata.utils.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
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.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 生成上传任务清单 out_jiasm_to_gree_upload_task_list
|
|
@@ -29,6 +33,11 @@ import java.util.Map;
|
|
|
@Slf4j
|
|
|
@Component
|
|
|
public class RepairProduceUploadList {
|
|
|
+ @Value("${baseurl}")
|
|
|
+ private String baseurl = "";
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TokenCenter tokenCenter;
|
|
|
@Resource
|
|
|
RepairProduceUploadList repairProduceUploadList;
|
|
|
@Resource
|
|
@@ -45,16 +54,22 @@ public class RepairProduceUploadList {
|
|
|
OrderProductService orderProductService;
|
|
|
@Resource
|
|
|
OrderRepairOperatingLogService orderRepairOperatingLogService;
|
|
|
+ @Resource
|
|
|
+ OrderInformationService orderInformationService;
|
|
|
+ @Resource
|
|
|
+ OrderInformationNewMapper orderInformationNewMapper;
|
|
|
|
|
|
|
|
|
@Scheduled(fixedDelay = 1 * 5 * 1000)
|
|
|
- private void produceList(){
|
|
|
+ private void produceList() {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
List<OutJiasmToGreeUploadTaskList> ojtgutls = new ArrayList<>();
|
|
|
/*if (1==1){
|
|
|
return;
|
|
|
}*/
|
|
|
|
|
|
+
|
|
|
+
|
|
|
log.info("开始预处理需要上传的维修工单数据: \uF0B7{}",sdf.format(new Date()));
|
|
|
|
|
|
// 从需要上传的订单数据表中提取数据
|
|
@@ -62,6 +77,8 @@ public class RepairProduceUploadList {
|
|
|
.eq(OutJiasmToGreeUploadnotifylist::getSynStatus,0)
|
|
|
.orderByAsc(OutJiasmToGreeUploadnotifylist::getSynReqId).list();
|
|
|
try{
|
|
|
+ Token token = tokenCenter.getCurrentToken();
|
|
|
+
|
|
|
for (OutJiasmToGreeUploadnotifylist item : taskResults) {
|
|
|
Long itemSynReqId = item.getSynReqId();
|
|
|
// 同步的表名
|
|
@@ -100,8 +117,37 @@ public class RepairProduceUploadList {
|
|
|
repairProduceUploadList.logProess(item, itemTableName, itemOrderNo, itemTableNameId);
|
|
|
}
|
|
|
// 子信息
|
|
|
- if (itemTableName.equals("order_information")){
|
|
|
- // 这里分维修或是安装的子信息
|
|
|
+ if (itemTableName.equals("order_information") &&
|
|
|
+ itemOrderType.equals(OrderTypeEnum.ORDER_TYPE_REPAIR.getCode())){
|
|
|
+ String newDykh = "";
|
|
|
+ // 执行 TL_get_fa_order_repair_information_pgid 取pgid 从工单主表中看
|
|
|
+ // 提取工单数据
|
|
|
+ OrderBase orderBase = orderBaseService.lambdaQuery()
|
|
|
+ .eq(OrderBase::getId, itemOrderNo).one();
|
|
|
+ // 提取对应的子信息
|
|
|
+ OrderInformation oi = orderInformationService.lambdaQuery()
|
|
|
+ .eq(OrderInformation::getId, itemTableNameId).one();
|
|
|
+
|
|
|
+ // 为空不做处理
|
|
|
+ if (StringUtils.isNotEmpty(orderBase.getPgid())){
|
|
|
+ // 看 ydid 值 不为空取该值 为空时网络获取
|
|
|
+ if (oi != null){
|
|
|
+ // 获取YDID 表中不存在时从接口中获取
|
|
|
+ newDykh = getYdId(token, itemOrderNo, itemTableNameId, srcTabName, orderBase, oi);
|
|
|
+ // 修改 ydid 来自接口
|
|
|
+ upYdid(itemTableNameId, newDykh);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 工单主表的pgid为空时不同步 不修改同步表数据
|
|
|
+ // 看表的 fkid字段值
|
|
|
+
|
|
|
|
|
|
// TL_PrePare_task_by_fa_order_repair_operating_log
|
|
|
repairProduceUploadList.logProess(item, itemTableName, itemOrderNo, itemTableNameId);
|
|
@@ -123,6 +169,66 @@ public class RepairProduceUploadList {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void upYdid(String itemTableNameId, String newDykh) {
|
|
|
+ OrderPar orderPar = new OrderPar();
|
|
|
+ orderPar.setId(itemTableNameId);
|
|
|
+ orderPar.setYdid(newDykh);
|
|
|
+ orderInformationNewMapper.upYdid(orderPar);
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getYdId(Token token, String itemOrderNo, String itemTableNameId, String srcTabName, OrderBase orderBase, OrderInformation oi) throws Exception {
|
|
|
+ String newDykh;
|
|
|
+ if (oi.getYdid()>0){
|
|
|
+ // 表中获取
|
|
|
+ newDykh = String.valueOf(oi.getYdid());
|
|
|
+ } else {
|
|
|
+ // 网络获取
|
|
|
+ newDykh = getWebAcquire(token, itemOrderNo, itemTableNameId, srcTabName, orderBase);
|
|
|
+ }
|
|
|
+ return newDykh;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getWebAcquire(Token token, String itemOrderNo, String itemTableNameId, String srcTabName, OrderBase orderBase) throws Exception {
|
|
|
+ String newDykh;
|
|
|
+ Map<String, Object> sourceData = prepareService.getTaskDataDetail(srcTabName, itemOrderNo,
|
|
|
+ itemTableNameId);
|
|
|
+ sourceData.put("pgid", orderBase.getPgid());
|
|
|
+
|
|
|
+ String serviceName = DataUtil.fromDbName2ServiceName("tbl_assign_xzyd");
|
|
|
+ String addDataUrl = baseurl + serviceName + "/add";
|
|
|
+
|
|
|
+ JSONResult addResult = HttpUtil.httpRequestWithToken(addDataUrl, "POST",
|
|
|
+ JSON.toJSONStringWithDateFormat(
|
|
|
+ genDataMapFromSource("pgid", "pgid", sourceData),
|
|
|
+ "yyyy-MM-dd HH:mm:ss"),
|
|
|
+ token);
|
|
|
+ if (!addResult.isOK()) {
|
|
|
+ throw new Exception("新增数据获取主键失败[" + serviceName + "],[" + addResult.getMsg() + "]");
|
|
|
+ } else {
|
|
|
+ if (addResult.getData() == null || addResult.getData().equals("")) {
|
|
|
+ throw new Exception("新增数据获取主键返回空[" + serviceName + "]");
|
|
|
+ } else {
|
|
|
+ newDykh = addResult.getData().toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return newDykh;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, Object> genDataMapFromSource(String localKeyList, String serverKeyList,
|
|
|
+ Map<String, Object> sourceData) {
|
|
|
+ Map<String, Object> paramMap = new HashMap<String, Object>();
|
|
|
+ String[] localKeys = localKeyList.split("\\Q,\\E");
|
|
|
+ String[] serverKeys = serverKeyList.split("\\Q,\\E");
|
|
|
+ for (int i = 0; i < localKeys.length; i++) {
|
|
|
+ String localKey = localKeys[i];
|
|
|
+ String serverKey = serverKeys[i];
|
|
|
+ Object value = sourceData.get(localKey.trim());
|
|
|
+ paramMap.put(DataUtil.fromDbName2ServiceName(serverKey.trim()), value);
|
|
|
+ }
|
|
|
+
|
|
|
+ return paramMap;
|
|
|
+ }
|
|
|
+
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void logProess(OutJiasmToGreeUploadnotifylist item, String itemTableName, String itemOrderNo, String itemTableNameId) {
|
|
|
// 提取日志数据
|