diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IQuestionClient.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IQuestionClient.java index da35544..4648e36 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IQuestionClient.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IQuestionClient.java @@ -19,6 +19,7 @@ public interface IQuestionClient { String API_PREFIX = "/feign/fdp/question"; String SUBMIT_STATION_INFO = API_PREFIX + "/submitStationInfo"; String DELETE_STATION_INFO = API_PREFIX + "/deleteStationInfo"; + String DELETE_STATION_ANSWER = API_PREFIX + "/deleteStationAnswer"; /** * 提交站点信息 @@ -31,4 +32,7 @@ public interface IQuestionClient { @DeleteMapping(DELETE_STATION_INFO) R deleteStationInfo(@RequestParam String stationId); + + @DeleteMapping(DELETE_STATION_INFO) + R deleteStationAnswer(@RequestParam String stationId); } diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/QuestionClientFallback.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/QuestionClientFallback.java index 2017105..1ade243 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/QuestionClientFallback.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/QuestionClientFallback.java @@ -22,4 +22,9 @@ public class QuestionClientFallback implements IQuestionClient { public R deleteStationInfo(String stationId) { return R.fail("智能诊断删除站点失败!"); } + + @Override + public R deleteStationAnswer(String stationId) { + return R.fail("智能诊断删除站点答案失败!"); + } } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessPlanEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessPlanEntity.java index 9ca45d1..b58b9d9 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessPlanEntity.java +++ b/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; /** @@ -135,4 +146,10 @@ public class OperAccessPlanEntity extends TenantEntity { @ApiModelProperty("票据模板ID") private Long ticketTemplateId; + + @ApiModelProperty("当前步骤任务名称") + private String taskName; + + @ApiModelProperty("当前环节处理人") + private String nextStepOperator; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/AccessPlanV4ClientFallback.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/AccessPlanV4ClientFallback.java new file mode 100644 index 0000000..c98940f --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/AccessPlanV4ClientFallback.java @@ -0,0 +1,17 @@ +package com.hnac.hzims.operational.access.feign; + +import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; +import org.springblade.core.tool.api.R; +import org.springframework.stereotype.Component; + +/** + * @author ysj + */ +@Component +public class AccessPlanV4ClientFallback implements IAccessPlanV4Client { + + @Override + public R listener(ProcessWorkFlowResponse processWorkFlowResponse) { + return R.fail("执行失败!"); + } +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/AccessTaskV4ClientFallback.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/AccessTaskV4ClientFallback.java new file mode 100644 index 0000000..c85381e --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/AccessTaskV4ClientFallback.java @@ -0,0 +1,17 @@ +package com.hnac.hzims.operational.access.feign; + +import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; +import org.springblade.core.tool.api.R; +import org.springframework.stereotype.Component; + +/** + * @author ysj + */ +@Component +public class AccessTaskV4ClientFallback implements IAccessTaskV4Client { + + @Override + public R listener(ProcessWorkFlowResponse processWorkFlowResponse) { + return R.fail("执行失败!"); + } +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/IAccessPlanV4Client.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/IAccessPlanV4Client.java new file mode 100644 index 0000000..18eba65 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/IAccessPlanV4Client.java @@ -0,0 +1,25 @@ +package com.hnac.hzims.operational.access.feign; + +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; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +/** + * @author ysj + */ +@FeignClient( + value = OperationalConstants.APP_NAME, + fallback = AccessPlanV4ClientFallback.class +) +public interface IAccessPlanV4Client { + + String API_PREFIX = "/feign/accessPlanV4"; + + String PLAN_PROCESS_LISTENER = API_PREFIX + "/listener"; + + @PostMapping(PLAN_PROCESS_LISTENER) + R listener(@RequestBody ProcessWorkFlowResponse processWorkFlowResponse); +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/IAccessTaskV4Client.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/IAccessTaskV4Client.java new file mode 100644 index 0000000..433216a --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/IAccessTaskV4Client.java @@ -0,0 +1,25 @@ +package com.hnac.hzims.operational.access.feign; + +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; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +/** + * @author ysj + */ +@FeignClient( + value = OperationalConstants.APP_NAME, + fallback = AccessTaskV4ClientFallback.class +) +public interface IAccessTaskV4Client { + + String API_PREFIX = "/feign/accessTaskV4"; + + String PLAN_PROCESS_LISTENER = API_PREFIX + "/listener"; + + @PostMapping(PLAN_PROCESS_LISTENER) + R listener(@RequestBody ProcessWorkFlowResponse processWorkFlowResponse); +} diff --git a/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/constant/TicketProcessConstant.java b/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/constant/TicketProcessConstant.java index 3ce57ea..43c409e 100644 --- a/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/constant/TicketProcessConstant.java +++ b/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/constant/TicketProcessConstant.java @@ -35,4 +35,15 @@ public class TicketProcessConstant { * 消缺流程 */ public static final String DEFECT_KEY = "defectCheck"; + + /** + * 检修计划 + */ + public static final String OVERHAUL_PLAN = "overhaul_plan"; + + /** + * 检修任务 + */ + public static final String OVERHAUL_TASK = "overhaul_task"; +// public static final String DEFECT_KEY = "defectCheck"; } diff --git a/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/fallback/ProcessDictFeignServiceFallback.java b/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/fallback/ProcessDictFeignServiceFallback.java index d29fdfd..afe824b 100644 --- a/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/fallback/ProcessDictFeignServiceFallback.java +++ b/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 diff --git a/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/feign/ProcessDictFeignService.java b/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/feign/ProcessDictFeignService.java index 4e213e4..27bc415 100644 --- a/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/feign/ProcessDictFeignService.java +++ b/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 { diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java index cabb623..d0b7c17 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java @@ -159,18 +159,7 @@ public class EmInfoController extends BladeController { @ApiOperationSupport(order = 9) @ApiOperation(value = "逻辑删除", notes = "传入ids") public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { - String[] split = ids.split(","); - for (String id : split) { - List gpids = em_infoService.list(new QueryWrapper() {{ - eq("GPID", id); - }}); - if (CollectionUtil.isNotEmpty(gpids)) { - return R.fail("请先删除子设备信息"); - } - } - boolean b = em_infoService.deleteLogic(Func.toLongList(ids)); - em_infoService.getStationCodeStoreRedis(); - return R.status(b); + return R.status(em_infoService.remove(ids)); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java index fb2c548..3352f49 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java @@ -2,9 +2,11 @@ package com.hnac.hzims.equipment.service; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.vo.*; +import io.swagger.annotations.ApiParam; import org.springblade.core.mp.base.BaseService; import org.springblade.core.tool.api.R; import org.springblade.system.vo.CreateTableVO; +import org.springframework.web.bind.annotation.RequestParam; import javax.validation.Valid; import java.util.List; @@ -61,4 +63,6 @@ public interface IEmInfoService extends BaseService { List getEmCreateTable(List tableNames); List listByTenantId(String tenantId); + + Boolean remove(String ids); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java index 0b0c69a..bf4b190 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java @@ -14,6 +14,7 @@ import com.hnac.hzims.equipment.mapper.EmInfoMapper; import com.hnac.hzims.equipment.mapper.EmInfoNoScopeMapper; import com.hnac.hzims.equipment.service.*; import com.hnac.hzims.equipment.vo.*; +import com.hnac.hzims.fdp.service.IFdpQuestionService; import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; @@ -28,6 +29,8 @@ import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.*; +import org.springblade.system.entity.Dept; +import org.springblade.system.feign.ISysClient; import org.springblade.system.vo.CreateTableVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -39,6 +42,7 @@ import org.springframework.util.Assert; import javax.validation.Valid; import java.util.*; +import java.util.function.Consumer; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -72,6 +76,12 @@ public class EmInfoServiceImpl extends BaseServiceImpl idList = Func.toLongList(",",ids); + // 判断是否存在子设备 + List childEmList = this.list(Wrappers.lambdaQuery().in(EmInfoEntity::getGpid, idList)); + Assert.isTrue(CollectionUtil.isEmpty(childEmList),() -> { + throw new ServiceException("请先删除子设备信息"); + }); + // 删除FDP答题记录 + Consumer removeFdpEmInfo = id -> { + EmInfoEntity infoEntity = this.getById(id); + R deptResult = sysClient.getDept(infoEntity.getDepartment()); + if(ObjectUtil.isNotEmpty(infoEntity) && Func.isNotEmpty(infoEntity.getEmIndex()) && deptResult.isSuccess() + && Func.isNotEmpty(deptResult.getData()) && Func.isNotEmpty(deptResult.getData().getStationId())) { + questionService.deleteDevsetAnswer(deptResult.getData().getStationId(), infoEntity.getEmIndex()); + } + }; + idList.forEach(removeFdpEmInfo); + return this.deleteLogic(Func.toLongList(",", ids)); + } + /** * 设备信息缓存(ct、pt、installedCapacity、监测点位) diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/config/FdpUrlConfiguration.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/config/FdpUrlConfiguration.java index c71a221..66a9273 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/config/FdpUrlConfiguration.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/config/FdpUrlConfiguration.java @@ -48,5 +48,11 @@ public class FdpUrlConfiguration { /**按物模型实例编号删除问题答案**/ private String deleteInstanceAnswer; + /**删除站点问题的答案**/ + private String deleteStationAnswer; + + /**删除机组问题答案**/ + private String deleteDevsetAnswer; + } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/QuestionClient.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/QuestionClient.java index 3c18b89..f2ef758 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/QuestionClient.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/QuestionClient.java @@ -32,4 +32,10 @@ public class QuestionClient implements IQuestionClient { return R.status(fdpQuestionService.deleteStationInfo(stationId)); } + @DeleteMapping(DELETE_STATION_ANSWER) + @Override + public R deleteStationAnswer(String stationId) { + return R.status(fdpQuestionService.deleteStationAnswer(stationId)); + } + } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpQuestionService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpQuestionService.java index 5ff9c13..c860dce 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpQuestionService.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpQuestionService.java @@ -74,4 +74,18 @@ public interface IFdpQuestionService { */ List getInstanceAnswer(String instanceId); + /** + * 提交机组问题的答案。提交前会删除该物模型实例编号下的所有原答案 + * @param stationId 站点编码 + * @param index 设备序号 + * @return + */ + Boolean deleteDevsetAnswer(String stationId, int index); + + /** + * 删除站点问题的答案,也会删除站点的所有机组问题答案 + * @param stationId 站点ID + * @return + */ + Boolean deleteStationAnswer(String stationId); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpQuestionServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpQuestionServiceImpl.java index 44b498a..e82b1c0 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpQuestionServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpQuestionServiceImpl.java @@ -193,6 +193,48 @@ public class FdpQuestionServiceImpl implements IFdpQuestionService { return Lists.newArrayList(); } + @Override + public Boolean deleteDevsetAnswer(String stationId, int index) { + HttpResponse httpResponse = HttpRequest.post(fdpUrlConfiguration.getDeleteDevsetAnswer()).body( + JSON.toJSONString( + new HashMap(2){{ + put("stationId",stationId); + put("index",index); + }} + ) + ).execute(); + JSONObject responseObject = JSONObject.parseObject(httpResponse.body()); + if(httpResponse.getStatus() == HttpServletResponse.SC_OK && + "1".equals(responseObject.getString("success"))) { + logger.info("FdpQuestion:deleteDevsetAnswer","FDP设备删除成功!站点ID为:"+stationId+",设备编号为:"+index); + return JSONObject.parseObject(responseObject.getString("data"),Boolean.class); + } + else { + logger.error("FdpQuestion:deleteDevsetAnswer","FDP设备删除失败!站点ID为:"+stationId+",设备编号为:"+index); + } + return false; + } + + @Override + public Boolean deleteStationAnswer(String stationId) { + HttpResponse httpResponse = HttpRequest.post(fdpUrlConfiguration.getDeleteStationAnswer()).body( + JSON.toJSONString( + new HashMap(1){{ + put("stationId",stationId); + }} + ) + ).execute(); + JSONObject responseObject = JSONObject.parseObject(httpResponse.body()); + if(httpResponse.getStatus() == HttpServletResponse.SC_OK && + "1".equals(responseObject.getString("success"))) { + return JSONObject.parseObject(responseObject.getString("data"),Boolean.class); + } + else { + logger.error("FdpQuestion:deleteDevsetAnswer","FDP设备站点问题的答案失败!站点ID为:"+stationId); + } + return false; + } + /** * 根据站点类型获取Fdp的站点类型 * @param stationType 站点管理站点类型 diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OverhaulPlanServiceImpl.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OverhaulPlanServiceImpl.java new file mode 100644 index 0000000..8d52efb --- /dev/null +++ b/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("检修计划业务执行异常!"); + } + } +} diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OverhaulTaskServiceImpl.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OverhaulTaskServiceImpl.java new file mode 100644 index 0000000..3283052 --- /dev/null +++ b/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("检修任务业务执行异常!"); + + } + } +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ShowScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ShowScheduledTask.java index a65d1da..e8d43b6 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ShowScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ShowScheduledTask.java @@ -42,6 +42,7 @@ public class ShowScheduledTask { * 首页-区域班组数据 */ @XxlJob(REGIONAL_DUTY_INFO) + //@Scheduled(cron = "0/40 * * * * ? ") public ReturnT loadRegionalDuty(String param) { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/WorkTicketServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/WorkTicketServiceImpl.java index e8bb066..7cad00b 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/WorkTicketServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/WorkTicketServiceImpl.java @@ -12,6 +12,7 @@ import com.hnac.hzims.ticket.workTicket.entity.WorkTicketDelayEntity; import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; import com.hnac.hzims.ticket.workTicket.entity.WorkTicketPrincipalChangeEntity; import com.hnac.hzims.ticket.workTicket.vo.WorkTicketStatisticVO; +import lombok.AllArgsConstructor; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.base.BaseServiceImpl; @@ -29,12 +30,12 @@ import java.util.stream.Collectors; */ @Service @Slf4j -@RequiredArgsConstructor +@AllArgsConstructor @DS("ticket") public class WorkTicketServiceImpl extends BaseServiceImpl implements WorkTicketService { - private WorkPrincipalService workPrincipalService; - private WorkDelayService workDelayService; + private final WorkPrincipalService workPrincipalService; + private final WorkDelayService workDelayService; @Override public WorkTicketStatisticVO work(String start, String end, List areas) { @@ -55,31 +56,22 @@ public class WorkTicketServiceImpl extends BaseServiceImpl completeList = infoList.stream().filter(w -> TicketConstants.FirstWorkTicketFlowStatusEnum.FINISH.getStatus().equals(w.getStatus())) .collect(Collectors.toList()); work.setComplete(CollectionUtil.isNotEmpty(completeList) ? completeList.size() : 0); - //工作票移交 - FutureTask transferTask = new FutureTask(() -> { - List moveList = workPrincipalService.list(new LambdaQueryWrapper() {{ - in(WorkTicketPrincipalChangeEntity::getTicketId, infoIdList); - }}); - return CollectionUtil.isNotEmpty(moveList) ? moveList.size() : 0; - }); - - new Thread(transferTask, "工作票移交Thread").start(); - //工作票延期 - FutureTask delayTask = new FutureTask(() -> { - log.info("开始工作票延期"); - List delayEntityList = workDelayService.list(Wrappers.lambdaQuery() - .in(WorkTicketDelayEntity::getTicketId, infoIdList) - ); - return CollectionUtil.isNotEmpty(delayEntityList) ? delayEntityList.size() : 0; - }); - new Thread(delayTask, "工作票延期Thread").start(); - try { - work.setDelay((Integer) delayTask.get()); - work.setTransfer((Integer) transferTask.get()); - } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); - Thread.currentThread().interrupt(); + int transferTask = 0; + int delayTask = 0; + List moveList = workPrincipalService.list(new LambdaQueryWrapper() {{ + in(WorkTicketPrincipalChangeEntity::getTicketId, infoIdList); + }}); + if(CollectionUtil.isNotEmpty(moveList)){ + transferTask = moveList.size(); + } + List delayEntityList = workDelayService.list(Wrappers.lambdaQuery() + .in(WorkTicketDelayEntity::getTicketId, infoIdList) + ); + if(CollectionUtil.isNotEmpty(delayEntityList)){ + delayTask = delayEntityList.size(); } + work.setDelay(delayTask); + work.setTransfer(transferTask); } return work; } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/AccessPlanV4Controller.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/AccessPlanV4Controller.java new file mode 100644 index 0000000..f52d218 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/AccessPlanV4Controller.java @@ -0,0 +1,39 @@ +package com.hnac.hzims.operational.access.controller; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.operational.access.dto.AccessPlanV4DTO; +import com.hnac.hzims.operational.access.service.AccessPlanV4Service; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +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; + + +/** + * @author ysj + */ +@RestController +@AllArgsConstructor +@RequestMapping("/overhaul_plan") +@Api(tags = "v4检修计划流程") +public class AccessPlanV4Controller extends BladeController { + + + private final AccessPlanV4Service service; + + /** + * v4检修计划流程开启 + * @return + */ + @PostMapping("/overhaul_start_v4") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "v4检修计划流程开启") + public R startV4(@RequestBody AccessPlanV4DTO entity) { + return R.status(service.startProcessV4(entity)); + } +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/AccessV4Controller.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/AccessV4Controller.java new file mode 100644 index 0000000..6dbfc08 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/AccessV4Controller.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.operational.access.controller; + +import io.swagger.annotations.Api; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +/** + * @author ysj + */ +@RestController +@AllArgsConstructor +@RequestMapping("/overhaul_task") +@Api(tags = "v4检修计划流程") +public class AccessV4Controller extends BladeController { + +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/AccessPlanV4DTO.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/AccessPlanV4DTO.java new file mode 100644 index 0000000..70cc9bc --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/AccessPlanV4DTO.java @@ -0,0 +1,24 @@ +package com.hnac.hzims.operational.access.dto; + +import com.hnac.hzims.operational.access.entity.OperAccessPlanEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +/** + * @author ysj + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class AccessPlanV4DTO extends OperAccessPlanEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("检修材料列表") + private List accessMaterials; + + @ApiModelProperty("检修内容列表") + private List accessContents; +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/AccessTaskV4DTO.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/AccessTaskV4DTO.java new file mode 100644 index 0000000..36c8b8b --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/AccessTaskV4DTO.java @@ -0,0 +1,39 @@ +package com.hnac.hzims.operational.access.dto; + +import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +/** + * @author ysj + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class AccessTaskV4DTO extends OperAccessTaskEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "创建机构集合") + private List deptIds; + + @ApiModelProperty(value = "工作流Key") + private String procDefId; + + @ApiModelProperty("为1时排除票据ID为空的数据") + private Long excludeNullTicket; + + @ApiModelProperty("检修任务详情") + private List accessTaskDetails; + + @ApiModelProperty("检修材料列表") + private List accessMaterials; + + @ApiModelProperty("开始时间") + private String startTime; + + @ApiModelProperty("结束时间") + private String endTime; +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/feign/AccessPlanV4Client.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/feign/AccessPlanV4Client.java new file mode 100644 index 0000000..73ed760 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/feign/AccessPlanV4Client.java @@ -0,0 +1,34 @@ +package com.hnac.hzims.operational.access.feign; + +import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; +import com.hnac.hzims.operational.access.service.AccessPlanV4Service; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +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; + +/** + * @author ysj + */ +@RestController +@RequestMapping("/feign/accessPlanV4") +@Slf4j +@RequiredArgsConstructor +public class AccessPlanV4Client implements IAccessPlanV4Client { + + private final AccessPlanV4Service service; + + /** + * 检修计划流程监听 + * @param processWorkFlowResponse + * @return + */ + @Override + @PostMapping("/listener") + public R listener(@RequestBody ProcessWorkFlowResponse processWorkFlowResponse) { + return R.status(service.listener(processWorkFlowResponse)); + } +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/feign/AccessTaskV4Client.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/feign/AccessTaskV4Client.java new file mode 100644 index 0000000..a4684f3 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/feign/AccessTaskV4Client.java @@ -0,0 +1,34 @@ +package com.hnac.hzims.operational.access.feign; + +import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; +import com.hnac.hzims.operational.access.service.AccessTaskV4Service; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +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; + +/** + * @author ysj + */ +@RestController +@RequestMapping("/feign/accessTaskV4") +@Slf4j +@RequiredArgsConstructor +public class AccessTaskV4Client implements IAccessTaskV4Client { + + private final AccessTaskV4Service service; + + /** + * 检修任务流程监听 + * @param processWorkFlowResponse + * @return + */ + @Override + @PostMapping("/listener") + public R listener(@RequestBody ProcessWorkFlowResponse processWorkFlowResponse) { + return R.status(service.listener(processWorkFlowResponse)); + } +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessPlanV4Service.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessPlanV4Service.java new file mode 100644 index 0000000..f95e019 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessPlanV4Service.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.operational.access.service; + +import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; +import com.hnac.hzims.operational.access.dto.AccessPlanV4DTO; + +/** + * @author ysj + */ +public interface AccessPlanV4Service{ + + boolean startProcessV4(AccessPlanV4DTO entity); + + boolean listener(ProcessWorkFlowResponse processWorkFlowResponse); +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessTaskV4Service.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessTaskV4Service.java new file mode 100644 index 0000000..409624b --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessTaskV4Service.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.operational.access.service; + +import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; +import com.hnac.hzims.operational.access.dto.AccessTaskV4DTO; + +/** + * @author ysj + */ +public interface AccessTaskV4Service { + + boolean startProcessV4(AccessTaskV4DTO entity); + + boolean listener(ProcessWorkFlowResponse processWorkFlowResponse); +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java new file mode 100644 index 0000000..8158577 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java @@ -0,0 +1,223 @@ +package com.hnac.hzims.operational.access.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +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; +import com.hnac.hzims.operational.access.service.*; +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; +import org.springblade.core.tool.utils.DateUtil; +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; + +import java.text.DecimalFormat; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author ysj + */ +@Service +@Slf4j +@RequiredArgsConstructor +public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ + + private final IOperAccessPlanService planService; + + private final IOperAccessMaterialService materialService; + + private final IOperAccessContentService contentService; + + private final AccessTaskV4Service accessTaskV4Service; + + private final IFlowClient flowClient; + + /** + * 开启检修计划流程 + * @param entity + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public boolean startProcessV4(AccessPlanV4DTO entity) { + // 步骤1.保存检修计划 + this.saveAccess(entity); + + // 步骤2.保存检修材料 + this.saveAccessMaterial(entity); + + // 步骤3.保存检修明细 + this.saveAccessContent(entity); + + // 步骤2.开启检修计划流程 + this.startProcess(entity); + return true; + } + + /** + * 保存检修计划 + * @param entity + */ + 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"); + entity.setActStartTime(new Date()); + planService.save(entity); + } + + + /** + * 保存检修材料 + * @param entity + */ + private void saveAccessMaterial(AccessPlanV4DTO entity) { + if(CollectionUtils.isEmpty(entity.getAccessMaterials())){ + return; + } + // 查询计划是否绑定检修材料 + List existsDetails = materialService.list(new LambdaQueryWrapper() {{ + eq(OperAccessMaterialEntity::getPlanId, entity.getId()); + eq(OperAccessMaterialEntity::getIsDeleted, 0L); + }}); + Set detailIds = entity.getAccessMaterials().stream().map(OperAccessMaterialDTO::getId).filter(Objects::nonNull).collect(Collectors.toSet()); + List ids = existsDetails.stream().map(OperAccessMaterialEntity::getId).filter(id -> !detailIds.contains(id)).collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(ids)) { + materialService.deleteLogic(ids); + } + // 材料添加/修改 + for (OperAccessMaterialDTO material : entity.getAccessMaterials()) { + material.setPlanId(entity.getId()); + if (ObjectUtil.isEmpty(material.getId())) { + materialService.doSave(material); + continue; + } + materialService.updateById(material); + } + } + + /** + * 保存检修明细 + * @param entity + */ + private void saveAccessContent(AccessPlanV4DTO entity) { + if(CollectionUtils.isEmpty(entity.getAccessContents())){ + return; + } + // 查询计划是否绑定任务明细 + List existsDetails = contentService.list(new LambdaQueryWrapper() {{ + eq(OperAccessContentEntity::getPlanId, entity.getId()); + eq(OperAccessContentEntity::getIsDeleted, 0L); + }}); + Set detailIds = entity.getAccessContents().stream().map(OperAccessContentDTO::getId).filter(Objects::nonNull).collect(Collectors.toSet()); + List ids = existsDetails.stream().map(OperAccessContentEntity::getId).filter(id -> !detailIds.contains(id)).collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(ids)) { + contentService.deleteLogic(ids); + } + // 明细添加/修改 + for (OperAccessContentDTO content : entity.getAccessContents()) { + content.setPlanId(entity.getId()); + if (ObjectUtil.isEmpty(content.getId())) { + contentService.doSave(content); + continue; + } + contentService.doUpdateById(content); + } + } + + + /** + * 开启检修计划流程 + * @param entity + */ + private void startProcess(AccessPlanV4DTO entity) { + Map variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(entity,DateUtil.PATTERN_DATETIME), Map.class); + variables.put("creator", TaskUtil.getTaskUser(String.valueOf(AuthUtil.getUserId()))); + R 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(); + entity.setProcessInstanceId(flow.getProcessInstanceId()); + planService.updateById(entity); + } else { + throw new ServiceException("开启检修计划流程失败,code=" + result.getCode()); + } + } + + /** + * 检修计划流程监听 + * @param processWorkFlowResponse + * @return + */ + @Override + public boolean listener(ProcessWorkFlowResponse processWorkFlowResponse) { + Map variables = (Map) processWorkFlowResponse.getVariables(); + AccessPlanV4DTO entity = JSONObject.parseObject(JSONObject.toJSONString(variables), new TypeReference(){}); + // 当前流程名称 + entity.setTaskName(processWorkFlowResponse.getTaskName()); + // 流程阶段执行人员名称 + entity.setNextStepOperator(processWorkFlowResponse.getNextStepOperator()); + if(ObjectUtil.isNotEmpty(variables.get("examine")) && (Boolean) variables.get("examine")){ + entity.setTaskName("流程结束"); + entity.setNextStepOperator("流程结束,无需人员处理"); + entity.setActEndTime(new Date()); + // 开启检修任务 + this.startTaskProcess(entity); + } + this.planService.updateById(entity); + this.saveAccessMaterial(entity); + this.saveAccessContent(entity); + return true; + } + + /** + * 开启检修任务 + * @param entity + */ + private void startTaskProcess(AccessPlanV4DTO entity) { + for(OperAccessContentDTO item : entity.getAccessContents()){ + //任务参数 + AccessTaskV4DTO task = BeanUtil.copy(item, AccessTaskV4DTO.class); + task.setCreateTime(new Date()); + task.setCreateUser(entity.getCreateUser()); + task.setProcDefId(entity.getProcDefId()); + task.setHandler(item.getManager()); + task.setPlanId(entity.getId()); + task.setContentId(item.getId()); + task.setEmCode(item.getEmCode()); + // 任务详情 + if(CollectionUtil.isNotEmpty(item.getAccessContentDetails())){ + task.setAccessTaskDetails(item.getAccessContentDetails().stream().map(content -> { + OperAccessTaskDetailDTO detail = new OperAccessTaskDetailDTO(); + detail.setContentDetailId(content.getId()); + detail.setContent(content.getContent()); + detail.setName(content.getName()); + return detail; + }).collect(Collectors.toList())); + } + // 材料 + if(CollectionUtil.isNotEmpty(entity.getAccessMaterials())){ + task.setAccessMaterials(entity.getAccessMaterials().stream().map(o-> BeanUtil.copy(o,OperAccessMaterialDTO.class)).collect(Collectors.toList())); + } + accessTaskV4Service.startProcessV4(task); + } + } +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java new file mode 100644 index 0000000..111f711 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java @@ -0,0 +1,160 @@ +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.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; +import com.hnac.hzims.operational.access.entity.OperAccessTaskDetailEntity; +import com.hnac.hzims.operational.access.service.AccessTaskV4Service; +import com.hnac.hzims.operational.access.service.IOperAccessMaterialService; +import com.hnac.hzims.operational.access.service.IOperAccessTaskDetailService; +import com.hnac.hzims.operational.access.service.IOperAccessTaskService; +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.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; +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; + +import java.text.DecimalFormat; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * @author ysj + */ +@Service +@Slf4j +@RequiredArgsConstructor +public class AccessTaskV4ServiceImpl implements AccessTaskV4Service { + + private final IOperAccessTaskService taskService; + + private final IOperAccessMaterialService materialService; + + private final IOperAccessTaskDetailService detailService; + + private final IFlowClient flowClient; + + /** + * 开启检修任务流程 + * @param entity + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public boolean startProcessV4(AccessTaskV4DTO entity) { + // 步骤1.保存检修任务 + this.save(entity); + + // 步骤2.保存检修材料 + this.saveMaterial(entity); + + // 步骤3.保存检修详情 + this.saveDetails(entity); + + // 步骤4.开启检修任务流程 + this.startProcess(entity); + return true; + } + + /** + * 开启检修流程 + * @param entity + */ + private void startProcess(AccessTaskV4DTO entity) { + Map variables = JSONObject.parseObject(JSONObject.toJSONString(entity), Map.class); + variables.put("handler",TaskUtil.getTaskUser(entity.getHandler().toString())); + R result = flowClient.startProcessInstanceContainNameByKey("overhaul_task", FlowUtil.getBusinessKey("access_task_v4", String.valueOf(entity.getId())), entity.getName(),variables); + // 更新任务流程Id + if (result.isSuccess()) { + BladeFlow flow = result.getData(); + entity.setProcessInstanceId(flow.getProcessInstanceId()); + taskService.updateById(entity); + } else { + throw new ServiceException("开启检修任务流程失败,code=" + result.getCode()); + } + } + + /** + * 检修任务保存 + * @param entity + */ + private void save(AccessTaskV4DTO entity) { + entity.setCode("TASK" + DateUtil.format(DateUtil.now(), DateUtil.PATTERN_DATETIME_MINI) + new DecimalFormat("###").format(RandomUtils.nextInt(0, 999))); + List materialEntityList = JSONObject.parseArray(JSON.toJSONString(entity.getAccessMaterials()), OperAccessMaterialEntity.class); + taskService.save(entity); + } + + /** + * 保存检修材料 + * @param entity + */ + private void saveMaterial(AccessTaskV4DTO entity) { + if (CollectionUtil.isNotEmpty(entity.getAccessMaterials())) { + return; + } + materialService.saveOrUpdateBatch(entity.getAccessMaterials().stream().peek(material -> { + material.setPlanId(null); + material.setId(null); + material.setTaskId(entity.getId()); + }).collect(Collectors.toList())); + } + + /** + * 保存检修对象 + * @param entity + * + */ + private void saveDetails(AccessTaskV4DTO entity) { + if(CollectionUtil.isEmpty(entity.getAccessTaskDetails())){ + return; + } + // 查询检修任务关联的检修对象 + List existsDetails = detailService.list(new LambdaQueryWrapper() {{ + eq(OperAccessTaskDetailEntity::getTaskId, entity.getId()); + eq(OperAccessTaskDetailEntity::getIsDeleted, 0L); + }}); + Set detailIds = entity.getAccessTaskDetails().stream().map(OperAccessTaskDetailDTO::getId).filter(Objects::nonNull).collect(Collectors.toSet()); + List ids = existsDetails.stream().map(OperAccessTaskDetailEntity::getId).filter(id -> !detailIds.contains(id)).collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(ids)) { + detailService.deleteLogic(ids); + } + // 检修任务对象 + Set existsIds = existsDetails.stream().map(OperAccessTaskDetailEntity::getId).collect(Collectors.toSet()); + for (OperAccessTaskDetailDTO details : entity.getAccessTaskDetails()) { + details.setTaskId(entity.getId()); + if (ObjectUtil.isNotEmpty(entity.getId())) { + detailService.updateById(details); + continue; + } + detailService.doSave(details); + } + } + + /** + * 检修任务流程监听 + * @param processWorkFlowResponse + * @return + */ + @Override + public boolean listener(ProcessWorkFlowResponse processWorkFlowResponse) { + + return false; + } +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/controller/EcologyController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/controller/EcologyController.java index f9f2e35..cbe4991 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/controller/EcologyController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/controller/EcologyController.java @@ -54,8 +54,8 @@ public class EcologyController extends BladeController { @PostMapping("/station_top") @ApiOperationSupport(order = 1) @ApiOperation(value = "站点数据及达标率排行", notes = "站点数据及达标率排行") - public R station_top(@RequestParam String city) { - return R.data(stationService.station_top(city)); + public R station_top(@RequestParam Long deptId) { + return R.data(stationService.station_top(deptId)); } /** @@ -65,8 +65,8 @@ public class EcologyController extends BladeController { @PostMapping("/trend_chart") @ApiOperationSupport(order = 1) @ApiOperation(value = "指标趋势图", notes = "指标趋势图") - public R trend_chart(@RequestParam String city,@RequestParam String type) { - return R.data(stationService.trend_chart(city,type)); + public R trend_chart(@RequestParam Long deptId,@RequestParam String type) { + return R.data(stationService.trend_chart(deptId,type)); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/service/EcologyFlowStationService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/service/EcologyFlowStationService.java index d129ab9..5dc89da 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/service/EcologyFlowStationService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/service/EcologyFlowStationService.java @@ -14,12 +14,12 @@ import java.util.List; */ public interface EcologyFlowStationService extends BaseService { - EcologFlowStationVo station_top(String city); + EcologFlowStationVo station_top(Long deptId); Boolean generate(Long mon,String year); - List trend_chart(String city,String type); + List trend_chart(Long deptId,String type); List station(); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/service/impl/EcologyFlowStationServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/service/impl/EcologyFlowStationServiceImpl.java index fbbcda1..820a9fd 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/service/impl/EcologyFlowStationServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/service/impl/EcologyFlowStationServiceImpl.java @@ -98,9 +98,9 @@ public class EcologyFlowStationServiceImpl extends BaseServiceImpl stations = this.list(Wrappers.lambdaQuery() - .eq(EcologyFlowStationEntity::getCity,city)); + .eq(EcologyFlowStationEntity::getCreateDept,deptId)); if(CollectionUtil.isEmpty(stations)){ return new EcologFlowStationVo(); } @@ -134,9 +134,9 @@ public class EcologyFlowStationServiceImpl extends BaseServiceImpl trend_chart(String city,String type) { + public List trend_chart(Long deptId,String type) { List stations = this.list(Wrappers.lambdaQuery() - .eq(EcologyFlowStationEntity::getCity,city)); + .eq(EcologyFlowStationEntity::getCreateDept,deptId)); if(CollectionUtil.isEmpty(stations)){ return new ArrayList<>(); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationAttributeController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationAttributeController.java index 0ba2954..eede11e 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationAttributeController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationAttributeController.java @@ -91,10 +91,12 @@ public class StationAttributeController extends BladeController { return R.status(stationAttributeService.deleteLogic(Func.toLongList(ids))); } - @PutMapping("/bandingMonitor/{emCode}") + @PutMapping("/bandingMonitor") @ApiOperation("根据设备编码更新集中监控监测点绑定") @ApiOperationSupport(order = 4) - public R> bandingMonitor(@PathVariable @ApiParam(value = "设备编码",required = true) String emCode) { - return R.data(stationAttributeService.bandingMonitor(emCode)); + public R> bandingMonitor(@ApiParam(value = "设备编码",required = true) String emCode, + @ApiParam(value = "站点类型",required = true) String stationType, + @ApiParam(value = "设备类型",required = true) String emType) { + return R.data(stationAttributeService.bandingMonitor(emCode,stationType,emType)); } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationAttributeService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationAttributeService.java index 9a0f891..d3ecdb8 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationAttributeService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationAttributeService.java @@ -45,5 +45,5 @@ public interface IStationAttributeService extends BaseService bandingMonitor(String emCode); + List bandingMonitor(String emCode,String stationType,String emType); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationAttributeServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationAttributeServiceImpl.java index efaf4d1..e9dd316 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationAttributeServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationAttributeServiceImpl.java @@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Lists; import com.hnac.hzims.common.service.UserAuthDataService; import com.hnac.hzims.fdp.vo.FdpFaultStatusVo; +import com.hnac.hzims.operational.config.entity.FocusAttributeEntity; +import com.hnac.hzims.operational.config.service.IFocusAttributeService; import com.hnac.hzims.operational.station.entity.StationAttrConfigEntity; import com.hnac.hzims.operational.station.entity.StationAttributeEntity; import com.hnac.hzims.operational.station.entity.StationEntity; @@ -14,7 +16,10 @@ import com.hnac.hzims.operational.station.service.IStationAttrConfigService; import com.hnac.hzims.operational.station.service.IStationAttributeService; import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.vo.StationAttributeVo; +import com.hnac.hzinfo.sdk.core.response.Result; import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; +import com.hnac.hzinfo.sdk.v5.device.dto.DeviceChildrenDTO; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceChildrenVO; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; import lombok.AllArgsConstructor; import lombok.RequiredArgsConstructor; @@ -25,19 +30,14 @@ import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; 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; -import org.springblade.core.tool.utils.ObjectUtil; -import org.springblade.core.tool.utils.StringUtil; +import org.springblade.core.tool.utils.*; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.util.Assert; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -50,6 +50,7 @@ public class StationAttributeServiceImpl extends BaseServiceImpl bandingMonitor(String emCode) { - List result = new ArrayList<>(); - LambdaQueryWrapper wq = Wrappers.lambdaQuery().eq(StationAttributeEntity::getEmCode, emCode); - List attributeEntities = this.list(wq); - if(CollectionUtil.isEmpty(attributeEntities)) { - return Lists.newArrayList(); - } - // 获取设备实例物模型绑定数据 - R> onlineAttrR= deviceClient.getOnlineAttr(emCode); - Assert.isTrue(onlineAttrR.isSuccess(),() -> { - throw new ServiceException(onlineAttrR.getMsg()); - }); - if(CollectionUtil.isNotEmpty(onlineAttrR.getData())) { - Map> stringListMap = onlineAttrR.getData().stream().collect(Collectors.groupingBy(DeviceInstanceAttrVO::getSignage)); - result = attributeEntities.stream().map(attributeEntity -> { - StationAttributeVo attributeVo = BeanUtil.copy(attributeEntity, StationAttributeVo.class); - List deviceInstanceAttrVOS = stringListMap.get(attributeEntity.getSignage()); - if(CollectionUtil.isNotEmpty(deviceInstanceAttrVOS)) { - attributeVo.setMonitorId(deviceInstanceAttrVOS.get(0).getFacDeviceAttrId()); - attributeVo.setMonitorName(deviceInstanceAttrVOS.get(0).getFacDeviceAttrName()); - } - return attributeVo; - }).collect(Collectors.toList()); - } + public List bandingMonitor(String emCode,String stationType,String emType) { + List result; + // 获取集中监控属性配置 + List attributes = attributeService.list(Wrappers.lambdaQuery() + .eq(FocusAttributeEntity::getDomainId, stationType) + .eq(FocusAttributeEntity::getGroupId, emType) + .eq(FocusAttributeEntity::getStatus, 0) + ); + // 标识 + List signages = attributes.stream().map(FocusAttributeEntity::getSignage).filter(Func::isNotEmpty).collect(Collectors.toList()); + // 根据设备实例查询采集点 + DeviceChildrenDTO deviceChildrenDTO = new DeviceChildrenDTO(); + deviceChildrenDTO.setSignages(signages); + deviceChildrenDTO.setDeviceCode(emCode); + deviceChildrenDTO.setType("attr"); + Result> deviceChildrenListResult = deviceClient.getRealId(deviceChildrenDTO); + boolean facAttrFlag = deviceChildrenListResult.isSuccess() && CollectionUtil.isNotEmpty(deviceChildrenListResult.getData()); + // 根据集中监控属性配置获取站点集中监控属性配置 + Function convert = focusAttr -> { + StationAttributeVo vo = BeanUtil.copy(focusAttr,StationAttributeVo.class); + if(facAttrFlag) { + List data = deviceChildrenListResult.getData(); + Optional facAttrOptional = data.stream().filter(attr -> focusAttr.getSignage().equals(attr.getSignage())).findAny(); + vo.setMonitorId(facAttrOptional.map(DeviceChildrenVO::getRealId).orElse(null)); + vo.setMonitorName(facAttrOptional.map(DeviceChildrenVO::getName).orElse(null)); + } + return vo; + }; + result = attributes.stream().map(convert).collect(Collectors.toList()); return result; } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java index 1a06dad..17d0b92 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.operational.station.service.impl; + package com.hnac.hzims.operational.station.service.impl; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -142,11 +142,16 @@ public class StationServiceImpl extends BaseServiceImpl { + // 删除站点下集中监控属性配置 stationAttributeService.removeByStationCode(stationEntity.getCode()); + // 删除智能诊断站点 + questionClient.deleteStationInfo(stationEntity.getCode()); + // 删除智能诊断实例图信息 + questionClient.deleteStationAnswer(stationEntity.getCode()); },"删除站点集中监控属性").start(); return saveFlag; } diff --git a/pom.xml b/pom.xml index 722d126..255422d 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ 3.8.1 UTF-8 - 4.6.1-SNAPSHOT + 5.0.1-SNAPSHOT