机台管理接口入参检查完善

This commit is contained in:
gaoqr
2024-10-16 14:52:16 +08:00
parent 94908e01eb
commit 266e11c202
4 changed files with 37 additions and 6 deletions
@@ -32,6 +32,7 @@ public class CuttingSaveReqVO {
private Integer machineType; private Integer machineType;
@Schema(description = "标签id") @Schema(description = "标签id")
@NotNull(message = "标签id不能空")
private Long labelId; private Long labelId;
// // 新的机台逻辑需要删除 // // 新的机台逻辑需要删除
@@ -40,6 +41,7 @@ public class CuttingSaveReqVO {
// private Long templateId; // private Long templateId;
@Schema(description = "品牌ID", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "品牌ID", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "品牌ID不能为空")
private Long brandId; private Long brandId;
@@ -31,10 +31,11 @@ public class CuttingTemplateSaveReqVO {
@Schema(description = "当前品牌ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") @Schema(description = "当前品牌ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotNull(message = "当前品牌ID不能为空")
private Long nowBrandId; private Long nowBrandId;
@Schema(description = "引用的品牌ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") @Schema(description = "引用的品牌ID", example = "2")
private Long brandId; private Long brandId;
@@ -54,7 +55,7 @@ public class CuttingTemplateSaveReqVO {
// private String model; // private String model;
@Schema(description = "机台的型号-机台ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") @Schema(description = "机台的型号-机台ID", example = "2")
private Long machineId; private Long machineId;
@@ -3,6 +3,8 @@ package com.cf.imes.module.system.controller.admin.machine.vo;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotNull;
/** /**
* @author Beal * @author Beal
*/ */
@@ -10,26 +12,32 @@ import lombok.Data;
public class MachineOrgAuthReq { public class MachineOrgAuthReq {
@Schema(description = "组织id", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "组织id", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "组织id不能为空")
private Long organId; private Long organId;
@Schema(description = "开料机授权数量") @Schema(description = "开料机授权数量")
@NotNull(message = "开料机授权数量不能为空")
private Integer cutLimit; private Integer cutLimit;
@Schema(description = "钻孔机授权数量") @Schema(description = "钻孔机授权数量")
@NotNull(message = "钻孔机授权数量不能为空")
private Integer drillLimit; private Integer drillLimit;
@Schema(description = "贴标机授权数量") @Schema(description = "贴标机授权数量")
@NotNull(message = "贴标机授权数量不能为空")
private Integer labelLimit; private Integer labelLimit;
@Schema(description = "裁板锯授权数量") @Schema(description = "裁板锯授权数量")
@NotNull(message = "裁板锯授权数量不能为空")
private Integer sawLimit; private Integer sawLimit;
@Schema(description = "封边机授权数量") @Schema(description = "封边机授权数量")
@NotNull(message = "封边机授权数量不能为空")
private Integer sealedgeLimit; private Integer sealedgeLimit;
@@ -1,6 +1,7 @@
package com.cf.imes.module.system.service.machine; package com.cf.imes.module.system.service.machine;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import co.elastic.clients.elasticsearch.ElasticsearchClient; import co.elastic.clients.elasticsearch.ElasticsearchClient;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cf.imes.framework.common.enums.CommonStatusEnum; import com.cf.imes.framework.common.enums.CommonStatusEnum;
@@ -148,7 +149,11 @@ public class MachineTemplateServiceImpl implements MachineTemplateService {
// MachineBrandDO machineBrandDO = machineBrandMapper.selectById(reqVO.getId()); // MachineBrandDO machineBrandDO = machineBrandMapper.selectById(reqVO.getId());
List<MachineTemplateDO> machineTemplateDOS = machineTemplateMapper.selectByBrand(reqVO.getId()); Long brandId = reqVO.getId();
// 校验品牌是否存在
validateBrandExistes(brandId);
List<MachineTemplateDO> machineTemplateDOS = machineTemplateMapper.selectByBrand(brandId);
if (!machineTemplateDOS.isEmpty()) { if (!machineTemplateDOS.isEmpty()) {
// throw exception(MACHINE_TEMPLATE_NOT_EXISTS); // throw exception(MACHINE_TEMPLATE_NOT_EXISTS);
@@ -160,7 +165,7 @@ public class MachineTemplateServiceImpl implements MachineTemplateService {
} }
machineBrandMapper.deleteById(reqVO.getId()); machineBrandMapper.deleteById(brandId);
return Boolean.TRUE; return Boolean.TRUE;
} }
@@ -281,8 +286,8 @@ public class MachineTemplateServiceImpl implements MachineTemplateService {
public void updateMachineTemplateBrand(MachineTemplateBrandReqVO reqVO) { public void updateMachineTemplateBrand(MachineTemplateBrandReqVO reqVO) {
// MachineBrandDO machineBrandDO = machineBrandMapper.selectBrand(reqVO.getBrand(), reqVO.getMachineType()); // MachineBrandDO machineBrandDO = machineBrandMapper.selectBrand(reqVO.getBrand(), reqVO.getMachineType());
// 校验机台品牌是否存在
MachineBrandDO machineBrandDO = machineBrandMapper.selectById(reqVO.getId()); MachineBrandDO machineBrandDO = validateBrandExistes(reqVO.getId());
machineBrandDO.setBrand(reqVO.getBrand()); machineBrandDO.setBrand(reqVO.getBrand());
@@ -291,6 +296,21 @@ public class MachineTemplateServiceImpl implements MachineTemplateService {
} }
/**
* 校验机台品牌是否存在
*
* @param id
*/
private MachineBrandDO validateBrandExistes(Long id) {
MachineBrandDO machineBrandDO = machineBrandMapper.selectById(id);
if (ObjectUtil.isNull(machineBrandDO)) {
throw exception(THE_CURRENT_BRAND);
}
return machineBrandDO;
}
@Override @Override
public TemplateAutoResp getTemplateAuth(Long organId) { public TemplateAutoResp getTemplateAuth(Long organId) {