新增了随机任务删除时更新待办数量

This commit is contained in:
wanggeng 2021-07-23 21:24:20 +08:00
parent 87365f8087
commit 3c576812cb
10 changed files with 112 additions and 9 deletions

View File

@ -0,0 +1,60 @@
package com.cm.inspection.runnable;
import com.alibaba.fastjson.JSONObject;
import com.cm.common.plugin.oauth.token.ClientTokenManager;
import com.cm.common.utils.http.AbstractRestTemplate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.client.HttpClientErrorException;
import java.util.Set;
/**
* @ClassName: Check2DeleteServiceRunnable
* @Description: 删除业务
* @Author: wanggeng
* @Date: 2021/7/23 2:36 下午
* @Version: 1.0
*/
@Slf4j
public class DeleteServiceRunnable extends AbstractRestTemplate<String, JSONObject> implements Runnable {
private String noticeUrl;
private Set<String> serviceIds;
public DeleteServiceRunnable(String noticeUrl, Set<String> serviceIds) {
this.noticeUrl = noticeUrl;
this.serviceIds = serviceIds;
}
@Override
public void run() {
this.postJson(getNoticeUrl());
}
public String getNoticeUrl() {
return String.format("%s/resource/message/delete?access_token=%s", noticeUrl, ClientTokenManager.getInstance().getClientToken().getAccessToken());
}
@Override
public JSONObject body() {
JSONObject bodyJSONObject = new JSONObject();
bodyJSONObject.put("serviceIds", serviceIds);
return bodyJSONObject;
}
@Override
public Class<String> successResultType() {
return String.class;
}
@Override
public void success200(String result) {
log.debug("请求成功result: {}", result);
}
@Override
public void error400(HttpClientErrorException error) {
log.error(error.getMessage(), error);
}
}

View File

