被检设备关联检测计划
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
package com.njcn.gather.machine.device.controller;
|
package com.njcn.gather.device.device.controller;
|
||||||
|
|
||||||
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||||
@@ -12,16 +12,17 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
|||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.common.pojo.response.HttpResult;
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
import com.njcn.common.utils.LogUtil;
|
import com.njcn.common.utils.LogUtil;
|
||||||
import com.njcn.gather.machine.device.pojo.param.PqDevParam;
|
import com.njcn.gather.device.device.pojo.param.PqDevParam;
|
||||||
import com.njcn.gather.machine.device.pojo.po.PqDev;
|
import com.njcn.gather.device.device.pojo.vo.PqDevExcel;
|
||||||
import com.njcn.gather.machine.device.pojo.vo.PqDevExcel;
|
import com.njcn.gather.device.device.service.IPqDevService;
|
||||||
import com.njcn.gather.machine.device.service.IPqDevService;
|
import com.njcn.gather.device.device.pojo.po.PqDev;
|
||||||
import com.njcn.gather.machine.pojo.enums.MachineResponseEnum;
|
import com.njcn.gather.device.pojo.enums.DeviceResponseEnum;
|
||||||
import com.njcn.web.controller.BaseController;
|
import com.njcn.web.controller.BaseController;
|
||||||
import com.njcn.web.utils.HttpResultUtil;
|
import com.njcn.web.utils.HttpResultUtil;
|
||||||
import com.njcn.web.utils.PoiUtil;
|
import com.njcn.web.utils.PoiUtil;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
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;
|
||||||
@@ -126,14 +127,14 @@ public class PqDevController extends BaseController {
|
|||||||
if (excelImportResult.isVerifyFail()) {
|
if (excelImportResult.isVerifyFail()) {
|
||||||
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
|
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
|
||||||
PoiUtil.exportFileByWorkbook(excelImportResult.getFailWorkbook(), "非法被检设备数据.xlsx", response);
|
PoiUtil.exportFileByWorkbook(excelImportResult.getFailWorkbook(), "非法被检设备数据.xlsx", response);
|
||||||
throw new BusinessException(MachineResponseEnum.IMPORT_DATA_FAIL);
|
throw new BusinessException(DeviceResponseEnum.IMPORT_DATA_FAIL);
|
||||||
} else {
|
} else {
|
||||||
//批量录入数据
|
//批量录入数据
|
||||||
List<PqDevExcel> sgEventExcels = excelImportResult.getList();
|
List<PqDevExcel> sgEventExcels = excelImportResult.getList();
|
||||||
pqDevService.importPqDevData(sgEventExcels);
|
pqDevService.importPqDevData(sgEventExcels);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new BusinessException(MachineResponseEnum.IMPORT_DATA_FAIL);
|
throw new BusinessException(DeviceResponseEnum.IMPORT_DATA_FAIL);
|
||||||
}
|
}
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
}
|
}
|
||||||
@@ -145,4 +146,43 @@ public class PqDevController extends BaseController {
|
|||||||
public void export(@RequestBody @Validated PqDevParam.PqDevQueryParam queryParam) {
|
public void export(@RequestBody @Validated PqDevParam.PqDevQueryParam queryParam) {
|
||||||
pqDevService.exportPqDevData(queryParam);
|
pqDevService.exportPqDevData(queryParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@GetMapping("/listUnbound")
|
||||||
|
@ApiOperation("查询出所有未绑定的设备")
|
||||||
|
public HttpResult<List<PqDev>> listUnbound() {
|
||||||
|
String methodDescribe = getMethodDescribe("listUnbound");
|
||||||
|
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, null);
|
||||||
|
List<PqDev> result = pqDevService.listUnbound();
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/listBoundByPlanId")
|
||||||
|
@ApiOperation("根据计划id查询出所有已绑定的设备")
|
||||||
|
@ApiImplicitParam(name = "planId", value = "计划id", required = true)
|
||||||
|
public HttpResult<List<PqDev>> listBoundByPlanId(@RequestParam("planId") String planId) {
|
||||||
|
String methodDescribe = getMethodDescribe("listBoundByPlanId");
|
||||||
|
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, planId);
|
||||||
|
List<PqDev> result = pqDevService.listBoundByPlanId(planId);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
|
||||||
|
@PostMapping("/bindPlan")
|
||||||
|
@ApiOperation("设备绑定计划")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "planId", value = "计划id", required = true),
|
||||||
|
@ApiImplicitParam(name = "pqDevId", value = "被检设备id", required = true)
|
||||||
|
})
|
||||||
|
public HttpResult<Object> bindPlan(@RequestBody PqDevParam.PqDevBindPlanParam bindPlanParam) {
|
||||||
|
String methodDescribe = getMethodDescribe("bindPlan");
|
||||||
|
LogUtil.njcnDebug(log, "{},绑定计划数据为:planId={}, pqDevId={}", methodDescribe, bindPlanParam.getPlanId(), String.join(StrUtil.COMMA, bindPlanParam.getPqDevIds()));
|
||||||
|
boolean result = pqDevService.bindPlan(bindPlanParam.getPlanId(), bindPlanParam.getPqDevIds());
|
||||||
|
if (result) {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
} else {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.njcn.gather.machine.device.mapper;
|
package com.njcn.gather.device.device.mapper;
|
||||||
|
|
||||||
import com.github.yulichang.base.MPJBaseMapper;
|
import com.github.yulichang.base.MPJBaseMapper;
|
||||||
import com.njcn.gather.machine.device.pojo.po.PqDev;
|
import com.njcn.gather.device.device.pojo.po.PqDev;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author caozehui
|
* @author caozehui
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.njcn.gather.machine.device.mapper.PqDevMapper">
|
<mapper namespace="com.njcn.gather.device.device.mapper.PqDevMapper">
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.njcn.gather.machine.device.pojo.param;
|
package com.njcn.gather.device.device.pojo.param;
|
||||||
|
|
||||||
import com.njcn.common.pojo.constant.PatternRegex;
|
import com.njcn.common.pojo.constant.PatternRegex;
|
||||||
import com.njcn.gather.machine.pojo.constant.MachineValidMessage;
|
import com.njcn.gather.device.pojo.constant.DeviceValidMessage;
|
||||||
import com.njcn.web.pojo.annotation.DateTimeStrValid;
|
import com.njcn.web.pojo.annotation.DateTimeStrValid;
|
||||||
import com.njcn.web.pojo.param.BaseParam;
|
import com.njcn.web.pojo.param.BaseParam;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
@@ -11,6 +11,7 @@ import lombok.EqualsAndHashCode;
|
|||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import javax.validation.constraints.Pattern;
|
import javax.validation.constraints.Pattern;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author caozehui
|
* @author caozehui
|
||||||
@@ -20,66 +21,66 @@ import javax.validation.constraints.Pattern;
|
|||||||
public class PqDevParam {
|
public class PqDevParam {
|
||||||
|
|
||||||
@ApiModelProperty(value = "名称", required = true)
|
@ApiModelProperty(value = "名称", required = true)
|
||||||
@NotBlank(message = MachineValidMessage.NAME_NOT_BLANK)
|
@NotBlank(message = DeviceValidMessage.NAME_NOT_BLANK)
|
||||||
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = MachineValidMessage.NAME_FORMAT_ERROR)
|
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DeviceValidMessage.NAME_FORMAT_ERROR)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@ApiModelProperty(value = "设备模式,字典表(数字、模拟、比对)", required = true)
|
@ApiModelProperty(value = "设备模式,字典表(数字、模拟、比对)", required = true)
|
||||||
@NotBlank(message = MachineValidMessage.PATTERN_NOT_BLANK)
|
@NotBlank(message = DeviceValidMessage.PATTERN_NOT_BLANK)
|
||||||
private String pattern;
|
private String pattern;
|
||||||
|
|
||||||
@ApiModelProperty(value = "设备类型,字典表", required = true)
|
@ApiModelProperty(value = "设备类型,字典表", required = true)
|
||||||
@NotBlank(message = MachineValidMessage.DEV_TYPE_NOT_BLANK)
|
@NotBlank(message = DeviceValidMessage.DEV_TYPE_NOT_BLANK)
|
||||||
private String devType;
|
private String devType;
|
||||||
|
|
||||||
@ApiModelProperty(value = "设备通道数", required = true)
|
@ApiModelProperty(value = "设备通道数", required = true)
|
||||||
@NotNull(message = MachineValidMessage.DEV_CHNS_NOT_NULL)
|
@NotNull(message = DeviceValidMessage.DEV_CHNS_NOT_NULL)
|
||||||
private Integer devChns;
|
private Integer devChns;
|
||||||
|
|
||||||
@ApiModelProperty(value = "额定电压(V)", required = true)
|
@ApiModelProperty(value = "额定电压(V)", required = true)
|
||||||
@NotNull(message = MachineValidMessage.DEV_VOLT_NOT_NULL)
|
@NotNull(message = DeviceValidMessage.DEV_VOLT_NOT_NULL)
|
||||||
private Float devVolt;
|
private Float devVolt;
|
||||||
|
|
||||||
@ApiModelProperty(value = "额定电流(A)", required = true)
|
@ApiModelProperty(value = "额定电流(A)", required = true)
|
||||||
@NotNull(message = MachineValidMessage.DEV_CURR_NOT_NULL)
|
@NotNull(message = DeviceValidMessage.DEV_CURR_NOT_NULL)
|
||||||
private Float devCurr;
|
private Float devCurr;
|
||||||
|
|
||||||
@ApiModelProperty(value = "生产厂家,字典表", required = true)
|
@ApiModelProperty(value = "生产厂家,字典表", required = true)
|
||||||
@NotBlank(message = MachineValidMessage.MANUFACTURER_NOT_BLANK)
|
@NotBlank(message = DeviceValidMessage.MANUFACTURER_NOT_BLANK)
|
||||||
private String manufacturer;
|
private String manufacturer;
|
||||||
|
|
||||||
@ApiModelProperty(value = "生产日期", required = true)
|
@ApiModelProperty(value = "生产日期", required = true)
|
||||||
@NotBlank(message = MachineValidMessage.CREATEDATETIME_NOT_NULL)
|
@NotBlank(message = DeviceValidMessage.CREATEDATETIME_NOT_NULL)
|
||||||
@DateTimeStrValid(format = "yyyy-MM-dd", message = MachineValidMessage.CREATEDATETIME_FORMAT_ERROR)
|
@DateTimeStrValid(format = "yyyy-MM-dd", message = DeviceValidMessage.CREATEDATETIME_FORMAT_ERROR)
|
||||||
private String createDate;
|
private String createDate;
|
||||||
|
|
||||||
@ApiModelProperty(value = "出厂编号", required = true)
|
@ApiModelProperty(value = "出厂编号", required = true)
|
||||||
@NotBlank(message = MachineValidMessage.FACTORYNO_NOT_BLANK)
|
@NotBlank(message = DeviceValidMessage.FACTORYNO_NOT_BLANK)
|
||||||
private String createId;
|
private String createId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "固件版本", required = true)
|
@ApiModelProperty(value = "固件版本", required = true)
|
||||||
@NotBlank(message = MachineValidMessage.FIRMWARE_NOT_BLANK)
|
@NotBlank(message = DeviceValidMessage.FIRMWARE_NOT_BLANK)
|
||||||
private String hardwareVersion;
|
private String hardwareVersion;
|
||||||
|
|
||||||
@ApiModelProperty(value = "软件版本", required = true)
|
@ApiModelProperty(value = "软件版本", required = true)
|
||||||
@NotBlank(message = MachineValidMessage.SOFTWARE_NOT_BLANK)
|
@NotBlank(message = DeviceValidMessage.SOFTWARE_NOT_BLANK)
|
||||||
private String softwareVersion;
|
private String softwareVersion;
|
||||||
|
|
||||||
@ApiModelProperty(value = "通讯协议", required = true)
|
@ApiModelProperty(value = "通讯协议", required = true)
|
||||||
@NotBlank(message = MachineValidMessage.PROTOCOL_NOT_BLANK)
|
@NotBlank(message = DeviceValidMessage.PROTOCOL_NOT_BLANK)
|
||||||
private String protocol;
|
private String protocol;
|
||||||
|
|
||||||
@ApiModelProperty(value = "IP地址", required = true)
|
@ApiModelProperty(value = "IP地址", required = true)
|
||||||
@NotBlank(message = MachineValidMessage.IP_NOT_BLANK)
|
@NotBlank(message = DeviceValidMessage.IP_NOT_BLANK)
|
||||||
@Pattern(regexp = PatternRegex.IP_REGEX, message = MachineValidMessage.IP_FORMAT_ERROR)
|
@Pattern(regexp = PatternRegex.IP_REGEX, message = DeviceValidMessage.IP_FORMAT_ERROR)
|
||||||
private String ip;
|
private String ip;
|
||||||
|
|
||||||
@ApiModelProperty(value = "端口号", required = true)
|
@ApiModelProperty(value = "端口号", required = true)
|
||||||
@NotNull(message = MachineValidMessage.PORT_NOT_NULL)
|
@NotNull(message = DeviceValidMessage.PORT_NOT_NULL)
|
||||||
private Integer port;
|
private Integer port;
|
||||||
|
|
||||||
@ApiModelProperty(value = "装置是否为加密版本", required = true)
|
@ApiModelProperty(value = "装置是否为加密版本", required = true)
|
||||||
@NotNull(message = MachineValidMessage.ENCRYPTION_NOT_NULL)
|
@NotNull(message = DeviceValidMessage.ENCRYPTION_NOT_NULL)
|
||||||
private Integer encryption;
|
private Integer encryption;
|
||||||
|
|
||||||
@ApiModelProperty("装置识别码(3ds加密)")
|
@ApiModelProperty("装置识别码(3ds加密)")
|
||||||
@@ -92,7 +93,7 @@ public class PqDevParam {
|
|||||||
private String sampleId;
|
private String sampleId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "送样日期")
|
@ApiModelProperty(value = "送样日期")
|
||||||
@DateTimeStrValid(message = MachineValidMessage.ARRIVE_DATE_TIME_FORMAT_ERROR)
|
@DateTimeStrValid(message = DeviceValidMessage.ARRIVE_DATE_TIME_FORMAT_ERROR)
|
||||||
private String arrivedDate;
|
private String arrivedDate;
|
||||||
|
|
||||||
@ApiModelProperty("所属地市名称")
|
@ApiModelProperty("所属地市名称")
|
||||||
@@ -123,7 +124,7 @@ public class PqDevParam {
|
|||||||
private String qrCode;
|
private String qrCode;
|
||||||
|
|
||||||
@ApiModelProperty(value = "复检次数,默认为0", required = true)
|
@ApiModelProperty(value = "复检次数,默认为0", required = true)
|
||||||
@NotNull(message = MachineValidMessage.RECHECK_NUM_NOT_NULL)
|
@NotNull(message = DeviceValidMessage.RECHECK_NUM_NOT_NULL)
|
||||||
private Integer reCheckNum;
|
private Integer reCheckNum;
|
||||||
|
|
||||||
|
|
||||||
@@ -135,8 +136,8 @@ public class PqDevParam {
|
|||||||
public static class PqDevUpdateParam extends PqDevParam {
|
public static class PqDevUpdateParam extends PqDevParam {
|
||||||
|
|
||||||
@ApiModelProperty("id")
|
@ApiModelProperty("id")
|
||||||
@NotBlank(message = MachineValidMessage.ID_NOT_BLANK)
|
@NotBlank(message = DeviceValidMessage.ID_NOT_BLANK)
|
||||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = MachineValidMessage.ID_FORMAT_ERROR)
|
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.ID_FORMAT_ERROR)
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -148,10 +149,23 @@ public class PqDevParam {
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public static class PqDevQueryParam extends BaseParam {
|
public static class PqDevQueryParam extends BaseParam {
|
||||||
@ApiModelProperty("名称")
|
@ApiModelProperty("名称")
|
||||||
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = MachineValidMessage.NAME_FORMAT_ERROR)
|
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DeviceValidMessage.NAME_FORMAT_ERROR)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@ApiModelProperty("设备类型")
|
@ApiModelProperty("设备类型")
|
||||||
private String devType;
|
private String devType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class PqDevBindPlanParam {
|
||||||
|
@ApiModelProperty("planId")
|
||||||
|
@NotNull(message = DeviceValidMessage.PLAN_ID_NOT_NULL)
|
||||||
|
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.ID_FORMAT_ERROR)
|
||||||
|
private String planId;
|
||||||
|
|
||||||
|
@ApiModelProperty("pqDevIds")
|
||||||
|
@NotNull(message = DeviceValidMessage.PQ_DEV_IDS_NOT_NULL)
|
||||||
|
private List<String> pqDevIds;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.njcn.gather.machine.device.pojo.po;
|
package com.njcn.gather.device.device.pojo.po;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
@@ -191,5 +191,10 @@ public class PqDev extends BaseEntity implements Serializable {
|
|||||||
* 状态:0-删除 1-正常
|
* 状态:0-删除 1-正常
|
||||||
*/
|
*/
|
||||||
private Integer state;
|
private Integer state;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测计划id
|
||||||
|
*/
|
||||||
|
private String planId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.njcn.gather.machine.device.pojo.vo;
|
package com.njcn.gather.device.device.pojo.vo;
|
||||||
|
|
||||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||||
import com.njcn.common.pojo.constant.PatternRegex;
|
import com.njcn.common.pojo.constant.PatternRegex;
|
||||||
import com.njcn.gather.machine.pojo.constant.MachineValidMessage;
|
import com.njcn.gather.device.pojo.constant.DeviceValidMessage;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
@@ -21,66 +21,66 @@ public class PqDevExcel implements Serializable {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Excel(name = "名称", width = 20)
|
@Excel(name = "名称", width = 20)
|
||||||
@NotBlank(message = MachineValidMessage.NAME_NOT_BLANK)
|
@NotBlank(message = DeviceValidMessage.NAME_NOT_BLANK)
|
||||||
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = MachineValidMessage.NAME_FORMAT_ERROR)
|
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DeviceValidMessage.NAME_FORMAT_ERROR)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Excel(name = "设备模式", width = 20)
|
@Excel(name = "设备模式", width = 20)
|
||||||
@NotBlank(message = MachineValidMessage.PATTERN_NOT_BLANK)
|
@NotBlank(message = DeviceValidMessage.PATTERN_NOT_BLANK)
|
||||||
private String pattern;
|
private String pattern;
|
||||||
|
|
||||||
@Excel(name = "设备类型", width = 20)
|
@Excel(name = "设备类型", width = 20)
|
||||||
@NotBlank(message = MachineValidMessage.DEV_TYPE_NOT_BLANK)
|
@NotBlank(message = DeviceValidMessage.DEV_TYPE_NOT_BLANK)
|
||||||
private String devType;
|
private String devType;
|
||||||
|
|
||||||
@Excel(name = "设备通道数", width = 20)
|
@Excel(name = "设备通道数", width = 20)
|
||||||
@NotNull(message = MachineValidMessage.DEV_CHNS_NOT_NULL)
|
@NotNull(message = DeviceValidMessage.DEV_CHNS_NOT_NULL)
|
||||||
private Integer devChns;
|
private Integer devChns;
|
||||||
|
|
||||||
@Excel(name = "额定电压(V)", width = 15)
|
@Excel(name = "额定电压(V)", width = 15)
|
||||||
@NotNull(message = MachineValidMessage.DEV_VOLT_NOT_NULL)
|
@NotNull(message = DeviceValidMessage.DEV_VOLT_NOT_NULL)
|
||||||
private Float devVolt;
|
private Float devVolt;
|
||||||
|
|
||||||
@Excel(name = "额定电流(A)", width = 15)
|
@Excel(name = "额定电流(A)", width = 15)
|
||||||
@NotNull(message = MachineValidMessage.DEV_CURR_NOT_NULL)
|
@NotNull(message = DeviceValidMessage.DEV_CURR_NOT_NULL)
|
||||||
private Float devCurr;
|
private Float devCurr;
|
||||||
|
|
||||||
@Excel(name = "生产厂家", width = 20)
|
@Excel(name = "生产厂家", width = 20)
|
||||||
@NotBlank(message = MachineValidMessage.MANUFACTURER_NOT_BLANK)
|
@NotBlank(message = DeviceValidMessage.MANUFACTURER_NOT_BLANK)
|
||||||
private String manufacturer;
|
private String manufacturer;
|
||||||
|
|
||||||
@Excel(name = "生产日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd")
|
@Excel(name = "生产日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd")
|
||||||
@NotNull(message = MachineValidMessage.CREATEDATETIME_NOT_NULL)
|
@NotNull(message = DeviceValidMessage.CREATEDATETIME_NOT_NULL)
|
||||||
//@DateTimeStrValid(format = "yyyy-MM-dd", message = MachineValidMessage.CREATEDATETIME_FORMAT_ERROR)
|
//@DateTimeStrValid(format = "yyyy-MM-dd", message = DeviceValidMessage.CREATEDATETIME_FORMAT_ERROR)
|
||||||
private LocalDate createDate;
|
private LocalDate createDate;
|
||||||
|
|
||||||
@Excel(name = "出厂编号", width = 40)
|
@Excel(name = "出厂编号", width = 40)
|
||||||
@NotBlank(message = MachineValidMessage.FACTORYNO_NOT_BLANK)
|
@NotBlank(message = DeviceValidMessage.FACTORYNO_NOT_BLANK)
|
||||||
private String createId;
|
private String createId;
|
||||||
|
|
||||||
@Excel(name = "固件版本", width = 15)
|
@Excel(name = "固件版本", width = 15)
|
||||||
@NotBlank(message = MachineValidMessage.FIRMWARE_NOT_BLANK)
|
@NotBlank(message = DeviceValidMessage.FIRMWARE_NOT_BLANK)
|
||||||
private String hardwareVersion;
|
private String hardwareVersion;
|
||||||
|
|
||||||
@Excel(name = "软件版本", width = 15)
|
@Excel(name = "软件版本", width = 15)
|
||||||
@NotBlank(message = MachineValidMessage.SOFTWARE_NOT_BLANK)
|
@NotBlank(message = DeviceValidMessage.SOFTWARE_NOT_BLANK)
|
||||||
private String softwareVersion;
|
private String softwareVersion;
|
||||||
|
|
||||||
@Excel(name = "通讯协议", width = 15)
|
@Excel(name = "通讯协议", width = 15)
|
||||||
@NotBlank(message = MachineValidMessage.PROTOCOL_NOT_BLANK)
|
@NotBlank(message = DeviceValidMessage.PROTOCOL_NOT_BLANK)
|
||||||
private String protocol;
|
private String protocol;
|
||||||
|
|
||||||
@Excel(name = "IP地址", width = 20)
|
@Excel(name = "IP地址", width = 20)
|
||||||
@NotBlank(message = MachineValidMessage.IP_NOT_BLANK)
|
@NotBlank(message = DeviceValidMessage.IP_NOT_BLANK)
|
||||||
@Pattern(regexp = PatternRegex.IP_REGEX, message = MachineValidMessage.IP_FORMAT_ERROR)
|
@Pattern(regexp = PatternRegex.IP_REGEX, message = DeviceValidMessage.IP_FORMAT_ERROR)
|
||||||
private String ip;
|
private String ip;
|
||||||
|
|
||||||
@Excel(name = "端口号")
|
@Excel(name = "端口号")
|
||||||
@NotNull(message = MachineValidMessage.PORT_NOT_NULL)
|
@NotNull(message = DeviceValidMessage.PORT_NOT_NULL)
|
||||||
private Integer port;
|
private Integer port;
|
||||||
|
|
||||||
@Excel(name = "是否为加密版本(1:是/0:否)", width = 20)
|
@Excel(name = "是否为加密版本(1:是/0:否)", width = 20)
|
||||||
@NotNull(message = MachineValidMessage.ENCRYPTION_NOT_NULL)
|
@NotNull(message = DeviceValidMessage.ENCRYPTION_NOT_NULL)
|
||||||
private Integer encryption;
|
private Integer encryption;
|
||||||
|
|
||||||
@Excel(name = "识别码(未加密)", width = 30)
|
@Excel(name = "识别码(未加密)", width = 30)
|
||||||
@@ -93,7 +93,7 @@ public class PqDevExcel implements Serializable {
|
|||||||
private String sampleId;
|
private String sampleId;
|
||||||
|
|
||||||
@Excel(name = "送样日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd")
|
@Excel(name = "送样日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd")
|
||||||
//@DateTimeStrValid(format = "yyyy-MM-dd", message = MachineValidMessage.ARRIVEDATETIME_FORMAT_ERROR)
|
//@DateTimeStrValid(format = "yyyy-MM-dd", message = DeviceValidMessage.ARRIVEDATETIME_FORMAT_ERROR)
|
||||||
private LocalDate arrivedDate;
|
private LocalDate arrivedDate;
|
||||||
|
|
||||||
@Excel(name = "所属地市名称", width = 20)
|
@Excel(name = "所属地市名称", width = 20)
|
||||||
@@ -124,6 +124,6 @@ public class PqDevExcel implements Serializable {
|
|||||||
private String qrCode;
|
private String qrCode;
|
||||||
|
|
||||||
@Excel(name = "复检次数", width = 15)
|
@Excel(name = "复检次数", width = 15)
|
||||||
@NotNull(message = MachineValidMessage.RECHECK_NUM_NOT_NULL)
|
@NotNull(message = DeviceValidMessage.RECHECK_NUM_NOT_NULL)
|
||||||
private Integer reCheckNum;
|
private Integer reCheckNum;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.njcn.gather.machine.device.service;
|
package com.njcn.gather.device.device.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
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.machine.device.pojo.param.PqDevParam;
|
import com.njcn.gather.device.device.pojo.param.PqDevParam;
|
||||||
import com.njcn.gather.machine.device.pojo.po.PqDev;
|
import com.njcn.gather.device.device.pojo.po.PqDev;
|
||||||
import com.njcn.gather.machine.device.pojo.vo.PqDevExcel;
|
import com.njcn.gather.device.device.pojo.vo.PqDevExcel;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -66,4 +66,27 @@ public interface IPqDevService extends IService<PqDev> {
|
|||||||
void exportPqDevData(PqDevParam.PqDevQueryParam queryParam);
|
void exportPqDevData(PqDevParam.PqDevQueryParam queryParam);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有未绑定的设备
|
||||||
|
*
|
||||||
|
* @return 未绑定的设备列表
|
||||||
|
*/
|
||||||
|
List<PqDev> listUnbound();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据计划id获取绑定的设备
|
||||||
|
*
|
||||||
|
* @param planId 计划id
|
||||||
|
* @return 绑定的设备列表
|
||||||
|
*/
|
||||||
|
List<PqDev> listBoundByPlanId(String planId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定计划
|
||||||
|
*
|
||||||
|
* @param planId 计划id
|
||||||
|
* @param pqDevIds 被检设备id列表
|
||||||
|
* @return 绑定成功返回true,否则返回false
|
||||||
|
*/
|
||||||
|
boolean bindPlan(String planId, List<String> pqDevIds);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,32 @@
|
|||||||
package com.njcn.gather.machine.device.service.impl;
|
package com.njcn.gather.device.device.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
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.db.mybatisplus.constant.DbConstant;
|
import com.njcn.db.mybatisplus.constant.DbConstant;
|
||||||
import com.njcn.gather.machine.device.mapper.PqDevMapper;
|
import com.njcn.gather.device.device.pojo.param.PqDevParam;
|
||||||
import com.njcn.gather.machine.device.pojo.param.PqDevParam;
|
import com.njcn.gather.device.device.pojo.vo.PqDevExcel;
|
||||||
import com.njcn.gather.machine.device.pojo.po.PqDev;
|
import com.njcn.gather.device.device.service.IPqDevService;
|
||||||
import com.njcn.gather.machine.device.pojo.vo.PqDevExcel;
|
import com.njcn.gather.device.device.mapper.PqDevMapper;
|
||||||
import com.njcn.gather.machine.device.service.IPqDevService;
|
import com.njcn.gather.device.device.pojo.po.PqDev;
|
||||||
import com.njcn.gather.machine.device.util.DeviceUtil;
|
import com.njcn.gather.device.device.util.DeviceUtil;
|
||||||
import com.njcn.web.factory.PageFactory;
|
import com.njcn.web.factory.PageFactory;
|
||||||
import com.njcn.web.utils.ExcelUtil;
|
import com.njcn.web.utils.ExcelUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author caozehui
|
* @author caozehui
|
||||||
@@ -130,4 +133,43 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
|||||||
List<PqDevExcel> pqDevExcels = BeanUtil.copyToList(pqDevs, PqDevExcel.class);
|
List<PqDevExcel> pqDevExcels = BeanUtil.copyToList(pqDevs, PqDevExcel.class);
|
||||||
ExcelUtil.exportExcel("被检设备导出数据.xlsx", "被检设备", PqDevExcel.class, pqDevExcels);
|
ExcelUtil.exportExcel("被检设备导出数据.xlsx", "被检设备", PqDevExcel.class, pqDevExcels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PqDev> listUnbound() {
|
||||||
|
return this.lambdaQuery()
|
||||||
|
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
|
||||||
|
.isNull(PqDev::getPlanId)
|
||||||
|
.list();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PqDev> listBoundByPlanId(String planId) {
|
||||||
|
return this.lambdaQuery()
|
||||||
|
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
|
||||||
|
.eq(PqDev::getPlanId, planId)
|
||||||
|
.list();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean bindPlan(String planId, List<String> pqDevIds) {
|
||||||
|
List<String> existedBoundPqDevIds = this.listBoundByPlanId(planId)
|
||||||
|
.stream().map(PqDev::getId).collect(Collectors.toList());
|
||||||
|
|
||||||
|
//共有的(交集)
|
||||||
|
List<String> intersection = existedBoundPqDevIds.stream().filter(pqDevIds::contains).collect(Collectors.toList());
|
||||||
|
|
||||||
|
//移除 已有的历史绑定而此次不绑定的
|
||||||
|
existedBoundPqDevIds.removeAll(intersection);
|
||||||
|
boolean result1 = this.lambdaUpdate().set(PqDev::getPlanId, null)
|
||||||
|
.in(PqDev::getId, existedBoundPqDevIds)
|
||||||
|
.update();
|
||||||
|
|
||||||
|
//绑定 没有的历史绑定而此次绑定的
|
||||||
|
pqDevIds.removeAll(existedBoundPqDevIds);
|
||||||
|
boolean result2 = this.lambdaUpdate().set(PqDev::getPlanId, planId)
|
||||||
|
.in(PqDev::getId, pqDevIds)
|
||||||
|
.update();
|
||||||
|
|
||||||
|
return result1 && result2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.njcn.gather.machine.device.util;
|
package com.njcn.gather.device.device.util;
|
||||||
|
|
||||||
import com.njcn.common.utils.sm.ThreeDesUtil;
|
import com.njcn.common.utils.sm.ThreeDesUtil;
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.njcn.gather.machine.pojo.constant;
|
package com.njcn.gather.device.pojo.constant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author caozehui
|
* @author caozehui
|
||||||
* @date 2024/11/06
|
* @date 2024/11/06
|
||||||
*/
|
*/
|
||||||
public interface MachineValidMessage {
|
public interface DeviceValidMessage {
|
||||||
|
|
||||||
String ID_NOT_BLANK = "id不能为空,请检查id参数";
|
String ID_NOT_BLANK = "id不能为空,请检查id参数";
|
||||||
|
|
||||||
@@ -48,5 +48,9 @@ public interface MachineValidMessage {
|
|||||||
|
|
||||||
String RECHECK_NUM_NOT_NULL = "复检次数不能为空,请检查reCheckNum参数";
|
String RECHECK_NUM_NOT_NULL = "复检次数不能为空,请检查reCheckNum参数";
|
||||||
|
|
||||||
|
String PLAN_ID_NOT_NULL="检测计划ID不能为空,请检查planId参数";
|
||||||
|
|
||||||
|
String PQ_DEV_IDS_NOT_NULL="设备ID集合不能为null,请检查pqDevIds参数";
|
||||||
|
|
||||||
String ARRIVE_DATE_TIME_FORMAT_ERROR = "送样日期格式错误,请检查arrivedDateTime参数";
|
String ARRIVE_DATE_TIME_FORMAT_ERROR = "送样日期格式错误,请检查arrivedDateTime参数";
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.njcn.gather.machine.pojo.enums;
|
package com.njcn.gather.device.pojo.enums;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public enum MachineResponseEnum {
|
public enum DeviceResponseEnum {
|
||||||
//NAME_REPEAT("A001001", "名称重复"),
|
//NAME_REPEAT("A001001", "名称重复"),
|
||||||
|
|
||||||
IMPORT_DATA_FAIL("A001002", "导入数据失败");
|
IMPORT_DATA_FAIL("A001002", "导入数据失败");
|
||||||
@@ -12,7 +12,7 @@ public enum MachineResponseEnum {
|
|||||||
|
|
||||||
private final String message;
|
private final String message;
|
||||||
|
|
||||||
MachineResponseEnum(String code, String message) {
|
DeviceResponseEnum(String code, String message) {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user