处理流程

This commit is contained in:
wenc000 2020-03-31 19:08:14 +08:00
parent 3b8f2a70a6
commit 4e1d3e2a49
12 changed files with 391 additions and 21 deletions

View File

@ -116,4 +116,20 @@ public class CheckController extends AbstractController {
return securityComponent.getCurrentUserIdInfo();
}
@ApiOperation(value = "我的复查项列表", notes = "我的复查项列表接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listrecheckofmine")
public List<CheckDTO> listReCheckOfMine() {
Map<String, Object> params = requestParams();
return checkService.listReCheckOfMine(params);
}
@ApiOperation(value = "我的领导检查列表", notes = "我的领导检查列表接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listleadercheckofmine")
public List<CheckDTO> listLeaderCheckOfMine() {
Map<String, Object> params = requestParams();
return checkService.listLeaderCheckOfMine(params);
}
}

View File

@ -3,6 +3,7 @@ package com.cm.inspection.controller.app.apis.check;
import com.cm.common.annotation.CheckRequestBodyAnnotation;
import com.cm.common.base.AbstractController;
import com.cm.common.constants.ISystemConstant;
import com.cm.common.exception.ParamsException;
import com.cm.common.exception.RemoveException;
import com.cm.common.exception.SearchException;
import com.cm.common.pojo.ListPage;
@ -16,6 +17,7 @@ import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.jsp.tagext.PageData;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@ -43,6 +45,11 @@ public class CheckAppController extends AbstractController {
@PostMapping("savecheck")
@CheckRequestBodyAnnotation
public SuccessResult saveCheck(@RequestHeader("token") String token, @RequestBody CheckVO checkVO) throws Exception {
if (checkVO.getIsCoordination() == 1) {
if (checkVO.getHiddenDangerReports().isEmpty()) {
throw new ParamsException("检查项列表为空");
}
}
return checkService.saveCheckByToken(token, checkVO);
}
@ -108,4 +115,43 @@ public class CheckAppController extends AbstractController {
return checkService.listPageCheck(page);
}
@ApiOperation(value = "检查表分页列表", notes = "检查表分页列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "form", dataType = "Integer", defaultValue = "1"),
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "form", dataType = "Integer", defaultValue = "20"),
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "form", dataType = "String"),
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "form", dataType = "String"),
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "form", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listpagecheckofmine")
public SuccessResultList<List<CheckDTO>> listPageCheckOfMine(@RequestHeader("token") String token, ListPage page) throws SearchException {
Map<String, Object> params = requestParams();
page.setParams(params);
return checkService.listPageCheckOfMine(token, page);
}
@ApiOperation(value = "我的复查项列表", notes = "我的复查项列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listrecheckofmine")
public List<CheckDTO> listReCheckOfMine(@RequestHeader("token") String token) {
Map<String, Object> params = requestParams();
return checkService.listReCheckOfMine(token, params);
}
@ApiOperation(value = "我的领导检查列表", notes = "我的领导检查列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listleadercheckofmine")
public List<CheckDTO> listLeaderCheckOfMine(@RequestHeader("token") String token) {
Map<String, Object> params = requestParams();
return checkService.listLeaderCheckOfMine(token, params);
}
}

View File

