소스 검색

hj212 2005

zjs 1 주 전
부모
커밋
94983516d7

+ 20 - 1
pom.xml

@@ -184,7 +184,26 @@
184 184
             <version>RELEASE</version>
185 185
             <scope>compile</scope>
186 186
         </dependency>
187
-
187
+		<dependency>
188
+			<groupId>org.apache.poi</groupId>
189
+			<artifactId>poi</artifactId>
190
+			<version>5.2.2</version>
191
+		</dependency>
192
+		<dependency>
193
+			<groupId>org.apache.poi</groupId>
194
+			<artifactId>poi-ooxml</artifactId>
195
+			<version>5.2.2</version>
196
+		</dependency>
197
+		<dependency>
198
+			<groupId>org.apache.poi</groupId>
199
+			<artifactId>poi-ooxml-schemas</artifactId>
200
+			<version>4.1.2</version>
201
+		</dependency>
202
+		<dependency>
203
+			<groupId>org.apache.xmlbeans</groupId>
204
+			<artifactId>xmlbeans</artifactId>
205
+			<version>5.1.1</version>
206
+		</dependency>
188 207
     </dependencies>
189 208
 
190 209
 

+ 2 - 1
src/main/java/com/cn/esermis/EsermisApplication.java

@@ -1,6 +1,7 @@
1 1
 package com.cn.esermis;
2 2
 
3 3
 import com.cn.esermis.server.BootNettyServer;
4
+import com.cn.esermis.server.Consumer;
4 5
 import org.mybatis.spring.annotation.MapperScan;
5 6
 import org.springframework.boot.CommandLineRunner;
6 7
 import org.springframework.boot.SpringApplication;
