优化标记号

This commit is contained in:
zc
2026-04-17 17:01:04 +08:00
parent e1a9fba2ca
commit 2b6c4ff7f3
6 changed files with 22 additions and 15 deletions

View File

@@ -30,12 +30,4 @@ public class BatchImportRowReq implements Serializable {
@Length(max = 255, message = "批次长度不能超过 {max} 个字符")
private String batch;
/**
* 标记
*/
@Schema(description = "标记")
@NotBlank(message = "标记不能为空")
@Length(max = 25, message = "标记长度不能超过 {max} 个字符")
private String mark;
}

View File

@@ -512,11 +512,17 @@ public class MaterialInfoServiceImpl extends BaseServiceImpl<MaterialInfoMapper,
// 总计行数
materialImportResp.setTotalRows(importRowList.size());
CheckUtils.throwIfEmpty(importRowList, "数据文件格式错误");
// 有效行数:过滤无效(同名物料)数据
// 有效行数:过滤无效数据
List<BatchImportRowReq> validRowList = this.filterImportData2(importRowList);
materialImportResp.setValidRows(validRowList.size());
CheckUtils.throwIfEmpty(validRowList, "数据文件格式错误");
Set<String> batchSet = validRowList.stream().map(BatchImportRowReq::getBatch).collect(Collectors.toSet());
if (batchSet.size() > 1) {
throw new BusinessException("存在不同批次数据,请检查批次信息");
}
validRowList = validRowList.stream().distinct().collect(Collectors.toList());
// 设置导入会话并缓存数据有效期10分钟
String importKey = UUID.fastUUID().toString(true);
RedisUtils.set(CacheConstants.DATA_IMPORT_KEY + importKey, JSONUtil.toJsonStr(validRowList), Duration
@@ -543,7 +549,6 @@ public class MaterialInfoServiceImpl extends BaseServiceImpl<MaterialInfoMapper,
MaterialInfoDO materialInfoDO = new MaterialInfoDO();
materialInfoDO.setEncoding(row.getEncoding());
materialInfoDO.setBatch(row.getBatch());
materialInfoDO.setMark(row.getMark());
materialInfoDO.setUpdateUser(UserContextHolder.getUserId());
return materialInfoDO;
}).toList();

View File

@@ -70,4 +70,10 @@ public class WorkOrderInfoReq implements Serializable {
*/
private Integer weightQuantity;
/**
* 标记
*/
@Schema(description = "标记")
private String mark;
}

View File

@@ -12,6 +12,7 @@ import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import top.continew.starter.core.exception.BusinessException;
import top.continew.starter.core.validation.CheckUtils;
import top.continew.starter.extension.crud.model.query.PageQuery;
import top.continew.starter.extension.crud.model.query.SortQuery;
@@ -156,7 +157,11 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
@Override
public WorkOrderResp addWorKerOrder(WorkOrderReq req) {
if (CollUtil.isEmpty(req.getWorkOrderInfos())) {
throw new IllegalArgumentException("称重列表不能为空");
throw new BusinessException("称重列表不能为空");
}
if (StrUtil.isBlank(req.getWorkOrderInfos().get(0).getMark())) {
throw new BusinessException("标记号不能为空");
}
BigDecimal totalWeight = new BigDecimal("0");
@@ -178,7 +183,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
workOrder.setTitle(title);
workOrder.setMaterialId(req.getMaterialId());
workOrder.setBatch(materialInfoDO.getBatch());
workOrder.setMark(materialInfoDO.getMark());
workOrder.setMark(req.getWorkOrderInfos().get(0).getMark());
workOrder.setTotalWeight(totalWeight);
workOrder.setTotalCount(totalCount);
workOrder.setTotalCalculatedWeight(materialInfoDO.getUnitWeight().multiply(BigDecimal.valueOf(totalCount)));
@@ -189,7 +194,6 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
workOrderInfoDOList.forEach(workOrderInfoDO -> {
workOrderInfoDO.setWorkOrderId(workOrder.getId());
workOrderInfoDO.setBatch(materialInfoDO.getBatch());
workOrderInfoDO.setMark(materialInfoDO.getMark());
});
workOrderInfoMapper.insertBatch(workOrderInfoDOList);

View File

@@ -28,9 +28,9 @@ import java.util.regex.Pattern;
public class AHDZCConnect {
//老设备只能跑jar包的
// private static final String PORT_NAME = "COM12";
private static final String PORT_NAME = "COM12";
//新设备(环境齐全的)
private static final String PORT_NAME = "COM13";
// private static final String PORT_NAME = "COM13";
private static final int BAUD_RATE = 9600;
private static final int DATA_BITS = 8;
private static final int STOP_BITS = 1;