wenwj
2025-04-09 df6bb7f982ca8a4ba57a87ef85aad58bfc4dd524
aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlatePlanServiceImpl.java
@@ -1,6 +1,15 @@
package com.aps.core.service.impl;
import java.util.List;
import com.aps.common.core.utils.uuid.IdUtils;
import com.aps.common.security.utils.DictUtils;
import com.aps.core.domain.ApsPlatePlanTemp;
import com.aps.core.mapper.ApsPartPlanTempMapper;
import com.aps.core.mapper.ApsPlatePlanTempMapper;
import com.aps.system.api.domain.SysDictData;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.aps.core.mapper.ApsPlatePlanMapper;
@@ -18,6 +27,11 @@
{
    @Autowired
    private ApsPlatePlanMapper apsPlatePlanMapper;
    @Autowired
    private ApsPartPlanTempMapper apsPartPlanTempMapper;
    @Autowired
    private ApsPlatePlanTempMapper apsPlatePlanTempMapper;
    /**
     * 查询钣金计划管理
@@ -52,6 +66,7 @@
    @Override
    public int insertApsPlatePlan(ApsPlatePlan apsPlatePlan)
    {
        apsPlatePlan.setId(IdUtils.fastUUID());
        return apsPlatePlanMapper.insertApsPlatePlan(apsPlatePlan);
    }
@@ -90,4 +105,52 @@
    {
        return apsPlatePlanMapper.deleteApsPlatePlanById(id);
    }
    @Override
    public int confirmPlan(ApsPlatePlanTemp tempPlan) {
        //查询临时表数据
        List<ApsPlatePlanTemp> apsPartPlanTemps=apsPlatePlanTempMapper.selectApsPlatePlanTempList(tempPlan);
        int count=0;
        String[] ids=new String[apsPartPlanTemps.size()];
        for (int i = 0; i <apsPartPlanTemps.size() ; i++) {
            //记录临时表id
            ids[i]=apsPartPlanTemps.get(i).getId();
            ApsPlatePlan platePlan=new ApsPlatePlan();
            BeanUtils.copyProperties(apsPartPlanTemps.get(i), platePlan);
            platePlan.setId(IdUtils.fastUUID());
            //插入正式表,并记录
            apsPlatePlanMapper.insertApsPlatePlan(platePlan);
            count++;
        }
        //插入数量与临时表查询一直则删除临时表数据
        if (count==apsPartPlanTemps.size()) {
            apsPlatePlanTempMapper.deleteApsPlatePlanTempByIds(ids);
        }
        return 1;
    }
   @Override
   public String importData(List<ApsPlatePlanTemp> tempList) throws Exception {
        String batchNum= IdUtils.fastUUID();
        //判断导入数据是否为空
        if (tempList.size() > 0) {
            List<SysDictData> dictDataList = DictUtils.getDictCache("aps_is_suspended");
            for (int i = 0; i < tempList.size(); i++) {
                ApsPlatePlanTemp planTemp = tempList.get(i);
                for (int j = 0; j < dictDataList.size(); j++) {
                    if (planTemp.getIsSuspendedTxt().equals(dictDataList.get(j).getDictLabel())) {
                        planTemp.setIsSuspended(Integer.parseInt(dictDataList.get(j).getDictValue()));
                        break;
                    }
                }
                //插入版本号
                planTemp.setBatchNumber(batchNum);
                //插入临时表
                apsPlatePlanTempMapper.insertApsPlatePlanTemp(planTemp);
            }
           return batchNum ;
        } else {
           return Strings.EMPTY;
        }
    }
}