地质所 沉降监测网建设项目
zmk
2024-05-15 9e3afc6d0fa514f986d3fea40fa23124e6fb5070
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
package com.javaweb.geo.service.impl;
 
import com.javaweb.common.core.domain.AjaxResult;
import com.javaweb.common.exception.BusinessException;
import com.javaweb.common.json.JSON;
import com.javaweb.common.utils.NumberUtils;
import com.javaweb.common.utils.StringUtils;
import com.javaweb.geo.domain.*;
import com.javaweb.geo.mapper.*;
import com.javaweb.geo.service.IProjectWorkService;
import com.javaweb.geo.vo.ProjectWorkVo;
import com.javaweb.geo.vo.YanTuVo;
import com.javaweb.geotdp.domain.ResponseResult;
import com.javaweb.geotdp.enums.RecordType;
import com.javaweb.platform.domain.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.*;
import java.util.stream.Collectors;
 
@Service
public class ProjectWorkServiceImpl implements IProjectWorkService {
 
    @Autowired
    private ProjectMapper projectMapper;
 
    @Autowired
    private HoleMapper holeMapper;
 
    @Autowired
    private HoleHuiciMapper holeHuiciMapper;
 
    @Autowired
    private HoleYantuMapper holeYantuMapper;
 
    @Autowired
    private HoleQutuMapper holeQutuMapper;
 
    @Autowired
    private HoleBiaoguanMapper holeBiaoguanMapper;
 
    @Autowired
    private HoleShuiweiMapper holeShuiweiMapper;
 
    @Autowired
    private HolePersonMapper holePersonMapper;
 
    @Autowired
    private HoleMediaMapper holeMediaMapper;
 
 
    /**
     * 工作量统计
     */
    @Override
    public AjaxResult workloadAccount(String projectId) {
        ProjectWorkVo projectWorkVo;
        try {
            projectWorkVo = getProjectWork(projectId);
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.error("获取工作量统计失败");
        }
        return AjaxResult.success("获取工作量统计成功", projectWorkVo);
    }
 
    /**
     * 获取钻孔数据
     * @param holeId
     * @return
     */
    @Override
    public AjaxResult holeRecordList(String holeId){
 
        AjaxResult ajaxResult = AjaxResult.success("获取钻孔数据成功");
        try{
 
            Hole hole = holeMapper.selectHoleById(holeId);
            ajaxResult.put("hole",hole);
 
            HoleYantu holeYantu = new HoleYantu();
            holeYantu.setHoleId(holeId);
            holeYantu.setIsDelete(false);
            holeYantuMapper.selectHoleYantuList(holeYantu);
            List<HoleYantu> yantus = holeYantuMapper.selectHoleYantuList(holeYantu);
 
            ajaxResult.put("yantuList",yantus);
 
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("取钻孔数据失败");
        }
 
        return ajaxResult;
    }
 
