自动下派逻辑调整

任务创建和巡查任务功能整合。
This commit is contained in:
Renpc-kilig 2021-11-17 15:23:27 +08:00
parent 2b116c0387
commit facbb1eba1
8 changed files with 180 additions and 78 deletions

View File

@ -130,10 +130,7 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri
// 设置任务清单数据 // 设置任务清单数据
setData(distributeVO, distributeId); setData(distributeVO, distributeId);
// 选择下派模板判断模板中任务频率若为单次截止日期为一条若为多次截止日期为多条 setOtherMsg(distributeVO, distributeId);
// 未选择下派模板截止日期仅一条
setDeadline(distributeId, distributeVO);
Map<String, Object> params = HashMapUtil.beanToMap(distributeVO); Map<String, Object> params = HashMapUtil.beanToMap(distributeVO);
params.put("distributeId", distributeId); params.put("distributeId", distributeId);
if (StringUtils.isBlank(token)) { if (StringUtils.isBlank(token)) {
@ -142,15 +139,16 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri
setAppSaveInfo(token, params); setAppSaveInfo(token, params);
} }
distributeDao.save(params); distributeDao.save(params);
return distributeId;
}
if(StringHandler.isNull(distributeVO.getTaskTemplate())) { /**
if (distributeVO.getDeadlineList().size() <= 1) { * 保存任务其他信息(任务子表数据任务接收人数据等)
List<ReceiverUserVO> receiverUserVOList = distributeVO.getReceiverUserList(); * @param distributeVO
if (null != receiverUserVOList && receiverUserVOList.size() > 0) { * @param distributeId
saveReceiveUser(distributeId, receiverUserVOList, null, null); */
} private void setOtherMsg(DistributeVO distributeVO, String distributeId) {
} if(!StringHandler.isNull(distributeVO.getTaskTemplate())) {
}else {
// 获取任务频率相关信息 // 获取任务频率相关信息
RateDTO rateDTO = getRateData(distributeVO.getTaskTemplate()); RateDTO rateDTO = getRateData(distributeVO.getTaskTemplate());
@ -158,46 +156,67 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri
if(null != rateDTO) { if(null != rateDTO) {
rateType = rateDTO.getRateType(); rateType = rateDTO.getRateType();
} }
// 如果任务频率为循环任务则定时下派任务 if("巡查任务".equals(distributeVO.getDistributeTaskType())) {
// 否则正常下派
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); 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 distributeId
* @param templateId
* @param distributeVO * @param distributeVO
* @param subId * @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下的所有事项 // 先通过distributeId删除此ID下的所有事项
matterService.removeAllById(distributeId); matterService.removeAllById(distributeId);
TemplateDTO templateDTO = templateService.get(templateId); TemplateDTO templateDTO = templateService.get(templateId);
String templateType = templateDTO.getTemplateType(); String templateType = templateDTO.getTemplateType();
String rateType = rateDTO.getRateType();
if("固定任务".equals(templateType)) { if("固定任务".equals(templateType)) {
forSaveMatterData(distributeId, distributeVO.getMatterList(), distributeVO.getBusiness()); forSaveMatterData(distributeId, distributeVO.getMatterList(), distributeVO.getBusiness());
saveReceiveUser(distributeId, distributeVO.getReceiverUserList(), subId, distributeVO.getBusiness()); setDateByRateType(rateType, distributeVO, distributeId, rateDTO);
} }
if("单随机任务".equals(templateType)) { if("单随机任务".equals(templateType)) {
List<RandomVO> randomVOList = distributeVO.getRandomList(); List<RandomVO> randomVOList = distributeVO.getRandomList();
for(RandomVO randomVO: randomVOList) { for(RandomVO randomVO: randomVOList) {
forSaveMatterData(distributeId, randomVO.getMatterList(), randomVO.getBusiness()); forSaveMatterData(distributeId, randomVO.getMatterList(), randomVO.getBusiness());
saveReceiveUser(distributeId, randomVO.getReceiveUserList(), subId, randomVO.getBusiness());
} }
setDateByRateType(rateType, distributeVO, distributeId, rateDTO);
} }
if("双随机任务".equals(templateType)) { if("双随机任务".equals(templateType)) {
@ -327,12 +346,19 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri
* @param distributeVO * @param distributeVO
*/ */
private void saveDistributeSub(String distributeId, String deadline, String frequency, DistributeVO 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 distributeSubVO = new DistributeSubVO();
distributeSubVO.setDistributeId(distributeId); distributeSubVO.setDistributeId(distributeId);
distributeSubVO.setDeadTime(deadline); distributeSubVO.setDeadTime(deadline);
distributeSubVO.setFrequency(frequency); distributeSubVO.setFrequency(frequency);
String subId = distributeSubService.saveReturnId(null, distributeSubVO); String subId = distributeSubService.saveReturnId(null, distributeSubVO);
saveMatterData(distributeId, distributeVO.getTaskTemplate(), distributeVO, subId); saveReceiveUser(distributeId, subId, distributeVO);
} }
@Override @Override
@ -374,63 +400,62 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri
} }
Map<String, Object> params = HashMapUtil.beanToMap(distributeVO); Map<String, Object> params = HashMapUtil.beanToMap(distributeVO);
params.put("distributeId", distributeId); params.put("distributeId", distributeId);
if (StringUtils.isBlank(token)) {
setUpdateInfo(params);
} else {
setAppUpdateInfo(token, params);
}
distributeDao.deleteTaskList(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)) { if (StringUtils.isBlank(token)) {
setUpdateInfo(params); setUpdateInfo(params);
} else { } else {
setAppUpdateInfo(token, params); setAppUpdateInfo(token, params);
} }
distributeDao.update(params); distributeDao.update(params);
setData(distributeVO, distributeId);
// 选择下派模板判断模板中任务频率若为单次截止日期为一条若为多次截止日期为多条
// 未选择下派模板截止日期仅一条
setDeadline(distributeId, distributeVO);
receiverUserService.removeAll(params);
if(StringHandler.isNull(distributeVO.getTaskTemplate())) {
if (distributeVO.getDeadlineList().size() <= 1) {
List<ReceiverUserVO> 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 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<RandomVO> randomVOList = distributeVO.getRandomList();
for(RandomVO randomVO: randomVOList) {
saveReceiveUserData(randomVO.getReceiveUserList(), distributeId, distributeSubId, randomVO.getBusiness());
}
}
}else {
saveReceiveUserData(distributeVO.getReceiverUserList(), distributeId, distributeSubId, null);
}
}
/**
* 保存任务接收人数据
* @param receiverUserVOList * @param receiverUserVOList
* @param distributeId
* @param distributeSubId * @param distributeSubId
* @param business * @param business
*/ */
private void saveReceiveUser(String distributeId, List<ReceiverUserVO> receiverUserVOList, String distributeSubId, String business) { private void saveReceiveUserData(List<ReceiverUserVO> receiverUserVOList, String distributeId, String distributeSubId, String business) {
for(ReceiverUserVO receiverUserVO: receiverUserVOList) { for(ReceiverUserVO receiverUserVO: receiverUserVOList) {
receiverUserVO.setDistributeId(distributeId); receiverUserVO.setDistributeId(distributeId);
if(null != distributeSubId) { if(null != distributeSubId) {
@ -506,10 +531,18 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri
} }
if(!StringUtils.isEmpty(distributeDTO.getTaskTemplate())) { if(!StringUtils.isEmpty(distributeDTO.getTaskTemplate())) {
getBusinessData(distributeDTO); if("巡查任务".equals(distributeDTO.getDistributeTaskType())) {
getBusinessData(distributeDTO);
}else {
params.put("taskType", "正常");
List<ReceiverUserDTO> receiverUserDTOList = receiverUserService.listForAuto(params);
if(null != receiverUserDTOList) {
distributeDTO.setReceiveUserList(receiverUserDTOList);
}
}
}else{ }else{
params.put("taskType", "正常"); params.put("taskType", "正常");
List<ReceiverUserDTO> receiverUserDTOList = receiverUserService.list(params); List<ReceiverUserDTO> receiverUserDTOList = receiverUserService.listForAuto(params);
if(null != receiverUserDTOList) { if(null != receiverUserDTOList) {
distributeDTO.setReceiveUserList(receiverUserDTOList); distributeDTO.setReceiveUserList(receiverUserDTOList);
} }
@ -603,7 +636,7 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri
if(null != userIdx) { if(null != userIdx) {
params.put("userIdx", userIdx); params.put("userIdx", userIdx);
} }
List<ReceiverUserDTO> receiverUserDTOList = receiverUserService.list(params); List<ReceiverUserDTO> receiverUserDTOList = receiverUserService.listForAuto(params);
return receiverUserDTOList; return receiverUserDTOList;
} }
@ -792,6 +825,11 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri
@Override @Override
public void regularDispatch() throws ParseException { public void regularDispatch() throws ParseException {
Map<String, Object> params = new HashMap<>(2); Map<String, Object> 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); params.put("isOpen", 1);
// 查询是否配置了下派顺序 // 查询是否配置了下派顺序
// 若配置了则按照下派顺序下派 // 若配置了则按照下派顺序下派
@ -1685,10 +1723,10 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri
distributeSubVO.setDeadTime(deadlineList[j]); distributeSubVO.setDeadTime(deadlineList[j]);
distributeSubVO.setFrequency("" + (j+1) + "次任务"); distributeSubVO.setFrequency("" + (j+1) + "次任务");
String subId = distributeSubService.saveReturnId(null, distributeSubVO); String subId = distributeSubService.saveReturnId(null, distributeSubVO);
saveReceiveUser(ids[i], distributeVO.getReceiverUserList(), subId, null); saveReceiveUser(ids[i], subId, distributeVO);
} }
}else { }else {
saveReceiveUser(ids[i], receiverUserVOList, null, null); saveReceiveUser(ids[i],null, distributeVO);
} }
} }
} }

