|
@@ -17,6 +17,8 @@ import com.qmth.sop.business.mapper.TBCrmMapper;
|
|
import com.qmth.sop.business.service.*;
|
|
import com.qmth.sop.business.service.*;
|
|
import com.qmth.sop.business.sync.FxxkApiUtils;
|
|
import com.qmth.sop.business.sync.FxxkApiUtils;
|
|
import com.qmth.sop.business.sync.been.fxxk.FxxkCrm;
|
|
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.contant.SystemConstant;
|
|
import com.qmth.sop.common.enums.*;
|
|
import com.qmth.sop.common.enums.*;
|
|
import com.qmth.sop.common.util.ResultUtil;
|
|
import com.qmth.sop.common.util.ResultUtil;
|
|
@@ -79,6 +81,9 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
@Resource
|
|
@Resource
|
|
private TBCrmDetailService tbCrmDetailService;
|
|
private TBCrmDetailService tbCrmDetailService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private SysMessageService sysMessageService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public IPage<CrmServiceResult> findServiceScopePage(Long serviceUnitId, String city, ProductTypeEnum productType,
|
|
public IPage<CrmServiceResult> findServiceScopePage(Long serviceUnitId, String city, ProductTypeEnum productType,
|
|
String customName, Boolean bindStatus, Integer pageNumber, Integer pageSize) {
|
|
String customName, Boolean bindStatus, Integer pageNumber, Integer pageSize) {
|
|
@@ -447,6 +452,8 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
int successCount = 0;
|
|
int successCount = 0;
|
|
// 已有的派单数(派单号相同不重新同步)
|
|
// 已有的派单数(派单号相同不重新同步)
|
|
int alreadyCount = 0;
|
|
int alreadyCount = 0;
|
|
|
|
+ // 缺失客户信息的客户
|
|
|
|
+ List<String> customMissList = new ArrayList<>();
|
|
try {
|
|
try {
|
|
for (FxxkCrm fxxkCrm : fxxkCrmList) {
|
|
for (FxxkCrm fxxkCrm : fxxkCrmList) {
|
|
String basicInfoMissingError = "";
|
|
String basicInfoMissingError = "";
|
|
@@ -463,6 +470,7 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
String customName = fxxkCrm.getCustomName();
|
|
String customName = fxxkCrm.getCustomName();
|
|
String customProvince = fxxkCrm.getCustomProvince();
|
|
String customProvince = fxxkCrm.getCustomProvince();
|
|
String customCity = fxxkCrm.getCustomCity();
|
|
String customCity = fxxkCrm.getCustomCity();
|
|
|
|
+ String customArea = fxxkCrm.getCustomArea();
|
|
String customAddress = fxxkCrm.getCustomAddress();
|
|
String customAddress = fxxkCrm.getCustomAddress();
|
|
Long examStartTime = fxxkCrm.getExamStartTime();
|
|
Long examStartTime = fxxkCrm.getExamStartTime();
|
|
Long examEndTime = fxxkCrm.getExamEndTime();
|
|
Long examEndTime = fxxkCrm.getExamEndTime();
|
|
@@ -485,12 +493,6 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
if (customName == null || customName.length() == 0) {
|
|
if (customName == null || customName.length() == 0) {
|
|
basicInfoMissingError = basicInfoMissingError + "缺少客户名称";
|
|
basicInfoMissingError = basicInfoMissingError + "缺少客户名称";
|
|
}
|
|
}
|
|
- if (customProvince == null || customProvince.length() == 0) {
|
|
|
|
- basicInfoMissingError = basicInfoMissingError + "缺少客户所在省份";
|
|
|
|
- }
|
|
|
|
- if (customCity == null || customCity.length() == 0) {
|
|
|
|
- basicInfoMissingError = basicInfoMissingError + "缺少客户所在城市";
|
|
|
|
- }
|
|
|
|
if (examStartTime == null || examStartTime == 0) {
|
|
if (examStartTime == null || examStartTime == 0) {
|
|
basicInfoMissingError = basicInfoMissingError + "缺少考试开始时间";
|
|
basicInfoMissingError = basicInfoMissingError + "缺少考试开始时间";
|
|
}
|
|
}
|
|
@@ -523,23 +525,35 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- // 客户名称校验
|
|
|
|
|
|
+ // 系统客户校验
|
|
Long customId = null;
|
|
Long customId = null;
|
|
List<SysCustom> sysCustomList = sysCustomService.list(
|
|
List<SysCustom> sysCustomList = sysCustomService.list(
|
|
new QueryWrapper<SysCustom>().lambda().eq(SysCustom::getName, customName).eq(SysCustom::getType, customType));
|
|
new QueryWrapper<SysCustom>().lambda().eq(SysCustom::getName, customName).eq(SysCustom::getType, customType));
|
|
|
|
|
|
if (CollectionUtils.isEmpty(sysCustomList)) {
|
|
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) {
|
|
} else if (sysCustomList.size() > 1) {
|
|
throw ExceptionResultEnum.ERROR.exception("客户数据异常 :客户名称-客户类型 不唯一\n");
|
|
throw ExceptionResultEnum.ERROR.exception("客户数据异常 :客户名称-客户类型 不唯一\n");
|
|
} else {
|
|
} else {
|
|
@@ -586,6 +600,32 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
if (errorMsgList.size() > 0) {
|
|
if (errorMsgList.size() > 0) {
|
|
errorMsg = String.join(";\n", errorMsgList);
|
|
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.SUCCESS, successCount);
|
|
map.put(SystemConstant.RESULT_ERROR, totalCount - successCount - alreadyCount);
|
|
map.put(SystemConstant.RESULT_ERROR, totalCount - successCount - alreadyCount);
|
|
map.put(SystemConstant.ALREADY_COUNT, alreadyCount);
|
|
map.put(SystemConstant.ALREADY_COUNT, alreadyCount);
|