|
@@ -20,6 +20,7 @@ import org.apache.ibatis.session.SqlSessionFactory;
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
+import org.apache.poi.ss.usermodel.Table;
|
|
|
import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.jsoup.Jsoup;
|
|
@@ -82,6 +83,8 @@ import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.BigInteger;
|
|
|
+import java.math.MathContext;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.function.Function;
|
|
@@ -110,6 +113,8 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
private final InformationQueryClient informationQueryClient;
|
|
|
private final ContractClient contractClient;
|
|
|
private final ITableFileService tableFileService;
|
|
|
+ private final TableInfoMapper tableInfoMapper;
|
|
|
+ private final WbsFormElementMapper wbsFormElementMapper;
|
|
|
|
|
|
|
|
|
@Autowired
|
|
@@ -1657,17 +1662,87 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
sgTabMaps.put(s + "---" + wbsTreeContract.getPKeyId(), wbsTreeContract.getInitTableName());
|
|
|
}
|
|
|
}
|
|
|
+ //获取 CL08水准测量记录表(监理)的 实际标高、高程偏差 对应字段 m_20220928134702_1574999102784012288
|
|
|
+ String leveling = "CL08水准测量记录表(监理)";
|
|
|
+ String levelingTableName = "m_20220928134702_1574999102784012288";
|
|
|
+
|
|
|
+ String designedElevation = "设计标高";
|
|
|
+ //负值+0/1 正值-0/1
|
|
|
+ String heightDeviation = "高程偏差";
|
|
|
+ //设置标高 + (高度偏差 / 100)
|
|
|
+ String actualElevation = "实际标高";
|
|
|
+
|
|
|
+ //m_20220928134725_1574999197613031424
|
|
|
+ String planePosition = "CL10平面位置检测记录表(监理)";
|
|
|
+ String planePositionTableName = "m_20220928134725_1574999197613031424";
|
|
|
+
|
|
|
+ //负值+0/1 正值-0/1
|
|
|
+ String difference = "差值";
|
|
|
+ //差值X + 差值Y 的开平方
|
|
|
+ String deviation = "偏位";
|
|
|
+ //指定表单和指定字段
|
|
|
+ Map<String, Map<String, String>> dataMaps = new HashMap<>();
|
|
|
+
|
|
|
for (WbsTreeContract wbsTreeContract : jlTabSort) {
|
|
|
//监理表
|
|
|
String s = extractAlphameric(wbsTreeContract.getNodeName());
|
|
|
if (StringUtils.isNotEmpty(s)) {
|
|
|
jlTabMaps.put(s + "---" + wbsTreeContract.getPKeyId(), wbsTreeContract.getInitTableName());
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 如果是
|
|
|
+ * CL08水准测量记录表(监理)
|
|
|
+ * 1、“实际标高”不获取数据,改为计算得来,计算规则为:实际标高 = 设计标高 + (高程偏差 / 100)。其中高程偏差需带符号进行计算,特别是负号;
|
|
|
+ * 2、获取的【高程偏差】需要做随机加减(规则为:如果是负数则+0/1,如果是正数则-0/1)
|
|
|
+ * CL10平面位置检测记录表(监理)
|
|
|
+ * 1、“差值”的两列和“偏位”数据不获取
|
|
|
+ * 2、获取的【差值】两列 需要做随机加减(规则为:如果是负数则+0/1,如果是正数则-0/1)
|
|
|
+ * 3、“偏差”不获取数据,改为计算得来,计算规则为:(差值x的平方 + 差值y的平方)的和开平方,四舍五入保留整数。
|
|
|
+ */
|
|
|
+ HashMap<String, String> map = new HashMap<>();
|
|
|
+
|
|
|
+ //判断当前表单是否是CL08、CL10
|
|
|
+ if (levelingTableName.equals(wbsTreeContract.getInitTableName()) || planePositionTableName.equals(wbsTreeContract.getInitTableName())) {
|
|
|
+ TableInfo tableInfo = tableInfoMapper.selectOne(Wrappers.<TableInfo>lambdaQuery()
|
|
|
+ .eq(TableInfo::getTabEnName, wbsTreeContract.getInitTableName()));
|
|
|
+ List<WbsFormElement> wbsFormElements = wbsFormElementMapper.selectList(Wrappers.<WbsFormElement>lambdaQuery()
|
|
|
+ .eq(WbsFormElement::getFId, tableInfo.getId()));
|
|
|
+ for (WbsFormElement wbsFormElement : wbsFormElements) {
|
|
|
+ String eName = wbsFormElement.getEName();
|
|
|
+ if(eName.contains(designedElevation)){
|
|
|
+ //设置标高
|
|
|
+ map.put(designedElevation, wbsFormElement.getEKey());
|
|
|
+ }else if(eName.contains(heightDeviation)){
|
|
|
+ //高度偏差
|
|
|
+ map.put(heightDeviation, wbsFormElement.getEKey());
|
|
|
+ }else if(eName.contains(actualElevation)){
|
|
|
+ //实际标高
|
|
|
+ map.put(actualElevation, wbsFormElement.getEKey());
|
|
|
+ }else if(eName.contains(difference)){
|
|
|
+ //差值
|
|
|
+ if(eName.contains("X")){
|
|
|
+ map.put(difference + "X", wbsFormElement.getEKey());
|
|
|
+ }else if (eName.contains("Y")){
|
|
|
+ map.put(difference + "Y", wbsFormElement.getEKey());
|
|
|
+ }
|
|
|
+ }else if(eName.contains(deviation)){
|
|
|
+ //偏差
|
|
|
+ map.put(deviation, wbsFormElement.getEKey());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //存储
|
|
|
+ dataMaps.put(wbsTreeContract.getInitTableName(),map);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//构造表数据
|
|
|
List<InsertDataVO> resultData = new LinkedList<>();
|
|
|
- this.syncTabDataImpl(sgTabMaps, jlTabMaps, resultData);
|
|
|
+ //坐标
|
|
|
+ Map<String,Set<String>> coordinateMap = new HashMap<>();
|
|
|
+ this.syncTabDataImpl(sgTabMaps, jlTabMaps, resultData,coordinateMap);
|
|
|
|
|
|
//入库处理
|
|
|
if (resultData.size() > 0) {
|
|
@@ -1753,6 +1828,209 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
filedNames.add(vo.getName());
|
|
|
}*/
|
|
|
}
|
|
|
+
|
|
|
+ Map<String, String> stringStringMap = dataMaps.get(initTabName);
|
|
|
+
|
|
|
+ //CL08水准测量记录表(监理)
|
|
|
+ if(levelingTableName.equals(initTabName)){
|
|
|
+ //设计标高
|
|
|
+ String designedElevationNew = stringStringMap.get(designedElevation);
|
|
|
+ HashMap<Integer, BigDecimal> designedElevationNewMap = new HashMap<>();
|
|
|
+ //偏差
|
|
|
+ String heightDeviationNew = stringStringMap.get(heightDeviation);
|
|
|
+ HashMap<Integer, BigDecimal> heightDeviationNewMap = new HashMap<>();
|
|
|
+ //实际标高
|
|
|
+ String actualElevationNew = stringStringMap.get(actualElevation);
|
|
|
+
|
|
|
+ //记录数量
|
|
|
+ Integer rowMin = null;
|
|
|
+ Integer rowMax = null;
|
|
|
+
|
|
|
+ for (int i = 0; i < keys.size(); i++) {
|
|
|
+ if(!Objects.equals(keys.get(i),designedElevationNew) && !Objects.equals(keys.get(i),heightDeviationNew)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String value = values.get(i);
|
|
|
+ //拆分数据
|
|
|
+ String[] split1 = value.split("☆");
|
|
|
+
|
|
|
+ List<String> heightDeviationList = new ArrayList<>();
|
|
|
+ for (String s : split1) {
|
|
|
+ String[] split2 = s.split("_\\^_");
|
|
|
+ int rowNum = Integer.parseInt(split2[1].split("_")[0]);
|
|
|
+ //获取最大行数
|
|
|
+ if(rowMax == null){
|
|
|
+ rowMax = rowNum;
|
|
|
+ }else if(rowMax < rowNum){
|
|
|
+ rowMax = rowNum;
|
|
|
+ }
|
|
|
+ //获取最小行数
|
|
|
+ if(rowMin == null){
|
|
|
+ rowMin = rowNum;
|
|
|
+ }else if(rowMin > rowNum){
|
|
|
+ rowMin = rowNum;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (keys.get(i).equals(designedElevationNew)) {
|
|
|
+ //设计标高
|
|
|
+ designedElevationNewMap.put(rowNum, new BigDecimal(split2[0]));
|
|
|
+ } else if (keys.get(i).equals(heightDeviationNew)){
|
|
|
+ if(StringUtils.isNotEmpty(split2[0])){
|
|
|
+ double v = Double.parseDouble(split2[0]);
|
|
|
+ //随机+ - 0/1
|
|
|
+ Random random = new Random();
|
|
|
+ int adjustment = random.nextInt(2);
|
|
|
+ if(v > 0){
|
|
|
+ v = v - adjustment;
|
|
|
+ }else{
|
|
|
+ v = v + adjustment;
|
|
|
+ }
|
|
|
+
|
|
|
+ //高度偏差
|
|
|
+ heightDeviationNewMap.put(rowNum, BigDecimal.valueOf(v));
|
|
|
+
|
|
|
+ heightDeviationList.add(new BigDecimal(v).setScale(0,RoundingMode.HALF_UP).intValue() + "_^_"+ split2[1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //设置偏高的值
|
|
|
+ if(CollectionUtil.isNotEmpty(heightDeviationList)){
|
|
|
+ values.set(i, String.join("☆",heightDeviationList));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(rowMin==null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+
|
|
|
+ //获取当前key对应的坐标
|
|
|
+ Set<String> strings = coordinateMap.get(initTabName);
|
|
|
+ String index = null;
|
|
|
+ for (String string : strings) {
|
|
|
+ String[] split = string.split("__");
|
|
|
+ if(Objects.equals(split[0],actualElevationNew)){
|
|
|
+ index = split[1];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //按照最小行数来计算
|
|
|
+ for (int i = rowMin; i <= rowMax; i++) {
|
|
|
+ BigDecimal designed = designedElevationNewMap.get(i);
|
|
|
+ BigDecimal height = heightDeviationNewMap.get(i);
|
|
|
+
|
|
|
+ if(designed == null || height == null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ BigDecimal v = designed.add(height.divide(new BigDecimal(1000)));
|
|
|
+ //第5列,索引为4
|
|
|
+ list.add(v.doubleValue() + "_^_"+ i + "_" + index);
|
|
|
+ }
|
|
|
+ //未获取到当前key的坐标就不设置值
|
|
|
+ if(index == null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //设置实际标高的值
|
|
|
+ values.set(keys.indexOf(actualElevationNew), String.join("☆",list));
|
|
|
+ }else if(planePositionTableName.equals(initTabName)){
|
|
|
+ //CL10平面位置检测记录表(监理)
|
|
|
+ //差值
|
|
|
+ String differenceNewX = stringStringMap.get(difference + "X");
|
|
|
+ HashMap<Integer, BigDecimal> differenceNewXMap = new HashMap<>();
|
|
|
+
|
|
|
+ String differenceNewY = stringStringMap.get(difference + "Y");
|
|
|
+ HashMap<Integer, BigDecimal> differenceNewYMap = new HashMap<>();
|
|
|
+
|
|
|
+
|
|
|
+ String deviationNew = stringStringMap.get(deviation);
|
|
|
+ //记录数量
|
|
|
+ Integer rowMin = null;
|
|
|
+ Integer rowMax = null;
|
|
|
+ for (int i = 0; i < keys.size(); i++) {
|
|
|
+ if(!Objects.equals(keys.get(i),differenceNewX) && !Objects.equals(keys.get(i),differenceNewY)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ String value = values.get(i);
|
|
|
+ //拆分数据
|
|
|
+ String[] split1 = value.split("☆");
|
|
|
+
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+
|
|
|
+ for (String s : split1) {
|
|
|
+ String[] split2 = s.split("_\\^_");
|
|
|
+ int rowNum = Integer.parseInt(split2[1].split("_")[0]);
|
|
|
+ //获取最大行数
|
|
|
+ if(rowMax == null){
|
|
|
+ rowMax = rowNum;
|
|
|
+ }else if(rowMax < rowNum){
|
|
|
+ rowMax = rowNum;
|
|
|
+ }
|
|
|
+ //获取最小行数
|
|
|
+ if(rowMin == null){
|
|
|
+ rowMin = rowNum;
|
|
|
+ }else if(rowMin > rowNum){
|
|
|
+ rowMin = rowNum;
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(split2[0])){
|
|
|
+ Integer v = Integer.parseInt(split2[0]);
|
|
|
+ //随机+ - 0/1
|
|
|
+ Random random = new Random();
|
|
|
+ int adjustment = random.nextInt(2);
|
|
|
+ if(v > 0){
|
|
|
+ v = v - adjustment;
|
|
|
+ }else{
|
|
|
+ v = v + adjustment;
|
|
|
+ }
|
|
|
+ if (keys.get(i).equals(differenceNewX)) {
|
|
|
+ //偏差X
|
|
|
+ differenceNewXMap.put(rowNum, new BigDecimal(split2[0]));
|
|
|
+ } else if (keys.get(i).equals(differenceNewY)){
|
|
|
+ //偏差Y
|
|
|
+ differenceNewYMap.put(rowNum, BigDecimal.valueOf(v));
|
|
|
+ }
|
|
|
+ list.add(v + "_^_"+ split2[1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ values.set(i, String.join("☆",list));
|
|
|
+ }
|
|
|
+ if(rowMin==null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ //获取当前key对应的坐标
|
|
|
+ Set<String> strings = coordinateMap.get(initTabName);
|
|
|
+ String index = null;
|
|
|
+ for (String string : strings) {
|
|
|
+ String[] split = string.split("__");
|
|
|
+ if(Objects.equals(split[0],deviationNew)){
|
|
|
+ index = split[1];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //按照最小行数来计算
|
|
|
+ for (int i = rowMin; i <= rowMax; i++) {
|
|
|
+ BigDecimal x = differenceNewXMap.get(i);
|
|
|
+ BigDecimal y = differenceNewYMap.get(i);
|
|
|
+
|
|
|
+ if(x == null || y == null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ BigDecimal sqrt = sqrt(x.multiply(x).add(y.multiply(y)), 0);
|
|
|
+
|
|
|
+ //第9列,索引为8
|
|
|
+ list.add(sqrt.intValue() + "_^_"+ i + "_" + index);
|
|
|
+ }
|
|
|
+ //未获取到当前key的坐标就不设置值
|
|
|
+ if(index == null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //设置实际标高的值
|
|
|
+ values.set(keys.indexOf(deviationNew), String.join("☆",list));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
if (keys.size() > 0 && values.size() > 0 && keys.size() == values.size()) {
|
|
|
//alter SQL(扩容字段长度)
|
|
|
StringBuilder exStrBuilder = new StringBuilder();
|
|
@@ -1857,6 +2135,32 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 牛顿迭代法实现开平方
|
|
|
+ public BigDecimal sqrt(BigDecimal value, int precision) {
|
|
|
+ // 检查负数输入
|
|
|
+ if (value.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
+ throw new ArithmeticException("不能对负数开平方");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 精度设置(保留小数位 + 额外2位保证精度)
|
|
|
+ MathContext mc = new MathContext(precision + 2, RoundingMode.HALF_EVEN);
|
|
|
+
|
|
|
+ // 初始值 = value / 2
|
|
|
+ BigDecimal guess = value.divide(BigDecimal.valueOf(2), mc);
|
|
|
+ BigDecimal lastGuess;
|
|
|
+
|
|
|
+ // 牛顿迭代公式:xₙ₊₁ = (xₙ + value/xₙ)/2
|
|
|
+ do {
|
|
|
+ lastGuess = guess;
|
|
|
+ guess = value.divide(guess, mc).add(guess)
|
|
|
+ .divide(BigDecimal.valueOf(2), mc);
|
|
|
+ } while (guess.subtract(lastGuess).abs().compareTo(
|
|
|
+ BigDecimal.valueOf(1, precision + 1)) > 0); // 精度控制
|
|
|
+
|
|
|
+ // 返回最终结果(精确到指定小数位)
|
|
|
+ return guess.setScale(precision, RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 构造数据
|
|
|
*
|
|
@@ -1866,7 +2170,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
private void syncTabDataImpl
|
|
|
- (Map<String, String> sgData, Map<String, String> jlData, List<InsertDataVO> resultData) throws
|
|
|
+ (Map<String, String> sgData, Map<String, String> jlData, List<InsertDataVO> resultData, Map<String,Set<String>> coordinateMap) throws
|
|
|
Exception {
|
|
|
for (Map.Entry<String, String> sgTab : sgData.entrySet()) { //质检表
|
|
|
String[] split = sgTab.getKey().split("---");
|
|
@@ -1885,6 +2189,22 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
//表的代码名称相同,就复制数据,例如:G10=G10
|
|
|
if (nodeNameRe.equals(nodeNameReJL)) {
|
|
|
String htmlStringJL = this.getHtmlString(pKeyIdJL);
|
|
|
+
|
|
|
+ //解析html坐标,生成key与keyName的映射关系
|
|
|
+ if (StringUtils.isNotEmpty(htmlStringJL)) {
|
|
|
+ Document doc = Jsoup.parse(htmlStringJL);
|
|
|
+ Elements select = doc.select("[id]");
|
|
|
+ HashSet<String> strings = new HashSet<>();
|
|
|
+ for (Element element : select) {
|
|
|
+ String id = element.id();
|
|
|
+ String[] split1 = id.split("__");
|
|
|
+ String s = split1[1].split("_")[1];
|
|
|
+
|
|
|
+ strings.add(split1[0] + "__" + s);
|
|
|
+ }
|
|
|
+ coordinateMap.put(initTabNameJL, strings);
|
|
|
+ }
|
|
|
+
|
|
|
//获取质检实体表对应数据
|
|
|
List<Map<String, Object>> mapsList = jdbcTemplate.queryForList("select * from " + initTabName + " where p_key_id = " + pKeyId);
|
|
|
if (mapsList.size() > 0) {
|