Browse Source

2025.01.20 绩效&送货计划 第二版

master
yuejiayang 12 months ago
parent
commit
af86a8c54d
  1. 26
      src/main/java/com/xujie/sys/modules/deliverySchedule/service/impl/DeliveryScheduleServiceImpl.java
  2. 11
      src/main/resources/mapper/deliverySchedule/deliveryScheduleMapper.xml

26
src/main/java/com/xujie/sys/modules/deliverySchedule/service/impl/DeliveryScheduleServiceImpl.java

@ -9,6 +9,10 @@ import com.xujie.sys.modules.deliverySchedule.service.DeliveryScheduleService;
import com.xujie.sys.modules.deliverySchedule.mapper.DeliveryScheduleMapper; import com.xujie.sys.modules.deliverySchedule.mapper.DeliveryScheduleMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/** /**
* @author Jia * @author Jia
@ -34,12 +38,28 @@ public class DeliveryScheduleServiceImpl extends ServiceImpl<DeliveryScheduleMap
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public void autoReservationInitiateHandler(DeliveryScheduleData data) { public void autoReservationInitiateHandler(DeliveryScheduleData data) {
Double allotmentQty = data.getAllotmentQty(); Double allotmentQty = data.getAllotmentQty();
List<Double> pendingQtyList = new ArrayList<>();
for (DeliveryScheduleData deliveryScheduleData : data.getAutoReservationDataList()) { for (DeliveryScheduleData deliveryScheduleData : data.getAutoReservationDataList()) {
double pendingQty = deliveryScheduleData.getQty() - deliveryScheduleData.getDelNotifyQty();
if (allotmentQty <= 0){
break;
double pendingQty = 0.0;
if (deliveryScheduleData.getDelNotifyQty() == null){
pendingQty = deliveryScheduleData.getQty();
}else {
pendingQty = deliveryScheduleData.getQty() - deliveryScheduleData.getDelNotifyQty();
}
pendingQtyList.add(pendingQty);
// 如果是最后一个循环
if (data.getAutoReservationDataList().indexOf(deliveryScheduleData) == data.getAutoReservationDataList().size() - 1){
double sum = pendingQtyList.stream().mapToDouble(Double::doubleValue).sum();
if (sum <= 0){
throw new RuntimeException("请检查订单是否已经发货!");
}
if (pendingQty < allotmentQty) {
throw new RuntimeException("总待发货数量超过总订单数量,无法自动预留!");
}
} }
if (pendingQty <= allotmentQty){ if (pendingQty <= allotmentQty){
deliveryScheduleData.setDeliveryQty(pendingQty); deliveryScheduleData.setDeliveryQty(pendingQty);

11
src/main/resources/mapper/deliverySchedule/deliveryScheduleMapper.xml

@ -28,10 +28,10 @@
POD.OrderRef2, POD.OrderRef2,
SOR.OperationDesc, SOR.OperationDesc,
POD.QTY, POD.QTY,
POD.DelNotifyQty,
POD.QTY - POD.DelNotifyQty AS PendingQty,
ISNULL(POD.DelNotifyQty,0) AS DelNotifyQty,
POD.QTY - ISNULL(POD.DelNotifyQty,0) AS PendingQty,
POD.BatchNo, POD.BatchNo,
COALESCE(POD.DeliveryQty, POD.QTY - POD.DelNotifyQty) AS DeliveryQty,
COALESCE(POD.DeliveryQty, POD.QTY - ISNULL(POD.DelNotifyQty,0)) AS DeliveryQty,
CASE CASE
WHEN POD.OrderRefType = '生产订单' THEN SO.PlanStartDate WHEN POD.OrderRefType = '生产订单' THEN SO.PlanStartDate
WHEN POD.OrderRefType IN ('外协订单', '外协订单-产品') THEN OWO.PlanStartDate WHEN POD.OrderRefType IN ('外协订单', '外协订单-产品') THEN OWO.PlanStartDate
@ -61,8 +61,11 @@
OR (POD.OrderRefType IN ('外协订单', '外协订单-产品') AND OWO.PlanStartDate IS NOT NULL) OR (POD.OrderRefType IN ('外协订单', '外协订单-产品') AND OWO.PlanStartDate IS NOT NULL)
OR (POD.OrderRefType = '生产订单-工序外协' AND SOR.PlanStartTime IS NOT NULL) OR (POD.OrderRefType = '生产订单-工序外协' AND SOR.PlanStartTime IS NOT NULL)
) )
AND POD.status NOT IN ('已取消', '已入库')
AND POD.status IN ('已下达', '部分入库','部分接收')
AND POD.site = #{query.site} AND POD.site = #{query.site}
<if test="query.Status != null and query.Status != ''">
AND POD.status = #{query.Status}
</if>
<if test="query.OrderNo != null and query.OrderNo != ''"> <if test="query.OrderNo != null and query.OrderNo != ''">
AND POD.OrderNo like #{query.OrderNo} AND POD.OrderNo like #{query.OrderNo}
</if> </if>

Loading…
Cancel
Save