提交 | 用户 | 时间
|
fd2207
|
1 |
package com.jcdm.main.da.paramCollection.service.impl; |
懒 |
2 |
|
|
3 |
import java.util.List; |
|
4 |
import com.jcdm.common.utils.DateUtils; |
|
5 |
import com.jcdm.main.da.paramCollection.domain.DaParamCollection; |
|
6 |
import com.jcdm.main.da.paramCollection.mapper.DaParamCollectionMapper; |
|
7 |
import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService; |
8ae9df
|
8 |
import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService; |
a9406b
|
9 |
import org.apache.ibatis.session.ExecutorType; |
Y |
10 |
import org.apache.ibatis.session.SqlSession; |
|
11 |
import org.apache.ibatis.session.SqlSessionFactory; |
fd2207
|
12 |
import org.springframework.beans.factory.annotation.Autowired; |
懒 |
13 |
import org.springframework.stereotype.Service; |
a9406b
|
14 |
|
Y |
15 |
import javax.annotation.Resource; |
fd2207
|
16 |
|
懒 |
17 |
/** |
|
18 |
* 设备产品过程参数采集Service业务层处理 |
|
19 |
* |
|
20 |
* @author yyt |
|
21 |
* @date 2023-12-13 |
|
22 |
*/ |
|
23 |
@Service |
|
24 |
public class DaParamCollectionServiceImpl implements IDaParamCollectionService |
|
25 |
{ |
|
26 |
@Autowired |
|
27 |
private DaParamCollectionMapper daParamCollectionMapper; |
8ae9df
|
28 |
|
H |
29 |
@Autowired |
|
30 |
private IDaParamCollectionService daParamCollectionService; |
a9406b
|
31 |
|
Y |
32 |
@Resource |
|
33 |
private SqlSessionFactory sqlSessionFactory; |
fd2207
|
34 |
|
懒 |
35 |
/** |
|
36 |
* 查询设备产品过程参数采集 |
|
37 |
* |
|
38 |
* @param id 设备产品过程参数采集主键 |
|
39 |
* @return 设备产品过程参数采集 |
|
40 |
*/ |
|
41 |
@Override |
|
42 |
public DaParamCollection selectDaParamCollectionById(Long id) |
|
43 |
{ |
|
44 |
return daParamCollectionMapper.selectDaParamCollectionById(id); |
|
45 |
} |
|
46 |
|
|
47 |
/** |
|
48 |
* 查询设备产品过程参数采集列表 |
|
49 |
* |
|
50 |
* @param daParamCollection 设备产品过程参数采集 |
|
51 |
* @return 设备产品过程参数采集 |
|
52 |
*/ |
|
53 |
@Override |
|
54 |
public List<DaParamCollection> selectDaParamCollectionList(DaParamCollection daParamCollection) |
|
55 |
{ |
8ae9df
|
56 |
if(daParamCollection.getDateConditions()!=null){ |
H |
57 |
String[] conditions = daParamCollection.getDateConditions(); |
|
58 |
daParamCollection.setStartTime(conditions[0]); |
|
59 |
daParamCollection.setEndTime(conditions[1]); |
|
60 |
} |
fd2207
|
61 |
return daParamCollectionMapper.selectDaParamCollectionList(daParamCollection); |
懒 |
62 |
} |
|
63 |
|
|
64 |
/** |
|
65 |
* 新增设备产品过程参数采集 |
|
66 |
* |
|
67 |
* @param daParamCollection 设备产品过程参数采集 |
|
68 |
* @return 结果 |
|
69 |
*/ |
|
70 |
@Override |
|
71 |
public int insertDaParamCollection(DaParamCollection daParamCollection) |
|
72 |
{ |
|
73 |
daParamCollection.setCreateTime(DateUtils.getNowDate()); |
|
74 |
return daParamCollectionMapper.insertDaParamCollection(daParamCollection); |
|
75 |
} |
|
76 |
|
|
77 |
/** |
|
78 |
* 修改设备产品过程参数采集 |
|
79 |
* |
|
80 |
* @param daParamCollection 设备产品过程参数采集 |
|
81 |
* @return 结果 |
|
82 |
*/ |
|
83 |
@Override |
|
84 |
public int updateDaParamCollection(DaParamCollection daParamCollection) |
|
85 |
{ |
|
86 |
daParamCollection.setUpdateTime(DateUtils.getNowDate()); |
|
87 |
return daParamCollectionMapper.updateDaParamCollection(daParamCollection); |
|
88 |
} |
|
89 |
|
|
90 |
/** |
|
91 |
* 批量删除设备产品过程参数采集 |
|
92 |
* |
|
93 |
* @param ids 需要删除的设备产品过程参数采集主键 |
|
94 |
* @return 结果 |
|
95 |
*/ |
|
96 |
@Override |
|
97 |
public int deleteDaParamCollectionByIds(Long[] ids) |
|
98 |
{ |
|
99 |
return daParamCollectionMapper.deleteDaParamCollectionByIds(ids); |
|
100 |
} |
|
101 |
|
|
102 |
/** |
|
103 |
* 删除设备产品过程参数采集信息 |
|
104 |
* |
|
105 |
* @param id 设备产品过程参数采集主键 |
|
106 |
* @return 结果 |
|
107 |
*/ |
|
108 |
@Override |
|
109 |
public int deleteDaParamCollectionById(Long id) |
|
110 |
{ |
|
111 |
return daParamCollectionMapper.deleteDaParamCollectionById(id); |
|
112 |
} |
a9406b
|
113 |
|
Y |
114 |
@Override |
|
115 |
public void saveBeachDaParamCollection(List<DaParamCollection> list) { |
|
116 |
// ExecutorType.SIMPLE: 这个执行器类型不做特殊的事情。它为每个语句的执行创建一个新的预处理语句。 |
|
117 |
// ExecutorType.REUSE: 这个执行器类型会复用预处理语句。 |
|
118 |
// ExecutorType.BATCH: 这个执行器会批量执行所有更新语句,如果 SELECT 在它们中间执行还会标定它们是 必须的,来保证一个简单并易于理解的行为。 |
|
119 |
|
|
120 |
// 关闭session的自动提交 |
|
121 |
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false); |
|
122 |
try { |
|
123 |
DaParamCollectionMapper userMapper = sqlSession.getMapper(DaParamCollectionMapper.class); |
|
124 |
list.stream().forEach(DaParamCollection -> userMapper.insertDaParamCollection(DaParamCollection)); |
|
125 |
// 提交数据 |
|
126 |
sqlSession.commit(); |
|
127 |
sqlSession.rollback(); |
|
128 |
} catch (Exception e) { |
|
129 |
sqlSession.rollback(); |
|
130 |
} finally { |
|
131 |
sqlSession.close(); |
|
132 |
} |
|
133 |
} |
fd2207
|
134 |
} |