Commit 3bab2240 authored by chenhao's avatar chenhao

Merge branch 'developer' of http://172.16.10.76/moa/amos-boot-biz into developer

parents 6513192c 62658dd3
......@@ -40,6 +40,16 @@ public interface IWorkflowExcuteService{
* @return
*/
boolean CompleteTask(String processInstanceId,String condition, ReginParams userInfo);
/**
* 查询并执行一步工作流-无权限
* @param procressId 流程id
* @param condition 条件
* @return boolean
* @throws Exception
*/
boolean excuteTask(String procressId, String condition) throws Exception;
}
......@@ -107,6 +107,7 @@ public class WorkflowExcuteServiceImpl implements IWorkflowExcuteService {
return map;
}
@Override
public boolean excuteTask(String procressId, String condition) throws Exception {
HashMap<String, Object> conditionMap = new HashMap<String, Object>();
conditionMap.put("condition", condition);
......
package com.yeejoin.amos.supervision.common.enums;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
public enum CheckTypeSuEnum {
/**
* @author DELL
*/
public enum CheckTypeSuEnum {
/**
* 检查类型枚举
*/
SUPERVISED("日常检查", "1", "supervised"),
DAILY("专项检查", "2", "daily");
......@@ -39,6 +42,17 @@ public enum CheckTypeSuEnum {
}).collect(Collectors.toList());
}
/**
* 获取枚举
* @param code 编号
* @return CheckTypeSuEnum
* @throws Exception
*/
public static CheckTypeSuEnum getEumByCode(String code) throws Exception {
Optional<CheckTypeSuEnum> op = Arrays.stream(CheckTypeSuEnum.values()).filter(e->e.code.equals(code)).findFirst();
return op.orElseThrow(()->new Exception("不存在"));
}
public String getName() {
return name;
}
......
......@@ -3,6 +3,7 @@ package com.yeejoin.amos.supervision.business.controller;
import java.util.HashMap;
import java.util.List;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.supervision.common.enums.PlanStatusEnum;
import com.yeejoin.amos.supervision.core.common.request.AddPlanRequest;
import com.yeejoin.amos.supervision.core.common.response.PlanPointRespone;
......@@ -89,14 +90,15 @@ public class PlanController extends AbstractBaseController {
@RequestMapping(value = "/addPlan", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse checkPlanAdd(@ApiParam(value = "巡检计划", required = true) @RequestBody AddPlanRequest param) {
try {
String userId = getUserId();
AgencyUserModel user = getUserInfo();
ReginParams reginParams = getSelectedOrgInfo();
String loginOrgCode = getOrgCode(reginParams);
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("org_code", loginOrgCode);
map.put("user_id", userId);
map.put("user_id", user.getUserId());
map.put("user_name", user.getRealName());
map.put("param", param);
planService.addPlan(map);
planService.addPlan(map,reginParams);
return CommonResponseUtil.success();
} catch (Exception e) {
log.error(e.getMessage(), e);
......
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.supervision.business.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.google.common.base.Joiner;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.service.IWorkflowExcuteService;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.supervision.business.constants.XJConstant;
......@@ -15,10 +16,7 @@ import com.yeejoin.amos.supervision.common.enums.PlanStatusEnum;
import com.yeejoin.amos.supervision.core.common.request.AddPlanRequest;
import com.yeejoin.amos.supervision.core.common.response.PlanPointRespone;
import com.yeejoin.amos.supervision.core.util.DateUtil;
import com.yeejoin.amos.supervision.dao.entity.Plan;
import com.yeejoin.amos.supervision.dao.entity.PlanAudit;
import com.yeejoin.amos.supervision.dao.entity.Route;
import com.yeejoin.amos.supervision.dao.entity.RoutePoint;
import com.yeejoin.amos.supervision.dao.entity.*;
import com.yeejoin.amos.supervision.feign.RemoteSecurityService;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
......@@ -66,12 +64,6 @@ public class PlanServiceImpl implements IPlanService {
private IRoutePointDao iRoutePointDao;
@Autowired
private IRoutePointItemDao iRoutePointItemDao;
@Autowired
private IPointInputItemDao iPointInputItemDao;
@Autowired
private IPlanService planService;
@Autowired
......@@ -86,7 +78,8 @@ public class PlanServiceImpl implements IPlanService {
@Value("${work.flow.processDefinitionKey}")
private String processDefinitionKey;
private static final Logger logger = LoggerFactory.getLogger(PlanServiceImpl.class);
@Autowired
private IPlanAuditLogDao planAuditLogDao;
@Override
public Page<HashMap<String, Object>> getPlanInfo(PlanInfoPageParam param) {
......@@ -126,37 +119,15 @@ public class PlanServiceImpl implements IPlanService {
}
@Override
@Transactional
public void addPlan(HashMap<String, Object> map) {
@Transactional(rollbackFor = Exception.class)
public void addPlan(HashMap<String, Object> map, ReginParams reginParams) throws Exception {
// 新增路线
AddPlanRequest addPlanRequest = (AddPlanRequest) map.get("param");
Plan param = addPlanRequest.getPlan();
ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity();
String orgCode = map.get("org_code") == null ? "" : map.get("org_code").toString();
String userId = map.get("user_id") == null ? "" : map.get("user_id").toString();
String userId = personIdentity.getPersonSeq();
param.setOrgCode(orgCode);
Integer status = param.getStatus();
if (status != null && status == 1) {
String checkTypeId = param.getCheckTypeId();
try {
String processInstanceId = null;
if ("1".equals(checkTypeId)) {
processInstanceId = workflowExcuteService.startAndComplete(processDefinitionKey, CheckTypeSuEnum.SUPERVISED.getCondition());
} else if ("2".equals(checkTypeId)) {
processInstanceId = workflowExcuteService.startAndComplete(processDefinitionKey, CheckTypeSuEnum.DAILY.getCondition());
}
PlanAudit audit = new PlanAudit();
audit.setPlanId(param.getId());
audit.setBusinessKey(String.valueOf(sequence.nextId()));
audit.setProcessDefinitionKey(processDefinitionKey);
audit.setProcessInstanceId(processInstanceId);
audit.setStartUserId(userId);
planAuditDao.save(audit);
} catch (Exception e) {
// e.printStackTrace();
log.error("=============防火监督,计划提交,工作流启动失败!!!=============");
}
}
// param.setStatus(Byte.parseByte(XJConstant.PLAN_STATUS_STOP));
param.setNextGenDate(DateUtil.getIntervalDate(new Date(), 0));
param.setCreateBy(userId);
addPlanRequest.setPlan(param);
......@@ -176,9 +147,50 @@ public class PlanServiceImpl implements IPlanService {
param.setDayEnd(DateUtil.formatStrToTime("23:59:59"));
}
planDao.save(param);
Integer status = param.getStatus();
if (status != null && status == 1) {
CheckTypeSuEnum checkTypeSuEnum = CheckTypeSuEnum.getEumByCode(param.getCheckTypeId());
try {
String processInstanceId;
PlanAudit audit = planAuditDao.findByPlanId(param.getId());
if (audit != null) {
//执行一步
processInstanceId = audit.getProcessInstanceId();
workflowExcuteService.excuteTask(processInstanceId, checkTypeSuEnum.getCondition());
//记录执行流水-启动节点
insertAuditLog(reginParams, param, personIdentity, audit);
} else {
//启动
processInstanceId = workflowExcuteService.startAndComplete(processDefinitionKey, checkTypeSuEnum.getCondition());
audit = new PlanAudit();
audit.setPlanId(param.getId());
audit.setBusinessKey(String.valueOf(sequence.nextId()));
audit.setProcessDefinitionKey(processDefinitionKey);
audit.setProcessInstanceId(processInstanceId);
audit.setStartUserId(userId);
planAuditDao.save(audit);
//记录执行流水-启动节点
insertAuditLog(reginParams, param, personIdentity, audit);
}
} catch (Exception e) {
log.error("=============防火监督,计划提交,工作流启动失败!!!=============");
}
}
}
}
private void insertAuditLog(ReginParams reginParams, Plan param, ReginParams.PersonIdentity personIdentity, PlanAudit audit) {
PlanAuditLog planAuditLog = new PlanAuditLog();
planAuditLog.setPlanAuditId(audit.getId());
planAuditLog.setPlanId(param.getId());
planAuditLog.setFlowTaskName("发起审核");
planAuditLog.setExcuteUserId(param.getCreateBy());
planAuditLog.setExcuteUserName(personIdentity.getPersonName());
planAuditLog.setExcuteState(1);
planAuditLog.setRoleName(reginParams.getRole().getRoleName());
planAuditLogDao.save(planAuditLog);
}
/**
* 默认新增路线
*/
......
......@@ -3,9 +3,8 @@ package com.yeejoin.amos.supervision.business.service.intfc;
import java.util.HashMap;
import java.util.List;
import com.yeejoin.amos.supervision.core.common.request.AddPlanRequest;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.supervision.core.common.response.PlanPointRespone;
import com.yeejoin.amos.supervision.dao.entity.Point;
import org.springframework.data.domain.Page;
import com.yeejoin.amos.supervision.business.param.PlanInfoPageParam;
......@@ -22,8 +21,9 @@ public interface IPlanService {
/**
* 巡检计划新增及维护
* @param map
* @param reginParams
*/
void addPlan(HashMap<String, Object> map);
void addPlan(HashMap<String, Object> map, ReginParams reginParams) throws Exception;
/**
* 巡检计划删除
......
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