View File

@ -252,4 +252,11 @@ public interface IReceiverUserService {
* @param userIds * @param userIds
*/ */
void sendNoteMsg(String content, String userIds); void sendNoteMsg(String content, String userIds);
/**
* 任务接收人列表
* @param params
* @return
*/
List<ReceiverUserDTO> listForAuto(Map<String, Object> params);
} }

View File

@ -417,4 +417,9 @@ public class ReceiverUserServiceImpl extends DefaultBaseService implements IRece
appTaskMsg.sendSmsTaskStatus(sendUrl, smsSendVO, accessToken);*/ appTaskMsg.sendSmsTaskStatus(sendUrl, smsSendVO, accessToken);*/
} }
@Override
public List<ReceiverUserDTO> listForAuto(Map<String, Object> params) {
return receiverUserDao.listForAuto(params);
}
} }

View File

@ -579,6 +579,10 @@
OR t1.mission_location LIKE CONCAT('%', #{keywords}, '%') OR t1.mission_location LIKE CONCAT('%', #{keywords}, '%')
) )
</if> </if>
<if test="nowTime != null and nowTime != '' and endTime != null and endTime != ''">
AND
t1.distribute_time between #{nowTime} and #{endTime}
</if>
<if test="distributeTaskType != null and distributeTaskType != ''"> <if test="distributeTaskType != null and distributeTaskType != ''">
AND AND
t1.distribute_task_type = #{distributeTaskType} t1.distribute_task_type = #{distributeTaskType}

