Browse Source

# 设备参数备份分组下发

zhongwei
haungxing 11 months ago
parent
commit
444870de1f
  1. 6
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/emParam/dto/ParamBackupsDTO.java
  2. 4
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/emParam/dto/ParamBackupsDetailDTO.java
  3. 15
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/emParam/entity/ParamBackupsDetailEntity.java
  4. 5
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/emParam/entity/ParamBackupsEntity.java
  5. 21
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/emParam/vo/ParamBackupsDetailTreeVO.java
  6. 4
      hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/controller/ParamBackupsController.java
  7. 35
      hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/controller/ParamBackupsDetailController.java
  8. 5
      hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/service/IParamBackupsDetailService.java
  9. 35
      hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/service/impl/ParamBackupsDetailServiceImpl.java

6
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.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat; 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 com.hnac.hzims.emParam.entity.ParamBackupsEntity;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@ -10,6 +12,8 @@ import lombok.EqualsAndHashCode;
import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.DateUtil;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.Valid;
import javax.validation.constraints.Size;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
@ -31,6 +35,8 @@ public class ParamBackupsDTO extends ParamBackupsEntity implements Serializable
private LocalDateTime endTime; private LocalDateTime endTime;
@ApiModelProperty("参数备份详情列表") @ApiModelProperty("参数备份详情列表")
@Valid
@Size(min = 1,groups = {Create.class, Update.class})
private List<ParamBackupsDetailDTO> details; private List<ParamBackupsDetailDTO> details;
} }

4
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; package com.hnac.hzims.emParam.dto;
import com.hnac.hzims.common.invalid.Create;
import com.hnac.hzims.emParam.entity.ParamBackupsDetailEntity; import com.hnac.hzims.emParam.entity.ParamBackupsDetailEntity;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable; import java.io.Serializable;
@Data @Data

15
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; package com.hnac.hzims.emParam.entity;
import com.baomidou.mybatisplus.annotation.TableName; 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.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; 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.mp.support.SqlCondition;
import org.springblade.core.tenant.mp.TenantEntity; 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; import java.io.Serializable;
@Data @Data
@ -21,20 +26,25 @@ public class ParamBackupsDetailEntity extends TenantEntity implements Serializab
private Long backupsId; private Long backupsId;
@ApiModelProperty("参数分组") @ApiModelProperty("参数分组")
@NotNull(message = "参数分组不能为空",groups = {Create.class})
private Long modelClassifyId; private Long modelClassifyId;
@ApiModelProperty("参数分组名称") @ApiModelProperty("参数分组名称")
@NotBlank(message = "参数分组名称不能为空",groups = {Create.class})
private String modelClassifyName; private String modelClassifyName;
@ApiModelProperty("参数名称") @ApiModelProperty("参数名称")
@QueryField(condition = SqlCondition.LIKE) @QueryField(condition = SqlCondition.LIKE)
@NotBlank(message = "参数名称不能为空",groups = {Create.class})
private String name; private String name;
@ApiModelProperty("标识") @ApiModelProperty("标识")
@QueryField(condition = SqlCondition.LIKE) @QueryField(condition = SqlCondition.LIKE)
@NotBlank(message = "标识不能为空",groups = {Create.class})
private String signage; private String signage;
@ApiModelProperty("关联设备") @ApiModelProperty("关联设备")
@NotBlank(message = "关联设备不能为空",groups = {Create.class})
private String facDeviceId; private String facDeviceId;
@ApiModelProperty("hz3000关联id") @ApiModelProperty("hz3000关联id")
@ -42,6 +52,7 @@ public class ParamBackupsDetailEntity extends TenantEntity implements Serializab
@ApiModelProperty("参数标识") @ApiModelProperty("参数标识")
@QueryField(condition = SqlCondition.LIKE) @QueryField(condition = SqlCondition.LIKE)
// @NotBlank(message = "参数标识不能为空",groups = {Create.class})
private String parameterTag; private String parameterTag;
@ApiModelProperty("参数名称") @ApiModelProperty("参数名称")
@ -49,15 +60,19 @@ public class ParamBackupsDetailEntity extends TenantEntity implements Serializab
private String parameterName; private String parameterName;
@ApiModelProperty("值") @ApiModelProperty("值")
// @NotBlank(message = "值不能为空",groups = {Create.class})
private String value; private String value;
@ApiModelProperty("最大值") @ApiModelProperty("最大值")
@NotBlank(message = "最大值不能为空",groups = {Create.class})
private String maxValue; private String maxValue;
@ApiModelProperty("最小值") @ApiModelProperty("最小值")
@NotBlank(message = "最小值不能为空",groups = {Create.class})
private String minValue; private String minValue;
@ApiModelProperty("保留小数位") @ApiModelProperty("保留小数位")
@NotNull(message = "保留小数位不能为空", groups = {Create.class})
private Integer keepFigures; private Integer keepFigures;
@ApiModelProperty("描述") @ApiModelProperty("描述")

