zhanghl
2025-05-22 dae4a24949c0c8cfad87aff850b667d3cad399c1
aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlate/ApsPlateProcessStatServiceImpl.java
@@ -2,12 +2,15 @@
import java.math.BigDecimal;
import java.time.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import cn.hutool.core.util.IdUtil;
import com.aps.common.core.utils.uuid.IdUtils;
import com.aps.common.security.utils.SecurityUtils;
import com.aps.core.domain.ApsPlate.ApsPlateStandardRequireBomOrderDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.aps.core.mapper.ApsPlateProcessStatMapper;
@@ -109,9 +112,11 @@
    public void savePlateProcessStat() {
        String batchNum = IdUtils.fastSimpleUUID();
        List<ApsPlateProcessStat> tempList = apsPlateProcessStatMapper.queryTempStat();
        ApsPlateProcessStat apsPlateProcessStat = tempList.stream().filter(x -> x.getWorkOrderNo().equals("MO-250409003498")).findFirst().get();
        Map<String, List<ApsPlateProcessStat>> groupByOrderNo = tempList.stream().collect(groupingBy(ApsPlateProcessStat::getWorkOrderNo));
        Boolean hasBefore = false;
        LocalDateTime now = LocalDateTime.now();
        List<ApsPlateProcessStat> totalList=new ArrayList<>();
        for (Map.Entry<String, List<ApsPlateProcessStat>> entry : groupByOrderNo.entrySet()) {
            List<ApsPlateProcessStat> statPerOrder = entry.getValue();
            /*num 为根据完工时间排序出的序号,按此排序,可保证是按完工时间倒叙排列*/
@@ -176,13 +181,21 @@
                    }
                }
                last = stat;
                apsPlateProcessStatMapper.insertApsPlateProcessStat(stat);
                totalList.add(stat);
                //apsPlateProcessStatMapper.insertApsPlateProcessStat(stat);
            }
            hasBefore=false;
        }
        apsPlateProcessStatMapper.removeOtherStat(batchNum);
        if(!totalList.isEmpty()){
            int batchSize = 1000;
            totalList.forEach(x->x.setId(String.valueOf(IdUtil.getSnowflakeNextId())));
            for (int i = 0; i < totalList.size(); i += batchSize) {
                int end = Math.min(i + batchSize, totalList.size());
                List<ApsPlateProcessStat> batch = totalList.subList(i, end);
                apsPlateProcessStatMapper.batchInsertPlateStat(batch);
            }
        }
    }