View File

@ -521,7 +521,9 @@
DISTINCT DISTINCT
t1.user_id, t1.user_id,
t1.user_name, t1.user_name,
t1.distribute_id t1.distribute_id,
t1.business,
t1.user_idx
FROM FROM
task_receiver_user t1 task_receiver_user t1
WHERE WHERE
@ -538,6 +540,48 @@
AND AND
t1.receive_type = #{receiveType} t1.receive_type = #{receiveType}
</if> </if>
<if test="userIdx != null and userIdx != ''">
AND
t1.user_idx = #{userIdx}
</if>
<if test="receiverUserId != null and receiverUserId != ''">
AND
t1.receiver_user_id = #{receiverUserId}
</if>
<if test="business != null and business != ''">
AND
t1.business = #{business}
</if>
<if test="userId != null and userId != ''">
AND
t1.user_id = #{userId}
</if>
<if test="isWarning != null and isWarning != ''">
AND
t1.is_warning = #{isWarning}
</if>
<if test="isSupervision != null and isSupervision != ''">
AND
t1.is_supervision = #{isSupervision}
</if>
<if test="executeStatus != null and executeStatus != ''">
AND
t1.execute_status = #{executeStatus}
</if>
<if test="executeStatusNoOver != null and executeStatusNoOver != ''">
AND
t1.execute_status &lt;&gt; #{executeStatusNoOver}
</if>
<if test="checkStatus != null and checkStatus != ''">
AND
t1.check_status = #{checkStatus}
</if>
<if test="userIds != null and userIds.size > 0">
AND t1.user_id IN
<foreach collection="userIds" index="index" open="(" separator="," close=")">
#{userIds[${index}]}
</foreach>
</if>
</select> </select>
<!-- 任务接收人列表 --> <!-- 任务接收人列表 -->

