|
|
@@ -42,8 +42,9 @@ import com.xunmei.core.access.service.ITMonitoringRetrievalPlanService;
|
|
|
import com.xunmei.core.access.service.ITMonitoringRetrievalPlanToExecOrgService;
|
|
|
import com.xunmei.core.access.vo.AccessPdfVO;
|
|
|
import com.xunmei.core.access.vo.TMonitoringRetrievalPlanVO;
|
|
|
-import com.xunmei.core.compense.dto.CompensateDto;
|
|
|
+import com.xunmei.common.core.domain.compensate.dto.CompensateDto;
|
|
|
import com.xunmei.core.compense.interfaces.CompensateService;
|
|
|
+import com.xunmei.core.compense.service.ICoreCompensateLogService;
|
|
|
import com.xunmei.core.registerbook.service.ICoreRegisterBookPdfService;
|
|
|
import com.xunmei.core.reminder.service.ICoreReminderConfigurationService;
|
|
|
import com.xunmei.core.reminder.service.ICoreReminderScheduleService;
|
|
|
@@ -129,6 +130,8 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
@Autowired
|
|
|
@Lazy
|
|
|
ICoreReminderScheduleService reminderScheduleService;
|
|
|
+ @Autowired
|
|
|
+ ICoreCompensateLogService compensateLogService;
|
|
|
|
|
|
@Override
|
|
|
public TableDataInfo selectPage(TMonitoringRetrievalPlan tMonitoringRetrievalPlan) {
|
|
|
@@ -592,7 +595,7 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
public int distribute(Long id, Boolean immediateEffect) throws ParseException {
|
|
|
//查询
|
|
|
TMonitoringRetrievalPlan publishPlan = tMonitoringRetrievalPlanMapper.selectById(id);
|
|
|
- Integer oldPlanStatus=publishPlan.getPlanStatus();
|
|
|
+ Integer oldPlanStatus = publishPlan.getPlanStatus();
|
|
|
publishPlan.setImmediately(immediateEffect);
|
|
|
publishPlan.setIsDistribute("1");
|
|
|
publishPlan.setPlanStatus(1);
|
|
|
@@ -615,7 +618,7 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
|
|
|
|
|
|
final CompletableFuture<List<TMonitoringRetrievalPlan>> planListFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
- return getNeedCreateTaskPlans(loginUserOrg, publishPlan,oldPlanStatus);
|
|
|
+ return getNeedCreateTaskPlans(loginUserOrg, publishPlan, oldPlanStatus);
|
|
|
}, threadPoolTaskExecutor);
|
|
|
|
|
|
planListFuture.thenAcceptAsync((result) -> {
|
|
|
@@ -632,7 +635,7 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
return i;
|
|
|
}
|
|
|
|
|
|
- private List<TMonitoringRetrievalPlan> getNeedCreateTaskPlans(SysOrg loginUserOrg, TMonitoringRetrievalPlan publishPlan,Integer oldPlanStatus) {
|
|
|
+ private List<TMonitoringRetrievalPlan> getNeedCreateTaskPlans(SysOrg loginUserOrg, TMonitoringRetrievalPlan publishPlan, Integer oldPlanStatus) {
|
|
|
List<TMonitoringRetrievalPlan> tempPlans = new ArrayList<>();
|
|
|
SysOrg publishPlanOrg = remoteOrgService.selectSysOrgById(publishPlan.getOrgId(), SecurityConstants.INNER);
|
|
|
//如果登录当前是省联社 办事处
|
|
|
@@ -646,11 +649,9 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
//如果已存在子计划
|
|
|
if (CollectionUtils.isNotEmpty(existSubPlanlist)) {
|
|
|
// 停用状态再次下发,肯定存在已完成任务,之前的子计划不会删除, 但是又有可能修改了具体执行机构 此时需要处理 历史子计划
|
|
|
- if(ObjectUtil.equal(oldPlanStatus,2))
|
|
|
- {
|
|
|
- tempPlans.addAll(dealSubPlanWithHistorySubPlan(existSubPlanlist,publishPlan,publishPlanOrg));
|
|
|
- }
|
|
|
- else {
|
|
|
+ if (ObjectUtil.equal(oldPlanStatus, 2)) {
|
|
|
+ tempPlans.addAll(dealSubPlanWithHistorySubPlan(existSubPlanlist, publishPlan, publishPlanOrg));
|
|
|
+ } else {
|
|
|
for (TMonitoringRetrievalPlan tm : existSubPlanlist) {
|
|
|
tm.setPlanStatus(1);
|
|
|
tm.setIsDistribute("1");
|
|
|
@@ -662,7 +663,7 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
} else {
|
|
|
// 计划机构类型 是 省联社或者办事处及行社以下的机构类型 才创建子计划
|
|
|
if (!checkOrgType(Integer.parseInt(publishPlan.getOrgType()))) {
|
|
|
- tempPlans.addAll(buildSubPlans(publishPlan,publishPlanOrg));
|
|
|
+ tempPlans.addAll(buildSubPlans(publishPlan, publishPlanOrg));
|
|
|
// // 查询当前计划的具体执行机构
|
|
|
// List<TMonitoringRetrievalPlanToExecOrg> planExecOrgList = tMonitoringRetrievalPlanToExecOrgMapper.selectByMap(MapUtil.of("plan_id", publishPlan.getId()));
|
|
|
//
|
|
|
@@ -720,8 +721,7 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
tempPlans.add(publishPlan);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- else // 行社计划,没有子计划,直接生成任务
|
|
|
+ } else // 行社计划,没有子计划,直接生成任务
|
|
|
{
|
|
|
publishPlan.setCreateType(1);
|
|
|
publishPlan.setIsDistribute("1");
|
|
|
@@ -734,15 +734,15 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
|
|
|
/**
|
|
|
* 停用状态再次下发,肯定存在已完成任务,之前的子计划不会删除, 但是又有可能修改了具体执行机构 此时需要处理 历史子计划
|
|
|
+ *
|
|
|
* @param existSubPlanlist
|
|
|
* @param publishPlan
|
|
|
* @param publishPlanOrg
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<TMonitoringRetrievalPlan> dealSubPlanWithHistorySubPlan(List<TMonitoringRetrievalPlan> existSubPlanlist, TMonitoringRetrievalPlan publishPlan,SysOrg publishPlanOrg) {
|
|
|
+ private List<TMonitoringRetrievalPlan> dealSubPlanWithHistorySubPlan(List<TMonitoringRetrievalPlan> existSubPlanlist, TMonitoringRetrievalPlan publishPlan, SysOrg publishPlanOrg) {
|
|
|
List<TMonitoringRetrievalPlan> tempPlans = new ArrayList<>();
|
|
|
- if(ObjectUtil.isNotEmpty(existSubPlanlist))
|
|
|
- {
|
|
|
+ if (ObjectUtil.isNotEmpty(existSubPlanlist)) {
|
|
|
// 查询当前计划的具体执行机构
|
|
|
List<TMonitoringRetrievalPlanToExecOrg> planExecOrgList = tMonitoringRetrievalPlanToExecOrgMapper.selectByMap(MapUtil.of("plan_id", publishPlan.getId()));
|
|
|
|
|
|
@@ -762,18 +762,16 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
|
|
|
// 找出历史子计划 在新的需要创建计划列表中不存在的删除掉
|
|
|
List<TMonitoringRetrievalPlan> needDeletedHistorySubPlan = existSubPlanlist.stream().filter(x -> !subPlanOrglist.stream().anyMatch(y -> ObjectUtil.equal(y.getId(), x.getOrgId()))).collect(toList());
|
|
|
- if(ObjectUtil.isNotEmpty(needDeletedHistorySubPlan))
|
|
|
- {
|
|
|
- needDeletedHistorySubPlan.forEach(x->x.setIsDeleted(1L));
|
|
|
+ if (ObjectUtil.isNotEmpty(needDeletedHistorySubPlan)) {
|
|
|
+ needDeletedHistorySubPlan.forEach(x -> x.setIsDeleted(1L));
|
|
|
this.saveOrUpdateBatch(needDeletedHistorySubPlan);
|
|
|
}
|
|
|
|
|
|
for (SysOrg subPlanOrg : subPlanOrglist) {
|
|
|
Optional<TMonitoringRetrievalPlan> historySubPlanOpt = existSubPlanlist.stream().filter(x -> x.getOrgId().equals(subPlanOrg.getId())).findFirst();
|
|
|
// 该机构下存在历史子计划
|
|
|
- if(historySubPlanOpt.isPresent())
|
|
|
- {
|
|
|
- TMonitoringRetrievalPlan historySubPlan=historySubPlanOpt.get();
|
|
|
+ if (historySubPlanOpt.isPresent()) {
|
|
|
+ TMonitoringRetrievalPlan historySubPlan = historySubPlanOpt.get();
|
|
|
historySubPlan.setIsDistribute("1");
|
|
|
historySubPlan.setCreateType(1);
|
|
|
historySubPlan.setPlanStatus(1);
|
|
|
@@ -789,8 +787,7 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
needAddSubPlanExecOrgList.add(tempExecOrg);
|
|
|
});
|
|
|
}
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
TMonitoringRetrievalPlan tMonitoringRetrievalPlan1 = new TMonitoringRetrievalPlan();
|
|
|
BeanUtils.copyProperties(publishPlan, tMonitoringRetrievalPlan1);
|
|
|
tMonitoringRetrievalPlan1.setId(IdWorker.getId());
|
|
|
@@ -822,15 +819,14 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
tempPlans.addAll(needSaveSubPlans);
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
- else // 不存在历史子计划,直接全新创建
|
|
|
+ } else // 不存在历史子计划,直接全新创建
|
|
|
{
|
|
|
- return buildSubPlans(publishPlan,publishPlanOrg);
|
|
|
+ return buildSubPlans(publishPlan, publishPlanOrg);
|
|
|
}
|
|
|
- return tempPlans;
|
|
|
+ return tempPlans;
|
|
|
}
|
|
|
|
|
|
- private List<TMonitoringRetrievalPlan> buildSubPlans(TMonitoringRetrievalPlan publishPlan,SysOrg publishPlanOrg) {
|
|
|
+ private List<TMonitoringRetrievalPlan> buildSubPlans(TMonitoringRetrievalPlan publishPlan, SysOrg publishPlanOrg) {
|
|
|
|
|
|
List<TMonitoringRetrievalPlan> tempPlans = new ArrayList<>();
|
|
|
// 查询当前计划的具体执行机构
|
|
|
@@ -881,7 +877,7 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
});
|
|
|
tempPlans.addAll(needAddSubPlans);
|
|
|
}
|
|
|
- return tempPlans;
|
|
|
+ return tempPlans;
|
|
|
}
|
|
|
|
|
|
private List<TMonitoringRetrievalPlanToExecOrg> buildPlanExecOrgs(List<TMonitoringRetrievalPlan> plans, List<SysOrg> execOrglist) {
|
|
|
@@ -1693,35 +1689,45 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
@Override
|
|
|
public void compensate(CompensateDto compensateDto) {
|
|
|
TMonitoringRetrievalPlan retrievalPlan = getById(compensateDto.getPlanId());
|
|
|
-
|
|
|
+ String errorMsg = StringUtil.EMPTY_STRING;
|
|
|
if (ObjectUtil.isNull(retrievalPlan)) {
|
|
|
- throw new ServiceException("计划不存在");
|
|
|
+ errorMsg = "计划不存在";
|
|
|
+ compensateLogService.buildLog(getBusinessPlanType(), true, compensateDto.getOrgIdList(), null, null, errorMsg);
|
|
|
+ throw new ServiceException(errorMsg);
|
|
|
}
|
|
|
|
|
|
if (ObjectUtil.notEqual(retrievalPlan.getPlanStatus(), PlanStatus.USING.getCode())) {
|
|
|
- throw new ServiceException("计划尚未下发或已停用");
|
|
|
+ errorMsg = "计划尚未下发或已停用";
|
|
|
+ compensateLogService.buildLog(getBusinessPlanType(), true, compensateDto.getOrgIdList(), retrievalPlan.getId(), retrievalPlan.getPlanName(), errorMsg);
|
|
|
+ throw new ServiceException(errorMsg);
|
|
|
}
|
|
|
|
|
|
if (ObjectUtil.equal(retrievalPlan.getIsDeleted(), "1")) {
|
|
|
- throw new ServiceException("计划状态异常");
|
|
|
+ errorMsg = "计划已删除";
|
|
|
+ compensateLogService.buildLog(getBusinessPlanType(), true, compensateDto.getOrgIdList(), retrievalPlan.getId(), retrievalPlan.getPlanName(), errorMsg);
|
|
|
+ throw new ServiceException(errorMsg);
|
|
|
}
|
|
|
|
|
|
List<SysOrgVO> orgCacheList = RedisUtils.getCacheList(CacheConstants.ORG_CACHE_LIST_KEY);
|
|
|
//推断计划 创建任务
|
|
|
- deducePlanAndBuildTask(retrievalPlan, compensateDto.getOrgIdList(), orgCacheList);
|
|
|
+ deducePlanAndBuildTask(retrievalPlan, compensateDto.getOrgIdList(), orgCacheList, errorMsg);
|
|
|
}
|
|
|
|
|
|
private static final Set<OrgTypeEnum> INVALID_ORG_TYPES = Sets.newHashSet(OrgTypeEnum.SHEGN_LIAN_SHE, OrgTypeEnum.BAN_SHI_CHU, OrgTypeEnum.DIQU_HANG_SHE);
|
|
|
|
|
|
- private void deducePlanAndBuildTask(TMonitoringRetrievalPlan retrievalPlan, List<Long> orgIdList, List<SysOrgVO> orgCacheList) {
|
|
|
+ private void deducePlanAndBuildTask(TMonitoringRetrievalPlan retrievalPlan, List<Long> orgIdList, List<SysOrgVO> orgCacheList, String errorMsg) {
|
|
|
List<SysOrgVO> orgList = orgCacheList.stream().filter(org -> orgIdList.contains(org.getId())).collect(toList());
|
|
|
if (orgList.isEmpty()) {
|
|
|
- throw new ServiceException("未查询到orgIdList中指定的机构信息");
|
|
|
+ errorMsg = "未查询到指定的机构信息";
|
|
|
+ compensateLogService.buildLog(getBusinessPlanType(), true, orgIdList, retrievalPlan.getId(), retrievalPlan.getPlanName(), errorMsg);
|
|
|
+ throw new ServiceException(errorMsg);
|
|
|
}
|
|
|
List<Long> idList = orgList.stream().map(SysOrgVO::getId).collect(toList());
|
|
|
List<Integer> typeList = orgList.stream().map(SysOrgVO::getType).distinct().collect(toList());
|
|
|
if (typeList.size() > 1) {
|
|
|
- throw new ServiceException("orgIdList中指定的机构信息存在多种机构类型");
|
|
|
+ errorMsg = "orgIdList中指定的机构信息存在多种机构类型";
|
|
|
+ compensateLogService.buildLog(getBusinessPlanType(), true, orgIdList, retrievalPlan.getId(), retrievalPlan.getPlanName(), errorMsg);
|
|
|
+ throw new ServiceException(errorMsg);
|
|
|
}
|
|
|
|
|
|
OrgTypeEnum orgTypeEnum = OrgTypeEnum.getOrgTypeEnum(typeList.get(0));
|
|
|
@@ -1742,11 +1748,15 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
List<TMonitoringRetrievalPlan> reallyPlanList = findReallyPlanIdList(hsPlanIdList, hsOrgIdList);
|
|
|
boolean underHsOrgType = (boolean) map.get("underHsOrgType");
|
|
|
create(reallyPlanList, underHsOrgType ? idList : null);
|
|
|
+ compensateLogService.buildLog(getBusinessPlanType(), false, orgIdList, retrievalPlan.getId(), retrievalPlan.getPlanName(), errorMsg);
|
|
|
+
|
|
|
return;
|
|
|
}
|
|
|
// 行社自建计划
|
|
|
if (INVALID_ORG_TYPES.contains(orgTypeEnum)) {
|
|
|
- throw new ServiceException("orgIdList中传递机构信息错误!与计划信息不匹配");
|
|
|
+ errorMsg = "orgIdList中传递机构信息错误!与计划信息不匹配";
|
|
|
+ compensateLogService.buildLog(getBusinessPlanType(), true, orgIdList, retrievalPlan.getId(), retrievalPlan.getPlanName(), errorMsg);
|
|
|
+ throw new ServiceException(errorMsg);
|
|
|
}
|
|
|
|
|
|
List<TMonitoringRetrievalPlan> plans = Lists.newArrayList(retrievalPlan);
|
|
|
@@ -1756,6 +1766,8 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
//其实这里如果真是传入了行社以下的机构,那么大概率这里的reallyPlanIdList 计划id也只会有一个元素
|
|
|
create(plans, idList);
|
|
|
}
|
|
|
+ compensateLogService.buildLog(getBusinessPlanType(), false, orgIdList, retrievalPlan.getId(), retrievalPlan.getPlanName(), errorMsg);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void create(List<TMonitoringRetrievalPlan> planList, List<Long> idList) {
|