|
@@ -22,6 +22,8 @@ import com.qmth.sop.common.enums.*;
|
|
|
import com.qmth.sop.common.util.ResultUtil;
|
|
|
import com.qmth.sop.common.util.ServletUtil;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.dao.DuplicateKeyException;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -42,6 +44,8 @@ import java.util.stream.Stream;
|
|
|
@Service
|
|
|
public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements TBCrmService {
|
|
|
|
|
|
+ private final static Logger log = LoggerFactory.getLogger(TBCrmServiceImpl.class);
|
|
|
+
|
|
|
@Resource
|
|
|
private TBServiceService tbServiceService;
|
|
|
|
|
@@ -69,6 +73,12 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
|
@Resource
|
|
|
private TBProductService tbProductService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private SequenceService sequenceService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private TBCrmDetailService tbCrmDetailService;
|
|
|
+
|
|
|
@Override
|
|
|
public IPage<CrmServiceResult> findServiceScopePage(Long serviceUnitId, String city, ProductTypeEnum productType,
|
|
|
String customName, Boolean bindStatus, Integer pageNumber, Integer pageSize) {
|
|
@@ -278,54 +288,38 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public CrmProjectResult findCrmProjectBySopNoOrCrmNo(String sopNo, String crmNo) {
|
|
|
+ public CrmProjectResult findCrmProjectInfo(String sopNo, Long crmDetailId,String crmNo) {
|
|
|
CrmProjectResult result = new CrmProjectResult();
|
|
|
- List<CrmProjectResult> crmProjectResults;
|
|
|
- if (sopNo != null && sopNo.length() > 0) {
|
|
|
- crmProjectResults = this.baseMapper.findCrmProjectBySopNo(sopNo);
|
|
|
+ TBCrmDetail tbCrmDetail = null;
|
|
|
+ if (crmDetailId != null && crmDetailId > 0) {
|
|
|
+ tbCrmDetail = tbCrmDetailService.getById(crmDetailId);
|
|
|
+ } else if (sopNo != null && sopNo.length() > 0) {
|
|
|
+ tbCrmDetail = tbCrmDetailService.getOne(
|
|
|
+ new QueryWrapper<TBCrmDetail>().lambda().eq(TBCrmDetail::getSopNo, sopNo).last(SystemConstant.LIMIT1));
|
|
|
} else if (crmNo != null && crmNo.length() > 0) {
|
|
|
- crmProjectResults = this.baseMapper.findCrmProjectByCrmNo(crmNo);
|
|
|
- } else {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("缺少sop单号和crm单号");
|
|
|
- }
|
|
|
- if (CollectionUtils.isNotEmpty(crmProjectResults)) {
|
|
|
- if (crmProjectResults.size() > 1) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("根据sop号找到多个与之对应的派单异常");
|
|
|
+ List<CrmProjectResult> crmProjectResultList = this.baseMapper.findCrmProjectByCrmNo(crmNo);
|
|
|
+ if (CollectionUtils.isNotEmpty(crmProjectResultList)) {
|
|
|
+ return crmProjectResultList.get(0);
|
|
|
}
|
|
|
- CrmProjectResult crmProjectResult = crmProjectResults.get(0);
|
|
|
- String tbCrmNo = crmProjectResult.getCrmNo();
|
|
|
-
|
|
|
- List<TBUserArchivesAllocation> archivesAllocationList = tbUserArchivesAllocationService.list(
|
|
|
- new QueryWrapper<TBUserArchivesAllocation>().lambda().eq(TBUserArchivesAllocation::getCrmNo, tbCrmNo));
|
|
|
-
|
|
|
- RoleResult effectRole = sysRoleService.findRoleInfoByArchivesType(RoleTypeEnum.EFFECT_ENGINEER);
|
|
|
- Long effectRoleId = effectRole.getRoleId();
|
|
|
- // TODO: 2024/5/14 查询派单分配信息修改 -czx
|
|
|
-// List<UserArchivesDto> effectEngineerList = archivesAllocationList.stream()
|
|
|
-// .filter(e -> effectRoleId.equals(e.getRoleId())).flatMap(e -> {
|
|
|
-// UserArchivesDto dto = new UserArchivesDto();
|
|
|
-// Long userArchivesId = e.getArchivesId();
|
|
|
-// dto.setUserArchivesId(userArchivesId);
|
|
|
-// dto.setUserId(e.getUserId());
|
|
|
-// dto.setName(tbUserArchivesService.getById(userArchivesId).getName());
|
|
|
-// return Stream.of(dto);
|
|
|
-// }).collect(Collectors.toList());
|
|
|
-//
|
|
|
-// RoleResult assistant = sysRoleService.findRoleInfoByArchivesType(RoleTypeEnum.ASSISTANT_ENGINEER);
|
|
|
-// Long assistantRoleId = assistant.getRoleId();
|
|
|
-// List<UserArchivesDto> assistantEngineerList = archivesAllocationList.stream()
|
|
|
-// .filter(e -> assistantRoleId.equals(e.getRoleId())).flatMap(e -> {
|
|
|
-// UserArchivesDto dto = new UserArchivesDto();
|
|
|
-// Long userArchivesId = e.getArchivesId();
|
|
|
-// dto.setUserArchivesId(userArchivesId);
|
|
|
-// dto.setUserId(e.getUserId());
|
|
|
-// dto.setName(tbUserArchivesService.getById(userArchivesId).getName());
|
|
|
-// return Stream.of(dto);
|
|
|
-// }).collect(Collectors.toList());
|
|
|
-// crmProjectResult.setEffectEngineerList(effectEngineerList);
|
|
|
-// crmProjectResult.setAssistantEngineerList(assistantEngineerList);
|
|
|
- result = crmProjectResult;
|
|
|
}
|
|
|
+ if (Objects.isNull(tbCrmDetail)) {
|
|
|
+ log.error(String.format("未找到对应的派单详情, sopNo[%s], crmDetailId[%s]", sopNo, crmDetailId));
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("未找到对应的派单详情");
|
|
|
+ }
|
|
|
+ crmNo = tbCrmDetail.getCrmNo();
|
|
|
+ crmDetailId = tbCrmDetail.getId();
|
|
|
+ List<CrmProjectResult> crmProjectResultList = this.baseMapper.findCrmProjectByCrmNo(crmNo);
|
|
|
+ if (CollectionUtils.isNotEmpty(crmProjectResultList)) {
|
|
|
+ result = crmProjectResultList.get(0);
|
|
|
+ }
|
|
|
+ List<TBUserArchivesAllocation> datasource = tbUserArchivesAllocationService.list(
|
|
|
+ new QueryWrapper<TBUserArchivesAllocation>().lambda().eq(TBUserArchivesAllocation::getCrmDetailId, crmDetailId));
|
|
|
+ List<UserArchivesDto> regionCoordinatorList = this.buildUserArchivesDtoList(datasource, SopRoleTypeEnum.REGION_COORDINATOR);
|
|
|
+ List<UserArchivesDto> projectManagerList = this.buildUserArchivesDtoList(datasource, SopRoleTypeEnum.PROJECT_MANAGER);
|
|
|
+ List<UserArchivesDto> engineerList = this.buildUserArchivesDtoList(datasource, SopRoleTypeEnum.ENGINEER);
|
|
|
+ result.setRegionCoordinatorList(regionCoordinatorList);
|
|
|
+ result.setProjectManagerList(projectManagerList);
|
|
|
+ result.setEngineerList(engineerList);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -467,6 +461,9 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
|
String managerMobileNumber = fxxkCrm.getManagerMobileNumber();
|
|
|
ProductTypeEnum customType = fxxkCrm.getCustomType();
|
|
|
String customName = fxxkCrm.getCustomName();
|
|
|
+ String customProvince = fxxkCrm.getCustomProvince();
|
|
|
+ String customCity = fxxkCrm.getCustomCity();
|
|
|
+ String customAddress = fxxkCrm.getCustomAddress();
|
|
|
Long examStartTime = fxxkCrm.getExamStartTime();
|
|
|
Long examEndTime = fxxkCrm.getExamEndTime();
|
|
|
|
|
@@ -488,6 +485,12 @@ 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,11 +526,20 @@ 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).eq(SysCustom::getEnable, true));
|
|
|
+ new QueryWrapper<SysCustom>().lambda().eq(SysCustom::getName, customName).eq(SysCustom::getType, customType));
|
|
|
|
|
|
if (CollectionUtils.isEmpty(sysCustomList)) {
|
|
|
- matchInfoError = matchInfoError + String.format("纷享销客中的客户[%s(%s)]在质控平台不存在或已禁用(客户名称 + 客户类型)\n",
|
|
|
- customName, customType.getTitle());
|
|
|
+ // 质控平台不存在该类型客户 -> 新增一个客户
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.format("客户[%s]不存在", sysCustom.getName()));
|
|
|
} else if (sysCustomList.size() > 1) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("客户数据异常 :客户名称-客户类型 不唯一\n");
|
|
|
} else {
|
|
@@ -583,4 +595,22 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
|
throw ExceptionResultEnum.ERROR.exception(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据sop用户身份类型构建用户档案信息
|
|
|
+ * @param datasource 数据源
|
|
|
+ * @param sopRoleTypeEnum 身份
|
|
|
+ * @return 用户档案信息
|
|
|
+ */
|
|
|
+ private List<UserArchivesDto> buildUserArchivesDtoList(List<TBUserArchivesAllocation> datasource, SopRoleTypeEnum sopRoleTypeEnum){
|
|
|
+ return datasource.stream()
|
|
|
+ .filter(e -> sopRoleTypeEnum.equals(e.getSopRoleType())).flatMap(e -> {
|
|
|
+ UserArchivesDto dto = new UserArchivesDto();
|
|
|
+ Long userArchivesId = e.getArchivesId();
|
|
|
+ dto.setUserArchivesId(userArchivesId);
|
|
|
+ dto.setUserId(e.getUserId());
|
|
|
+ dto.setName(tbUserArchivesService.getById(userArchivesId).getName());
|
|
|
+ return Stream.of(dto);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
}
|