被检设备关联检测计划

This commit is contained in:
caozehui
2024-11-09 17:02:59 +08:00
parent 81357906ca
commit b605605c13
11 changed files with 206 additions and 78 deletions

View File

@@ -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.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.response.HttpResult;
import com.njcn.common.utils.LogUtil;
import com.njcn.gather.machine.device.pojo.param.PqDevParam;
import com.njcn.gather.machine.device.pojo.po.PqDev;
import com.njcn.gather.machine.device.pojo.vo.PqDevExcel;
import com.njcn.gather.machine.device.service.IPqDevService;
import com.njcn.gather.machine.pojo.enums.MachineResponseEnum;
import com.njcn.gather.device.device.pojo.param.PqDevParam;
import com.njcn.gather.device.device.pojo.vo.PqDevExcel;
import com.njcn.gather.device.device.service.IPqDevService;
import com.njcn.gather.device.device.pojo.po.PqDev;
import com.njcn.gather.device.pojo.enums.DeviceResponseEnum;
import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.HttpResultUtil;
import com.njcn.web.utils.PoiUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -126,14 +127,14 @@ public class PqDevController extends BaseController {
if (excelImportResult.isVerifyFail()) {
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
PoiUtil.exportFileByWorkbook(excelImportResult.getFailWorkbook(), "非法被检设备数据.xlsx", response);
throw new BusinessException(MachineResponseEnum.IMPORT_DATA_FAIL);
throw new BusinessException(DeviceResponseEnum.IMPORT_DATA_FAIL);
} else {
//批量录入数据
List<PqDevExcel> sgEventExcels = excelImportResult.getList();
pqDevService.importPqDevData(sgEventExcels);
}
} catch (Exception e) {
throw new BusinessException(MachineResponseEnum.IMPORT_DATA_FAIL);
throw new BusinessException(DeviceResponseEnum.IMPORT_DATA_FAIL);
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@@ -145,4 +146,43 @@ public class PqDevController extends BaseController {
public void export(@RequestBody @Validated PqDevParam.PqDevQueryParam 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);
}
}
}

View File

