自动下派逻辑调整
任务创建和巡查任务功能整合。
This commit is contained in:
parent
2b116c0387
commit
facbb1eba1
@ -130,10 +130,7 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri
|
||||
// 设置任务清单数据
|
||||
setData(distributeVO, distributeId);
|
||||
|
||||
// 选择下派模板,判断模板中任务频率,若为单次,截止日期为一条,若为多次,截止日期为多条
|
||||
// 未选择下派模板:截止日期仅一条
|
||||
setDeadline(distributeId, distributeVO);
|
||||
|
||||
setOtherMsg(distributeVO, distributeId);
|
||||
Map<String, Object> 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<ReceiverUserVO> 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,6 +156,26 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri
|
||||
if(null != rateDTO) {
|
||||
rateType = rateDTO.getRateType();
|
||||
}
|
||||
if("巡查任务".equals(distributeVO.getDistributeTaskType())) {
|
||||
// 获取任务模板中模板类型
|
||||
// 固定任务、单随机任务、双随机任务
|
||||
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)) {
|
||||
@ -167,37 +185,38 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else {
|
||||
// 获取任务模板中模板类型
|
||||
// 固定任务、单随机任务、双随机任务
|
||||
saveMatterData(distributeId, distributeVO.getTaskTemplate(), distributeVO, null);
|
||||
}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<RandomVO> 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<String, Object> 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<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 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 distributeId
|
||||
* @param distributeSubId
|
||||
* @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) {
|
||||
receiverUserVO.setDistributeId(distributeId);
|
||||
if(null != distributeSubId) {
|
||||
@ -506,10 +531,18 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri
|
||||
}
|
||||
|
||||
if(!StringUtils.isEmpty(distributeDTO.getTaskTemplate())) {
|
||||
if("巡查任务".equals(distributeDTO.getDistributeTaskType())) {
|
||||
getBusinessData(distributeDTO);
|
||||
}else {
|
||||
params.put("taskType", "正常");
|
||||
List<ReceiverUserDTO> receiverUserDTOList = receiverUserService.list(params);
|
||||
List<ReceiverUserDTO> receiverUserDTOList = receiverUserService.listForAuto(params);
|
||||
if(null != receiverUserDTOList) {
|
||||
distributeDTO.setReceiveUserList(receiverUserDTOList);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
params.put("taskType", "正常");
|
||||
List<ReceiverUserDTO> 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<ReceiverUserDTO> receiverUserDTOList = receiverUserService.list(params);
|
||||
List<ReceiverUserDTO> receiverUserDTOList = receiverUserService.listForAuto(params);
|
||||
return receiverUserDTOList;
|
||||
}
|
||||
|
||||
@ -792,6 +825,11 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri
|
||||
@Override
|
||||
public void regularDispatch() throws ParseException {
|
||||
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);
|
||||
// 查询是否配置了下派顺序
|
||||
// 若配置了,则按照下派顺序下派
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -252,4 +252,11 @@ public interface IReceiverUserService {
|
||||
* @param userIds
|
||||
*/
|
||||
void sendNoteMsg(String content, String userIds);
|
||||
|
||||
/**
|
||||
* 任务接收人列表
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
List<ReceiverUserDTO> listForAuto(Map<String, Object> params);
|
||||
}
|
@ -417,4 +417,9 @@ public class ReceiverUserServiceImpl extends DefaultBaseService implements IRece
|
||||
appTaskMsg.sendSmsTaskStatus(sendUrl, smsSendVO, accessToken);*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ReceiverUserDTO> listForAuto(Map<String, Object> params) {
|
||||
return receiverUserDao.listForAuto(params);
|
||||
}
|
||||
|
||||
}
|
@ -579,6 +579,10 @@
|
||||
OR t1.mission_location LIKE CONCAT('%', #{keywords}, '%')
|
||||
)
|
||||
</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 != ''">
|
||||
AND
|
||||
t1.distribute_task_type = #{distributeTaskType}
|
||||
|
@ -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}
|
||||
</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 <> #{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>
|
||||
|
||||
<!-- 任务接收人列表 -->
|
||||
|
@ -123,7 +123,7 @@
|
||||
<label class="layui-form-label">巡查事项</label>
|
||||
<div class="layui-input-block layui-form" id="businessSelectTemplateBox" lay-filter="businessSelectTemplateBox"></div>
|
||||
<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>
|
||||
{{# for(var i = 0, item; item = d[i++];) { }}
|
||||
<option value="{{item.businessId}},{{item.businessSummary}}">{{item.businessName}}</option>
|
||||
@ -700,7 +700,7 @@
|
||||
receiverUserList = data;
|
||||
businessUserFun();
|
||||
}
|
||||
taskRate = data.rateType;
|
||||
// taskRate = data.rateType;
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
@ -1238,6 +1238,7 @@
|
||||
$('#reportCount').val(reportCount);
|
||||
$('#reportCount').attr('readonly', 'readonly');
|
||||
taskRate = data.rateType;
|
||||
alert(taskRate);
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
@ -1547,6 +1548,7 @@
|
||||
function deadlineFun(value) {
|
||||
if('' != taskRate) {
|
||||
if('多次任务' == taskRate) {
|
||||
alert()
|
||||
$('#distributeDeadline').val('');
|
||||
$('#deadlineDiv').show();
|
||||
var deadlineObj = {};
|
||||
|
@ -555,6 +555,7 @@
|
||||
$('#reportCount').val(reportCount);
|
||||
$('#reportCount').attr('readonly', 'readonly');
|
||||
taskRate = data.rateType;
|
||||
alert(taskRate);
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
|
@ -778,7 +778,7 @@
|
||||
receiverUserList = data;
|
||||
businessUserFun();
|
||||
}
|
||||
taskRate = data.rateType;
|
||||
// taskRate = data.rateType;
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
@ -1781,6 +1781,7 @@
|
||||
$('#taskListDiv').show();
|
||||
initTaskListTable(data['distributeListDTOList']);
|
||||
}
|
||||
console.log(data)
|
||||
if(null != data['rateStatus'] && '' != data['rateStatus'] && typeof(data['rateStatus'] != 'undefined')) {
|
||||
taskRate = data['rateStatus'];
|
||||
if('多次任务' == data['rateStatus']) {
|
||||
|
Loading…
Reference in New Issue
Block a user