设备类型相关接口

This commit is contained in:
caozehui
2025-02-11 09:01:43 +08:00
parent 1e64382a98
commit 5b0cdb5c18
24 changed files with 612 additions and 27 deletions

View File

@@ -26,7 +26,7 @@ import com.njcn.gather.device.pojo.vo.PreDetection;
import com.njcn.gather.device.service.IPqDevService; import com.njcn.gather.device.service.IPqDevService;
import com.njcn.gather.system.dictionary.pojo.po.DictData; import com.njcn.gather.system.dictionary.pojo.po.DictData;
import com.njcn.gather.system.dictionary.service.IDictDataService; import com.njcn.gather.system.dictionary.service.IDictDataService;
import com.njcn.gather.type.entity.DevType; import com.njcn.gather.type.pojo.po.DevType;
import com.njcn.gather.type.service.IDevTypeService; import com.njcn.gather.type.service.IDevTypeService;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.ExcelUtil; import com.njcn.web.utils.ExcelUtil;

View File

@@ -68,8 +68,6 @@ public interface DevValidMessage {
String DEV_TYPE_FORMAT_ERROR = "设备类型格式错误请检查devType参数"; String DEV_TYPE_FORMAT_ERROR = "设备类型格式错误请检查devType参数";
String DEV_CHNS_RANGE_ERROR = "设备通道系数错误请检查devChns参数";
String MANUFACTURER_FORMAT_ERROR = "设备厂家格式错误请检查manufacturer参数"; String MANUFACTURER_FORMAT_ERROR = "设备厂家格式错误请检查manufacturer参数";
String PROTOCOL_FORMAT_ERROR = "通讯协议格式错误请检查protocol参数"; String PROTOCOL_FORMAT_ERROR = "通讯协议格式错误请检查protocol参数";

View File

@@ -35,7 +35,7 @@ import com.njcn.gather.system.dictionary.pojo.po.DictData;
import com.njcn.gather.system.dictionary.pojo.po.DictType; import com.njcn.gather.system.dictionary.pojo.po.DictType;
import com.njcn.gather.system.dictionary.service.IDictDataService; import com.njcn.gather.system.dictionary.service.IDictDataService;
import com.njcn.gather.system.dictionary.service.IDictTypeService; import com.njcn.gather.system.dictionary.service.IDictTypeService;
import com.njcn.gather.type.entity.DevType; import com.njcn.gather.type.pojo.po.DevType;
import com.njcn.gather.type.service.IDevTypeService; import com.njcn.gather.type.service.IDevTypeService;
import com.njcn.gather.util.DeviceUtil; import com.njcn.gather.util.DeviceUtil;
import com.njcn.web.factory.PageFactory; import com.njcn.web.factory.PageFactory;

View File

@@ -0,0 +1,113 @@
package com.njcn.gather.icd.controller;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
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.LogUtil;
import com.njcn.gather.icd.pojo.param.PqIcdPathParam;
import com.njcn.gather.icd.pojo.po.PqIcdPath;
import com.njcn.gather.icd.service.IPqIcdPathService;
import com.njcn.gather.type.pojo.param.DevTypeParam;
import com.njcn.gather.type.pojo.po.DevType;
import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.HttpResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
*
* @author caozehui
* @date 2025-02-10
*/
@Slf4j
@Api(tags="icd管理")
@RestController
@RequestMapping("/icd")
@RequiredArgsConstructor
public class PqIcdPathController extends BaseController{
private final IPqIcdPathService pqIcdPathService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/listAll")
@ApiOperation("获取所有icd")
public HttpResult<List<PqIcdPath>> listAll() {
String methodDescribe = getMethodDescribe("listAll");
List<PqIcdPath> result = pqIcdPathService.listAll();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo
@PostMapping("/list")
@ApiOperation("分页查询icd")
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<Page<PqIcdPath>> list(@RequestBody @Validated PqIcdPathParam.QueryParam param) {
String methodDescribe = getMethodDescribe("list");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
Page<PqIcdPath> result = pqIcdPathService.listIcd(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
@PostMapping("/add")
@ApiOperation("新增icd")
@ApiImplicitParam(name = "param", value = "icd新增参数", required = true)
public HttpResult<String> add(@RequestBody @Validated PqIcdPathParam param) {
String methodDescribe = getMethodDescribe("add");
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param);
boolean result = pqIcdPathService.addIcd(param);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
}
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
@PostMapping("/update")
@ApiOperation("修改icd")
@ApiImplicitParam(name = "param", value = "icd修改参数", required = true)
public HttpResult<String> update(@RequestBody @Validated PqIcdPathParam.UpdateParam param) {
String methodDescribe = getMethodDescribe("update");
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, param);
boolean result = pqIcdPathService.updateIcd(param);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
}
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DELETE)
@PostMapping("/delete")
@ApiOperation("删除icd")
@ApiImplicitParam(name = "ids", value = "icd的id列表", required = true)
public HttpResult<String> delete(@RequestBody List<String> ids) {
String methodDescribe = getMethodDescribe("delete");
LogUtil.njcnDebug(log, "{},删除数据为:{}", methodDescribe, String.join(StrUtil.COMMA, ids));
boolean result = pqIcdPathService.deleteIcd(ids);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
}
}
}