5
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.SqlCondition;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.hnac.hzims.common.invalid.Create;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -10,6 +11,7 @@ import lombok.EqualsAndHashCode;
import org.springblade.core.mp.support.QueryField; import org.springblade.core.mp.support.QueryField;
import org.springblade.core.tenant.mp.TenantEntity; import org.springblade.core.tenant.mp.TenantEntity;
import javax.validation.constraints.NotBlank;
import java.io.Serializable; import java.io.Serializable;
@Data @Data
@ -20,14 +22,17 @@ public class ParamBackupsEntity extends TenantEntity implements Serializable {
@ApiModelProperty("备份名称") @ApiModelProperty("备份名称")
@QueryField(condition = SqlCondition.LIKE) @QueryField(condition = SqlCondition.LIKE)
@NotBlank(message = "备份名称不能为空",groups = {Create.class})
private String name; private String name;
@ApiModelProperty("站点编号") @ApiModelProperty("站点编号")
@QueryField(condition = SqlCondition.EQUAL) @QueryField(condition = SqlCondition.EQUAL)
@NotBlank(message = "站点编号不能为空",groups = {Create.class})
private String stationCode; private String stationCode;
@ApiModelProperty("设备编号") @ApiModelProperty("设备编号")
@QueryField(condition = SqlCondition.EQUAL) @QueryField(condition = SqlCondition.EQUAL)
@NotBlank(message = "设备编号不能为空",groups = {Create.class})
private String emCode; private String emCode;
@ApiModelProperty("是否延迟发布") @ApiModelProperty("是否延迟发布")

21
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<ParamBackupsDetailVO> children;
}

4
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.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; 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.common.utils.Condition;
import com.hnac.hzims.emParam.dto.ParamBackupsDTO; import com.hnac.hzims.emParam.dto.ParamBackupsDTO;
import com.hnac.hzims.emParam.entity.ParamBackupsEntity; 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.api.R;
import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@RestController @RestController
@ -46,7 +48,7 @@ public class ParamBackupsController extends BladeController {
@PostMapping("/save") @PostMapping("/save")
@ApiOperation("新增") @ApiOperation("新增")
@ApiOperationSupport(order = 3) @ApiOperationSupport(order = 3)
public R save(@RequestBody ParamBackupsDTO request) { public R save(@RequestBody @Validated({Create.class}) ParamBackupsDTO request) {
return R.status(paramBackupsService.save(request)); return R.status(paramBackupsService.save(request));
} }

35
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<List<ParamBackupsDetailTreeVO>> getBackupsParamTree(@RequestParam @ApiParam("备份ID") Long backupsId) {
return R.data(paramBackupsDetailService.getBackupsParamTree(backupsId));
}
}

5
hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/service/IParamBackupsDetailService.java

@ -1,8 +1,13 @@
package com.hnac.hzims.emParam.service; package com.hnac.hzims.emParam.service;
import com.hnac.hzims.emParam.entity.ParamBackupsDetailEntity; import com.hnac.hzims.emParam.entity.ParamBackupsDetailEntity;
import com.hnac.hzims.emParam.vo.ParamBackupsDetailTreeVO;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
import java.util.List;
public interface IParamBackupsDetailService extends BaseService<ParamBackupsDetailEntity> { public interface IParamBackupsDetailService extends BaseService<ParamBackupsDetailEntity> {
List<ParamBackupsDetailTreeVO> getBackupsParamTree(Long backupsId);
} }

35
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; 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.entity.ParamBackupsDetailEntity;
import com.hnac.hzims.emParam.mapper.ParamBackupsDetailMapper; import com.hnac.hzims.emParam.mapper.ParamBackupsDetailMapper;
import com.hnac.hzims.emParam.service.IParamBackupsDetailService; 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.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service @Service
@AllArgsConstructor @AllArgsConstructor
@Slf4j @Slf4j
public class ParamBackupsDetailServiceImpl extends BaseServiceImpl<ParamBackupsDetailMapper, ParamBackupsDetailEntity> implements IParamBackupsDetailService { public class ParamBackupsDetailServiceImpl extends BaseServiceImpl<ParamBackupsDetailMapper, ParamBackupsDetailEntity> implements IParamBackupsDetailService {
@Override
public List<ParamBackupsDetailTreeVO> getBackupsParamTree(Long backupsId) {
LambdaQueryWrapper<ParamBackupsDetailEntity> lqw = Wrappers.<ParamBackupsDetailEntity>lambdaQuery().eq(ParamBackupsDetailEntity::getBackupsId, backupsId);
List<ParamBackupsDetailEntity> detailList = this.list(lqw);
if(CollectionUtil.isNotEmpty(detailList)) {
List<ParamBackupsDetailVO> detailVOList = ParamBackupsDetailWrapper.build().listVO(detailList);
Map<HashMap, List<ParamBackupsDetailVO>> detailGroup = detailVOList.stream().collect(Collectors.groupingBy(d -> new HashMap() {{
put("modelClassifyId", d.getModelClassifyId());
put("modelClassifyName", d.getModelClassifyName());
}}));
List<ParamBackupsDetailTreeVO> 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;
}
} }

Loading…
Cancel
Save