@@ -17,7 +18,7 @@ public class EsermisApplication  implements CommandLineRunner {
17 18
     public static void main(String[] args) throws InterruptedException {
18 19
         ConfigurableApplicationContext context =  SpringApplication.run(EsermisApplication.class, args);
19 20
         // 调用异步任务 启动消费服务
20
-//        context.getBean(Consumer.class).receive();
21
+        context.getBean(Consumer.class).receive();
21 22
     }
22 23
     //异步方法
23 24
     @Async

+ 174 - 4
src/main/java/com/cn/esermis/controller/DataAcquisitionInstrumentController.java

@@ -9,13 +9,11 @@ import com.cn.esermis.dpld.entity.AnalyticalInstruments;
9 9
 import com.cn.esermis.dpld.entity.DataAcquisitionInstrument;
10 10
 import com.cn.esermis.dpld.entity.DetectMonitoringFactor;
11 11
 import com.cn.esermis.dpld.mapper.DataAcquisitionInstrumentMapper;
12
-import com.cn.esermis.dpld.model.AjaxResult;
13
-import com.cn.esermis.dpld.model.AnalyticalInstrumentsVo;
14
-import com.cn.esermis.dpld.model.DataAcquisitionInstrumentVo;
15
-import com.cn.esermis.dpld.model.OutletAndFactorVo;
12
+import com.cn.esermis.dpld.model.*;
16 13
 import com.cn.esermis.dpld.service.IAnalyticalInstrumentsService;
17 14
 import com.cn.esermis.dpld.service.IDataAcquisitionInstrumentService;
18 15
 import com.cn.esermis.dpld.service.IDetectMonitoringFactorService;
16
+import com.cn.esermis.excelReader.ExcelReader;
19 17
 import com.cn.esermis.model.BaseUser;
20 18
 import com.cn.esermis.utils.TokenUtils;
21 19
 import org.springframework.beans.BeanUtils;
@@ -29,6 +27,7 @@ import javax.annotation.Resource;
29 27
 import javax.servlet.http.HttpServletRequest;
30 28
 
31 29
 import java.util.*;
30
+import java.util.stream.Collectors;
32 31
 
33 32
 import static com.cn.esermis.dpld.model.AjaxResult.error;
34 33
 import static com.cn.esermis.dpld.model.AjaxResult.success;
@@ -269,4 +268,175 @@ public class DataAcquisitionInstrumentController {
269 268
         return success(dataAcquisitionInstruments);
270 269
     }
271 270
 
271
+
272
+
273
+    /**
274
+     * 获取数采仪信息表
275
+     */
276
+    @GetMapping("/daoru")
277
+    public AjaxResult daoru(HttpServletRequest request) {
278
+
279
+        ExcelReader excelReader = new ExcelReader();
280
+        List<DataAllVo> data = excelReader.getData();
281
+        System.out.println(data);
282
+        List<Department> departmentList =  dataAcquisitionInstrumentService.getDepartmentDit();
283
+        // 添加公司编号
284
+        for (DataAllVo datum : data) {
285
+            Optional<Department> first = departmentList.stream().filter(d -> d.getDepartmentname().equals(datum.getCompanyCode())).findFirst();
286
+            if (first.isPresent()){
287
+                datum.setCompanyCode(first.get().getCompanyid());
288
+                datum.setDepartmentCode(first.get().getDepartmentid());
289
+            }
290
+        }
291
+        Map<String, List<DataAllVo>> collect = data.stream().collect(Collectors.groupingBy(d -> d.getOutletName() + "_" + d.getLicenseNumber()));
292
+        for (Map.Entry<String, List<DataAllVo>> entry : collect.entrySet()) {
293
+            List<DataAllVo> value = entry.getValue();
294
+            DataAcquisitionInstrument dataAcquisitionInstrument = new DataAcquisitionInstrument();
295
+            value.forEach(x->{
296
+                if (x.getOutletName()!=null && !x.getOutletName().isEmpty()){
297
+                    dataAcquisitionInstrument.setOutletName(x.getOutletName());
298
+                }
299
+                if (x.getOutletCode()!=null && !x.getOutletCode().isEmpty()){
300
+                    dataAcquisitionInstrument.setOutletCode(x.getOutletCode());
301
+                }
302
+                if (x.getType()!=null){
303
+                    dataAcquisitionInstrument.setType(x.getType());
304
+                }
305
+                if (x.getUseData()!=null){
306
+                    dataAcquisitionInstrument.setUseData(x.getUseData());
307
+                }
308
+                if (x.getCompleteFilings()!=null){
309
+                    dataAcquisitionInstrument.setCompleteFilings(x.getCompleteFilings());
310
+                }
311
+                if (x.getCompleteFilingsTime()!=null){
312
+                    dataAcquisitionInstrument.setCompleteFilingsTime(x.getCompleteFilingsTime());
313
+                }
314
+                if (x.getCollectionName()!=null && !x.getCollectionName().isEmpty()){
315
+                    dataAcquisitionInstrument.setCollectionName(x.getCollectionName());
316
+                }
317
+                if (x.getCollectionBrand()!=null && !x.getCollectionBrand().isEmpty()){
318
+                    dataAcquisitionInstrument.setCollectionBrand(x.getCollectionBrand());
319
+                }
320
+                if (x.getCollectionModel()!=null && !x.getCollectionModel().isEmpty()){
321
+                    dataAcquisitionInstrument.setCollectionModel(x.getCollectionModel());
322
+                }
323
+                if (x.getMnCode()!=null && !x.getMnCode().isEmpty()){
324
+                    dataAcquisitionInstrument.setMnCode(x.getMnCode());
325
+                }
326
+                if (x.getCollectionIp()!=null && !x.getCollectionIp().isEmpty()){
327
+                    dataAcquisitionInstrument.setCollectionIp(x.getCollectionIp());
328
+                }
329
+                if (x.getCompanyCode()!=null && !x.getCompanyCode().isEmpty()){
330
+                    dataAcquisitionInstrument.setCompanyCode(x.getCompanyCode());
331
+                }
332
+                if (x.getDepartmentCode()!=null && !x.getDepartmentCode().isEmpty()){
333
+                    dataAcquisitionInstrument.setDepartmentCode(x.getDepartmentCode());
334
+                }
335
+                if (x.getHaveExhaust()!=null){
336
+                    dataAcquisitionInstrument.setHaveExhaust(x.getHaveExhaust());
337
+                }
338
+                if (x.getExhaustTemperature()!=null && !x.getExhaustTemperature().isEmpty()){
339
+                    dataAcquisitionInstrument.setExhaustTemperature(x.getExhaustTemperature());
340
+                }
341
+                if (x.getExhaustHeight()!=null && !x.getExhaustHeight().isEmpty()){
342
+                    dataAcquisitionInstrument.setExhaustHeight(x.getExhaustHeight());
343
+                }
344
+                if (x.getExhaustDiameter()!=null && !x.getExhaustDiameter().isEmpty()){
345
+                    dataAcquisitionInstrument.setExhaustDiameter(x.getExhaustDiameter());
346
+                }
347
+                if (x.getIndustryCategory()!=null && !x.getIndustryCategory().isEmpty()){
348
+                    dataAcquisitionInstrument.setIndustryCategory(x.getIndustryCategory());
349
+                }
350
+                if (x.getLicenseNumber()!=null && !x.getLicenseNumber().isEmpty()){
351
+                    dataAcquisitionInstrument.setLicenseNumber(x.getLicenseNumber());
352
+                }
353
+                if (x.getLicenseData()!=null && !x.getLicenseData().isEmpty()){
354
+                    dataAcquisitionInstrument.setLicenseData(x.getLicenseData());
355
+                }
356
+            });
357
+            dataAcquisitionInstrumentService.save(dataAcquisitionInstrument);
358
+            // 解析分析仪数据
359
+            Map<String, List<DataAllVo>> brandCollect = value.stream().collect(Collectors.groupingBy(DataAllVo::getBrand));
360
+            for (Map.Entry<String, List<DataAllVo>> listEntry : brandCollect.entrySet()) {
361
+                AnalyticalInstruments analyticalInstruments = new AnalyticalInstruments();
362
+                List<DataAllVo> dataAllVos = listEntry.getValue();
363
+                analyticalInstruments.setDataAcquisitionInstrumentId(dataAcquisitionInstrument.getId());
364
+                dataAllVos.forEach(x->{
365
+                    if (x.getBrand()!=null && !x.getBrand().isEmpty()){
366
+                        analyticalInstruments.setBrand(x.getBrand());
367
+                    }
368
+                    if (x.getModel()!=null && !x.getModel().isEmpty()){
369
+                        analyticalInstruments.setModel(x.getModel());
370
+                    }
371
+                    if (x.getName()!=null && !x.getName().isEmpty()){
372
+                        analyticalInstruments.setName(x.getName());
373
+                    }
374
+                    if (x.getFactorInfor()!=null && !x.getFactorInfor().isEmpty()){
375
+                        analyticalInstruments.setFactorInfor(x.getFactorInfor());
376
+                    }
377
+//                    if (x.getRange()!=null && !x.getRange().isEmpty()){
378
+//                        analyticalInstruments.setRange(x.getRange());
379
+//                    }
380
+                    if (x.getRange()!=null && !x.getRange().isEmpty())   {
381
+                        analyticalInstruments.setRange(x.getRange());
382
+                    }
383
+                    if(x.getReferenceOxygenContent()!=null && !x.getReferenceOxygenContent().isEmpty()){
384
+                        analyticalInstruments.setReferenceOxygenContent(x.getReferenceOxygenContent());
385
+                    }
386
+                    if(x.getVelocityFieldCoefficient()!=null && !x.getVelocityFieldCoefficient().isEmpty()){
387
+                        analyticalInstruments.setVelocityFieldCoefficient(x.getVelocityFieldCoefficient());
388
+                    }
389
+                    if(x.getPitotTubeCoefficient()!=null && !x.getPitotTubeCoefficient().isEmpty()){
390
+                        analyticalInstruments.setPitotTubeCoefficient(x.getPitotTubeCoefficient());
391
+                    }
392
+                    if(x.getKvalue()!=null && !x.getKvalue().isEmpty()){
393
+                        analyticalInstruments.setKvalue(x.getKvalue());
394
+                    }
395
+                    if(x.getFlueArea()!=null && !x.getFlueArea().isEmpty()){
396
+                        analyticalInstruments.setFlueArea(x.getFlueArea());
397
+                    }
398
+                    if(x.getDilutionRatio()!=null && !x.getDilutionRatio().isEmpty()){
399
+                        analyticalInstruments.setDilutionRatio(x.getDilutionRatio());
400
+                    }
401
+                    if(x.getFxytype()!=null){
402
+                        analyticalInstruments.setType(x.getFxytype());
403
+                    }
404
+                });
405
+                analyticalInstrumentsService.save(analyticalInstruments);
406
+                dataAllVos.forEach(x->{
407
+                    DetectMonitoringFactor detectMonitoringFactor = new DetectMonitoringFactor();
408
+                    detectMonitoringFactor.setAnalyticalInstrumentId(analyticalInstruments.getId());
409
+                    detectMonitoringFactor.setDataAcquisitionInstrumentId(dataAcquisitionInstrument.getId());
410
+                    if (x.getFactor()!=null && !x.getFactor().isEmpty()){
411
+                        detectMonitoringFactor.setFactor(x.getFactor());
412
+                    }
413
+                    if (x.getHoursAvg()!=null && !x.getHoursAvg().isEmpty()){
414
+                        detectMonitoringFactor.setHoursAvg(x.getHoursAvg());
415
+                    }
416
+                    if (x.getHoursUnit()!=null && !x.getHoursUnit().isEmpty()){
417
+                        detectMonitoringFactor.setHoursUnit(x.getHoursUnit());
418
+                    }
419
+                    if (x.getMonthlyEmissions()!=null && !x.getMonthlyEmissions().isEmpty()){
420
+                        detectMonitoringFactor.setMonthlyEmissions(x.getMonthlyEmissions());
421
+                    }
422
+                    if (x.getMonthlyEmissionsUnit()!=null && !x.getMonthlyEmissionsUnit().isEmpty()){
423
+                        detectMonitoringFactor.setMonthlyEmissionsUnit(x.getMonthlyEmissionsUnit());
424
+                    }
425
+                    if (x.getYearEmissions()!=null && !x.getYearEmissions().isEmpty()){
426
+                        detectMonitoringFactor.setYearEmissions(x.getYearEmissions());
427
+                    }
428
+                    if (x.getYearEmissionsUnit()!=null && !x.getYearEmissionsUnit().isEmpty()){
429
+                        detectMonitoringFactor.setYearEmissionsUnit(x.getYearEmissionsUnit());
430
+                    }
431
+                    detectMonitoringFactor.setRange(x.getRangeStr());
432
+                    detectMonitoringFactor.setRangeUnit(x.getRangeUnit());
433
+                    detectMonitoringFactor.setFactorName(x.getFactorName());
434
+                    detectMonitoringFactorService.save(detectMonitoringFactor);
435
+                });
436
+            }
437
+        }
438
+        return success();
439
+    }
440
+
441
+
272 442
 }