View File

@@ -0,0 +1,13 @@
package com.njcn.gather.icd.mapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.njcn.gather.icd.pojo.po.PqIcdPath;
/**
* @author caozehui
* @date 2025-02-10
*/
public interface PqIcdPathMapper extends MPJBaseMapper<PqIcdPath> {
}

View File

@@ -0,0 +1,7 @@
<?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.gather.icd.mapper.PqIcdPathMapper">
</mapper>

View File

@@ -0,0 +1,12 @@
package com.njcn.gather.icd.pojo.constant;
/**
* @author caozehui
* @data 2025-02-11
*/
public interface PqIcdPathValidMessage {
String ID_NOT_BLANK = "id不能为空请检查id参数";
String ID_FORMAT_ERROR = "id格式错误请检查id参数";
String NAME_NOT_BLANK = "名称不能为空";
String PATH_NOT_BLANK = "icd存储路径不能为空";
}

View File

@@ -0,0 +1,50 @@
package com.njcn.gather.icd.pojo.param;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.icd.pojo.constant.PqIcdPathValidMessage;
import com.njcn.gather.type.pojo.constant.DevTypeValidMessage;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
/**
* @author caozehui
* @data 2025-02-11
*/
@Data
public class PqIcdPathParam {
@ApiModelProperty(value = "名称", required = true)
@NotBlank(message = PqIcdPathValidMessage.NAME_NOT_BLANK)
private String name;
@ApiModelProperty(value = "存储路径", required = true)
@NotBlank(message = PqIcdPathValidMessage.PATH_NOT_BLANK)
private String path;
/**
* 分页查询实体
*/
@Data
@EqualsAndHashCode(callSuper = true)
public static class QueryParam extends BaseParam {
@ApiModelProperty(value = "名称", required = true)
private String name;
}
/**
* 更新参数
*/
@Data
@EqualsAndHashCode(callSuper = true)
public static class UpdateParam extends PqIcdPathParam {
@ApiModelProperty(value = "id", required = true)
@NotBlank(message = PqIcdPathValidMessage.ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = PqIcdPathValidMessage.ID_FORMAT_ERROR)
private String id;
}
}

View File

@@ -0,0 +1,36 @@
package com.njcn.gather.icd.pojo.po;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.mybatisplus.bo.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author caozehui
* @date 2025-02-10
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("pq_icd_path")
public class PqIcdPath extends BaseEntity implements Serializable {
private static final long serialVersionUID = -93625299788915474L;
/**
* icdID
*/
private String id;
/**
* icd名称
*/
private String name;
/**
* icd存储地址
*/
private String path;
}

View File

@@ -0,0 +1,25 @@
package com.njcn.gather.icd.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.gather.icd.pojo.param.PqIcdPathParam;
import com.njcn.gather.icd.pojo.po.PqIcdPath;
import java.util.List;
/**
* @author caozehui
* @date 2025-02-10
*/
public interface IPqIcdPathService extends IService<PqIcdPath> {
List<PqIcdPath> listAll();
Page<PqIcdPath> listIcd(PqIcdPathParam.QueryParam param);
boolean addIcd(PqIcdPathParam param);
boolean updateIcd(PqIcdPathParam.UpdateParam param);
boolean deleteIcd(List<String> ids);
}

