Browse Source

#定时任务抽离

zhongwei
yang_shj 2 years ago
parent
commit
708e1e7e35
  1. 11
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessPlanEntity.java
  2. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/AccessPlanV4ClientFallback.java
  3. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/AccessTaskV4ClientFallback.java
  4. 4
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/IAccessPlanV4Client.java
  5. 4
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/IAccessTaskV4Client.java
  6. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/ecology/entity/EcologyFlowStationEntity.java
  7. 10
      hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/constant/TicketProcessConstant.java
  8. 3
      hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/fallback/ProcessDictFeignServiceFallback.java
  9. 2
      hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/feign/ProcessDictFeignService.java
  10. 56
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OverhaulPlanServiceImpl.java
  11. 56
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OverhaulTaskServiceImpl.java
  12. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/AccessPlanV4Controller.java
  13. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/feign/AccessPlanV4Client.java
  14. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/feign/AccessTaskV4Client.java
  15. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessPlanV4Service.java
  16. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessTaskV4Service.java
  17. 18
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java
  18. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java

11
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessPlanEntity.java

@ -1,6 +1,7 @@
package com.hnac.hzims.operational.access.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import io.swagger.annotations.ApiModel;
@ -8,6 +9,8 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
@ -62,24 +65,32 @@ public class OperAccessPlanEntity extends TenantEntity {
* 计划开始时间
*/
@ApiModelProperty(value = "计划开始时间")
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
private Date planStartTime;
/**
* 计划结束时间
*/
@ApiModelProperty(value = "计划结束时间")
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
private Date planEndTime;
/**
* 实际开始时间
*/
@ApiModelProperty(value = "实际开始时间")
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
private Date actStartTime;
/**
* 实际结束时间
*/
@ApiModelProperty(value = "实际结束时间")
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
private Date actEndTime;
/**

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/AccessPlanV4ClientFallback.java

@ -1,6 +1,6 @@
package com.hnac.hzims.operational.access.feign;
import com.hnac.hzims.common.to.process.ProcessWorkFlowResponse;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import org.springblade.core.tool.api.R;
import org.springframework.stereotype.Component;

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/AccessTaskV4ClientFallback.java

@ -1,6 +1,6 @@
package com.hnac.hzims.operational.access.feign;
import com.hnac.hzims.common.to.process.ProcessWorkFlowResponse;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import org.springblade.core.tool.api.R;
import org.springframework.stereotype.Component;

4
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/IAccessPlanV4Client.java

@ -1,6 +1,6 @@
package com.hnac.hzims.operational.access.feign;
import com.hnac.hzims.common.to.process.ProcessWorkFlowResponse;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.operational.OperationalConstants;
import org.springblade.core.tool.api.R;
import org.springframework.cloud.openfeign.FeignClient;
@ -18,7 +18,7 @@ public interface IAccessPlanV4Client {
String API_PREFIX = "/feign/accessPlanV4";
String PLAN_PROCESS_LISTENER = API_PREFIX + "listener";
String PLAN_PROCESS_LISTENER = API_PREFIX + "/listener";
@PostMapping(PLAN_PROCESS_LISTENER)
R<Boolean> listener(@RequestBody ProcessWorkFlowResponse processWorkFlowResponse);

4
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/IAccessTaskV4Client.java

@ -1,6 +1,6 @@
package com.hnac.hzims.operational.access.feign;
import com.hnac.hzims.common.to.process.ProcessWorkFlowResponse;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.operational.OperationalConstants;
import org.springblade.core.tool.api.R;
import org.springframework.cloud.openfeign.FeignClient;
@ -18,7 +18,7 @@ public interface IAccessTaskV4Client {
String API_PREFIX = "/feign/accessTaskV4";
String PLAN_PROCESS_LISTENER = API_PREFIX + "listener";
String PLAN_PROCESS_LISTENER = API_PREFIX + "/listener";
@PostMapping(PLAN_PROCESS_LISTENER)
R<Boolean> listener(@RequestBody ProcessWorkFlowResponse processWorkFlowResponse);

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/ecology/entity/EcologyFlowStationEntity.java

@ -28,6 +28,4 @@ public class EcologyFlowStationEntity extends TenantEntity {
private Long isTimely;
private Long isComplete;
private String city;
}

10
hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/constant/TicketProcessConstant.java

@ -35,4 +35,14 @@ public class TicketProcessConstant {
* 消缺流程
*/
public static final String DEFECT_KEY = "defectDealty";
/**
* 检修计划
*/
public static final String OVERHAUL_PLAN = "overhaul_plan";
/**
* 检修任务
*/
public static final String OVERHAUL_TASK = "overhaul_task";
}