@ -57,6 +57,17 @@ public class EnterpriseOfGridOperatorAppController extends AbstractController {
return enterpriseOfGridOperatorService.removeEnterpriseOfGridOperatorByToken(token, ids);
}
@ApiOperation(value = "删除网格员的企业(通过id物理)", notes = "删除网格员的企业(通过id物理)接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "ids", value = "ID列表用下划线分隔", paramType = "path", example = "1_2_3")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@DeleteMapping("deleteenterpriseofgridoperator/{ids}")
public SuccessResult deleteEnterpriseOfGridOperatorById(@RequestHeader("token") String token, @PathVariable("ids") String ids) throws RemoveException {
return enterpriseOfGridOperatorService.deleteEnterpriseOfGridOperator(ids);
}
@ApiOperation(value = "修改网格员的企业", notes = "修改网格员的企业接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ -108,4 +119,39 @@ public class EnterpriseOfGridOperatorAppController extends AbstractController {
return enterpriseOfGridOperatorService.listPageEnterpriseOfGridOperator(page);
}
@ApiOperation(value = "我的企业分页列表", notes = "我的企业分页列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "form", dataType = "Integer", defaultValue = "1"),
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "form", dataType = "Integer", defaultValue = "20"),
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "form", dataType = "String"),
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "form", dataType = "String"),
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "form", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listpageenterpriseofgridoperatorofmine")
public SuccessResultList<List<EnterpriseOfGridOperatorDTO>> listPageEnterpriseOfGridOperatorOfMine(@RequestHeader("token") String token, ListPage page) throws SearchException {
Map<String, Object> params = requestParams();
page.setParams(params);
return enterpriseOfGridOperatorService.listPageEnterpriseOfGridOperatorOfMine(token, page);
}
@ApiOperation(value = "网格员的企业分页列表通过用户ID", notes = "网格员的企业分页列表通过用户ID接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "userId", value = "用户ID", paramType = "path"),
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "form", dataType = "Integer", defaultValue = "1"),
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "form", dataType = "Integer", defaultValue = "20"),
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "form", dataType = "String"),
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "form", dataType = "String"),
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "form", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listpageenterpriseofgridoperatorbyuserid/{userId}")
public SuccessResultList<List<EnterpriseOfGridOperatorDTO>> listPageEnterpriseOfGridOperatorByUserId(@RequestHeader("token") String token, @PathVariable("userId") String userId, ListPage page) throws SearchException {
Map<String, Object> params = requestParams();
page.setParams(params);
return enterpriseOfGridOperatorService.listPageEnterpriseOfGridOperatorByUserId(userId, page);
}
}

View File