View File

@@ -0,0 +1,48 @@
package com.njcn.gather.icd.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.gather.icd.pojo.param.PqIcdPathParam;
import com.njcn.gather.icd.pojo.po.PqIcdPath;
import com.njcn.gather.icd.mapper.PqIcdPathMapper;
import com.njcn.gather.icd.service.IPqIcdPathService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author caozehui
* @date 2025-02-10
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath> implements IPqIcdPathService {
@Override
public List<PqIcdPath> listAll() {
return null;
}
@Override
public Page<PqIcdPath> listIcd(PqIcdPathParam.QueryParam param) {
return null;
}
@Override
public boolean addIcd(PqIcdPathParam param) {
return false;
}
@Override
public boolean updateIcd(PqIcdPathParam.UpdateParam param) {
return false;
}
@Override
public boolean deleteIcd(List<String> ids) {
return false;
}
}

View File

@@ -65,7 +65,7 @@ public class AdPlanController extends BaseController {
@OperateInfo(operateType = OperateType.ADD) @OperateInfo(operateType = OperateType.ADD)
@PostMapping("/add") @PostMapping("/add")
@ApiOperation("新增检测计划") @ApiOperation("新增检测计划")
@ApiImplicitParam(name = "pqDevParam", value = "检测计划", required = true) @ApiImplicitParam(name = "param", value = "检测计划", required = true)
public HttpResult<Object> add(@RequestBody @Validated AdPlanParam param) { public HttpResult<Object> add(@RequestBody @Validated AdPlanParam param) {
String methodDescribe = getMethodDescribe("add"); String methodDescribe = getMethodDescribe("add");
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param); LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param);

View File

@@ -112,9 +112,6 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
adPlan.setTestState(CheckStateEnum.UNCHECKED.getValue()); adPlan.setTestState(CheckStateEnum.UNCHECKED.getValue());
adPlan.setReportState(PlanReportStateEnum.REPORT_STATE_NOT_GENERATED.getValue()); adPlan.setReportState(PlanReportStateEnum.REPORT_STATE_NOT_GENERATED.getValue());
adPlan.setResult(CheckResultEnum.UNCHECKED.getValue()); adPlan.setResult(CheckResultEnum.UNCHECKED.getValue());
// todo code 生成
// 日期生成 MMdd
//String dateStr = DateFormatUtils.format(new Date(), "MMdd");
adPlan.setCode(this.generateCode()); adPlan.setCode(this.generateCode());
// 新增检测计划、检测源关联 // 新增检测计划、检测源关联

View File

@@ -28,7 +28,7 @@ import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
import com.njcn.gather.storage.service.AdHarmonicService; import com.njcn.gather.storage.service.AdHarmonicService;
import com.njcn.gather.storage.service.AdNonHarmonicService; import com.njcn.gather.storage.service.AdNonHarmonicService;
import com.njcn.gather.system.dictionary.service.IDictDataService; import com.njcn.gather.system.dictionary.service.IDictDataService;
import com.njcn.gather.type.entity.DevType; import com.njcn.gather.type.pojo.po.DevType;
import com.njcn.gather.type.service.IDevTypeService; import com.njcn.gather.type.service.IDevTypeService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;

View File

@@ -22,7 +22,7 @@ import com.njcn.gather.script.service.IPqScriptCheckDataService;
import com.njcn.gather.script.service.IPqScriptDtlsService; import com.njcn.gather.script.service.IPqScriptDtlsService;
import com.njcn.gather.script.util.ScriptDtlsDesc; import com.njcn.gather.script.util.ScriptDtlsDesc;
import com.njcn.gather.system.dictionary.pojo.po.DictTree; import com.njcn.gather.system.dictionary.pojo.po.DictTree;
import com.njcn.gather.type.entity.DevType; import com.njcn.gather.type.pojo.po.DevType;
import com.njcn.gather.type.service.IDevTypeService; import com.njcn.gather.type.service.IDevTypeService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;

View File

@@ -18,7 +18,7 @@ import com.njcn.gather.source.pojo.po.PqSource;
import com.njcn.gather.source.pojo.po.SourceInitialize; import com.njcn.gather.source.pojo.po.SourceInitialize;
import com.njcn.gather.source.pojo.po.SourceParam; import com.njcn.gather.source.pojo.po.SourceParam;
import com.njcn.gather.source.service.IPqSourceService; import com.njcn.gather.source.service.IPqSourceService;
import com.njcn.gather.type.entity.DevType; import com.njcn.gather.type.pojo.po.DevType;
import com.njcn.gather.type.service.IDevTypeService; import com.njcn.gather.type.service.IDevTypeService;
import com.njcn.gather.system.dictionary.pojo.po.DictData; import com.njcn.gather.system.dictionary.pojo.po.DictData;
import com.njcn.gather.system.dictionary.service.IDictDataService; import com.njcn.gather.system.dictionary.service.IDictDataService;

View File

@@ -1,29 +1,35 @@
package com.njcn.gather.type.controller; package com.njcn.gather.type.controller;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.enums.common.LogEnum; import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.gather.type.entity.DevType; import com.njcn.common.utils.LogUtil;
import com.njcn.gather.type.pojo.param.DevTypeParam;
import com.njcn.gather.type.pojo.po.DevType;
import com.njcn.gather.type.service.IDevTypeService; import com.njcn.gather.type.service.IDevTypeService;
import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.HttpResultUtil; import com.njcn.web.utils.HttpResultUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.njcn.web.controller.BaseController;
import java.util.List; import java.util.List;
/** /**
* <p> * <p>
* 前端控制器 * 前端控制器
* </p> * </p>
* *
* @author hongawen * @author hongawen
@@ -39,20 +45,71 @@ public class DevTypeController extends BaseController {
private final IDevTypeService devTypeService; private final IDevTypeService devTypeService;
/** @OperateInfo(info = LogEnum.BUSINESS_COMMON)
* 获取所有有效设备类型集合 @PostMapping("/listAll")
*/ @ApiOperation("获取所有设备类型")
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@PostMapping("/list")
@ApiOperation("获取所有有效设备类型集合")
public HttpResult<List<DevType>> listAll() { public HttpResult<List<DevType>> listAll() {
String methodDescribe = getMethodDescribe("listAll"); String methodDescribe = getMethodDescribe("listAll");
List<DevType> result = devTypeService.listAll(); List<DevType> result = devTypeService.listAll();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
} }
@OperateInfo
@PostMapping("/list")
@ApiOperation("分页查询设备类型")
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
public HttpResult<Page<DevType>> list(@RequestBody @Validated DevTypeParam.QueryParam queryParam) {
String methodDescribe = getMethodDescribe("list");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
Page<DevType> result = devTypeService.listDevType(queryParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
@PostMapping("/add")
@ApiOperation("新增设备类型")
@ApiImplicitParam(name = "devTypeParam", value = "设备类型", required = true)
public HttpResult<String> add(@RequestBody @Validated DevTypeParam devTypeParam) {
String methodDescribe = getMethodDescribe("add");
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, devTypeParam);
boolean result = devTypeService.addDevType(devTypeParam);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
}
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
@PostMapping("/update")
@ApiOperation("修改设备类型")
@ApiImplicitParam(name = "devTypeParam", value = "设备类型", required = true)
public HttpResult<String> update(@RequestBody @Validated DevTypeParam.UpdateParam updateParam) {
String methodDescribe = getMethodDescribe("update");
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, updateParam);
boolean result = devTypeService.updateDevType(updateParam);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
}
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DELETE)
@PostMapping("/delete")
@ApiOperation("删除设备类型")
@ApiImplicitParam(name = "ids", value = "设备类型id列表", required = true)
public HttpResult<String> delete(@RequestBody List<String> ids) {
String methodDescribe = getMethodDescribe("delete");
LogUtil.njcnDebug(log, "{},删除数据为:{}", methodDescribe, String.join(StrUtil.COMMA, ids));
boolean result = devTypeService.deleteDevType(ids);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
}
}
} }

