-
admin
2024-05-15 a320dcc8a480436f2f6b3ef81fe6b607f080a64a
提交 | 用户 | 时间
e57a89 1 package com.jcdm.main.da.passingStationCollection.service.impl;
2
0ce25f 3 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
e57a89 4 import com.jcdm.common.utils.DateUtils;
5 //import com.jcdm.main.bs.orderScheduling.domain.BsOrderScheduling;
6 //import com.jcdm.main.bs.orderScheduling.mapper.BsOrderSchedulingMapper;
7 //import com.jcdm.main.bs.orderScheduling.service.IBsOrderSchedulingService;
a320dc 8 import com.jcdm.main.da.paramCollection.mapper.DaParamCollectionMapper;
e57a89 9 import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection;
10 import com.jcdm.main.da.passingStationCollection.mapper.DaPassingStationCollectionMapper;
11 import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService;
12 import com.jcdm.main.rm.repairRecord.domain.RmRepairRecord;
13 import com.jcdm.main.rm.repairRecord.mapper.RmRepairRecordMapper;
a320dc 14 import org.apache.ibatis.session.ExecutorType;
A 15 import org.apache.ibatis.session.SqlSession;
16 import org.apache.ibatis.session.SqlSessionFactory;
e57a89 17 import org.springframework.beans.factory.annotation.Autowired;
18 import org.springframework.stereotype.Service;
19
a320dc 20 import javax.annotation.Resource;
e57a89 21 import java.time.LocalDate;
22 import java.time.LocalDateTime;
23 import java.time.format.DateTimeFormatter;
24 import java.util.List;
25
26 /**
27  * 产品过站采集Service业务层处理
28  * 
29  * @author yyt
30  * @date 2023-12-12
31  */
32 @Service
0ce25f 33 public class DaPassingStationCollectionServiceImpl extends ServiceImpl<DaPassingStationCollectionMapper,DaPassingStationCollection> implements IDaPassingStationCollectionService
e57a89 34 {
35     @Autowired
36     private DaPassingStationCollectionMapper daPassingStationCollectionMapper;
37
38     @Autowired
06713a 39     private IDaPassingStationCollectionService daPassingStationCollectionService;
A 40
41     @Autowired
e57a89 42     private RmRepairRecordMapper rmRepairRecordMapper;
a320dc 43
A 44     @Resource
45     private SqlSessionFactory sqlSessionFactory;
e57a89 46
47 //    @Autowired
48 //    private BsOrderSchedulingMapper bsOrderSchedulingMapper;
49 //
50 //    @Autowired
51 //    private IBsOrderSchedulingService bsOrderSchedulingService;
52
53     /**
54      * 查询产品过站采集
55      * 
56      * @param id 产品过站采集主键
57      * @return 产品过站采集
58      */
59     @Override
60     public DaPassingStationCollection selectDaPassingStationCollectionById(Long id)
61     {
62         return daPassingStationCollectionMapper.selectDaPassingStationCollectionById(id);
63     }
64
65     /**
66      * 查询产品过站采集列表
67      * 
68      * @param daPassingStationCollection 产品过站采集
69      * @return 产品过站采集
70      */
71     @Override
72     public List<DaPassingStationCollection> selectDaPassingStationCollectionList(DaPassingStationCollection daPassingStationCollection)
73     {
74         return daPassingStationCollectionMapper.selectDaPassingStationCollectionList(daPassingStationCollection);
75     }
76
77 //    /**
78 //     * 获取首页单日累计量产数据
79 //     * @param fieldName bs
80 //     * @return list
81 //     */
82 //    @Override
83 //    public Integer getProduceNumToday(String fieldName) {
84 //
85 //        BsOrderScheduling bsOrderScheduling = new BsOrderScheduling();
86 //        bsOrderScheduling.setQueryField(fieldName);
87 //        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
88 //        LocalDateTime startTime = LocalDate.now().atStartOfDay();
89 //        LocalDateTime endTime = LocalDate.now().plusDays(1).atStartOfDay();
90 //        String s1 = startTime.format(formatter);
91 //        String s2 = endTime.format(formatter);
92 //        bsOrderScheduling.setStartTime(s1);
93 //        bsOrderScheduling.setEndTime(s2);
94 //        return bsOrderSchedulingMapper.getProduceNumToday(bsOrderScheduling);
95 //    }
96
97     /**
98      * 新增产品过站采集
99      * 
100      * @param daPassingStationCollection 产品过站采集
101      * @return 结果
102      */
103     @Override
104     public int insertDaPassingStationCollection(DaPassingStationCollection daPassingStationCollection)
105     {
106         daPassingStationCollection.setCreateTime(DateUtils.getNowDate());
107         return daPassingStationCollectionMapper.insertDaPassingStationCollection(daPassingStationCollection);
108     }
109
110     /**
111      * 修改产品过站采集
112      * 
113      * @param daPassingStationCollection 产品过站采集
114      * @return 结果
115      */
116     @Override
117     public int updateDaPassingStationCollection(DaPassingStationCollection daPassingStationCollection)
118     {
119         daPassingStationCollection.setUpdateTime(DateUtils.getNowDate());
120         return daPassingStationCollectionMapper.updateDaPassingStationCollection(daPassingStationCollection);
121     }
122
123     /**
124      * 批量删除产品过站采集
125      * 
126      * @param ids 需要删除的产品过站采集主键
127      * @return 结果
128      */
129     @Override
130     public int deleteDaPassingStationCollectionByIds(Long[] ids)
131     {
132         return daPassingStationCollectionMapper.deleteDaPassingStationCollectionByIds(ids);
133     }
134
135     /**
136      * 删除产品过站采集信息
137      * 
138      * @param id 产品过站采集主键
139      * @return 结果
140      */
141     @Override
142     public int deleteDaPassingStationCollectionById(Long id)
143     {
144         return daPassingStationCollectionMapper.deleteDaPassingStationCollectionById(id);
145     }
146
147     @Override
148     public void insertRepairRecordByIds(DaPassingStationCollection daPassingStationCollection) {
149         Long[] conditions = daPassingStationCollection.getIds();
150         for (int i = 0; i < conditions.length; i++) {
151             DaPassingStationCollection result = daPassingStationCollectionMapper.selectDaPassingStationCollectionById(conditions[i]);
152             RmRepairRecord rmRepairRecord = new RmRepairRecord();
153             rmRepairRecord.setBoxCode(result.getSfcCode());
154             rmRepairRecord.setProcessesCode(result.getLocationCode());
155             rmRepairRecord.setOriginalResult(result.getOutRsSign());
156             rmRepairRecordMapper.insertRmRepairRecord(rmRepairRecord);
157         }
158     }
06713a 159
A 160     @Override
161     public int jrmAddPassingStationCollection(DaPassingStationCollection daPassingStationCollection) {
162         for (String model : daPassingStationCollection.getSfcCode().split(",")) {
163             daPassingStationCollection.setSfcCode(model);
c860ca 164             daPassingStationCollectionService.save(daPassingStationCollection);
06713a 165         }
1c84ae 166         return 1;
06713a 167     }
a320dc 168
A 169     @Override
170     public void saveBeachDaPassingStationCollection(List<DaPassingStationCollection> list) {
171         // ExecutorType.SIMPLE: 这个执行器类型不做特殊的事情。它为每个语句的执行创建一个新的预处理语句。
172         // ExecutorType.REUSE: 这个执行器类型会复用预处理语句。
173         // ExecutorType.BATCH: 这个执行器会批量执行所有更新语句,如果 SELECT 在它们中间执行还会标定它们是 必须的,来保证一个简单并易于理解的行为。
174
175         // 关闭session的自动提交
176         SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
177         try {
178             DaPassingStationCollectionMapper userMapper = sqlSession.getMapper(DaPassingStationCollectionMapper.class);
179             list.stream().forEach(item -> userMapper.insertDaPassingStationCollection(item));
180             // 提交数据
181             sqlSession.commit();
182             sqlSession.rollback();
183         } catch (Exception e) {
184             sqlSession.rollback();
185         } finally {
186             sqlSession.close();
187         }
188     }
e57a89 189 }