@ -18,14 +18,23 @@ public class SelfCheckReportCompleteListener implements TaskListener {
@Override
public void notify(DelegateTask delegateTask) {
if (delegateTask.getVariable("reReportor") == null) {
if (delegateTask.getVariable("reReporter") != null) {
String reReportor = delegateTask.getVariable("reReporter").toString();
if (StringUtils.isBlank(reReportor)) {
return;
}
delegateTask.setAssignee(reReportor);
return;
}
String reReportor = delegateTask.getVariable("reReportor").toString();
if (StringUtils.isBlank(reReportor)) {
if (delegateTask.getVariable("leader") != null) {
String leader = delegateTask.getVariable("leader").toString();
if (StringUtils.isBlank(leader)) {
return;
}
delegateTask.setAssignee(leader);
return;
}
delegateTask.setAssignee(reReportor);
}
}

View File

@ -108,4 +108,61 @@ public interface ICheckService {
*/
SuccessResultList<List<CheckDTO>> listPageCheck(ListPage page) throws SearchException;
/**
* 我的检查列表分页
*
* @param page
* @return
*/
SuccessResultList<List<CheckDTO>> listPageCheckOfMine(ListPage page) throws SearchException;
/**
* 我的检查列表分页
*
* @param token
* @param page
* @return
* @throws SearchException
*/
SuccessResultList<List<CheckDTO>> listPageCheckOfMine(String token, ListPage page) throws SearchException;
/**
* 我的复查项列表
*
* @param params
* @return
* @throws SearchException
*/
List<CheckDTO> listReCheckOfMine(Map<String, Object> params) throws SearchException;
/**
* 我的复查项列表
*
* @param token
* @param params
* @return
* @throws SearchException
*/
List<CheckDTO> listReCheckOfMine(String token, Map<String, Object> params) throws SearchException;
/**
* 我的领导检查列表
*
* @param params
* @return
* @throws SearchException
*/
List<CheckDTO> listLeaderCheckOfMine(Map<String, Object> params) throws SearchException;
/**
* 我的领导检查列表
*
* @param token
* @param params
* @return
* @throws SearchException
*/
List<CheckDTO> listLeaderCheckOfMine(String token, Map<String, Object> params) throws SearchException;
}

View File

@ -5,23 +5,28 @@ import com.cm.common.exception.SearchException;
import com.cm.common.pojo.ListPage;
import com.cm.common.result.SuccessResult;
import com.cm.common.result.SuccessResultList;
import com.cm.common.token.app.AppTokenManager;
import com.cm.common.utils.HashMapUtil;
import com.cm.common.utils.UUIDUtil;
import com.cm.inspection.dao.check.ICheckDao;
import com.cm.inspection.enums.HiddenDangerCheckResultEnum;
import com.cm.inspection.pojo.dtos.check.CheckDTO;
import com.cm.inspection.pojo.dtos.gridpersonnel.GridPersonnelDTO;
import com.cm.inspection.pojo.vos.check.CheckVO;
import com.cm.inspection.pojo.vos.hiddendangerreport.HiddenDangerReportVO;
import com.cm.inspection.service.BaseService;
import com.cm.inspection.service.check.ICheckService;
import com.cm.inspection.service.gridpersonnel.IGridPersonnelService;
import com.cm.inspection.service.hiddendangerreport.IHiddenDangerReportService;
import com.cm.inspection.service.process.IProcessService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.activiti.engine.task.Task;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@ -42,6 +47,8 @@ public class CheckServiceImpl extends BaseService implements ICheckService {
private IHiddenDangerReportService hiddenDangerReportService;
@Autowired
private IProcessService processService;
@Autowired
private IGridPersonnelService gridPersonnelService;
@Override
public SuccessResult saveCheck(CheckVO checkVO) throws Exception {
@ -66,45 +73,73 @@ public class CheckServiceImpl extends BaseService implements ICheckService {
Integer isCoordination = checkVO.getIsCoordination();
String checkId = UUIDUtil.getUUID();
Map<String, Object> params = HashMapUtil.beanToMap(checkVO);
params.put("checkId", checkId);
if (token != null) {
setSaveInfo(token, params);
} else {
setSaveInfo(params);
}
checkDao.saveCheck(params);
saveCheckWithId(checkId, token, params);
LOG.debug("开启流程");
String userId = params.get("creator").toString();
String businessKey = String.format("check:%s", checkId);
params.clear();
params.put("reporter", userId);
processService.startProcess(IProcessService.CHECK_SELF_PROCESS, businessKey, params);
Task task = processService.getTaskByAssigneeAndBusinessKey(userId, businessKey);
params.clear();
params.put("isCoordination", isCoordination);
if (isCoordination == 1) {
LOG.debug("isCoordination: 1");
LOG.debug("1.isCoordination: 1, 配合");
List<HiddenDangerReportVO> hiddenDangerReports = checkVO.getHiddenDangerReports();
int isAllPass = 1;
for (HiddenDangerReportVO hiddenDangerReportVO : hiddenDangerReports) {
hiddenDangerReportService.saveHiddenDangerReport(hiddenDangerReportVO);
hiddenDangerReportVO.setCheckId(checkId);
hiddenDangerReportService.saveHiddenDangerReportInfo(token, hiddenDangerReportVO);
if (HiddenDangerCheckResultEnum.PASS.getValue() != hiddenDangerReportVO.getCheckResult()) {
isAllPass = 0;
}
}
LOG.debug("isAllPass: {}", isAllPass);
LOG.debug("2.isAllPass: {}", isAllPass);
params.put("isAllPass", isAllPass);
if (isAllPass == 0) {
LOG.debug("检查项没有完全通过,需要复查");
params.put("reReportor", userId);
LOG.debug("3.检查项没有完全通过,需要复查");
params.put("reReporter", userId);
processService.setTaskVariableByTaskId(task.getId(), "isReport", 1);
LOG.debug("4.标记上一次的检查项");
processService.setTaskVariableByTaskId(task.getId(), "lastCheckId", checkId);
} else {
LOG.debug("3.全部通过,更新当前检查状态");
CheckVO updateCheckVO = new CheckVO();
updateCheckVO.setIsComplete(1);
updateCheck(checkId, updateCheckVO);
}
} else {
LOG.debug("1.isCoordination2, 不配合");
// 查询上级领导如果上级领导为空指向自己如果有多个网格员角色取最高level的上级领导
List<GridPersonnelDTO> gridPersonnelDTOs = gridPersonnelService.listGridPersonnelByUserIdAndIsGridOperator(userId, 1);
if (gridPersonnelDTOs.isEmpty()) {
params.put("leader", userId);
} else {
params.put("leader", gridPersonnelDTOs.get(0).getUserId().split("\\|")[0]);
}
processService.setTaskVariableByTaskId(task.getId(), "isLeader", 1);
LOG.debug("2.标记上一次的检查项");
processService.setTaskVariableByTaskId(task.getId(), "lastCheckId", checkId);
}
processService.saveTaskCompleteByTaskId(task.getId(), params);
}
/**
* 保存检查项
*
* @param checkId
* @param token
* @throws Exception
*/
private void saveCheckWithId(String checkId, String token, Map<String, Object> params) throws Exception {
params.put("checkId", checkId);
if (token != null) {
setSaveInfo(token, params);
} else {
setSaveInfo(params);
}
checkDao.saveCheck(params);
}
@Override
public SuccessResult removeCheck(String ids) throws RemoveException {
removeCheckInfo(null, ids);
@ -184,4 +219,83 @@ public class CheckServiceImpl extends BaseService implements ICheckService {
return new SuccessResultList<>(checkDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
}
@Override
public SuccessResultList<List<CheckDTO>> listPageCheckOfMine(ListPage page) throws SearchException {
String userId = getUserId(null);
page.getParams().put("creator", userId);
return listPageCheck(page);
}
@Override
public SuccessResultList<List<CheckDTO>> listPageCheckOfMine(String token, ListPage page) throws SearchException {
String userId = getUserId(token);
page.getParams().put("creator", userId);
return listPageCheck(page);
}
@Override
public List<CheckDTO> listReCheckOfMine(Map<String, Object> params) throws SearchException {
return listReCheckOfMine(null, params);
}
@Override
public List<CheckDTO> listLeaderCheckOfMine(Map<String, Object> params) throws SearchException {
return listLeaderCheckOfMine(null, params);
}
@Override
public List<CheckDTO> listLeaderCheckOfMine(String token, Map<String, Object> params) {
List<String> checkIds = listLastCheckId(getUserId(token), "isLeader");
if (checkIds.isEmpty()) {
return new ArrayList<>();
}
params.put("checkIds", checkIds);
return listCheck(params);
}
/**
* 我的待复查列表
*
* @param token
* @param params
* @return
*/
@Override
public List<CheckDTO> listReCheckOfMine(String token, Map<String, Object> params) {
List<String> checkIds = listLastCheckId(getUserId(token), "isReport");
if (checkIds.isEmpty()) {
return new ArrayList<>();
}
params.put("checkIds", checkIds);
return listCheck(params);
}
/**
* 获取用户ID
*
* @param token
* @return
*/
private String getUserId(String token) {
String userId;
if (StringUtils.isBlank(token)) {
userId = securityComponent.getCurrentUser().getUserId();
} else {
userId = AppTokenManager.getInstance().getToken(token).getAppTokenUser().getId();
}
return userId;
}
private List<String> listLastCheckId(String userId, String isKeyString) {
List<Task> tasks = processService.listTaskByAssignee(userId);
List<String> lastCheckId = new ArrayList<>();
for (Task task : tasks) {
Object isKeyObj = processService.getTaskVariableByTaskId(task.getId(), isKeyString);
if (isKeyObj != null && Integer.parseInt(isKeyObj.toString()) == 1) {
lastCheckId.add(processService.getTaskVariableByTaskId(task.getId(), "lastCheckId").toString());
}
}
return lastCheckId;
}
}

View File

@ -108,4 +108,13 @@ public interface IGridPersonnelService {
*/
SuccessResultList<List<GridPersonnelDTO>> listPageGridPersonnel(ListPage page) throws SearchException;
/**
* 网格人员列表通过用户名和是否是网格员
*
* @param userId
* @param isGridOperator
* @return
* @throws SearchException
*/
List<GridPersonnelDTO> listGridPersonnelByUserIdAndIsGridOperator(String userId, int isGridOperator) throws SearchException;
}

View File

@ -142,4 +142,12 @@ public class GridPersonnelServiceImpl extends BaseService implements IGridPerson
return new SuccessResultList<>(gridPersonnelDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
}
@Override
public List<GridPersonnelDTO> listGridPersonnelByUserIdAndIsGridOperator(String userId, int isGridOperator) throws SearchException {
Map<String, Object> params = getHashMap(2);
params.put("userId", userId);
params.put("isGridOperator", isGridOperator);
return listGridPersonnel(params);
}
}

View File

@ -41,6 +41,15 @@ public interface IHiddenDangerReportService {
*/
SuccessResult saveHiddenDangerReportByToken(String token, HiddenDangerReportVO hiddenDangerReportVO) throws Exception;
/**
* 新增隐患上报
*
* @param token
* @param hiddenDangerReportVO
* @throws Exception
*/
void saveHiddenDangerReportInfo(String token, HiddenDangerReportVO hiddenDangerReportVO) throws Exception;
/**
* 删除隐患上报
*

View File

@ -52,7 +52,8 @@ public class HiddenDangerReportServiceImpl extends BaseService implements IHidde
* @param hiddenDangerReportVO
* @throws Exception
*/
private void saveHiddenDangerReportInfo(String token, HiddenDangerReportVO hiddenDangerReportVO) throws Exception {
@Override
public void saveHiddenDangerReportInfo(String token, HiddenDangerReportVO hiddenDangerReportVO) throws Exception {
Map<String, Object> params = HashMapUtil.beanToMap(hiddenDangerReportVO);
params.put("hiddenDangerReportId", UUIDUtil.getUUID());
if (token != null) {

View File

@ -80,6 +80,7 @@ public interface IProcessService {
/**
* 获取任务通过流程ID
*
* @param listTask
* @param processId
* @return
*/
@ -94,6 +95,40 @@ public interface IProcessService {
*/
Task getTaskByAssigneeAndProcessId(String assignee, String processId);
/**
* 设置任务变量
*
* @param taskId
* @param variables
*/
void setTaskVariablesByTaskId(String taskId, Map<String, Object> variables);
/**
* 设置任务变量
*
* @param taskId
* @param key
* @param value
*/
void setTaskVariableByTaskId(String taskId, String key, Object value);
/**
* 获取任务变量
*
* @param taskId
* @return
*/
Map<String, Object> getTaskVariablesByTaskId(String taskId);
/**
* 获取任务变量
*
* @param taskId
* @param key
* @return
*/
Object getTaskVariableByTaskId(String taskId, String key);
/**
* 完成案件通过taskId
*

View File

@ -101,6 +101,26 @@ public class ProcessServiceImpl implements IProcessService {
return getTaskByProcessId(taskList, processId);
}
@Override
public void setTaskVariablesByTaskId(String taskId, Map<String, Object> variables) {
taskService.setVariables(taskId, variables);
}
@Override
public void setTaskVariableByTaskId(String taskId, String key, Object value) {
taskService.setVariable(taskId, key, value);
}
@Override
public Map<String, Object> getTaskVariablesByTaskId(String taskId) {
return taskService.getVariables(taskId);
}
@Override
public Object getTaskVariableByTaskId(String taskId, String key) {
return taskService.getVariable(taskId, key);
}
@Override
public void saveTaskCompleteByTaskId(String taskId, Map<String, Object> params) {
taskService.complete(taskId, params);