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