From facbb1eba12f0d670ce0d12f1b04e2b5ff0b3e56 Mon Sep 17 00:00:00 2001 From: Renpc-kilig <308442850@qq.com> Date: Wed, 17 Nov 2021 15:23:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E4=B8=8B=E6=B4=BE=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E8=B0=83=E6=95=B4=20=E4=BB=BB=E5=8A=A1=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E5=92=8C=E5=B7=A1=E6=9F=A5=E4=BB=BB=E5=8A=A1=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=95=B4=E5=90=88=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DistributeServiceImpl.java | 186 +++++++++++------- .../receiveruser/IReceiverUserService.java | 7 + .../impl/ReceiverUserServiceImpl.java | 5 + .../mapper/distribute/distribute-mapper.xml | 4 + .../receiveruser/receiver-user-mapper.xml | 46 ++++- .../templates/distribute/save-business.html | 6 +- .../resources/templates/distribute/save.html | 1 + .../templates/distribute/update-business.html | 3 +- 8 files changed, 180 insertions(+), 78 deletions(-) diff --git a/src/main/java/cn/com/tenlion/systemtask/service/distribute/impl/DistributeServiceImpl.java b/src/main/java/cn/com/tenlion/systemtask/service/distribute/impl/DistributeServiceImpl.java index 63d79d6..cee5dd8 100644 --- a/src/main/java/cn/com/tenlion/systemtask/service/distribute/impl/DistributeServiceImpl.java +++ b/src/main/java/cn/com/tenlion/systemtask/service/distribute/impl/DistributeServiceImpl.java @@ -130,10 +130,7 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri // 设置任务清单数据 setData(distributeVO, distributeId); - // 选择下派模板,判断模板中任务频率,若为单次,截止日期为一条,若为多次,截止日期为多条 - // 未选择下派模板:截止日期仅一条 - setDeadline(distributeId, distributeVO); - + setOtherMsg(distributeVO, distributeId); Map params = HashMapUtil.beanToMap(distributeVO); params.put("distributeId", distributeId); if (StringUtils.isBlank(token)) { @@ -142,15 +139,16 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri setAppSaveInfo(token, params); } distributeDao.save(params); + return distributeId; + } - if(StringHandler.isNull(distributeVO.getTaskTemplate())) { - if (distributeVO.getDeadlineList().size() <= 1) { - List receiverUserVOList = distributeVO.getReceiverUserList(); - if (null != receiverUserVOList && receiverUserVOList.size() > 0) { - saveReceiveUser(distributeId, receiverUserVOList, null, null); - } - } - }else { + /** + * 保存任务其他信息(任务子表数据,任务接收人数据等) + * @param distributeVO + * @param distributeId + */ + private void setOtherMsg(DistributeVO distributeVO, String distributeId) { + if(!StringHandler.isNull(distributeVO.getTaskTemplate())) { // 获取任务频率相关信息 RateDTO rateDTO = getRateData(distributeVO.getTaskTemplate()); @@ -158,46 +156,67 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri if(null != rateDTO) { rateType = rateDTO.getRateType(); } - // 如果任务频率为循环任务,则定时下派任务 - // 否则正常下派 - if("循环任务".equals(rateType)) { - try { - Date date = df.parse(distributeVO.getDistributeTime()); - setDistributeSubByRateType(rateDTO.getCycleType(), date, distributeId, distributeVO); - }catch (Exception e) { - e.printStackTrace(); - } - }else { + if("巡查任务".equals(distributeVO.getDistributeTaskType())) { // 获取任务模板中模板类型 // 固定任务、单随机任务、双随机任务 - saveMatterData(distributeId, distributeVO.getTaskTemplate(), distributeVO, null); + saveMatterData(distributeId, distributeVO, null, rateDTO); + }else { + setDateByRateType(rateType, distributeVO, distributeId, rateDTO); } + }else { + saveReceiveUser(distributeId, null, distributeVO); + } + } + + /** + * 通过任务类型保存数据 + * @param rateType + * @param distributeVO + * @param distributeId + * @param rateDTO + */ + private void setDateByRateType(String rateType, DistributeVO distributeVO, String distributeId, RateDTO rateDTO) { + // 如果任务频率为循环任务,则定时下派任务 + // 否则正常下派 + if("循环任务".equals(rateType)) { + try { + Date date = df.parse(distributeVO.getDistributeTime()); + setDistributeSubByRateType(rateDTO.getCycleType(), date, distributeId, distributeVO); + }catch (Exception e) { + e.printStackTrace(); + } + }else if("单次任务".equals(rateType)){ + saveReceiveUser(distributeId, null, distributeVO); + }else if("多次任务".equals(rateType)) { + // 选择下派模板,判断模板中任务频率,若为单次,截止日期为一条,若为多次,截止日期为多条 + // 未选择下派模板:截止日期仅一条 + setDeadline(distributeId, distributeVO); } - return distributeId; } /** * 保存事项列表数据 * @param distributeId - * @param templateId * @param distributeVO * @param subId */ - private void saveMatterData(String distributeId, String templateId, DistributeVO distributeVO, String subId) { + private void saveMatterData(String distributeId, DistributeVO distributeVO, String subId, RateDTO rateDTO) { + String templateId = distributeVO.getTaskTemplate(); // 先通过distributeId删除此ID下的所有事项 matterService.removeAllById(distributeId); TemplateDTO templateDTO = templateService.get(templateId); String templateType = templateDTO.getTemplateType(); + String rateType = rateDTO.getRateType(); if("固定任务".equals(templateType)) { forSaveMatterData(distributeId, distributeVO.getMatterList(), distributeVO.getBusiness()); - saveReceiveUser(distributeId, distributeVO.getReceiverUserList(), subId, distributeVO.getBusiness()); + setDateByRateType(rateType, distributeVO, distributeId, rateDTO); } if("单随机任务".equals(templateType)) { List randomVOList = distributeVO.getRandomList(); for(RandomVO randomVO: randomVOList) { forSaveMatterData(distributeId, randomVO.getMatterList(), randomVO.getBusiness()); - saveReceiveUser(distributeId, randomVO.getReceiveUserList(), subId, randomVO.getBusiness()); } + setDateByRateType(rateType, distributeVO, distributeId, rateDTO); } if("双随机任务".equals(templateType)) { @@ -327,12 +346,19 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri * @param distributeVO */ private void saveDistributeSub(String distributeId, String deadline, String frequency, DistributeVO distributeVO) { + // 获取任务频率相关信息 + RateDTO rateDTO = getRateData(distributeVO.getTaskTemplate()); + + String rateType = null; + if(null != rateDTO) { + rateType = rateDTO.getRateType(); + } DistributeSubVO distributeSubVO = new DistributeSubVO(); distributeSubVO.setDistributeId(distributeId); distributeSubVO.setDeadTime(deadline); distributeSubVO.setFrequency(frequency); String subId = distributeSubService.saveReturnId(null, distributeSubVO); - saveMatterData(distributeId, distributeVO.getTaskTemplate(), distributeVO, subId); + saveReceiveUser(distributeId, subId, distributeVO); } @Override @@ -374,63 +400,62 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri } Map params = HashMapUtil.beanToMap(distributeVO); params.put("distributeId", distributeId); + if (StringUtils.isBlank(token)) { + setUpdateInfo(params); + } else { + setAppUpdateInfo(token, params); + } distributeDao.deleteTaskList(params); + + setData(distributeVO, distributeId); + + receiverUserService.removeAll(params); + + setOtherMsg(distributeVO, distributeId); + + params = HashMapUtil.beanToMap(distributeVO); + params.put("distributeId", distributeId); if (StringUtils.isBlank(token)) { setUpdateInfo(params); } else { setAppUpdateInfo(token, params); } distributeDao.update(params); - - setData(distributeVO, distributeId); - - // 选择下派模板,判断模板中任务频率,若为单次,截止日期为一条,若为多次,截止日期为多条 - // 未选择下派模板:截止日期仅一条 - setDeadline(distributeId, distributeVO); - - receiverUserService.removeAll(params); - - if(StringHandler.isNull(distributeVO.getTaskTemplate())) { - if (distributeVO.getDeadlineList().size() <= 1) { - List receiverUserVOList = distributeVO.getReceiverUserList(); - if (null != receiverUserVOList && receiverUserVOList.size() > 0) { - saveReceiveUser(distributeId, receiverUserVOList, null, null); - } - } - }else { - // 获取任务频率相关信息 - RateDTO rateDTO = getRateData(distributeVO.getTaskTemplate()); - - String rateType = null; - if(null != rateDTO) { - rateType = rateDTO.getRateType(); - } - // 如果任务频率为循环任务,则定时下派任务 - // 否则正常下派 - if("循环任务".equals(rateType)) { - try { - Date date = df.parse(distributeVO.getDistributeTime()); - setDistributeSubByRateType(rateDTO.getCycleType(), date, distributeId, distributeVO); - }catch (Exception e) { - e.printStackTrace(); - } - }else { - // 获取任务模板中模板类型 - // 固定任务、单随机任务、双随机任务 - saveMatterData(distributeId, distributeVO.getTaskTemplate(), distributeVO, null); - } - } } /** * 新增任务接收人 * 产生任务接收人数据 * @param distributeId + * @param distributeSubId + */ + private void saveReceiveUser(String distributeId, String distributeSubId, DistributeVO distributeVO) { + if("巡查任务".equals(distributeVO.getDistributeTaskType())) { + String templateId = distributeVO.getTaskTemplate(); + TemplateDTO templateDTO = templateService.get(templateId); + String templateType = templateDTO.getTemplateType(); + if("固定任务".equals(templateType)) { + saveReceiveUserData(distributeVO.getReceiverUserList(), distributeId, distributeSubId, distributeVO.getBusiness()); + } + if("单随机任务".equals(templateType)) { + List randomVOList = distributeVO.getRandomList(); + for(RandomVO randomVO: randomVOList) { + saveReceiveUserData(randomVO.getReceiveUserList(), distributeId, distributeSubId, randomVO.getBusiness()); + } + } + }else { + saveReceiveUserData(distributeVO.getReceiverUserList(), distributeId, distributeSubId, null); + } + } + + /** + * 保存任务接收人数据 * @param receiverUserVOList + * @param distributeId * @param distributeSubId * @param business */ - private void saveReceiveUser(String distributeId, List receiverUserVOList, String distributeSubId, String business) { + private void saveReceiveUserData(List receiverUserVOList, String distributeId, String distributeSubId, String business) { for(ReceiverUserVO receiverUserVO: receiverUserVOList) { receiverUserVO.setDistributeId(distributeId); if(null != distributeSubId) { @@ -506,10 +531,18 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri } if(!StringUtils.isEmpty(distributeDTO.getTaskTemplate())) { - getBusinessData(distributeDTO); + if("巡查任务".equals(distributeDTO.getDistributeTaskType())) { + getBusinessData(distributeDTO); + }else { + params.put("taskType", "正常"); + List receiverUserDTOList = receiverUserService.listForAuto(params); + if(null != receiverUserDTOList) { + distributeDTO.setReceiveUserList(receiverUserDTOList); + } + } }else{ params.put("taskType", "正常"); - List receiverUserDTOList = receiverUserService.list(params); + List receiverUserDTOList = receiverUserService.listForAuto(params); if(null != receiverUserDTOList) { distributeDTO.setReceiveUserList(receiverUserDTOList); } @@ -603,7 +636,7 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri if(null != userIdx) { params.put("userIdx", userIdx); } - List receiverUserDTOList = receiverUserService.list(params); + List receiverUserDTOList = receiverUserService.listForAuto(params); return receiverUserDTOList; } @@ -792,6 +825,11 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri @Override public void regularDispatch() throws ParseException { Map params = new HashMap<>(2); + long errorTime = 5 * 60 * 1000; + Date nowTime = new Date(); + Date endTime = new Date(nowTime.getTime() + errorTime); + params.put("nowTime", df.format(nowTime)); + params.put("endTime", df.format(endTime)); params.put("isOpen", 1); // 查询是否配置了下派顺序 // 若配置了,则按照下派顺序下派 @@ -1685,10 +1723,10 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri distributeSubVO.setDeadTime(deadlineList[j]); distributeSubVO.setFrequency("第" + (j+1) + "次任务"); String subId = distributeSubService.saveReturnId(null, distributeSubVO); - saveReceiveUser(ids[i], distributeVO.getReceiverUserList(), subId, null); + saveReceiveUser(ids[i], subId, distributeVO); } }else { - saveReceiveUser(ids[i], receiverUserVOList, null, null); + saveReceiveUser(ids[i],null, distributeVO); } } } diff --git a/src/main/java/cn/com/tenlion/systemtask/service/receiveruser/IReceiverUserService.java b/src/main/java/cn/com/tenlion/systemtask/service/receiveruser/IReceiverUserService.java index 3dbb40d..7fd2db4 100644 --- a/src/main/java/cn/com/tenlion/systemtask/service/receiveruser/IReceiverUserService.java +++ b/src/main/java/cn/com/tenlion/systemtask/service/receiveruser/IReceiverUserService.java @@ -252,4 +252,11 @@ public interface IReceiverUserService { * @param userIds */ void sendNoteMsg(String content, String userIds); + + /** + * 任务接收人列表 + * @param params + * @return + */ + List listForAuto(Map params); } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/systemtask/service/receiveruser/impl/ReceiverUserServiceImpl.java b/src/main/java/cn/com/tenlion/systemtask/service/receiveruser/impl/ReceiverUserServiceImpl.java index 1194124..1234efd 100644 --- a/src/main/java/cn/com/tenlion/systemtask/service/receiveruser/impl/ReceiverUserServiceImpl.java +++ b/src/main/java/cn/com/tenlion/systemtask/service/receiveruser/impl/ReceiverUserServiceImpl.java @@ -417,4 +417,9 @@ public class ReceiverUserServiceImpl extends DefaultBaseService implements IRece appTaskMsg.sendSmsTaskStatus(sendUrl, smsSendVO, accessToken);*/ } + @Override + public List listForAuto(Map params) { + return receiverUserDao.listForAuto(params); + } + } \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/distribute/distribute-mapper.xml b/src/main/resources/mybatis/mapper/distribute/distribute-mapper.xml index 11546fe..5e46797 100644 --- a/src/main/resources/mybatis/mapper/distribute/distribute-mapper.xml +++ b/src/main/resources/mybatis/mapper/distribute/distribute-mapper.xml @@ -579,6 +579,10 @@ OR t1.mission_location LIKE CONCAT('%', #{keywords}, '%') ) + + AND + t1.distribute_time between #{nowTime} and #{endTime} + AND t1.distribute_task_type = #{distributeTaskType} diff --git a/src/main/resources/mybatis/mapper/receiveruser/receiver-user-mapper.xml b/src/main/resources/mybatis/mapper/receiveruser/receiver-user-mapper.xml index 7fc9a2c..5dc1132 100644 --- a/src/main/resources/mybatis/mapper/receiveruser/receiver-user-mapper.xml +++ b/src/main/resources/mybatis/mapper/receiveruser/receiver-user-mapper.xml @@ -521,7 +521,9 @@ DISTINCT t1.user_id, t1.user_name, - t1.distribute_id + t1.distribute_id, + t1.business, + t1.user_idx FROM task_receiver_user t1 WHERE @@ -538,6 +540,48 @@ AND t1.receive_type = #{receiveType} + + AND + t1.user_idx = #{userIdx} + + + AND + t1.receiver_user_id = #{receiverUserId} + + + AND + t1.business = #{business} + + + AND + t1.user_id = #{userId} + + + AND + t1.is_warning = #{isWarning} + + + AND + t1.is_supervision = #{isSupervision} + + + AND + t1.execute_status = #{executeStatus} + + + AND + t1.execute_status <> #{executeStatusNoOver} + + + AND + t1.check_status = #{checkStatus} + + + AND t1.user_id IN + + #{userIds[${index}]} + + diff --git a/src/main/resources/templates/distribute/save-business.html b/src/main/resources/templates/distribute/save-business.html index c124668..f849d71 100644 --- a/src/main/resources/templates/distribute/save-business.html +++ b/src/main/resources/templates/distribute/save-business.html @@ -123,7 +123,7 @@