@@ -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.njcn.gather.machine.device.pojo.po.PqDev;
import com.njcn.gather.device.device.pojo.po.PqDev;
/**
* @author caozehui

View File

@@ -1,6 +1,6 @@
<?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.machine.device.mapper.PqDevMapper">
<mapper namespace="com.njcn.gather.device.device.mapper.PqDevMapper">
</mapper>

View File

@@ -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.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.param.BaseParam;
import io.swagger.annotations.ApiModelProperty;
@@ -11,6 +11,7 @@ import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.List;
/**
* @author caozehui
@@ -20,66 +21,66 @@ import javax.validation.constraints.Pattern;
public class PqDevParam {
@ApiModelProperty(value = "名称", required = true)
@NotBlank(message = MachineValidMessage.NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = MachineValidMessage.NAME_FORMAT_ERROR)
@NotBlank(message = DeviceValidMessage.NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DeviceValidMessage.NAME_FORMAT_ERROR)
private String name;
@ApiModelProperty(value = "设备模式,字典表(数字、模拟、比对)", required = true)
@NotBlank(message = MachineValidMessage.PATTERN_NOT_BLANK)
@NotBlank(message = DeviceValidMessage.PATTERN_NOT_BLANK)
private String pattern;
@ApiModelProperty(value = "设备类型,字典表", required = true)
@NotBlank(message = MachineValidMessage.DEV_TYPE_NOT_BLANK)
@NotBlank(message = DeviceValidMessage.DEV_TYPE_NOT_BLANK)
private String devType;
@ApiModelProperty(value = "设备通道数", required = true)
@NotNull(message = MachineValidMessage.DEV_CHNS_NOT_NULL)
@NotNull(message = DeviceValidMessage.DEV_CHNS_NOT_NULL)
private Integer devChns;
@ApiModelProperty(value = "额定电压V", required = true)
@NotNull(message = MachineValidMessage.DEV_VOLT_NOT_NULL)
@NotNull(message = DeviceValidMessage.DEV_VOLT_NOT_NULL)
private Float devVolt;
@ApiModelProperty(value = "额定电流A", required = true)
@NotNull(message = MachineValidMessage.DEV_CURR_NOT_NULL)
@NotNull(message = DeviceValidMessage.DEV_CURR_NOT_NULL)
private Float devCurr;
@ApiModelProperty(value = "生产厂家,字典表", required = true)
@NotBlank(message = MachineValidMessage.MANUFACTURER_NOT_BLANK)
@NotBlank(message = DeviceValidMessage.MANUFACTURER_NOT_BLANK)
private String manufacturer;
@ApiModelProperty(value = "生产日期", required = true)
@NotBlank(message = MachineValidMessage.CREATEDATETIME_NOT_NULL)
@DateTimeStrValid(format = "yyyy-MM-dd", message = MachineValidMessage.CREATEDATETIME_FORMAT_ERROR)
@NotBlank(message = DeviceValidMessage.CREATEDATETIME_NOT_NULL)
@DateTimeStrValid(format = "yyyy-MM-dd", message = DeviceValidMessage.CREATEDATETIME_FORMAT_ERROR)
private String createDate;
@ApiModelProperty(value = "出厂编号", required = true)
@NotBlank(message = MachineValidMessage.FACTORYNO_NOT_BLANK)
@NotBlank(message = DeviceValidMessage.FACTORYNO_NOT_BLANK)
private String createId;
@ApiModelProperty(value = "固件版本", required = true)
@NotBlank(message = MachineValidMessage.FIRMWARE_NOT_BLANK)
@NotBlank(message = DeviceValidMessage.FIRMWARE_NOT_BLANK)
private String hardwareVersion;
@ApiModelProperty(value = "软件版本", required = true)
@NotBlank(message = MachineValidMessage.SOFTWARE_NOT_BLANK)
@NotBlank(message = DeviceValidMessage.SOFTWARE_NOT_BLANK)
private String softwareVersion;
@ApiModelProperty(value = "通讯协议", required = true)
@NotBlank(message = MachineValidMessage.PROTOCOL_NOT_BLANK)
@NotBlank(message = DeviceValidMessage.PROTOCOL_NOT_BLANK)
private String protocol;
@ApiModelProperty(value = "IP地址", required = true)
@NotBlank(message = MachineValidMessage.IP_NOT_BLANK)
@Pattern(regexp = PatternRegex.IP_REGEX, message = MachineValidMessage.IP_FORMAT_ERROR)
@NotBlank(message = DeviceValidMessage.IP_NOT_BLANK)
@Pattern(regexp = PatternRegex.IP_REGEX, message = DeviceValidMessage.IP_FORMAT_ERROR)
private String ip;
@ApiModelProperty(value = "端口号", required = true)
@NotNull(message = MachineValidMessage.PORT_NOT_NULL)
@NotNull(message = DeviceValidMessage.PORT_NOT_NULL)
private Integer port;
@ApiModelProperty(value = "装置是否为加密版本", required = true)
@NotNull(message = MachineValidMessage.ENCRYPTION_NOT_NULL)
@NotNull(message = DeviceValidMessage.ENCRYPTION_NOT_NULL)
private Integer encryption;
@ApiModelProperty("装置识别码3ds加密")
@@ -92,7 +93,7 @@ public class PqDevParam {
private String sampleId;
@ApiModelProperty(value = "送样日期")
@DateTimeStrValid(message = MachineValidMessage.ARRIVE_DATE_TIME_FORMAT_ERROR)
@DateTimeStrValid(message = DeviceValidMessage.ARRIVE_DATE_TIME_FORMAT_ERROR)
private String arrivedDate;
@ApiModelProperty("所属地市名称")
@@ -123,7 +124,7 @@ public class PqDevParam {
private String qrCode;
@ApiModelProperty(value = "复检次数,默认为0", required = true)
@NotNull(message = MachineValidMessage.RECHECK_NUM_NOT_NULL)
@NotNull(message = DeviceValidMessage.RECHECK_NUM_NOT_NULL)
private Integer reCheckNum;
@@ -135,8 +136,8 @@ public class PqDevParam {
public static class PqDevUpdateParam extends PqDevParam {
@ApiModelProperty("id")
@NotBlank(message = MachineValidMessage.ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = MachineValidMessage.ID_FORMAT_ERROR)
@NotBlank(message = DeviceValidMessage.ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.ID_FORMAT_ERROR)
private String id;
}
@@ -148,10 +149,23 @@ public class PqDevParam {
@EqualsAndHashCode(callSuper = true)
public static class PqDevQueryParam extends BaseParam {
@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;
@ApiModelProperty("设备类型")
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;
}
}

View File

@@ -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.TableField;
@@ -191,5 +191,10 @@ public class PqDev extends BaseEntity implements Serializable {
* 状态0-删除 1-正常
*/
private Integer state;
/**
* 检测计划id
*/
private String planId;
}

