diff --git a/src/main/java/com/letian/modules/production/entity/SoScheduleRmMoveData.java b/src/main/java/com/letian/modules/production/entity/SoScheduleRmMoveData.java new file mode 100644 index 0000000..df832e4 --- /dev/null +++ b/src/main/java/com/letian/modules/production/entity/SoScheduleRmMoveData.java @@ -0,0 +1,100 @@ +package com.letian.modules.production.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * 排产原材料移库存储过程 {@code SO_Schedule_MoveRM} 入参 - rqrq + * + * @author rqrq + */ +public class SoScheduleRmMoveData { + + private String site; + private String orderNo; + private Float scheduleQty; + private String fromWarehouseID; + private String toWarehouseID; + + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date transDate; + + private String userID; + private String receiver; + private String partnerID; + + public String getSite() { + return site; + } + + public void setSite(String site) { + this.site = site; + } + + public String getOrderNo() { + return orderNo; + } + + public void setOrderNo(String orderNo) { + this.orderNo = orderNo; + } + + public Float getScheduleQty() { + return scheduleQty; + } + + public void setScheduleQty(Float scheduleQty) { + this.scheduleQty = scheduleQty; + } + + public String getFromWarehouseID() { + return fromWarehouseID; + } + + public void setFromWarehouseID(String fromWarehouseID) { + this.fromWarehouseID = fromWarehouseID; + } + + public String getToWarehouseID() { + return toWarehouseID; + } + + public void setToWarehouseID(String toWarehouseID) { + this.toWarehouseID = toWarehouseID; + } + + public Date getTransDate() { + return transDate; + } + + public void setTransDate(Date transDate) { + this.transDate = transDate; + } + + public String getUserID() { + return userID; + } + + public void setUserID(String userID) { + this.userID = userID; + } + + public String getReceiver() { + return receiver; + } + + public void setReceiver(String receiver) { + this.receiver = receiver; + } + + public String getPartnerID() { + return partnerID; + } + + public void setPartnerID(String partnerID) { + this.partnerID = partnerID; + } +} diff --git a/src/main/java/com/letian/modules/production/entity/SoScheduleRmStockCheckData.java b/src/main/java/com/letian/modules/production/entity/SoScheduleRmStockCheckData.java new file mode 100644 index 0000000..c7a6255 --- /dev/null +++ b/src/main/java/com/letian/modules/production/entity/SoScheduleRmStockCheckData.java @@ -0,0 +1,46 @@ +package com.letian.modules.production.entity; + +/** + * 排产原料库存检查存储过程 {@code SO_Schedule_CheckRMStock} 入参 - rqrq + * + * @author rqrq + */ +public class SoScheduleRmStockCheckData { + + private String site; + private String orderNo; + private Float scheduleQty; + private String fromWarehouseID; + + public String getSite() { + return site; + } + + public void setSite(String site) { + this.site = site; + } + + public String getOrderNo() { + return orderNo; + } + + public void setOrderNo(String orderNo) { + this.orderNo = orderNo; + } + + public Float getScheduleQty() { + return scheduleQty; + } + + public void setScheduleQty(Float scheduleQty) { + this.scheduleQty = scheduleQty; + } + + public String getFromWarehouseID() { + return fromWarehouseID; + } + + public void setFromWarehouseID(String fromWarehouseID) { + this.fromWarehouseID = fromWarehouseID; + } +} diff --git a/src/main/java/com/letian/modules/production/service/DailyPlanService.java b/src/main/java/com/letian/modules/production/service/DailyPlanService.java index cf48db4..861950e 100644 --- a/src/main/java/com/letian/modules/production/service/DailyPlanService.java +++ b/src/main/java/com/letian/modules/production/service/DailyPlanService.java @@ -323,4 +323,17 @@ public interface DailyPlanService { * @throw */ void circulationPlan(CirculationPlanData inData); + + /** + * @Description 排产原料库存检查(存储过程 SO_Schedule_CheckRMStock)- rqrq + * @return 短缺物料列表:PartNo、PartDescription、Spec 等(与过程结果集列名一致) + * @author rqrq + */ + List> soScheduleCheckRmStock(SoScheduleRmStockCheckData inData); + + /** + * @Description 排产原材料自动移库(存储过程 SO_Schedule_MoveRM)- rqrq + * @author rqrq + */ + void soScheduleMoveRm(SoScheduleRmMoveData inData); } diff --git a/src/main/java/com/letian/modules/production/service/impl/DailyPlanServiceImpl.java b/src/main/java/com/letian/modules/production/service/impl/DailyPlanServiceImpl.java index ec2c6f5..91ee527 100644 --- a/src/main/java/com/letian/modules/production/service/impl/DailyPlanServiceImpl.java +++ b/src/main/java/com/letian/modules/production/service/impl/DailyPlanServiceImpl.java @@ -16,6 +16,7 @@ import oracle.sql.DATE; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StringUtils; import java.math.BigDecimal; import java.text.ParseException; @@ -579,4 +580,91 @@ public class DailyPlanServiceImpl implements DailyPlanService { dailyPlanMapper.circulationSOScheduledList(inData); dailyPlanMapper.circulationScheduleSerialNoList(inData); } + + /** + * 存储过程返回行中读取结果码/消息(兼容 resultCode 与 result_column 命名)- rqrq + */ + private static String getProcedureString(Map row, String... preferredKeys) { + if (row == null) { + return ""; + } + for (String k : preferredKeys) { + if (row.containsKey(k) && row.get(k) != null) { + return String.valueOf(row.get(k)); + } + } + for (Map.Entry e : row.entrySet()) { + for (String k : preferredKeys) { + if (k.equalsIgnoreCase(e.getKey())) { + return e.getValue() == null ? "" : String.valueOf(e.getValue()); + } + } + } + return ""; + } + + @Override + public List> soScheduleCheckRmStock(SoScheduleRmStockCheckData inData) { + if (inData == null) { + throw new RuntimeException("参数不能为空"); + } + if (!StringUtils.hasText(inData.getSite()) || !StringUtils.hasText(inData.getOrderNo())) { + throw new RuntimeException("工厂、订单号不能为空"); + } + if (inData.getScheduleQty() == null || inData.getScheduleQty() <= 0) { + throw new RuntimeException("排产数量必须大于0"); + } + if (!StringUtils.hasText(inData.getFromWarehouseID())) { + throw new RuntimeException("发出仓库不能为空"); + } + List params = new ArrayList<>(); + params.add(inData.getSite()); + params.add(inData.getOrderNo()); + params.add(inData.getScheduleQty()); + params.add(inData.getFromWarehouseID()); + return procedureMapper.getProcedureData("SO_Schedule_CheckRMStock", params); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void soScheduleMoveRm(SoScheduleRmMoveData inData) { + if (inData == null) { + throw new RuntimeException("参数不能为空"); + } + if (!StringUtils.hasText(inData.getSite()) || !StringUtils.hasText(inData.getOrderNo())) { + throw new RuntimeException("工厂、订单号不能为空"); + } + if (inData.getScheduleQty() == null || inData.getScheduleQty() <= 0) { + throw new RuntimeException("排产数量必须大于0"); + } + if (!StringUtils.hasText(inData.getFromWarehouseID()) || !StringUtils.hasText(inData.getToWarehouseID())) { + throw new RuntimeException("发出仓库、接收仓库不能为空"); + } + if (inData.getTransDate() == null) { + throw new RuntimeException("单据日期不能为空"); + } + if (!StringUtils.hasText(inData.getUserID())) { + throw new RuntimeException("用户ID不能为空"); + } + List params = new ArrayList<>(); + params.add(inData.getSite()); + params.add(inData.getOrderNo()); + params.add(inData.getScheduleQty()); + params.add(inData.getFromWarehouseID()); + params.add(inData.getToWarehouseID()); + params.add(inData.getTransDate()); + params.add(inData.getUserID()); + params.add(StringUtils.hasText(inData.getReceiver()) ? inData.getReceiver() : ""); + params.add(StringUtils.hasText(inData.getPartnerID()) ? inData.getPartnerID() : "*"); + List> resultList = procedureMapper.getProcedureData("SO_Schedule_MoveRM", params); + if (resultList == null || resultList.isEmpty()) { + throw new RRException("SO_Schedule_MoveRM 无返回结果"); + } + Map resultMap = resultList.get(resultList.size() - 1); + String resultCode = getProcedureString(resultMap, "resultCode", "result_code"); + if (!"800".equalsIgnoreCase(resultCode)) { + String msg = getProcedureString(resultMap, "resultMsg", "result_msg"); + throw new RRException(StringUtils.hasText(msg) ? msg : ("移库失败,结果代码:" + resultCode)); + } + } }