+ 2 - 2
src/main/java/com/cn/esermis/dpld/business/MonitorBusiness.java

@@ -345,8 +345,8 @@ public class MonitorBusiness {
345 345
                 }
346 346
             }
347 347
         } catch (Exception e) {
348
-//            throw new RuntimeException(e);
349
-            log.error("插入数据库异常:"+e);
348
+            throw new RuntimeException(e);
349
+//            log.error("插入数据库异常:"+e);
350 350
         }
351 351
     }
352 352
 

+ 15 - 0
src/main/java/com/cn/esermis/dpld/entity/DataAcquisitionInstrument.java

@@ -115,4 +115,19 @@ public class DataAcquisitionInstrument {
115 115
      */
116 116
     @TableField(value = "exhaust_diameter")
117 117
     private String exhaustDiameter;
118
+    /**
119
+     * 行业类别
120
+     */
121
+    @TableField(value = "industry_category")
122
+    private String industryCategory;
123
+    /**
124
+     * 排污许可证编号
125
+     */
126
+    @TableField(value = "license_number")
127
+    private String licenseNumber;
128
+    /**
129
+     *排污许可证有效期
130
+     */
131
+    @TableField(value = "license_data")
132
+    private String licenseData;
118 133
 }

+ 2 - 2
src/main/java/com/cn/esermis/dpld/entity/DetectMonitoringFactor.java