View File

@@ -2,7 +2,7 @@ package com.njcn.gather.type.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.gather.type.entity.DevType; import com.njcn.gather.type.pojo.po.DevType;
/** /**
* <p> * <p>

View File

@@ -0,0 +1,17 @@
package com.njcn.gather.type.pojo.constant;
/**
* @author caozehui
* @data 2025-02-10
*/
public interface DevTypeValidMessage {
String ID_NOT_BLANK = "id不能为空请检查id参数";
String ID_FORMAT_ERROR = "id格式错误请检查id参数";
String NAME_NOT_BLANK = "名称不能为空";
String ICD_NOT_BLANK = "ICD不能为空";
String POWER_NOT_BLANK = "工作电源不能为空";
String VOLT_NOT_BLANK = "额定电压不能为空";
String CURR_NOT_BLANK = "额定电流不能为空";
String CHNS_NOT_BLANK = "通道数不能为空";
String DEV_CHNS_RANGE_ERROR = "通道数格式错误";
}

View File

@@ -0,0 +1,22 @@
package com.njcn.gather.type.pojo.enums;
/**
* @author caozehui
* @data 2025-02-10
*/
import lombok.Getter;
@Getter
public enum DevTypeResponseEnum {
DEV_TYPE_REPEAT("A003007", "设备类型名称重复");
private final String code;
private final String message;
DevTypeResponseEnum(String code, String message) {
this.message = message;
this.code = code;
}
}

