diff --git a/src/main/java/com/heai/modules/production/dao/DailyPlanMapper.java b/src/main/java/com/heai/modules/production/dao/DailyPlanMapper.java index fc2b8ad..bb01019 100644 --- a/src/main/java/com/heai/modules/production/dao/DailyPlanMapper.java +++ b/src/main/java/com/heai/modules/production/dao/DailyPlanMapper.java @@ -56,6 +56,10 @@ public interface DailyPlanMapper { * @throws: */ List getShopOrderList(DailyPlanInData dailyPlanInData); + + /** PDA 生产退库:仅按生产订单号查询(同号多工厂取 ENTERDATE 最新一条)- rqrq */ + ShopOrderData getShopOrderByOrderNoForReturn(@Param("orderNo") String orderNo); + /** * @Method * @Description: 获取混炼任务信息 diff --git a/src/main/java/com/heai/modules/production/entity/ShopOrderForReturnScanData.java b/src/main/java/com/heai/modules/production/entity/ShopOrderForReturnScanData.java index 361022b..0e36b66 100644 --- a/src/main/java/com/heai/modules/production/entity/ShopOrderForReturnScanData.java +++ b/src/main/java/com/heai/modules/production/entity/ShopOrderForReturnScanData.java @@ -5,7 +5,7 @@ import lombok.Data; import java.io.Serializable; /** - * 生产退库:扫派工单/混炼任务单统一入口 - rqrq + * PDA 生产退库:`orderStr` —分号分段第 4 段 SeqNo / 纯整数 SeqNo / 纯文本订单号(无混炼任务单扫码)- rqrq * * @author rqrq */ @@ -13,7 +13,7 @@ import java.io.Serializable; public class ShopOrderForReturnScanData implements Serializable { /** - * 扫到的内容:纯数字为派工单 SeqNo;HL 开头为混炼任务单(待扩展) + * 扫描内容 - rqrq */ private String orderStr; } diff --git a/src/main/java/com/heai/modules/production/service/impl/DailyPlanServiceImpl.java b/src/main/java/com/heai/modules/production/service/impl/DailyPlanServiceImpl.java index 06521cf..523b941 100644 --- a/src/main/java/com/heai/modules/production/service/impl/DailyPlanServiceImpl.java +++ b/src/main/java/com/heai/modules/production/service/impl/DailyPlanServiceImpl.java @@ -870,7 +870,7 @@ public class DailyPlanServiceImpl implements DailyPlanService { } /** - * @Description PDA 生产退库扫码:纯数字→派工单 SeqNo;HL 开头→混炼任务单 TaskNo 查 Hunlian_TaskHeader.orderRef1 再走生产订单 - rqrq + * @Description PDA 生产退库扫码:①含分号取第 4 段 SeqNo;②整段整数为 SeqNo;③否则按生产订单号查询(无混炼任务单扫码)- rqrq */ @Override public ShopOrderData getShopOrderForReturnByScan(ShopOrderForReturnScanData scan) { @@ -878,23 +878,53 @@ public class DailyPlanServiceImpl implements DailyPlanService { throw new RuntimeException("扫描内容不能为空"); } String raw = scan.getOrderStr().trim(); - if (isAllDigitsDispatchOrder(raw)) { - DailyPlanInData dailyPlanInData = new DailyPlanInData(); - try { - dailyPlanInData.setSeqNo(Integer.parseInt(raw)); - } catch (NumberFormatException e) { - throw new RuntimeException("派工单号格式错误"); + + if (raw.contains(";")) { + String[] parts = raw.split(";", -1); + if (parts.length < 4) { + throw new RuntimeException("扫码格式错误(分号分段不足)"); + } + Integer seqNoFromQr = parseIntegerSeqNo(parts[3]); + if (seqNoFromQr == null) { + throw new RuntimeException("扫码第4段派工单序号格式错误"); } - dailyPlanInData.setRemark("生产退库"); - return getShopOrderForReturn(dailyPlanInData); + DailyPlanInData dispatchData = new DailyPlanInData(); + dispatchData.setSeqNo(seqNoFromQr); + dispatchData.setRemark("生产退库"); + return getShopOrderForReturn(dispatchData); } - if (raw.toUpperCase().startsWith("HL")) { - HunlianData hl = new HunlianData(); - hl.setTaskNo(raw); - return getShopOrderForHunlianTask(hl); + + Integer directSeqNo = parseIntegerSeqNo(raw); + if (directSeqNo != null) { + DailyPlanInData dispatchData = new DailyPlanInData(); + dispatchData.setSeqNo(directSeqNo); + dispatchData.setRemark("生产退库"); + return getShopOrderForReturn(dispatchData); + } + + ShopOrderData byOrderOnly = dailyPlanMapper.getShopOrderByOrderNoForReturn(raw); + if (byOrderOnly == null || !StringUtils.hasText(byOrderOnly.getOrderNo())) { + throw new RuntimeException("该生产订单不存在"); } + return byOrderOnly; + } - throw new RuntimeException("只能扫派工单和混炼任务单二维码"); + /** + * 仅识别非空十进制整数(派工单 SeqNo);含字母/小数等返回 null - rqrq + */ + private static Integer parseIntegerSeqNo(String part) { + if (!StringUtils.hasText(part)) { + return null; + } + String t = part.trim(); + if (!isAllDigitsDispatchOrder(t)) { + return null; + } + try { + return Integer.parseInt(t); + } catch (NumberFormatException e) { + return null; + } } private static boolean isAllDigitsDispatchOrder(String s) { diff --git a/src/main/resources/mapper/production/DailyPlanMapper.xml b/src/main/resources/mapper/production/DailyPlanMapper.xml index a52632b..4e84f94 100644 --- a/src/main/resources/mapper/production/DailyPlanMapper.xml +++ b/src/main/resources/mapper/production/DailyPlanMapper.xml @@ -140,6 +140,24 @@ + + +