@@ -41,7 +41,7 @@ public class DetectMonitoringFactor {
41 41
      * 小时均值单位
42 42
      */
43 43
     @TableField(value = "hours_unit")
44
-    private Date hoursUnit;
44
+    private String hoursUnit;
45 45
     /**
46 46
      * 月排放量
47 47
      */
@@ -52,7 +52,7 @@ public class DetectMonitoringFactor {
52 52
      * 月排放量单位
53 53
      */
54 54
     @TableField(value = "monthly_emissions_unit")
55
-    private Date monthlyEmissionsUnit;
55
+    private String monthlyEmissionsUnit;
56 56
 
57 57
     /**
58 58
      * 年排放量

+ 3 - 0
src/main/java/com/cn/esermis/dpld/mapper/DataAcquisitionInstrumentMapper.java

@@ -3,6 +3,7 @@ package com.cn.esermis.dpld.mapper;
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 4
 import com.cn.esermis.dpld.entity.DataAcquisitionInstrument;
5 5
 import com.cn.esermis.dpld.model.DataAcquisitionInstrumentVo;
6
+import com.cn.esermis.dpld.model.Department;
6 7
 import com.cn.esermis.dpld.model.OutletAndFactorVo;
7 8
 import org.apache.ibatis.annotations.MapKey;
8 9
 import org.apache.ibatis.annotations.Mapper;
@@ -35,4 +36,6 @@ public interface DataAcquisitionInstrumentMapper extends BaseMapper<DataAcquisit
35 36
     List<String> getComponyList(String companyName, String companyId);
36 37
 
37 38
     List<String> getComponyListAll(@Param("companyName") String companyName);
39
+
40
+    List<Department> getDepartmentDit();
38 41
 }

+ 2 - 0
src/main/java/com/cn/esermis/dpld/model/DataAcquisitionInstrumentVo.java

@@ -17,7 +17,9 @@ public class DataAcquisitionInstrumentVo extends DataAcquisitionInstrument {
17 17
    private Integer pageNum;
18 18
 
19 19
    private Integer pageSize;
20
+
20 21
    private String companyName;
22
+
21 23
    private String departmentName;
22 24
 
23 25
 }

+ 199 - 0
src/main/java/com/cn/esermis/dpld/model/DataAllVo.java

@@ -0,0 +1,199 @@
1
+package com.cn.esermis.dpld.model;
2
+
3
+import lombok.Data;
4
+
5
+import java.util.Date;
6
+
7
+
8
+@Data
9
+public class DataAllVo {
10
+
11
+    /**
12
+     * 排污口名称
13
+     */
14
+    private String outletName;
15
+    /**
16
+     * 排污口编号
17
+     */
18
+    private String outletCode;
19
+    /**
20
+     * 排污口类型(1 废气,2废水)
21
+     */
22
+    private Integer type;
23
+    /**
24
+     *建设投用日期
25
+     */
26
+    private Date useData;
27
+    /**
28
+     * 是否完成验收备案(0否 1是)
29
+     */
30
+    private Integer completeFilings;
31
+
32
+    /**
33
+     * 验收备案时间
34
+     */
35
+    private Date completeFilingsTime;
36
+
37
+    /**
38
+     * 数采仪品牌
39
+     */
40
+    private String collectionName;
41
+    /**
42
+     * 数采仪品牌
43
+     */
44
+    private String collectionBrand;
45
+    /**
46
+     * 数采仪型号
47
+     */
48
+    private String collectionModel;
49
+
50
+    /**
51
+     * 数采仪MN号
52
+     */
53
+    private String mnCode;
54
+    /**
55
+     * 数采仪IP
56
+     */
57
+    private String collectionIp;
58
+    /**
59
+     * 单位编码
60
+     */
61
+    private String companyCode;
62
+    /**
63
+     * 单位编码
64
+     */
65
+    private String departmentCode;
66
+    /**
67
+     * 是否有排气筒 1是 0否
68
+     */
69
+    private Integer haveExhaust;
70
+    /**
71
+     * 排气筒温度
72
+     */
73
+    private String exhaustTemperature;
74
+    /**
75
+     * 排气筒高度
76
+     */
77
+    private String exhaustHeight;
78
+    /**
79
+     * 排气筒直径
80
+     */
81
+    private String exhaustDiameter;
82
+    /**
83
+     * 行业类别
84
+     */
85
+    private String industryCategory;
86
+    /**
87
+     * 排污许可证编号
88
+     */
89
+    private String licenseNumber;
90
+    /**
91
+     *排污许可证有效期
92
+     */
93
+    private String licenseData;
94
+
95
+    /**
96
+     * 分析仪品牌
97
+     */
98
+    private String brand;
99
+    /**
100
+     * 分析仪型号
101
+     */
102
+    private String model;
103
+    /**
104
+     * 分析仪名称
105
+     */
106
+    private String name;
107
+    /**
108
+     *监测污染物因子及限值(小时均值、月排放总量、年排放总量)
109
+     */
110
+    private String factorInfor;
111
+    /**
112
+     * 量程
113
+     */
114
+    private String range;
115
+
116
+    /**
117
+     * 数采仪id
118
+     */
119
+    private String dataAcquisitionInstrumentId;
120
+
121
+    /**
122
+     * 基准氧含量(%)
123
+     */
124
+    private String referenceOxygenContent;
125
+    /**
126
+     * 速度场系数
127
+     */
128
+    private String velocityFieldCoefficient;
129
+
130
+    /**
131
+     * 皮托管系数
132
+     */
133
+    private String pitotTubeCoefficient;
134
+    /**
135
+     * k值
136
+     */
137
+    private String kvalue;
138
+    /**
139
+     * 烟道(监测口)截面积 M3
140
+     */
141
+    private String flueArea;
142
+    /**
143
+     * 稀释比
144
+     */
145
+    private String dilutionRatio;
146
+    /**
147
+     * 分析仪类型(1气体分析仪,2污水分析仪)
148
+     */
149
+    private Integer fxytype;
150
+
151
+    /**
152
+     * 分析仪主键ID
153
+     */
154
+    private String analyticalInstrumentId;
155
+    /**
156
+     * 检测因子编码
157
+     */
158
+    private String factor;
159
+    /**
160
+     * 小时均值
161
+     */
162
+    private String hoursAvg;
163
+    /**
164
+     * 小时均值单位
165
+     */
166
+    private String hoursUnit;
167
+    /**
168
+     * 月排放量
169
+     */
170
+    private String monthlyEmissions;
171
+
172
+    /**
173
+     * 月排放量单位
174
+     */
175
+    private String monthlyEmissionsUnit;
176
+
177
+    /**
178
+     * 年排放量
179
+     */
180
+    private String yearEmissions;
181
+    /**
182
+     * 年排放量单位
183
+     */
184
+    private String yearEmissionsUnit;
185
+
186
+    /**
187
+     * 量程
188
+     */
189
+    private String rangeStr;
190
+    /**
191
+     * 量程单位
192
+     */
193
+    private String rangeUnit;
194
+    /**
195
+     * 量程单位
196
+     */
197
+    private String factorName;
198
+
199
+}

+ 15 - 0
src/main/java/com/cn/esermis/dpld/model/Department.java

@@ -0,0 +1,15 @@
1
+package com.cn.esermis.dpld.model;
2
+
3
+import lombok.Data;
4
+
5
+@Data
6
+public class Department {
7
+
8
+    private String departmentid;
9
+
10
+    private String companyid;
11
+
12
+    private String departmentname;
13
+
14
+
15
+}

+ 3 - 0
src/main/java/com/cn/esermis/dpld/service/IDataAcquisitionInstrumentService.java

@@ -3,6 +3,7 @@ package com.cn.esermis.dpld.service;
3 3
 import com.baomidou.mybatisplus.extension.service.IService;
4 4
 import com.cn.esermis.dpld.entity.DataAcquisitionInstrument;
5 5
 import com.cn.esermis.dpld.model.DataAcquisitionInstrumentVo;
6
+import com.cn.esermis.dpld.model.Department;
6 7
 import com.cn.esermis.dpld.model.OutletAndFactorVo;
7 8
 import org.springframework.stereotype.Service;
8 9
 
@@ -28,4 +29,6 @@ public interface IDataAcquisitionInstrumentService extends IService<DataAcquisit
28 29
     List<String> getComponyList(String companyName,String companyId);
29 30
 
30 31
     List<String> getComponyListAll(String companyName);
32
+
33
+    List<Department> getDepartmentDit();
31 34
 }

+ 6 - 0
src/main/java/com/cn/esermis/dpld/service/impl/DataAcquisitionInstrumentServiceImpl.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4 4
 import com.cn.esermis.dpld.entity.DataAcquisitionInstrument;
5 5
 import com.cn.esermis.dpld.mapper.DataAcquisitionInstrumentMapper;
6 6
 import com.cn.esermis.dpld.model.DataAcquisitionInstrumentVo;
