wenwj
2025-04-14 f095619e00f149b538e8cdafa16513a7a70c6b47
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package com.aps.core.service.impl;
 
import java.util.List;
 
import com.aps.common.core.utils.DateUtils;
import com.aps.common.core.utils.uuid.IdUtils;
import com.aps.core.domain.ApsPartPlanTemp;
import com.aps.core.mapper.ApsPartPlanTempMapper;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.aps.core.mapper.ApsPartPlanMapper;
import com.aps.core.domain.ApsPartPlan;
import com.aps.core.service.IApsPartPlanService;
 
/**
 * 零件计划管理Service业务层处理
 * 
 * @author wwj
 * @date 2025-04-08
 */
@Service
public class ApsPartPlanServiceImpl implements IApsPartPlanService 
{
    @Autowired
    private ApsPartPlanMapper apsPartPlanMapper;
    @Autowired
    private ApsPartPlanTempMapper apsPartPlanTempMapper;
 
    /**
     * 查询零件计划管理
     * 
     * @param id 零件计划管理主键
     * @return 零件计划管理
     */
    @Override
    public ApsPartPlan selectApsPartPlanById(String id)
    {
        return apsPartPlanMapper.selectApsPartPlanById(id);
    }
 
    /**
     * 查询零件计划管理列表
     * 
     * @param apsPartPlan 零件计划管理
     * @return 零件计划管理
     */
    @Override
    public List<ApsPartPlan> selectApsPartPlanList(ApsPartPlan apsPartPlan)
    {
        return apsPartPlanMapper.selectApsPartPlanList(apsPartPlan);
    }
 
    /**
     * 新增零件计划管理
     * 
     * @param apsPartPlan 零件计划管理
     * @return 结果
     */
    @Override
    public int insertApsPartPlan(ApsPartPlan apsPartPlan)
    {
        apsPartPlan.setId(IdUtils.fastUUID());
        apsPartPlan.setCreateTime(DateUtils.getNowDate());
        return apsPartPlanMapper.insertApsPartPlan(apsPartPlan);
    }
 
    /**
     * 修改零件计划管理
     * 
     * @param apsPartPlan 零件计划管理
     * @return 结果
     */
    @Override
    public int updateApsPartPlan(ApsPartPlan apsPartPlan)
    {
        return apsPartPlanMapper.updateApsPartPlan(apsPartPlan);
    }
 
    /**
     * 批量删除零件计划管理
     * 
     * @param ids 需要删除的零件计划管理主键
     * @return 结果
     */
    @Override
    public int deleteApsPartPlanByIds(String[] ids)
    {
        return apsPartPlanMapper.deleteApsPartPlanByIds(ids);
    }
 
    /**
     * 删除零件计划管理信息
     * 
     * @param id 零件计划管理主键
     * @return 结果
     */
    @Override
    public int deleteApsPartPlanById(String id)
    {
        return apsPartPlanMapper.deleteApsPartPlanById(id);
    }
 
    @Override
    public int confirmPart(ApsPartPlanTemp apsPartPlanTemp) {
        //查询临时表数据
        List<ApsPartPlanTemp> apsPartPlanTemps=apsPartPlanTempMapper.selectApsPartPlanTempList(apsPartPlanTemp);
        int count=0;
        List<String> aids=apsPartPlanTemps.stream().map(ApsPartPlanTemp::getId).toList();
        String[] ids=aids.toArray(new String[0]);
//        for (int i = 0; i <apsPartPlanTemps.size() ; i++) {
//            //记录临时表id
//            ids[i]=apsPartPlanTemps.get(i).getId();
//            ApsPartPlan apsPartPlan=new ApsPartPlan();
//            BeanUtils.copyProperties(apsPartPlanTemps.get(i), apsPartPlan);
//            apsPartPlan.setId(IdUtils.fastUUID());
//            //插入正式表,并记录
//            apsPartPlanMapper.insertApsPartPlan(apsPartPlan);
//            count++;
//        }
        count =apsPartPlanMapper.insertBatch(apsPartPlanTemps);
        //插入数量与临时表查询一直则删除临时表数据
        if (count==apsPartPlanTemps.size()) {
            apsPartPlanTempMapper.deleteApsPartPlanTempByIds(ids);
        }
        return 1;
    }
}