Commit 43cc2fe0 authored by tianbo's avatar tianbo

隐患流程修改

parent 8214b40c
package com.yeejoin.amos.latentdanger.common.enums;
/**
* @author DELL
*/
public enum ExecuteTypeEnum {
/**
* 未执行
*/
未执行("未执行", -1),
通过("通过", 0),
驳回("驳回", 1);
/**
* 名称,描述
*/
private String name;
/**
* 编码
*/
private Integer code;
ExecuteTypeEnum(String name, Integer code) {
this.name = name;
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public static ExecuteTypeEnum getByCode(Integer code) {
for (ExecuteTypeEnum e : ExecuteTypeEnum.values()) {
if (code.equals(e.getCode())) {
return e;
}
}
return null;
}
}
package com.yeejoin.amos.latentdanger.common.enums; package com.yeejoin.amos.latentdanger.common.enums;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import java.util.List;
import java.util.Map;
/** /**
* @author DELL * @author DELL
*/ */
...@@ -11,7 +17,9 @@ public interface LatentDangerState { ...@@ -11,7 +17,9 @@ public interface LatentDangerState {
* @param code * @param code
* @return * @return
*/ */
LatentDangerState getEnumByCode(String code); static LatentDangerState getEnumByCode(String code) {
return null;
}
/** /**
* 根据code获取枚举名称 * 根据code获取枚举名称
...@@ -19,7 +27,9 @@ public interface LatentDangerState { ...@@ -19,7 +27,9 @@ public interface LatentDangerState {
* @param code * @param code
* @return * @return
*/ */
String getEnumNameByCode(String code); static String getEnumNameByCode(String code) {
return null;
}
enum SupervisionDangerStateEnum implements LatentDangerState { enum SupervisionDangerStateEnum implements LatentDangerState {
/** /**
...@@ -129,16 +139,7 @@ public interface LatentDangerState { ...@@ -129,16 +139,7 @@ public interface LatentDangerState {
this.rejectNext = rejectNext; this.rejectNext = rejectNext;
} }
public LatentDangerState getNextEnum() { public static SupervisionDangerStateEnum getEnumByCode(String code) {
return getEnumByCode(next);
}
public LatentDangerState getRejectNextEnum() {
return getEnumByCode(rejectNext);
}
@Override
public LatentDangerState getEnumByCode(String code) {
for (SupervisionDangerStateEnum _enum : SupervisionDangerStateEnum.values()) { for (SupervisionDangerStateEnum _enum : SupervisionDangerStateEnum.values()) {
if (code.equals(_enum.getCode())) { if (code.equals(_enum.getCode())) {
return _enum; return _enum;
...@@ -147,8 +148,7 @@ public interface LatentDangerState { ...@@ -147,8 +148,7 @@ public interface LatentDangerState {
return null; return null;
} }
@Override public static String getEnumNameByCode(String code) {
public String getEnumNameByCode(String code) {
String enumName = ""; String enumName = "";
for(SupervisionDangerStateEnum type: SupervisionDangerStateEnum.values()) { for(SupervisionDangerStateEnum type: SupervisionDangerStateEnum.values()) {
if (type.getCode().equals(code)) { if (type.getCode().equals(code)) {
...@@ -158,6 +158,17 @@ public interface LatentDangerState { ...@@ -158,6 +158,17 @@ public interface LatentDangerState {
} }
return enumName; return enumName;
} }
public static List<Map<String, String>> getEnumList() {
List<Map<String, String>> enumList = Lists.newArrayList();
for(SupervisionDangerStateEnum type: SupervisionDangerStateEnum.values()) {
Map<String, String> resultMap = Maps.newHashMap();
resultMap.put("key", type.getCode());
resultMap.put("name", type.getName());
enumList.add(resultMap);
}
return enumList;
}
} }
enum PatrolDangerLevelEnum implements LatentDangerState { enum PatrolDangerLevelEnum implements LatentDangerState {
...@@ -205,7 +216,6 @@ public interface LatentDangerState { ...@@ -205,7 +216,6 @@ public interface LatentDangerState {
this.code = code; this.code = code;
} }
@Override
public LatentDangerState getEnumByCode(String code) { public LatentDangerState getEnumByCode(String code) {
for (PatrolDangerLevelEnum _enum : PatrolDangerLevelEnum.values()) { for (PatrolDangerLevelEnum _enum : PatrolDangerLevelEnum.values()) {
if (code.equals(_enum.getCode())) { if (code.equals(_enum.getCode())) {
...@@ -215,7 +225,6 @@ public interface LatentDangerState { ...@@ -215,7 +225,6 @@ public interface LatentDangerState {
return null; return null;
} }
@Override
public String getEnumNameByCode(String code) { public String getEnumNameByCode(String code) {
String enumName = ""; String enumName = "";
for(PatrolDangerLevelEnum type: PatrolDangerLevelEnum.values()) { for(PatrolDangerLevelEnum type: PatrolDangerLevelEnum.values()) {
...@@ -226,5 +235,16 @@ public interface LatentDangerState { ...@@ -226,5 +235,16 @@ public interface LatentDangerState {
} }
return enumName; return enumName;
} }
public static List<Map<String, String>> getEnumList() {
List<Map<String, String>> enumList = Lists.newArrayList();
for(PatrolDangerLevelEnum type: PatrolDangerLevelEnum.values()) {
Map<String, String> resultMap = Maps.newHashMap();
resultMap.put("key", type.getCode());
resultMap.put("name", type.getName());
enumList.add(resultMap);
}
return enumList;
}
} }
} }
...@@ -215,5 +215,5 @@ public class LatentDanger extends BasicEntity { ...@@ -215,5 +215,5 @@ public class LatentDanger extends BasicEntity {
* 业务信息 * 业务信息
*/ */
@Column(name = "biz_info") @Column(name = "biz_info")
private JSONObject bizInfo; private String bizInfo;
} }
...@@ -125,8 +125,7 @@ public class LatentDangerController extends BaseController { ...@@ -125,8 +125,7 @@ public class LatentDangerController extends BaseController {
public ResponseModel<LatentDangerDetailVo> detail(@ApiParam(value = "隐患Id", required = true) @RequestParam Long dangerId, public ResponseModel<LatentDangerDetailVo> detail(@ApiParam(value = "隐患Id", required = true) @RequestParam Long dangerId,
@ApiParam(value = "是否完成") @RequestParam(required = false) boolean isFinish) throws Exception { @ApiParam(value = "是否完成") @RequestParam(required = false) boolean isFinish) throws Exception {
AgencyUserModel user = getUserInfo(); AgencyUserModel user = getUserInfo();
throw new Exception("aaaa"); return iLatentDangerService.detail(dangerId, user.getUserId(), isFinish);
// return iLatentDangerService.detail(dangerId, user.getUserId(), isFinish);
} }
@ApiOperation(value = "隐患执行记录", notes = "隐患执行记录") @ApiOperation(value = "隐患执行记录", notes = "隐患执行记录")
...@@ -300,4 +299,11 @@ public class LatentDangerController extends BaseController { ...@@ -300,4 +299,11 @@ public class LatentDangerController extends BaseController {
public ResponseModel<Boolean> delete(@RequestParam String ids) throws Exception { public ResponseModel<Boolean> delete(@RequestParam String ids) throws Exception {
return ResponseHelper.buildResponse(iLatentDangerService.delete(ids)); return ResponseHelper.buildResponse(iLatentDangerService.delete(ids));
} }
@ApiOperation(value = "隐患状态列表", notes = "隐患状态列表")
@GetMapping(value = "/state")
@TycloudOperation(ApiLevel = UserType.AGENCY)
public ResponseModel getDangerState() {
return ResponseHelper.buildResponse(iLatentDangerService.getDangerState());
}
} }
...@@ -39,17 +39,29 @@ public class PageParam<K, V> extends HashMap<K, V> implements Pageable { ...@@ -39,17 +39,29 @@ public class PageParam<K, V> extends HashMap<K, V> implements Pageable {
this.offset = size * current; this.offset = size * current;
} }
public PageParam(int pageNumber, int size) { public PageParam(int current, int size) {
this.current = pageNumber; this.current = current;
this.size = size; this.size = size;
this.offset = size * pageNumber; this.offset = size * current;
} }
public PageParam(int pageNumber, int size, Sort sort) { public PageParam(int current, int size, Sort sort) {
this.current = pageNumber; this.current = current;
this.size = size; this.size = size;
this.sort = sort; this.sort = sort;
this.offset = size * pageNumber; this.offset = size * current;
}
public int getCurrent() {
return current;
}
public void setCurrent(int current) {
this.current = current;
}
public int getSize() {
return size;
} }
public void setSize(int size) { public void setSize(int size) {
......
...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; ...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
...@@ -50,6 +51,7 @@ import com.yeejoin.amos.latentdanger.business.vo.LatentDangerListVo; ...@@ -50,6 +51,7 @@ import com.yeejoin.amos.latentdanger.business.vo.LatentDangerListVo;
import com.yeejoin.amos.latentdanger.common.enums.DangerHandleStateEnum; import com.yeejoin.amos.latentdanger.common.enums.DangerHandleStateEnum;
import com.yeejoin.amos.latentdanger.common.enums.DictTypeEnum; import com.yeejoin.amos.latentdanger.common.enums.DictTypeEnum;
import com.yeejoin.amos.latentdanger.common.enums.ExecuteStateEnum; import com.yeejoin.amos.latentdanger.common.enums.ExecuteStateEnum;
import com.yeejoin.amos.latentdanger.common.enums.ExecuteTypeEnum;
import com.yeejoin.amos.latentdanger.common.enums.InstanceKeyEnum; import com.yeejoin.amos.latentdanger.common.enums.InstanceKeyEnum;
import com.yeejoin.amos.latentdanger.common.enums.LatentDangerBizTypeEnum; import com.yeejoin.amos.latentdanger.common.enums.LatentDangerBizTypeEnum;
import com.yeejoin.amos.latentdanger.common.enums.LatentDangerExecuteTypeEnum; import com.yeejoin.amos.latentdanger.common.enums.LatentDangerExecuteTypeEnum;
...@@ -1100,27 +1102,49 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD ...@@ -1100,27 +1102,49 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
private DangerExecuteSubmitDto executeSupervisionBiz(LatentDangerExecuteParam param, LatentDanger latentDanger, String userId, String userRealName, String departmentId, String departmentName, DangerExecuteSubmitDto executeSubmitDto, RoleBo role) throws Exception { private DangerExecuteSubmitDto executeSupervisionBiz(LatentDangerExecuteParam param, LatentDanger latentDanger, String userId, String userRealName, String departmentId, String departmentName, DangerExecuteSubmitDto executeSubmitDto, RoleBo role) throws Exception {
// TODO 查询隐患的巡查信息 // TODO 查询隐患的巡查信息
String planType = "special"; JSONObject bizInfo = JSONObject.parseObject(latentDanger.getBizInfo());
String taskUserId = "256"; if (ValidationUtil.isEmpty(bizInfo)) {
executeSubmitDto.setIsOk(false);
executeSubmitDto.setMsg("业务信息错误");
return executeSubmitDto;
}
String planType = ValidationUtil.isEmpty(bizInfo.get("planType")) ? "special" :
bizInfo.get("planType").toString();
String taskUserId = ValidationUtil.isEmpty(bizInfo.get("taskUserId")) ? userId :
bizInfo.get("taskUserId").toString();
String processInstanceId = latentDanger.getInstanceId(); String processInstanceId = latentDanger.getInstanceId();
String dangerState = latentDanger.getDangerState(); String currentDangerState = latentDanger.getDangerState();
LatentDangerState.SupervisionDangerStateEnum currentStateEnum =
LatentDangerState.SupervisionDangerStateEnum.getEnumByCode(currentDangerState);
String executeResultMsg = ""; String executeResultMsg = "";
String condition = ""; String condition;
// 日志信息
LatentDangerFlowRecord record;
// 第一次处于待现场确认时,启动工作流 // 第一次处于待现场确认时,启动工作流
if (ValidationUtil.isEmpty(processInstanceId)) { if (ValidationUtil.isEmpty(processInstanceId)) {
// 1、开启工作流 // 1、开启工作流
JSONObject result = workflowFeignService.startByVariable(workflowProcessDefinitionKey); JSONObject body = new JSONObject();
if (result == null) { body.put("businessKey", latentDanger.getBusinessKey());
body.put("processDefinitionKey", workflowProcessDefinitionKey);
JSONObject result = workflowFeignService.startByVariable(body);
if (result == null || ValidationUtil.isEmpty(result.get("data"))) {
executeSubmitDto.setIsOk(false); executeSubmitDto.setIsOk(false);
executeSubmitDto.setMsg("启动工作流失败"); executeSubmitDto.setMsg("启动工作流失败");
return executeSubmitDto; return executeSubmitDto;
} }
latentDanger.setInstanceId((String) result.get("instanceId")); Map resultData = (Map) result.get("data");
latentDanger.setInstanceId((String) resultData.get("id"));
latentDanger.setUpdateDate(new Date()); latentDanger.setUpdateDate(new Date());
latentDanger.setDangerState(LatentDangerState.SupervisionDangerStateEnum.现场确认.getCode()); latentDanger.setDangerState(LatentDangerState.SupervisionDangerStateEnum.现场确认.getCode());
latentDanger.setDangerStateName(LatentDangerState.SupervisionDangerStateEnum.现场确认.getName()); latentDanger.setDangerStateName(LatentDangerState.SupervisionDangerStateEnum.现场确认.getName());
// 保存日志信息
record = saveFlowRecord("", latentDanger.getDangerStateName(), userId, departmentId, null, latentDanger.getId(), role, "", "");
latentDanger.setCurrentFlowRecordId(record.getId());
this.updateById(latentDanger); this.updateById(latentDanger);
executeSubmitDto.setIsOk(true); executeSubmitDto.setIsOk(true);
executeSubmitDto.setMsg(latentDanger.getDangerStateName()); executeSubmitDto.setMsg(latentDanger.getDangerStateName());
return executeSubmitDto; return executeSubmitDto;
...@@ -1133,25 +1157,51 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD ...@@ -1133,25 +1157,51 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
} }
// 执行任务(带权限校验) // 执行任务(带权限校验)
workflowExecuteService.CompleteTask(processInstanceId, condition); Boolean executeResult = workflowExecuteService.CompleteTask(processInstanceId, condition);
if (!executeResult) {
// 当隐患状态是现场确认时,在执行完节点后需要将检查组长id设置为下个节点执行人 executeSubmitDto.setIsOk(false);
if (LatentDangerState.SupervisionDangerStateEnum.现场确认.getCode().equals(dangerState)) { executeResultMsg = "任务执行失败";
Object result = workflowExecuteService.setTaskAssign(processInstanceId, taskUserId); }
if (!(Boolean) result) {
executeSubmitDto.setIsOk(false); String nextState = "";
executeResultMsg = "设置节点执行人失败"; String nextStateName = "";
if (ExecuteTypeEnum.通过.getCode() == param.getExecuteType()) {
// 执行成功更新隐患状态
LatentDangerState.SupervisionDangerStateEnum nextStateEnum =
LatentDangerState.SupervisionDangerStateEnum.getEnumByCode(currentStateEnum.getNext());
nextState = nextStateEnum.getCode();
nextStateName = nextStateEnum.getName();
// 当隐患状态是现场确认时,在执行完节点后需要将检查组长id设置为下个节点执行人
if (LatentDangerState.SupervisionDangerStateEnum.现场确认.getCode().equals(currentDangerState)) {
Object result = workflowExecuteService.setTaskAssign(processInstanceId, taskUserId);
if (!(Boolean) result) {
executeSubmitDto.setIsOk(false);
executeResultMsg = "设置节点执行人失败";
}
} }
} else {
LatentDangerState.SupervisionDangerStateEnum nextStateEnum =
LatentDangerState.SupervisionDangerStateEnum.getEnumByCode(currentStateEnum.getRejectNext());
nextState = nextStateEnum.getCode();
nextStateName = nextStateEnum.getName();
executeResultMsg = nextStateName + "拒绝";
} }
latentDanger.setDangerState(nextState);
latentDanger.setDangerStateName(nextStateName);
if (LatentDangerState.SupervisionDangerStateEnum.整改检查分管领导确认.getCode().equals(dangerState)
|| LatentDangerState.SupervisionDangerStateEnum.整改二次审核确认.getCode().equals(dangerState)) { if (LatentDangerState.SupervisionDangerStateEnum.整改检查分管领导确认.getCode().equals(currentDangerState)
|| LatentDangerState.SupervisionDangerStateEnum.整改二次审核确认.getCode().equals(currentDangerState)) {
latentDanger.setDangerState(LatentDangerState.SupervisionDangerStateEnum.整改完毕.getCode()); latentDanger.setDangerState(LatentDangerState.SupervisionDangerStateEnum.整改完毕.getCode());
latentDanger.setDangerStateName(LatentDangerState.SupervisionDangerStateEnum.整改完毕.getName()); latentDanger.setDangerStateName(LatentDangerState.SupervisionDangerStateEnum.整改完毕.getName());
executeResultMsg = latentDanger.getDangerStateName(); executeResultMsg = latentDanger.getDangerStateName();
} }
record = saveFlowRecord("", latentDanger.getDangerStateName(), userId, departmentId, null, latentDanger.getId(), role,
executeResultMsg, "");
latentDanger.setCurrentFlowRecordId(record.getId());
this.updateById(latentDanger); this.updateById(latentDanger);
executeSubmitDto.setIsOk(true); executeSubmitDto.setIsOk(true);
executeSubmitDto.setMsg(executeResultMsg); executeSubmitDto.setMsg(executeResultMsg);
...@@ -1542,9 +1592,9 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD ...@@ -1542,9 +1592,9 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
@Override @Override
public IPage<LatentDanger> listDanger(PageParam pageParam) { public IPage<LatentDanger> listDanger(PageParam pageParam) {
String idsStr = (String) pageParam.get("dangerIds"); String idsStr = (String) pageParam.get("dangerIds");
List<String> dangerIdList = Lists.newArrayList();
if (StringUtil.isNotEmpty(idsStr)) { if (StringUtil.isNotEmpty(idsStr)) {
List<String> dangerIdList = Lists.newArrayList(idsStr.split(",")); dangerIdList = Lists.newArrayList(idsStr.split(","));
pageParam.put("dangerIds", dangerIdList);
} }
// if (StringUtil.isNotEmpty(pageParam.get("current")) && StringUtil.isNotEmpty(pageParam.get("size"))) { // if (StringUtil.isNotEmpty(pageParam.get("current")) && StringUtil.isNotEmpty(pageParam.get("size"))) {
// int offSet = (int) pageParam.get("current") * (int) pageParam.get("size"); // int offSet = (int) pageParam.get("current") * (int) pageParam.get("size");
...@@ -1572,6 +1622,7 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD ...@@ -1572,6 +1622,7 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
eq(!ValidationUtil.isEmpty(pageParam.get("dangerState")), LatentDanger::getDangerState, eq(!ValidationUtil.isEmpty(pageParam.get("dangerState")), LatentDanger::getDangerState,
pageParam.get("dangerState")) pageParam.get("dangerState"))
.eq(LatentDanger::getDeleted, false) .eq(LatentDanger::getDeleted, false)
.in(!ValidationUtil.isEmpty(pageParam.get("dangerIds")), LatentDanger::getId, dangerIdList)
.in(!ValidationUtil.isEmpty(structureIdList), LatentDanger::getStructureId, structureIdList); .in(!ValidationUtil.isEmpty(structureIdList), LatentDanger::getStructureId, structureIdList);
return latentDangerMapper.selectPage(page, queryWrapper); return latentDangerMapper.selectPage(page, queryWrapper);
...@@ -1716,6 +1767,32 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD ...@@ -1716,6 +1767,32 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
if (dangerIdList.size() != dangerList.size()) { if (dangerIdList.size() != dangerList.size()) {
throw new Exception("执行中隐患不能删除"); throw new Exception("执行中隐患不能删除");
} }
return this.deleteBatchSeq(dangerIdList);
LambdaQueryWrapper<LatentDangerFlowRecord> recordQueryWrapper = new LambdaQueryWrapper<>();
recordQueryWrapper.in(LatentDangerFlowRecord::getDangerId, dangerIdList);
List<LatentDangerFlowRecord> recordList = latentDangerFlowRecordService.list(recordQueryWrapper);
if (!ValidationUtil.isEmpty(recordList)) {
recordList.forEach(r -> r.setDeleted(true));
}
latentDangerFlowRecordService.saveOrUpdateBatch(recordList);
LambdaQueryWrapper<LatentDanger> dangerQueryWrapper = new LambdaQueryWrapper<>();
dangerQueryWrapper.in(LatentDanger::getId, dangerIdList);
List<LatentDanger> dangers = this.list(dangerQueryWrapper);
if (!ValidationUtil.isEmpty(dangers)) {
dangers.forEach(r -> r.setDeleted(true));
}
return this.saveOrUpdateBatch(dangers);
}
@Override
public List<Map<String, String>> getDangerState() {
String bizType = redisUtils.get(Constants.DANGER_BIZ_TYPE_KEY).toString();
if (LatentDangerBizTypeEnum.防火监督.getCode().equals(bizType)) {
return LatentDangerState.SupervisionDangerStateEnum.getEnumList();
} else {
return LatentDangerState.PatrolDangerLevelEnum.getEnumList();
}
} }
} }
...@@ -123,4 +123,11 @@ public interface ILatentDangerService { ...@@ -123,4 +123,11 @@ public interface ILatentDangerService {
* @return * @return
*/ */
Boolean delete(String ids) throws Exception; Boolean delete(String ids) throws Exception;
/**
* 获取隐患状态
*
* @return
*/
List<Map<String, String>> getDangerState();
} }
...@@ -69,7 +69,6 @@ public class LatentDangerApplication { ...@@ -69,7 +69,6 @@ public class LatentDangerApplication {
public static void main(String[] args) throws UnknownHostException { public static void main(String[] args) throws UnknownHostException {
logger.info("start Service.........."); logger.info("start Service..........");
ConfigurableApplicationContext context = SpringApplication.run(LatentDangerApplication.class, args); ConfigurableApplicationContext context = SpringApplication.run(LatentDangerApplication.class, args);
GlobalExceptionHandler.setAlwaysOk(true);
Environment env = context.getEnvironment(); Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress(); String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port"); String port = env.getProperty("server.port");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment