Commit e1df9dc8 authored by 高建强's avatar 高建强

item:添加防火监督工作流执行

parent 486062e5
......@@ -8,8 +8,8 @@ import java.util.stream.Collectors;
public enum CheckTypeSuEnum {
TIME_DESC("日常检查", "1"),
TIME_ASC("专项检查", "2");
SUPERVISED("日常检查", "1", "supervised"),
DAILY("专项检查", "2", "daily");
/**
* 名字
......@@ -20,9 +20,15 @@ public enum CheckTypeSuEnum {
*/
private String code;
CheckTypeSuEnum(String name, String code) {
/**
* 执行控制条件
*/
private String condition;
CheckTypeSuEnum(String name, String code, String condition) {
this.name = name;
this.code = code;
this.condition = condition;
}
public static List<Map<String, Object>> getEnumList() {
......@@ -48,4 +54,12 @@ public enum CheckTypeSuEnum {
public void setCode(String code) {
this.code = code;
}
public String getCondition() {
return condition;
}
public void setCondition(String condition) {
this.condition = condition;
}
}
package com.yeejoin.amos.supervision.dao.entity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import java.util.Date;
/**
* @ProjectName: amos-biz-boot
* @Package: com.yeejoin.amos.supervision.dao.entity
* @ClassName: PlanAudit
* @Author: Jianqiang Gao
* @Description: 计划审核申请表
* @Date: 2021/9/23 9:52
* @Version: 1.0
*/
@Entity
@Table(name = "p_plan_audit")
@NamedQuery(name = "PlanAudit.findAll", query = "SELECT p FROM PlanAudit p")
@Data
public class PlanAudit extends BasicEntity {
private static final long serialVersionUID = 1L;
/**
* 计划id
*/
@Column(name = "plan_id")
private Long planId;
/**
* 业务唯一标识
*/
@Column(name = "business_key")
private String businessKey;
/**
* 工作流实例编号
*/
@Column(name = "process_instance_id")
private String processInstanceId;
/**
* 流程定义key
*/
@Column(name = "process_definition_key")
private String processDefinitionKey;
/**
* 启动者id
*/
@Column(name = "start_user_id")
private String startUserId;
/**
* 更新时间
*/
@Column(name = "update_date")
private Date updateDate;
}
\ No newline at end of file
package com.yeejoin.amos.supervision.dao.entity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
/**
* @ProjectName: amos-biz-boot
* @Package: com.yeejoin.amos.supervision.dao.entity
* @ClassName: PlanAudit
* @Author: Jianqiang Gao
* @Description: 计划审核申请表
* @Date: 2021/9/23 9:52
* @Version: 1.0
*/
@Entity
@Table(name = "p_plan_audit_log")
@NamedQuery(name = "PlanAuditLog.findAll", query = "SELECT p FROM PlanAuditLog p")
@Data
public class PlanAuditLog extends BasicEntity {
private static final long serialVersionUID = 1L;
/**
* 计划id(冗余)
*/
@Column(name = "plan_id")
private Long planId;
/**
* 计划审核申请主表
*/
@Column(name = "plan_audit_id")
private Long planAuditId;
/**
* 当前节点编号
*/
@Column(name = "flow_task_id")
private String flowTaskId;
/**
* 当前节点名称
*/
@Column(name = "flow_task_name")
private String flowTaskName;
/**
* 实际执行人
*/
@Column(name = "excute_user_id")
private String excuteUserId;
/**
* 执行人用户名称(冗余)
*/
@Column(name = "excute_user_name")
private String excuteUserName;
/**
* 执行状态(1:不通过;2:通过)
*/
@Column(name = "excute_state")
private Integer excuteState;
/**
* 角色名称
*/
@Column(name = "role_name")
private String roleName;
/**
* 执行结果
*/
@Column(name = "excute_result")
private String excuteResult;
/**
* 提交工作流json数据
*/
@Column(name = "flow_json")
private String flowJson;
/**
* 备注
*/
@Column(name = "remark")
private String remark;
}
\ No newline at end of file
package com.yeejoin.amos.supervision.business.controller;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.supervision.business.service.intfc.IPlanAuditService;
import com.yeejoin.amos.supervision.business.util.CommonResponse;
import com.yeejoin.amos.supervision.business.util.CommonResponseUtil;
import com.yeejoin.amos.supervision.dao.entity.PlanAuditLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
@RestController
@RequestMapping(value = "/api/planAudit")
@Api(tags = "计划审核api")
public class PlanAuditController extends AbstractBaseController {
private final Logger log = LoggerFactory.getLogger(PlanAuditController.class);
@Autowired
private IPlanAuditService planAuditService;
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "计划工作流审核", notes = "计划工作流审核")
@RequestMapping(value = "/auditWorkFlow", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse auditWorkFlow(
@ApiParam(value = "工作流流水实例", required = true) @RequestBody PlanAuditLog planAuditLog,
@ApiParam(value = "工作流实例编号", required = true) @RequestParam String instanceId,
@ApiParam(value = "执行控制条件", required = true) @RequestParam String condition) {
try {
AgencyUserModel userInfo = getUserInfo();
ReginParams reginParams = getSelectedOrgInfo();
return CommonResponseUtil.success(planAuditService.auditWorkFlow(planAuditLog, instanceId, condition, reginParams));
} catch (Exception e) {
log.error(e.getMessage(), e);
return CommonResponseUtil.failure("计划工作流审核失败!");
}
}
}
package com.yeejoin.amos.supervision.business.controller;
import com.yeejoin.amos.supervision.business.service.intfc.IPlanAuditLogService;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value = "/api/planAuditLog")
@Api(tags = "工作流流水api")
public class PlanAuditLogController extends AbstractBaseController {
private final Logger log = LoggerFactory.getLogger(PlanAuditLogController.class);
@Autowired
private IPlanAuditLogService planAuditLogService;
}
package com.yeejoin.amos.supervision.business.dao.repository;
import com.yeejoin.amos.supervision.dao.entity.PlanAudit;
import org.springframework.stereotype.Repository;
@Repository("planAuditDao")
public interface IPlanAuditDao extends BaseDao<PlanAudit, Long> {
PlanAudit findByProcessInstanceId(String instanceId);
}
\ No newline at end of file
package com.yeejoin.amos.supervision.business.dao.repository;
import com.yeejoin.amos.supervision.dao.entity.PlanAuditLog;
import org.springframework.stereotype.Repository;
@Repository("planAuditLogDao")
public interface IPlanAuditLogDao extends BaseDao<PlanAuditLog, Long> {
}
\ No newline at end of file
package com.yeejoin.amos.supervision.business.service.impl;
import com.yeejoin.amos.supervision.business.service.intfc.IPlanAuditLogService;
import org.springframework.stereotype.Service;
@Service("planAuditLogService")
public class PlanAuditLogServiceImpl implements IPlanAuditLogService {
}
package com.yeejoin.amos.supervision.business.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.service.IWorkflowExcuteService;
import com.yeejoin.amos.boot.biz.common.workflow.feign.WorkflowFeignService;
import com.yeejoin.amos.supervision.business.dao.repository.IPlanAuditDao;
import com.yeejoin.amos.supervision.business.dao.repository.IPlanAuditLogDao;
import com.yeejoin.amos.supervision.business.service.intfc.IPlanAuditService;
import com.yeejoin.amos.supervision.dao.entity.PlanAudit;
import com.yeejoin.amos.supervision.dao.entity.PlanAuditLog;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
@Service("planAuditService")
public class PlanAuditServiceImpl implements IPlanAuditService {
@Autowired
private IWorkflowExcuteService workflowExcuteService;
@Autowired
private IPlanAuditDao planAuditDao;
@Autowired
private IPlanAuditLogDao planAuditLogDao;
@Autowired
private WorkflowFeignService workflowFeignService;
@Override
@Transactional
public Boolean auditWorkFlow(PlanAuditLog planAuditLog, String instanceId, String condition, ReginParams reginParams) {
Map<String, Object> taskAuthMap = workflowExcuteService.checkTaskAuthMap(instanceId);
if (taskAuthMap != null && !taskAuthMap.isEmpty()) {
String taskId = taskAuthMap.get("taskId").toString();
if (StringUtils.isNotBlank(taskId)) {
String roleName = reginParams.getRole().getRoleName();
JSONObject taskGroupName = workflowFeignService.getTaskGroupName(taskId);
JSONArray taskGroupNameDetail = taskGroupName.getJSONArray("data");
// JSONObject taskGroupNameDetail = JSONObject.parseObject(JSONObject.toJSONString(data.get(data.size() - 2)));
if (!ObjectUtils.isEmpty(taskGroupNameDetail)) {
String defaultExecutionRoleProcess = taskGroupNameDetail.getJSONObject(0).getString("groupId");
}
boolean b = workflowExcuteService.CompleteTask(instanceId, condition);
if (b) {
ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity();
workflowExcuteService.setTaskAssign(instanceId, personIdentity.getPersonSeq());
PlanAudit planAudit = planAuditDao.findByProcessInstanceId(instanceId);
if (ObjectUtils.isNotEmpty(planAudit)) {
planAuditLog.setPlanId(planAudit.getPlanId());
planAuditLog.setPlanAuditId(planAudit.getId());
planAuditLog.setExcuteUserId(personIdentity.getPersonSeq());
planAuditLog.setExcuteUserName(personIdentity.getPersonName());
// planAuditLog.setFlowTaskId();
// planAuditLog.setFlowTaskName();
planAuditLog.setFlowJson(condition);
planAuditLog.setRoleName(roleName);
planAuditLogDao.save(planAuditLog);
}
}
return b;
}
}
return Boolean.FALSE;
}
}
package com.yeejoin.amos.supervision.business.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
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;
import com.yeejoin.amos.supervision.business.dao.mapper.PlanMapper;
import com.yeejoin.amos.supervision.business.dao.mapper.PointMapper;
import com.yeejoin.amos.supervision.business.dao.mapper.RouteMapper;
import com.yeejoin.amos.supervision.business.dao.repository.*;
import com.yeejoin.amos.supervision.business.param.PlanInfoPageParam;
import com.yeejoin.amos.supervision.business.service.intfc.IPlanService;
import com.yeejoin.amos.supervision.common.enums.CheckTypeSuEnum;
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.*;
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.feign.RemoteSecurityService;
import org.apache.commons.lang.StringUtils;
import org.apache.velocity.util.ArrayListWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.stereotype.Service;
......@@ -32,6 +36,9 @@ import java.util.stream.Collectors;
@Service("planService")
public class PlanServiceImpl implements IPlanService {
private final static Logger log = LoggerFactory.getLogger(PlanServiceImpl.class);
@Autowired
private IPlanDao planDao;
@Autowired
......@@ -67,6 +74,18 @@ public class PlanServiceImpl implements IPlanService {
@Autowired
private IPlanService planService;
@Autowired
private IWorkflowExcuteService workflowExcuteService;
@Autowired
private IPlanAuditDao planAuditDao;
@Autowired
private Sequence sequence;
@Value("${work.flow.processDefinitionKey}")
private String processDefinitionKey;
private static final Logger logger = LoggerFactory.getLogger(PlanServiceImpl.class);
@Override
......@@ -115,6 +134,28 @@ public class PlanServiceImpl implements IPlanService {
String orgCode = map.get("org_code") == null ? "" : map.get("org_code").toString();
String userId = map.get("user_id") == null ? "" : map.get("user_id").toString();
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.SUPERVISED.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);
......@@ -139,14 +180,14 @@ public class PlanServiceImpl implements IPlanService {
}
/**
* 默认新增路线
* 默认新增路线
*/
public Route save (AddPlanRequest addPlanRequest) {
public Route save(AddPlanRequest addPlanRequest) {
Route saveRoute = new Route();
Plan plan = addPlanRequest.getPlan();
// 判断是新增还是修改
if (plan.getId()>0) {
if (plan.getId() > 0) {
// 删除相关点项内容
iRoutePointDao.delRoutePointByRouteId(plan.getRouteId());
// iRoutePointItemDao.delRoutePointItem(plan.getRouteId());
......@@ -251,10 +292,10 @@ public class PlanServiceImpl implements IPlanService {
public Plan queryPlanById(Long id) {
Plan plan = null;
Optional<Plan> op = planDao.findById(id);
if(op.isPresent()){
if (op.isPresent()) {
plan = op.get();
Optional<Route> optionalRoute = iRouteDao.findById(plan.getRouteId());
plan.setOwnerId( optionalRoute.isPresent() ? optionalRoute.get().getOwnerId() : "" );
plan.setOwnerId(optionalRoute.isPresent() ? optionalRoute.get().getOwnerId() : "");
}
return plan;
}
......@@ -270,16 +311,16 @@ public class PlanServiceImpl implements IPlanService {
}
@Override
public void setplanstatus (Long id, Integer status) {
public void setplanstatus(Long id, Integer status) {
Plan oriPlan = planDao.findById(id).get();
oriPlan.setStatus(status);
planDao.save(oriPlan);
}
@Override
public PlanPointRespone getplandetails (Long id) {
public PlanPointRespone getplandetails(Long id) {
PlanPointRespone planRequest = new PlanPointRespone();
Plan plan = planService.queryPlanById(id);;
Plan plan = planService.queryPlanById(id);
if (!ObjectUtils.isEmpty(plan)) {
List<Long> ids = pointMapper.getPointoriginalidbyrouteid(plan.getRouteId());
planRequest.setPlan(plan);
......
package com.yeejoin.amos.supervision.business.service.intfc;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.supervision.dao.entity.PlanAuditLog;
public interface IPlanAuditService {
Boolean auditWorkFlow(PlanAuditLog planAuditLog, String instanceId, String condition, ReginParams reginParams);
}
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