diff --git a/detection/src/main/java/com/njcn/gather/device/controller/PqDevController.java b/detection/src/main/java/com/njcn/gather/device/controller/PqDevController.java index afcb4201..14cde444 100644 --- a/detection/src/main/java/com/njcn/gather/device/controller/PqDevController.java +++ b/detection/src/main/java/com/njcn/gather/device/controller/PqDevController.java @@ -26,7 +26,7 @@ import com.njcn.gather.device.pojo.vo.PreDetection; import com.njcn.gather.device.service.IPqDevService; import com.njcn.gather.system.dictionary.pojo.po.DictData; 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.web.controller.BaseController; import com.njcn.web.utils.ExcelUtil; diff --git a/detection/src/main/java/com/njcn/gather/device/pojo/constant/DevValidMessage.java b/detection/src/main/java/com/njcn/gather/device/pojo/constant/DevValidMessage.java index ddfbad04..488fe91b 100644 --- a/detection/src/main/java/com/njcn/gather/device/pojo/constant/DevValidMessage.java +++ b/detection/src/main/java/com/njcn/gather/device/pojo/constant/DevValidMessage.java @@ -68,8 +68,6 @@ public interface DevValidMessage { String DEV_TYPE_FORMAT_ERROR = "设备类型格式错误,请检查devType参数"; - String DEV_CHNS_RANGE_ERROR = "设备通道系数错误,请检查devChns参数"; - String MANUFACTURER_FORMAT_ERROR = "设备厂家格式错误,请检查manufacturer参数"; String PROTOCOL_FORMAT_ERROR = "通讯协议格式错误,请检查protocol参数"; diff --git a/detection/src/main/java/com/njcn/gather/device/service/impl/PqDevServiceImpl.java b/detection/src/main/java/com/njcn/gather/device/service/impl/PqDevServiceImpl.java index 95be73b2..45712b84 100644 --- a/detection/src/main/java/com/njcn/gather/device/service/impl/PqDevServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/device/service/impl/PqDevServiceImpl.java @@ -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.service.IDictDataService; 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.util.DeviceUtil; import com.njcn.web.factory.PageFactory; diff --git a/detection/src/main/java/com/njcn/gather/icd/controller/PqIcdPathController.java b/detection/src/main/java/com/njcn/gather/icd/controller/PqIcdPathController.java new file mode 100644 index 00000000..0cc969c8 --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/icd/controller/PqIcdPathController.java @@ -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> listAll() { + String methodDescribe = getMethodDescribe("listAll"); + List result = pqIcdPathService.listAll(); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); + } + + @OperateInfo + @PostMapping("/list") + @ApiOperation("分页查询icd") + @ApiImplicitParam(name = "param", value = "查询参数", required = true) + public HttpResult> list(@RequestBody @Validated PqIcdPathParam.QueryParam param) { + String methodDescribe = getMethodDescribe("list"); + LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param); + Page 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 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 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 delete(@RequestBody List 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); + } + } + +} + diff --git a/detection/src/main/java/com/njcn/gather/icd/mapper/PqIcdPathMapper.java b/detection/src/main/java/com/njcn/gather/icd/mapper/PqIcdPathMapper.java new file mode 100644 index 00000000..2897346b --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/icd/mapper/PqIcdPathMapper.java @@ -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 { + +} + diff --git a/detection/src/main/java/com/njcn/gather/icd/mapper/mapping/PqIcdPathMapper.xml b/detection/src/main/java/com/njcn/gather/icd/mapper/mapping/PqIcdPathMapper.xml new file mode 100644 index 00000000..a4062903 --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/icd/mapper/mapping/PqIcdPathMapper.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/detection/src/main/java/com/njcn/gather/icd/pojo/constant/PqIcdPathValidMessage.java b/detection/src/main/java/com/njcn/gather/icd/pojo/constant/PqIcdPathValidMessage.java new file mode 100644 index 00000000..2cdac979 --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/icd/pojo/constant/PqIcdPathValidMessage.java @@ -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存储路径不能为空"; +} diff --git a/detection/src/main/java/com/njcn/gather/icd/pojo/param/PqIcdPathParam.java b/detection/src/main/java/com/njcn/gather/icd/pojo/param/PqIcdPathParam.java new file mode 100644 index 00000000..9c72cf61 --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/icd/pojo/param/PqIcdPathParam.java @@ -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; + } +} diff --git a/detection/src/main/java/com/njcn/gather/icd/pojo/po/PqIcdPath.java b/detection/src/main/java/com/njcn/gather/icd/pojo/po/PqIcdPath.java new file mode 100644 index 00000000..cdd49322 --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/icd/pojo/po/PqIcdPath.java @@ -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; +} + diff --git a/detection/src/main/java/com/njcn/gather/icd/service/IPqIcdPathService.java b/detection/src/main/java/com/njcn/gather/icd/service/IPqIcdPathService.java new file mode 100644 index 00000000..dda9378b --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/icd/service/IPqIcdPathService.java @@ -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 { + + List listAll(); + + Page listIcd(PqIcdPathParam.QueryParam param); + + boolean addIcd(PqIcdPathParam param); + + boolean updateIcd(PqIcdPathParam.UpdateParam param); + + boolean deleteIcd(List ids); +} diff --git a/detection/src/main/java/com/njcn/gather/icd/service/impl/PqIcdPathServiceImpl.java b/detection/src/main/java/com/njcn/gather/icd/service/impl/PqIcdPathServiceImpl.java new file mode 100644 index 00000000..392a961b --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/icd/service/impl/PqIcdPathServiceImpl.java @@ -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 implements IPqIcdPathService { + + @Override + public List listAll() { + return null; + } + + @Override + public Page 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 ids) { + return false; + } +} diff --git a/detection/src/main/java/com/njcn/gather/plan/controller/AdPlanController.java b/detection/src/main/java/com/njcn/gather/plan/controller/AdPlanController.java index 92eb59b8..2daba460 100644 --- a/detection/src/main/java/com/njcn/gather/plan/controller/AdPlanController.java +++ b/detection/src/main/java/com/njcn/gather/plan/controller/AdPlanController.java @@ -65,7 +65,7 @@ public class AdPlanController extends BaseController { @OperateInfo(operateType = OperateType.ADD) @PostMapping("/add") @ApiOperation("新增检测计划") - @ApiImplicitParam(name = "pqDevParam", value = "检测计划", required = true) + @ApiImplicitParam(name = "param", value = "检测计划", required = true) public HttpResult add(@RequestBody @Validated AdPlanParam param) { String methodDescribe = getMethodDescribe("add"); LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param); diff --git a/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java b/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java index 4feed15d..cfade95f 100644 --- a/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java @@ -112,9 +112,6 @@ public class AdPlanServiceImpl extends ServiceImpl impleme adPlan.setTestState(CheckStateEnum.UNCHECKED.getValue()); adPlan.setReportState(PlanReportStateEnum.REPORT_STATE_NOT_GENERATED.getValue()); adPlan.setResult(CheckResultEnum.UNCHECKED.getValue()); - // todo code 生成 - // 日期生成 MMdd - //String dateStr = DateFormatUtils.format(new Date(), "MMdd"); adPlan.setCode(this.generateCode()); // 新增检测计划、检测源关联 diff --git a/detection/src/main/java/com/njcn/gather/report/service/impl/ReportServiceImpl.java b/detection/src/main/java/com/njcn/gather/report/service/impl/ReportServiceImpl.java index 53dcca47..b002444d 100644 --- a/detection/src/main/java/com/njcn/gather/report/service/impl/ReportServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/report/service/impl/ReportServiceImpl.java @@ -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.AdNonHarmonicService; 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 lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java b/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java index a0d2ff72..0ec8670f 100644 --- a/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java @@ -22,7 +22,7 @@ import com.njcn.gather.script.service.IPqScriptCheckDataService; import com.njcn.gather.script.service.IPqScriptDtlsService; import com.njcn.gather.script.util.ScriptDtlsDesc; 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 lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/detection/src/main/java/com/njcn/gather/source/service/impl/PqSourceServiceImpl.java b/detection/src/main/java/com/njcn/gather/source/service/impl/PqSourceServiceImpl.java index ef135851..45d8bfe3 100644 --- a/detection/src/main/java/com/njcn/gather/source/service/impl/PqSourceServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/source/service/impl/PqSourceServiceImpl.java @@ -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.SourceParam; 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.system.dictionary.pojo.po.DictData; import com.njcn.gather.system.dictionary.service.IDictDataService; diff --git a/detection/src/main/java/com/njcn/gather/type/controller/DevTypeController.java b/detection/src/main/java/com/njcn/gather/type/controller/DevTypeController.java index 15e596cd..b313038f 100644 --- a/detection/src/main/java/com/njcn/gather/type/controller/DevTypeController.java +++ b/detection/src/main/java/com/njcn/gather/type/controller/DevTypeController.java @@ -1,29 +1,35 @@ 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.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.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.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 com.njcn.web.controller.BaseController; import java.util.List; /** *