7
+import com.cn.esermis.dpld.model.Department;
7 8
 import com.cn.esermis.dpld.model.OutletAndFactorVo;
8 9
 import com.cn.esermis.dpld.service.IDataAcquisitionInstrumentService;
9 10
 import org.springframework.stereotype.Service;
@@ -60,4 +61,9 @@ public class DataAcquisitionInstrumentServiceImpl extends ServiceImpl<DataAcquis
60 61
     public List<String> getComponyListAll(String companyName) {
61 62
         return mapper.getComponyListAll(companyName);
62 63
     }
64
+
65
+    @Override
66
+    public List<Department> getDepartmentDit() {
67
+        return mapper.getDepartmentDit();
68
+    }
63 69
 }

+ 268 - 0
src/main/java/com/cn/esermis/excelReader/ExcelReader.java

@@ -0,0 +1,268 @@
1
+package com.cn.esermis.excelReader;
2
+
3
+
4
+import com.cn.esermis.coding.PollutionGas;
5
+import com.cn.esermis.dpld.model.DataAllVo;
6
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
7
+import org.apache.poi.ss.usermodel.Cell;
8
+import org.apache.poi.ss.usermodel.Row;
9
+import org.apache.poi.ss.usermodel.Sheet;
10
+import org.apache.poi.ss.usermodel.Workbook;
11
+
12
+import java.io.File;
13
+import java.io.FileInputStream;
14
+import java.io.IOException;
15
+import java.util.*;
16
+
17
+
18
+public class ExcelReader {
19
+
20
+    public List<Map<Integer,Object>> readExcelFile(String filePath) throws IOException {
21
+        List<Map<Integer,Object>> data = new LinkedList<>();
22
+
23
+        FileInputStream fis = new FileInputStream(new File(filePath));
24
+        Workbook workbook = new HSSFWorkbook(fis);
25
+        Sheet sheet = workbook.getSheetAt(0);
26
+
27
+        Iterator<Row> rowIterator = sheet.iterator();
28
+        while (rowIterator.hasNext()) {
29
+            Row row = rowIterator.next();
30
+            if(row.getRowNum() == 0){
31
+                continue;
32
+            }
33
+//            List<String> rowData = new ArrayList<>();
34
+            Map<Integer,Object> map = new LinkedHashMap<>();
35
+            Iterator<Cell> cellIterator = row.cellIterator();
36
+
37
+            while (cellIterator.hasNext()) {
38
+                Cell cell = cellIterator.next();
39
+                // 行标
40
+                int columnIndex = cell.getColumnIndex();
41
+                switch (cell.getCellType()) {
42
+                    case STRING:
43
+                        map.put(columnIndex,cell.getStringCellValue());
44
+                        break;
45
+                    case NUMERIC:
46
+                        map.put(columnIndex,String.valueOf(cell.getNumericCellValue()));
47
+                        break;
48
+                    case BOOLEAN:
49
+                        map.put(columnIndex,String.valueOf(cell.getBooleanCellValue()));
50
+                        break;
51
+                    default:
52
+                        map.put(columnIndex,"");
53
+                        break;
54
+                }
55
+            }
56
+            data.add(map);
57
+        }
58
+
59
+        workbook.close();
60
+        fis.close();
61
+
62
+        return data;
63
+    }
64
+
65
+    public List<DataAllVo> getData() {
66
+        String filePath = "E:\\Desktop\\排口信息.xls";
67
+        List<DataAllVo> dataAcquisitionInstrumentret = new ArrayList<>();
68
+        ExcelReader excelReader = new ExcelReader();
69
+        try {
70
+            List<Map<Integer, Object>> maps = excelReader.readExcelFile(filePath);
71
+            List<DataAllVo> dataAcquisitionInstruments = new ArrayList<>();
72
+
73
+            maps.forEach(x->{
74
+                DataAllVo instrumentVo = new DataAllVo();
75
+//                instrumentVo.setAnalyticalInstruments();
76
+//                instrumentVo.setPageNum();
77
+//                instrumentVo.setPageSize();
78
+//                instrumentVo.setCompanyName();
79
+//                instrumentVo.setDepartmentName();
80
+//                instrumentVo.setId();
81
+                instrumentVo.setOutletName(String.valueOf(x.get(6)!=null?x.get(6):""));
82
+                instrumentVo.setOutletCode(String.valueOf(x.get(6)!=null?x.get(6):""));
83
+                instrumentVo.setType(String.valueOf(x.get(6)!=null?x.get(6):"").equals("废气")?1:2);
84
+//                instrumentVo.setUseData();
85
+                if (x.get(14)!=null
86
+                        && !String.valueOf(x.get(14)).equals("是")){
87
+                    instrumentVo.setCompleteFilings(1);
88
+                }
89
+//                instrumentVo.setCompleteFilingsTime();
90
+                instrumentVo.setCollectionName(x.get(18)!=null? String.valueOf(x.get(18)) :"");
91
+                instrumentVo.setCollectionBrand(x.get(18)!=null? String.valueOf(x.get(18)) :"");
92
+                instrumentVo.setCollectionModel(x.get(19)!=null? String.valueOf(x.get(19)) :"");
93
+                instrumentVo.setMnCode(x.get(17)!=null? String.valueOf(x.get(17)) :"");
94
+//                if ()
95
+
96
+//                instrumentVo.setDepartmentCode();
97
+                instrumentVo.setHaveExhaust(String.valueOf(x.get(9)).equals("是")?1:0);
98
+                instrumentVo.setExhaustTemperature(x.get(11)!=null? String.valueOf(x.get(11)) :"");
99
+                instrumentVo.setExhaustHeight(x.get(10)!=null? String.valueOf(x.get(10)) :"");
100
+                instrumentVo.setExhaustDiameter(x.get(12)!=null? String.valueOf(x.get(12)) :"");
101
+                if (x.get(2)==null) {
102
+                    DataAllVo instrumentVo1 = dataAcquisitionInstruments.get(0);
103
+                    instrumentVo.setIndustryCategory(instrumentVo1.getIndustryCategory());
104
+                    instrumentVo.setLicenseNumber(instrumentVo1.getLicenseNumber());
105
+                    instrumentVo.setLicenseData(instrumentVo1.getLicenseData());
106
+                    instrumentVo.setCompanyCode(instrumentVo1.getCompanyCode());
107
+                }else if(x.get(2)!=null && String.valueOf(x.get(2)).equals("") ){
108
+                    DataAllVo instrumentVo1 = dataAcquisitionInstruments.get(0);
109
+                    instrumentVo.setIndustryCategory(instrumentVo1.getIndustryCategory());
110
+                    instrumentVo.setLicenseNumber(instrumentVo1.getLicenseNumber());
111
+                    instrumentVo.setLicenseData(instrumentVo1.getLicenseData());
112
+                    instrumentVo.setCompanyCode(instrumentVo1.getCompanyCode());
113
+                }
114
+                else{
115
+                    dataAcquisitionInstrumentret.addAll(dataAcquisitionInstruments);
116
+                    dataAcquisitionInstruments.clear();
117
+                    instrumentVo.setIndustryCategory(x.get(2)!=null? String.valueOf(x.get(2)) :"");
118
+                    instrumentVo.setLicenseNumber(x.get(3)!=null? String.valueOf(x.get(3)) :"");
119
+                    instrumentVo.setLicenseData(x.get(4)!=null? String.valueOf(x.get(4)) :"");
120
+                    instrumentVo.setCompanyCode(x.get(1)!=null? String.valueOf(x.get(1)) :"");
121
+                }
122
+                // 分析仪
123
+                instrumentVo.setBrand(x.get(20)!=null? String.valueOf(x.get(20)) :"");
124
+                instrumentVo.setModel(x.get(21)!=null? String.valueOf(x.get(21)) :"");
125
+                instrumentVo.setName(x.get(20)!=null? String.valueOf(x.get(20)) :"");
126
+//                instrumentVo.setFactorInfor(x.get(22)!=null? String.valueOf(x.get(22)) :"");
127
+//                instrumentVo.setRange(x.get(23)!=null? String.valueOf(x.get(23)) :"");
128
+//                instrumentVo.setDataAcquisitionInstrumentId(x.get(24)!=null? String.valueOf(x.get(24)) :"");
129
+                instrumentVo.setReferenceOxygenContent(x.get(22)!=null? String.valueOf(x.get(22)) :"");
130
+                instrumentVo.setVelocityFieldCoefficient(x.get(23)!=null? String.valueOf(x.get(23)) :"");
131
+                instrumentVo.setPitotTubeCoefficient(x.get(24)!=null? String.valueOf(x.get(24)) :"");
132
+                instrumentVo.setKvalue(x.get(26)!=null? String.valueOf(x.get(26)) :"");
133
+                instrumentVo.setFlueArea(x.get(25)!=null? String.valueOf(x.get(25)) :"");
134
+                instrumentVo.setDilutionRatio(x.get(27)!=null? String.valueOf(x.get(27)) :"");
135
+
136
+
137
+
138
+                instrumentVo.setHoursAvg(x.get(31)!=null? String.valueOf(x.get(31)) :"");
139
+                instrumentVo.setHoursUnit(x.get(32)!=null? String.valueOf(x.get(32)) :null);
140
+                instrumentVo.setMonthlyEmissions(x.get(33)!=null? String.valueOf(x.get(33)) :"");
141
+                instrumentVo.setMonthlyEmissionsUnit(x.get(34)!=null? String.valueOf(x.get(34)) :null);
142
+                instrumentVo.setYearEmissions(x.get(35)!=null? String.valueOf(x.get(35)) :"");
143
+                instrumentVo.setYearEmissionsUnit(x.get(36)!=null? String.valueOf(x.get(36)) :null);
144
+                instrumentVo.setRangeStr(x.get(37)!=null? String.valueOf(x.get(37)) :"");
145
+                instrumentVo.setRangeUnit(x.get(38)!=null? String.valueOf(x.get(38)) :"");
146
+                // 检测因子信息
147
+                instrumentVo.setFactorName(x.get(30)!=null? String.valueOf(x.get(30)) :"");
148
+
149
+                PollutionGas[] values = PollutionGas.values();
150
+                for (PollutionGas value : values) {
151
+                    if (value.mean().equals(instrumentVo.getFactorName())){
152
+                        instrumentVo.setFactor(value.code());
153
+                    }
154
+                }
155
+
156
+                dataAcquisitionInstruments.add(instrumentVo);
157
+
158
+            });
159
+//            System.out.println(dataAcquisitionInstrumentret);
160
+        } catch (IOException e) {
161
+            e.printStackTrace();
162
+        }
163
+        return dataAcquisitionInstrumentret;
164
+    }
165
+
166
+
167
+
168
+    public static void main(String[] args) {
169
+        String filePath = "E:\\Desktop\\排口信息.xls";
170
+
171
+        ExcelReader excelReader = new ExcelReader();
172
+        try {
173
+            List<Map<Integer, Object>> maps = excelReader.readExcelFile(filePath);
174
+            List<DataAllVo> dataAcquisitionInstruments = new ArrayList<>();
175
+            List<DataAllVo> dataAcquisitionInstrumentret = new ArrayList<>();
176
+            maps.forEach(x->{
177
+                DataAllVo instrumentVo = new DataAllVo();
178
+//                instrumentVo.setAnalyticalInstruments();
179
+//                instrumentVo.setPageNum();
180
+//                instrumentVo.setPageSize();
181
+//                instrumentVo.setCompanyName();
182
+//                instrumentVo.setDepartmentName();
183
+//                instrumentVo.setId();
184
+                instrumentVo.setOutletName(String.valueOf(x.get(6)!=null?x.get(6):""));
185
+                instrumentVo.setOutletCode(String.valueOf(x.get(6)!=null?x.get(6):""));
186
+                instrumentVo.setType(String.valueOf(x.get(6)!=null?x.get(6):"").equals("废气")?1:2);
187
+//                instrumentVo.setUseData();
188
+                if (x.get(14)!=null
189
+                        && !String.valueOf(x.get(14)).equals("是")){
190
+                    instrumentVo.setCompleteFilings(1);
191
+                }
192
+//                instrumentVo.setCompleteFilingsTime();
193
+                instrumentVo.setCollectionName(x.get(18)!=null? String.valueOf(x.get(18)) :"");
194
+                instrumentVo.setCollectionBrand(x.get(18)!=null? String.valueOf(x.get(18)) :"");
195
+                instrumentVo.setCollectionModel(x.get(19)!=null? String.valueOf(x.get(19)) :"");
196
+                instrumentVo.setMnCode(x.get(17)!=null? String.valueOf(x.get(17)) :"");
197
+//                if ()
198
+
199
+//                instrumentVo.setDepartmentCode();
200
+                instrumentVo.setHaveExhaust(String.valueOf(x.get(9)).equals("是")?1:0);
201
+                instrumentVo.setExhaustTemperature(x.get(11)!=null? String.valueOf(x.get(11)) :"");
202
+                instrumentVo.setExhaustHeight(x.get(10)!=null? String.valueOf(x.get(10)) :"");
203
+                instrumentVo.setExhaustDiameter(x.get(12)!=null? String.valueOf(x.get(12)) :"");
204
+                if (x.get(2)==null) {
205
+                    DataAllVo instrumentVo1 = dataAcquisitionInstruments.get(0);
206
+                    instrumentVo.setIndustryCategory(instrumentVo1.getIndustryCategory());
207
+                    instrumentVo.setLicenseNumber(instrumentVo1.getLicenseNumber());
208
+                    instrumentVo.setLicenseData(instrumentVo1.getLicenseData());
209
+                    instrumentVo.setCompanyCode(instrumentVo1.getCompanyCode());
210
+                }else if(x.get(2)!=null && String.valueOf(x.get(2)).equals("") ){
211
+                    DataAllVo instrumentVo1 = dataAcquisitionInstruments.get(0);
212
+                    instrumentVo.setIndustryCategory(instrumentVo1.getIndustryCategory());
213
+                    instrumentVo.setLicenseNumber(instrumentVo1.getLicenseNumber());
214
+                    instrumentVo.setLicenseData(instrumentVo1.getLicenseData());
215
+                    instrumentVo.setCompanyCode(instrumentVo1.getCompanyCode());
216
+                }
217
+                else{
218
+                    dataAcquisitionInstrumentret.addAll(dataAcquisitionInstruments);
219
+                    dataAcquisitionInstruments.clear();
220
+                    instrumentVo.setIndustryCategory(x.get(2)!=null? String.valueOf(x.get(2)) :"");
221
+                    instrumentVo.setLicenseNumber(x.get(3)!=null? String.valueOf(x.get(3)) :"");
222
+                    instrumentVo.setLicenseData(x.get(4)!=null? String.valueOf(x.get(4)) :"");
223
+                    instrumentVo.setCompanyCode(x.get(1)!=null? String.valueOf(x.get(1)) :"");
224
+                }
225
+                // 分析仪
226
+                instrumentVo.setBrand(x.get(20)!=null? String.valueOf(x.get(20)) :"");
227
+                instrumentVo.setModel(x.get(21)!=null? String.valueOf(x.get(21)) :"");
228
+                instrumentVo.setName(x.get(20)!=null? String.valueOf(x.get(20)) :"");
229
+//                instrumentVo.setFactorInfor(x.get(22)!=null? String.valueOf(x.get(22)) :"");
230
+//                instrumentVo.setRange(x.get(23)!=null? String.valueOf(x.get(23)) :"");
231
+//                instrumentVo.setDataAcquisitionInstrumentId(x.get(24)!=null? String.valueOf(x.get(24)) :"");
232
+                instrumentVo.setReferenceOxygenContent(x.get(22)!=null? String.valueOf(x.get(22)) :"");
233
+                instrumentVo.setVelocityFieldCoefficient(x.get(23)!=null? String.valueOf(x.get(23)) :"");
234
+                instrumentVo.setPitotTubeCoefficient(x.get(24)!=null? String.valueOf(x.get(24)) :"");
235
+                instrumentVo.setKvalue(x.get(26)!=null? String.valueOf(x.get(26)) :"");
236
+                instrumentVo.setFlueArea(x.get(25)!=null? String.valueOf(x.get(25)) :"");
237
+                instrumentVo.setDilutionRatio(x.get(27)!=null? String.valueOf(x.get(27)) :"");
238
+
239
+
240
+
241
+                instrumentVo.setHoursAvg(x.get(31)!=null? String.valueOf(x.get(31)) :"");
242
+                instrumentVo.setHoursUnit(x.get(32)!=null? String.valueOf(x.get(32)) :null);
243
+                instrumentVo.setMonthlyEmissions(x.get(33)!=null? String.valueOf(x.get(33)) :"");
244
+                instrumentVo.setMonthlyEmissionsUnit(x.get(34)!=null? String.valueOf(x.get(34)) :null);
245
+                instrumentVo.setYearEmissions(x.get(35)!=null? String.valueOf(x.get(35)) :"");
246
+                instrumentVo.setYearEmissionsUnit(x.get(36)!=null? String.valueOf(x.get(36)) :null);
247
+                instrumentVo.setRangeStr(x.get(37)!=null? String.valueOf(x.get(37)) :"");
248
+                instrumentVo.setRangeUnit(x.get(38)!=null? String.valueOf(x.get(38)) :"");
249
+                // 检测因子信息
250
+                instrumentVo.setFactorName(x.get(30)!=null? String.valueOf(x.get(30)) :"");
251
+
252
+                PollutionGas[] values = PollutionGas.values();
253
+                for (PollutionGas value : values) {
254
+                    if (value.mean().equals(instrumentVo.getFactorName())){
255
+                        instrumentVo.setFactor(value.code());
256
+                    }
257
+                }
258
+
259
+                dataAcquisitionInstruments.add(instrumentVo);
260
+
261
+            });
262
+            System.out.println(dataAcquisitionInstrumentret);
263
+        } catch (IOException e) {
264
+            e.printStackTrace();
265
+        }
266
+
267
+    }
268
+}