View File

@@ -0,0 +1,73 @@
package com.njcn.gather.type.pojo.param;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.device.pojo.constant.DevValidMessage;
import com.njcn.gather.type.pojo.constant.DevTypeValidMessage;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
/**
* @author caozehui
* @data 2025-02-10
*/
@Data
public class DevTypeParam {
@ApiModelProperty(value = "名称", required = true)
@NotBlank(message = DevTypeValidMessage.NAME_NOT_BLANK)
private String name;
@ApiModelProperty(value = "设备关联的ICD", required = true)
@NotBlank(message = DevTypeValidMessage.ICD_NOT_BLANK)
private String icd;
@ApiModelProperty(value = "工作电源", required = true)
@NotBlank(message = DevTypeValidMessage.POWER_NOT_BLANK)
private String power;
@ApiModelProperty(value = "额定电压", required = true)
@NotNull(message = DevTypeValidMessage.VOLT_NOT_BLANK)
private Double devVolt;
@ApiModelProperty(value = "额定电流", required = true)
@NotNull(message = DevTypeValidMessage.CURR_NOT_BLANK)
private Double devCurr;
@ApiModelProperty(value = "通道数", required = true)
@NotNull(message = DevTypeValidMessage.CHNS_NOT_BLANK)
@Min(value = 1, message = DevTypeValidMessage.DEV_CHNS_RANGE_ERROR)
private Integer devChns;
@ApiModelProperty(value = "报告模板")
// @NotBlank(message = "报告模板不能为空")
private String reportName;
/**
* 分页查询实体
*/
@Data
@EqualsAndHashCode(callSuper = true)
public static class QueryParam extends BaseParam {
@ApiModelProperty(value = "名称", required = true)
private String name;
}
/**
* 更新参数
*/
@Data
@EqualsAndHashCode(callSuper = true)
public static class UpdateParam extends DevTypeParam {
@ApiModelProperty(value = "id", required = true)
@NotBlank(message = DevTypeValidMessage.ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevTypeValidMessage.ID_FORMAT_ERROR)
private String id;
}
}

View File

