yaozhixue %!s(int64=2) %!d(string=hai) anos
pai
achega
eb589fd935

+ 15 - 4
src/main/java/com/zfire/jiasm/syncdata/constant/OrderStatusEnum.java

@@ -76,10 +76,21 @@ public enum OrderStatusEnum {
      */
     INSTALL_STATUS_I10("A1309","已关闭工单"),
 
-    // 维修:B1=保存,B2=待分部派工,B3=待分中心派工,B4=待网点派工,B5=派审批改派,B6=待审批支援,B18=待服务人员处理,B41=服务人员报完工,B51=网点报完工,B61=分中心报完工,B71=分部报完工,B100=历史信息,B101=批量关闭,B102=正常关闭,B103=异常关闭',
-
-
-
+    REPAIR_STATUS_R1("B1","保存"),
+    REPAIR_STATUS_R2("B2","待分部派工"),
+    REPAIR_STATUS_R3("B3","待分中心派工"),
+    REPAIR_STATUS_R4("B4","待网点派工"),
+    REPAIR_STATUS_R5("B5","派审批改派"),
+    REPAIR_STATUS_R6("B6","待审批支援"),
+    REPAIR_STATUS_R7("B18","待服务人员处理"),// 20,21,22,23,24
+    REPAIR_STATUS_R8("B41","服务人员报完工"),
+    REPAIR_STATUS_R9("B51","网点报完工"),
+    REPAIR_STATUS_R10("B61","分中心报完工"),
+    REPAIR_STATUS_R11("B71","分部报完工"),
+    REPAIR_STATUS_R12("B100","历史信息"),
+    REPAIR_STATUS_R13("B101","批量关闭"),
+    REPAIR_STATUS_R14("B102","正常关闭"),
+    REPAIR_STATUS_R15("B103","异常关闭"),
 
 
     ;

+ 4 - 4
src/main/java/com/zfire/jiasm/syncdata/constant/OrderTypeEnum.java

@@ -18,22 +18,22 @@ public enum OrderTypeEnum {
     /**
      * 维修单
      */
-    INSTALL_STATUS_REPAIR("REPAIR","维修单"),
+    ORDER_TYPE_REPAIR("REPAIR","维修单"),
 
     /**
      * 退换货
      */
-    INSTALL_STATUS_RETURN_EXCHANGE("RETURN_EXCHANGE","退换货"),
+    ORDER_TYPE_RETURN_EXCHANGE("RETURN_EXCHANGE","退换货"),
 
     /**
      * 以旧换新
      */
-    INSTALL_STATUS_TRADE_IN("TRADE_IN","以旧换新"),
+    ORDER_TYPE_TRADE_IN("TRADE_IN","以旧换新"),
 
     /**
      * 维保工单
      */
-    INSTALL_STATUS_MAINTENANCE("MAINTENANCE","维保工单"),
+    ORDER_TYPE_MAINTENANCE("MAINTENANCE","维保工单"),
 
 
 

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

@@ -16,4 +16,6 @@ public interface RepairDownloadMapper extends BaseMapper<ItfTblAssignDownload> {
 
     @SqlParser(filter = true)
     OrderBase getOrderBase(@Param("request") OrderPar request);
+    @SqlParser(filter = true)
+    OrderBase getUpOrderBase(@Param("request") OrderPar request);
 }

+ 1 - 1
src/main/java/com/zfire/jiasm/syncdata/download/order/install/InstallBusiness.java

@@ -27,7 +27,7 @@ import java.util.stream.Collectors;
 
 /**
  * 格力品牌安装工单下载后落本地数据表
- * 3:落业务表
+ * 3:落业务表  TL_SynDataFrom_tbl_az_assign_lc_ls_batch
  *:4:修改下载主表处理结果
  */
 @Slf4j

+ 153 - 7
src/main/java/com/zfire/jiasm/syncdata/download/order/repair/RepairBusiness.java

@@ -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");
 

+ 2 - 0
src/main/java/com/zfire/jiasm/syncdata/service/OrderService.java

@@ -17,4 +17,6 @@ public interface OrderService extends IService<OrderBase> {
 
     void setParame(Brand brand, OrderBase orderBase);
 
+    void getPCAS(OrderBase orderBase);
+
 }

+ 3 - 2
src/main/java/com/zfire/jiasm/syncdata/service/impl/OrderServiceImpl.java

@@ -98,7 +98,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderBaseMapper, OrderBase> im
 
 
     @Override
-    public  void setParame(Brand brand, OrderBase orderBase) {
+    public void setParame(Brand brand, OrderBase orderBase) {
         orderBase.setBrandId(brand.getBrandId());
         orderBase.setBrandName(brand.getBrand());
         // 总部下来的工单统一为待接收状态-派工状态
@@ -159,7 +159,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderBaseMapper, OrderBase> im
         }
     }
 
-    private void getPCAS(OrderBase orderBase) {
+    @Override
+    public void getPCAS(OrderBase orderBase) {
         List<BrandLbsRelate> br;
         if (StringUtils.isNotEmpty(orderBase.getStreet())){
             Street street = streetService.lambdaQuery()

+ 7 - 3
src/main/java/com/zfire/jiasm/syncdata/upload/order/ProduceDataUploadList.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.zfire.jiasm.syncdata.base.BaseService;
 import com.zfire.jiasm.syncdata.constant.DictTypeEnum;
 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.*;
 import com.zfire.jiasm.syncdata.plus.entity.*;
@@ -193,19 +194,22 @@ public class ProduceDataUploadList {
                     // TL_PrePareSynDataby_fa_order_install_test
 
                     // 安装工单 基础表数据同步
-                    if (ojtutl.getTableName().equals("order_base") && ojtutl.getOrderType().equals("INSTALL")){
+                    if (ojtutl.getTableName().equals("order_base") &&
+                            ojtutl.getOrderType().equals(OrderTypeEnum.ORDER_TYPE_INSTALL.getCode())){
                         if (produceDataUploadList.orderBaseInstall(brand, ojtutl, CategoryRefmap)) {
                             continue;
                         }
                     }
 
                     // 安装工单操作明细 TL_PrePareSynDataby_fa_order_install_operating_log
-                    if (ojtutl.getTableName().equals("order_install_operating_log") && ojtutl.getOrderType().equals("INSTALL")){
+                    if (ojtutl.getTableName().equals("order_install_operating_log") &&
+                            ojtutl.getOrderType().equals(OrderTypeEnum.ORDER_TYPE_INSTALL.getCode())){
                         produceDataUploadList.getFkmx(brand, ojtutl);
                     }
 
                     // 安装工单用户改约明细 与操作明细最好放在一起,因表设计分开两天,所以独立开来处理
-                    if (ojtutl.getTableName().equals("order_re_appointment") && ojtutl.getOrderType().equals("INSTALL")){
+                    if (ojtutl.getTableName().equals("order_re_appointment") &&
+                            ojtutl.getOrderType().equals(OrderTypeEnum.ORDER_TYPE_INSTALL.getCode())){
                         getAppointment(ojtutl);
                     }
 

+ 3 - 1
src/main/java/com/zfire/jiasm/syncdata/upload/order/ProduceUploadList.java

@@ -1,6 +1,7 @@
 package com.zfire.jiasm.syncdata.upload.order;
 
 import com.zfire.jiasm.syncdata.constant.OrderStatusEnum;
+import com.zfire.jiasm.syncdata.constant.OrderTypeEnum;
 import com.zfire.jiasm.syncdata.plus.entity.*;
 import com.zfire.jiasm.syncdata.plus.service.*;
 import com.zfire.jiasm.syncdata.service.PrepareService;
@@ -97,7 +98,8 @@ public class ProduceUploadList {
                     // 数据上传任务表OutJiasmToGreeUploadTaskList 生成数据
 
                     // 安装工单处理
-                    if (itemTableName.equals("order_base") && itemOrderType.equals("INSTALL")){
+                    if (itemTableName.equals("order_base") &&
+                            itemOrderType.equals(OrderTypeEnum.ORDER_TYPE_INSTALL.getCode())){
                         produceUploadList.orderBaseProess(itemTableNameId, ojtgutls, item.getSynReqId(), itemTableName, itemOrderType);
                     }
                     // 安装工单操作日志

+ 37 - 12
src/main/resources/mapper/RepairDownloadMapper.xml

@@ -32,23 +32,48 @@
                  left join sys_dict_ref e on e.ref_dict_code=a.spid and e.brand_id = #{request.brandId} and e.dict_type='MAIN_TYPE'
                  left join sys_dict f on f.dict_type='SERVICE_CATEGORY' and f.dict_value='家电售后'
                  left join websit g on g.websit_id in
-                          (select websit_id from websit_order_sign
-                                  where brand_id = #{request.brandId} and brand_websit_id in
-                                           (select if((wxwdno='' or wxwdno is null),IFNULL(xjwdno,''),wxwdno) from itf_tbl_assign_download where syn_req_id = #{request.synReqId}))
+                                       (select websit_id from websit_order_sign
+                                        where brand_id = #{request.brandId} and brand_websit_id in
+                                                         (select if((wxwdno='' or wxwdno is null),IFNULL(xjwdno,''),wxwdno) from itf_tbl_assign_download where syn_req_id = #{request.synReqId}))
                  left join websit h on h.websit_id in
-                          (select websit_id from websit_order_sign
-                                  where brand_id = #{request.brandId} and brand_websit_id in
-                                           (select xjwdno from itf_tbl_assign_download where syn_req_id = #{request.synReqId}))
+                                       (select websit_id from websit_order_sign
+                                        where brand_id = #{request.brandId} and brand_websit_id in
+                                                         (select xjwdno from itf_tbl_assign_download where syn_req_id = #{request.synReqId}))
                  left join websit j on j.websit_id in
-                          (select websit_id from websit_order_sign
-                                  where brand_id = #{request.brandId} and brand_websit_id in
-                                           (select cjwdno from itf_tbl_assign_download where syn_req_id = #{request.synReqId}))
+                                       (select websit_id from websit_order_sign
+                                        where brand_id = #{request.brandId} and brand_websit_id in
+                                                         (select cjwdno from itf_tbl_assign_download where syn_req_id = #{request.synReqId}))
                  left join websit k on k.websit_id in
-                          (select websit_id from customer_information_websit
-                                   where brand_id = #{request.brandId} and ref_websit_id in
-                                           (select xswdno from itf_tbl_assign_download where syn_req_id = #{request.synReqId}))
+                                       (select websit_id from customer_information_websit
+                                        where brand_id = #{request.brandId} and ref_websit_id in
+                                                         (select xswdno from itf_tbl_assign_download where syn_req_id = #{request.synReqId}))
         where a.syn_req_id = #{request.synReqId};
     </select>
 
+    <select id="getUpOrderBase" parameterType="com.zfire.jiasm.syncdata.parameter.OrderPar" resultType="com.zfire.jiasm.syncdata.plus.entity.OrderBase">
+        select a.yhmc as user_name,a.quhao as area_code,
+               case a.yddh when '' then case a.dhhm when '' then '' else a.dhhm end  else a.yddh end as tel_phone,
+               a.email,a.yddh2 as user_mobile2,a.sfen as province,a.cshi as city,a.xian as area,a.xzhen as street,
+               a.dizi as address,a.beiz as remark,
+               case when a.spid=102 then '商用' when a.spid=109 then '商用' else '家用' end as service_flag,
+               b.sfzen as worker_id,b.wxgmc as worker_name,b.yddh as worker_mobile,
+               b.sfzen as worker_idcard,a.yxji as priority,a.gpsdzxx as gps_address,
+               case a.tsdengji when '一级投诉' then 'FIRST'
+                               when '二级投诉' then 'SECOND'
+                               when '三级投诉' then 'THIRD'
+                               when '特级投诉' then 'SUPER' else 'NO' end as complaint,
+               k.websit_id as sale_websit_id,k.websit_name as sale_websit_name,k.websit_id as sale_websit_sys_number,
+               a.wcsj as over_time,IFNULL(a.zjczsj,a.last_modified_date) as last_operator_time,
+               IFNULL(a.last_modified_date,a.zjczsj) as update_time,a.yhsx as user_attr,a.yhsxid as user_attr_id,
+               a.fjhm,a.gdhao as file_no,a.zxhao as seat_no,a.xjwdsj as rece_time,a.yhqwsmsj as appointment_time,
+               a.yhqwsmsj as expect_start_time,a.qwsmjssj as expect_end_time,a.fjhm
+        from itf_tbl_assign_download a
+                 left join itf_tbl_wangdian_wxg_download b on b.wxgid=a.wxrenid and b.wdno=a.wxwdno
+                 left join websit k on k.websit_id in
+                                       (select websit_id from customer_information_websit
+                                        where brand_id = #{request.brandId} and ref_websit_id in
+                                                         (select xswdno from itf_tbl_assign_download where syn_req_id = #{request.synReqId}))
+    </select>
+
 
 </mapper>