diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/emParam/dto/ParamBackupsDTO.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/emParam/dto/ParamBackupsDTO.java index 273365b..ab02f79 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/emParam/dto/ParamBackupsDTO.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/emParam/dto/ParamBackupsDTO.java @@ -2,6 +2,8 @@ package com.hnac.hzims.emParam.dto; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; +import com.hnac.hzims.common.invalid.Create; +import com.hnac.hzims.common.invalid.Update; import com.hnac.hzims.emParam.entity.ParamBackupsEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -10,6 +12,8 @@ import lombok.EqualsAndHashCode; import org.springblade.core.tool.utils.DateUtil; import org.springframework.format.annotation.DateTimeFormat; +import javax.validation.Valid; +import javax.validation.constraints.Size; import java.io.Serializable; import java.time.LocalDateTime; import java.util.List; @@ -31,6 +35,8 @@ public class ParamBackupsDTO extends ParamBackupsEntity implements Serializable private LocalDateTime endTime; @ApiModelProperty("参数备份详情列表") + @Valid + @Size(min = 1,groups = {Create.class, Update.class}) private List details; } diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/emParam/dto/ParamBackupsDetailDTO.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/emParam/dto/ParamBackupsDetailDTO.java index 80eb450..43dc0d4 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/emParam/dto/ParamBackupsDetailDTO.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/emParam/dto/ParamBackupsDetailDTO.java @@ -1,10 +1,14 @@ package com.hnac.hzims.emParam.dto; +import com.hnac.hzims.common.invalid.Create; import com.hnac.hzims.emParam.entity.ParamBackupsDetailEntity; import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; import java.io.Serializable; @Data diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/emParam/entity/ParamBackupsDetailEntity.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/emParam/entity/ParamBackupsDetailEntity.java index 7dbd983..2a28a4d 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/emParam/entity/ParamBackupsDetailEntity.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/emParam/entity/ParamBackupsDetailEntity.java @@ -1,6 +1,8 @@ package com.hnac.hzims.emParam.entity; import com.baomidou.mybatisplus.annotation.TableName; +import com.hnac.hzims.common.invalid.Create; +import com.hnac.hzims.common.invalid.Update; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -9,6 +11,9 @@ import org.springblade.core.mp.support.QueryField; import org.springblade.core.mp.support.SqlCondition; import org.springblade.core.tenant.mp.TenantEntity; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; import java.io.Serializable; @Data @@ -21,20 +26,25 @@ public class ParamBackupsDetailEntity extends TenantEntity implements Serializab private Long backupsId; @ApiModelProperty("参数分组") + @NotNull(message = "参数分组不能为空",groups = {Create.class}) private Long modelClassifyId; @ApiModelProperty("参数分组名称") + @NotBlank(message = "参数分组名称不能为空",groups = {Create.class}) private String modelClassifyName; @ApiModelProperty("参数名称") @QueryField(condition = SqlCondition.LIKE) + @NotBlank(message = "参数名称不能为空",groups = {Create.class}) private String name; @ApiModelProperty("标识") @QueryField(condition = SqlCondition.LIKE) + @NotBlank(message = "标识不能为空",groups = {Create.class}) private String signage; @ApiModelProperty("关联设备") + @NotBlank(message = "关联设备不能为空",groups = {Create.class}) private String facDeviceId; @ApiModelProperty("hz3000关联id") @@ -42,6 +52,7 @@ public class ParamBackupsDetailEntity extends TenantEntity implements Serializab @ApiModelProperty("参数标识") @QueryField(condition = SqlCondition.LIKE) +// @NotBlank(message = "参数标识不能为空",groups = {Create.class}) private String parameterTag; @ApiModelProperty("参数名称") @@ -49,15 +60,19 @@ public class ParamBackupsDetailEntity extends TenantEntity implements Serializab private String parameterName; @ApiModelProperty("值") +// @NotBlank(message = "值不能为空",groups = {Create.class}) private String value; @ApiModelProperty("最大值") + @NotBlank(message = "最大值不能为空",groups = {Create.class}) private String maxValue; @ApiModelProperty("最小值") + @NotBlank(message = "最小值不能为空",groups = {Create.class}) private String minValue; @ApiModelProperty("保留小数位") + @NotNull(message = "保留小数位不能为空", groups = {Create.class}) private Integer keepFigures; @ApiModelProperty("描述") diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/emParam/entity/ParamBackupsEntity.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/emParam/entity/ParamBackupsEntity.java index e9de13e..d59b118 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/emParam/entity/ParamBackupsEntity.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/emParam/entity/ParamBackupsEntity.java @@ -2,6 +2,7 @@ package com.hnac.hzims.emParam.entity; import com.baomidou.mybatisplus.annotation.SqlCondition; import com.baomidou.mybatisplus.annotation.TableName; +import com.hnac.hzims.common.invalid.Create; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; @@ -10,6 +11,7 @@ import lombok.EqualsAndHashCode; import org.springblade.core.mp.support.QueryField; import org.springblade.core.tenant.mp.TenantEntity; +import javax.validation.constraints.NotBlank; import java.io.Serializable; @Data @@ -20,14 +22,17 @@ public class ParamBackupsEntity extends TenantEntity implements Serializable { @ApiModelProperty("备份名称") @QueryField(condition = SqlCondition.LIKE) + @NotBlank(message = "备份名称不能为空",groups = {Create.class}) private String name; @ApiModelProperty("站点编号") @QueryField(condition = SqlCondition.EQUAL) + @NotBlank(message = "站点编号不能为空",groups = {Create.class}) private String stationCode; @ApiModelProperty("设备编号") @QueryField(condition = SqlCondition.EQUAL) + @NotBlank(message = "设备编号不能为空",groups = {Create.class}) private String emCode; @ApiModelProperty("是否延迟发布") diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/emParam/vo/ParamBackupsDetailTreeVO.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/emParam/vo/ParamBackupsDetailTreeVO.java new file mode 100644 index 0000000..3d6e8b5 --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/emParam/vo/ParamBackupsDetailTreeVO.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.emParam.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +public class ParamBackupsDetailTreeVO implements Serializable { + + @ApiModelProperty("参数分组") + private Long modelClassifyId; + + @ApiModelProperty("参数分组名称") + private String modelClassifyName; + + @ApiModelProperty("分组下的参数") + private List children; + +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/controller/ParamBackupsController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/controller/ParamBackupsController.java index d27ff95..01c27ae 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/controller/ParamBackupsController.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/controller/ParamBackupsController.java @@ -2,6 +2,7 @@ package com.hnac.hzims.emParam.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.common.invalid.Create; import com.hnac.hzims.common.utils.Condition; import com.hnac.hzims.emParam.dto.ParamBackupsDTO; import com.hnac.hzims.emParam.entity.ParamBackupsEntity; @@ -17,6 +18,7 @@ import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.Func; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @RestController @@ -46,7 +48,7 @@ public class ParamBackupsController extends BladeController { @PostMapping("/save") @ApiOperation("新增") @ApiOperationSupport(order = 3) - public R save(@RequestBody ParamBackupsDTO request) { + public R save(@RequestBody @Validated({Create.class}) ParamBackupsDTO request) { return R.status(paramBackupsService.save(request)); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/controller/ParamBackupsDetailController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/controller/ParamBackupsDetailController.java new file mode 100644 index 0000000..febbb87 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/controller/ParamBackupsDetailController.java @@ -0,0 +1,35 @@ +package com.hnac.hzims.emParam.controller; + + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.emParam.service.IParamBackupsDetailService; +import com.hnac.hzims.emParam.vo.ParamBackupsDetailTreeVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController +@RequestMapping("/emParam/backups/detail") +@AllArgsConstructor +@Api(value = "设备参数备份详情管理",tags = "设备参数备份详情管理") +public class ParamBackupsDetailController extends BladeController { + + private final IParamBackupsDetailService paramBackupsDetailService; + + @GetMapping("/getBackupsParamTree") + @ApiOperation("") + @ApiOperationSupport(order = 1) + public R> getBackupsParamTree(@RequestParam @ApiParam("备份ID") Long backupsId) { + return R.data(paramBackupsDetailService.getBackupsParamTree(backupsId)); + } + +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/service/IParamBackupsDetailService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/service/IParamBackupsDetailService.java index 20b3381..70a5081 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/service/IParamBackupsDetailService.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/service/IParamBackupsDetailService.java @@ -1,8 +1,13 @@ package com.hnac.hzims.emParam.service; import com.hnac.hzims.emParam.entity.ParamBackupsDetailEntity; +import com.hnac.hzims.emParam.vo.ParamBackupsDetailTreeVO; import org.springblade.core.mp.base.BaseService; +import java.util.List; + public interface IParamBackupsDetailService extends BaseService { + List getBackupsParamTree(Long backupsId); + } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/service/impl/ParamBackupsDetailServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/service/impl/ParamBackupsDetailServiceImpl.java index 8ea468c..18fbffa 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/service/impl/ParamBackupsDetailServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/service/impl/ParamBackupsDetailServiceImpl.java @@ -1,18 +1,51 @@ package com.hnac.hzims.emParam.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.collect.Lists; import com.hnac.hzims.emParam.entity.ParamBackupsDetailEntity; import com.hnac.hzims.emParam.mapper.ParamBackupsDetailMapper; import com.hnac.hzims.emParam.service.IParamBackupsDetailService; +import com.hnac.hzims.emParam.vo.ParamBackupsDetailTreeVO; +import com.hnac.hzims.emParam.vo.ParamBackupsDetailVO; +import com.hnac.hzims.emParam.wrapper.ParamBackupsDetailWrapper; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.tool.utils.CollectionUtil; import org.springframework.stereotype.Service; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + @Service @AllArgsConstructor @Slf4j public class ParamBackupsDetailServiceImpl extends BaseServiceImpl implements IParamBackupsDetailService { - + @Override + public List getBackupsParamTree(Long backupsId) { + LambdaQueryWrapper lqw = Wrappers.lambdaQuery().eq(ParamBackupsDetailEntity::getBackupsId, backupsId); + List detailList = this.list(lqw); + if(CollectionUtil.isNotEmpty(detailList)) { + List detailVOList = ParamBackupsDetailWrapper.build().listVO(detailList); + Map> detailGroup = detailVOList.stream().collect(Collectors.groupingBy(d -> new HashMap() {{ + put("modelClassifyId", d.getModelClassifyId()); + put("modelClassifyName", d.getModelClassifyName()); + }})); + List result = Lists.newArrayList(); + detailGroup.forEach((classify,list) -> { + ParamBackupsDetailTreeVO detailTreeVO = new ParamBackupsDetailTreeVO(); + detailTreeVO.setModelClassifyId((Long) classify.get("modelClassifyId")); + detailTreeVO.setModelClassifyName((String) classify.get("modelClassifyName")); + detailTreeVO.setChildren(list); + result.add(detailTreeVO); + }); + return result; + } + return null; + } }