zhanghl
2025-05-15 b3ed5823f971c04e5f814711a49c9baf7cdf54b9
aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlatePlanServiceImpl.java
@@ -1,5 +1,6 @@
package com.aps.core.service.impl;
import cn.hutool.core.util.IdUtil;
import com.aps.common.core.utils.DateUtils;
import com.aps.common.core.utils.uuid.IdUtils;
import com.aps.common.security.utils.DictUtils;
@@ -15,6 +16,8 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Hashtable;
import java.util.List;
import java.util.Optional;
@@ -68,7 +71,7 @@
    @Override
    public int insertApsPlatePlan(ApsPlatePlan apsPlatePlan)
    {
        apsPlatePlan.setId(IdUtils.fastUUID());
        apsPlatePlan.setId(IdUtil.getSnowflakeNextId());
        apsPlatePlan.setCreateTime(DateUtils.getNowDate());
        return apsPlatePlanMapper.insertApsPlatePlan(apsPlatePlan);
    }
@@ -122,7 +125,7 @@
            ids[i]=apsPartPlanTemps.get(i).getId();
            ApsPlatePlan platePlan=new ApsPlatePlan();
            BeanUtils.copyProperties(apsPartPlanTemps.get(i), platePlan);
            platePlan.setId(IdUtils.fastUUID());
            platePlan.setId(IdUtil.getSnowflakeNextId());
            platePlan.setCreateTime(DateUtils.getNowDate());
            //插入正式表,并记录
            apsPlatePlanMapper.insertApsPlatePlan(platePlan);
@@ -191,4 +194,21 @@
    public List<ApsPlatePlan> selectPlateRedundantOrderList(ApsPlatePlan apsPlatePlan) {
        return apsPlatePlanMapper.selectPlateRedundantOrderList(apsPlatePlan);
    }
    @Override
    public ApsPlatePlan selectUnMatchPlateSubPlan(String plant, String itemNumber, Hashtable<String, List<ApsPlatePlan>> subPlans) {
       if(subPlans.containsKey(itemNumber)) {
           List<ApsPlatePlan> subPlanList = subPlans.get(itemNumber);
           Optional<ApsPlatePlan> firstPlant = subPlanList.stream().filter(x -> x.getUnmatchedQuantity().compareTo(BigDecimal.ZERO) > 0).findFirst();
           return firstPlant.orElse(null);
       }else {
           List<ApsPlatePlan> plans = apsPlatePlanMapper.selectUnMatchPlateSubPlanList(plant, itemNumber);
           if (!plans.isEmpty()) {
               subPlans.put(itemNumber, plans);
               return selectUnMatchPlateSubPlan(plant, itemNumber, subPlans);
           } else {
               return null;
           }
       }
    }
}