@@ -1,5 +1,6 @@
package com.njcn.gather.type.entity; package com.njcn.gather.type.pojo.po;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.mybatisplus.bo.BaseEntity; import com.njcn.db.mybatisplus.bo.BaseEntity;
@@ -53,6 +54,12 @@ public class DevType extends BaseEntity {
*/ */
private Integer devChns; private Integer devChns;
/**
* 报告模板
*/
@TableField("report_name")
private String reportName;
/** /**
* 状态0-删除 1-正常 * 状态0-删除 1-正常
*/ */

View File

@@ -1,13 +1,15 @@
package com.njcn.gather.type.service; package com.njcn.gather.type.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.gather.type.entity.DevType; import com.njcn.gather.type.pojo.param.DevTypeParam;
import com.njcn.gather.type.pojo.po.DevType;
import java.util.List; import java.util.List;
/** /**
* <p> * <p>
* 服务类 * 服务类
* </p> * </p>
* *
* @author hongawen * @author hongawen
@@ -15,11 +17,66 @@ import java.util.List;
*/ */
public interface IDevTypeService extends IService<DevType> { public interface IDevTypeService extends IService<DevType> {
/**
* 查询所有设备类型
*
* @return 所有设备类型
*/
List<DevType> listAll(); List<DevType> listAll();
/**
* 根据名称查询设备类型
*
* @param name 名称
* @return
*/
DevType getByName(String name); DevType getByName(String name);
/**
* 根据id查询设备类型
*
* @param id id
* @return
*/
DevType getById(String id); DevType getById(String id);
/**
* 根据id列表查询设备类型
*
* @param ids id列表
* @return
*/
List<DevType> listByIds(List<String> ids); List<DevType> listByIds(List<String> ids);
/**
* 分页查询设备类型
*
* @param queryParam 查询参数
* @return 分页查询结果
*/
Page<DevType> listDevType(DevTypeParam.QueryParam queryParam);
/**
* 新增设备类型
*
* @param addParam 设备类型数据
* @return 成功返回true失败返回false
*/
boolean addDevType(DevTypeParam addParam);
/**
* 修改设备类型
*
* @param updateParam 设备类型数据
* @return 成功返回true失败返回false
*/
boolean updateDevType(DevTypeParam.UpdateParam updateParam);
/**
* 批量删除设备类型
*
* @param ids id列表
* @return 成功返回true失败返回false
*/
boolean deleteDevType(List<String> ids);
} }

View File

@@ -1,18 +1,24 @@
package com.njcn.gather.type.service.impl; package com.njcn.gather.type.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.gather.type.entity.DevType; import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.gather.type.mapper.DevTypeMapper; import com.njcn.gather.type.mapper.DevTypeMapper;
import com.njcn.gather.type.pojo.enums.DevTypeResponseEnum;
import com.njcn.gather.type.pojo.param.DevTypeParam;
import com.njcn.gather.type.pojo.po.DevType;
import com.njcn.gather.type.service.IDevTypeService; import com.njcn.gather.type.service.IDevTypeService;
import com.njcn.web.factory.PageFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
/** /**
* <p> * <p>
* 服务实现类 * 服务实现类
* </p> * </p>
* *
* @author hongawen * @author hongawen
@@ -43,4 +49,51 @@ public class DevTypeServiceImpl extends ServiceImpl<DevTypeMapper, DevType> impl
public List<DevType> listByIds(List<String> ids) { public List<DevType> listByIds(List<String> ids) {
return this.lambdaQuery().in(DevType::getId, ids).eq(DevType::getState, DataStateEnum.ENABLE.getCode()).list(); return this.lambdaQuery().in(DevType::getId, ids).eq(DevType::getState, DataStateEnum.ENABLE.getCode()).list();
} }
@Override
public Page<DevType> listDevType(DevTypeParam.QueryParam queryParam) {
LambdaQueryWrapper<DevType> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(DevType::getState, DataStateEnum.ENABLE.getCode())
.like(DevType::getName, queryParam.getName())
.orderByDesc(DevType::getCreateTime);
Page<DevType> page = this.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), wrapper);
return page;
}
@Override
public boolean addDevType(DevTypeParam addParam) {
this.checkRepeat(addParam, false);
DevType devType = new DevType();
BeanUtil.copyProperties(addParam, devType);
devType.setState(DataStateEnum.ENABLE.getCode());
return this.save(devType);
}
@Override
public boolean updateDevType(DevTypeParam.UpdateParam updateParam) {
this.checkRepeat(updateParam, true);
DevType devType = new DevType();
BeanUtil.copyProperties(updateParam, devType);
return this.updateById(devType);
}
@Override
public boolean deleteDevType(List<String> ids) {
return this.lambdaUpdate().in(DevType::getId, ids).set(DevType::getState, DataStateEnum.DELETED.getCode()).update();
}
private void checkRepeat(DevTypeParam param, boolean isExcludeSelf) {
LambdaQueryWrapper<DevType> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(DevType::getName, param.getName())
.eq(DevType::getState, DataStateEnum.ENABLE.getCode());
if (isExcludeSelf) {
if (param instanceof DevTypeParam.UpdateParam) {
wrapper.ne(DevType::getId, ((DevTypeParam.UpdateParam) param).getId());
}
}
int count = this.count(wrapper);
if (count > 0) {
throw new BusinessException(DevTypeResponseEnum.DEV_TYPE_REPEAT);
}
}
} }