tanghaihao
1 year ago
73 changed files with 2064 additions and 62 deletions
@ -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; |
||||
} |
@ -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; |
||||
} |
@ -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<EmTreeEntity> children; |
||||
} |
@ -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; |
||||
|
||||
} |
@ -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; |
||||
} |
@ -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<IPage<EmDefinitionEntity>> getEmDefinitionPage(EmDefinitionEntity emDefinition, Query query) { |
||||
LambdaQueryWrapper<EmDefinitionEntity> 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<EmDefinitionEntity> 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<EmTreeEntity> treeWrapper = new LambdaQueryWrapper(); |
||||
treeWrapper.eq(EmTreeEntity::getDefinitionId, id); |
||||
List<EmTreeEntity> 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<EmDefinitionEntity> 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)); |
||||
} |
||||
} |
@ -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<Map<String, Object>> getEmTreePage(EmTreeEntity emTree, Query query) { |
||||
Map<String, Object> result = new HashMap<>(); |
||||
LambdaQueryWrapper<EmTreeEntity> 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<EmTreeEntity> list = emTreeService.list(wrapper); |
||||
|
||||
List<EmTreeEntity> resultList = new ArrayList<>(); |
||||
if (Func.isNotEmpty(emTree.getPid()) || Func.isNotEmpty(emTree.getSignage()) || Func.isNotEmpty(emTree.getName())) { |
||||
// 把筛选过的数据子设备也查询出来,再拼成树结构
|
||||
for (EmTreeEntity parentEmTree : list) { |
||||
LambdaQueryWrapper<EmTreeEntity> parentWrapper = new LambdaQueryWrapper<>(); |
||||
parentWrapper.likeRight(EmTreeEntity::getPath, parentEmTree.getPath()); |
||||
List<EmTreeEntity> emTreeList = emTreeService.list(parentWrapper); |
||||
Map<Long, List<EmTreeEntity>> 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<Long, List<EmTreeEntity>> 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<EmTreeEntity> wrapper = new LambdaQueryWrapper<>(); |
||||
wrapper.eq(EmTreeEntity::getPid, id); |
||||
List<EmTreeEntity> list = emTreeService.list(wrapper); |
||||
if (Func.isNotEmpty(list)) { |
||||
return R.fail("存在子设备不能删除"); |
||||
} |
||||
LambdaQueryWrapper<EmInfoEntity> infoWrapper = new LambdaQueryWrapper<>(); |
||||
infoWrapper.eq(EmInfoEntity::getTreeId, id); |
||||
List<EmInfoEntity> 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<EmTreeEntity> 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<EmTreeInspectEntity> 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<EmTreeParamEntity> 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<EmTreeBasicEntity> wrapper = new LambdaQueryWrapper(); |
||||
wrapper.eq(EmTreeBasicEntity::getTreeId, treeId); |
||||
return R.data(emTreeBasicService.list(wrapper)); |
||||
} |
||||
|
||||
} |
@ -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 { |
||||
|
||||
|
||||
} |
@ -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<EmTreeIdsDTO> treeIds; |
||||
} |
@ -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; |
||||
|
||||
} |
@ -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<EmTreeInspectEntity> emTreeInspectList; |
||||
|
||||
@ApiModelProperty(value = "设备参数") |
||||
private List<EmTreeParamEntity> emTreeParamList; |
||||
|
||||
@ApiModelProperty(value = "物资ids") |
||||
private List<Long> basicIds; |
||||
} |
@ -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<EmTreeIdsDTO> children; |
||||
} |
@ -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<EmDefinitionEntity> { |
||||
} |
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.hnac.hzims.equipment.mapper.EmDefinitionMapper"> |
||||
|
||||
</mapper> |
@ -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<EmTreeBasicEntity> { |
||||
} |
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.hnac.hzims.equipment.mapper.EmTreeBasicMapper"> |
||||
|
||||
</mapper> |
@ -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<EmTreeInspectEntity> { |
||||
} |
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.hnac.hzims.equipment.mapper.EmTreeInspectMapper"> |
||||
|
||||
</mapper> |
@ -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<EmTreeEntity> { |
||||
} |
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.hnac.hzims.equipment.mapper.EmTreeMapper"> |
||||
|
||||
</mapper> |
@ -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<EmTreeParamEntity> { |
||||
|
||||
} |
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.hnac.hzims.equipment.mapper.EmTreeParamMapper"> |
||||
|
||||
</mapper> |
@ -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<EmDefinitionEntity> { |
||||
} |
@ -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<EmTreeBasicEntity> { |
||||
} |
@ -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<EmTreeInspectEntity> { |
||||
} |
@ -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<EmTreeParamEntity> { |
||||
} |
@ -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<EmTreeEntity> { |
||||
|
||||
Boolean saveEmTrree(EmTreeDTO emTreeDTO); |
||||
|
||||
Boolean updateEmTrree(EmTreeDTO emTreeDTO); |
||||
|
||||
List<EmTreeEntity> getEmTreeByDefinitionId(Long definitionId); |
||||
|
||||
List<EmTreeEntity> getSonEmTreeByPid(Long pid); |
||||
} |
@ -0,0 +1,17 @@
|
||||
package com.hnac.hzims.equipment.service.impl; |
||||
|
||||
import com.hnac.hzims.equipment.entity.EmDefinitionEntity; |
||||
import com.hnac.hzims.equipment.mapper.EmDefinitionMapper; |
||||
import com.hnac.hzims.equipment.service.IEmDefinitionService; |
||||
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 EmDefinitionServiceImpl extends BaseServiceImpl<EmDefinitionMapper, EmDefinitionEntity> implements IEmDefinitionService { |
||||
} |
@ -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<EmTreeBasicMapper, EmTreeBasicEntity> implements IEmTreeBasicService { |
||||
|
||||
|
||||
} |
@ -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<EmTreeInspectMapper, EmTreeInspectEntity> implements IEmTreeInspectService { |
||||
} |
@ -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<EmTreeParamMapper, EmTreeParamEntity> implements IEmTreeParamService { |
||||
} |
@ -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<EmTreeMapper, EmTreeEntity> 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<EmTreeEntity> 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<EmTreeInspectEntity> emTreeInspectList = emTreeDTO.getEmTreeInspectList(); |
||||
for (EmTreeInspectEntity emTreeInspect: emTreeInspectList) { |
||||
emTreeInspect.setTreeId(treeId); |
||||
} |
||||
List<EmTreeParamEntity> emTreeParamList = emTreeDTO.getEmTreeParamList(); |
||||
for (EmTreeParamEntity emTreeParam: emTreeParamList) { |
||||
emTreeParam.setTreeId(treeId); |
||||
} |
||||
List<EmTreeBasicEntity> 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<EmTreeEntity> 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<EmTreeInspectEntity> emTreeInspectList = emTreeDTO.getEmTreeInspectList(); |
||||
if (Func.isNotEmpty(emTreeInspectList)) { |
||||
for (EmTreeInspectEntity emTreeInspect: emTreeInspectList) { |
||||
emTreeInspect.setTreeId(emTree.getId()); |
||||
} |
||||
emTreeInspectService.saveOrUpdateBatch(emTreeInspectList); |
||||
|
||||
List<Long> updateInspectIds = emTreeInspectList.stream().map(EmTreeInspectEntity::getId).collect(Collectors.toList()); |
||||
List<Long> removeInspectIds = new ArrayList<>(); |
||||
LambdaQueryWrapper<EmTreeInspectEntity> inspectWrapper = new LambdaQueryWrapper(); |
||||
inspectWrapper.eq(EmTreeInspectEntity::getTreeId, emTree.getId()); |
||||
List<EmTreeInspectEntity> 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<EmTreeInspectEntity> removeInspectWrapper = new LambdaQueryWrapper<>(); |
||||
removeInspectWrapper.eq(EmTreeInspectEntity::getTreeId, emTreeDTO.getId()); |
||||
emTreeInspectService.remove(removeInspectWrapper); |
||||
} |
||||
// 更新设备参数
|
||||
List<EmTreeParamEntity> emTreeParamList = emTreeDTO.getEmTreeParamList(); |
||||
if (Func.isNotEmpty(emTreeParamList)) { |
||||
for (EmTreeParamEntity emTreeParam : emTreeParamList) { |
||||
emTreeParam.setTreeId(emTree.getId()); |
||||
} |
||||
emTreeParamService.saveOrUpdateBatch(emTreeParamList); |
||||
|
||||
List<Long> updateParamIds = emTreeParamList.stream().map(EmTreeParamEntity::getId).collect(Collectors.toList()); |
||||
List<Long> removeParamIds = new ArrayList<>(); |
||||
LambdaQueryWrapper<EmTreeParamEntity> paramWrapper = new LambdaQueryWrapper(); |
||||
paramWrapper.eq(EmTreeParamEntity::getTreeId, emTree.getId()); |
||||
List<EmTreeParamEntity> 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<EmTreeParamEntity> removeParamWrapper = new LambdaQueryWrapper<>(); |
||||
removeParamWrapper.eq(EmTreeParamEntity::getTreeId, emTreeDTO.getId()); |
||||
emTreeParamService.remove(removeParamWrapper); |
||||
} |
||||
// 更新设备物资
|
||||
List<Long> updateBasicIds = emTreeDTO.getBasicIds(); |
||||
if (Func.isNotEmpty(updateBasicIds)) { |
||||
LambdaQueryWrapper<EmTreeBasicEntity> basicWrapper = new LambdaQueryWrapper(); |
||||
basicWrapper.eq(EmTreeBasicEntity::getTreeId, emTree.getId()); |
||||
List<EmTreeBasicEntity> list = emTreeBasicService.list(basicWrapper); |
||||
List<Long> oldBasicIds = list.stream().map(EmTreeBasicEntity::getBasicId).collect(Collectors.toList()); |
||||
// 添加新增的设备物资
|
||||
List<EmTreeBasicEntity> 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<Long> 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<EmTreeBasicEntity> removeBasicWrapper = new LambdaQueryWrapper<>(); |
||||
removeBasicWrapper.eq(EmTreeBasicEntity::getTreeId, emTree.getId()); |
||||
emTreeBasicService.remove(removeBasicWrapper); |
||||
} |
||||
return this.updateById(emTree); |
||||
} |
||||
|
||||
@Override |
||||
public List<EmTreeEntity> getEmTreeByDefinitionId(Long definitionId) { |
||||
List<EmTreeEntity> emTreeList = this.list(Wrappers.<EmTreeEntity>lambdaQuery().eq(EmTreeEntity::getDefinitionId, definitionId)); |
||||
|
||||
// 把List结构数据转换成树结构
|
||||
Map<Long, List<EmTreeEntity>> emTreeMap = emTreeList.stream().collect(Collectors.groupingBy(EmTreeEntity::getPid)); |
||||
emTreeList.forEach(emTree -> { |
||||
emTree.setChildren(emTreeMap.get(emTree.getId())); |
||||
}); |
||||
List<EmTreeEntity> resultList = emTreeList.stream().filter(item -> item.getPid().equals(0L)).collect(Collectors.toList()); |
||||
return resultList; |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public List<EmTreeEntity> getSonEmTreeByPid(Long pid) { |
||||
EmTreeEntity parentEmTree = this.getById(pid); |
||||
List<EmTreeEntity> sonEmTreeList = this.list(Wrappers.<EmTreeEntity>lambdaQuery().likeRight(EmTreeEntity::getPath, parentEmTree.getPath()).ne(EmTreeEntity::getId, pid)); |
||||
|
||||
// 把List结构数据转换成树结构
|
||||
Map<Long, List<EmTreeEntity>> emTreeMap = sonEmTreeList.stream().collect(Collectors.groupingBy(EmTreeEntity::getPid)); |
||||
sonEmTreeList.forEach(emTree -> { |
||||
emTree.setChildren(emTreeMap.get(emTree.getId())); |
||||
}); |
||||
List<EmTreeEntity> resultList = sonEmTreeList.stream().filter(item -> item.getPid().equals(pid)).collect(Collectors.toList()); |
||||
return resultList; |
||||
} |
||||
} |
@ -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; |
||||
} |
@ -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<EmTreeVO> children; |
||||
} |
@ -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; |
||||
} |
@ -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 <T> List<T> pagination(List<T> 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()); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -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; |
||||
|
||||
} |
@ -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; |
||||
} |
Loading…
Reference in new issue