Commit 7f11f763 by jiang'yun

修改

parent 99e3adff
...@@ -1794,28 +1794,6 @@ public class SjDjjcController extends BaseController ...@@ -1794,28 +1794,6 @@ public class SjDjjcController extends BaseController
param.setJh(jh); param.setJh(jh);
List<SjDcfxDzfc> dzfcList = djdcService.getDzfcList2(param); List<SjDcfxDzfc> dzfcList = djdcService.getDzfcList2(param);
List<SjFdfx> sjFdfxList=new ArrayList<>(); List<SjFdfx> sjFdfxList=new ArrayList<>();
double ksjs= 0;
for (int i = 0; i < sjJsjgList.size(); i++) {
if (i == 0) {
ksjs = 0;
} else {
//上一次的垂深
ksjs = sjJsjgList.get(i - 1).getJs();
}
}
for (SjDcfxDzfc sjDcfxDzfc : dzfcList){
SjFdfx sjFdfx = new SjFdfx();
BeanUtils.copyProperties(sjDcfxDzfc,sjFdfx);
sjFdfx.setZbid(id);
sjFdfxList.add(sjFdfx);
}
if(sjFdfxList.size()>0){
sjFdfxMapper.deleteSjFdfxByZbid(id);
sjFdfxMapper.insertSjFdfxBatch(sjFdfxList);
}
if(dzfcList.size()>0){ if(dzfcList.size()>0){
sjDcfxDzfcMapper.deleteSjDcfxDzfcByJh(jh); sjDcfxDzfcMapper.deleteSjDcfxDzfcByJh(jh);
sjDcfxDzfcMapper.insertSjDcfxDzfcBatch(dzfcList); sjDcfxDzfcMapper.insertSjDcfxDzfcBatch(dzfcList);
...@@ -1834,11 +1812,17 @@ public class SjDjjcController extends BaseController ...@@ -1834,11 +1812,17 @@ public class SjDjjcController extends BaseController
double targetCs = CxszhUtil.getCs(sjJygjGdsjgdcsList, sjJsjg.getJs()); double targetCs = CxszhUtil.getCs(sjJygjGdsjgdcsList, sjJsjg.getJs());
csaa = targetCs; csaa = targetCs;
sjFdsgcsDcyxList.addAll(processAndDisplay(dzfcList, previousDepth, targetCs, jh, sjJsjg.getKc())); sjFdsgcsDcyxList.addAll(processAndDisplay(dzfcList, previousDepth, targetCs, jh, sjJsjg.getKc()));
sjFdfxList.addAll(processAndDisplayFd(dzfcList, previousDepth, targetCs, jh, sjJsjg.getKc(),sjJygjGdsjgdcsList,id));
} }
if (sjFdsgcsDcyxList.size() > 0) { if (sjFdsgcsDcyxList.size() > 0) {
sjFdsgcsDcyxMapper.deleteSjFdsgcsDcyxByJh(jh); sjFdsgcsDcyxMapper.deleteSjFdsgcsDcyxByJh(jh);
sjFdsgcsDcyxMapper.insertSjFdsgcsDcyxBatch(sjFdsgcsDcyxList); sjFdsgcsDcyxMapper.insertSjFdsgcsDcyxBatch(sjFdsgcsDcyxList);
} }
if(sjFdfxList.size()>0){
sjFdfxMapper.deleteSjFdfxByZbid(id);
sjFdfxMapper.insertSjFdfxBatch(sjFdfxList);
}
} }
} catch (IOException e) { } catch (IOException e) {
e.getMessage(); e.getMessage();
...@@ -1852,6 +1836,39 @@ public class SjDjjcController extends BaseController ...@@ -1852,6 +1836,39 @@ public class SjDjjcController extends BaseController
return AjaxResult.success("导入成功"); return AjaxResult.success("导入成功");
} }
@GetMapping("/tqfdfx")
public AjaxResult tqfdfx(SjDjjc sjDjjc) throws Exception {
SjDjjc sjDjjcnew=sjDjjcService.selectSjDjjcById(sjDjjc.getId());
String jh = sjDjjcnew.getJh();
SjDcfxDzfc sjDcfxDzfc=new SjDcfxDzfc();
sjDcfxDzfc.setJh(sjDjjcnew.getJh());
List<SjDcfxDzfc> dzfcList = sjDcfxDzfcMapper.selectSjDcfxDzfcList(sjDcfxDzfc);
SjJsjg sjJsjg1=new SjJsjg();
sjJsjg1.setJh(sjDjjcnew.getJh());
List<SjJsjg> sjJsjgList = sjJsjgMapper.selectSjJsjgList(sjJsjg1);
SjJygjGdsjgdcs sjJygjGdsjgdcs=new SjJygjGdsjgdcs();
sjJygjGdsjgdcs.setJh(sjDjjcnew.getJh());
List<SjJygjGdsjgdcs> sjJygjGdsjgdcsList = sjJygjGdsjgdcsMapper.selectSjJygjGdsjgdcsList(sjJygjGdsjgdcs);
List<SjFdfx> sjFdfxList=new ArrayList<>();
double previousDepth= 0;
double csaa= 0;
for (int i = 0; i < sjJsjgList.size(); i++) {
SjJsjg sjJsjg = sjJsjgList.get(i);
if (i == 0) {
previousDepth = 0;
} else {
//上一次的垂深
previousDepth = csaa;
}
//计算垂深
double targetCs = CxszhUtil.getCs(sjJygjGdsjgdcsList, sjJsjg.getJs());
csaa = targetCs;
sjFdfxList.addAll(processAndDisplayFd(dzfcList, previousDepth, targetCs, jh, sjJsjg.getKc(),sjJygjGdsjgdcsList,sjDjjcnew.getId()));
}
return AjaxResult.success(sjFdfxList);
}
private static List<SjFdsgcsDcyx> processAndDisplay(List<SjDcfxDzfc> stratumList,double kscs, double targetCs,String jh,String kc) { private static List<SjFdsgcsDcyx> processAndDisplay(List<SjDcfxDzfc> stratumList,double kscs, double targetCs,String jh,String kc) {
...@@ -1904,6 +1921,60 @@ public class SjDjjcController extends BaseController ...@@ -1904,6 +1921,60 @@ public class SjDjjcController extends BaseController
private static List<SjFdfx> processAndDisplayFd(List<SjDcfxDzfc> stratumList,double kscs, double targetCs,String jh,String kc,List<SjJygjGdsjgdcs> sjJygjGdsjgdcsList,Long id) {
List<SjFdfx> list =new ArrayList<>();
System.out.println("名称\t井段垂深 / m");
double previousDepth = kscs; // 从kscs开始计算
boolean foundStartingPoint = false;
System.out.println("名称\t井段垂深 / m");
for (SjDcfxDzfc stratum : stratumList) {
double currentDepth = stratum.getCs();
// 如果还没找到起始点,且当前地层深度小于kscs,跳过
if (!foundStartingPoint && currentDepth < kscs) {
continue;
}
// 标记已找到起始点
foundStartingPoint = true;
// 确定当前地层的显示结束深度
double endDepth = Math.min(currentDepth, targetCs);
SjFdfx sjFdfx = new SjFdfx();
sjFdfx.setZbid(id);
sjFdfx.setJh(jh);
sjFdfx.setKc(kc);
sjFdfx.setDzfc(stratum.getDzfc());
sjFdfx.setCs(endDepth);
//计算斜深
sjFdfx.setXs(getJs(sjJygjGdsjgdcsList,endDepth));
sjFdfx.setYxts(stratum.getYxts());
sjFdfx.setYqsts(stratum.getYqsts());
sjFdfx.setGzts(stratum.getGzts());
list.add(sjFdfx);
// 更新上一个深度
previousDepth = currentDepth;
// 如果当前地层已经超过cs参数,结束处理
if (currentDepth >= targetCs) {
break;
}
}
return list;
}
public static double getCs(List<SjJygjGdsjgdcs> yjMnJygjJgList, double js){ public static double getCs(List<SjJygjGdsjgdcs> yjMnJygjJgList, double js){
DecimalFormat df = new DecimalFormat("#.00"); DecimalFormat df = new DecimalFormat("#.00");
...@@ -1940,6 +2011,40 @@ public class SjDjjcController extends BaseController ...@@ -1940,6 +2011,40 @@ public class SjDjjcController extends BaseController
return Double.parseDouble(df.format(cs)); return Double.parseDouble(df.format(cs));
} }
public static double getJs(List<SjJygjGdsjgdcs> yjMnJygjJgList, double cs) {
// 创建DecimalFormat对象,用于保留两位小数
DecimalFormat df = new DecimalFormat("#.00");
double js = 0;
// 遍历所有数据点
for (int i = 0; i < yjMnJygjJgList.size(); i++) {
SjJygjGdsjgdcs jg = yjMnJygjJgList.get(i);
double currentCs = jg.getCs();
// 找到垂深大于等于目标垂深的点
if (currentCs >= cs) {
// 如果是第一个点,直接返回该点的斜深
if (i == 0) {
js = yjMnJygjJgList.get(i).getJs();
break;
} else {
// 找到目标垂深所在的区间,进行线性插值计算斜深
double prevCs = yjMnJygjJgList.get(i-1).getCs();
double prevJs = yjMnJygjJgList.get(i-1).getJs();
double currJs = yjMnJygjJgList.get(i).getJs();
// 计算插值比例
double ratio = (cs - prevCs) / (currentCs - prevCs);
// 线性插值计算斜深
js = prevJs + ratio * (currJs - prevJs);
break;
}
}
}
// 格式化结果并返回
return Double.parseDouble(df.format(js));
}
public static String extractNumber(String str) { public static String extractNumber(String str) {
// 正则表达式:匹配-或~,然后捕获后面的数字 // 正则表达式:匹配-或~,然后捕获后面的数字
......
...@@ -2,6 +2,8 @@ package com.zjsgfa.project.zjsgfa.controller; ...@@ -2,6 +2,8 @@ package com.zjsgfa.project.zjsgfa.controller;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.zjsgfa.project.system.domain.SysUser;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -20,6 +22,7 @@ import com.zjsgfa.framework.web.controller.BaseController; ...@@ -20,6 +22,7 @@ import com.zjsgfa.framework.web.controller.BaseController;
import com.zjsgfa.framework.web.domain.AjaxResult; import com.zjsgfa.framework.web.domain.AjaxResult;
import com.zjsgfa.common.utils.poi.ExcelUtil; import com.zjsgfa.common.utils.poi.ExcelUtil;
import com.zjsgfa.framework.web.page.TableDataInfo; import com.zjsgfa.framework.web.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
/** /**
* 设计-分段分析Controller * 设计-分段分析Controller
...@@ -41,7 +44,7 @@ public class SjFdfxController extends BaseController ...@@ -41,7 +44,7 @@ public class SjFdfxController extends BaseController
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(SjFdfx sjFdfx) public TableDataInfo list(SjFdfx sjFdfx)
{ {
startPage(); // startPage();
List<SjFdfx> list = sjFdfxService.selectSjFdfxList(sjFdfx); List<SjFdfx> list = sjFdfxService.selectSjFdfxList(sjFdfx);
return getDataTable(list); return getDataTable(list);
} }
...@@ -109,4 +112,22 @@ public class SjFdfxController extends BaseController ...@@ -109,4 +112,22 @@ public class SjFdfxController extends BaseController
return toAjax(sjFdfxService.pladd(sjFdfx)); return toAjax(sjFdfxService.pladd(sjFdfx));
} }
@PostMapping("/importData")
public AjaxResult importData(MultipartFile file, Long zbid) throws Exception
{
ExcelUtil<SjFdfx> util = new ExcelUtil<SjFdfx>(SjFdfx.class);
List<SjFdfx> sjFdfxList = util.importExcel(file.getInputStream());
sjFdfxList.forEach(sjFdfx -> sjFdfx.setZbid(zbid));
if(sjFdfxList.size()>0){
sjFdfxService.importData(sjFdfxList);
}
return success("导入成功!");
}
} }
...@@ -23,15 +23,16 @@ public class SjFdfx extends BaseEntity ...@@ -23,15 +23,16 @@ public class SjFdfx extends BaseEntity
private Long id; private Long id;
/** 主表id */ /** 主表id */
@Excel(name = "主表id") // @Excel(name = "主表id")
private Long zbid; private Long zbid;
private String kc;
/** 井号 */ /** 井号 */
@Excel(name = "井号") @Excel(name = "井号")
private String jh; private String jh;
@Excel(name = "开次")
private String kc;
/** 地质分层 */ /** 地质分层 */
@Excel(name = "地质分层") @Excel(name = "地质分层")
private String dzfc; private String dzfc;
...@@ -41,7 +42,7 @@ public class SjFdfx extends BaseEntity ...@@ -41,7 +42,7 @@ public class SjFdfx extends BaseEntity
private Double cs; private Double cs;
/** 井身 */ /** 井身 */
@Excel(name = "井") @Excel(name = "井")
private Double xs; private Double xs;
/** 岩性提示 */ /** 岩性提示 */
...@@ -57,7 +58,7 @@ public class SjFdfx extends BaseEntity ...@@ -57,7 +58,7 @@ public class SjFdfx extends BaseEntity
private String gzts; private String gzts;
/** 工程地质分段合并id */ /** 工程地质分段合并id */
@Excel(name = "工程地质分段合并id") // @Excel(name = "工程地质分段合并id")
private String gcdzfdid; private String gcdzfdid;
/** 工程地质分段 */ /** 工程地质分段 */
...@@ -65,7 +66,7 @@ public class SjFdfx extends BaseEntity ...@@ -65,7 +66,7 @@ public class SjFdfx extends BaseEntity
private String gcdzfd; private String gcdzfd;
/** 划分依据合并id */ /** 划分依据合并id */
@Excel(name = "划分依据合并id") // @Excel(name = "划分依据合并id")
private String hfyjid; private String hfyjid;
/** 划分依据 */ /** 划分依据 */
......
...@@ -61,4 +61,5 @@ public interface ISjFdfxService ...@@ -61,4 +61,5 @@ public interface ISjFdfxService
int pladd(SjFdfx sjFdfx); int pladd(SjFdfx sjFdfx);
int importData(List<SjFdfx> sjFdfxList);
} }
...@@ -102,32 +102,39 @@ public class SjFdfxServiceImpl implements ISjFdfxService ...@@ -102,32 +102,39 @@ public class SjFdfxServiceImpl implements ISjFdfxService
if(list.size()==0){ if(list.size()==0){
return 0; return 0;
} }
List<SjFdfx> collect = list.stream().filter(it -> StringUtils.isEmpty(it.getGcdzfdid())).collect(Collectors.toList()); // List<SjFdfx> collect = list.stream().filter(it -> StringUtils.isEmpty(it.getGcdzfdid())).collect(Collectors.toList());
Map<String, List<SjFdfx>> groupedByList = list.stream().filter(it -> StringUtils.isNotEmpty(it.getGcdzfdid())).collect(Collectors.toList()).stream() // Map<String, List<SjFdfx>> groupedByList = list.stream().filter(it -> StringUtils.isNotEmpty(it.getGcdzfdid())).collect(Collectors.toList()).stream()
.collect(Collectors.groupingBy(SjFdfx::getGcdzfdid)); // .collect(Collectors.groupingBy(SjFdfx::getGcdzfdid));
List<SjFdfx> addList =new ArrayList<>(); // List<SjFdfx> addList =new ArrayList<>();
for (Map.Entry<String, List<SjFdfx>> entry : groupedByList.entrySet()) { // for (Map.Entry<String, List<SjFdfx>> entry : groupedByList.entrySet()) {
List<SjFdfx> sjFdfxList = entry.getValue(); // List<SjFdfx> sjFdfxList = entry.getValue();
SjFdfx sjFdfx1 = sjFdfxList.stream().filter(item -> StringUtils.isNotEmpty(item.getGcdzfd())).findFirst().orElse(null); // SjFdfx sjFdfx1 = sjFdfxList.stream().filter(item -> StringUtils.isNotEmpty(item.getGcdzfd())).findFirst().orElse(null);
String gcdzfd=""; // String gcdzfd="";
if(sjFdfx1!=null){ // if(sjFdfx1!=null){
gcdzfd= sjFdfx1.getGcdzfd(); // gcdzfd= sjFdfx1.getGcdzfd();
} // }
//
SjFdfx sjFdfx2 = sjFdfxList.stream().filter(item -> StringUtils.isNotEmpty(item.getHfyj())).findFirst().orElse(null); // SjFdfx sjFdfx2 = sjFdfxList.stream().filter(item -> StringUtils.isNotEmpty(item.getHfyj())).findFirst().orElse(null);
String fdyj=""; // String fdyj="";
if(sjFdfx2!=null){ // if(sjFdfx2!=null){
fdyj= sjFdfx2.getHfyj(); // fdyj= sjFdfx2.getHfyj();
} // }
for(SjFdfx item:sjFdfxList){ // for(SjFdfx item:sjFdfxList){
item.setGcdzfd(gcdzfd); // item.setGcdzfd(gcdzfd);
item.setHfyj(fdyj); // item.setHfyj(fdyj);
addList.add(item); // addList.add(item);
} // }
} // }
addList.addAll(collect); // addList.addAll(collect);
//删除数据 //删除数据
sjFdfxMapper.deleteSjFdfxByZbid(list.get(0).getZbid()); sjFdfxMapper.deleteSjFdfxByZbid(list.get(0).getZbid());
return sjFdfxMapper.insertSjFdfxBatch(addList); return sjFdfxMapper.insertSjFdfxBatch(list);
}
@Override
public int importData(List<SjFdfx> sjFdfxList) {
//删除数据
sjFdfxMapper.deleteSjFdfxByZbid(sjFdfxList.get(0).getZbid());
return sjFdfxMapper.insertSjFdfxBatch(sjFdfxList);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment