Commit f372b8ae authored by xixinzhao's avatar xixinzhao

防火监督优化项

parent 2036bb38
...@@ -16,6 +16,8 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation; ...@@ -16,6 +16,8 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.Map;
@RestController @RestController
@RequestMapping(value = "/api/planAudit") @RequestMapping(value = "/api/planAudit")
@Api(tags = "计划审核api") @Api(tags = "计划审核api")
...@@ -45,4 +47,13 @@ public class PlanAuditController extends AbstractBaseController { ...@@ -45,4 +47,13 @@ public class PlanAuditController extends AbstractBaseController {
return ResponseHelper.buildResponse(planAuditService.listByPlanId(planId)); return ResponseHelper.buildResponse(planAuditService.listByPlanId(planId));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PersonIdentify
@ApiOperation(value = "查询登陆人有没有计划执行权限")
@GetMapping(value = "/checkTaskAuth")
public ResponseModel checkTaskAuth(@RequestParam("planId") Long planId) {
ReginParams reginParams = getSelectedOrgInfo();
return ResponseHelper.buildResponse(planAuditService.checkTaskAuth(planId, reginParams));
}
} }
package com.yeejoin.amos.supervision.business.feign; package com.yeejoin.amos.supervision.business.feign;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.supervision.business.dto.OrgUsrFormDto; import com.yeejoin.amos.supervision.business.dto.OrgUsrFormDto;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -64,4 +66,13 @@ public interface JCSFeignClient { ...@@ -64,4 +66,13 @@ public interface JCSFeignClient {
*/ */
@RequestMapping(value = "jcs/org-usr/{companyId}/person/list", method = RequestMethod.GET) @RequestMapping(value = "jcs/org-usr/{companyId}/person/list", method = RequestMethod.GET)
FeignClientResult<List<OrgUsrFormDto>> getPersonListByCompanyId(@PathVariable("companyId") String companyId); FeignClientResult<List<OrgUsrFormDto>> getPersonListByCompanyId(@PathVariable("companyId") String companyId);
/**
* 根据机场人员id获取amos平台人员id
*
* @param orgUserId 机场单位人员id
* @return AgencyUserModel 平台人员信息
**/
@RequestMapping(value = "jcs/org-usr/amos/{orgUserId}", method = RequestMethod.GET)
ResponseModel<AgencyUserModel> getAmosIdByUserId(@PathVariable String orgUserId);
} }
...@@ -300,6 +300,9 @@ public class HiddenDangerServiceImpl implements IHiddenDangerService { ...@@ -300,6 +300,9 @@ public class HiddenDangerServiceImpl implements IHiddenDangerService {
result.put("makerUserName", plan.getMakerUserName()); // 计划制定人名称 result.put("makerUserName", plan.getMakerUserName()); // 计划制定人名称
result.put("userId", plan.getUserId()); // 检查参与人id result.put("userId", plan.getUserId()); // 检查参与人id
result.put("userIdName", plan.getUserName()); // 检查参与人名称 result.put("userIdName", plan.getUserName()); // 检查参与人名称
// 放入标识隐患是外部导入还是非外部,1为外部导入
String isOuter = DangerCheckTypeLevelEnum.EXTERNAL.getCode().equals(plan.getCheckLevel()) ? "1" : "0";
result.put("isOuter", isOuter);
// 将机场单位bizOrgCode保存起来用于按机场单位数据过滤 // 将机场单位bizOrgCode保存起来用于按机场单位数据过滤
FeignClientResult<Map<String, Object>> companyResult = jcsFeignClient.getCompanyById(point.getOriginalId()); FeignClientResult<Map<String, Object>> companyResult = jcsFeignClient.getCompanyById(point.getOriginalId());
if (!ValidationUtil.isEmpty(companyResult)) { if (!ValidationUtil.isEmpty(companyResult)) {
......
...@@ -3,9 +3,11 @@ package com.yeejoin.amos.supervision.business.service.impl; ...@@ -3,9 +3,11 @@ package com.yeejoin.amos.supervision.business.service.impl;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; 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.service.IWorkflowExcuteService;
import com.yeejoin.amos.boot.biz.common.workflow.feign.WorkflowFeignService; import com.yeejoin.amos.boot.biz.common.workflow.feign.WorkflowFeignService;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.supervision.business.dao.repository.IPlanAuditDao; import com.yeejoin.amos.supervision.business.dao.repository.IPlanAuditDao;
import com.yeejoin.amos.supervision.business.dao.repository.IPlanAuditLogDao; import com.yeejoin.amos.supervision.business.dao.repository.IPlanAuditLogDao;
import com.yeejoin.amos.supervision.business.dao.repository.IPlanDao; import com.yeejoin.amos.supervision.business.dao.repository.IPlanDao;
import com.yeejoin.amos.supervision.business.feign.JCSFeignClient;
import com.yeejoin.amos.supervision.business.service.intfc.IPlanAuditService; import com.yeejoin.amos.supervision.business.service.intfc.IPlanAuditService;
import com.yeejoin.amos.supervision.common.enums.CheckTypeSuEnum; import com.yeejoin.amos.supervision.common.enums.CheckTypeSuEnum;
import com.yeejoin.amos.supervision.common.enums.DangerCheckTypeLevelEnum; import com.yeejoin.amos.supervision.common.enums.DangerCheckTypeLevelEnum;
...@@ -14,11 +16,13 @@ import com.yeejoin.amos.supervision.common.enums.WorkFlowBranchEnum; ...@@ -14,11 +16,13 @@ import com.yeejoin.amos.supervision.common.enums.WorkFlowBranchEnum;
import com.yeejoin.amos.supervision.dao.entity.Plan; import com.yeejoin.amos.supervision.dao.entity.Plan;
import com.yeejoin.amos.supervision.dao.entity.PlanAudit; import com.yeejoin.amos.supervision.dao.entity.PlanAudit;
import com.yeejoin.amos.supervision.dao.entity.PlanAuditLog; import com.yeejoin.amos.supervision.dao.entity.PlanAuditLog;
import com.yeejoin.amos.supervision.exception.YeeException;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -45,6 +49,9 @@ public class PlanAuditServiceImpl implements IPlanAuditService { ...@@ -45,6 +49,9 @@ public class PlanAuditServiceImpl implements IPlanAuditService {
@Autowired @Autowired
private PlanServiceImpl planService; private PlanServiceImpl planService;
@Autowired
JCSFeignClient jcsFeignClient;
@Override @Override
@Transactional @Transactional
public Boolean auditWorkFlow(PlanAuditLog planAuditLog, Integer status, String condition, ReginParams reginParams) throws Exception { public Boolean auditWorkFlow(PlanAuditLog planAuditLog, Integer status, String condition, ReginParams reginParams) throws Exception {
...@@ -58,11 +65,13 @@ public class PlanAuditServiceImpl implements IPlanAuditService { ...@@ -58,11 +65,13 @@ public class PlanAuditServiceImpl implements IPlanAuditService {
String taskId = taskAuthMap.get("taskId") == null ? null : taskAuthMap.get("taskId").toString(); String taskId = taskAuthMap.get("taskId") == null ? null : taskAuthMap.get("taskId").toString();
String name = taskAuthMap.get("name") == null ? null : taskAuthMap.get("name").toString(); String name = taskAuthMap.get("name") == null ? null : taskAuthMap.get("name").toString();
String roleName = reginParams.getRole().getRoleName(); String roleName = reginParams.getRole().getRoleName();
workflowExcuteService.CompleteTask(instanceId, condition, reginParams); // 获取审核最后一步所需条件
String conditionValue = getConditionValue(plan, condition);
workflowExcuteService.CompleteTask(instanceId, conditionValue, reginParams);
ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity(); ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity();
String userId = reginParams.getUserModel().getUserId(); String userId = reginParams.getUserModel().getUserId();
// 更新计划状态,指定执行人 // 更新计划状态,指定执行人
updatePlanStatus(condition,plan,instanceId,userId); updatePlanStatus(condition,plan,instanceId, conditionValue);
// 更新流水表 // 更新流水表
planAuditLog.setPlanId(planAudit.getPlanId()); planAuditLog.setPlanId(planAudit.getPlanId());
planAuditLog.setPlanAuditId(planAudit.getId()); planAuditLog.setPlanAuditId(planAudit.getId());
...@@ -81,35 +90,89 @@ public class PlanAuditServiceImpl implements IPlanAuditService { ...@@ -81,35 +90,89 @@ public class PlanAuditServiceImpl implements IPlanAuditService {
} }
/** /**
* 获取最后一步审核通过下一步条件
* @param plan 计划
* @param condition 前端传的是否通过
* @return 下一步条件
*/
private String getConditionValue(Plan plan, String condition) throws Exception {
String fail = "1";
String nextCondition = "outer";
// 前端传递为0表示通过,通过才区分下一步
if (!fail.equals(condition) && DangerCheckTypeLevelEnum.EXTERNAL.getCode().equals(plan.getCheckLevel())) {
String workFlowBranch = getWorkFlowBranch(plan);
if (workFlowBranch.equals(WorkFlowBranchEnum.DAILY.getWorkFlowBranch())) {
if (PlanStatusEnum.EXAMINE_THREE.getValue() == plan.getStatus()) {
return nextCondition;
}
} else {
if (PlanStatusEnum.EXAMINE_ONE.getValue() == plan.getStatus()) {
return nextCondition;
}
}
return fail;
}
return condition;
}
/**
* 更新计划id * 更新计划id
* @param condition 同意0 不同意1 * @param condition 同意0 不同意1
* @param plan 当前计划对象 * @param plan 当前计划对象
*/ */
private void updatePlanStatus (String condition, Plan plan, String instanceId, String userId) throws Exception { private void updatePlanStatus (String condition, Plan plan, String instanceId, String conditionValue) throws Exception {
String fail = "1"; String fail = "1";
String nextCondition = "outer";
if (fail.equals(condition)) { if (fail.equals(condition)) {
planDao.updatePlanStatus(PlanStatusEnum.DRAFT.getValue(), plan.getId()); planDao.updatePlanStatus(PlanStatusEnum.DRAFT.getValue(), plan.getId());
} else { } else {
//检查级别 // 获取检查组长
DangerCheckTypeLevelEnum dangerCheckTypeLevelEnum = DangerCheckTypeLevelEnum.getEumByCode(plan.getCheckLevel()); AgencyUserModel userModel = jcsFeignClient.getAmosIdByUserId(plan.getLeadPeopleIds()).getResult();
//检查类型 if (ValidationUtil.isEmpty(userModel)) {
CheckTypeSuEnum checkTypeSuEnum = CheckTypeSuEnum.getEumByCode(plan.getCheckTypeId()); throw new YeeException("业务信息错误");
String branch = PlanServiceImpl.workFlowExcuteBranch(dangerCheckTypeLevelEnum.getCondition(), checkTypeSuEnum.getCondition());
if (branch.equals(WorkFlowBranchEnum.DAILY.getWorkFlowBranch())) {
if (PlanStatusEnum.EXAMINE_THREE.getValue() == plan.getStatus()) {
workflowExcuteService.setTaskAssign(instanceId, plan.getLeadPeopleIds());
} }
// 工作流中使用平台用户名称,因此这里取userName
String checkLeaderId = userModel.getUserName();
String workFlowBranch = getWorkFlowBranch(plan);
PlanStatusEnum statusEnum = PlanStatusEnum.getEnum(plan.getStatus()); PlanStatusEnum statusEnum = PlanStatusEnum.getEnum(plan.getStatus());
planDao.updatePlanStatus(statusEnum != null ? statusEnum.getNextStatus() : PlanStatusEnum.DRAFT.getValue(), plan.getId()); if (workFlowBranch.equals(WorkFlowBranchEnum.DAILY.getWorkFlowBranch())) {
if (PlanStatusEnum.EXAMINE_THREE.getValue() == plan.getStatus()) {
workflowExcuteService.setTaskAssign(instanceId, checkLeaderId);
}
int status = statusEnum != null ? statusEnum.getNextStatus() : PlanStatusEnum.DRAFT.getValue();
if (nextCondition.equals(conditionValue) && PlanStatusEnum.EXAMINE_THREE.getValue() == status) {
status = PlanStatusEnum.IN_EXECUTION.getValue();
}
planDao.updatePlanStatus(status, plan.getId());
} else { } else {
int status = PlanStatusEnum.EXAMINE_FORMULATE.getValue();
if (PlanStatusEnum.EXAMINE_ONE.getValue() == plan.getStatus()) { if (PlanStatusEnum.EXAMINE_ONE.getValue() == plan.getStatus()) {
workflowExcuteService.setTaskAssign(instanceId, plan.getLeadPeopleIds()); workflowExcuteService.setTaskAssign(instanceId, checkLeaderId);
} else {
status = statusEnum != null ? statusEnum.getNextStatus() : PlanStatusEnum.DRAFT.getValue();
}
if (nextCondition.equals(conditionValue)) {
status = PlanStatusEnum.IN_EXECUTION.getValue();
} }
planDao.updatePlanStatus(PlanStatusEnum.EXAMINE_FORMULATE.getValue(), plan.getId()); planDao.updatePlanStatus(status, plan.getId());
} }
} }
} }
/**
* 获取当前流程分支
* @param plan 计划对象
* @return 流程分支
*/
private String getWorkFlowBranch(Plan plan) throws Exception {
//检查级别
DangerCheckTypeLevelEnum dangerCheckTypeLevelEnum = DangerCheckTypeLevelEnum.getEumByCode(plan.getCheckLevel());
//检查类型
CheckTypeSuEnum checkTypeSuEnum = CheckTypeSuEnum.getEumByCode(plan.getCheckTypeId());
return PlanServiceImpl.workFlowExcuteBranch(dangerCheckTypeLevelEnum.getCondition(), checkTypeSuEnum.getCondition());
}
@Override @Override
public List<PlanAuditLog> listByPlanId(Long planId) { public List<PlanAuditLog> listByPlanId(Long planId) {
Sort.Order idOrder = new Sort.Order(Sort.Direction.ASC, "createDate"); Sort.Order idOrder = new Sort.Order(Sort.Direction.ASC, "createDate");
...@@ -119,6 +182,17 @@ public class PlanAuditServiceImpl implements IPlanAuditService { ...@@ -119,6 +182,17 @@ public class PlanAuditServiceImpl implements IPlanAuditService {
return planAuditLogDao.findAllByPlanId(planId, sort); return planAuditLogDao.findAllByPlanId(planId, sort);
} }
@Override
public Map<String, Object> checkTaskAuth(Long planId, ReginParams reginParams) {
PlanAudit planAudit = planAuditDao.findByPlanId(planId);
if (ObjectUtils.isNotEmpty(planAudit)) {
String instanceId = planAudit.getProcessInstanceId();
return workflowExcuteService.checkTaskAuthMap(instanceId, reginParams);
} else {
throw new YeeException("该计划暂无流程实例!");
}
}
// @Override // @Override
// @Transactional // @Transactional
// public Boolean auditWorkFlow(PlanAuditLog planAuditLog, String condition, ReginParams reginParams) { // public Boolean auditWorkFlow(PlanAuditLog planAuditLog, String condition, ReginParams reginParams) {
......
...@@ -4,6 +4,7 @@ import com.yeejoin.amos.boot.biz.common.bo.ReginParams; ...@@ -4,6 +4,7 @@ import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.supervision.dao.entity.PlanAuditLog; import com.yeejoin.amos.supervision.dao.entity.PlanAuditLog;
import java.util.List; import java.util.List;
import java.util.Map;
public interface IPlanAuditService { public interface IPlanAuditService {
Boolean auditWorkFlow(PlanAuditLog planAuditLog, Integer status, String condition, ReginParams reginParams) throws Exception; Boolean auditWorkFlow(PlanAuditLog planAuditLog, Integer status, String condition, ReginParams reginParams) throws Exception;
...@@ -14,4 +15,12 @@ public interface IPlanAuditService { ...@@ -14,4 +15,12 @@ public interface IPlanAuditService {
* @return List<PlanAuditLog> * @return List<PlanAuditLog>
*/ */
List<PlanAuditLog> listByPlanId(Long planId); List<PlanAuditLog> listByPlanId(Long planId);
/**
* 登陆人是否有该计划执行权限
* @param planId 计划id
* @param reginParams 登陆人信息
* @return 权限标识
*/
Map<String, Object> checkTaskAuth(Long planId, 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