3
hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/fallback/ProcessDictFeignServiceFallback.java

@ -2,6 +2,7 @@ package com.hnac.hzims.middle.process.fallback;
import com.hnac.hzims.middle.process.feign.ProcessDictFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
@ -13,7 +14,7 @@ import java.time.LocalDateTime;
* @Date 2023/6/15 15:17
*/
@Slf4j
@Service
@Component
public class ProcessDictFeignServiceFallback implements ProcessDictFeignService {
/**
* 获取工作票工作票唯一ID

2
hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/feign/ProcessDictFeignService.java

@ -2,7 +2,6 @@ package com.hnac.hzims.middle.process.feign;
import com.hnac.hzims.middle.process.fallback.ProcessDictFeignServiceFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@ -14,7 +13,6 @@ import java.time.LocalDateTime;
* @Serial 1.0
* @Date 2023/6/15 15:16
*/
@Repository
@FeignClient(value = "hzims-middle", fallback = ProcessDictFeignServiceFallback.class)
public interface ProcessDictFeignService {

56
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OverhaulPlanServiceImpl.java

@ -0,0 +1,56 @@
package com.hnac.hzims.middle.processflow.strategy.serviceimpl;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.middle.processflow.service.ProcessDictService;
import com.hnac.hzims.middle.processflow.strategy.abstracts.ProcessAbstractService;
import com.hnac.hzims.middle.processflow.strategy.entity.WorkflowQueue;
import com.hnac.hzims.operational.access.feign.IAccessPlanV4Client;
import com.hnac.hzims.operational.defect.feign.IOperDefectClient;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.api.R;
import org.springframework.stereotype.Service;
import static com.hnac.hzims.middle.process.constant.TicketProcessConstant.DEFECT_KEY;
import static com.hnac.hzims.middle.process.constant.TicketProcessConstant.OVERHAUL_PLAN;
/**
* @author ysj
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class OverhaulPlanServiceImpl extends ProcessAbstractService {
private final IAccessPlanV4Client accessPlanV4Client;
private final ProcessDictService processDictService;
/**
* 消息确认
* @param flowQueue
* @return
*/
@Override
public Boolean isWorkflowProcess(WorkflowQueue flowQueue) {
String dictValue = processDictService.selectDictValueByKey(OVERHAUL_PLAN);
return dictValue.equals(flowQueue.getProcessDefinitionKey());
}
/**
* 两票管理业务方法
*
* @param response
*/
@Override
public void calculate(ProcessWorkFlowResponse response) {
R defect = accessPlanV4Client.listener(response);
if (!defect.isSuccess()) {
throw new ServiceException("检修计划业务执行异常!");
}
}
}

56
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OverhaulTaskServiceImpl.java

@ -0,0 +1,56 @@
package com.hnac.hzims.middle.processflow.strategy.serviceimpl;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.middle.processflow.service.ProcessDictService;
import com.hnac.hzims.middle.processflow.strategy.abstracts.ProcessAbstractService;
import com.hnac.hzims.middle.processflow.strategy.entity.WorkflowQueue;
import com.hnac.hzims.operational.access.feign.IAccessPlanV4Client;
import com.hnac.hzims.operational.access.feign.IAccessTaskV4Client;
import com.hnac.hzims.operational.defect.feign.IOperDefectClient;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.api.R;
import org.springframework.stereotype.Service;
import static com.hnac.hzims.middle.process.constant.TicketProcessConstant.*;
/**
* @author ysj
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class OverhaulTaskServiceImpl extends ProcessAbstractService {
private final IAccessTaskV4Client accessTaskV4Client;
private final ProcessDictService processDictService;
/**
* 消息确认
* @param flowQueue
* @return
*/
@Override
public Boolean isWorkflowProcess(WorkflowQueue flowQueue) {
String dictValue = processDictService.selectDictValueByKey(OVERHAUL_TASK);
return dictValue.equals(flowQueue.getProcessDefinitionKey());
}
/**
* 调用检修业务处理
* @param response
*/
@Override
public void calculate(ProcessWorkFlowResponse response) {
R defect = accessTaskV4Client.listener(response);
if (!defect.isSuccess()) {
throw new ServiceException("检修任务业务执行异常!");
}
}
}

3
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/AccessPlanV4Controller.java

@ -9,6 +9,7 @@ import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.api.R;
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;
@ -32,7 +33,7 @@ public class AccessPlanV4Controller extends BladeController {
@PostMapping("/overhaul_start_v4")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "v4检修计划流程开启")
public R startV4(AccessPlanV4DTO entity) {
public R startV4(@RequestBody AccessPlanV4DTO entity) {
return R.status(service.startProcessV4(entity));
}
}

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/feign/AccessPlanV4Client.java