@ -29,7 +29,7 @@ public class Check2MsgRequest extends AbstractRestTemplate<String, JSONObject> {
private String checkId;
@Override
public JSONObject postBody() {
public JSONObject body() {
JSONObject noticeJSONObject = new JSONObject();
JSONArray noticeJSONArray = new JSONArray();
JSONObject notice = new JSONObject();

View File

@ -34,7 +34,7 @@ public class DischargePermitNoticeRequest extends AbstractRestTemplate<String, J
}
@Override
public JSONObject postBody() {
public JSONObject body() {
JSONObject noticeJSONObject = new JSONObject();
JSONArray noticeJSONArray = new JSONArray();
dischargePermitSet.forEach(dischargePermitDTO -> {

View File

@ -34,7 +34,7 @@ public class EiaReportNoticeRequest extends AbstractRestTemplate<String, JSONObj
}
@Override
public JSONObject postBody() {
public JSONObject body() {
JSONObject noticeJSONObject = new JSONObject();
JSONArray noticeJSONArray = new JSONArray();
eiaReportSet.forEach(eiaReportDTO -> {

View File

@ -36,7 +36,7 @@ public class TaskCheckNoticeRequest extends AbstractRestTemplate<String, JSONObj
}
@Override
public JSONObject postBody() {
public JSONObject body() {
JSONObject noticeJSONObject = new JSONObject();
JSONArray noticeJSONArray = new JSONArray();
enterpriseSet.forEach(enterprise -> {

View File

@ -36,7 +36,7 @@ public class TaskCheckNoticeRequest extends AbstractRestTemplate<String, JSONObj
}
@Override
public JSONObject postBody() {
public JSONObject body() {
JSONObject noticeJSONObject = new JSONObject();
JSONArray noticeJSONArray = new JSONArray();
enterpriseSet.forEach(enterprise -> {

View File

@ -97,13 +97,13 @@ public class PublicAreaReportServiceImpl extends BaseService implements IPublicA
if (StringUtils.isBlank(leaderUserId)) {
throw new SaveException("无上级领导,上报失败");
}
String[] leaderUserIdArray = leaderUserId.split("\\|");
String leaderUserName = gridPersonnelDTO.getLeaderUserName();
PublicLeaderHandleVO publicLeaderHandleVO = new PublicLeaderHandleVO();
publicLeaderHandleVO.setPublicAreaReportId(publicAreaReportId);
publicLeaderHandleVO.setHandleUserId(leaderUserIdArray[0]);
publicLeaderHandleVO.setHandleUserName(leaderUserIdArray[2]);
publicLeaderHandleVO.setHandleUserId(leaderUserId);
publicLeaderHandleVO.setHandleUserName(leaderUserName);
String publicLeaderHandleId = publicLeaderHandleService.savePublicLeaderHandleByTokenReturnId(token, publicLeaderHandleVO);
publicLogService.savePublicLogSimple(token, publicAreaReportId, publicLeaderHandleId, "等待领导处理", leaderUserIdArray[2]);
publicLogService.savePublicLogSimple(token, publicAreaReportId, publicLeaderHandleId, "等待领导处理", leaderUserName);
}
}

View File

@ -26,6 +26,7 @@ import com.cm.inspection.pojo.dtos.taskcheck.v1.TaskCheckReportDTO;
import com.cm.inspection.pojo.vos.taskcheck.v1.TaskCheckReportVO;
import com.cm.inspection.pojo.vos.taskcheck.v1.TaskCheckVO;
import com.cm.inspection.runnable.RunnableExecutor;
import com.cm.inspection.runnable.DeleteServiceRunnable;
import com.cm.inspection.runnable.taskcheck.v1.TaskCheckSaveRunnable;
import com.cm.inspection.service.BaseService;
import com.cm.inspection.service.enterprise.checkitemoption.v1.ICheckItemOptionService;
@ -111,6 +112,12 @@ public class TaskCheckServiceImpl extends BaseService implements ITaskCheckServi
public SuccessResult delete(String ids) throws RemoveException {
Map<String, Object> params = getHashMap(3);
params.put("taskIds", Arrays.asList(ids.split("_")));
// 查询任务关联企业
List<TaskCheckDTO.EnterpriseDTO> taskCheckEnterpriseDTOs = taskCheckDao.listTaskEnterprise(params);
if (taskCheckEnterpriseDTOs.isEmpty()) {
return new SuccessResult();
}
setUpdateInfo(params);
// 删除任务
taskCheckDao.deleteTask(params);
@ -118,6 +125,13 @@ public class TaskCheckServiceImpl extends BaseService implements ITaskCheckServi
taskCheckDao.deleteTaskEnterprise(params);
// 删除任务企业检查项
taskCheckDao.deleteTaskEnterpriseCheckItem(params);
// 更新消息
Set<String> taskEnterpriseIdSet = new HashSet<>();
taskCheckEnterpriseDTOs.forEach(taskCheckEnterprise -> {
taskEnterpriseIdSet.add(taskCheckEnterprise.getTaskId() + ":" + taskCheckEnterprise.getEnterpriseId());
});
RunnableExecutor.execute(new DeleteServiceRunnable(noticeUrl, taskEnterpriseIdSet));
return new SuccessResult();
}

View File

@ -25,6 +25,7 @@ import com.cm.inspection.pojo.dtos.taskcheck.v2.TaskCheckReportCheckItemDTO;
import com.cm.inspection.pojo.dtos.taskcheck.v2.TaskCheckReportDTO;
import com.cm.inspection.pojo.vos.taskcheck.v2.TaskCheckReportVO;
import com.cm.inspection.pojo.vos.taskcheck.v2.TaskCheckVO;
import com.cm.inspection.runnable.DeleteServiceRunnable;
import com.cm.inspection.runnable.RunnableExecutor;
import com.cm.inspection.runnable.taskcheck.v2.TaskCheckSaveRunnable;
import com.cm.inspection.service.BaseService;
@ -111,6 +112,13 @@ public class TaskCheckServiceImpl extends BaseService implements ITaskCheckServi
public SuccessResult delete(String ids) throws RemoveException {
Map<String, Object> params = getHashMap(3);
params.put("taskIds", Arrays.asList(ids.split("_")));
// 查询任务关联企业
List<TaskCheckDTO.EnterpriseDTO> taskCheckEnterpriseDTOs = taskCheckDao.listTaskEnterprise(params);
if (taskCheckEnterpriseDTOs.isEmpty()) {
return new SuccessResult();
}
setUpdateInfo(params);
// 删除任务
taskCheckDao.deleteTask(params);
@ -118,6 +126,13 @@ public class TaskCheckServiceImpl extends BaseService implements ITaskCheckServi
taskCheckDao.deleteTaskEnterprise(params);
// 删除任务企业检查项
taskCheckDao.deleteTaskEnterpriseCheckItem(params);
// 更新消息
Set<String> taskEnterpriseIdSet = new HashSet<>();
taskCheckEnterpriseDTOs.forEach(taskCheckEnterprise -> {
taskEnterpriseIdSet.add(taskCheckEnterprise.getTaskId() + ":" + taskCheckEnterprise.getEnterpriseId());
});
RunnableExecutor.execute(new DeleteServiceRunnable(noticeUrl, taskEnterpriseIdSet));
return new SuccessResult();
}

View File

@ -176,6 +176,13 @@
gen_task_v1 t1
WHERE
t1.is_delete = 0
<if test="taskIds != null and taskIds.size > 0">
AND
t1.task_id IN
<foreach collection="taskIds" index="index" open="(" separator="," close=")">
#{taskIds[${index}]}
</foreach>
</if>
<if test="checkUserId != null and checkUserId != '' and isCompleted != null">
AND
t1.task_id IN (
@ -370,6 +377,13 @@
AND
t1.task_id = #{taskId}
</if>
<if test="taskIds != null and taskIds.size > 0">
AND
t1.task_id IN
<foreach collection="taskIds" index="index" open="(" separator="," close=")">
#{taskIds[${index}]}
</foreach>
</if>
<if test="isCompleted != null">
AND
t1.is_completed = #{isCompleted}