|
|
@@ -6,25 +6,27 @@ import com.chinaitop.depot.intelligent.basicdata.model.TDcsqtinfo;
|
|
6
|
6
|
import com.chinaitop.depot.intelligent.basicdata.model.TDcsqtinfoExample;
|
|
7
|
7
|
import com.chinaitop.depot.intelligent.basicdata.model.TQtdevinfo;
|
|
8
|
8
|
import com.chinaitop.depot.intelligent.basicdata.model.TQtdevinfoExample;
|
|
|
9
|
+import com.chinaitop.depot.intelligent.common.ConstantClass;
|
|
9
|
10
|
import com.chinaitop.depot.intelligent.factoryObject.factoryInterface.StringFactory;
|
|
10
|
11
|
import com.chinaitop.depot.intelligent.grainsituation.mapper.TDcsdataMapper;
|
|
11
|
12
|
import com.chinaitop.depot.intelligent.grainsituation.mapper.TGasDataMapper;
|
|
12
|
13
|
import com.chinaitop.depot.intelligent.grainsituation.mapper.TQtdevinfoValueMapper;
|
|
13
|
14
|
import com.chinaitop.depot.intelligent.grainsituation.model.*;
|
|
|
15
|
+import com.chinaitop.depot.intelligent.grainsituation.service.GasConfigService;
|
|
14
|
16
|
import com.chinaitop.depot.intelligent.grainsituation.service.GasDetectionService;
|
|
15
|
17
|
import com.chinaitop.depot.intelligent.utils.DateUtils;
|
|
16
|
18
|
import com.chinaitop.depot.intelligent.utils.ParameterUtil;
|
|
|
19
|
+import com.chinaitop.depot.intelligent.utils.UuidUtils;
|
|
|
20
|
+import com.google.common.collect.Lists;
|
|
17
|
21
|
import com.google.common.collect.Maps;
|
|
18
|
22
|
import org.apache.commons.lang3.StringUtils;
|
|
19
|
23
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
20
|
24
|
import org.springframework.stereotype.Service;
|
|
21
|
25
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
26
|
+import reactor.util.annotation.Nullable;
|
|
22
|
27
|
|
|
23
|
28
|
import javax.annotation.Resource;
|
|
24
|
|
-import java.util.Date;
|
|
25
|
|
-import java.util.HashMap;
|
|
26
|
|
-import java.util.List;
|
|
27
|
|
-import java.util.Map;
|
|
|
29
|
+import java.util.*;
|
|
28
|
30
|
|
|
29
|
31
|
@Service
|
|
30
|
32
|
public class GasDetectionServiceImpl implements GasDetectionService {
|
|
|
@@ -117,7 +119,7 @@ public class GasDetectionServiceImpl implements GasDetectionService {
|
|
117
|
119
|
if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)) {
|
|
118
|
120
|
Date startDate = DateUtils.stringToData(stringFactory.joinString(1, startTime, DateUtils.startTime));
|
|
119
|
121
|
Date endDate = DateUtils.stringToData(stringFactory.joinString(1, endTime, DateUtils.endTime));
|
|
120
|
|
- criteria.andResultTimeBetween(startDate,endDate);
|
|
|
122
|
+ criteria.andResultTimeBetween(startDate, endDate);
|
|
121
|
123
|
}
|
|
122
|
124
|
return gasDataMapper.selectByExample(example);
|
|
123
|
125
|
}
|
|
|
@@ -127,5 +129,69 @@ public class GasDetectionServiceImpl implements GasDetectionService {
|
|
127
|
129
|
return gasDataMapper.getGasCheckGroupList(storeCode);
|
|
128
|
130
|
}
|
|
129
|
131
|
|
|
|
132
|
+ @Resource
|
|
|
133
|
+ private GasConfigService gasConfigService;
|
|
|
134
|
+
|
|
|
135
|
+ @Override
|
|
|
136
|
+ public void saveGasData(List<List<Float>> objects1, String ip) {
|
|
|
137
|
+ if (objects1.size() > 0 && StringUtils.isNotBlank(ip)) {
|
|
|
138
|
+ // 根据ip获取仓房信息
|
|
|
139
|
+ TGasConfig gasConfig = gasConfigService.getList(null, ip).getList().get(ConstantClass.TYPE_ZRO);
|
|
|
140
|
+ String orgId = gasConfig.getOrgId();
|
|
|
141
|
+ String storeCode = gasConfig.getStoreCode();
|
|
|
142
|
+ // 数据list
|
|
|
143
|
+ ArrayList<TGasData> gases = Lists.newArrayList();
|
|
|
144
|
+ objects1.forEach(data -> {
|
|
|
145
|
+ if (data.size() > 12) {
|
|
|
146
|
+ TGasData gasData = new TGasData();
|
|
|
147
|
+ gasData.setNowO2(data.get(0)); // 氧气实时
|
|
|
148
|
+ gasData.setNowPh3(data.get(1)); // 磷化氢实时
|
|
|
149
|
+ gasData.setSouthO2(data.get(2)); // 南检测结果 氧气
|
|
|
150
|
+ gasData.setSouthPh3(data.get(3)); // 南检测结果 磷化氢
|
|
|
151
|
+ gasData.setEastO2(data.get(4)); // 东检测结果 氧气
|
|
|
152
|
+ gasData.setEastPh3(data.get(5)); // 东检测结果 磷化氢
|
|
|
153
|
+ gasData.setNorthO2(data.get(6)); // 北检测结果 氧气
|
|
|
154
|
+ gasData.setNorthPh3(data.get(7)); // 北检测结果 磷化氢
|
|
|
155
|
+ gasData.setWestO2(data.get(8)); // 西检测结果 氧气
|
|
|
156
|
+ gasData.setWestPh3(data.get(9)); // 西检测结果 磷化氢
|
|
|
157
|
+ gasData.setInO2(data.get(10)); // 中检测结果 氧气
|
|
|
158
|
+ gasData.setInPh3(data.get(11)); // 中检测结果 磷化氢
|
|
|
159
|
+ gases.add(gasData);
|
|
|
160
|
+ }
|
|
|
161
|
+ });
|
|
|
162
|
+ // 保存对象
|
|
|
163
|
+ TGasData saveOnlyGasData = new TGasData();
|
|
|
164
|
+ saveOnlyGasData.setId(UuidUtils.getCode()); // id
|
|
|
165
|
+ saveOnlyGasData.setOrgId(orgId); // 组织机构编码
|
|
|
166
|
+ saveOnlyGasData.setStoreCode(storeCode); // 仓房编码
|
|
|
167
|
+ // 计算平均值
|
|
|
168
|
+ float avgNowO2 = (float) gases.stream().mapToDouble(TGasData::getNowO2).average().getAsDouble();
|
|
|
169
|
+ float avgNowPh3 = (float) gases.stream().mapToDouble(TGasData::getNowPh3).average().getAsDouble();
|
|
|
170
|
+ float avgSouthO2 = (float) gases.stream().mapToDouble(TGasData::getSouthO2).average().getAsDouble();
|
|
|
171
|
+ float avgSouthPh3 = (float) gases.stream().mapToDouble(TGasData::getSouthPh3).average().getAsDouble();
|
|
|
172
|
+ float avgEastO2 = (float) gases.stream().mapToDouble(TGasData::getEastO2).average().getAsDouble();
|
|
|
173
|
+ float avgEastPh3 = (float) gases.stream().mapToDouble(TGasData::getEastPh3).average().getAsDouble();
|
|
|
174
|
+ float avgNorthO2 = (float) gases.stream().mapToDouble(TGasData::getNorthO2).average().getAsDouble();
|
|
|
175
|
+ float avgNorthPh3 = (float) gases.stream().mapToDouble(TGasData::getNorthPh3).average().getAsDouble();
|
|
|
176
|
+ float avgWestO2 = (float) gases.stream().mapToDouble(TGasData::getWestO2).average().getAsDouble();
|
|
|
177
|
+ float avgWestPh3 = (float) gases.stream().mapToDouble(TGasData::getWestPh3).average().getAsDouble();
|
|
|
178
|
+ float avgInO2 = (float) gases.stream().mapToDouble(TGasData::getInO2).average().getAsDouble();
|
|
|
179
|
+ float avgInPh3 = (float) gases.stream().mapToDouble(TGasData::getInPh3).average().getAsDouble();
|
|
|
180
|
+ saveOnlyGasData.setNowO2(avgNowO2);
|
|
|
181
|
+ saveOnlyGasData.setNowPh3(avgNowPh3);
|
|
|
182
|
+ saveOnlyGasData.setSouthO2(avgSouthO2);
|
|
|
183
|
+ saveOnlyGasData.setSouthPh3(avgSouthPh3);
|
|
|
184
|
+ saveOnlyGasData.setEastO2(avgEastO2);
|
|
|
185
|
+ saveOnlyGasData.setEastPh3(avgEastPh3);
|
|
|
186
|
+ saveOnlyGasData.setNorthO2(avgNorthO2);
|
|
|
187
|
+ saveOnlyGasData.setNorthPh3(avgNorthPh3);
|
|
|
188
|
+ saveOnlyGasData.setWestO2(avgWestO2);
|
|
|
189
|
+ saveOnlyGasData.setWestPh3(avgWestPh3);
|
|
|
190
|
+ saveOnlyGasData.setInO2(avgInO2);
|
|
|
191
|
+ saveOnlyGasData.setInPh3(avgInPh3);
|
|
|
192
|
+ // 保存
|
|
|
193
|
+ gasDataMapper.insert(saveOnlyGasData);
|
|
|
194
|
+ }
|
|
|
195
|
+ }
|
|
130
|
196
|
|
|
131
|
197
|
}
|