组态功能和台账功能部分开发
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package com.njcn.csdevice.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author xuyang
|
||||
*/
|
||||
|
||||
@Getter
|
||||
public enum LineBaseEnum {
|
||||
|
||||
/**
|
||||
* 治理终端树结构
|
||||
*/
|
||||
ENGINEERING_LEVEL(0, "工程"),
|
||||
PROJECT_LEVEL(1, "项目"),
|
||||
DEVICE_LEVEL(2, "设备"),
|
||||
LINE_LEVEL(3, "监测点"),
|
||||
INVALID_LEVEL(-1, "非法拓扑等级"),
|
||||
;
|
||||
|
||||
private final Integer code;
|
||||
private final String message;
|
||||
|
||||
LineBaseEnum(Integer code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public static com.njcn.csdevice.enums.LineBaseEnum getLineBaseEnumByCode(Integer code) {
|
||||
return Arrays.stream(com.njcn.csdevice.enums.LineBaseEnum.values())
|
||||
.filter(lineBaseEnum -> lineBaseEnum.getCode().equals(code))
|
||||
.findAny()
|
||||
.orElse(INVALID_LEVEL);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.njcn.csdevice.pojo.param;
|
||||
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import com.njcn.web.constant.ValidMessage;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/5/31 14:54
|
||||
*/
|
||||
@Data
|
||||
public class CsLedgerParam {
|
||||
|
||||
@ApiModelProperty("父Id")
|
||||
@NotBlank(message = "父Id不能为空")
|
||||
private String pid;
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
@NotBlank(message = "名称不能为空")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("等级")
|
||||
@NotNull(message = "等级不能为空")
|
||||
@Range(min = 0, max = 3, message = "参数类型错误")
|
||||
private Integer level;
|
||||
|
||||
@ApiModelProperty("排序")
|
||||
@NotNull(message = "排序不能为空(默认为0)")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
/**
|
||||
* 更新操作实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class Update extends CsLedgerParam {
|
||||
@ApiModelProperty("台账表Id")
|
||||
@NotBlank(message = "台账表Id不能为空")
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = ValidMessage.ID_FORMAT_ERROR)
|
||||
private String id;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.njcn.csdevice.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 详细数据表
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-31
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("cs_data_array")
|
||||
public class CsDataArray extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 数据集表id(cs_data_set)
|
||||
*/
|
||||
private String pid;
|
||||
|
||||
/**
|
||||
* 数据字典表id(ele_epd_pqd的id)
|
||||
*/
|
||||
private String dataId;
|
||||
|
||||
/**
|
||||
* 数据名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 数据别名
|
||||
*/
|
||||
private String anotherName;
|
||||
|
||||
/**
|
||||
* 字典序号
|
||||
*/
|
||||
private Integer idx;
|
||||
|
||||
/**
|
||||
* 排序(数据解析序号)
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 数据统计方法(max、min、avg、cp95)
|
||||
*/
|
||||
private String statMethod;
|
||||
|
||||
/**
|
||||
* 数据类型(Float)
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 相别(A、B、C...)
|
||||
*/
|
||||
private String phase;
|
||||
|
||||
/**
|
||||
* influxdb表名
|
||||
*/
|
||||
private String classId;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.njcn.csdevice.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据集表
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-31
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("cs_data_set")
|
||||
public class CsDataSet extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 装置数据模板表Id(cs_dev_model)
|
||||
*/
|
||||
private String pid;
|
||||
|
||||
/**
|
||||
* 数据集名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 数据集别名
|
||||
*/
|
||||
private String anotherName;
|
||||
|
||||
/**
|
||||
* 字典序号
|
||||
*/
|
||||
private Integer idx;
|
||||
|
||||
/**
|
||||
* 数据类型(Rt:实时数据、Stat:统计数据)
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 周期
|
||||
*/
|
||||
private Integer period;
|
||||
|
||||
/**
|
||||
* 是否存储 0:不存储 1:存储
|
||||
*/
|
||||
private Integer storeFlag;
|
||||
|
||||
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import lombok.Setter;
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("cs_engineering_user")
|
||||
public class CsEngineeringUserPO extends BaseEntity {
|
||||
public class CsEngineeringUserPO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.njcn.csdevice.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 台账表
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-31
|
||||
*/
|
||||
|
||||
@TableName("cs_ledger")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CsLedger extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 父节点(0为根节点)
|
||||
*/
|
||||
private String pid;
|
||||
|
||||
/**
|
||||
* 上层所有节点
|
||||
*/
|
||||
private String pids;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 等级:0-工程名称;1- 项目名称;2-终端;3-监测点;
|
||||
*/
|
||||
private Integer level;
|
||||
|
||||
/**
|
||||
* 排序(默认为0,有特殊排序需要时候人为输入)
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 状态 0-删除;1-正常;默认正常
|
||||
*/
|
||||
private Integer state;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.njcn.csdevice.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/5/29 19:47
|
||||
*/
|
||||
@Data
|
||||
public class CsLedgerVO implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "id",value = "id")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(name = "pid",value = "父id")
|
||||
private String pid;
|
||||
|
||||
@ApiModelProperty(name = "name",value = "名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(name = "sort",value = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(name = "level",value = "等级")
|
||||
private Integer level;
|
||||
|
||||
@ApiModelProperty(name = "comFlag",value = "设备状态")
|
||||
private Integer comFlag;
|
||||
|
||||
@ApiModelProperty(name = "children",value = "子节点")
|
||||
private List<CsLedgerVO> children = new ArrayList<>();
|
||||
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.njcn.csdevice.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/5/29 19:47
|
||||
*/
|
||||
@Data
|
||||
public class LedgerTreeVO implements Serializable {
|
||||
|
||||
private String id;
|
||||
|
||||
private String pid;
|
||||
|
||||
private String name;
|
||||
|
||||
private List<LedgerTreeVO> children;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.njcn.csdevice.controller.Equipment;
|
||||
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 详细数据表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-31
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/csDataArray")
|
||||
@Api(tags = "终端指标集")
|
||||
@AllArgsConstructor
|
||||
public class CsDataArrayController extends BaseController {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.njcn.csdevice.controller.Equipment;
|
||||
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据集表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-31
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/csDataSet")
|
||||
@Api(tags = "终端数据集")
|
||||
@AllArgsConstructor
|
||||
public class CsDataSetController extends BaseController {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
package com.njcn.csdevice.controller.Equipment;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.pojo.vo.LedgerTreeVO;
|
||||
import com.njcn.csdevice.service.IDeviceService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/5/29 19:43
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/device")
|
||||
@Api(tags = "终端台账")
|
||||
@AllArgsConstructor
|
||||
public class DeviceController extends BaseController {
|
||||
|
||||
private final IDeviceService deviceService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/ledgerTree")
|
||||
@ApiOperation("台账树")
|
||||
public HttpResult<LedgerTreeVO> getLedgerTree(){
|
||||
String methodDescribe = getMethodDescribe("getLedgerTree");
|
||||
LedgerTreeVO ledgerTree = deviceService.getLedgerTree();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, ledgerTree, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.njcn.csdevice.controller.ledger;
|
||||
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.pojo.param.CsLedgerParam;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
|
||||
import com.njcn.csdevice.service.CsLinePOService;
|
||||
import com.njcn.csdevice.service.ICsLedgerService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.njcn.web.controller.BaseController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 台账表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-31
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/csLedger")
|
||||
@Slf4j
|
||||
@Api(tags = "治理终端台账")
|
||||
@AllArgsConstructor
|
||||
public class CsLedgerController extends BaseController {
|
||||
|
||||
private final ICsLedgerService csLedgerService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/tree")
|
||||
@ApiOperation("治理终端台账树")
|
||||
public HttpResult<List<CsLedgerVO>> ledgerTree(){
|
||||
String methodDescribe = getMethodDescribe("ledgerTree");
|
||||
List<CsLedgerVO> list = csLedgerService.getLedgerTree();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增台账信息")
|
||||
@ApiImplicitParam(name = "csLedgerParam", value = "新增台账实体", required = true)
|
||||
public HttpResult<String> add(@RequestBody @Validated CsLedgerParam csLedgerParam){
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
csLedgerService.addLedgerTree(csLedgerParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除台账信息")
|
||||
@ApiImplicitParam(name = "id", value = "数据id", required = true)
|
||||
public HttpResult<String> delete(@RequestParam @Validated String id){
|
||||
String methodDescribe = getMethodDescribe("delete");
|
||||
csLedgerService.deleteLedgerTree(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("更新台账信息")
|
||||
@ApiImplicitParam(name = "csLedgerParam", value = "更新台账实体", required = true)
|
||||
public HttpResult<String> update(@RequestBody @Validated CsLedgerParam.Update csLedgerParam){
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
csLedgerService.updateLedgerTree(csLedgerParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/findDevByLineId")
|
||||
@ApiOperation("根据监测点Id查询装置")
|
||||
@ApiImplicitParam(name = "lineId", value = "监测点Id", required = true)
|
||||
public HttpResult<String> findDevByLineId(@RequestParam @Validated String lineId){
|
||||
String methodDescribe = getMethodDescribe("findDevByLineId");
|
||||
String deviceId = csLedgerService.findDevByLineId(lineId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, deviceId, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,10 +39,9 @@ public class CsEngineeringUserController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getEngineeringByUser")
|
||||
@ApiOperation("根据用户获取工程")
|
||||
@ApiImplicitParam(name = "userIndex", value = "用户id", required = true)
|
||||
public HttpResult<List<CsEngineeringPO>> getEngineeringByUser(@RequestParam String userIndex){
|
||||
public HttpResult<List<CsEngineeringPO>> getEngineeringByUser(){
|
||||
String methodDescribe = getMethodDescribe("getEngineeringByUser");
|
||||
List<CsEngineeringPO> list = csEngineeringUserService.getEngineeringByUser(userIndex);
|
||||
List<CsEngineeringPO> list = csEngineeringUserService.getEngineeringByUser();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.csdevice.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsDataArray;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 详细数据表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-31
|
||||
*/
|
||||
public interface CsDataArrayMapper extends BaseMapper<CsDataArray> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.csdevice.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsDataSet;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据集表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-31
|
||||
*/
|
||||
public interface CsDataSetMapper extends BaseMapper<CsDataSet> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.csdevice.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsLedger;
|
||||
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 台账表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-31
|
||||
*/
|
||||
public interface CsLedgerMapper extends BaseMapper<CsLedger> {
|
||||
|
||||
List<CsLedgerVO> getAll();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?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.njcn.csdevice.mapper.CsLedgerMapper">
|
||||
|
||||
<select id="getAll" resultType="CsLedgerVO">
|
||||
select
|
||||
id,pid,name,level,sort
|
||||
from
|
||||
cs_ledger
|
||||
where
|
||||
state = 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -54,5 +54,21 @@ public interface CsDevModelService extends IService<CsDevModelPO>{
|
||||
*/
|
||||
CsDevModelPageVO queryDevModelOne(CsDevModelQueryListParm projectEquipmentQueryParm);
|
||||
|
||||
/**
|
||||
* 根据条件查询模板
|
||||
* @param devType
|
||||
* @param version
|
||||
* @param time
|
||||
* @return
|
||||
*/
|
||||
CsDevModelPO findModel(String devType, String version, String time);
|
||||
|
||||
/**
|
||||
* 根据装置型号查询模板
|
||||
* @param devType 装置型号
|
||||
* @return
|
||||
*/
|
||||
CsDevModelPO findModelByDevType(String devType);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csdevice.pojo.po.CsDataArray;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 详细数据表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-31
|
||||
*/
|
||||
public interface ICsDataArrayService extends IService<CsDataArray> {
|
||||
|
||||
/**
|
||||
* 根据数据集id获取指标数据
|
||||
* @param dataSetId 数据集Id
|
||||
* @return
|
||||
*/
|
||||
List<CsDataArray> findDataArrayByDataSetId(String dataSetId);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csdevice.pojo.po.CsDataSet;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据集表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-31
|
||||
*/
|
||||
public interface ICsDataSetService extends IService<CsDataSet> {
|
||||
|
||||
/**
|
||||
* 根据模板获取数据集
|
||||
* @param modelId 模板id
|
||||
* @return
|
||||
*/
|
||||
List<CsDataSet> findDataSetByModelId(String modelId);
|
||||
|
||||
}
|
||||
@@ -14,6 +14,6 @@ import java.util.List;
|
||||
*/
|
||||
public interface ICsEngineeringUserService {
|
||||
|
||||
List<CsEngineeringPO> getEngineeringByUser(String userIndex);
|
||||
List<CsEngineeringPO> getEngineeringByUser();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
import com.njcn.csdevice.pojo.param.CsLedgerParam;
|
||||
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 台账表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-31
|
||||
*/
|
||||
public interface ICsLedgerService {
|
||||
|
||||
/**
|
||||
* 获取终端台账树
|
||||
* @return
|
||||
*/
|
||||
List<CsLedgerVO> getLedgerTree();
|
||||
|
||||
/**
|
||||
* 新增台账数据
|
||||
* @param csLedgerParam
|
||||
*/
|
||||
void addLedgerTree(CsLedgerParam csLedgerParam);
|
||||
|
||||
/**
|
||||
* 删除台账数据
|
||||
* @param id
|
||||
*/
|
||||
void deleteLedgerTree(String id);
|
||||
|
||||
/**
|
||||
* 更新台账数据
|
||||
* @param csLedgerParam
|
||||
*/
|
||||
void updateLedgerTree(CsLedgerParam.Update csLedgerParam);
|
||||
|
||||
/**
|
||||
* 根据监测点Id查询装置
|
||||
* @param lineId
|
||||
* @return
|
||||
*/
|
||||
String findDevByLineId(String lineId);
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
import com.njcn.csdevice.pojo.vo.LedgerTreeVO;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/5/29 19:53
|
||||
*/
|
||||
|
||||
public interface IDeviceService {
|
||||
|
||||
LedgerTreeVO getLedgerTree();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csdevice.mapper.CsDataArrayMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsDataArray;
|
||||
import com.njcn.csdevice.service.ICsDataArrayService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 详细数据表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-31
|
||||
*/
|
||||
@Service
|
||||
public class CsDataArrayServiceImpl extends ServiceImpl<CsDataArrayMapper, CsDataArray> implements ICsDataArrayService {
|
||||
|
||||
@Override
|
||||
public List<CsDataArray> findDataArrayByDataSetId(String dataSetId) {
|
||||
return this.lambdaQuery().eq(CsDataArray::getPid,dataSetId).list();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csdevice.mapper.CsDataSetMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsDataSet;
|
||||
import com.njcn.csdevice.service.ICsDataSetService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据集表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-31
|
||||
*/
|
||||
@Service
|
||||
public class CsDataSetServiceImpl extends ServiceImpl<CsDataSetMapper, CsDataSet> implements ICsDataSetService {
|
||||
|
||||
@Override
|
||||
public List<CsDataSet> findDataSetByModelId(String modelId) {
|
||||
return this.lambdaQuery().eq(CsDataSet::getPid,modelId).list();
|
||||
}
|
||||
}
|
||||
@@ -75,4 +75,9 @@ public class CsDevModelServiceImpl extends ServiceImpl<CsDevModelMapper, CsDevMo
|
||||
.eq(CsDevModelPO::getStatus,1);
|
||||
return this.baseMapper.selectOne(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CsDevModelPO findModelByDevType(String devType) {
|
||||
return this.lambdaQuery().eq(CsDevModelPO::getDevType,devType).eq(CsDevModelPO::getStatus,1).one();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csdevice.mapper.CsEngineeringUserMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsEngineeringPO;
|
||||
import com.njcn.csdevice.pojo.po.CsEngineeringUserPO;
|
||||
import com.njcn.csdevice.service.CsEngineeringService;
|
||||
import com.njcn.csdevice.service.ICsEngineeringUserService;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -29,11 +32,11 @@ public class CsEngineeringUserServiceImpl extends ServiceImpl<CsEngineeringUserM
|
||||
private final CsEngineeringService csEngineeringService;
|
||||
|
||||
@Override
|
||||
public List<CsEngineeringPO> getEngineeringByUser(String userIndex) {
|
||||
public List<CsEngineeringPO> getEngineeringByUser() {
|
||||
List<CsEngineeringPO> result = new ArrayList<>();
|
||||
List<CsEngineeringUserPO> list = this.lambdaQuery().eq(CsEngineeringUserPO::getUserId, userIndex).list();
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
List<String> engineering = list.stream().map(CsEngineeringUserPO::getEngineeringId).collect(Collectors.toList());
|
||||
List<CsEngineeringUserPO> list = this.lambdaQuery().eq(CsEngineeringUserPO::getUserId, RequestUtil.getUserIndex()).list();
|
||||
List<String> engineering = list.stream().map(CsEngineeringUserPO::getEngineeringId).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(engineering)) {
|
||||
result = csEngineeringService.getEngineerings(engineering);
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.enums.LineBaseEnum;
|
||||
import com.njcn.csdevice.mapper.CsLedgerMapper;
|
||||
import com.njcn.csdevice.pojo.param.CsLedgerParam;
|
||||
import com.njcn.csdevice.pojo.po.CsEngineeringPO;
|
||||
import com.njcn.csdevice.pojo.po.CsLedger;
|
||||
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
|
||||
import com.njcn.csdevice.service.ICsEngineeringUserService;
|
||||
import com.njcn.csdevice.service.ICsLedgerService;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.bouncycastle.cert.ocsp.Req;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 台账表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-31
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> implements ICsLedgerService {
|
||||
|
||||
private final ICsEngineeringUserService csEngineeringUserService;
|
||||
|
||||
@Override
|
||||
public List<CsLedgerVO> getLedgerTree() {
|
||||
List<CsLedgerVO> list = new ArrayList<>();
|
||||
List<CsLedgerVO> engineeringList = new ArrayList<>();
|
||||
List<CsLedgerVO> allList = this.baseMapper.getAll();
|
||||
//fixme 这边先根据登录的用户名称来区分是否展示所有的台账信息
|
||||
if (Objects.equals(RequestUtil.getUsername(),"root") || Objects.equals(RequestUtil.getUsername(),"njcnser")){
|
||||
engineeringList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.ENGINEERING_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
} else {
|
||||
List<CsEngineeringPO> engineering = csEngineeringUserService.getEngineeringByUser();
|
||||
engineeringList = allList.stream().filter(item->engineering.stream().map(CsEngineeringPO::getId).collect(Collectors.toList()).contains(item.getId())).collect(Collectors.toList());
|
||||
}
|
||||
List<CsLedgerVO> projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
List<CsLedgerVO> deviceList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.DEVICE_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
List<CsLedgerVO> lineList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.LINE_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
deviceList.forEach(dev -> dev.setChildren(getChildren(dev, lineList)));
|
||||
projectList.forEach(pro -> pro.setChildren(getChildren(pro, deviceList)));
|
||||
engineeringList.forEach(eng -> eng.setChildren(getChildren(eng, projectList)));
|
||||
CsLedgerVO vo = new CsLedgerVO();
|
||||
vo.setId("9999999");
|
||||
vo.setLevel(0);
|
||||
vo.setName("台账管理");
|
||||
if (CollectionUtil.isNotEmpty(engineeringList)) {
|
||||
vo.setChildren(engineeringList);
|
||||
}
|
||||
list.add(vo);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLedgerTree(CsLedgerParam csLedgerParam) {
|
||||
CsLedger fatherCsLedger = this.lambdaQuery().eq(CsLedger::getId,csLedgerParam.getPid()).one();
|
||||
CsLedger csLedger = new CsLedger();
|
||||
BeanUtils.copyProperties(csLedgerParam,csLedger);
|
||||
csLedger.setState(1);
|
||||
if (Objects.equals(csLedgerParam.getPid(),"9999999")){
|
||||
csLedger.setPid("0");
|
||||
csLedger.setPids("0");
|
||||
} else {
|
||||
csLedger.setPids(fatherCsLedger.getPids() + "," + csLedgerParam.getPid());
|
||||
}
|
||||
this.save(csLedger);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteLedgerTree(String id) {
|
||||
CsLedger csLedger = this.lambdaQuery().eq(CsLedger::getId,id).one();
|
||||
csLedger.setState(0);
|
||||
this.updateById(csLedger);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLedgerTree(CsLedgerParam.Update csLedgerParam) {
|
||||
CsLedger csLedger = new CsLedger();
|
||||
BeanUtil.copyProperties(csLedgerParam, csLedger);
|
||||
this.updateById(csLedger);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String findDevByLineId(String lineId) {
|
||||
String deviceId = null;
|
||||
CsLedger csLedger = this.lambdaQuery().eq(CsLedger::getId,lineId).eq(CsLedger::getState,1).one();
|
||||
if (!Objects.isNull(csLedger)){
|
||||
deviceId = csLedger.getPid();
|
||||
}
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子节点
|
||||
*/
|
||||
public List<CsLedgerVO> getChildren(CsLedgerVO item, List<CsLedgerVO> all) {
|
||||
return all.stream().filter(allItem -> allItem.getPid().equals(item.getId())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import com.njcn.csdevice.pojo.po.AppProjectPO;
|
||||
import com.njcn.csdevice.pojo.po.CsEngineeringPO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.csdevice.pojo.po.CsProjectEquipmentPO;
|
||||
import com.njcn.csdevice.pojo.vo.LedgerTreeVO;
|
||||
import com.njcn.csdevice.service.*;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/5/29 19:53
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class DeviceServiceImpl implements IDeviceService {
|
||||
|
||||
private final ICsEngineeringUserService csEngineeringUserService;
|
||||
|
||||
private final AppProjectService appProjectService;
|
||||
|
||||
private final CsProjectEquipmentService csProjectEquipmentService;
|
||||
|
||||
private final CsLinePOService csLinePOService;
|
||||
|
||||
|
||||
@Override
|
||||
public LedgerTreeVO getLedgerTree() {
|
||||
List<AppProjectPO> list1;
|
||||
List<CsProjectEquipmentPO> list2;
|
||||
List<CsLinePO> list3;
|
||||
List<LedgerTreeVO> children = new ArrayList<>();
|
||||
LedgerTreeVO ledgerTreeVo = new LedgerTreeVO();
|
||||
ledgerTreeVo.setId("0");
|
||||
ledgerTreeVo.setName("台账管理");
|
||||
String userIndex = RequestUtil.getUserIndex();
|
||||
//获取工程
|
||||
List<CsEngineeringPO> list = csEngineeringUserService.getEngineeringByUser(userIndex);
|
||||
if (!CollectionUtils.isEmpty(list)){
|
||||
list.forEach(item->{
|
||||
LedgerTreeVO vo = new LedgerTreeVO();
|
||||
BeanUtils.copyProperties(item,vo);
|
||||
children.add(vo);
|
||||
});
|
||||
ledgerTreeVo.setChildren(children);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// if (!CollectionUtils.isEmpty(list)){
|
||||
// List<String> engineeringList = list.stream().map(CsEngineeringPO::getId).collect(Collectors.toList());
|
||||
// //获取项目
|
||||
// list1 = appProjectService.getProjectByEngineering(engineeringList);
|
||||
// if (!CollectionUtils.isEmpty(list1)){
|
||||
// List<String> projectList = list1.stream().map(AppProjectPO::getId).collect(Collectors.toList());
|
||||
// //获取装置
|
||||
// list2 = csProjectEquipmentService.getDeviceByProject(projectList);
|
||||
// if (!CollectionUtils.isEmpty(list2)){
|
||||
// List<String> deviceList = list2.stream().map(CsProjectEquipmentPO::getId).collect(Collectors.toList());
|
||||
// //获取监测点
|
||||
// list3 = csLinePOService.getLineByDev(deviceList);
|
||||
// list2.stream().map(l2 -> list3.stream().filter(l3 -> Objects.equals(l2.getEquipmentId(), l3.getDevId())).findAny().map(m -> {
|
||||
// LedgerTreeVO vo1 = new LedgerTreeVO();
|
||||
// vo1.setId(m.getLineId());
|
||||
// vo1.setPid(m.getDevId());
|
||||
// vo1.setName(m.getName());
|
||||
// test.add(vo1);
|
||||
// LedgerTreeVO vo = new LedgerTreeVO();
|
||||
// vo.setId(l2.getEquipmentId());
|
||||
// vo.setPid(l2.getProjectId());
|
||||
// vo.setName(l2.getEquipmentId());
|
||||
// vo.setChildren(test);
|
||||
// return vo;
|
||||
// })).collect(Collectors.toList());
|
||||
//
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
return ledgerTreeVo;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user