+ 21 - 21
src/main/java/com/cn/esermis/netty/BootNettyChannelInboundHandlerAdapter.java

@@ -87,8 +87,8 @@ public class BootNettyChannelInboundHandlerAdapter extends ChannelInboundHandler
87 87
                     JSONObject jsonObject = HJ212MsgUtils.dealMsg2(message);
88 88
                     if ((jsonObject!=null && jsonObject.getString(Constant.CN).equals(Constant.MINUTE))
89 89
                             ||(jsonObject!=null && jsonObject.getString(Constant.CN).equals(Constant.HOUR))){
90
-                        adapter.publisherService.pubMsg(jsonObject);
91
-//                        adapter.redisQueueService.sendMessage(Constant.SERVER, jsonObject);
90
+//                        adapter.publisherService.pubMsg(jsonObject);
91
+                        adapter.redisQueueService.sendMessage(Constant.SERVER, jsonObject);
92 92
                     }
93 93
                 } else {
94 94
                     if (dataMap.get(ctx.channel().id().toString()) != null) {
@@ -97,8 +97,8 @@ public class BootNettyChannelInboundHandlerAdapter extends ChannelInboundHandler
97 97
                         JSONObject jsonObject = HJ212MsgUtils.dealMsg2(startStr);
98 98
                         if ((jsonObject!=null &&  jsonObject.getString(Constant.CN).equals(Constant.MINUTE))
99 99
                                 || (jsonObject!=null && jsonObject.getString(Constant.CN).equals(Constant.HOUR))){
100
-//                            adapter.redisQueueService.sendMessage(Constant.SERVER, jsonObject);
101
-                            adapter.publisherService.pubMsg(jsonObject);
100
+                            adapter.redisQueueService.sendMessage(Constant.SERVER, jsonObject);
101
+//                            adapter.publisherService.pubMsg(jsonObject);
102 102
                         }
103 103
                         dataMap.remove(ctx.channel().id().toString());
104 104
                     } else {
@@ -185,23 +185,23 @@ public class BootNettyChannelInboundHandlerAdapter extends ChannelInboundHandler
185 185
     @Override
186 186
     public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception, IOException {
187 187
         if (evt instanceof IdleStateEvent) {
188
-            IdleStateEvent event = (IdleStateEvent) evt;
189
-
190
-            String eventType = null;
191
-            switch (event.state()) {
192
-                case READER_IDLE:
193
-                    eventType = "读超时";
194
-                    break;
195
-                case WRITER_IDLE:
196
-                    eventType = "写超时";
197
-                    break;
198
-                case ALL_IDLE:
199
-                    eventType = "读写超时";
200
-                    break;
201
-                default:
202
-                    eventType = "设备超时";
203
-            }
204
-            log.warn(ctx.channel().id() + " : " + eventType + "---> 关闭该设备");
188
+//            IdleStateEvent event = (IdleStateEvent) evt;
189
+//
190
+//            String eventType = null;
191
+//            switch (event.state()) {
192
+//                case READER_IDLE:
193
+//                    eventType = "读超时";
194
+//                    break;
195
+//                case WRITER_IDLE:
196
+//                    eventType = "写超时";
197
+//                    break;
198
+//                case ALL_IDLE:
199
+//                    eventType = "读写超时";
200
+//                    break;
201
+//                default:
202
+//                    eventType = "设备超时";
203
+//            }
204
+//            log.warn(ctx.channel().id() + " : " + eventType + "---> 关闭该设备");
205 205
             dataMap.remove(ctx.channel().id().toString());
206 206
             ctx.channel().close();
207 207
         }

+ 22 - 4
src/main/java/com/cn/esermis/server/Consumer.java

@@ -9,6 +9,10 @@ import org.springframework.beans.factory.annotation.Autowired;
9 9
 import org.springframework.scheduling.annotation.Async;
10 10
 import org.springframework.stereotype.Component;
11 11
 
12
+import java.util.concurrent.ExecutorService;
13
+import java.util.concurrent.Executors;
14
+import java.util.concurrent.TimeUnit;
15
+
12 16
 /**
13 17
  * 消费者类
14 18
  */
@@ -23,6 +27,12 @@ public class Consumer {
23 27
 
24 28
     @Async
25 29
     public void receive() throws InterruptedException {
30
+        System.out.println("开始消费消息");
31
+        // 开启线程池,如果有数据就启动线程消费
32
+        int numberOfThreads = 8;
33
+        int tolot = 0;
34
+        ExecutorService executorService = Executors.newFixedThreadPool(numberOfThreads);
35
+
26 36
         while (true){
27 37
             //取出消息
28 38
             Object message = redisQueueService.receiveMessage(Constant.SERVER);
@@ -30,10 +40,18 @@ public class Consumer {
30 40
 //                System.out.println("消息队列为空");
31 41
                 Thread.sleep(1000*5);
32 42
             }else{
33
-                // 数据入库
34
-                System.out.println("消费消息------------:"+message);
35
-                JSONObject jsonObject = (JSONObject) JSON.toJSON(message);
36
-                monitorBusiness.inboundOperations(jsonObject);
43
+                tolot++;
44
+                int finalTolot = tolot;
45
+                executorService.submit(new Runnable() {
46
+                    @Override
47
+                    public void run() {
48
+                        // 数据入库
49
+//                        System.out.println("消费消息------------:"+message);
50
+                        System.out.println("消费消息------------:第("+ finalTolot+")条");
51
+                        JSONObject jsonObject = (JSONObject) JSON.toJSON(message);
52
+                        monitorBusiness.inboundOperations(jsonObject);
53
+                    }
54
+                });
37 55
             }
38 56
         }
39 57
     }

+ 6 - 6
src/main/java/com/cn/esermis/server/Receiver.java

@@ -24,12 +24,12 @@ public class Receiver{
24 24
      */
25 25
     @Async
26 26
     public void systemMessage(Object message){
27
-        int counter = this.counter.incrementAndGet();
28
-        System.out.println("接收到第" + counter + "条消息!!频道为:server,消息内容为======:");
29
-
30
-        //TODO 开启多线程调用并处理消息
31
-        JSONObject result = sendAndStorageProcess.storageMsg(message);
32
-        System.out.println(result);
27
+//        int counter = this.counter.incrementAndGet();
28
+//        System.out.println("接收到第" + counter + "条消息!!频道为:server,消息内容为======:");
29
+//
30
+//        //TODO 开启多线程调用并处理消息
31
+//        JSONObject result = sendAndStorageProcess.storageMsg(message);
32
+//        System.out.println(result);
33 33
     }
34 34
 
35 35
 }

+ 3 - 0
src/main/resources/static/mybatis/DataAcquisitionInstrumentMapper.xml

@@ -67,5 +67,8 @@
67 67
             where companyname like concat('%',#{companyName},'%')
68 68
         </if>
69 69
     </select>
70
+    <select id="getDepartmentDit" resultType="com.cn.esermis.dpld.model.Department">
71
+        select departmentid,companyid,departmentname from department
72
+    </select>
70 73
 </mapper>
71 74