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;
|
}
|
|
|
}
|