yaozhixue 1 年之前
父节点
当前提交
2942db997d

+ 2 - 0
src/main/java/com/zfire/jiasm/syncdata/dao/mapper/OrderInformationNewMapper.java

@@ -9,4 +9,6 @@ import org.apache.ibatis.annotations.Param;
 public interface OrderInformationNewMapper extends BaseMapper<OrderInformation> {
 
     ItfTblAzAssignXzydUpload getOrderInformation (@Param("request") OrderPar request);
+
+    void upYdid (@Param("request") OrderPar request);
 }

+ 3 - 0
src/main/java/com/zfire/jiasm/syncdata/parameter/OrderPar.java

@@ -29,4 +29,7 @@ public class OrderPar {
     private String mainId;
 
     private String fkid;
+
+    // 阅读ID
+    private String ydid;
 }

+ 9 - 6
src/main/java/com/zfire/jiasm/syncdata/plus/entity/CustomerInformationWebsit.java

@@ -32,12 +32,6 @@ public class CustomerInformationWebsit extends Model<CustomerInformationWebsit>
     @TableId(value = "id", type = IdType.ID_WORKER_STR)
     private String id;
 
-    @ApiModelProperty(value = "品牌id")
-    private String brandId;
-
-    @ApiModelProperty(value = "品牌名称")
-    private String brandName;
-
     @ApiModelProperty(value = "商户id")
     private String customerId;
 
@@ -53,6 +47,15 @@ public class CustomerInformationWebsit extends Model<CustomerInformationWebsit>
     @ApiModelProperty(value = "品牌网点名称")
     private String refWebsitName;
 
+    @ApiModelProperty(value = "售后中心编号")
+    private String refAfterSaleWebsitId;
+
+    @ApiModelProperty(value = "售后中心名称")
+    private String refAfterSaleWebsitName;
+
+    @ApiModelProperty(value = "上级销售中心编号")
+    private String refParentWebsitId;
+
     @ApiModelProperty(value = "创建时间")
     @TableField(fill = FieldFill.INSERT)
     private Date createTime;

+ 5 - 1
src/main/java/com/zfire/jiasm/syncdata/service/impl/PrepareServiceImpl.java

@@ -197,7 +197,11 @@ public class PrepareServiceImpl implements PrepareService {
 		if (tabName.equals("order_base")){
 			result = jdbcTemplate.queryForMap(
 					"SELECT * FROM " + tabName + " where  id=? ", new Object[] { id });
-		} else {
+		} else if (tabName.equals("order_information")){
+			result = jdbcTemplate.queryForMap(
+					"SELECT * FROM " + tabName + " where worker_order_no=? and id=? ", new Object[] { orderNo, id });
+		}
+		else {
 			result = jdbcTemplate.queryForMap(
 					"SELECT * FROM " + tabName + " where order_base_id=? and id=? ", new Object[] { orderNo, id });
 		}

+ 114 - 8
src/main/java/com/zfire/jiasm/syncdata/upload/order/RepairProduceUploadList.java

@@ -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) {
         // 提取日志数据

+ 6 - 0
src/main/resources/mapper/OrderInformationNewMapper.xml

@@ -14,5 +14,11 @@
         where a.pid = #{request.id}
     </select>
 
+    <update id="upYdid" parameterType="com.zfire.jiasm.syncdata.parameter.OrderPar">
+        update order_information set ydid = #{request.ydid}
+        where id = #{request.id}
+    </update>
+
+
 
 </mapper>