|
@@ -99,9 +99,16 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
}
|
|
}
|
|
}
|
|
}
|
|
List<TBCrm> tbCrmList = this.listByIds(crmIdList);
|
|
List<TBCrm> tbCrmList = this.listByIds(crmIdList);
|
|
|
|
+ // 派单调配资源变换
|
|
|
|
+ for (TBCrm dbCrm : tbCrmList) {
|
|
|
|
+ tbUserArchivesAllocationService.crmReBindServiceUnit(dbCrm.getCrmNo(), dbCrm.getServiceId(), serviceUnitId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 绑定服务单元
|
|
tbCrmList = tbCrmList.stream().peek(e -> e.setServiceId(serviceUnitId)).collect(Collectors.toList());
|
|
tbCrmList = tbCrmList.stream().peek(e -> e.setServiceId(serviceUnitId)).collect(Collectors.toList());
|
|
this.updateBatchById(tbCrmList);
|
|
this.updateBatchById(tbCrmList);
|
|
|
|
|
|
|
|
+ // 自动匹配派单对应的大区经理
|
|
tbCrmList = tbCrmList.stream().peek(e -> {
|
|
tbCrmList = tbCrmList.stream().peek(e -> {
|
|
Long regionLeaderId = tbServiceRegionService.findRegionLeader(serviceUnitId, e.getCrmNo());
|
|
Long regionLeaderId = tbServiceRegionService.findRegionLeader(serviceUnitId, e.getCrmNo());
|
|
if (Objects.nonNull(regionLeaderId)) {
|
|
if (Objects.nonNull(regionLeaderId)) {
|
|
@@ -132,6 +139,7 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
.set(TBCrm::getLeadId, null)
|
|
.set(TBCrm::getLeadId, null)
|
|
.eq(TBCrm::getId, tbCrm.getId());
|
|
.eq(TBCrm::getId, tbCrm.getId());
|
|
this.update(updateWrapper);
|
|
this.update(updateWrapper);
|
|
|
|
+ tbUserArchivesAllocationService.crmReBindServiceUnit(tbCrm.getCrmNo(), serviceUnitId, null);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -180,6 +188,7 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
@Transactional
|
|
@Transactional
|
|
public Boolean saveTBCrm(TBCrm tBCrm) {
|
|
public Boolean saveTBCrm(TBCrm tBCrm) {
|
|
try {
|
|
try {
|
|
|
|
+ Long oldServiceUnitId = null;
|
|
tBCrm.setSync(false);
|
|
tBCrm.setSync(false);
|
|
tBCrm.setEnable(true);
|
|
tBCrm.setEnable(true);
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
@@ -187,6 +196,11 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
tBCrm.setStatus(CrmStatusEnum.UN_PUBLISH);
|
|
tBCrm.setStatus(CrmStatusEnum.UN_PUBLISH);
|
|
tBCrm.insertInfo(sysUser.getId());
|
|
tBCrm.insertInfo(sysUser.getId());
|
|
} else { // 修改
|
|
} else { // 修改
|
|
|
|
+ TBCrm dbTBCrm = this.getById(tBCrm.getId());
|
|
|
|
+ if (Objects.isNull(dbTBCrm)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("未找到派单信息");
|
|
|
|
+ }
|
|
|
|
+ oldServiceUnitId = dbTBCrm.getServiceId();
|
|
tBCrm.updateInfo(sysUser.getId());
|
|
tBCrm.updateInfo(sysUser.getId());
|
|
}
|
|
}
|
|
boolean result = saveOrUpdate(tBCrm);
|
|
boolean result = saveOrUpdate(tBCrm);
|
|
@@ -194,9 +208,10 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
if (result && serviceId != null && serviceId > 0) {
|
|
if (result && serviceId != null && serviceId > 0) {
|
|
Long regionLeaderId = tbServiceRegionService.findRegionLeader(serviceId, tBCrm.getCrmNo());
|
|
Long regionLeaderId = tbServiceRegionService.findRegionLeader(serviceId, tBCrm.getCrmNo());
|
|
UpdateWrapper<TBCrm> updateWrapper = new UpdateWrapper<>();
|
|
UpdateWrapper<TBCrm> updateWrapper = new UpdateWrapper<>();
|
|
- updateWrapper.lambda().eq(TBCrm::getId,tBCrm.getId()).set(TBCrm::getLeadId,regionLeaderId);
|
|
|
|
|
|
+ updateWrapper.lambda().eq(TBCrm::getId, tBCrm.getId()).set(TBCrm::getLeadId, regionLeaderId);
|
|
this.update(updateWrapper);
|
|
this.update(updateWrapper);
|
|
}
|
|
}
|
|
|
|
+ tbUserArchivesAllocationService.crmReBindServiceUnit(tBCrm.getCrmNo(), oldServiceUnitId, serviceId);
|
|
return result;
|
|
return result;
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
if (e instanceof DuplicateKeyException) {
|
|
if (e instanceof DuplicateKeyException) {
|
|
@@ -247,7 +262,14 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
//批量修改
|
|
//批量修改
|
|
List<Long> crmIdList = Arrays.stream(crmIds).boxed().collect(Collectors.toList());
|
|
List<Long> crmIdList = Arrays.stream(crmIds).boxed().collect(Collectors.toList());
|
|
List<TBCrm> tbCrmList = this.listByIds(crmIdList);
|
|
List<TBCrm> tbCrmList = this.listByIds(crmIdList);
|
|
- tbCrmList.forEach(e -> e.setEnable(false));
|
|
|
|
|
|
+ for (TBCrm tbCrm : tbCrmList) {
|
|
|
|
+ Long serviceId = tbCrm.getServiceId();
|
|
|
|
+ if (serviceId != null && serviceId > 0){
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.format("已经划分的派单[%s]不能作废",tbCrm.getCrmNo()));
|
|
|
|
+ }
|
|
|
|
+ tbCrm.setEnable(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
return this.updateBatchById(tbCrmList);
|
|
return this.updateBatchById(tbCrmList);
|
|
}
|
|
}
|
|
|
|
|