View File

@@ -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 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 javax.validation.constraints.NotBlank;
@@ -21,66 +21,66 @@ public class PqDevExcel implements Serializable {
private static final long serialVersionUID = 1L;
@Excel(name = "名称", width = 20)
@NotBlank(message = MachineValidMessage.NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = MachineValidMessage.NAME_FORMAT_ERROR)
@NotBlank(message = DeviceValidMessage.NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DeviceValidMessage.NAME_FORMAT_ERROR)
private String name;
@Excel(name = "设备模式", width = 20)
@NotBlank(message = MachineValidMessage.PATTERN_NOT_BLANK)
@NotBlank(message = DeviceValidMessage.PATTERN_NOT_BLANK)
private String pattern;
@Excel(name = "设备类型", width = 20)
@NotBlank(message = MachineValidMessage.DEV_TYPE_NOT_BLANK)
@NotBlank(message = DeviceValidMessage.DEV_TYPE_NOT_BLANK)
private String devType;
@Excel(name = "设备通道数", width = 20)
@NotNull(message = MachineValidMessage.DEV_CHNS_NOT_NULL)
@NotNull(message = DeviceValidMessage.DEV_CHNS_NOT_NULL)
private Integer devChns;
@Excel(name = "额定电压V", width = 15)
@NotNull(message = MachineValidMessage.DEV_VOLT_NOT_NULL)
@NotNull(message = DeviceValidMessage.DEV_VOLT_NOT_NULL)
private Float devVolt;
@Excel(name = "额定电流A", width = 15)
@NotNull(message = MachineValidMessage.DEV_CURR_NOT_NULL)
@NotNull(message = DeviceValidMessage.DEV_CURR_NOT_NULL)
private Float devCurr;
@Excel(name = "生产厂家", width = 20)
@NotBlank(message = MachineValidMessage.MANUFACTURER_NOT_BLANK)
@NotBlank(message = DeviceValidMessage.MANUFACTURER_NOT_BLANK)
private String manufacturer;
@Excel(name = "生产日期yyyy-MM-dd", width = 25, format = "yyyy-MM-dd")
@NotNull(message = MachineValidMessage.CREATEDATETIME_NOT_NULL)
//@DateTimeStrValid(format = "yyyy-MM-dd", message = MachineValidMessage.CREATEDATETIME_FORMAT_ERROR)
@NotNull(message = DeviceValidMessage.CREATEDATETIME_NOT_NULL)
//@DateTimeStrValid(format = "yyyy-MM-dd", message = DeviceValidMessage.CREATEDATETIME_FORMAT_ERROR)
private LocalDate createDate;
@Excel(name = "出厂编号", width = 40)
@NotBlank(message = MachineValidMessage.FACTORYNO_NOT_BLANK)
@NotBlank(message = DeviceValidMessage.FACTORYNO_NOT_BLANK)
private String createId;
@Excel(name = "固件版本", width = 15)
@NotBlank(message = MachineValidMessage.FIRMWARE_NOT_BLANK)
@NotBlank(message = DeviceValidMessage.FIRMWARE_NOT_BLANK)
private String hardwareVersion;
@Excel(name = "软件版本", width = 15)
@NotBlank(message = MachineValidMessage.SOFTWARE_NOT_BLANK)
@NotBlank(message = DeviceValidMessage.SOFTWARE_NOT_BLANK)
private String softwareVersion;
@Excel(name = "通讯协议", width = 15)
@NotBlank(message = MachineValidMessage.PROTOCOL_NOT_BLANK)
@NotBlank(message = DeviceValidMessage.PROTOCOL_NOT_BLANK)
private String protocol;
@Excel(name = "IP地址", width = 20)
@NotBlank(message = MachineValidMessage.IP_NOT_BLANK)
@Pattern(regexp = PatternRegex.IP_REGEX, message = MachineValidMessage.IP_FORMAT_ERROR)
@NotBlank(message = DeviceValidMessage.IP_NOT_BLANK)
@Pattern(regexp = PatternRegex.IP_REGEX, message = DeviceValidMessage.IP_FORMAT_ERROR)
private String ip;
@Excel(name = "端口号")
@NotNull(message = MachineValidMessage.PORT_NOT_NULL)
@NotNull(message = DeviceValidMessage.PORT_NOT_NULL)
private Integer port;
@Excel(name = "是否为加密版本1是/0", width = 20)
@NotNull(message = MachineValidMessage.ENCRYPTION_NOT_NULL)
@NotNull(message = DeviceValidMessage.ENCRYPTION_NOT_NULL)
private Integer encryption;
@Excel(name = "识别码(未加密)", width = 30)
@@ -93,7 +93,7 @@ public class PqDevExcel implements Serializable {
private String sampleId;
@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;
@Excel(name = "所属地市名称", width = 20)
@@ -124,6 +124,6 @@ public class PqDevExcel implements Serializable {
private String qrCode;
@Excel(name = "复检次数", width = 15)
@NotNull(message = MachineValidMessage.RECHECK_NUM_NOT_NULL)
@NotNull(message = DeviceValidMessage.RECHECK_NUM_NOT_NULL)
private Integer reCheckNum;
}

View File

@@ -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.service.IService;
import com.njcn.gather.machine.device.pojo.param.PqDevParam;
import com.njcn.gather.machine.device.pojo.po.PqDev;
import com.njcn.gather.machine.device.pojo.vo.PqDevExcel;
import com.njcn.gather.device.device.pojo.param.PqDevParam;
import com.njcn.gather.device.device.pojo.po.PqDev;
import com.njcn.gather.device.device.pojo.vo.PqDevExcel;
import java.util.List;
@@ -66,4 +66,27 @@ public interface IPqDevService extends IService<PqDev> {
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);
}

View File

@@ -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.util.ObjectUtil;
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.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.db.mybatisplus.constant.DbConstant;
import com.njcn.gather.machine.device.mapper.PqDevMapper;
import com.njcn.gather.machine.device.pojo.param.PqDevParam;
import com.njcn.gather.machine.device.pojo.po.PqDev;
import com.njcn.gather.machine.device.pojo.vo.PqDevExcel;
import com.njcn.gather.machine.device.service.IPqDevService;
import com.njcn.gather.machine.device.util.DeviceUtil;
import com.njcn.gather.device.device.pojo.param.PqDevParam;
import com.njcn.gather.device.device.pojo.vo.PqDevExcel;
import com.njcn.gather.device.device.service.IPqDevService;
import com.njcn.gather.device.device.mapper.PqDevMapper;
import com.njcn.gather.device.device.pojo.po.PqDev;
import com.njcn.gather.device.device.util.DeviceUtil;
import com.njcn.web.factory.PageFactory;
import com.njcn.web.utils.ExcelUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @author caozehui
@@ -130,4 +133,43 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
List<PqDevExcel> pqDevExcels = BeanUtil.copyToList(pqDevs, PqDevExcel.class);
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;
}
}

View File

@@ -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 org.apache.commons.codec.binary.Base64;

View File

@@ -1,10 +1,10 @@
package com.njcn.gather.machine.pojo.constant;
package com.njcn.gather.device.pojo.constant;
/**
* @author caozehui
* @date 2024/11/06
*/
public interface MachineValidMessage {
public interface DeviceValidMessage {
String ID_NOT_BLANK = "id不能为空请检查id参数";
@@ -48,5 +48,9 @@ public interface MachineValidMessage {
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参数";
}

View File

@@ -1,9 +1,9 @@
package com.njcn.gather.machine.pojo.enums;
package com.njcn.gather.device.pojo.enums;
import lombok.Getter;
@Getter
public enum MachineResponseEnum {
public enum DeviceResponseEnum {
//NAME_REPEAT("A001001", "名称重复"),
IMPORT_DATA_FAIL("A001002", "导入数据失败");
@@ -12,7 +12,7 @@ public enum MachineResponseEnum {
private final String message;
MachineResponseEnum(String code, String message) {
DeviceResponseEnum(String code, String message) {
this.code = code;
this.message = message;
}