- * 前端控制器 + * 前端控制器 *

* * @author hongawen @@ -39,20 +45,71 @@ public class DevTypeController extends BaseController { private final IDevTypeService devTypeService; - /** - * 获取所有有效设备类型集合 - */ - @OperateInfo(info = LogEnum.SYSTEM_COMMON) - @PostMapping("/list") - @ApiOperation("获取所有有效设备类型集合") + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/listAll") + @ApiOperation("获取所有设备类型") public HttpResult> listAll() { String methodDescribe = getMethodDescribe("listAll"); List result = devTypeService.listAll(); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); } + @OperateInfo + @PostMapping("/list") + @ApiOperation("分页查询设备类型") + @ApiImplicitParam(name = "queryParam", value = "查询参数", required = true) + public HttpResult> list(@RequestBody @Validated DevTypeParam.QueryParam queryParam) { + String methodDescribe = getMethodDescribe("list"); + LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam); + Page 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 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 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 delete(@RequestBody List 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); + } + } } diff --git a/detection/src/main/java/com/njcn/gather/type/mapper/DevTypeMapper.java b/detection/src/main/java/com/njcn/gather/type/mapper/DevTypeMapper.java index 66494326..0d6fe709 100644 --- a/detection/src/main/java/com/njcn/gather/type/mapper/DevTypeMapper.java +++ b/detection/src/main/java/com/njcn/gather/type/mapper/DevTypeMapper.java @@ -2,7 +2,7 @@ package com.njcn.gather.type.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.njcn.gather.type.entity.DevType; +import com.njcn.gather.type.pojo.po.DevType; /** *

diff --git a/detection/src/main/java/com/njcn/gather/type/pojo/constant/DevTypeValidMessage.java b/detection/src/main/java/com/njcn/gather/type/pojo/constant/DevTypeValidMessage.java new file mode 100644 index 00000000..36384427 --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/type/pojo/constant/DevTypeValidMessage.java @@ -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 = "通道数格式错误"; +} diff --git a/detection/src/main/java/com/njcn/gather/type/pojo/enums/DevTypeResponseEnum.java b/detection/src/main/java/com/njcn/gather/type/pojo/enums/DevTypeResponseEnum.java new file mode 100644 index 00000000..d32a6904 --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/type/pojo/enums/DevTypeResponseEnum.java @@ -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; + } +} diff --git a/detection/src/main/java/com/njcn/gather/type/pojo/param/DevTypeParam.java b/detection/src/main/java/com/njcn/gather/type/pojo/param/DevTypeParam.java new file mode 100644 index 00000000..21785342 --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/type/pojo/param/DevTypeParam.java @@ -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; + } +} diff --git a/detection/src/main/java/com/njcn/gather/type/entity/DevType.java b/detection/src/main/java/com/njcn/gather/type/pojo/po/DevType.java similarity index 81% rename from detection/src/main/java/com/njcn/gather/type/entity/DevType.java rename to detection/src/main/java/com/njcn/gather/type/pojo/po/DevType.java index 3e8d0274..2ec76f82 100644 --- a/detection/src/main/java/com/njcn/gather/type/entity/DevType.java +++ b/detection/src/main/java/com/njcn/gather/type/pojo/po/DevType.java @@ -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.njcn.db.mybatisplus.bo.BaseEntity; @@ -53,6 +54,12 @@ public class DevType extends BaseEntity { */ private Integer devChns; + /** + * 报告模板 + */ + @TableField("report_name") + private String reportName; + /** * 状态:0-删除 1-正常 */ diff --git a/detection/src/main/java/com/njcn/gather/type/service/IDevTypeService.java b/detection/src/main/java/com/njcn/gather/type/service/IDevTypeService.java index e483cc92..07760bd9 100644 --- a/detection/src/main/java/com/njcn/gather/type/service/IDevTypeService.java +++ b/detection/src/main/java/com/njcn/gather/type/service/IDevTypeService.java @@ -1,13 +1,15 @@ package com.njcn.gather.type.service; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 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; /** *

- * 服务类 + * 服务类 *

* * @author hongawen @@ -15,11 +17,66 @@ import java.util.List; */ public interface IDevTypeService extends IService { + /** + * 查询所有设备类型 + * + * @return 所有设备类型 + */ List listAll(); + /** + * 根据名称查询设备类型 + * + * @param name 名称 + * @return + */ DevType getByName(String name); + /** + * 根据id查询设备类型 + * + * @param id id + * @return + */ DevType getById(String id); + /** + * 根据id列表查询设备类型 + * + * @param ids id列表 + * @return + */ List listByIds(List ids); + + /** + * 分页查询设备类型 + * + * @param queryParam 查询参数 + * @return 分页查询结果 + */ + Page 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 ids); } diff --git a/detection/src/main/java/com/njcn/gather/type/service/impl/DevTypeServiceImpl.java b/detection/src/main/java/com/njcn/gather/type/service/impl/DevTypeServiceImpl.java index 38a3bccd..3c3dbd7a 100644 --- a/detection/src/main/java/com/njcn/gather/type/service/impl/DevTypeServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/type/service/impl/DevTypeServiceImpl.java @@ -1,18 +1,24 @@ 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.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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.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.web.factory.PageFactory; import org.springframework.stereotype.Service; import java.util.List; /** *

- * 服务实现类 + * 服务实现类 *

* * @author hongawen @@ -43,4 +49,51 @@ public class DevTypeServiceImpl extends ServiceImpl impl public List listByIds(List ids) { return this.lambdaQuery().in(DevType::getId, ids).eq(DevType::getState, DataStateEnum.ENABLE.getCode()).list(); } + + @Override + public Page listDevType(DevTypeParam.QueryParam queryParam) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(DevType::getState, DataStateEnum.ENABLE.getCode()) + .like(DevType::getName, queryParam.getName()) + .orderByDesc(DevType::getCreateTime); + Page 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 ids) { + return this.lambdaUpdate().in(DevType::getId, ids).set(DevType::getState, DataStateEnum.DELETED.getCode()).update(); + } + + private void checkRepeat(DevTypeParam param, boolean isExcludeSelf) { + LambdaQueryWrapper 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); + } + } }