Эх сурвалжийг харах

add:fxxk同步派单更改

caozixuan 1 жил өмнө
parent
commit
1b6878afa5

+ 57 - 17
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBCrmServiceImpl.java

@@ -17,6 +17,8 @@ import com.qmth.sop.business.mapper.TBCrmMapper;
 import com.qmth.sop.business.service.*;
 import com.qmth.sop.business.sync.FxxkApiUtils;
 import com.qmth.sop.business.sync.been.fxxk.FxxkCrm;
+import com.qmth.sop.business.util.SmsSendUtil;
+import com.qmth.sop.common.contant.SpringContextHolder;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.*;
 import com.qmth.sop.common.util.ResultUtil;
@@ -79,6 +81,9 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
     @Resource
     private TBCrmDetailService tbCrmDetailService;
 
+    @Resource
+    private SysMessageService sysMessageService;
+
     @Override
     public IPage<CrmServiceResult> findServiceScopePage(Long serviceUnitId, String city, ProductTypeEnum productType,
             String customName, Boolean bindStatus, Integer pageNumber, Integer pageSize) {
@@ -447,6 +452,8 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
         int successCount = 0;
         // 已有的派单数(派单号相同不重新同步)
         int alreadyCount = 0;
+        // 缺失客户信息的客户
+        List<String> customMissList = new ArrayList<>();
         try {
             for (FxxkCrm fxxkCrm : fxxkCrmList) {
                 String basicInfoMissingError = "";
@@ -463,6 +470,7 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
                 String customName = fxxkCrm.getCustomName();
                 String customProvince = fxxkCrm.getCustomProvince();
                 String customCity = fxxkCrm.getCustomCity();
+                String customArea = fxxkCrm.getCustomArea();
                 String customAddress = fxxkCrm.getCustomAddress();
                 Long examStartTime = fxxkCrm.getExamStartTime();
                 Long examEndTime = fxxkCrm.getExamEndTime();
@@ -485,12 +493,6 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
                 if (customName == null || customName.length() == 0) {
                     basicInfoMissingError = basicInfoMissingError + "缺少客户名称";
                 }
-                if (customProvince == null || customProvince.length() == 0) {
-                    basicInfoMissingError = basicInfoMissingError + "缺少客户所在省份";
-                }
-                if (customCity == null || customCity.length() == 0) {
-                    basicInfoMissingError = basicInfoMissingError + "缺少客户所在城市";
-                }
                 if (examStartTime == null || examStartTime == 0) {
                     basicInfoMissingError = basicInfoMissingError + "缺少考试开始时间";
                 }
@@ -523,23 +525,35 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
                         }
                     }
 
-                    // 客户名称校验
+                    // 系统客户校验
                     Long customId = null;
                     List<SysCustom> sysCustomList = sysCustomService.list(
                             new QueryWrapper<SysCustom>().lambda().eq(SysCustom::getName, customName).eq(SysCustom::getType, customType));
 
                     if (CollectionUtils.isEmpty(sysCustomList)) {
-                        // 质控平台不存在该类型客户 -> 新增一个客户
-                        SysCustom sysCustom = new SysCustom();
-                        sysCustom.setName(customName);
-                        sysCustom.setCode(sequenceService.createSerialNo(SequenceEnum.SYS_CUSTOM_CODE));
-                        sysCustom.setType(customType);
-                        sysCustom.setProvince(customProvince);
-                        sysCustom.setCity(customCity);
-                        if (customAddress != null && customAddress.length() > 0) {
-                            sysCustom.setAddress(customAddress);
+                        if (customProvince == null || customProvince.length() == 0 || customCity == null || customCity.length() == 0) {
+                            // 客户不存在且客户信息缺失
+                            String customMissKey = customName + "-" + customType;
+                            if (!customMissList.contains(customMissKey)) {
+                                customMissList.add(customMissKey);
+                            }
+                        } else {
+                            // 质控平台不存在该类型客户 -> 新增一个客户
+                            SysCustom sysCustom = new SysCustom();
+                            sysCustom.setName(customName);
+                            sysCustom.setCode(sequenceService.createSerialNo(SequenceEnum.SYS_CUSTOM_CODE));
+                            sysCustom.setType(customType);
+                            sysCustom.setProvince(customProvince);
+                            sysCustom.setCity(customCity);
+                            if (customArea != null && customArea.length() > 0) {
+                                sysCustom.setArea(customArea);
+                            }
+                            if (customAddress != null && customAddress.length() > 0) {
+                                sysCustom.setAddress(customAddress);
+                            }
+                            sysCustom.insertInfo(requestUser.getId());
+                            sysCustomService.save(sysCustom);
                         }
-                        throw ExceptionResultEnum.ERROR.exception(String.format("客户[%s]不存在", sysCustom.getName()));
                     } else if (sysCustomList.size() > 1) {
                         throw ExceptionResultEnum.ERROR.exception("客户数据异常 :客户名称-客户类型 不唯一\n");
                     } else {
@@ -586,6 +600,32 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
             if (errorMsgList.size() > 0) {
                 errorMsg = String.join(";\n", errorMsgList);
             }
+            if (CollectionUtils.isNotEmpty(customMissList)) {
+                // 发送短信
+                SmsSendUtil smsSendUtil = SpringContextHolder.getBean(SmsSendUtil.class);
+                String configKey = SystemConstant.SMS_CUSTOM_INFO_MISSING_REMIND_CODE;
+                String mobileNumber = "18903719928";
+                SysUser signature = sysUserService.getOne(
+                        new QueryWrapper<SysUser>().lambda().eq(SysUser::getMobileNumber, mobileNumber).last(SystemConstant.LIMIT1));
+                if (Objects.nonNull(signature)) {
+                    String userName = signature.getRealName();
+                    String customInfo = String.join(";", customMissList);
+                    Map<String, Object> templateParam = new HashMap<>();
+                    templateParam.put("userName", userName);
+                    templateParam.put("customInfo", customInfo);
+
+                    String content = MessageEnum.NOTICE_OF_CUSTOM_MISSING_REMIND.getTemplate()
+                            .replaceAll("\\$\\{userName\\}", userName).replaceAll("\\$\\{customInfo\\}", customInfo);
+                    SysMessage sysMessage = new SysMessage(null, null, MessageTypeEnum.CUSTOM_INFO_MISSING, null, null,
+                            null, content, null);
+
+                    //发送消息
+                    sysMessageService.saveSysMessage(Collections.singletonList(sysMessage));
+
+                    //发送短信
+                    smsSendUtil.sendSms(mobileNumber, configKey, templateParam);
+                }
+            }
             map.put(SystemConstant.SUCCESS, successCount);
             map.put(SystemConstant.RESULT_ERROR, totalCount - successCount - alreadyCount);
             map.put(SystemConstant.ALREADY_COUNT, alreadyCount);

+ 2 - 0
sop-business/src/main/java/com/qmth/sop/business/sync/FxxkApiUtils.java

@@ -304,6 +304,7 @@ public class FxxkApiUtils {
                 String customCounty = cell.getString("field_O0l25__c__r");
                 String customProvince = cell.getString("field_Nc2M6__c__r");
                 String customCity = cell.getString("field_270tB__c__r");
+                String customArea = cell.getString("field_SFOSi__c__r");
                 String customAddress = cell.getString("field_KmXg2__c");
 
                 Long examStartTime = cell.getLong("field_Fl84j__c");
@@ -334,6 +335,7 @@ public class FxxkApiUtils {
                 fxxkCrm.setCustomCounty(customCounty);
                 fxxkCrm.setCustomProvince(customProvince);
                 fxxkCrm.setCustomCity(customCity);
+                fxxkCrm.setCustomArea(customArea);
                 fxxkCrm.setCustomAddress(customAddress);
                 fxxkCrm.setExamStartTime(examStartTime);
                 fxxkCrm.setExamEndTime(examEndTime);

+ 10 - 0
sop-business/src/main/java/com/qmth/sop/business/sync/been/fxxk/FxxkCrm.java

@@ -34,6 +34,8 @@ public class FxxkCrm {
     private String customProvince;
     @ApiModelProperty("城市")
     private String customCity;
+    @ApiModelProperty("区域")
+    private String customArea;
     @ApiModelProperty("详细地址")
     private String customAddress;
 
@@ -125,6 +127,14 @@ public class FxxkCrm {
         this.customCity = customCity;
     }
 
+    public String getCustomArea() {
+        return customArea;
+    }
+
+    public void setCustomArea(String customArea) {
+        this.customArea = customArea;
+    }
+
     public String getCustomAddress() {
         return customAddress;
     }

+ 4 - 1
sop-business/src/main/resources/db/log/caozixuan_update_log.sql

@@ -45,4 +45,7 @@ update t_b_ding set sop_role_type = 'ENGINEER' where sop_role_type = '';
 update t_b_user_archives_allocation set sop_role_type = 'ENGINEER' where sop_role_type = '';
 update sys_ding_obj set sop_role_type = 'ENGINEER' where sop_role_type = '';
 
-INSERT INTO sequence (name, current_value, increment) VALUES ('sysCustomCode', '1', '1');
+INSERT INTO sequence (name, current_value, increment) VALUES ('sysCustomCode', '1', '1');
+
+-- 2024-05-16
+INSERT INTO sys_config (id, config_key, config_name, config_value, enable, sort, create_id) VALUES ('39', 'sms.custom.info.missing.remind.code', '客户信息缺失通知', 'SMS_467015006', '1', '1', '1');

+ 1 - 0
sop-common/src/main/java/com/qmth/sop/common/contant/SystemConstant.java

@@ -204,6 +204,7 @@ public class SystemConstant {
     public static final String SMS_FLOW_DING_EXCEPTION_FINISH_CODE = "sms.flow.ding.exception.finish.code";
     public static final String SMS_SOP_AFTER_REMIND_CODE = "sms.sop.after.remind.code";
     public static final String SMS_VIOLATION_REMIND_CODE = "sms.violation.remind.code";
+    public static final String SMS_CUSTOM_INFO_MISSING_REMIND_CODE = "sms.custom.info.missing.remind.code";
 //    public static final String WXAPP_APP_ID = "wxapp.appid";
 //    public static final String WXAPP_REQUEST_URL = "wxapp.request.url";
 //    public static final String WXAPP_PHONE_BIND_NEW_URL = "wxapp.phone.bind.new.url";

+ 3 - 1
sop-common/src/main/java/com/qmth/sop/common/enums/MessageEnum.java

@@ -21,7 +21,9 @@ public enum MessageEnum {
 
     NOTICE_OF_SOP_DONE_REMIND("教务处/研究生SOP提前提醒通知", "${userName}您好,[${serviceName}]的[${customName}]SOP有[${flowName}]待办任务即将到期,请及时处理!"),
 
-    NOTICE_OF_SYSTEM_REMIND("系统通知公告通知", "${userName}您好,您收到标题为“${title}”的通知公告,请及时上线查阅!");
+    NOTICE_OF_SYSTEM_REMIND("系统通知公告通知", "${userName}您好,您收到标题为“${title}”的通知公告,请及时上线查阅!"),
+
+    NOTICE_OF_CUSTOM_MISSING_REMIND("客户信息缺失通知","${userName}您好,客户${customInfo}在sop质控平台信息不存在,请增加客户信息");
 
     MessageEnum(String name, String template) {
         this.name = name;

+ 2 - 0
sop-common/src/main/java/com/qmth/sop/common/enums/MessageTypeEnum.java

@@ -25,6 +25,8 @@ public enum MessageTypeEnum {
 
     SYSTEM_PLAN_CHANGE("系统计划变更提醒"),
 
+    CUSTOM_INFO_MISSING("客户信息缺失提醒"),
+
     SYSTEM("系统公告");
 
     private String title;