|
@@ -254,10 +254,11 @@ public class MachineNodeServiceImpl implements NodeOperationService {
|
|
|
String unionCode = workpieceService.getUnionCode(task.getCompleteBatchNo());
|
|
|
|
|
|
Order order = orderMapper.selectById(task.getOrderId());
|
|
|
- TWorkpiece tWorkpiece = workpieceMapper.selectOne(Wraps.<TWorkpiece>lbQ().eq(TWorkpiece::getCompleteBatchNo, task.getCompleteBatchNo()));
|
|
|
- tWorkpiece.setProductNo(order.getSource().equals("2")? order.getBatchNo()+"-"+ String.format("%03d", tWorkpiece.getSerialNo()) : unionCode.substring(0, 12));
|
|
|
- workpieceService.updateById(tWorkpiece);
|
|
|
-
|
|
|
+ if ("2".equals(order.getSource())){
|
|
|
+ TWorkpiece tWorkpiece = workpieceMapper.selectOne(Wraps.<TWorkpiece>lbQ().eq(TWorkpiece::getCompleteBatchNo, task.getCompleteBatchNo()));
|
|
|
+ tWorkpiece.setProductNo(order.getSource().equals("2")? order.getBatchNo()+"-"+ String.format("%03d", tWorkpiece.getSerialNo()) : unionCode.substring(0, 12));
|
|
|
+ workpieceService.updateById(tWorkpiece);
|
|
|
+ }
|
|
|
BomProcedureVersion procedure = bomProcedureVersionService.getById(task.getProcedureId());
|
|
|
|
|
|
JSONObject data = new JSONObject();
|
|
@@ -268,8 +269,14 @@ public class MachineNodeServiceImpl implements NodeOperationService {
|
|
|
data.put("orderNo", order.getOrderNo());
|
|
|
data.put("taskNo", task.getTaskNo());
|
|
|
data.put("productNo", unionCode);
|
|
|
- data.put("batchNo", task.getCompleteBatchNo());
|
|
|
+// data.put("batchNo", task.getCompleteBatchNo());//打标内容
|
|
|
+ data.put("batchNo", completeBatchNoFormat(order.getBatchNo()));//打标内容
|
|
|
data.put("serialNo", task.getProcedureSort().toString());
|
|
|
+
|
|
|
+ //4. 打标成功后:编号递增并更新到order表
|
|
|
+ String nextBatchNo = incrementBatchNo(completeBatchNoFormat(order.getBatchNo())); //生成下一个编号
|
|
|
+ order.setBatchNo(nextBatchNo); //更新订单编号
|
|
|
+ orderMapper.updateById(order); //保存到数据库
|
|
|
map.put("data", data);
|
|
|
map.put("result", true);
|
|
|
}
|
|
@@ -425,6 +432,55 @@ public class MachineNodeServiceImpl implements NodeOperationService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ // 新增:补全编号格式的工具方法
|
|
|
+ private String completeBatchNoFormat(String batchNo) {
|
|
|
+ if (batchNo == null || batchNo.trim().isEmpty()) {
|
|
|
+ throw new IllegalArgumentException("打标基础编号不能为空");
|
|
|
+ }
|
|
|
+ String trimmedNo = batchNo.trim();
|
|
|
+ String[] parts = trimmedNo.split("-");
|
|
|
+
|
|
|
+ // 情况1:已有4部分(完整格式),直接返回
|
|
|
+ if (parts.length == 4) {
|
|
|
+ // 确保序号是3位数字(补零)
|
|
|
+ try {
|
|
|
+ int seq = Integer.parseInt(parts[3]);
|
|
|
+ return String.format("%s-%s-%s-%03d", parts[0], parts[1], parts[2], seq);
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ // 序号非数字时,默认使用001
|
|
|
+ return String.format("%s-%s-%s-001", parts[0], parts[1], parts[2]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 情况2:只有3部分(无序号),补全-001
|
|
|
+ if (parts.length == 3) {
|
|
|
+ return trimmedNo + "-001";
|
|
|
+ }
|
|
|
+
|
|
|
+ // 其他异常格式:默认使用基础格式(如传入"010125"则转为"01-01-25-001")
|
|
|
+ if (trimmedNo.length() >= 6) {
|
|
|
+ String part1 = trimmedNo.substring(0, 2);
|
|
|
+ String part2 = trimmedNo.substring(2, 4);
|
|
|
+ String part3 = trimmedNo.substring(4, 6);
|
|
|
+ return part1 + "-" + part2 + "-" + part3 + "-001";
|
|
|
+ }
|
|
|
+
|
|
|
+ // 无法解析的格式,返回默认值
|
|
|
+ return "00-00-00-001";
|
|
|
+ }
|
|
|
+
|
|
|
+ //新增:编号递增(01-01-25-001 → 01-01-25-002)
|
|
|
+ private String incrementBatchNo(String currentNo) {
|
|
|
+ String[] parts = currentNo.split("-");
|
|
|
+ if (parts.length != 4) {
|
|
|
+ throw new IllegalArgumentException("无效的编号格式:" + currentNo);
|
|
|
+ }
|
|
|
+
|
|
|
+ String prefix = parts[0] + "-" + parts[1] + "-" + parts[2];
|
|
|
+ int currentSeq = Integer.parseInt(parts[3]);
|
|
|
+ return prefix + "-" + String.format("%03d", currentSeq + 1);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Map operation(JSONObject jsonObject, JSONObject bizJsonObject, Map<String, Object> conMap) {
|
|
|
//获取节点指令操作名称
|