From 4f41e6e3f595ebc0e0f0c154ab519f9e392610db Mon Sep 17 00:00:00 2001 From: tanghaihao <850814414@qq.com> Date: Tue, 18 Jul 2023 16:38:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=AE=9A=E4=B9=89=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4=20=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E4=BF=A1=E6=81=AF=E6=A8=A1=E5=9D=97=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=20=E8=AE=BE=E5=A4=87=E7=94=9F=E5=91=BD?= =?UTF-8?q?=E5=91=A8=E6=9C=9F=E6=A8=A1=E5=9D=97=E4=BB=A3=E7=A0=81=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hnac/hzims/EquipmentConstants.java | 19 ++ .../hzims/equipment/entity/EmDefinitionEntity.java | 43 +++ .../hnac/hzims/equipment/entity/EmInfoEntity.java | 14 +- .../hnac/hzims/equipment/entity/EmParamEntity.java | 7 +- .../hzims/equipment/entity/EmTreeBasicEntity.java | 26 ++ .../hnac/hzims/equipment/entity/EmTreeEntity.java | 63 +++++ .../equipment/entity/EmTreeInspectEntity.java | 42 +++ .../hzims/equipment/entity/EmTreeParamEntity.java | 38 +++ .../hnac/hzims/equipment/feign/IEmInfoClient.java | 4 + .../hzims/equipment/feign/IEmInfoClientBack.java | 5 + hzims-service/assets/pom.xml | 4 + .../hnac/hzims/spare/mapper/WtSpBasicMapper.java | 1 - .../hnac/hzims/spare/mapper/WtSpBasicMapper.xml | 1 + .../spare/service/impl/WtSpBasicServiceImpl.java | 4 + hzims-service/equipment/pom.xml | 6 +- .../controller/EmDefinitionController.java | 150 +++++++++++ .../equipment/controller/EmInfoController.java | 143 ++++++++-- .../equipment/controller/EmTreeController.java | 219 ++++++++++++++++ .../equipment/controller/LifeCycleController.java | 21 ++ .../hnac/hzims/equipment/dto/DeviceTreeDTO.java | 26 ++ .../hnac/hzims/equipment/dto/EmDefinitionDTO.java | 37 +++ .../com/hnac/hzims/equipment/dto/EmTreeDTO.java | 66 +++++ .../com/hnac/hzims/equipment/dto/EmTreeIdsDTO.java | 21 ++ .../hnac/hzims/equipment/feign/EmInfoClient.java | 10 + .../hzims/equipment/mapper/EmDefinitionMapper.java | 7 + .../hzims/equipment/mapper/EmDefinitionMapper.xml | 5 + .../hnac/hzims/equipment/mapper/EmInfoMapper.java | 5 + .../hnac/hzims/equipment/mapper/EmInfoMapper.xml | 28 ++ .../hzims/equipment/mapper/EmTreeBasicMapper.java | 11 + .../hzims/equipment/mapper/EmTreeBasicMapper.xml | 5 + .../equipment/mapper/EmTreeInspectMapper.java | 8 + .../hzims/equipment/mapper/EmTreeInspectMapper.xml | 5 + .../hnac/hzims/equipment/mapper/EmTreeMapper.java | 7 + .../hnac/hzims/equipment/mapper/EmTreeMapper.xml | 5 + .../hzims/equipment/mapper/EmTreeParamMapper.java | 8 + .../hzims/equipment/mapper/EmTreeParamMapper.xml | 5 + .../equipment/service/IEmDefinitionService.java | 7 + .../hzims/equipment/service/IEmInfoService.java | 17 ++ .../equipment/service/IEmTreeBasicService.java | 7 + .../equipment/service/IEmTreeInspectService.java | 7 + .../equipment/service/IEmTreeParamService.java | 7 + .../hzims/equipment/service/IEmTreeService.java | 19 ++ .../impl/EmAssociationDetailServiceImpl.java | 19 +- .../service/impl/EmDefinitionServiceImpl.java | 17 ++ .../equipment/service/impl/EmInfoServiceImpl.java | 290 ++++++++++++++++++++- .../service/impl/EmTreeBasicServiceImpl.java | 22 ++ .../service/impl/EmTreeInspectServiceImpl.java | 17 ++ .../service/impl/EmTreeParamServiceImpl.java | 17 ++ .../equipment/service/impl/EmTreeServiceImpl.java | 235 +++++++++++++++++ .../hnac/hzims/equipment/vo/EmInfoContentVO.java | 49 ++++ .../java/com/hnac/hzims/equipment/vo/EmTreeVO.java | 25 ++ .../com/hnac/hzims/equipment/vo/SparePartVO.java | 32 +++ .../hnac/hzims/fdp/controller/ModelController.java | 6 + .../hnac/hzims/monitor/server/IModelService.java | 1 + .../monitor/server/impl/ModelServiceImpl.java | 9 + .../java/com/hnac/hzims/util/MemoryPagination.java | 39 +++ .../controller/OperAccessTaskController.java | 15 +- .../access/mapper/OperAccessTaskMapper.java | 3 + .../access/mapper/OperAccessTaskMapper.xml | 26 +- .../access/service/IOperAccessTaskService.java | 2 + .../service/impl/OperAccessTaskServiceImpl.java | 11 + .../hzims/operational/access/vo/RepairBillVO.java | 33 +++ .../controller/OperDefectStatisticsController.java | 6 +- .../defect/mapper/OperDefectStatisticsMapper.java | 19 +- .../defect/mapper/OperDefectStatisticsMapper.xml | 9 +- .../service/IOperDefectStatisticsService.java | 2 +- .../impl/OperDefectStatisticsServiceImpl.java | 6 +- .../controller/WorkTicketInfoController.java | 11 + .../workTicket/mapper/WorkTicketInfoMapper.java | 3 + .../workTicket/mapper/xml/WorkTicketInfoMapper.xml | 21 ++ .../workTicket/service/IWorkTicketInfoService.java | 4 + .../service/impl/WorkTicketInfoServiceImpl.java | 14 + .../ticket/workTicket/vo/WorkTicketBillVO.java | 30 +++ 73 files changed, 2064 insertions(+), 62 deletions(-) create mode 100644 hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmDefinitionEntity.java create mode 100644 hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmTreeBasicEntity.java create mode 100644 hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmTreeEntity.java create mode 100644 hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmTreeInspectEntity.java create mode 100644 hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmTreeParamEntity.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmDefinitionController.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmTreeController.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/LifeCycleController.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/dto/DeviceTreeDTO.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/dto/EmDefinitionDTO.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/dto/EmTreeDTO.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/dto/EmTreeIdsDTO.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmDefinitionMapper.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmDefinitionMapper.xml create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeBasicMapper.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeBasicMapper.xml create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeInspectMapper.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeInspectMapper.xml create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeMapper.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeMapper.xml create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeParamMapper.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeParamMapper.xml create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmDefinitionService.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmTreeBasicService.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmTreeInspectService.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmTreeParamService.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmTreeService.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmDefinitionServiceImpl.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmTreeBasicServiceImpl.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmTreeInspectServiceImpl.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmTreeParamServiceImpl.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmTreeServiceImpl.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/EmInfoContentVO.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/EmTreeVO.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/SparePartVO.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/util/MemoryPagination.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/vo/RepairBillVO.java create mode 100644 hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/vo/WorkTicketBillVO.java diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/EquipmentConstants.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/EquipmentConstants.java index cc01220..03f3ac7 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/EquipmentConstants.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/EquipmentConstants.java @@ -1,5 +1,6 @@ package com.hnac.hzims; +import io.swagger.models.auth.In; import lombok.Getter; public class EquipmentConstants { @@ -145,6 +146,24 @@ public class EquipmentConstants { } } + /** + * 运行状态 + */ + public enum ActivateStatusEnum { + stop(0,"停用"), + start(1,"启用") + ; + @Getter + private Integer status; + @Getter + private String des; + + private ActivateStatusEnum(Integer status, String des) { + this.status = status; + this.des = des; + } + } + /** * 装机容量 diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmDefinitionEntity.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmDefinitionEntity.java new file mode 100644 index 0000000..d37dcab --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmDefinitionEntity.java @@ -0,0 +1,43 @@ +package com.hnac.hzims.equipment.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.tenant.mp.TenantEntity; + +/** + * 设备定义实体类 + * @author tanghaihao + * @date 2023年06月14日 16:45 + */ +@Data +@TableName("hzims_em_definition") +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "设备定义实体类", description = "") +public class EmDefinitionEntity extends TenantEntity { + + @ApiModelProperty(value = "站点类型") + private String stationType; + + @ApiModelProperty(value = "类型") + private String type; + + @ApiModelProperty(value = "设备定义名称") + private String name; + + @ApiModelProperty(value = "模型标识") + private String modelSignage; + + @ApiModelProperty(value = "模型名称") + private String modelName; + + @ApiModelProperty(value = "创建用户") + private Long createUser; + + @ApiModelProperty(value = "创建用户名称") + @TableField(exist = false) + private String createUserName; +} diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmInfoEntity.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmInfoEntity.java index b78e45f..3581439 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmInfoEntity.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmInfoEntity.java @@ -18,6 +18,7 @@ import org.springframework.format.annotation.DateTimeFormat; import javax.validation.constraints.NotNull; import java.math.BigDecimal; import java.util.Date; +import java.util.List; /** @@ -40,6 +41,11 @@ public class EmInfoEntity extends TenantEntity { @JsonSerialize(nullsUsing = NullSerializer.class) private Long gpid; /** + * 设备树ID + */ + @ApiModelProperty(value = "设备树ID") + private Long treeId; + /** * 所属组织 */ @ApiModelProperty(value = "所属组织") @@ -73,6 +79,10 @@ public class EmInfoEntity extends TenantEntity { @ApiModelProperty(value = "设备编号") @NotNull private String number; + + @ApiModelProperty(value = "设备编号路径") + private String path; + /** * 设备名称 */ @@ -216,7 +226,6 @@ public class EmInfoEntity extends TenantEntity { @ApiModelProperty("机组类型") private String setType; - @TableField(exist = false) @ApiModelProperty("站点编码") private String stationCode; @@ -228,4 +237,7 @@ public class EmInfoEntity extends TenantEntity { @ApiModelProperty("站点类型") private Integer stationType; + @ApiModelProperty(value = "子设备") + @TableField(exist = false) + private List infoChildren; } diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmParamEntity.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmParamEntity.java index f8df9d5..7fa0392 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmParamEntity.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmParamEntity.java @@ -30,10 +30,15 @@ public class EmParamEntity extends TenantEntity { @JsonSerialize(nullsUsing = NullSerializer.class) private Long infoId; /** + * 参数标识 + */ + @ApiModelProperty(value = "参数标识") + private String paramName; + /** * 参数名称 */ @ApiModelProperty(value = "参数名称") - private String paramName; + private String name; /** * 排序 */ diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmTreeBasicEntity.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmTreeBasicEntity.java new file mode 100644 index 0000000..c6a73d4 --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmTreeBasicEntity.java @@ -0,0 +1,26 @@ +package com.hnac.hzims.equipment.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.tenant.mp.TenantEntity; + +/** + * 设备树和物资台账关联表实体类 + * @author tanghaihao + * @date 2023年07月14日 15:54 + */ +@Data +@TableName("hzims_em_tree_basic") +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "设备树和物资台账关联表实体类") +public class EmTreeBasicEntity extends TenantEntity { + + @ApiModelProperty(value = "设备树id") + private Long treeId; + + @ApiModelProperty(value = "物资台账id") + private Long basicId; +} diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmTreeEntity.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmTreeEntity.java new file mode 100644 index 0000000..87027f2 --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmTreeEntity.java @@ -0,0 +1,63 @@ +package com.hnac.hzims.equipment.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.tenant.mp.TenantEntity; + +import java.util.List; + +/** + * 设备树实体类 + * @author tanghaihao + * @date 2023年06月14日 16:46 + */ +@Data +@TableName("hzims_em_tree") +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "设备树实体类") +public class EmTreeEntity extends TenantEntity { + + @ApiModelProperty(value = "设备定义Id") + private Long definitionId; + + @ApiModelProperty(value = "父Id") + private Long pid; + + @ApiModelProperty(value = "设备树标识路径") + private String path; + + @ApiModelProperty(value = "设备类别") + private String gradeCode; + + @ApiModelProperty("设备类型") + private String emType; + + @ApiModelProperty("机组类型") + private String setType; + + @ApiModelProperty(value = "设备名称") + private String name; + + @ApiModelProperty(value = "设备标识") + private String signage; + + @ApiModelProperty(value = "排序") + private Integer sort; + + @ApiModelProperty(value = "所属组织") + private Long refOreanization; + + @ApiModelProperty(value = "设备等级") + private Integer emGrade; + + @ApiModelProperty(value = "巡检标准") + private String inspectStandard; + + @ApiModelProperty(value = "子设备") + @TableField(exist = false) + private List children; +} diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmTreeInspectEntity.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmTreeInspectEntity.java new file mode 100644 index 0000000..4f784d3 --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmTreeInspectEntity.java @@ -0,0 +1,42 @@ +package com.hnac.hzims.equipment.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.tenant.mp.TenantEntity; + +/** + * 设备树绑定巡检实体类 + * @author tanghaihao + * @date 2023年06月14日 16:46 + */ +@Data +@TableName("hzims_em_tree_inspect") +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "设备树绑定巡检实体类", description = "") +public class EmTreeInspectEntity extends TenantEntity { + + @ApiModelProperty(value = "设备树ID") + private Long treeId; + + @ApiModelProperty(value = "巡检内容id") + private Long contentId; + + @ApiModelProperty(value = "巡检内容名称") + private String contentName; + + @ApiModelProperty(value = "模型标识") + private String modelSignage; + + @ApiModelProperty(value = "模型名称") + private String modelName; + + @ApiModelProperty(value = "模型属性标识") + private String modelAttrSignage; + + @ApiModelProperty(value = "模型属性名称") + private String modelAttrName; + +} diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmTreeParamEntity.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmTreeParamEntity.java new file mode 100644 index 0000000..59c0781 --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmTreeParamEntity.java @@ -0,0 +1,38 @@ +package com.hnac.hzims.equipment.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.tenant.mp.TenantEntity; + +/** + * 设备树绑定参数实体类 + * @author tanghaihao + * @date 2023年06月14日 16:48 + */ +@Data +@TableName("hzims_em_tree_param") +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "设备树绑定参数实体类", description = "") +public class EmTreeParamEntity extends TenantEntity { + + @ApiModelProperty(value = "设备树ID") + private Long treeId; + + @ApiModelProperty(value = "参数标识") + private String paramName; + + @ApiModelProperty(value = "参数名称") + private String name; + + @ApiModelProperty(value = "排序") + private Integer sort; + + @ApiModelProperty(value = "单位") + private String unit; + + @ApiModelProperty(value = "描述") + private String description; +} diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java index 4c8b8f7..7d22c2e 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java @@ -76,6 +76,7 @@ public interface IEmInfoClient { String GET_EM_INFO_BY_DEPT = API_PREFIX + "/getEmInfoByDept"; String GET_EM_INFO_BY_NAME = API_PREFIX + "/getEmInfoByName"; String GET_EM_INFO_BY_EM_CODE = API_PREFIX + "/getEmInfoByEmCode"; + String GET_EM_INFO_TREE_BY_EM_CODE = API_PREFIX + "/getEmInfoTreeByEmCode"; String UPDATE_BY_EM_CODE = API_PREFIX + "/updateByEmCode"; String UPDATE_BATCH_EM_STATE = API_PREFIX + "/updateBachEmState"; @@ -114,6 +115,9 @@ public interface IEmInfoClient { @GetMapping(GET_EM_INFO_BY_EM_CODES) R> getEmInfoByEmCodes(@RequestParam("emCodes") List emCodes); + @GetMapping(GET_EM_INFO_TREE_BY_EM_CODE) + R> getEmInfoTreeByEmCode(@RequestParam("emCode") String emCode); + @PostMapping(GET_EM_INFO_UNIT_COUNT_BY_DEPT) R getEmInfoUnitCountByDept(@RequestParam("list") List list); diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java index cdd6e9d..f79cbfd 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java @@ -55,6 +55,11 @@ public class IEmInfoClientBack implements IEmInfoClient { } @Override + public R> getEmInfoTreeByEmCode(String emCode) { + return R.data(new ArrayList<>()); + } + + @Override public R getEmInfoUnitCountByDept(List depts) { return R.data(null); } diff --git a/hzims-service/assets/pom.xml b/hzims-service/assets/pom.xml index 3304ecc..ca4b3b0 100644 --- a/hzims-service/assets/pom.xml +++ b/hzims-service/assets/pom.xml @@ -64,6 +64,10 @@ message-api compile + + com.hnac.hzims + equipment-api + diff --git a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/WtSpBasicMapper.java b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/WtSpBasicMapper.java index efb8569..74bf8bb 100644 --- a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/WtSpBasicMapper.java +++ b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/WtSpBasicMapper.java @@ -1,6 +1,5 @@ package com.hnac.hzims.spare.mapper; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.hnac.hzims.spare.entity.SpTemporaryStockDetailEntity; import com.hnac.hzims.spare.entity.WtSpBasicEntity; import com.hnac.hzims.spare.vo.WtSpBasicVO; diff --git a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/WtSpBasicMapper.xml b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/WtSpBasicMapper.xml index 7691918..d832b9d 100644 --- a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/WtSpBasicMapper.xml +++ b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/WtSpBasicMapper.xml @@ -93,4 +93,5 @@ AND b.SP_BASIC_ID = #{spBasicId} AND b.type = 5 + diff --git a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java index 0dd5b53..348723e 100644 --- a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java +++ b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java @@ -15,6 +15,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.hnac.hzims.equipment.entity.EmInfoEntity; +import com.hnac.hzims.equipment.feign.IEmInfoClient; import com.hnac.hzims.spare.entity.*; import com.hnac.hzims.spare.enume.WarehouseInType; import com.hnac.hzims.spare.enume.WarehouseOutType; @@ -97,6 +99,8 @@ public class WtSpBasicServiceImpl extends BaseServiceImplslf4j-log4j12 - + --> com.hnac.hzinfo.data @@ -93,6 +93,10 @@ org.apache.commons commons-collections4 + + com.hnac.hzinfo + inspect-api + diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmDefinitionController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmDefinitionController.java new file mode 100644 index 0000000..b746354 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmDefinitionController.java @@ -0,0 +1,150 @@ +package com.hnac.hzims.equipment.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.equipment.dto.EmDefinitionDTO; +import com.hnac.hzims.equipment.entity.EmDefinitionEntity; +import com.hnac.hzims.equipment.entity.EmTreeEntity; +import com.hnac.hzims.equipment.service.IEmDefinitionService; +import com.hnac.hzims.equipment.service.IEmTreeService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springblade.system.user.cache.UserCache; +import org.springblade.system.user.entity.User; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.List; + +/** + * 设备定义控制层 + * @author tanghaihao + * @date 2023年06月15日 9:52 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/em/definition") +@Api(value = "设备定义控制层", tags = "设备定义管理") +public class EmDefinitionController extends BladeController { + + private final IEmDefinitionService emDefinitionService; + + private final IEmTreeService emTreeService; + + + /** + * 设备定义列表分页 + * @param emDefinition + * @param query + * @return + */ + @GetMapping("/page") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "分页") + @ApiImplicitParams({ + }) + public R> getEmDefinitionPage(EmDefinitionEntity emDefinition, Query query) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + if (Func.isNotEmpty(emDefinition.getStationType())) { + wrapper.eq(EmDefinitionEntity::getStationType, emDefinition.getStationType()); + } + if (Func.isNotEmpty(emDefinition.getType())) { + wrapper.eq(EmDefinitionEntity::getType, emDefinition.getType()); + } + if (Func.isNotEmpty(emDefinition.getName())) { + wrapper.like(EmDefinitionEntity::getName, emDefinition.getName()); + } + if (Func.isNotEmpty(emDefinition.getStatus())) { + wrapper.eq(EmDefinitionEntity::getStatus, emDefinition.getStatus()); + } + IPage pages = emDefinitionService.page(Condition.getPage(query), wrapper); + for (EmDefinitionEntity definition : pages.getRecords()) { + User createUser = UserCache.getUser(definition.getCreateUser()); + definition.setCreateUserName(createUser.getName()); + } + + return R.data(pages); + } + + /** + * 新增 + */ + @PostMapping("/save") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "新增", notes = "传入EmDefinitionDTO") + public R save(@Valid @RequestBody EmDefinitionDTO emDefinitionDTO) { + EmDefinitionEntity emDefinition = new EmDefinitionEntity(); + Func.copy(emDefinitionDTO, emDefinition); + return R.data(emDefinitionService.save(emDefinition)); + } + + /** + * 编辑 + */ + @PostMapping("/update") + @ApiOperationSupport(order = 3) + @ApiOperation(value = "编辑", notes = "传入EmDefinitionDTO") + public R update(@Valid @RequestBody EmDefinitionDTO emDefinitionDTO) { + EmDefinitionEntity emDefinition = new EmDefinitionEntity(); + Func.copy(emDefinitionDTO, emDefinition); + return R.data(emDefinitionService.updateById(emDefinition)); + } + + /** + * 删除 + */ + @GetMapping("/remove") + @ApiOperationSupport(order = 4) + @ApiOperation(value = "逻辑删除", notes = "传入id") + public R remove(Long id) { + EmDefinitionEntity emDefinition = emDefinitionService.getById(id); + if (emDefinition.getStatus().equals(1)) { + return R.fail("已启用的设备定义不能删除"); + } + LambdaQueryWrapper treeWrapper = new LambdaQueryWrapper(); + treeWrapper.eq(EmTreeEntity::getDefinitionId, id); + List list = emTreeService.list(treeWrapper); + if (Func.isNotEmpty(list)) { + return R.fail("设备定义中存在设备树,不能删除"); + } + return R.status(emDefinitionService.removeById(id)); + } + + /** + * 启用/停用 + */ + @GetMapping("/startOrStop") + @ApiOperationSupport(order = 5) + @ApiOperation(value = "启用/停用", notes = "传入id") + public R startOrStop(Long id, Integer status) { + EmDefinitionEntity emDefinition = emDefinitionService.getById(id); + emDefinition.setStatus(status); + return R.status(emDefinitionService.updateById(emDefinition)); + } + + /** + * 获取设备定义(下拉列表) + */ + @GetMapping("/getEmDefinitionList") + @ApiOperationSupport(order = 6) + @ApiOperation(value = "获取设备定义(下拉列表)", notes = "传入定义名称和站点类型") + public R getEmDefinitionList(EmDefinitionEntity emDefinition) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + if (Func.isNotEmpty(emDefinition.getName())) { + wrapper.like(EmDefinitionEntity::getName, emDefinition.getName()); + } + if (Func.isNotEmpty(emDefinition.getStationType())) { + wrapper.eq(EmDefinitionEntity::getStationType, emDefinition.getStationType()); + } + wrapper.eq(EmDefinitionEntity::getStatus, 1); + return R.data(emDefinitionService.list(wrapper)); + } +} 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 d0b7c17..aedbbf7 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 @@ -1,18 +1,23 @@ package com.hnac.hzims.equipment.controller; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.common.logs.annotation.OperationAnnotation; import com.hnac.hzims.common.logs.enums.BusinessType; import com.hnac.hzims.common.logs.enums.OperatorType; +import com.hnac.hzims.equipment.dto.DeviceTreeDTO; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.service.IEmInfoService; import com.hnac.hzims.equipment.vo.EmInfoAddVo; +import com.hnac.hzims.equipment.vo.EmInfoContentVO; import com.hnac.hzims.equipment.vo.EmInfoVO; +import com.hnac.hzims.equipment.vo.SparePartVO; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; +import com.hnac.hzims.util.MemoryPagination; +import com.hnac.hzinfo.inspect.obj.dto.ContentDTO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; @@ -20,23 +25,16 @@ import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.log.annotation.ApiLog; -import org.springblade.core.log.exception.ServiceException; 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.CollectionUtil; import org.springblade.core.tool.utils.Func; -import org.springblade.core.tool.utils.ObjectUtil; -import org.springframework.util.Assert; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; import javax.validation.Valid; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.util.*; /** * 设备控制器 @@ -112,6 +110,72 @@ public class EmInfoController extends BladeController { } /** + * 查看子设备列表 分页(树结构) + */ + @ApiLog + @RequestMapping(value = "/treeList") + @ApiOperationSupport(order = 3) + @ApiOperation(value = "查看子设备列表 分页(树结构)", notes = "传入设备id") + public R> treeList(Long id, String name, Query query) { + Map result = new HashMap<>(); + EmInfoEntity parentEmInfo = em_infoService.getById(id); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.likeRight(EmInfoEntity::getPath, parentEmInfo.getPath()); + queryWrapper.ne(EmInfoEntity::getId, id); + if (Func.isNotEmpty(name)) { + queryWrapper.like(EmInfoEntity::getName, name); + } + List list = em_infoService.list(queryWrapper); + // 获取站点列表 - 填充站点编码、站点类型、站点名称 + R> stationListR = stationClient.list(new StationEntity()); + + List resultList = new ArrayList<>(); + // 把List结构数据转换成树结构 + if (Func.isNotEmpty(name)) { + for (EmInfoEntity emInfo : list) { + LambdaQueryWrapper sonWrapper = new LambdaQueryWrapper<>(); + sonWrapper.likeRight(EmInfoEntity::getPath, emInfo.getPath()); + List sonList = em_infoService.list(sonWrapper); + if(stationListR.isSuccess() && CollectionUtil.isNotEmpty(stationListR.getData())) { + List stationList = stationListR.getData(); + sonList.forEach(emInfoEntity -> { + Optional stationOptional = stationList.stream() + .filter(station -> Func.isNotEmpty(station.getRefDept()) && station.getRefDept().equals(emInfoEntity.getDepartment())).findAny(); + if(stationOptional.isPresent()) { + StationEntity stationEntity = stationOptional.get(); + emInfoEntity.setStationCode(stationEntity.getCode()); + emInfoEntity.setStationType(stationEntity.getType()); + emInfoEntity.setStationName(stationEntity.getName()); + } + }); + } + resultList.addAll(em_infoService.convertToTree(emInfo.getGpid(), sonList)); + } + } else { + if(stationListR.isSuccess() && CollectionUtil.isNotEmpty(stationListR.getData())) { + List stationList = stationListR.getData(); + list.forEach(emInfoEntity -> { + Optional stationOptional = stationList.stream() + .filter(station -> Func.isNotEmpty(station.getRefDept()) && station.getRefDept().equals(emInfoEntity.getDepartment())).findAny(); + if(stationOptional.isPresent()) { + StationEntity stationEntity = stationOptional.get(); + emInfoEntity.setStationCode(stationEntity.getCode()); + emInfoEntity.setStationType(stationEntity.getType()); + emInfoEntity.setStationName(stationEntity.getName()); + } + }); + } + resultList = em_infoService.convertToTree(id, list); + } + + // 内存分页 + resultList = MemoryPagination.pagination(resultList, query.getCurrent(), query.getSize()); + result.put("data", resultList); + result.put("total", resultList.size()); + return R.data(result); + } + + /** * 新增 */ @PostMapping("/save") @@ -125,7 +189,7 @@ public class EmInfoController extends BladeController { * 修改 */ @PostMapping("/update") - @ApiOperationSupport(order = 6) + @ApiOperationSupport(order = 5) @ApiOperation(value = "修改", notes = "传入em_info,isModel;其中isModel=0为非母版,=1时保存为母版,modelName,modelType") public R update(@Valid @RequestBody EmInfoAddVo em_info) { // List name = em_infoService.list(new QueryWrapper() {{ @@ -156,7 +220,7 @@ public class EmInfoController extends BladeController { * 删除 */ @PostMapping("/remove") - @ApiOperationSupport(order = 9) + @ApiOperationSupport(order = 6) @ApiOperation(value = "逻辑删除", notes = "传入ids") public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { return R.status(em_infoService.remove(ids)); @@ -167,7 +231,7 @@ public class EmInfoController extends BladeController { * 查询所有 */ @GetMapping("/list/all") - @ApiOperationSupport(order = 10) + @ApiOperationSupport(order = 7) @ApiOperation(value = "查询所有") public R listAll(EmInfoEntity fdpDeviceEntity) { List list = em_infoService.list(Condition.getQueryWrapper(fdpDeviceEntity)); @@ -178,7 +242,7 @@ public class EmInfoController extends BladeController { * 查询设备树 */ @GetMapping("/list/tree") - @ApiOperationSupport(order = 10) + @ApiOperationSupport(order = 8) @ApiOperation(value = "查询设备树") public R listTree() { return em_infoService.listTree(); @@ -188,7 +252,7 @@ public class EmInfoController extends BladeController { * 根据站点及所属设备Code一起存放Redis */ @GetMapping("/StationCodeStoreRedis") - @ApiOperationSupport(order = 10) + @ApiOperationSupport(order = 9) @ApiOperation(value = "根据站点及所属设备Code一起存放Redis") public R StationCodeStoreRedis() { em_infoService.getStationCodeStoreRedis(); @@ -209,7 +273,7 @@ public class EmInfoController extends BladeController { * 取Redis数据-根据自定义key取出站点及所属Code */ @GetMapping("/redisCode") - @ApiOperationSupport(order = 10) + @ApiOperationSupport(order = 11) @ApiOperation(value = "根据站点及所属设备Code一起存放Redis") public R redisCode() { return R.data(em_infoService.redisCode()); @@ -219,7 +283,7 @@ public class EmInfoController extends BladeController { * 取Redis数据-根据自定义key取出站点及所属Code */ @GetMapping("/emInfoAndParamRedis") - @ApiOperationSupport(order = 10) + @ApiOperationSupport(order = 12) @ApiOperation(value = "存设备数据") public R emInfoAndParamRedis() { em_infoService.loadEmInfo(); @@ -230,14 +294,14 @@ public class EmInfoController extends BladeController { * 取Redis数据-根据自定义key取出站点及所属Code */ @GetMapping("/getEmInfoAndParamRedis") - @ApiOperationSupport(order = 10) + @ApiOperationSupport(order = 13) @ApiOperation(value = "取设备数据") public R getEmInfoAndParamRedis() { return R.data(em_infoService.getEmInfoAndParamRedis()); } @GetMapping(value = "/getEmInfoByCode") - @ApiOperationSupport(order = 11) + @ApiOperationSupport(order = 14) @ApiOperation(value = "获取所有设备数据") public R getEmInfoByCode(@RequestParam(value = "emCode") String emCode){ return em_infoService.getEmInfoByCode(emCode); @@ -247,9 +311,50 @@ public class EmInfoController extends BladeController { * 查询设备名称 */ @GetMapping("/getDevices") - @ApiOperationSupport(order = 4) + @ApiOperationSupport(order = 15) @ApiOperation(value = "获取设备", notes = "传入设备列表集合") public R getDevices(@RequestParam(value ="codes") List codes) { return R.data(em_infoService.listByCodes(codes)); } + + /** + * 导入设备树 + */ + @PostMapping("/importDeviceTree") + @ApiOperationSupport(order = 16) + @ApiOperation(value = "导入设备树", notes = "传入设备树id集合") + public R importDeviceTree(@RequestBody DeviceTreeDTO deviceTreeDTO) { + return R.status(em_infoService.importDeviceTree(deviceTreeDTO)); + } + + /** + * 导入子设备树 + */ + @PostMapping("/importSonDeviceTree") + @ApiOperationSupport(order = 17) + @ApiOperation(value = "导入子设备树", notes = "传入设备树id集合") + public R importSonDeviceTree(@RequestBody DeviceTreeDTO deviceTreeDTO) { + return R.status(em_infoService.importSonDeviceTree(deviceTreeDTO)); + } + + /** + * 获取设备的巡检内容 + */ + @GetMapping("/getEmInfoContent") + @ApiOperationSupport(order = 18) + @ApiOperation(value = "获取设备的巡检内容", notes = "传入设备编码") + public R> getEmInfoContent(String emCode, ContentDTO dto) { + return R.data(em_infoService.getEmInfoContent(emCode, dto)); + } + + /** + * 获取设备的备品备件 + */ + @ApiLog + @GetMapping("/getSparePart") + @ApiOperationSupport(order = 10) + @ApiOperation(value = "获取设备的备品备件") + public R> getSparePart(String emCode, String startTime, String endTime) { + return R.data(em_infoService.getSparePart(emCode, startTime, endTime)); + } } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmTreeController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmTreeController.java new file mode 100644 index 0000000..4d1a843 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmTreeController.java @@ -0,0 +1,219 @@ +package com.hnac.hzims.equipment.controller; + + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.equipment.dto.EmTreeDTO; +import com.hnac.hzims.equipment.entity.*; +import com.hnac.hzims.equipment.service.*; +import com.hnac.hzims.equipment.service.IEmTreeService; +import com.hnac.hzims.util.MemoryPagination; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + + +/** + * 设备树控制层 + * @author tanghaihao + * @date 2023年06月15日 15:23 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/em/tree") +@Api(value = "设备树控制层", tags = "设备树管理,包括巡检内容、设备参数") +public class EmTreeController extends BladeController { + + private final IEmTreeService emTreeService; + + private final IEmTreeInspectService emTreeInspectService; + + private final IEmTreeParamService emTreeParamService; + + private final IEmTreeBasicService emTreeBasicService; + + private final IEmInfoService emInfoService; + + /** + * 设备定义列表分页 + * @param emTree + * @param query + * @return + */ + @GetMapping("/page") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "分页") + @ApiImplicitParams({ + }) + public R> getEmTreePage(EmTreeEntity emTree, Query query) { + Map result = new HashMap<>(); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(EmTreeEntity::getDefinitionId, emTree.getDefinitionId()); + if (Func.isNotEmpty(emTree.getPid())) { + wrapper.eq(EmTreeEntity::getPid, emTree.getPid()); + } + if (Func.isNotEmpty(emTree.getSignage())) { + wrapper.like(EmTreeEntity::getSignage, emTree.getSignage()); + } + if (Func.isNotEmpty(emTree.getName())) { + wrapper.like(EmTreeEntity::getName, emTree.getName()); + } + wrapper.orderByAsc(EmTreeEntity::getSort); + List list = emTreeService.list(wrapper); + + List resultList = new ArrayList<>(); + if (Func.isNotEmpty(emTree.getPid()) || Func.isNotEmpty(emTree.getSignage()) || Func.isNotEmpty(emTree.getName())) { + // 把筛选过的数据子设备也查询出来,再拼成树结构 + for (EmTreeEntity parentEmTree : list) { + LambdaQueryWrapper parentWrapper = new LambdaQueryWrapper<>(); + parentWrapper.likeRight(EmTreeEntity::getPath, parentEmTree.getPath()); + List emTreeList = emTreeService.list(parentWrapper); + Map> emTreeMap = emTreeList.stream().collect(Collectors.groupingBy(EmTreeEntity::getPid)); + emTreeList.forEach(tree -> { + tree.setChildren(emTreeMap.get(tree.getId())); + }); + emTreeList = emTreeList.stream().filter(item -> item.getPid().equals(parentEmTree.getPid())).collect(Collectors.toList()); + resultList.addAll(emTreeList); + } + } else { + // 把List结构数据转换成树结构 + Map> emTreeMap = list.stream().collect(Collectors.groupingBy(EmTreeEntity::getPid)); + list.forEach(tree -> { + tree.setChildren(emTreeMap.get(tree.getId())); + }); + resultList = list.stream().filter(item -> item.getPid().equals(0L)).collect(Collectors.toList()); + } + // 内存分页 + resultList = MemoryPagination.pagination(resultList, query.getCurrent(), query.getSize()); + result.put("data", resultList); + result.put("total", resultList.size()); + return R.data(result); + } + + /** + * 新增 + */ + @PostMapping("/save") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "新增", notes = "传入EmTreeDTO") + public R save(@Valid @RequestBody EmTreeDTO emTreeDTO) { + return R.data(emTreeService.saveEmTrree(emTreeDTO)); + } + + /** + * 编辑 + */ + @PostMapping("/update") + @ApiOperationSupport(order = 3) + @ApiOperation(value = "编辑", notes = "传入EmTreeDTO") + public R update(@Valid @RequestBody EmTreeDTO emTreeDTO) { + return R.data(emTreeService.updateEmTrree(emTreeDTO)); + } + + /** + * 删除 + */ + @GetMapping("/remove") + @ApiOperationSupport(order = 4) + @ApiOperation(value = "逻辑删除", notes = "传入id") + public R remove(Long id) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(EmTreeEntity::getPid, id); + List list = emTreeService.list(wrapper); + if (Func.isNotEmpty(list)) { + return R.fail("存在子设备不能删除"); + } + LambdaQueryWrapper infoWrapper = new LambdaQueryWrapper<>(); + infoWrapper.eq(EmInfoEntity::getTreeId, id); + List infoList = emInfoService.list(infoWrapper); + if (Func.isNotEmpty(infoList)) { + return R.fail("设备树已被设备信息使用,不能删除"); + } + return R.status(emTreeService.removeById(id)); + } + + /** + * 通过设备定义id获取设备树(树结构) + */ + @GetMapping("/getEmTreeByDefinitionId") + @ApiOperationSupport(order = 5) + @ApiOperation(value = "通过设备定义id获取设备树(树结构)", notes = "传入设备定义id") + public R getEmTreeByDefinitionId(Long definitionId) { + return R.data(emTreeService.getEmTreeByDefinitionId(definitionId)); + } + + /** + * 通过父设备树id获取子设备树(树结构) + */ + @GetMapping("/getSonEmTreeByPid") + @ApiOperationSupport(order = 5) + @ApiOperation(value = "通过父设备树id获取子设备树(树结构)", notes = "传入父设备树id") + public R getSonEmTreeByPid(Long pid) { + return R.data(emTreeService.getSonEmTreeByPid(pid)); + } + + /** + * 获取定义的所有设备(下拉列表) + */ + @GetMapping("/getDefinitionAllEmTree") + @ApiOperationSupport(order = 6) + @ApiOperation(value = "获取定义的所有设备(下拉列表)", notes = "传入设备定义id") + public R getDefinitionAllDevice(Long definitionId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + wrapper.eq(EmTreeEntity::getDefinitionId, definitionId); + wrapper.ne(EmTreeEntity::getEmGrade, 5); + return R.data(emTreeService.list(wrapper)); + } + + /** + * 获取设备树绑定的巡检内容 + */ + @GetMapping("/getEmTreeContent") + @ApiOperationSupport(order = 7) + @ApiOperation(value = "获取设备树绑定的巡检内容", notes = "传入设备树id") + public R getEmTreeContent(Long treeId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + wrapper.eq(EmTreeInspectEntity::getTreeId, treeId); + return R.data(emTreeInspectService.list(wrapper)); + } + + /** + * 获取设备树绑定的参数 + */ + @GetMapping("/getEmTreeParam") + @ApiOperationSupport(order = 7) + @ApiOperation(value = "获取设备树绑定的参数", notes = "传入设备树id") + public R getEmTreeParam(Long treeId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + wrapper.eq(EmTreeParamEntity::getTreeId, treeId); + return R.data(emTreeParamService.list(wrapper)); + } + + /** + * 获取设备树绑定的物资 + */ + @GetMapping("/getEmTreeBasic") + @ApiOperationSupport(order = 7) + @ApiOperation(value = "获取设备树绑定的物资", notes = "传入设备树id") + public R getEmTreeBasic(Long treeId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + wrapper.eq(EmTreeBasicEntity::getTreeId, treeId); + return R.data(emTreeBasicService.list(wrapper)); + } + +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/LifeCycleController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/LifeCycleController.java new file mode 100644 index 0000000..e55ab9d --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/LifeCycleController.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.equipment.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 tanghaihao + * @date 2023年07月05日 17:04 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/lifecycle") +@Api(value = "设备生命周期控制层", tags = "设备生命周期") +public class LifeCycleController extends BladeController { + + +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/dto/DeviceTreeDTO.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/dto/DeviceTreeDTO.java new file mode 100644 index 0000000..05e4fc4 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/dto/DeviceTreeDTO.java @@ -0,0 +1,26 @@ +package com.hnac.hzims.equipment.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author tanghaihao + * @date 2023年06月20日 10:46 + */ +@Data +public class DeviceTreeDTO { + + @ApiModelProperty(value = "站点ID") + private String stationId; + + @ApiModelProperty(value = "设备信息ID") + private Long infoId; + + @ApiModelProperty(value = "设备定义ID") + private Long definitionId; + + @ApiModelProperty(value = "设备树ids") + private List treeIds; +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/dto/EmDefinitionDTO.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/dto/EmDefinitionDTO.java new file mode 100644 index 0000000..e100454 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/dto/EmDefinitionDTO.java @@ -0,0 +1,37 @@ +package com.hnac.hzims.equipment.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @author tanghaihao + * @date 2023年06月15日 10:22 + */ +@Data +public class EmDefinitionDTO { + + @ApiModelProperty(value = "id") + private Long id; + + @ApiModelProperty(value = "站点类型") + @NotNull + private String stationType; + + @ApiModelProperty(value = "类型") + @NotNull + private String type; + + @ApiModelProperty(value = "设备定义名称") + @NotNull + private String name; + + @ApiModelProperty(value = "模型标识") + @NotNull + private String modelSignage; + + @ApiModelProperty(value = "模型标识") + private String modelName; + +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/dto/EmTreeDTO.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/dto/EmTreeDTO.java new file mode 100644 index 0000000..b4c2a47 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/dto/EmTreeDTO.java @@ -0,0 +1,66 @@ +package com.hnac.hzims.equipment.dto; + +import com.hnac.hzims.equipment.entity.EmTreeInspectEntity; +import com.hnac.hzims.equipment.entity.EmTreeParamEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @author tanghaihao + * @date 2023年06月15日 15:44 + */ +@Data +public class EmTreeDTO { + + @ApiModelProperty(value = "id") + private Long id; + + @ApiModelProperty(value = "设备定义Id") + @NotNull + private Long definitionId; + + @ApiModelProperty(value = "父Id") + private Long pid; + + @ApiModelProperty(value = "设备类型") + @NotNull + private String emType; + + @ApiModelProperty("机组类型") + private String setType; + + @ApiModelProperty(value = "设备名称") + @NotNull + private String name; + + @ApiModelProperty(value = "设备标识") + @NotNull + private String signage; + + @ApiModelProperty(value = "排序") + @NotNull + private Integer sort; + + @ApiModelProperty(value = "所属组织") + @NotNull + private Long refOreanization; + + @ApiModelProperty(value = "设备类别") + private String gradeCode; + + @ApiModelProperty(value = "巡检标准") + @NotNull + private String inspectStandard; + + @ApiModelProperty(value = "巡检内容") + private List emTreeInspectList; + + @ApiModelProperty(value = "设备参数") + private List emTreeParamList; + + @ApiModelProperty(value = "物资ids") + private List basicIds; +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/dto/EmTreeIdsDTO.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/dto/EmTreeIdsDTO.java new file mode 100644 index 0000000..8213827 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/dto/EmTreeIdsDTO.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.equipment.dto; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.hnac.hzims.equipment.entity.EmTreeEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author tanghaihao + * @date 2023年07月10日 11:44 + */ +@Data +public class EmTreeIdsDTO { + @ApiModelProperty(value = "设备树Id") + private Long treeId; + + @ApiModelProperty(value = "子设备树") + private List children; +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java index 7afed46..5d999c3 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java @@ -133,4 +133,14 @@ public class EmInfoClient implements IEmInfoClient { return service.getEmCreateTable(tableNames); } + /** + * + * @param emCode + * @return + */ + @GetMapping(value = GET_EM_INFO_TREE_BY_EM_CODE) + @Override + public R> getEmInfoTreeByEmCode(String emCode) { + return R.data(service.getEmInfoTreeByEmCode(emCode)); + } } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmDefinitionMapper.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmDefinitionMapper.java new file mode 100644 index 0000000..6fc92fb --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmDefinitionMapper.java @@ -0,0 +1,7 @@ +package com.hnac.hzims.equipment.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.equipment.entity.EmDefinitionEntity; + +public interface EmDefinitionMapper extends BaseMapper { +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmDefinitionMapper.xml b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmDefinitionMapper.xml new file mode 100644 index 0000000..59347b7 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmDefinitionMapper.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.java index 96dbbf0..387e821 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.java @@ -4,6 +4,7 @@ import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.vo.EmInfoExtendVo; import com.hnac.hzims.equipment.vo.DeviceVO; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; +import com.hnac.hzims.equipment.vo.SparePartVO; import org.apache.ibatis.annotations.Param; import org.springblade.core.datascope.annotation.UserDataAuth; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; @@ -48,4 +49,8 @@ public interface EmInfoMapper extends UserDataScopeBaseMapper { String getCurDataBaseName(); List listByTenantId(@Param("tenantId") String tenantId); + + Integer getMaxEmIndexByPid(@Param("pid") Long pid); + + List getSparePart(@Param("path") String path, @Param("startTime") String startTime, @Param("endTime") String endTime); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.xml b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.xml index 252566c..e90bc2a 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.xml +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.xml @@ -115,4 +115,32 @@ where is_deleted = 0 and tenant_id = #{tenantId} + + + + diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeBasicMapper.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeBasicMapper.java new file mode 100644 index 0000000..0db6c29 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeBasicMapper.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.equipment.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.equipment.entity.EmTreeBasicEntity; + +/** + * @author tanghaihao + * @date 2023年07月14日 16:38 + */ +public interface EmTreeBasicMapper extends BaseMapper { +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeBasicMapper.xml b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeBasicMapper.xml new file mode 100644 index 0000000..75365d5 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeBasicMapper.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeInspectMapper.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeInspectMapper.java new file mode 100644 index 0000000..3e3b868 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeInspectMapper.java @@ -0,0 +1,8 @@ +package com.hnac.hzims.equipment.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.equipment.entity.EmTreeInspectEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +public interface EmTreeInspectMapper extends BaseMapper { +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeInspectMapper.xml b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeInspectMapper.xml new file mode 100644 index 0000000..d1eab9f --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeInspectMapper.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeMapper.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeMapper.java new file mode 100644 index 0000000..739168c --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeMapper.java @@ -0,0 +1,7 @@ +package com.hnac.hzims.equipment.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.equipment.entity.EmTreeEntity; + +public interface EmTreeMapper extends BaseMapper { +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeMapper.xml b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeMapper.xml new file mode 100644 index 0000000..9a66892 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeMapper.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeParamMapper.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeParamMapper.java new file mode 100644 index 0000000..e39c02d --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeParamMapper.java @@ -0,0 +1,8 @@ +package com.hnac.hzims.equipment.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.equipment.entity.EmTreeParamEntity; + +public interface EmTreeParamMapper extends BaseMapper { + +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeParamMapper.xml b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeParamMapper.xml new file mode 100644 index 0000000..2e1d3b1 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeParamMapper.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmDefinitionService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmDefinitionService.java new file mode 100644 index 0000000..21e7128 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmDefinitionService.java @@ -0,0 +1,7 @@ +package com.hnac.hzims.equipment.service; + +import com.hnac.hzims.equipment.entity.EmDefinitionEntity; +import org.springblade.core.mp.base.BaseService; + +public interface IEmDefinitionService extends BaseService { +} 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 3352f49..79c864e 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 @@ -1,7 +1,9 @@ package com.hnac.hzims.equipment.service; +import com.hnac.hzims.equipment.dto.DeviceTreeDTO; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.vo.*; +import com.hnac.hzinfo.inspect.obj.dto.ContentDTO; import io.swagger.annotations.ApiParam; import org.springblade.core.mp.base.BaseService; import org.springblade.core.tool.api.R; @@ -19,6 +21,10 @@ import java.util.Map; */ public interface IEmInfoService extends BaseService { + String PUBLIC_TYPE = "1"; + String SET_TYPE = "2"; + String OTHERS_TYPE = "3"; + /** * 根据emCode获取设备 * @return @@ -53,6 +59,7 @@ public interface IEmInfoService extends BaseService { EmInfoEntity getEmInfoByEmCode(String emCode); + List getEmInfoTreeByEmCode(String emCode); void loadEmInfo(); @@ -65,4 +72,14 @@ public interface IEmInfoService extends BaseService { List listByTenantId(String tenantId); Boolean remove(String ids); + + Boolean importDeviceTree(DeviceTreeDTO deviceTreeDTO); + + Boolean importSonDeviceTree(DeviceTreeDTO deviceTreeDTO); + + List getEmInfoContent(String code, ContentDTO dto); + + List getSparePart(String emCode, String startTime, String endTime); + + List convertToTree(Long pid, List list); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmTreeBasicService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmTreeBasicService.java new file mode 100644 index 0000000..1202a99 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmTreeBasicService.java @@ -0,0 +1,7 @@ +package com.hnac.hzims.equipment.service; + +import com.hnac.hzims.equipment.entity.EmTreeBasicEntity; +import org.springblade.core.mp.base.BaseService; + +public interface IEmTreeBasicService extends BaseService { +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmTreeInspectService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmTreeInspectService.java new file mode 100644 index 0000000..9b10228 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmTreeInspectService.java @@ -0,0 +1,7 @@ +package com.hnac.hzims.equipment.service; + +import com.hnac.hzims.equipment.entity.EmTreeInspectEntity; +import org.springblade.core.mp.base.BaseService; + +public interface IEmTreeInspectService extends BaseService { +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmTreeParamService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmTreeParamService.java new file mode 100644 index 0000000..7a57110 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmTreeParamService.java @@ -0,0 +1,7 @@ +package com.hnac.hzims.equipment.service; + +import com.hnac.hzims.equipment.entity.EmTreeParamEntity; +import org.springblade.core.mp.base.BaseService; + +public interface IEmTreeParamService extends BaseService { +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmTreeService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmTreeService.java new file mode 100644 index 0000000..97a17eb --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmTreeService.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.equipment.service; + +import com.hnac.hzims.equipment.dto.EmTreeDTO; +import com.hnac.hzims.equipment.entity.EmTreeEntity; +import com.hnac.hzims.equipment.vo.EmTreeVO; +import org.springblade.core.mp.base.BaseService; + +import java.util.List; + +public interface IEmTreeService extends BaseService { + + Boolean saveEmTrree(EmTreeDTO emTreeDTO); + + Boolean updateEmTrree(EmTreeDTO emTreeDTO); + + List getEmTreeByDefinitionId(Long definitionId); + + List getSonEmTreeByPid(Long pid); +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmAssociationDetailServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmAssociationDetailServiceImpl.java index d68b144..76e6307 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmAssociationDetailServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmAssociationDetailServiceImpl.java @@ -1,26 +1,11 @@ package com.hnac.hzims.equipment.service.impl; -import ReadData.ReadData; -import ReadData.ReadDataTypes; -import ReadData.YcRValue; -import com.alibaba.fastjson.JSON; import com.hnac.hzims.equipment.entity.EmAssociationDetailEntity; import com.hnac.hzims.equipment.mapper.EmAssociationDetailMapper; import com.hnac.hzims.equipment.service.IEmAssociationDetailService; -import com.hnac.hzims.equipment.vo.EmAssociationDetailVo; -import com.hnac.hzims.fdp.util.HttpRequestUtil; import org.springblade.core.mp.base.BaseServiceImpl; -import org.springblade.core.tool.utils.DateUtil; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; -import java.io.*; -import java.net.HttpURLConnection; -import java.net.URL; - -import java.util.*; - @Service public class EmAssociationDetailServiceImpl extends BaseServiceImpl implements IEmAssociationDetailService { @@ -29,7 +14,7 @@ public class EmAssociationDetailServiceImpl extends BaseServiceImpl list, String tenantId) { + /*public Map getRealValue(List list, String tenantId) { Map resultMap = new HashMap<>(); List listMap = new ArrayList<>(); for (int i = 0; i < list.size(); i++) { @@ -78,5 +63,5 @@ public class EmAssociationDetailServiceImpl extends BaseServiceImpl implements IEmDefinitionService { +} 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 bf4b190..8623cd0 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 @@ -6,9 +6,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.google.api.client.util.Sleeper; import com.google.common.collect.Lists; import com.hnac.hzims.equipment.EquipmentContants; +import com.hnac.hzims.equipment.dto.DeviceTreeDTO; +import com.hnac.hzims.equipment.dto.EmTreeIdsDTO; import com.hnac.hzims.equipment.entity.*; import com.hnac.hzims.equipment.mapper.EmInfoMapper; import com.hnac.hzims.equipment.mapper.EmInfoNoScopeMapper; @@ -21,17 +22,34 @@ import com.hnac.hzims.operational.station.feign.IStationClient; import com.hnac.hzims.util.TableJsonUtils; import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; +import com.hnac.hzinfo.datasearch.device.IDeviceClient; +import com.hnac.hzinfo.inspect.obj.dto.ContentDTO; +import com.hnac.hzinfo.inspect.obj.dto.ContentDefinitionDTO; +import com.hnac.hzinfo.inspect.obj.dto.ProjectDTO; +import com.hnac.hzinfo.inspect.obj.feign.IContentDefinitionClient; +import com.hnac.hzinfo.inspect.obj.feign.IProjectClient; +import com.hnac.hzinfo.inspect.obj.request.ProjectContentRequest; +import com.hnac.hzinfo.inspect.obj.vo.ContentDefinitionVO; +import com.hnac.hzinfo.inspect.obj.vo.ContentVO; +import com.hnac.hzinfo.inspect.obj.vo.ProjectVO; import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO; +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.project.ProjectClient; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.MapUtils; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; +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.*; import org.springblade.system.entity.Dept; import org.springblade.system.feign.ISysClient; import org.springblade.system.vo.CreateTableVO; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; @@ -41,8 +59,10 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; import javax.validation.Valid; +import java.math.BigDecimal; import java.util.*; import java.util.function.Consumer; +import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -63,6 +83,12 @@ public class EmInfoServiceImpl extends BaseServiceImpl getEmInfoTreeByEmCode(String emCode) { + + return null; + } + /** * 把设备信息及装机容量、ct、pt从Redis 取出来 */ @@ -451,6 +490,98 @@ public class EmInfoServiceImpl extends BaseServiceImpl getEmInfoContent(String emCode, ContentDTO dto) { + List emInfoContentList = new ArrayList<>(); + ProjectContentRequest request = new ProjectContentRequest(); + request.setCurrent(1); + request.setSize(-1); + request.setEmCode(emCode); + request.setContentDTO(dto); + R projectResult = projectClient.getProjectAndContentByEmCode(request); + if (projectResult.getCode() != 200) { + throw new ServiceException("获取项目信息失败"); + } + ProjectVO projectVO = projectResult.getData(); + if (Func.isEmpty(projectVO)) { + return emInfoContentList; + } + List contentVOList = projectVO.getContentList(); + if (Func.isEmpty(contentVOList)) { + return emInfoContentList; + } + List attrSignages = contentVOList.stream().map(ContentVO::getAttrSignage).collect(Collectors.toList()); + + // 通过设备编号找到相同的设备实例获取设备绑定的采集点 + DeviceChildrenDTO deviceChildrenDTO = new DeviceChildrenDTO(); + deviceChildrenDTO.setDeviceCode(emCode); + deviceChildrenDTO.setType("attr"); + deviceChildrenDTO.setSignages(attrSignages); + Result> deviceResult = deviceClient.getRealId(deviceChildrenDTO); + Map childrenMap = new HashMap<>(); + if (deviceResult.getCode() == 200 && Func.isNotEmpty(deviceResult.getData())) { + List deviceChildrenList = deviceResult.getData(); + childrenMap = deviceChildrenList.stream().collect(Collectors.toMap(DeviceChildrenVO::getSignage, Function.identity())); + } + + // 拼接采集点到设备巡检内容 + for (ContentVO content : contentVOList) { + EmInfoContentVO vo = new EmInfoContentVO(); + BeanUtils.copyProperties(content, vo); + + if (Func.isNotEmpty(childrenMap)) { + DeviceChildrenVO deviceChildrenVO = childrenMap.get(vo.getAttrSignage()); + vo.setInstanceFacDeviceId(deviceChildrenVO.getRealId()); + vo.setInstanceFacDeviceName(deviceChildrenVO.getFacName()); + } + emInfoContentList.add(vo); + } + return emInfoContentList; + } + + @Override + public List getSparePart(String emCode, String startTime, String endTime) { + EmInfoEntity emInfo = this.getEmInfoByEmCode(emCode); + return baseMapper.getSparePart(emInfo.getPath(), startTime, endTime); + } + + @Override + public List convertToTree(Long pid, List list) { + // 把List结构数据转换成树结构 + Map> emTreeMap = list.stream().collect(Collectors.groupingBy(EmInfoEntity::getGpid)); + list.forEach(tree -> { + tree.setInfoChildren(emTreeMap.get(tree.getId())); + }); + return list.stream().filter(item -> item.getGpid().equals(pid)).collect(Collectors.toList()); + } + /** * 设备信息缓存(ct、pt、installedCapacity、监测点位) @@ -562,4 +693,161 @@ public class EmInfoServiceImpl extends BaseServiceImpl getFatherAndSonDevice(EmInfoEntity emInfo, List treeIds){ + List fatherAndSonList = new ArrayList<>(); + List parentSignages = new ArrayList<>(); + List emTreeList = emTreeService.listByIds(treeIds); + for (EmTreeEntity emTree : emTreeList) { + LambdaQueryWrapper emTreeWrapper = new LambdaQueryWrapper(); + emTreeWrapper.eq(EmTreeEntity::getDefinitionId, emTree.getDefinitionId()); + emTreeWrapper.likeRight(EmTreeEntity::getPath, emTree.getPath()); + if (Func.isNotEmpty(emInfo)) { + // 有设备信息说明是导入子设备,防止本级设备二次导入 + emTreeWrapper.ne(EmTreeEntity::getId, emInfo.getTreeId()); + } + + // 获取所有子设备 + List list = emTreeService.list(emTreeWrapper); + if (Func.isNotEmpty(list)) { + fatherAndSonList.addAll(list); + } + + int index = 0; + if (Func.isNotEmpty(emInfo)) { + EmTreeEntity parentEmTree = emTreeService.getById(emInfo.getTreeId()); + // 导入子设备根目录从父设备后面开始 + index = emTree.getPath().indexOf(parentEmTree.getSignage()) + parentEmTree.getSignage().length(); + } + // 通过path获取所有父设备标识,不包括自己 + String parentPath = emTree.getPath().substring(index, emTree.getPath().lastIndexOf("/")); + if (parentPath.length() > 0) { + parentSignages.addAll(Arrays.asList(parentPath.split("/"))); + } + } + + if (Func.isNotEmpty(parentSignages)) { + LambdaQueryWrapper parentWrapper = new LambdaQueryWrapper(); + parentWrapper.eq(EmTreeEntity::getDefinitionId, emTreeList.get(0).getDefinitionId()); + parentWrapper.in(EmTreeEntity::getSignage, parentSignages); + // 通过标识获取父设备 + List parentList = emTreeService.list(parentWrapper); + fatherAndSonList.addAll(parentList); + } + + // 把List结构数据转换成树结构 + Map> fatherAndSonMap = fatherAndSonList.stream().collect(Collectors.groupingBy(EmTreeEntity::getPid)); + fatherAndSonList.forEach(emTree -> { + emTree.setChildren(fatherAndSonMap.get(emTree.getId())); + }); + List resultList = fatherAndSonList.stream().filter(item -> item.getPid() == 0).collect(Collectors.toList()); + return resultList; + } + + private void copyDeviceTree(StationEntity station, Long pid, Long definitionId, List treeIds) { + List projectDTOList = new ArrayList<>(); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + wrapper.eq(EmTreeEntity::getDefinitionId, definitionId); + List definitionEmTrees = emTreeService.list(wrapper); + Map emTreeMap = definitionEmTrees.stream().collect(Collectors.toMap(EmTreeEntity::getId, Function.identity())); + for (EmTreeIdsDTO emTreeIdsDTO : treeIds) { + EmTreeEntity emTree = emTreeMap.get(emTreeIdsDTO.getTreeId()); + EmInfoEntity emInfo = new EmInfoEntity(); + // 把设备树复制成设备实例 + BeanUtils.copyProperties(emTree, emInfo); + Long infoId = IdWorker.getId(); + String number = emInfoCodePrefix + IdWorker.getId(); + emInfo.setId(infoId); + emInfo.setGpid(pid); + emInfo.setTreeId(emTree.getId()); + emInfo.setInsLocation(station.getAddress()); + emInfo.setNumber(number); + emInfo.setStationCode(station.getCode()); + EmInfoEntity parentEmInfo = this.getById(pid); + if (Func.isNotEmpty(parentEmInfo)) { + emInfo.setPath(parentEmInfo.getPath() + "/" + number); + } else { + emInfo.setPath("/" + number); + } + + emInfo.setLgtd(new BigDecimal(station.getLgtd().toString())); + emInfo.setLttd(new BigDecimal(station.getLttd().toString())); + emInfo.setDepartment(station.getRefDept()); + emInfo.setInstallTime(new Date()); + emInfo.setRunStatus("1"); + emInfo.setStatus(1); + emInfo.setRunDate(new Date()); + emInfo.setCreateDept(station.getRefDept()); + emInfo.setCreateTime(new Date()); + emInfo.setCreateUser(AuthUtil.getUserId()); + if (SET_TYPE.equals(emInfo.getEmType())) { + Integer maxIndex = baseMapper.getMaxEmIndexByPid(pid); + if (Func.isNotEmpty(maxIndex)) { + emInfo.setEmIndex(maxIndex + 1); + } else { + emInfo.setEmIndex(1); + } + emInfo.setName(emInfo.getEmIndex() + "号机组"); + } + this.save(emInfo); + LambdaQueryWrapper treeParamWrapper = new LambdaQueryWrapper(); + treeParamWrapper.eq(EmTreeParamEntity::getTreeId, emTree.getId()); + List treeParamList = emTreeParamService.list(treeParamWrapper); + // 复制设备参数 + if (Func.isNotEmpty(treeParamList)) { + List paramList = new ArrayList<>(); + for (EmTreeParamEntity emTreeParam : treeParamList) { + EmParamEntity param = new EmParamEntity(); + BeanUtils.copyProperties(emTreeParam, param); + param.setInfoId(infoId); + param.setId(null); + paramList.add(param); + } + paramService.saveBatch(paramList); + } + // 新增巡检项目和巡检内容 + ProjectDTO projectDTO = new ProjectDTO(); + projectDTO.setEmCode(emInfo.getNumber()); + projectDTO.setName(emInfo.getName()); + + // 获取设备树中绑定的巡检内容 + LambdaQueryWrapper inspectWrapper = new LambdaQueryWrapper(); + inspectWrapper.eq(EmTreeInspectEntity::getTreeId, emTree.getId()); + List list = emTreeInspectService.list(inspectWrapper); + List contentIds = list.stream().map(EmTreeInspectEntity::getContentId).collect(Collectors.toList()); + ContentDefinitionDTO contentDefinitionDTO = new ContentDefinitionDTO(); + contentDefinitionDTO.setIds(contentIds); + R> result = contentDefinitionClient.list(contentDefinitionDTO); + if (result.getCode() != 200) { + throw new ServiceException("获取巡检内容失败"); + } + List contentDefinitionList = result.getData(); + + if (Func.isNotEmpty(contentDefinitionList)) { + Map contentDefinitionMap = contentDefinitionList.stream().collect(Collectors.toMap(ContentDefinitionVO::getId, Function.identity())); + // 把巡检内容拼装成projectDTO + List contentDTOList = new ArrayList<>(); + for (EmTreeInspectEntity emTreeInspect : list) { + ContentDTO dto = new ContentDTO(); + ContentDefinitionVO vo = contentDefinitionMap.get(emTreeInspect.getContentId()); + BeanUtils.copyProperties(vo, dto); + dto.setModelSignage(emTreeInspect.getModelSignage()); + dto.setAttrSignage(emTreeInspect.getModelAttrSignage()); + dto.setAttrName(emTreeInspect.getModelAttrName()); + dto.setId(null); + contentDTOList.add(dto); + } + projectDTO.setContentDTOList(contentDTOList); + } + + projectDTOList.add(projectDTO); + + if (Func.isNotEmpty(emTreeIdsDTO.getChildren())) { + copyDeviceTree(station, infoId, definitionId, emTreeIdsDTO.getChildren()); + } + } + if (Func.isNotEmpty(projectDTOList)) { + projectClient.addProjectAndContent(projectDTOList); + } + } } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmTreeBasicServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmTreeBasicServiceImpl.java new file mode 100644 index 0000000..d7197db --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmTreeBasicServiceImpl.java @@ -0,0 +1,22 @@ +package com.hnac.hzims.equipment.service.impl; + +import com.hnac.hzims.equipment.entity.EmTreeBasicEntity; +import com.hnac.hzims.equipment.entity.EmTreeInspectEntity; +import com.hnac.hzims.equipment.mapper.EmTreeBasicMapper; +import com.hnac.hzims.equipment.mapper.EmTreeInspectMapper; +import com.hnac.hzims.equipment.service.IEmTreeBasicService; +import com.hnac.hzims.equipment.service.IEmTreeInspectService; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @author tanghaihao + * @date 2023年07月14日 16:36 + */ +@Service +@Slf4j +public class EmTreeBasicServiceImpl extends BaseServiceImpl implements IEmTreeBasicService { + + +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmTreeInspectServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmTreeInspectServiceImpl.java new file mode 100644 index 0000000..6ce7b74 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmTreeInspectServiceImpl.java @@ -0,0 +1,17 @@ +package com.hnac.hzims.equipment.service.impl; + +import com.hnac.hzims.equipment.entity.EmTreeInspectEntity; +import com.hnac.hzims.equipment.mapper.EmTreeInspectMapper; +import com.hnac.hzims.equipment.service.IEmTreeInspectService; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @author tanghaihao + * @date 2023年06月15日 9:08 + */ +@Service +@Slf4j +public class EmTreeInspectServiceImpl extends BaseServiceImpl implements IEmTreeInspectService { +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmTreeParamServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmTreeParamServiceImpl.java new file mode 100644 index 0000000..83ea058 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmTreeParamServiceImpl.java @@ -0,0 +1,17 @@ +package com.hnac.hzims.equipment.service.impl; + +import com.hnac.hzims.equipment.entity.EmTreeParamEntity; +import com.hnac.hzims.equipment.mapper.EmTreeParamMapper; +import com.hnac.hzims.equipment.service.IEmTreeParamService; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @author tanghaihao + * @date 2023年06月15日 9:08 + */ +@Service +@Slf4j +public class EmTreeParamServiceImpl extends BaseServiceImpl implements IEmTreeParamService { +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmTreeServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmTreeServiceImpl.java new file mode 100644 index 0000000..5f05da2 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmTreeServiceImpl.java @@ -0,0 +1,235 @@ +package com.hnac.hzims.equipment.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.IdWorker; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.equipment.dto.EmTreeDTO; +import com.hnac.hzims.equipment.entity.EmTreeBasicEntity; +import com.hnac.hzims.equipment.entity.EmTreeEntity; +import com.hnac.hzims.equipment.entity.EmTreeInspectEntity; +import com.hnac.hzims.equipment.entity.EmTreeParamEntity; +import com.hnac.hzims.equipment.mapper.EmTreeMapper; +import com.hnac.hzims.equipment.service.IEmTreeBasicService; +import com.hnac.hzims.equipment.service.IEmTreeInspectService; +import com.hnac.hzims.equipment.service.IEmTreeParamService; +import com.hnac.hzims.equipment.service.IEmTreeService; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.core.tool.utils.Func; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @author tanghaihao + * @date 2023年06月15日 9:08 + */ +@Service +@Slf4j +public class EmTreeServiceImpl extends BaseServiceImpl implements IEmTreeService { + + @Autowired + private IEmTreeInspectService emTreeInspectService; + + @Autowired + private IEmTreeParamService emTreeParamService; + + @Autowired + private IEmTreeBasicService emTreeBasicService; + + @Override + @Transactional + public Boolean saveEmTrree(EmTreeDTO emTreeDTO) { + Long treeId = IdWorker.getId(); + EmTreeEntity emTree = new EmTreeEntity(); + Func.copy(emTreeDTO, emTree); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(EmTreeEntity::getDefinitionId, emTree.getDefinitionId()); + wrapper.eq(EmTreeEntity::getSignage, emTree.getSignage()); + EmTreeEntity one = this.getOne(wrapper); + if (Func.isNotEmpty(one)) { + throw new ServiceException("在同一个定义中设备标识不能重复"); + } + List emTreeInspectList = emTreeDTO.getEmTreeInspectList(); + for (EmTreeInspectEntity emTreeInspect: emTreeInspectList) { + emTreeInspect.setTreeId(treeId); + } + List emTreeParamList = emTreeDTO.getEmTreeParamList(); + for (EmTreeParamEntity emTreeParam: emTreeParamList) { + emTreeParam.setTreeId(treeId); + } + List emTreeBasicList = new ArrayList<>(); + for (Long basicId : emTreeDTO.getBasicIds()) { + EmTreeBasicEntity emTreeBasic = new EmTreeBasicEntity(); + emTreeBasic.setTreeId(treeId); + emTreeBasic.setBasicId(basicId); + emTreeBasicList.add(emTreeBasic); + } + + emTreeInspectService.saveBatch(emTreeInspectList); + emTreeParamService.saveBatch(emTreeParamList); + emTreeBasicService.saveBatch(emTreeBasicList); + + emTree.setId(treeId); + if (Func.isEmpty(emTree.getPid())) { + emTree.setEmGrade(0); + // 添加设备树标识路径,方便快速查询父子设备 + emTree.setPath("/" + emTree.getSignage()); + } else { + EmTreeEntity parentEmTree = this.getById(emTree.getPid()); + if (parentEmTree.getEmGrade() >= 5) { + throw new ServiceException("设备等级最多五级"); + } + emTree.setEmGrade(parentEmTree.getEmGrade() + 1); + EmTreeEntity parent = this.getById(emTree.getPid()); + emTree.setPath(parent.getPath() + "/" + emTree.getSignage()); + } + emTree.setCreateTime(new Date()); + emTree.setCreateUser(AuthUtil.getUserId()); + emTree.setStatus(1); + emTree.setCreateDept(Long.valueOf(AuthUtil.getDeptId())); + return this.save(emTree); + } + + @Override + @Transactional + public Boolean updateEmTrree(EmTreeDTO emTreeDTO) { + EmTreeEntity emTree = new EmTreeEntity(); + Func.copy(emTreeDTO, emTree); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(EmTreeEntity::getSignage, emTree.getSignage()); + wrapper.eq(EmTreeEntity::getDefinitionId, emTree.getDefinitionId()); + wrapper.ne(EmTreeEntity::getId, emTree.getId()); + EmTreeEntity one = this.getOne(wrapper); + if (Func.isNotEmpty(one)) { + throw new ServiceException("设备标识已存在"); + } + // 更新设备巡检内容 + List emTreeInspectList = emTreeDTO.getEmTreeInspectList(); + if (Func.isNotEmpty(emTreeInspectList)) { + for (EmTreeInspectEntity emTreeInspect: emTreeInspectList) { + emTreeInspect.setTreeId(emTree.getId()); + } + emTreeInspectService.saveOrUpdateBatch(emTreeInspectList); + + List updateInspectIds = emTreeInspectList.stream().map(EmTreeInspectEntity::getId).collect(Collectors.toList()); + List removeInspectIds = new ArrayList<>(); + LambdaQueryWrapper inspectWrapper = new LambdaQueryWrapper(); + inspectWrapper.eq(EmTreeInspectEntity::getTreeId, emTree.getId()); + List list = emTreeInspectService.list(inspectWrapper); + for (EmTreeInspectEntity inspect : list) { + if (!updateInspectIds.contains(inspect.getId())) { + removeInspectIds.add(inspect.getId()); + } + } + // 删掉页面上删除的巡检内容 + if (Func.isNotEmpty(removeInspectIds)) { + emTreeInspectService.removeByIds(removeInspectIds); + } + } else { + LambdaQueryWrapper removeInspectWrapper = new LambdaQueryWrapper<>(); + removeInspectWrapper.eq(EmTreeInspectEntity::getTreeId, emTreeDTO.getId()); + emTreeInspectService.remove(removeInspectWrapper); + } + // 更新设备参数 + List emTreeParamList = emTreeDTO.getEmTreeParamList(); + if (Func.isNotEmpty(emTreeParamList)) { + for (EmTreeParamEntity emTreeParam : emTreeParamList) { + emTreeParam.setTreeId(emTree.getId()); + } + emTreeParamService.saveOrUpdateBatch(emTreeParamList); + + List updateParamIds = emTreeParamList.stream().map(EmTreeParamEntity::getId).collect(Collectors.toList()); + List removeParamIds = new ArrayList<>(); + LambdaQueryWrapper paramWrapper = new LambdaQueryWrapper(); + paramWrapper.eq(EmTreeParamEntity::getTreeId, emTree.getId()); + List list = emTreeParamService.list(paramWrapper); + for (EmTreeParamEntity param : list) { + if (!updateParamIds.contains(param.getId())) { + removeParamIds.add(param.getId()); + } + } + // 删掉页面上删除的设备参数 + if (Func.isNotEmpty(removeParamIds)) { + emTreeParamService.removeByIds(removeParamIds); + } + } else { + LambdaQueryWrapper removeParamWrapper = new LambdaQueryWrapper<>(); + removeParamWrapper.eq(EmTreeParamEntity::getTreeId, emTreeDTO.getId()); + emTreeParamService.remove(removeParamWrapper); + } + // 更新设备物资 + List updateBasicIds = emTreeDTO.getBasicIds(); + if (Func.isNotEmpty(updateBasicIds)) { + LambdaQueryWrapper basicWrapper = new LambdaQueryWrapper(); + basicWrapper.eq(EmTreeBasicEntity::getTreeId, emTree.getId()); + List list = emTreeBasicService.list(basicWrapper); + List oldBasicIds = list.stream().map(EmTreeBasicEntity::getBasicId).collect(Collectors.toList()); + // 添加新增的设备物资 + List addBasicList = new ArrayList<>(); + for (Long basicId : updateBasicIds) { + if (!oldBasicIds.contains(basicId)) { + EmTreeBasicEntity emTreeBasic = new EmTreeBasicEntity(); + emTreeBasic.setTreeId(emTree.getId()); + emTreeBasic.setBasicId(basicId); + addBasicList.add(emTreeBasic); + } + } + if (Func.isNotEmpty(addBasicList)) { + emTreeBasicService.saveBatch(addBasicList); + } + + // 删掉页面上删除的设备参数 + List removeBasicIds = new ArrayList<>(); + for (EmTreeBasicEntity basic : list) { + if (!updateBasicIds.contains(basic.getBasicId())) { + removeBasicIds.add(basic.getId()); + } + } + if (Func.isNotEmpty(removeBasicIds)) { + emTreeBasicService.removeByIds(removeBasicIds); + } + } else { + LambdaQueryWrapper removeBasicWrapper = new LambdaQueryWrapper<>(); + removeBasicWrapper.eq(EmTreeBasicEntity::getTreeId, emTree.getId()); + emTreeBasicService.remove(removeBasicWrapper); + } + return this.updateById(emTree); + } + + @Override + public List getEmTreeByDefinitionId(Long definitionId) { + List emTreeList = this.list(Wrappers.lambdaQuery().eq(EmTreeEntity::getDefinitionId, definitionId)); + + // 把List结构数据转换成树结构 + Map> emTreeMap = emTreeList.stream().collect(Collectors.groupingBy(EmTreeEntity::getPid)); + emTreeList.forEach(emTree -> { + emTree.setChildren(emTreeMap.get(emTree.getId())); + }); + List resultList = emTreeList.stream().filter(item -> item.getPid().equals(0L)).collect(Collectors.toList()); + return resultList; + + } + + @Override + public List getSonEmTreeByPid(Long pid) { + EmTreeEntity parentEmTree = this.getById(pid); + List sonEmTreeList = this.list(Wrappers.lambdaQuery().likeRight(EmTreeEntity::getPath, parentEmTree.getPath()).ne(EmTreeEntity::getId, pid)); + + // 把List结构数据转换成树结构 + Map> emTreeMap = sonEmTreeList.stream().collect(Collectors.groupingBy(EmTreeEntity::getPid)); + sonEmTreeList.forEach(emTree -> { + emTree.setChildren(emTreeMap.get(emTree.getId())); + }); + List resultList = sonEmTreeList.stream().filter(item -> item.getPid().equals(pid)).collect(Collectors.toList()); + return resultList; + } +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/EmInfoContentVO.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/EmInfoContentVO.java new file mode 100644 index 0000000..1ceb83d --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/EmInfoContentVO.java @@ -0,0 +1,49 @@ +package com.hnac.hzims.equipment.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 设备巡检内容VO + * @author tanghaihao + * @date 2023年07月07日 16:41 + */ +@Data +public class EmInfoContentVO { + + @ApiModelProperty(value = "内容编码") + private String code; + + @ApiModelProperty(value = "内容名称,长度必须为1到128") + private String name; + + @ApiModelProperty(value = "检测类型") + private String checkType; + + @ApiModelProperty(value = "记录类型 0不记录 1仅选择 2仅记值 3选择并记值") + private String recordType; + + @ApiModelProperty(value = "绑定物模型标识") + private String modelSignage; + + @ApiModelProperty(value = "绑定物模型属性标识") + private String attrSignage; + + @ApiModelProperty(value = "绑定物模型属性名称") + private String attrName; + + @ApiModelProperty(value = "设备名称") + private String emName; + + @ApiModelProperty(value = "绑定采集点ID") + private String facDeviceId; + + @ApiModelProperty(value = "绑定采集点名称") + private String facDeviceName; + + @ApiModelProperty(value = "实例采集点ID") + private String instanceFacDeviceId; + + @ApiModelProperty(value = "实例采集点名称") + private String instanceFacDeviceName; +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/EmTreeVO.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/EmTreeVO.java new file mode 100644 index 0000000..d5f727a --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/EmTreeVO.java @@ -0,0 +1,25 @@ +package com.hnac.hzims.equipment.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author tanghaihao + * @date 2023年06月16日 14:39 + */ +@Data +public class EmTreeVO { + @ApiModelProperty(value = "id") + private Long id; + + @ApiModelProperty(value = "父Id") + private Long pid; + + @ApiModelProperty(value = "设备名称") + private String name; + + @ApiModelProperty(value = "子设备") + private List children; +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/SparePartVO.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/SparePartVO.java new file mode 100644 index 0000000..d97b830 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/SparePartVO.java @@ -0,0 +1,32 @@ +package com.hnac.hzims.equipment.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author tanghaihao + * @date 2023年07月13日 17:23 + */ +@Data +public class SparePartVO { + @ApiModelProperty(value = "设备名称") + private String emName; + + @ApiModelProperty(value = "仓库") + private String houseName; + + @ApiModelProperty(value = "物资种类") + private String basicName; + + @ApiModelProperty(value = "物资消耗(件)") + private Integer expend; + + @ApiModelProperty(value = "库存上限") + private Integer upperLimit; + + @ApiModelProperty(value = "库存下限") + private Integer lowerLimit; + + @ApiModelProperty(value = "物资库存(件)") + private Integer stock; +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/ModelController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/ModelController.java index 49be46c..d92f6da 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/ModelController.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/ModelController.java @@ -52,4 +52,10 @@ public class ModelController extends BladeController { return R.data(modelService.getAttr(modelSignage)); } + @GetMapping("/getAllModel") + @ApiOperation("获取所有模型") + @ApiOperationSupport(order = 4) + public R> getAllModel(String name) { + return R.data(modelService.getAllModel(name)); + } } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/server/IModelService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/server/IModelService.java index bbf199c..ab37f13 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/server/IModelService.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/server/IModelService.java @@ -34,5 +34,6 @@ public interface IModelService { List getAttr(String modelSignage); + List getAllModel(String name); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/server/impl/ModelServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/server/impl/ModelServiceImpl.java index 4e881f4..9797edf 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/server/impl/ModelServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/server/impl/ModelServiceImpl.java @@ -48,6 +48,15 @@ public class ModelServiceImpl implements IModelService { } @Override + public List getAllModel(String name) { + R> models = modelClient.getModelsLikeName(name); + Assert.isTrue(models.isSuccess(),() -> { + throw new ServiceException(models.getMsg()); + }); + return models.getData(); + } + + @Override public List mGroupByModel(Long modelGroupId) { R> listR = modelClient.mGroupByModel(modelGroupId); Assert.isTrue(listR.isSuccess(),() -> { diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/util/MemoryPagination.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/util/MemoryPagination.java new file mode 100644 index 0000000..f03edce --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/util/MemoryPagination.java @@ -0,0 +1,39 @@ +package com.hnac.hzims.util; + +import org.springframework.util.CollectionUtils; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author tanghaihao + * @date 2023年07月12日 17:15 + */ +public class MemoryPagination { + /** + * 内存分页 + * + * @param records 待分页的数据 + * @param pageNum 当前页码 + * @param pageSize 每页显示的条数 + * @return 分页之后的数据 + */ + public static List pagination(List records, int pageNum, int pageSize) { + if (CollectionUtils.isEmpty(records)) { + return Collections.emptyList(); + } + int totalCount = records.size() ; + int remainder = totalCount % pageSize; + int pageCount = (remainder > 0) ? totalCount / pageSize + 1 : totalCount / pageSize; + if (remainder == 0) { + return records.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); + } else { + if (pageNum == pageCount) { + return records.stream().skip((pageNum - 1) * pageSize).limit(totalCount).collect(Collectors.toList()); + } else { + return records.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); + } + } + } +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessTaskController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessTaskController.java index 7fad159..2438e11 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessTaskController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessTaskController.java @@ -9,6 +9,7 @@ import com.hnac.hzims.operational.access.dto.OperAccessTaskDTO; import com.hnac.hzims.operational.access.dto.OperAccessTaskFlowDTO; import com.hnac.hzims.operational.access.service.IOperAccessTaskService; import com.hnac.hzims.operational.access.vo.OperAccessTaskVO; +import com.hnac.hzims.operational.access.vo.RepairBillVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -21,8 +22,9 @@ import org.springblade.core.tool.utils.Func; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; +import java.util.List; - /** +/** * 检修任务 * * @author xiashandong @@ -91,4 +93,15 @@ public class OperAccessTaskController extends BladeController { return service.list(req, query); } + + /** + * 获取检修台账 + */ + @ApiLog + @GetMapping("/getRepairBill") + @ApiOperationSupport(order = 60) + @ApiOperation(value = "获取检修台账") + public R> getAccessTaskByEmCode(String emCode, String startTime, String endTime) { + return R.data(service.getRepairBill(emCode, startTime, endTime)); + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.java index dbd3c14..b9ca2b3 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.java @@ -1,6 +1,7 @@ package com.hnac.hzims.operational.access.mapper; import com.baomidou.mybatisplus.annotation.SqlParser; +import com.hnac.hzims.operational.access.vo.RepairBillVO; import org.springblade.core.datascope.annotation.UserDataAuth; import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.operational.access.dto.OperAccessTaskDTO; @@ -36,4 +37,6 @@ public interface OperAccessTaskMapper extends UserDataScopeBaseMapper> getAccessConclusion(Map params); List selectAccessTask(@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("list")List list); + + List getRepairBill(@Param("path") String path, @Param("startTime") String startTime, @Param("endTime") String endTime); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.xml index 2e9a36f..cd1a58f 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.xml +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.xml @@ -128,7 +128,8 @@ select count(hoat.`id`) ACCESS_TASK_COUNT ,count(case when hoat.`status` = 1 then 1 else null end) ACCESS_COMPLETE from `hzims_oper_access_task` hoat - left join (select `EM_CODE`,count(`ID`) findProblemCount from `hzims_oper_phenomenon` where `IS_DELETED` = 0 group by `EM_CODE`) hop on hoat.`EM_CODE` = hop.`EM_CODE` + left join (select `EM_CODE`,count(`ID`) findProblemCount from `hzims_oper_phenomenon` where `IS_DELETED` = 0 + group by `EM_CODE`) hop on hoat.`EM_CODE` = hop.`EM_CODE` hoat.`IS_DELETED` =0 @@ -144,7 +145,7 @@ + + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessTaskService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessTaskService.java index e4f8212..54335f3 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessTaskService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessTaskService.java @@ -7,6 +7,7 @@ import com.hnac.hzims.operational.access.dto.OperAccessTaskDTO; import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; import com.hnac.hzims.operational.access.vo.OperAccessStatisticsVO; import com.hnac.hzims.operational.access.vo.OperAccessTaskVO; +import com.hnac.hzims.operational.access.vo.RepairBillVO; import com.hnac.hzims.operational.report.vo.AccessReportVO; import com.hnac.hzims.vo.SafeCheckStatisticVO; import org.springblade.core.mp.base.BaseService; @@ -74,4 +75,5 @@ public interface IOperAccessTaskService extends BaseService selectPage(Page dbPage, OperAccessTaskEntity result); + List getRepairBill(String emCode, String startTime, String endTime); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessTaskServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessTaskServiceImpl.java index 809791b..0dc61c9 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessTaskServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessTaskServiceImpl.java @@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.hnac.hzims.equipment.entity.EmInfoEntity; +import com.hnac.hzims.equipment.feign.IEmInfoClient; import com.hnac.hzims.message.fegin.IMessagePushClient; import com.hnac.hzims.message.req.PushExtrasReq; import com.hnac.hzims.operational.OperationalConstants; @@ -21,6 +23,7 @@ import com.hnac.hzims.operational.access.entity.*; import com.hnac.hzims.operational.access.mapper.OperAccessTaskMapper; import com.hnac.hzims.operational.access.service.*; import com.hnac.hzims.operational.access.vo.OperAccessTaskVO; +import com.hnac.hzims.operational.access.vo.RepairBillVO; import com.hnac.hzims.operational.access.wrapper.OperAccessTaskDetailWrapper; import com.hnac.hzims.operational.access.wrapper.OperAccessTaskWrapper; import com.hnac.hzims.operational.defect.constants.DefectConstant; @@ -87,6 +90,7 @@ public class OperAccessTaskServiceImpl extends BaseServiceImpl getRepairBill(String emCode, String startTime, String endTime) { + EmInfoEntity emInfo = emInfoClient.getEmInfoByEmCode(emCode).getData(); + List repairBillList = baseMapper.getRepairBill(emInfo.getPath(), startTime, endTime); + return repairBillList; + } + /*** * 根据流程ID和处理人完成任务 * @param comleteTask diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/vo/RepairBillVO.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/vo/RepairBillVO.java new file mode 100644 index 0000000..e85b418 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/vo/RepairBillVO.java @@ -0,0 +1,33 @@ +package com.hnac.hzims.operational.access.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 检修台账VO + * @author tanghaihao + * @date 2023年07月06日 15:58 + */ +@Data +public class RepairBillVO { + + @ApiModelProperty("设备名称") + private String emName; + + @ApiModelProperty("检修等级") + private String gradeCode; + + @ApiModelProperty("检修次数") + private Integer frequency; + + @ApiModelProperty("耗材数量") + private Integer amount; + + @ApiModelProperty("检修工时") + private Double actHours; + + @ApiModelProperty("最近一次检修时间") + private String recently; + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectStatisticsController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectStatisticsController.java index d42c2f9..2c90313 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectStatisticsController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectStatisticsController.java @@ -94,8 +94,10 @@ public class OperDefectStatisticsController extends BladeController { @GetMapping("/getEMStaticstic") @ApiOperationSupport(order = 3) @ApiOperation(value = "获取设备缺陷统计数据", notes = "传入statistics") - public R> getEMStaticstic(@ApiParam(value = "设备编码", required = true) @RequestParam String emCode) { - return R.data(statisticsService.getEMStaticstic(emCode)); + public R> getEMStaticstic(@ApiParam(value = "设备编码", required = true) @RequestParam String emCode, + @ApiParam(value = "开始时间", required = true) @RequestParam String startTime, + @ApiParam(value = "结束时间", required = true) @RequestParam String endTime) { + return R.data(statisticsService.getEMStaticstic(emCode, startTime, endTime)); } /** diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/mapper/OperDefectStatisticsMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/mapper/OperDefectStatisticsMapper.java index e997d09..2a2714e 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/mapper/OperDefectStatisticsMapper.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/mapper/OperDefectStatisticsMapper.java @@ -10,19 +10,20 @@ import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; import java.util.List; /** - * Mapper 接口 + * Mapper 接口 * * @author Chill */ public interface OperDefectStatisticsMapper extends UserDataScopeBaseMapper { - /** - * 获取设备缺陷统计数据 - * @param emCode 设备编码 - //* @param tenantId 租户id - * @return - */ - @UserDataAuth - List getEMStaticstic(@Param("emCode")String emCode); + /** + * 获取设备缺陷统计数据 + * + * @param emCode 设备编码 + * //* @param tenantId 租户id + * @return + */ + @UserDataAuth + List getEMStaticstic(@Param("emCode") String emCode, @Param("startTime") String startTime, @Param("endTime") String endTime); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/mapper/OperDefectStatisticsMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/mapper/OperDefectStatisticsMapper.xml index 72567d1..a996ca2 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/mapper/OperDefectStatisticsMapper.xml +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/mapper/OperDefectStatisticsMapper.xml @@ -7,9 +7,12 @@ SELECT SOURCE_CODE,COUNT(ID) NUM,SUM(CHECK_HOURS) CHECK_HOURS ,`NAME` ,EM_CODE,CREATE_USER,CREATE_DEPT from HZIMS_OPER_DEFECT_STATISTICS WHERE EM_CODE = #{emCode} - + + and PLAN_START_TIME >= #{startTime} + + + and PLAN_START_TIME <= #{endTime} + GROUP BY SOURCE_CODE diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperDefectStatisticsService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperDefectStatisticsService.java index 70a1bc1..12b9695 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperDefectStatisticsService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperDefectStatisticsService.java @@ -21,7 +21,7 @@ public interface IOperDefectStatisticsService extends BaseService getEMStaticstic(String emCode); + List getEMStaticstic(String emCode, String startTime, String endTime); LambdaQueryWrapper getQueryWrapper(OperDefectStatisticsVO statistics); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectStatisticsServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectStatisticsServiceImpl.java index aeaf591..208566e 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectStatisticsServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectStatisticsServiceImpl.java @@ -29,12 +29,12 @@ public class OperDefectStatisticsServiceImpl extends BaseServiceImpl getEMStaticstic(String emCode){ - List re = this.baseMapper.getEMStaticstic(emCode); + public List getEMStaticstic(String emCode, String startTime, String endTime){ + List re = this.baseMapper.getEMStaticstic(emCode, startTime, endTime); for (OperDefectStatisticsDTO dto : re) { dto.setSourceCodeName(DictCache.getValue(dto.getSourceCode(), DefectConstant.SOURCE_CODE_DICT_KEY)); } - return this.baseMapper.getEMStaticstic(emCode); + return re; } @Override diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/controller/WorkTicketInfoController.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/controller/WorkTicketInfoController.java index c9fbc87..b062939 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/controller/WorkTicketInfoController.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/controller/WorkTicketInfoController.java @@ -18,6 +18,7 @@ import com.hnac.hzims.ticket.workTicket.dto.WorkInfoFlowDto; import com.hnac.hzims.ticket.workTicket.dto.WorkTicketInfoDto; import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; import com.hnac.hzims.ticket.workTicket.service.IWorkTicketInfoService; +import com.hnac.hzims.ticket.workTicket.vo.WorkTicketBillVO; import com.hnac.hzims.ticket.workTicket.vo.WorkTicketInfoVO; import io.swagger.annotations.*; import lombok.AllArgsConstructor; @@ -196,5 +197,15 @@ public class WorkTicketInfoController { return R.data(standardWorkVoList); } + /** + * 获取工作票台账 + */ + @ApiLog + @GetMapping("/getWorkTicketBill") + @ApiOperation(value = "获取工作票台账") + public R> getWorkTicketBill(String emCode, String startTime, String endTime) { + return R.data(workTicketInfoService.getWorkTicketBill(emCode, startTime, endTime)); + } + } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/mapper/WorkTicketInfoMapper.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/mapper/WorkTicketInfoMapper.java index bdee63c..8f931f5 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/mapper/WorkTicketInfoMapper.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/mapper/WorkTicketInfoMapper.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Constants; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; +import com.hnac.hzims.ticket.workTicket.vo.WorkTicketBillVO; import com.hnac.hzims.ticket.workTicket.vo.WorkTicketReportStatisticVO; import com.hnac.hzims.vo.SafeCheckStatisticVO; import org.apache.ibatis.annotations.Mapper; @@ -64,4 +65,6 @@ public interface WorkTicketInfoMapper extends UserDataScopeBaseMapper selectPages(Page pageEntity, @Param(Constants.WRAPPER) QueryWrapper queryWrapper); + + List getWorkTicketBill(@Param("path") String path, @Param("startTime") String startTime, @Param("endTime") String endTime); } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/mapper/xml/WorkTicketInfoMapper.xml b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/mapper/xml/WorkTicketInfoMapper.xml index 2daaf81..2d8173d 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/mapper/xml/WorkTicketInfoMapper.xml +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/mapper/xml/WorkTicketInfoMapper.xml @@ -85,4 +85,25 @@ ${ew.customSqlSegment} + diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/IWorkTicketInfoService.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/IWorkTicketInfoService.java index ddaf420..270f7ba 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/IWorkTicketInfoService.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/IWorkTicketInfoService.java @@ -2,12 +2,14 @@ package com.hnac.hzims.ticket.workTicket.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.hnac.hzims.ticket.areamonthly.vo.AreaMonthlyVo; import com.hnac.hzims.ticket.areamonthly.vo.StandardTicketWithAreaVo; import com.hnac.hzims.ticket.areamonthly.vo.StandardWorkVo; import com.hnac.hzims.ticket.twoTicket.vo.process.WorkTicketVo; import com.hnac.hzims.ticket.workTicket.dto.TicketAccessTaskDto; import com.hnac.hzims.ticket.workTicket.dto.WorkTicketInfoDto; import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; +import com.hnac.hzims.ticket.workTicket.vo.WorkTicketBillVO; import com.hnac.hzims.ticket.workTicket.vo.WorkTicketInfoVO; import com.hnac.hzims.vo.SafeCheckStatisticVO; import org.springblade.core.mp.base.BaseService; @@ -164,4 +166,6 @@ public interface IWorkTicketInfoService extends BaseService selectTicketByDeptIdWithTicketType(List createDept, String ticketType, String dateTime); + + List getWorkTicketBill(String emCode, String startTime, String endTime); } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketInfoServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketInfoServiceImpl.java index d153b8d..8e86e7e 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketInfoServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketInfoServiceImpl.java @@ -13,6 +13,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; import com.hnac.hzims.common.logs.utils.StringUtils; +import com.hnac.hzims.equipment.entity.EmInfoEntity; +import com.hnac.hzims.equipment.feign.IEmInfoClient; import com.hnac.hzims.operational.access.constants.AccessConstants; import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; import com.hnac.hzims.operational.access.feign.IOperAccessTaskClient; @@ -106,6 +108,7 @@ public class WorkTicketInfoServiceImpl extends BaseServiceImpl getWorkTicketBill(String emCode, String startTime, String endTime) { + R emInfoEntityR = emInfoClient.getEmInfoByEmCode(emCode); + if (emInfoEntityR.getCode() != 200 || Func.isEmpty(emInfoEntityR.getData())) { + throw new ServiceException("设备信息查询异常"); + } + EmInfoEntity emInfo = emInfoEntityR.getData(); + List workTicketBillList = baseMapper.getWorkTicketBill(emInfo.getPath(), startTime, endTime); + return workTicketBillList; + } } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/vo/WorkTicketBillVO.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/vo/WorkTicketBillVO.java new file mode 100644 index 0000000..0de6fe6 --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/vo/WorkTicketBillVO.java @@ -0,0 +1,30 @@ +package com.hnac.hzims.ticket.workTicket.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 工作票VO + * @author tanghaihao + * @date 2023年07月06日 19:08 + */ +@Data +public class WorkTicketBillVO { + @ApiModelProperty("设备名称") + private String emName; + + @ApiModelProperty("开票种类") + private String type; + + @ApiModelProperty("开票数量") + private Integer payment; + + @ApiModelProperty("完成数量") + private Integer finish; + + @ApiModelProperty("作废数量") + private Double invalid; + + @ApiModelProperty("合格数量") + private String qualified; +}