From b726697e566e2cb029831944d4e6203293dea013 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Thu, 31 Aug 2023 17:49:20 +0800 Subject: [PATCH] =?UTF-8?q?#=E6=99=BA=E8=83=BD=E7=94=9F=E4=BA=A7=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/spare/feign/ISpareClient.java | 7 + .../hzims/spare/feign/ISpareClientFallback.java | 7 + .../java/com/hnac/hzims/spare/vo/ExceedVo.java | 26 +++ .../hnac/hzims/fdp/feign/IFdpMonitorClient.java | 2 +- .../hzims/fdp/feign/IFdpMonitorClientFallBack.java | 2 +- .../hzims/operational/census/vo/AreaTimelyVo.java | 6 + .../inspect/task/feign/IInspectTaskClient.java | 15 +- .../inspect/task/feign/IInspectTaskClientBack.java | 5 + .../com/hnac/hzims/spare/feign/SpareClient.java | 94 ++++++++- .../com/hnac/hzims/fdp/feign/FdpMonitorClient.java | 4 +- .../hnac/hzims/fdp/service/IFdpMonitorService.java | 2 +- .../fdp/service/impl/FdpMonitorServiceImpl.java | 18 +- .../inspect/task/feign/InspectTaskClient.java | 19 ++ .../census/controller/AreaDutyController.java | 21 +- .../census/service/impl/AreaDutyServiceImpl.java | 216 +++++++++++++++++++-- .../service/impl/StAlamRecordServiceImpl.java | 2 +- 16 files changed, 397 insertions(+), 49 deletions(-) create mode 100644 hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/vo/ExceedVo.java diff --git a/hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/feign/ISpareClient.java b/hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/feign/ISpareClient.java index 703e512..ba86f10 100644 --- a/hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/feign/ISpareClient.java +++ b/hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/feign/ISpareClient.java @@ -1,6 +1,8 @@ package com.hnac.hzims.spare.feign; +import com.hnac.hzims.operational.census.vo.AreaTimelyVo; import com.hnac.hzims.spare.entity.*; +import com.hnac.hzims.spare.vo.ExceedVo; import com.hnac.hzims.spare.vo.WtSpBasicVO; import org.springblade.core.tool.api.R; import org.springframework.cloud.openfeign.FeignClient; @@ -19,6 +21,8 @@ public interface ISpareClient { String API_PREFIX = "/client"; String WAREHOUSEOUT = API_PREFIX+"/warehouseOut"; + String EXCEED_LIMIT = API_PREFIX + "/exceedLimit" ; + /** * 保存工单与出库单关联信息 * @param recordEntity @@ -26,4 +30,7 @@ public interface ISpareClient { */ @PostMapping(WAREHOUSEOUT) Boolean warehouseOut(@RequestBody SpRecordEntity recordEntity); + + @PostMapping(EXCEED_LIMIT) + List exceedLimit(@RequestParam("deptId") Long deptId); } diff --git a/hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/feign/ISpareClientFallback.java b/hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/feign/ISpareClientFallback.java index fffc82b..6a55a8e 100644 --- a/hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/feign/ISpareClientFallback.java +++ b/hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/feign/ISpareClientFallback.java @@ -1,5 +1,6 @@ package com.hnac.hzims.spare.feign; +import com.hnac.hzims.operational.census.vo.AreaTimelyVo; import com.hnac.hzims.spare.entity.*; import com.hnac.hzims.spare.vo.WtSpBasicVO; import org.springblade.core.tool.api.R; @@ -7,6 +8,7 @@ import org.springframework.stereotype.Component; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -17,4 +19,9 @@ public class ISpareClientFallback implements ISpareClient { public Boolean warehouseOut(SpRecordEntity recordEntity) { return false; } + + @Override + public List exceedLimit(Long deptId) { + return new ArrayList<>(); + } } diff --git a/hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/vo/ExceedVo.java b/hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/vo/ExceedVo.java new file mode 100644 index 0000000..c1b4e1c --- /dev/null +++ b/hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/vo/ExceedVo.java @@ -0,0 +1,26 @@ +package com.hnac.hzims.spare.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + */ +@Data +public class ExceedVo { + + @ApiModelProperty(value = "机构名称") + private String deptName; + + @ApiModelProperty(value = "事件Id") + private String eventId; + + @ApiModelProperty(value = "事件内容") + private String content; + + @ApiModelProperty(value = "事件time") + private String time; + + @ApiModelProperty(value = "提醒数量") + private Integer sum; +} diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IFdpMonitorClient.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IFdpMonitorClient.java index 304fe4e..7c8ffa3 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IFdpMonitorClient.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IFdpMonitorClient.java @@ -32,7 +32,7 @@ public interface IFdpMonitorClient { R> getRealIds(); @GetMapping(GET_FAULT_LIST) - String getFaultList(); + String getFaultList(List stations); @GetMapping(UPDATE_FAULT_STATE) String updateFaultState(UpdateFaultStateVo state); diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IFdpMonitorClientFallBack.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IFdpMonitorClientFallBack.java index a96ff35..f354cff 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IFdpMonitorClientFallBack.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IFdpMonitorClientFallBack.java @@ -24,7 +24,7 @@ public class IFdpMonitorClientFallBack implements IFdpMonitorClient{ } @Override - public String getFaultList() { + public String getFaultList(List stations) { return null; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/AreaTimelyVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/AreaTimelyVo.java index 0f5c844..d50cd69 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/AreaTimelyVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/AreaTimelyVo.java @@ -11,6 +11,9 @@ import lombok.Data; @Data public class AreaTimelyVo { + @ApiModelProperty(value = "机构名称") + private String deptName; + @ApiModelProperty(value = "事件Id") private String eventId; @@ -22,4 +25,7 @@ public class AreaTimelyVo { @ApiModelProperty(value = "提醒数量") private Integer sum; + + @ApiModelProperty(value = "字体颜色:1-红色 0-黄色") + private Integer colour; } diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/feign/IInspectTaskClient.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/feign/IInspectTaskClient.java index db54fe2..2804780 100644 --- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/feign/IInspectTaskClient.java +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/feign/IInspectTaskClient.java @@ -20,6 +20,8 @@ public interface IInspectTaskClient { String QUERY_BY_PLAN_START_TIME_AND_DEPT = API_PREFIX + "/queryByPlanStartTimeAndDept"; String GET_INSPECT_TASK_CHECK = API_PREFIX + "/getInspectTaskCheck"; + String EXPIRE_INSPECT = API_PREFIX + "/expireInspect"; + /** * 根据创建时间查询巡检任务列表 **/ @@ -40,9 +42,20 @@ public interface IInspectTaskClient { * @param inspectType 查询类型 1:为运行人员 2:管理及其他人员 * @return */ - @GetMapping(GET_INSPECT_TASK_CHECK) + @GetMapping(EXPIRE_INSPECT) R getInspectTaskCheck(@RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate, @RequestParam("dept") Long dept, @RequestParam("inspectType") String inspectType); + + /** + * 查询到期巡检 + * @param start + * @param end + * @param deptId + * @return + */ + @GetMapping(EXPIRE_INSPECT) + List expireInspect(@RequestParam("start") String start, @RequestParam("end") String end,@RequestParam("deptId")Long deptId); + } diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/feign/IInspectTaskClientBack.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/feign/IInspectTaskClientBack.java index bd35e0e..0075825 100644 --- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/feign/IInspectTaskClientBack.java +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/feign/IInspectTaskClientBack.java @@ -28,4 +28,9 @@ public class IInspectTaskClientBack implements IInspectTaskClient { public R getInspectTaskCheck(String startDate, String endDate, Long dept, String inspectType) { return R.data(new SafeCheckStatisticVO()); } + + @Override + public List expireInspect(String start, String end, Long deptId) { + return new ArrayList<>(); + } } diff --git a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/feign/SpareClient.java b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/feign/SpareClient.java index 191d23e..aef9c2b 100644 --- a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/feign/SpareClient.java +++ b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/feign/SpareClient.java @@ -1,23 +1,26 @@ package com.hnac.hzims.spare.feign; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.operational.census.vo.AreaTimelyVo; import com.hnac.hzims.spare.entity.*; import com.hnac.hzims.spare.mapper.SpRecordMapper; import com.hnac.hzims.spare.mapper.SpWarehouseOutMapper; import com.hnac.hzims.spare.service.*; -import com.hnac.hzims.spare.vo.WtSpBasicVO; import lombok.RequiredArgsConstructor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springblade.core.mp.support.Condition; -import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.RequestParam; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.system.feign.ISysClient; import org.springframework.web.bind.annotation.RestController; import springfox.documentation.annotations.ApiIgnore; -import java.text.SimpleDateFormat; -import java.util.*; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; /** * 备品备件Feign实现类 @@ -42,8 +45,17 @@ public class SpareClient implements ISpareClient{ private final IWtSpProviderService providerService; + private final IWtSpTotalService totalService; + + private final IWtSpBasicService wtSpBasicService; + private final ISpWarehouseOutService warehouseOutService; + private final IWtSpWarehouseService wtSpWarehouseService; + + private final ISysClient sysClient; + + @Override public Boolean warehouseOut(SpRecordEntity recordEntity) { List recordEntities = new ArrayList<>(); @@ -57,4 +69,72 @@ public class SpareClient implements ISpareClient{ Boolean result = warehouseOutService.save(entity); return result; } + + /** + * 固定资产越限 + * @param deptId + * @return + */ + @Override + public List exceedLimit(Long deptId) { + // 查询仓库 + List warehouses = wtSpWarehouseService.list(Wrappers.lambdaQuery() + .like(WtSpWarehouseEntity::getCreateDept,deptId) + ); + if(CollectionUtil.isEmpty(warehouses)){ + return new ArrayList<>(); + } + // 查询库存 + List totals = totalService.list(Wrappers.lambdaQuery() + .in(WtSpTotalEntity::getWarehouseId, warehouses.stream().map(WtSpWarehouseEntity::getId).collect(Collectors.toList())) + ); + if(CollectionUtil.isEmpty(totals)){ + return new ArrayList<>(); + } + // 查询限制条件 + List basics = wtSpBasicService.list(Wrappers.lambdaQuery() + .in(WtSpBasicEntity::getId,totals.stream().map(WtSpTotalEntity::getSpBasicId).collect(Collectors.toList())) + ); + if(CollectionUtil.isEmpty(totals)){ + return new ArrayList<>(); + } + // 过滤越限记录 + List exceeds = new ArrayList<>(); + for (WtSpTotalEntity total : totals){ + WtSpBasicEntity basic = basics.stream().filter(o->o.getId().equals(total.getSpBasicId())).min(Comparator.comparing(WtSpBasicEntity::getId)).get(); + if(ObjectUtil.isEmpty(basics)){ + continue; + } + if(total.getStock() > basic.getUpperLimit() || total.getStock() < basic.getLowerLimit()){ + AreaTimelyVo timely = new AreaTimelyVo(); + WtSpWarehouseEntity warehouse = warehouses.stream().filter(o->o.getId().equals(total.getWarehouseId())).min(Comparator.comparing(WtSpWarehouseEntity::getId)).get(); + timely.setDeptName(warehouse.getName()); + timely.setEventId(String.valueOf(total.getId())); + if(total.getStock() > basic.getUpperLimit()){ + timely.setContent(String.format("(%s)已达到上限,目前仓库内的库存为:%s,上限值为:%s。", + basic.getName(), + total.getStock(), + basic.getUpperLimit())); + timely.setSum((int) (total.getStock() - basic.getUpperLimit())); + timely.setColour(0); + if((double) (total.getStock() - basic.getUpperLimit()) / basic.getUpperLimit() > 0.3){ + timely.setColour(1); + } + }else{ + timely.setContent(String.format("(%s)已达到下限,目前仓库内的库存为:%s,下限值为:%s。", + basic.getName(), + total.getStock(), + basic.getUpperLimit())); + timely.setSum((int) (total.getStock() - basic.getLowerLimit())); + timely.setColour(0); + if((double)(basic.getLowerLimit() - total.getStock()) / basic.getLowerLimit() > 0.3){ + timely.setColour(1); + } + } + timely.setTime(DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME)); + exceeds.add(timely); + } + } + return exceeds; + } } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/FdpMonitorClient.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/FdpMonitorClient.java index b8a3552..e8d2f6a 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/FdpMonitorClient.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/FdpMonitorClient.java @@ -30,8 +30,8 @@ public class FdpMonitorClient implements IFdpMonitorClient{ @GetMapping(GET_FAULT_LIST) @Override - public String getFaultList() { - return fdpMonitorService.getFaultList(); + public String getFaultList(List stations) { + return fdpMonitorService.getFaultList(stations); } @GetMapping(UPDATE_FAULT_STATE) diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpMonitorService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpMonitorService.java index 6dda785..31e19a7 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpMonitorService.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpMonitorService.java @@ -159,7 +159,7 @@ public interface IFdpMonitorService extends BaseService { List getRealIds(); - String getFaultList(); + String getFaultList(List stations); String updateFaultState(UpdateFaultStateVo state); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpMonitorServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpMonitorServiceImpl.java index 364ca2d..ccf9ee1 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpMonitorServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpMonitorServiceImpl.java @@ -629,16 +629,20 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl list = this.baseMapper.selectStationIds(); - if (CollectionUtil.isEmpty(list)) { - return null; - } + public String getFaultList(List stations) { Map paramMap = new HashMap<>(); - paramMap.put("stationIds", list.toArray(new String[0])); + if(CollectionUtil.isEmpty(stations)){ + List list = this.baseMapper.selectStationIds(); + if (CollectionUtil.isEmpty(list)) { + return null; + } + paramMap.put("stationIds", list.toArray(new String[0])); + }else{ + paramMap.put("stationIds", stations); + } String result = HttpRequestUtil.postCall(paramMap, autoFaultPath, "POST"); if (StringUtil.isBlank(result)) { - return null; + return null; } return JSONObject.parseObject(result).get("data").toString(); } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/feign/InspectTaskClient.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/feign/InspectTaskClient.java index 5c50adf..0fc8788 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/feign/InspectTaskClient.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/feign/InspectTaskClient.java @@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.List; @@ -58,6 +59,7 @@ public class InspectTaskClient implements IInspectTaskClient { return taskService.queryByPlanStartTime(startDate,endDate,depts); } + /** * 获取安全检查巡检任务 * @param startDate 开始时间 @@ -74,4 +76,21 @@ public class InspectTaskClient implements IInspectTaskClient { @RequestParam("inspectType") String inspectType) { return taskService.getInspectTaskCheck(startDate,endDate,dept,inspectType); } + + /** + * 到期巡检任务 + * @param start + * @param end + * @param deptId + * @return + */ + @Override + public List expireInspect(String start, String end, Long deptId) { + return taskService.list(Wrappers.lambdaQuery() + .ge(TaskEntity::getPlanEndTime,start) + .le(TaskEntity::getPlanEndTime,end) + .ne(TaskEntity::getStatus,TaskContants.TaskStatusEnum.FINISH_STATUS) + .like(TaskEntity::getCreateDept,deptId) + ); + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/AreaDutyController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/AreaDutyController.java index bb8f270..8add3fa 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/AreaDutyController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/AreaDutyController.java @@ -12,10 +12,7 @@ import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; import org.springblade.core.log.annotation.ApiLog; import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.Calendar; import java.util.List; @@ -35,7 +32,7 @@ public class AreaDutyController { @ApiLog @ApiOperation("值班数据") - @PostMapping("/duty") + @GetMapping("/duty") @ApiOperationSupport(order = 1) public R duty(@ApiParam(value = "机构Id", required = true) @RequestParam Long deptId) { return R.data(service.duty(deptId)); @@ -43,25 +40,25 @@ public class AreaDutyController { @ApiLog @ApiOperation("资产信息") - @PostMapping("/asset") - @ApiOperationSupport(order = 1) + @GetMapping("/asset") + @ApiOperationSupport(order = 2) public R> asset(@ApiParam(value = "机构Id", required = true) @RequestParam Long deptId) { return R.data(service.asset(deptId)); } @ApiLog @ApiOperation("及时提醒消息") - @PostMapping("/timely") - @ApiOperationSupport(order = 1) + @GetMapping("/timely") + @ApiOperationSupport(order = 3) public R> timely(@ApiParam(value = "机构Id", required = true) @RequestParam Long deptId, - @ApiParam(value = "机构Id", required = true) @RequestParam Integer type) { + @ApiParam(value = "类型", required = true) @RequestParam Integer type) { return R.data(service.timely(deptId,type)); } @ApiLog @ApiOperation("排班数据") - @PostMapping("/scheduling") - @ApiOperationSupport(order = 1) + @GetMapping("/scheduling") + @ApiOperationSupport(order = 4) public R scheduling(@ApiParam(value = "机构Id", required = true) @RequestParam Long deptId) { Calendar calendar = Calendar.getInstance(); return dutyMainService.getSchedulingListV2(calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH) + 1, deptId); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/AreaDutyServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/AreaDutyServiceImpl.java index 42e5a1e..f67fa82 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/AreaDutyServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/AreaDutyServiceImpl.java @@ -1,34 +1,47 @@ package com.hnac.hzims.operational.census.service.impl; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; +import com.hnac.hzims.fdp.feign.IFdpMonitorClient; +import com.hnac.hzims.operational.access.dto.AccessTaskV4DTO; +import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; +import com.hnac.hzims.operational.access.service.IOperAccessTaskService; import com.hnac.hzims.operational.census.service.AreaDutyService; import com.hnac.hzims.operational.census.vo.AreaAssetDeviceVo; import com.hnac.hzims.operational.census.vo.AreaAssetVo; import com.hnac.hzims.operational.census.vo.AreaTimelyVo; +import com.hnac.hzims.operational.config.vo.FaultVo; +import com.hnac.hzims.operational.main.service.IMainTaskStatisticService; import com.hnac.hzims.operational.main.vo.AreaDutyVo; import com.hnac.hzims.operational.main.vo.HydropowerUnitRealVo; +import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; +import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; +import com.hnac.hzims.operational.maintenance.service.MaintenanceService; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.service.IStationService; +import com.hnac.hzims.spare.feign.ISpareClient; +import com.hnac.hzinfo.inspect.task.entity.TaskEntity; +import com.hnac.hzinfo.inspect.task.feign.IInspectTaskClient; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -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.core.tool.utils.StringUtil; import org.springblade.system.entity.Dept; import org.springblade.system.feign.ISysClient; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; -import java.lang.reflect.Array; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; +import java.time.Duration; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.*; import java.util.stream.Collectors; /** @@ -51,10 +64,19 @@ public class AreaDutyServiceImpl implements AreaDutyService { private final IStationService stationService; + private final IOperMaintenanceTaskService maintenanceService; + + private final IOperAccessTaskService accessTaskService; + private final ISysClient sysClient; - private final RedisTemplate redisTemplate; + private final ISpareClient spareClient; + + private final IFdpMonitorClient monitorClient; + private final IInspectTaskClient inspectTaskClient; + + private final RedisTemplate redisTemplate; /** * 区域值班数据 @@ -63,7 +85,7 @@ public class AreaDutyServiceImpl implements AreaDutyService { */ @Override public AreaDutyVo duty(Long deptId) { - List dutys = (List) redisTemplate.opsForValue().get(area_duty_cache_final);; + List dutys = (List) redisTemplate.opsForValue().get(area_duty_cache_final); if(CollectionUtil.isEmpty(dutys)){ return new AreaDutyVo(); } @@ -77,24 +99,178 @@ public class AreaDutyServiceImpl implements AreaDutyService { */ @Override public List timely(Long deptId,Integer type) { + Calendar calendar = Calendar.getInstance(); + String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); + calendar.add(Calendar.DAY_OF_MONTH,1); + String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); switch (type){ case 1: - break; + return this.early(deptId); case 2: - break; + return this.inspection(start,end,deptId); case 3: - break; + return this.overhaul(start,end,deptId); case 4: - break; + return this.maintenance(start,end,deptId); case 5: - break; + return this.regular(deptId); default: return new ArrayList<>(); } - return new ArrayList<>(); + } + + + /** + * 预警 + * @return + */ + private List early(Long deptId) { + // 查询子机构 + R> result = sysClient.getDeptChild(deptId); + if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + return new ArrayList<>(); + } + // 站点 + List stations = stationService.list(Wrappers.lambdaQuery() + .in(StationEntity::getRefDept,result.getData().stream().map(Dept::getId).collect(Collectors.toList())) + ); + if(CollectionUtil.isEmpty(stations)){ + return new ArrayList<>(); + } + // 预警信息查询 + String response = monitorClient.getFaultList(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); + if (StringUtil.isBlank(response)) { + return new ArrayList<>(); + } + List earlys = JSONArray.parseArray(response,FaultVo.class); + if(CollectionUtil.isEmpty(earlys)){ + return new ArrayList<>(); + } + // 遍历 + return earlys.stream().map(early->{ + AreaTimelyVo timely = new AreaTimelyVo(); + timely.setEventId(early.getFaultId()); + timely.setContent(early.getFinfo()); + timely.setDeptName(early.getStation()); + timely.setTime(early.getCreateTime()); + int sum = this.eventToHours(LocalDateTime.parse(early.getCreateTime(),DateUtil.DATETIME_FORMATTER)); + timely.setSum(sum); + timely.setColour(0); + if(sum > 12){ + timely.setColour(1); + } + return timely; + }).collect(Collectors.toList()); + } + + /** + * 巡检 + * @param deptId + * @return + */ + private List inspection(String start,String end,Long deptId) { + List expires = inspectTaskClient.expireInspect(start,end,deptId); + if(CollectionUtil.isEmpty(expires)){ + return new ArrayList<>(); + } + return expires.stream().map(expire->{ + AreaTimelyVo timely = new AreaTimelyVo(); + timely.setEventId(String.valueOf(expire.getId())); + timely.setContent(expire.getPlanName()); + R result = sysClient.getDept(expire.getCreateDept()); + if(result.isSuccess() && ObjectUtil.isNotEmpty(result.getData())){ + timely.setDeptName(result.getData().getDeptName()); + } + timely.setTime(expire.getPlanEndTime().format(DateUtil.DATETIME_FORMATTER)); + int sum = this.eventToHours(expire.getPlanEndTime()); + timely.setSum(sum); + timely.setColour(0); + if(sum < 12){ + timely.setColour(1); + } + return timely; + }).collect(Collectors.toList()); + } + + /** + * 检修 + * @param deptId + * @return + */ + private List overhaul(String start,String end,Long deptId) { + List overhauls = accessTaskService.list(Wrappers.lambdaQuery() + .ge(OperAccessTaskEntity::getPlanEndTime,start) + .le(OperAccessTaskEntity::getPlanEndTime,end) + .ne(OperAccessTaskEntity::getStatus,4) + .like(OperAccessTaskEntity::getCreateDept,deptId) + ); + if(CollectionUtil.isEmpty(overhauls)){ + return new ArrayList<>(); + } + return overhauls.stream().map(overhaul->{ + AreaTimelyVo timely = new AreaTimelyVo(); + timely.setEventId(String.valueOf(overhaul.getId())); + timely.setContent(overhaul.getName()); + R result = sysClient.getDept(overhaul.getCreateDept()); + if(result.isSuccess() && ObjectUtil.isNotEmpty(result.getData())){ + timely.setDeptName(result.getData().getDeptName()); + } + timely.setTime(DateUtil.format(overhaul.getPlanEndTime(),DateUtil.PATTERN_DATETIME)); + int sum = this.eventToHours(LocalDateTime.ofInstant(overhaul.getPlanEndTime().toInstant(), ZoneId.systemDefault())); + timely.setSum(sum); + timely.setColour(0); + if(sum < 12){ + timely.setColour(1); + } + return timely; + }).collect(Collectors.toList()); + } + + /** + * 日常维护 + * @param deptId + * @return + */ + private List maintenance(String start,String end,Long deptId) { + List maintenances = maintenanceService.list(Wrappers.lambdaQuery() + .ge(OperMaintenanceTaskEntity::getPlanEndTime,start) + .le(OperMaintenanceTaskEntity::getPlanEndTime,end) + .ne(OperMaintenanceTaskEntity::getFlowTaskName,"结束") + .like(OperMaintenanceTaskEntity::getCreateDept,deptId) + ); + if(CollectionUtil.isEmpty(maintenances)){ + return new ArrayList<>(); + } + return maintenances.stream().map(maintenance -> { + AreaTimelyVo timely = new AreaTimelyVo(); + timely.setEventId(String.valueOf(maintenance.getId())); + timely.setContent(maintenance.getTitle()); + R result = sysClient.getDept(maintenance.getCreateDept()); + if(result.isSuccess() && ObjectUtil.isNotEmpty(result.getData())){ + timely.setDeptName(result.getData().getDeptName()); + } + timely.setTime(DateUtil.format(maintenance.getPlanEndTime(),DateUtil.PATTERN_DATETIME)); + int sum = this.eventToHours(maintenance.getPlanEndTime()); + timely.setSum(sum); + timely.setColour(0); + if(sum < 12){ + timely.setColour(1); + } + return timely; + }).collect(Collectors.toList()); } /** + * 固定资产 + * @param deptId + * @return + */ + private List regular(Long deptId) { + return spareClient.exceedLimit(deptId); + } + + + /** * 资产信息 * @param deptId * @return @@ -143,6 +319,14 @@ public class AreaDutyServiceImpl implements AreaDutyService { } } - - + /** + * 事件产生时长 + * @param startTime + * @return + */ + private int eventToHours(LocalDateTime startTime) { + // 计算投运时间与当前时间相隔天数 + Duration dur = Duration.between(startTime, LocalDateTime.now()); + return Math.abs((int) dur.toHours()); + } } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/StAlamRecordServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/StAlamRecordServiceImpl.java index c636df2..9cb52a5 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/StAlamRecordServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/StAlamRecordServiceImpl.java @@ -731,7 +731,7 @@ public class StAlamRecordServiceImpl extends BaseServiceImpl()); if(StringUtil.isEmpty(result)){ return null; }