@ -1,6 +1,6 @@
package com.hnac.hzims.operational.access.feign;
import com.hnac.hzims.common.to.process.ProcessWorkFlowResponse;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.operational.access.service.AccessPlanV4Service;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

3
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/feign/AccessTaskV4Client.java

@ -1,7 +1,6 @@
package com.hnac.hzims.operational.access.feign;
import com.hnac.hzims.common.to.process.ProcessWorkFlowResponse;
import com.hnac.hzims.operational.access.service.AccessPlanV4Service;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.operational.access.service.AccessTaskV4Service;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessPlanV4Service.java

@ -1,6 +1,6 @@
package com.hnac.hzims.operational.access.service;
import com.hnac.hzims.common.to.process.ProcessWorkFlowResponse;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.operational.access.dto.AccessPlanV4DTO;
/**

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessTaskV4Service.java

@ -1,6 +1,6 @@
package com.hnac.hzims.operational.access.service;
import com.hnac.hzims.common.to.process.ProcessWorkFlowResponse;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.operational.access.dto.AccessTaskV4DTO;
/**

18
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java

@ -1,8 +1,9 @@
package com.hnac.hzims.operational.access.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hnac.hzims.common.to.process.ProcessWorkFlowResponse;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.operational.access.dto.*;
import com.hnac.hzims.operational.access.entity.OperAccessContentEntity;
import com.hnac.hzims.operational.access.entity.OperAccessMaterialEntity;
@ -11,6 +12,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomUtils;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.CollectionUtil;
@ -19,6 +21,7 @@ import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.flow.core.entity.BladeFlow;
import org.springblade.flow.core.feign.IFlowClient;
import org.springblade.flow.core.utils.FlowUtil;
import org.springblade.flow.core.utils.TaskUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@ -74,6 +77,7 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{
private void saveAccess(AccessPlanV4DTO entity) {
// 检修计划保存
entity.setCode("PLAN_" + DateUtil.format(DateUtil.now(), DateUtil.PATTERN_DATETIME_MINI) + new DecimalFormat("###").format(RandomUtils.nextInt(0, 999)));
entity.setProcDefId("overhaul_plan");
planService.save(entity);
}
@ -143,7 +147,9 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{
*/
private void startProcess(AccessPlanV4DTO entity) {
Map<String, Object> variables = JSONObject.parseObject(JSONObject.toJSONString(entity), Map.class);
variables.put("creator", TaskUtil.getTaskUser(String.valueOf(AuthUtil.getUserId())));
R<BladeFlow> result = flowClient.startProcessInstanceContainNameByKey("overhaul_plan", FlowUtil.getBusinessKey("access_plan_v4",String.valueOf(entity.getId())), entity.getName(), variables);
log.error("start_process_planV4 :{}",result);
// 更新任务流程Id
if (result.isSuccess()) {
BladeFlow flow = result.getData();
@ -162,16 +168,18 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{
@Override
public boolean listener(ProcessWorkFlowResponse processWorkFlowResponse) {
Map<String, Object> variables = (Map<String, Object>) processWorkFlowResponse.getVariables();
AccessPlanV4DTO entity = JSONObject.parseObject(variables.toString(), AccessPlanV4DTO.class);
AccessPlanV4DTO entity = JSONObject.parseObject(JSONObject.toJSONString(variables), new TypeReference<AccessPlanV4DTO>(){});
// 当前流程名称
entity.setTaskName(processWorkFlowResponse.getTaskName());
// 流程阶段执行人员名称
entity.setNextStepOperator(processWorkFlowResponse.getNextStepOperator());
if((Boolean) variables.get("pass")){
if(ObjectUtil.isNotEmpty(variables.get("examine")) && (Boolean) variables.get("examine")){
entity.setTaskName("流程结束");
entity.setNextStepOperator("流程结束,不需要人员处理");
entity.setNextStepOperator("流程结束,无需人员处理");
// 开启检修任务
this.startTaskProcess(entity);
}
this.saveAccess(entity);
this.planService.updateById(entity);
this.saveAccessMaterial(entity);
this.saveAccessContent(entity);
return true;

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java

@ -3,7 +3,7 @@ package com.hnac.hzims.operational.access.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hnac.hzims.common.to.process.ProcessWorkFlowResponse;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.operational.access.dto.AccessTaskV4DTO;
import com.hnac.hzims.operational.access.dto.OperAccessTaskDetailDTO;
import com.hnac.hzims.operational.access.entity.OperAccessMaterialEntity;

Loading…
Cancel
Save