    /**
     * 地质钻孔柱状图
     * @param holeId
     * @return
     */
    @Override
    public List<Map<Object, Object>> histogramJson(String holeId) {
        List<Map<Object,Object>> mapList=new ArrayList<>();
        //====================岩土==================
        HoleYantu holeYantu = new HoleYantu();
        holeYantu.setHoleId(holeId);
        holeYantu.setIsDelete(false);
 
        List<HoleYantu>  holeYantuList =holeYantuMapper.selectHoleYantuList(holeYantu);
 
        holeYantuList= holeYantuList.stream().filter(v->v.getBeginDepth() !=null && v.getEndDepth() !=null).collect(Collectors.toList());
        holeYantuList = holeYantuList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(HoleYantu:: getEndDepth))), ArrayList::new));
 
        try {
            holeYantuList.sort((x, y) -> Double.compare(x.getEndDepth(), y.getEndDepth()));
        }
        catch(Exception e) {
            throw new BusinessException("岩土数据排序异常:"+e.toString());
        }
        for(HoleYantu yantu:holeYantuList) {
            Map<Object,Object> map=new HashMap<Object,Object>();
            map.put("id", yantu.getIds());
            map.put("type", "岩土");
            map.put("code", yantu.getCode());
            map.put("typeName", yantu.getFrequencyType());
            map.put("layerName", yantu.getLayerName());
            map.put("begin", yantu.getBeginDepth());
            map.put("end", yantu.getEndDepth());
            map.put("medias",new String[0]);
 
            String title="";
 
            if(!StringUtils.isEmpty(yantu.getFrequencyType())){
                title+="岩土类型:"+yantu.getFrequencyType()+";";
            }
 
            if(!StringUtils.isEmpty(yantu.getLayerName())){
                title+="岩土定名:"+yantu.getLayerName()+";";
            }
 
            if(!StringUtils.isEmpty(yantu.getYs())) {
                title+="颜色:"+yantu.getYs()+";";
            }
            if(!StringUtils.isEmpty(yantu.getMsd())) {
                title+="密实度:"+yantu.getMsd()+";";
            }
            if(!StringUtils.isEmpty(yantu.getSd())) {
                title+="湿度:"+yantu.getSd()+";";
            }
 
            if(!StringUtils.isEmpty(yantu.getYbljx())) {
                title+="一般粒径小:"+yantu.getYbljx()+";";
            }
            if(!StringUtils.isEmpty(yantu.getYbljd())) {
                title+="一般粒径大:"+yantu.getYbljd()+";";
            }
            if(!StringUtils.isEmpty(yantu.getZdlj())) {
                title+="最大粒径:"+yantu.getZdlj()+";";
            }
            if(!StringUtils.isEmpty(yantu.getZt())) {
                title+="状态:"+yantu.getZt()+";";
            }
            if(!StringUtils.isEmpty(yantu.getBhw())) {
                title+="包含物:"+yantu.getBhw()+";";
            }
            if(!StringUtils.isEmpty(yantu.getKlxz())) {
                title+="颗粒形状:"+yantu.getKlxz()+";";
            }
            if(!StringUtils.isEmpty(yantu.getKlpl())) {
                title+="颗粒排列:"+yantu.getKlpl()+";";
            }
            if(!StringUtils.isEmpty(yantu.getKljp())) {
                title+="颗粒级配:"+yantu.getKljp()+";";
            }
            map.put("title", title);
            mapList.add(map);
        }
        //=========================水位==================================
        HoleShuiwei holeShuiwei = new HoleShuiwei();
        holeShuiwei.setHoleId(holeId);
        holeShuiwei.setIsDelete(false);
 
        List<HoleShuiwei> shuiweiList = holeShuiweiMapper.selectHoleShuiweiList(holeShuiwei);
 
        shuiweiList=shuiweiList.stream().filter(v->v.getShownWaterLevel()!=null&&v.getStillWaterLevel()!=null).collect(Collectors.toList());
        try {
            shuiweiList.sort((x, y) -> Double.compare(x.getShownWaterLevel(),y.getShownWaterLevel()));
        }
        catch(Exception e) {
            throw new BusinessException("水位数据排序异常:"+e.toString());
        }
        for(HoleShuiwei shuiwei:shuiweiList) {
            Map<Object,Object> map=new HashMap<Object,Object>();
            map.put("id", shuiwei.getIds());
            map.put("type", "水位");
            map.put("code", shuiwei.getCode());
            map.put("typeName", "地下水");
            map.put("begin", shuiwei.getShownTime());
            map.put("end", shuiwei.getStillWaterLevel());
            map.put("medias",new String[0]);
            String title="";
            if(shuiwei.getShownWaterLevel() !=null){
                title+="初见水位:"+shuiwei.getShownWaterLevel()+";";
            }
            if(shuiwei.getStillWaterLevel() !=null){
                title+="稳定水位:"+shuiwei.getStillWaterLevel()+";";
            }
            map.put("title", title);
            mapList.add(map);
        }
        try {
            mapList.sort((x, y) -> Double.compare(Double.parseDouble(x.get("begin").toString()),Double.parseDouble(y.get("begin").toString())));
        }
        catch(Exception e) {
            System.out.print(e);
        }
        //==========================回次==========================
        HoleHuici holeHuici = new HoleHuici();
        holeHuici.setHoleId(holeId);
        holeHuici.setIsDelete(false);
        List<HoleHuici> huiciList = holeHuiciMapper.selectHoleHuiciList(holeHuici);
 
        huiciList=huiciList.stream().filter(v->v.getBeginDepth()!=null&&v.getEndDepth()!=null).collect(Collectors.toList());
        try {
            huiciList.sort((x, y) -> Double.compare(x.getEndDepth(),y.getEndDepth()));
        }
        catch(Exception e) {
            System.out.print(e);
        }
        for(HoleHuici huici:huiciList) {
            Map<Object,Object> map=new HashMap<Object,Object>();
            map.put("id", huici.getIds());
            map.put("type", "回次");
            map.put("code", huici.getCode());
            map.put("typeName", huici.getFrequencyType()+'-'+huici.getFrequencyMode());
            map.put("begin", huici.getBeginDepth());
            map.put("end", huici.getEndDepth());
            map.put("medias",new String[0]);
            String title="";
            if(!StringUtils.isEmpty(huici.getFrequencyType())) {
                title+="钻进方法:"+huici.getFrequencyType()+";";
            }
            if(!StringUtils.isEmpty(huici.getFrequencyMode())) {
                title+="护壁方法:"+huici.getFrequencyMode()+";";
            }
            if(huici.getAperture() !=null ) {
                title+="钻孔孔径:"+huici.getAperture()+";";
            }
            if(huici.getBeginDepth() != null ) {
                title+="起始深度:"+huici.getBeginDepth()+";";
            }
            if(huici.getEndDepth() !=null) {
                title+="终止深度:"+huici.getEndDepth()+";";
            }
            map.put("title", title);
            mapList.add(map);
        }
 
        //=======================取样 / 取土==========================
 
        HoleQutu holeQutu = new HoleQutu();
        holeQutu.setHoleId(holeId);
        holeQutu.setIsDelete(false);
 
        List<HoleQutu> qutuList = holeQutuMapper.selectHoleQutuList(holeQutu);
 
        qutuList=qutuList.stream().filter(v->v.getBeginDepth()!=null&&v.getEndDepth()!=null).collect(Collectors.toList());
        try {
            qutuList.sort((x, y) -> Double.compare(x.getEndDepth(),y.getEndDepth()));
        }
        catch(Exception e) {
            System.out.print(e);
        }
        for(HoleQutu qutu:qutuList) {
            Map<Object,Object> map=new HashMap<Object,Object>();
            map.put("id", qutu.getIds());
            map.put("type", "取土");
            map.put("code",qutu.getCode());
            map.put("typeName", "取土");
            map.put("begin", qutu.getBeginDepth());
            map.put("end", qutu.getEndDepth());
            map.put("medias",new String[0]);
            String title="";
            if(!StringUtils.isEmpty(qutu.getEarthType())) {
                title+="土样质量等级:"+qutu.getEarthType()+";";
            }
            if(!StringUtils.isEmpty(qutu.getGetMode())) {
                title+="取样工具和方法:"+qutu.getGetMode()+";";
            }
            map.put("title", title);
            mapList.add(map);
        }
 
        //==================动探/标贯===========================
        HoleBiaoguan holeBiaoguan = new HoleBiaoguan();
        holeBiaoguan.setHoleId(holeId);
        holeBiaoguan.setIsDelete(false);
 
        List<HoleBiaoguan> biaoguanList = holeBiaoguanMapper.selectHoleBiaoguanList(holeBiaoguan);
        try {
            biaoguanList.sort((x, y) -> Double.compare(x.getBegin1(),y.getBegin1()));
        }
        catch(Exception e) {
            System.out.print(e);
        }
        for(HoleBiaoguan biaogaun:biaoguanList) {
            if(biaogaun.getBegin1() != null && biaogaun.getBegin1() !=0 ) {
                Map<Object,Object> map=new HashMap<Object,Object>();
                map.put("id", biaogaun.getIds());
                if(biaogaun.getType().equals(RecordType.dt.getId())) {
                    map.put("type", "动探");
                    map.put("typeName", "动探");
                }
                else if(biaogaun.getType().equals(RecordType.bg.getId())) {
                    map.put("type", "标贯");
                    map.put("typeName", "标贯");
                }
                map.put("code", biaogaun.getCode());
                map.put("begin", biaogaun.getBegin1());
//                Double endDepth=0.0;
                //此处end 有疑问
                map.put("end", biaogaun.getEnd1());
                map.put("medias",new String[0]);
                String title="";
 
                if(biaogaun.getDrillLength()!=null) {
                    title+="钻杆长度:"+biaogaun.getDrillLength()+";";
                }
                if(biaogaun.getBegin1()!=null && biaogaun.getBlow1() !=null) {
                    title+="<br/>预:"+biaogaun.getBegin1()+"m~"+biaogaun.getEnd1()+"m="+biaogaun.getBlow1()+";";
                }
                if(biaogaun.getBegin2()!=null && biaogaun.getBlow2() !=null) {
                    title+="<br/>1:"+biaogaun.getBegin2()+"m~"+biaogaun.getEnd2()+"m="+biaogaun.getBlow2()+";";
                }
                if(biaogaun.getBegin3()!=null&&biaogaun.getBlow3() !=null) {
                    title+="<br/>2:"+biaogaun.getBegin3()+"m~"+biaogaun.getEnd3()+"m="+biaogaun.getBlow3()+";";
                }
                if(biaogaun.getBegin4()!=null&&biaogaun.getBlow4() !=null) {
                    title+="<br/>3:"+biaogaun.getBegin4()+"m~"+biaogaun.getEnd4()+"m="+biaogaun.getBlow4()+";";
                }
                map.put("title", title);
                mapList.add(map);
            }
        }
        return mapList;
    }
 
 
    /**
     * 工作量统计
     * @param projectId
     * @return
     */
    private ProjectWorkVo getProjectWork(String projectId){
 
        // 水位 + 取水
        Long shuiWeiCount = holeShuiweiMapper.countNumberByProjectId(projectId, RecordType.sw.getName());
        Long quShuiCount = holeShuiweiMapper.countNumberByProjectId(projectId, RecordType.qs.getName());
 
        // 标贯 + 动探
        Long biaoGuanCount = holeBiaoguanMapper.countNumberByProjectId(projectId, RecordType.bg.getName());
        Long dongKanCount = holeBiaoguanMapper.countNumberByProjectId(projectId, RecordType.dt.getName());
 
        // 照片
        Long zhaoPianCount = holeMediaMapper.countNumberByProjectId(projectId);
 
        //取样(回次)
        Long huiCiCount = holeHuiciMapper.countNumberByProjectId(projectId);
 
        //TODO 回次总进尺、总次数
 
        //TODO 岩土对象
 
        ProjectWorkVo projectWorkVo = new ProjectWorkVo();
        projectWorkVo.setHuiciCount(-1d);
        projectWorkVo.setHuiciNumber(huiCiCount);
 
        projectWorkVo.setShuiWeiNumber(shuiWeiCount);
        projectWorkVo.setQuYangNumber(huiCiCount);
        projectWorkVo.setQuShuiNumber(quShuiCount);
        projectWorkVo.setDongTanNumber(dongKanCount);
        projectWorkVo.setBiaoGuanNumber(biaoGuanCount);
        projectWorkVo.setZhaoPianNumber(zhaoPianCount);
 
        //获取岩土的对象集合
        List<YanTuVo> yantuList = YanTuVoList(projectId);
        projectWorkVo.setYanTuList(yantuList);
 
        return projectWorkVo;
    }
 
 
    /**
     * 获取岩土工作量表格
     * @return
     */
    private List<YanTuVo> YanTuVoList(String projectId){
        HoleYantu holeYantu = new HoleYantu();
        holeYantu.setProjectId(projectId);
        holeYantu.setIsDelete(false);
 
        //List<HoleYantu> yantus = holeYantuMapper.selectHoleYantuList(holeYantu);
        List<HoleYantu> yantus = holeYantuMapper.selectTongjiHoleYantuList(holeYantu);
        Map <String,Integer>  cishuMap= new HashMap<>();
        Map<String,Double> jinchiMap = new HashMap<>();
 
        for(HoleYantu tu : yantus){
            String ftype = tu.getFrequencyType();
            if(StringUtils.isEmpty(ftype)){
                continue;
            }
            Double begin = tu.getBeginDepth();
            Double end = tu.getEndDepth();
            if(begin==null || end ==null){
                continue;
            }
            Double total = end-begin;
            if(cishuMap.containsKey(ftype)){
                cishuMap.put(ftype,cishuMap.get(ftype)+1);
                jinchiMap.put(ftype,jinchiMap.get(ftype)+total);
            }else{
                cishuMap.put(ftype,1);
                jinchiMap.put(ftype,total);
            }
        }
        Integer CISHU = 0;
        Double JINCHI=0d;
        List<YanTuVo> list = new ArrayList<>();
        for(Map.Entry<String,Integer> entry : cishuMap.entrySet() ){
            CISHU +=entry.getValue();
            JINCHI += jinchiMap.get(entry.getKey());
 
            //设置vo对象
            YanTuVo yanTuVo = new YanTuVo();
            yanTuVo.setFrequencyType(entry.getKey());
            yanTuVo.setCishuNumber(entry.getValue().longValue());
            yanTuVo.setJinchiCount(NumberUtils.div(jinchiMap.get(entry.getKey()),1,2));
            list.add(yanTuVo);
        }
 
        YanTuVo  yan = new YanTuVo();
        yan.setFrequencyType("总计");
        yan.setJinchiCount(NumberUtils.div(JINCHI,1,2));
        yan.setCishuNumber(CISHU.longValue());
 
        List<YanTuVo> result  = new ArrayList<>();
        result.add(yan);
        result.addAll(list);
        return result;
    }
 
 
}