View File

@ -123,7 +123,7 @@
<label class="layui-form-label">巡查事项</label> <label class="layui-form-label">巡查事项</label>
<div class="layui-input-block layui-form" id="businessSelectTemplateBox" lay-filter="businessSelectTemplateBox"></div> <div class="layui-input-block layui-form" id="businessSelectTemplateBox" lay-filter="businessSelectTemplateBox"></div>
<script id="businessSelectTemplate" type="text/html"> <script id="businessSelectTemplate" type="text/html">
<select id="business" name="business" lay-filter="business" lay-verify="required"> <select id="business" name="business" lay-filter="business">
<option value="">请选择巡查事项</option> <option value="">请选择巡查事项</option>
{{# for(var i = 0, item; item = d[i++];) { }} {{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.businessId}},{{item.businessSummary}}">{{item.businessName}}</option> <option value="{{item.businessId}},{{item.businessSummary}}">{{item.businessName}}</option>
@ -700,7 +700,7 @@
receiverUserList = data; receiverUserList = data;
businessUserFun(); businessUserFun();
} }
taskRate = data.rateType; // taskRate = data.rateType;
}, function(code, data) { }, function(code, data) {
top.dialog.msg(data.msg); top.dialog.msg(data.msg);
}, function() { }, function() {
@ -1238,6 +1238,7 @@
$('#reportCount').val(reportCount); $('#reportCount').val(reportCount);
$('#reportCount').attr('readonly', 'readonly'); $('#reportCount').attr('readonly', 'readonly');
taskRate = data.rateType; taskRate = data.rateType;
alert(taskRate);
}, function(code, data) { }, function(code, data) {
top.dialog.msg(data.msg); top.dialog.msg(data.msg);
}, function() { }, function() {
@ -1547,6 +1548,7 @@
function deadlineFun(value) { function deadlineFun(value) {
if('' != taskRate) { if('' != taskRate) {
if('多次任务' == taskRate) { if('多次任务' == taskRate) {
alert()
$('#distributeDeadline').val(''); $('#distributeDeadline').val('');
$('#deadlineDiv').show(); $('#deadlineDiv').show();
var deadlineObj = {}; var deadlineObj = {};

View File

@ -555,6 +555,7 @@
$('#reportCount').val(reportCount); $('#reportCount').val(reportCount);
$('#reportCount').attr('readonly', 'readonly'); $('#reportCount').attr('readonly', 'readonly');
taskRate = data.rateType; taskRate = data.rateType;
alert(taskRate);
}, function(code, data) { }, function(code, data) {
top.dialog.msg(data.msg); top.dialog.msg(data.msg);
}, function() { }, function() {

View File

@ -778,7 +778,7 @@
receiverUserList = data; receiverUserList = data;
businessUserFun(); businessUserFun();
} }
taskRate = data.rateType; // taskRate = data.rateType;
}, function(code, data) { }, function(code, data) {
top.dialog.msg(data.msg); top.dialog.msg(data.msg);
}, function() { }, function() {
@ -1781,6 +1781,7 @@
$('#taskListDiv').show(); $('#taskListDiv').show();
initTaskListTable(data['distributeListDTOList']); initTaskListTable(data['distributeListDTOList']);
} }
console.log(data)
if(null != data['rateStatus'] && '' != data['rateStatus'] && typeof(data['rateStatus'] != 'undefined')) { if(null != data['rateStatus'] && '' != data['rateStatus'] && typeof(data['rateStatus'] != 'undefined')) {
taskRate = data['rateStatus']; taskRate = data['rateStatus'];
if('多次任务' == data['rateStatus']) { if('多次任务' == data['rateStatus']) {