提交代码
This commit is contained in:
@@ -2,7 +2,7 @@ package com.njcn.bpm.listener.business;
|
||||
|
||||
import com.njcn.bpm.listener.BpmProcessInstanceStatusEvent;
|
||||
import com.njcn.bpm.listener.BpmProcessInstanceStatusEventListener;
|
||||
import com.njcn.supervision.api.TempLineFeignClient;
|
||||
import com.njcn.supervision.api.TempLineDebugFeignClient;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -12,7 +12,7 @@ import javax.annotation.Resource;
|
||||
public class BpmTempLineDebugStatusListener extends BpmProcessInstanceStatusEventListener {
|
||||
|
||||
@Resource
|
||||
private TempLineFeignClient tempLineFeignClient;
|
||||
private TempLineDebugFeignClient tempLineDebugFeignClient;
|
||||
|
||||
@Override
|
||||
protected String getProcessDefinitionKey() {
|
||||
@@ -21,7 +21,7 @@ public class BpmTempLineDebugStatusListener extends BpmProcessInstanceStatusEven
|
||||
|
||||
@Override
|
||||
protected void onEvent(BpmProcessInstanceStatusEvent event) {
|
||||
tempLineFeignClient.updateStatus(event.getBusinessKey(), event.getStatus());
|
||||
tempLineDebugFeignClient.updateStatus(event.getBusinessKey(), event.getStatus());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.supervision.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.supervision.api.fallback.SupervisionPlanFeignClientFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
|
||||
/**
|
||||
* 流程实例 Api 接口
|
||||
*
|
||||
* @author hongawen
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.SUPERVISION, path = "/superPlan", fallbackFactory = SupervisionPlanFeignClientFallbackFactory.class)
|
||||
public interface SupervisionPlanFeignClient {
|
||||
|
||||
@GetMapping("/updateStatus")
|
||||
HttpResult<Object> updateStatus(@RequestParam("businessKey") String businessKey, @RequestParam("status")Integer status);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.njcn.supervision.api.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.supervision.api.SupervisionPlanFeignClient;
|
||||
import com.njcn.supervision.utils.SupervisionEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
* @date 2022/3/16
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SupervisionPlanFeignClientFallbackFactory implements FallbackFactory<SupervisionPlanFeignClient> {
|
||||
@Override
|
||||
public SupervisionPlanFeignClient create(Throwable throwable) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (throwable.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) throwable.getCause();
|
||||
exceptionEnum = SupervisionEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new SupervisionPlanFeignClient() {
|
||||
@Override
|
||||
public HttpResult<Object> updateStatus(String businessKey, Integer status) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "更新退运装置数据流程状态", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,6 @@ public class SupervisopnProblemParam extends BaseParam {
|
||||
* 整改时间
|
||||
*/
|
||||
@ApiModelProperty(value = "整改时间",required = true)
|
||||
@DateTimeStrValid(message = "整改时间格式有误")
|
||||
private String rectificationTime;
|
||||
|
||||
/**
|
||||
@@ -55,7 +54,6 @@ public class SupervisopnProblemParam extends BaseParam {
|
||||
*/
|
||||
@ApiModelProperty(value = "计划整改时间",required = true)
|
||||
@NotNull(message = "计划整改时间不可为空")
|
||||
@DateTimeStrValid(message = "计划整改时间格式有误")
|
||||
private String planRectificationTime;
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,13 +14,11 @@ import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 干扰源用户管理
|
||||
@@ -60,5 +58,30 @@ public class SupervisionPlanController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/initiateAudit")
|
||||
@ApiOperation("发起审核")
|
||||
public HttpResult<String> initiateAudit(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("initiateAudit");
|
||||
String processId = supervisionPlanPOService.initiateAudit(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, processId, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getDetail")
|
||||
@ApiOperation("查询详情")
|
||||
public HttpResult<SupervisionPlanVO> getDetailPlan(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("getDetailPlan");
|
||||
SupervisionPlanVO out = supervisionPlanPOService.getDetailPlan(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, out, methodDescribe);
|
||||
}
|
||||
@GetMapping("/updateStatus")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@Operation(summary = "更改表单状态")
|
||||
public HttpResult<Object> updateStatus(String businessKey,Integer status) {
|
||||
String methodDescribe = getMethodDescribe("updateStatus");
|
||||
supervisionPlanPOService.updateStatus(businessKey,status);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,4 +20,10 @@ public interface SupervisionPlanPOService extends IService<SupervisionPlanPO>{
|
||||
String addPlan(SupervisionPlanParam supvPlanParam);
|
||||
|
||||
Page<SupervisionPlanVO> pagePlan(SupervisionPlanParam supvPlanParam);
|
||||
}
|
||||
|
||||
String initiateAudit(String id);
|
||||
|
||||
SupervisionPlanVO getDetailPlan(String id);
|
||||
|
||||
void updateStatus(String businessKey, Integer status);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.supervision.service.plan.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
@@ -9,24 +10,30 @@ import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.bpm.api.BpmProcessFeignClient;
|
||||
import com.njcn.bpm.pojo.dto.BpmProcessInstanceCreateReqDTO;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.supervision.mapper.plan.SupervisionPlanPOMapper;
|
||||
import com.njcn.supervision.pojo.param.plan.SupervisionPlanParam;
|
||||
import com.njcn.supervision.pojo.po.plan.SupervisionPlanPO;
|
||||
import com.njcn.supervision.pojo.po.plan.SupervisionProblemPO;
|
||||
import com.njcn.supervision.pojo.vo.plan.SupervisionPlanVO;
|
||||
import com.njcn.supervision.service.plan.SupervisionPlanPOService;
|
||||
import com.njcn.supervision.service.plan.SupervisionProblemPOService;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
import com.njcn.user.pojo.po.User;
|
||||
import com.njcn.user.pojo.vo.PvTerminalTreeVO;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.supervision.mapper.plan.SupervisionPlanPOMapper;
|
||||
import com.njcn.supervision.pojo.po.plan.SupervisionPlanPO;
|
||||
import com.njcn.supervision.service.plan.SupervisionPlanPOService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -47,7 +54,9 @@ import java.util.stream.Stream;
|
||||
public class SupervisionPlanPOServiceImpl extends ServiceImpl<SupervisionPlanPOMapper, SupervisionPlanPO> implements SupervisionPlanPOService{
|
||||
private final UserFeignClient userFeignClient;
|
||||
private final DeptFeignClient deptFeignClient;
|
||||
|
||||
private final BpmProcessFeignClient bpmProcessFeignClient;
|
||||
public static final String PROCESS_KEY = "sup_plan_add";
|
||||
private final SupervisionProblemPOService supervisionProblemPOService;
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String addPlan(SupervisionPlanParam supvPlanParam) {
|
||||
@@ -120,7 +129,7 @@ public class SupervisionPlanPOServiceImpl extends ServiceImpl<SupervisionPlanPOM
|
||||
|
||||
|
||||
List<PvTerminalTreeVO> deptList = deptFeignClient.allDeptList().getData();
|
||||
Map<String, PvTerminalTreeVO> mapCode = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getCode, Function.identity()));
|
||||
// Map<String, PvTerminalTreeVO> mapCode = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getCode, Function.identity()));
|
||||
Map<String, PvTerminalTreeVO> mapList = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getId, Function.identity()));
|
||||
|
||||
|
||||
@@ -129,8 +138,8 @@ public class SupervisionPlanPOServiceImpl extends ServiceImpl<SupervisionPlanPOM
|
||||
List<String> userIds = supvPlanVOList.stream().map(SupervisionPlanVO::getPlanUserId).distinct().collect(Collectors.toList());
|
||||
supvPlanVOList.forEach(item -> {
|
||||
PvTerminalTreeVO pvTerminalTreeVO = null;
|
||||
if (mapCode.containsKey(item.getSupvOrgId())) {
|
||||
pvTerminalTreeVO = mapCode.get(item.getSupvOrgId());
|
||||
if (mapList.containsKey(item.getSupvOrgId())) {
|
||||
pvTerminalTreeVO = mapList.get(item.getSupvOrgId());
|
||||
item.setSupvOrgName(pvTerminalTreeVO.getName());
|
||||
int deptLevel = pvTerminalTreeVO.getPids().split(StrUtil.COMMA).length;
|
||||
if (deptLevel == 2) {
|
||||
@@ -161,8 +170,8 @@ public class SupervisionPlanPOServiceImpl extends ServiceImpl<SupervisionPlanPOM
|
||||
}
|
||||
}
|
||||
|
||||
if (mapCode.containsKey(item.getPlanOrgId())) {
|
||||
item.setPlanOrgName(mapCode.get(item.getPlanOrgId()).getName());
|
||||
if (mapList.containsKey(item.getPlanOrgId())) {
|
||||
item.setPlanOrgName(mapList.get(item.getPlanOrgId()).getName());
|
||||
}
|
||||
|
||||
// SupvFile supvFile = supvFileMapper.selectOne(new LambdaQueryWrapper<SupvFile>().eq(SupvFile::getBusiId, item.getPlanId()).eq(SupvFile::getType, 0));
|
||||
@@ -187,6 +196,96 @@ public class SupervisionPlanPOServiceImpl extends ServiceImpl<SupervisionPlanPOM
|
||||
return pageVo;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String initiateAudit(String id) {
|
||||
|
||||
SupervisionPlanPO byId = this.getById(id);
|
||||
|
||||
List<SupervisionProblemPO> list = supervisionProblemPOService.lambdaQuery().eq(SupervisionProblemPO::getPlanId, id).list();
|
||||
if (CollectionUtil.isEmpty(list)){
|
||||
throw new BusinessException("请填写完事实问题在提交审核");
|
||||
}
|
||||
// 发起 BPM 流程
|
||||
Map<String, Object> processInstanceVariables = new HashMap<>();
|
||||
BpmProcessInstanceCreateReqDTO bpmProcessInstanceCreateReqDTO = new BpmProcessInstanceCreateReqDTO();
|
||||
bpmProcessInstanceCreateReqDTO.setProcessDefinitionKey(PROCESS_KEY);
|
||||
bpmProcessInstanceCreateReqDTO.setBusinessKey(id);
|
||||
bpmProcessInstanceCreateReqDTO.setStartUserSelectAssignees(new HashMap<String, List<String>> ());
|
||||
bpmProcessInstanceCreateReqDTO.setVariables(processInstanceVariables);
|
||||
String processInstanceId = bpmProcessFeignClient.createProcessInstance(byId.getCreateBy(), bpmProcessInstanceCreateReqDTO).getData();
|
||||
// 将工作流的编号,更新到流程单中
|
||||
byId.setProcessInstanceId(processInstanceId);
|
||||
this.baseMapper.updateById(byId);
|
||||
return processInstanceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SupervisionPlanVO getDetailPlan(String id) {
|
||||
SupervisionPlanVO supervisionPlanVO = new SupervisionPlanVO();
|
||||
List<PvTerminalTreeVO> deptList = deptFeignClient.allDeptList().getData();
|
||||
Map<String, PvTerminalTreeVO> mapList = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getId, Function.identity()));
|
||||
SupervisionPlanPO byId = this.getById(id);
|
||||
BeanUtils.copyProperties(byId,supervisionPlanVO);
|
||||
|
||||
if (mapList.containsKey(supervisionPlanVO.getSupvOrgId())) {
|
||||
PvTerminalTreeVO pvTerminalTreeVO = null;
|
||||
|
||||
pvTerminalTreeVO = mapList.get(supervisionPlanVO.getSupvOrgId());
|
||||
supervisionPlanVO.setSupvOrgName(pvTerminalTreeVO.getName());
|
||||
int deptLevel = pvTerminalTreeVO.getPids().split(StrUtil.COMMA).length;
|
||||
if (deptLevel == 2) {
|
||||
//省
|
||||
supervisionPlanVO.setProvince(pvTerminalTreeVO.getName());
|
||||
} else if (deptLevel == 3) {
|
||||
//市
|
||||
supervisionPlanVO.setCity(pvTerminalTreeVO.getName());
|
||||
if (mapList.containsKey(pvTerminalTreeVO.getPid())) {
|
||||
PvTerminalTreeVO pvTerminalTreeOne = mapList.get(pvTerminalTreeVO.getPid());
|
||||
supervisionPlanVO.setProvince(pvTerminalTreeOne.getName());
|
||||
}
|
||||
} else if (deptLevel == 4) {
|
||||
//县
|
||||
if (mapList.containsKey(pvTerminalTreeVO.getPid())) {
|
||||
supervisionPlanVO.setCounty(pvTerminalTreeVO.getName());
|
||||
PvTerminalTreeVO pvTerminalTreeOne = mapList.get(pvTerminalTreeVO.getPid());
|
||||
if (Objects.nonNull(pvTerminalTreeOne)) {
|
||||
supervisionPlanVO.setCity(pvTerminalTreeOne.getName());
|
||||
if (mapList.containsKey(pvTerminalTreeOne.getPid())) {
|
||||
PvTerminalTreeVO pvTerminalTreeTwo = mapList.get(pvTerminalTreeOne.getPid());
|
||||
if (Objects.nonNull(pvTerminalTreeTwo)) {
|
||||
supervisionPlanVO.setProvince(pvTerminalTreeTwo.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mapList.containsKey(supervisionPlanVO.getPlanOrgId())) {
|
||||
supervisionPlanVO.setPlanOrgName(mapList.get(supervisionPlanVO.getPlanOrgId()).getName());
|
||||
}
|
||||
|
||||
// SupvFile supvFile = supvFileMapper.selectOne(new LambdaQueryWrapper<SupvFile>().eq(SupvFile::getBusiId, item.getPlanId()).eq(SupvFile::getType, 0));
|
||||
// if (Objects.nonNull(supvFile)) {
|
||||
// item.setAttachmentName(supvFile.getAttachmentName());
|
||||
// }
|
||||
|
||||
// List<User> userList = userFeignClient.getUserByIdList(userIds).getData();
|
||||
// Map<String, User> map = userList.stream().collect(Collectors.toMap(User::getId, Function.identity()));
|
||||
//
|
||||
// if (map.containsKey(supervisionPlanVO.getPlanUserId())) {
|
||||
// supervisionPlanVO.setPlanUserName(map.get(supervisionPlanVO.getPlanUserId()).getName());
|
||||
// }
|
||||
|
||||
return supervisionPlanVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus(String businessKey, Integer status) {
|
||||
this.lambdaUpdate().set(SupervisionPlanPO::getStatus,status).eq(SupervisionPlanPO::getPlanId,businessKey).update();
|
||||
}
|
||||
|
||||
|
||||
private void checkParam(SupervisionPlanParam supvPlanParam, Boolean updateFlag) {
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.supervision.mapper.plan.SupervisionPlanPOMapper;
|
||||
import com.njcn.supervision.mapper.plan.SupervisionProblemPOMapper;
|
||||
import com.njcn.supervision.pojo.param.plan.SupervisopnProblemParam;
|
||||
import com.njcn.supervision.pojo.po.plan.SupervisionPlanPO;
|
||||
import com.njcn.supervision.pojo.po.plan.SupervisionProblemPO;
|
||||
import com.njcn.supervision.service.plan.SupervisionPlanPOService;
|
||||
import com.njcn.supervision.service.plan.SupervisionProblemPOService;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
@@ -43,7 +43,7 @@ import java.util.stream.Collectors;
|
||||
public class SupervisionProblemPOServiceImpl extends ServiceImpl<SupervisionProblemPOMapper, SupervisionProblemPO> implements SupervisionProblemPOService{
|
||||
|
||||
|
||||
private final SupervisionPlanPOService supervisionPlanPOService;
|
||||
private final SupervisionPlanPOMapper supervisionPlanPOMapper;
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final DeptFeignClient deptFeignClient;
|
||||
@@ -95,7 +95,7 @@ public class SupervisionProblemPOServiceImpl extends ServiceImpl<SupervisionProb
|
||||
//判断是否存在时间范围内
|
||||
public void checkParam(String id,String time) {
|
||||
if(StrUtil.isNotBlank(time)){
|
||||
SupervisionPlanPO supvPlan = supervisionPlanPOService.getById(id);
|
||||
SupervisionPlanPO supvPlan = supervisionPlanPOMapper.selectById(id);
|
||||
if(ObjectUtil.isNotNull(supvPlan)){
|
||||
//判断时间范围
|
||||
if (ObjectUtil.isAllNotEmpty(supvPlan.getEffectStartTime(), supvPlan.getEffectEndTime())||
|
||||
|
||||
Reference in New Issue
Block a user