From f6abc8c724eed706487b7616bc6c816e5db5c939 Mon Sep 17 00:00:00 2001
From: czt <czt18638530771@163.com>
Date: 星期二, 09 十二月 2025 20:13:48 +0800
Subject: [PATCH] 数量检测页面提交
---
fzzy-igdss-core/src/main/java/com/fzzy/igds/utils/GrainDataBuilder.java | 1090 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 1,090 insertions(+), 0 deletions(-)
diff --git a/fzzy-igdss-core/src/main/java/com/fzzy/igds/utils/GrainDataBuilder.java b/fzzy-igdss-core/src/main/java/com/fzzy/igds/utils/GrainDataBuilder.java
new file mode 100644
index 0000000..42a1d5f
--- /dev/null
+++ b/fzzy-igdss-core/src/main/java/com/fzzy/igds/utils/GrainDataBuilder.java
@@ -0,0 +1,1090 @@
+package com.fzzy.igds.utils;
+
+import com.alibaba.fastjson.JSONObject;
+import com.fzzy.igds.constant.Constant;
+import com.fzzy.igds.constant.DepotType;
+import com.fzzy.igds.data.*;
+import com.fzzy.igds.domain.DepotConf;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import java.util.*;
+
+/**
+ * @Description 绮儏鏁版嵁鍚勪釜绫诲瀷鐨勮浆鎹㈡帶鍒�
+ * @Author CZT
+ * @Date 2025/12/9 10:19
+ */
+@Slf4j
+public class GrainDataBuilder {
+
+ /**
+ * @param report
+ * @param conf 娉ㄦ剰褰撳墠鍙傛暟鍙槸涓轰簡鑾峰彇鍏跺叏灞�閰嶇疆鍙傛暟锛屼笉鑰冭檻鏄惁涓庡綋鍓嶇伯鎯呬俊鎭槸鍚﹀尮閰�
+ * @return
+ */
+ public static GrainDataReport updateReport(GrainDataReport report, DepotConf conf) {
+ // 鏍规嵁浠撳簱绫诲瀷涓嶅悓杩涜涓嶅悓璋冩暣
+ if (DepotType.TYPE_02.getCode().equals(report.getDepotType())) {// 娴呭渾浠�
+ buildLays2(report, conf);
+ } else if (DepotType.TYPE_03.getCode().equals(report.getDepotType())) {
+ buildLays2(report, conf);
+ } else if (DepotType.TYPE_04.getCode().equals(report.getDepotType())) {
+ buildLays2(report, conf);
+ } else {
+ buildLays(report);
+ }
+
+ report.setPoints(null);
+ return report;
+ }
+
+ /**
+ * 鏍规嵁鍗曚釜绮儏鐨勬暟鎹俊鎭紝鍖呮嫭閲囬泦鐐瑰拰灞備俊鎭�
+ *
+ * @param result
+ * @param depotConf
+ * @param depotType
+ */
+ public static void updateGrainData(GrainData result, DepotConf depotConf, String depotType) {
+
+ if (null == depotType || null == depotConf) {
+ return;
+ }
+
+ List<GrainPoint> listPoints = new ArrayList<>();
+ List<GrainLay> listLays = new ArrayList<>();
+ List<GrainRow> listRows = new ArrayList<>();
+
+ // 鏍规嵁浠撳簱绫诲瀷涓嶅悓杩涜涓嶅悓璋冩暣
+ if (DepotType.TYPE_02.getCode().equals(depotType)) {// 娴呭渾浠�
+ result = buildLLaysAndRows2(listPoints, listLays, listRows, result, depotConf);
+
+ } else if (DepotType.TYPE_03.getCode().equals(depotType)) {
+
+ result = buildLLaysAndRows3(listPoints, listLays, listRows, result, depotConf);
+
+ } else if (DepotType.TYPE_04.getCode().equals(depotType)) {
+ result = buildLLaysAndRows2(listPoints, listLays, listRows, result, depotConf);
+
+ } else {
+ result = buildLLaysAndRows1(listPoints, listLays, listRows, result, depotConf);
+ }
+
+ result.setListLays(listLays);
+ result.setListRows(listRows);
+ result.setListPoints(listPoints);
+
+ log.debug("---------{}", JSONObject.toJSONString(result));
+ }
+
+ /**
+ * 骞虫柟浠� 璺熸柊灞傛暟鎹拰琛屾暟鎹�
+ *
+ * @param listPoints
+ * @param listLays
+ * @param listRows
+ * @param result
+ * @param depotConf
+ * @return
+ */
+ public static GrainData buildLLaysAndRows1(List<GrainPoint> listPoints,
+ List<GrainLay> listLays, List<GrainRow> listRows,
+ GrainData result, DepotConf depotConf) {
+
+ String points = result.getPoints();
+ String cable = result.getCable();
+ // 鑾峰彇甯冪嚎瑙勫垯
+ if (StringUtils.isEmpty(cable)) {
+ return result;
+ }
+ if (StringUtils.isEmpty(points)) {
+ return result;
+ }
+
+ String[] attr = cable.split("-");
+ int cableZ = Integer.valueOf(attr[0]);
+ int cableY = Integer.valueOf(attr[1]);
+ int cableX = Integer.valueOf(attr[2]);
+
+ // 鏍规嵁灞傛洿鏂板眰鍒楄〃淇℃伅
+ updateListLays(listLays, cableX, cableY, cableZ);
+
+ // 鏇存柊琛屾暟鎹殑鍒楄〃
+ updateListRows(listRows, cableX, cableY, cableZ);
+
+ attr = points.split(",");
+
+ GrainPoint point;
+ Double tempT;
+ GrainLay lay;
+ GrainRow row;
+ List<Integer> listErrorTag = new ArrayList<>();// 鏁呴殰鎴栬�呴敊璇殑鐐�
+ Double sumAll = 0.0;
+
+ Double sumAllTemp = 0.0;
+
+ int sumAllNum = 0;
+ int tempT2;
+ int x = 0, y = 0, z = 0, fz = 0;
+ for (int i = 0; i < attr.length; i++) {
+ z = i % cableZ;
+ fz = z + 1;
+ x = i / (cableZ * cableY);
+ y = x * (cableZ * cableY);
+ y = (i - y) / cableZ;
+
+ // 鍊掕浆X杞�
+ x = cableX - 1 - x;
+
+ tempT = Double.valueOf(attr[i]);
+ point = new GrainPoint(tempT, x, y, z, fz);
+
+ // 缁熻姣忓眰鏁版嵁 --鍒濆鍖栨暟鎹�
+ lay = listLays.get(z);
+
+ // 寮�濮嬪皝瑁呰鏁版嵁淇℃伅
+ row = listRows.get(y);
+
+ if (tempT <= Constant.ERROR_TEMP) {
+ listErrorTag.add(i);
+
+ lay.setSumNum(lay.getSumNum() - 1);
+
+ row.setSumNum(row.getSumNum() - 1);
+
+ if (x == (cableX - 1) || y == (cableY - 1) || x == 0 || y == 0) {
+ lay.setSumOutNum(lay.getSumOutNum() - 1);
+ } else {
+ lay.setSumInNum(lay.getSumInNum() - 1);
+ }
+ } else {
+ sumAllTemp += tempT;
+ // 楂樻俯浼樺寲鐨勫惎鐢ㄨ姹�1-澶勭悊鍗曚釜楂樻俯鐐�
+ if (null != depotConf
+ && null != depotConf.getTempMax()
+ && Constant.YN_Y.equals(depotConf.getGrainAuto())) {
+
+ if (tempT > depotConf.getTempMax()) {
+ tempT2 = (int) (tempT - depotConf.getTempMax()) + 1;
+ tempT = NumberUtil.keepPrecision(tempT - tempT2, 1);
+ result.setRemark("绮俯妫�娴嬫甯�");
+ log.debug("--鍘熷��={},--宸��={},--缁撴灉={}", point.getTemp(),
+ tempT2, tempT);
+ }
+ if (result.getTempMax() > depotConf.getTempMax()) {
+ tempT2 = (int) (result.getTempMax() - depotConf
+ .getTempMax()) + 1;
+ result.setTempMax(NumberUtil.keepPrecision(
+ result.getTempMax() - tempT2, 1));
+ }
+ if (tempT > result.getTempMax()) {
+ result.setTempMax(tempT);
+ }
+ }
+
+ // 灞傝鍒楄ˉ鍏�
+ lay.setSumTemp(lay.getSumTemp() + tempT);
+ lay.setSumTemp(NumberUtil.keepPrecision(lay.getSumTemp(), 1));
+
+ row.setSumTemp(row.getSumTemp() + tempT);
+ row.setSumTemp(NumberUtil.keepPrecision(row.getSumTemp(), 1));
+
+ if (x == (cableX - 1) || y == (cableY - 1) || x == 0 || y == 0) {
+ lay.setSumOutTemp(lay.getSumOutTemp() + tempT);
+ } else {
+ lay.setSumInTemp(lay.getSumInTemp() + tempT);
+ }
+
+ // 灞傛渶楂樻渶浣�
+ if (tempT > lay.getTempMax()) {
+ lay.setTempMax(tempT);
+ }
+ if (tempT < lay.getTempMin()) {
+ lay.setTempMin(tempT);
+ }
+
+ // 琛屾渶楂樻渶浣�
+ if (tempT > row.getTempMax()) {
+ row.setTempMax(tempT);
+ }
+ if (tempT < row.getTempMin()) {
+ row.setTempMin(tempT);
+ }
+
+ // log.info("----娓╁害鐐�={}",tempT);
+ sumAll += tempT;
+ sumAllNum = sumAllNum + 1;
+ point.setTemp(tempT);
+ }
+ point.setTemp(NumberUtil.keepPrecision(point.getTemp(), 1));
+ listPoints.add(point);
+ }
+
+ // 璋冩暣灞備俊鎭�
+ for (GrainLay detail : listLays) {
+ if (0 != detail.getSumNum()) {
+ detail.setTempAve(detail.getSumTemp() / detail.getSumNum());
+ detail.setTempAve(NumberUtil.keepPrecision(detail.getTempAve(),
+ 1));
+ }
+
+ if (0 != detail.getSumInNum()) {
+ detail.setTempAveIn(detail.getSumInTemp()
+ / detail.getSumInNum());
+ detail.setTempAveIn(NumberUtil.keepPrecision(
+ detail.getTempAveIn(), 1));
+ }
+
+ if (0 != detail.getSumOutNum()) {
+ detail.setTempAveOut(detail.getSumOutTemp()
+ / detail.getSumOutNum());
+ detail.setTempAveOut(NumberUtil.keepPrecision(
+ detail.getTempAveOut(), 1));
+ }
+ //杩囨护鎺夋瘮杈冪殑鏈�澶ф渶灏忕殑鍊�50鍜�-50
+ if (detail.getTempMax() == -50) {
+ detail.setTempMax(0.0);
+ }
+ if (detail.getTempMin() == 50) {
+ detail.setTempMin(0.0);
+ }
+ }
+
+ // 璋冩暣琛屼俊鎭�
+ for (GrainRow detail : listRows) {
+ if (0 != detail.getSumNum()) {
+ detail.setTempAve(detail.getSumTemp() / detail.getSumNum());
+ detail.setTempAve(NumberUtil.keepPrecision(detail.getTempAve(),
+ 1));
+ }
+ //杩囨护鎺夋瘮杈冪殑鏈�澶ф渶灏忕殑鍊�50鍜�-50
+ if (detail.getTempMax() == -50) {
+ detail.setTempMax(0.0);
+ }
+ if (detail.getTempMin() == 50) {
+ detail.setTempMin(0.0);
+ }
+ }
+ Random random = new Random();
+ Double randomValue;
+ if (null != depotConf && Constant.YN_Y.equals(depotConf.getGrainAuto())) {
+ if (listErrorTag.size() > 0) {
+ for (Integer integer : listErrorTag) {
+ point = listPoints.get(integer);
+ // 鑾峰彇褰撳墠灞傜殑淇℃伅
+ lay = listLays.get(point.getZ());
+ randomValue = lay.getTempMin() + (lay.getTempMax() - lay.getTempMin()) * random.nextDouble();
+ point.setTemp(NumberUtil.keepPrecision(randomValue, 1));
+ attr[integer] = NumberUtil.keepPrecision(randomValue, 1) + "";
+ listPoints.set(integer, point);
+ }
+ }
+
+ }
+
+ if (null != depotConf && Constant.YN_Y.equals(depotConf.getGrainAuto())) {
+ {
+ log.debug("---鍘熷钩鍧�={},鍚庢�绘俯={},--鍚庢�讳釜鏁�={},鍚庡钩鍧�={},鍘熸�绘俯={}",
+ result.getTempAve(), sumAll, sumAllNum, sumAll / sumAllNum,
+ sumAllTemp);
+ result.setTempAve(NumberUtil.keepPrecision((sumAll / sumAllNum), 1));
+ }
+ }
+
+ result.setPoints(StringUtils.join(attr, ","));
+ return result;
+ }
+
+ /**
+ * 鍦嗙瓛浠� 鏇存柊灞曠ず鏁堟灉鏁版嵁
+ *
+ * @param listPoints
+ * @param listLays
+ * @param listRows
+ * @param result
+ * @param depotConf
+ * @return
+ */
+ private static GrainData buildLLaysAndRows2(List<GrainPoint> listPoints,
+ List<GrainLay> listLays, List<GrainRow> listRows,
+ GrainData result, DepotConf depotConf) {
+
+ String points = result.getPoints();
+ String cableRule = result.getCable();
+ String cableCir = result.getCableCir();
+
+ if (StringUtils.isEmpty(points)) {
+ return result;
+ }
+
+ // 鑾峰彇甯冪嚎瑙勫垯
+ if (StringUtils.isEmpty(cableRule) || StringUtils.isEmpty(cableCir)) {
+ return result;
+ }
+ // 姣忎竴鍦堝垪鏁�
+ String[] cableRuleAtt = result.getCable().split("-");
+ // 姣忎竴鍦堝眰鏁�
+ String[] cableCirAtt = result.getCableCir().split("-");
+
+ if (cableRuleAtt.length != cableCirAtt.length) {
+ log.error("褰撳墠浠撳簱锛歿}锛屽竷绾胯鍒欎笉姝g‘锛屾棤娉曡В鏋愮伯鎯呬俊鎭�︹��", depotConf.getDepotId());
+ return result;
+ }
+
+ // 鑾峰彇鏈�澶х殑灞傞厤缃�--榛樿姣忎竴鍦堥兘涓�鏍�
+ int layMax = Integer.valueOf(cableCirAtt[0]);
+ for (int i = 0; i < cableCirAtt.length; i++) {
+ if (Integer.valueOf(cableCirAtt[i]) >= layMax) layMax = Integer.valueOf(cableCirAtt[i]);
+ }
+ if (null == depotConf.getCableCone() || depotConf.getCableCone().isEmpty()) {
+ depotConf.setCableCone(Constant.CABLE_CONE_0);
+ }
+
+ // 鏍规嵁灞傛洿鏂板眰鍒楄〃淇℃伅
+ updateListLaysCir(listLays, cableRuleAtt, cableCirAtt, layMax, depotConf.getCableCone());
+
+ String[] attr = points.split(",");
+
+ GrainPoint point;
+ Double tempT;
+ GrainLay lay;
+ int x = 0, y = 0, z = 1, fz = 0;// x=鎵�鍦ㄥ湀锛屼粠0寮�濮嬶紱y浠h〃鐢电紗鏍瑰彿浠�0寮�濮嬶紝z=浠h〃鎵�鍦ㄥ眰浠�1寮�濮�
+ List<Integer> listErrorTag = new ArrayList<>();// 鏁呴殰鎴栬�呴敊璇殑鐐�
+ List<Integer> listHighTag = new ArrayList<>();// 楂樻俯鐐�
+
+ int layNum = layMax;// 褰撳墠鍦堢殑灞傛暟
+ int rowNum = 1;// 褰撳墠鍦堢殑鏍规暟
+ int index = 0;// 褰撳墠娓╁害鐐圭殑浣嶇疆
+ int startRow = 0;//褰撳墠绮儏鐢电紗鏍瑰彿
+ for (int i = 0; i < cableRuleAtt.length; i++) {
+ x = i;
+ rowNum = Integer.valueOf(cableRuleAtt[i]);// 鏍规暟
+ for (int k = 0; k < rowNum; k++) {
+ y = k;
+ for (int j = 0; j < layNum; j++) {
+ z = j;
+ fz = j + 1;
+ tempT = Double.valueOf(attr[index]);
+ index++;
+
+ point = new GrainPoint(tempT, x, startRow, z, fz);
+
+ // 缁熻姣忓眰鏁版嵁 --鍒濆鍖栨暟鎹�
+ lay = listLays.get(z);
+ point.setTemp(tempT);
+ listPoints.add(point);
+
+ if (tempT <= Constant.ERROR_TEMP) {
+ if (tempT != Constant.ADD_TEMP) {
+ lay.setSumNum(lay.getSumNum() - 1);
+ }
+ } else {
+
+ //鍒ゆ柇鏄惁楂樻俯浼樺寲
+ if (null != depotConf
+ && null != depotConf.getTempMax()
+ && Constant.YN_Y.equals(depotConf.getGrainAuto())) {
+ if (tempT > depotConf.getTempMax()) {
+ //璁板綍楂樻俯鐐圭殑浣嶇疆
+ listHighTag.add(listPoints.size() - 1);
+ } else {
+ lay.setSumTemp(lay.getSumTemp() + tempT);
+ // 灞傛渶楂樻渶浣�
+ if (tempT > lay.getTempMax()) {
+ lay.setTempMax(tempT);
+ }
+ if (tempT < lay.getTempMin()) {
+ lay.setTempMin(tempT);
+ }
+ }
+ } else {
+ lay.setSumTemp(lay.getSumTemp() + tempT);
+ // 灞傛渶楂樻渶浣�
+ if (tempT > lay.getTempMax()) {
+ lay.setTempMax(tempT);
+ }
+ if (tempT < lay.getTempMin()) {
+ lay.setTempMin(tempT);
+ }
+ }
+ }
+ if (tempT == Constant.ERROR_TEMP || tempT == Constant.FAULT_TEMP) {
+ listErrorTag.add(listPoints.size() - 1);
+ }
+ }
+
+ startRow++;
+ }
+
+ }
+
+ Double maxTemp = -50.0; //姣旇緝鏈�楂樻俯
+ // 璋冩暣灞備俊鎭�
+ for (GrainLay detail : listLays) {
+ if (0 != detail.getSumNum()) {
+ detail.setTempAve(detail.getSumTemp() / detail.getSumNum());
+ detail.setTempAve(NumberUtil.keepPrecision(detail.getTempAve(),
+ 1));
+ }
+
+ if (0 != detail.getSumInNum()) {
+ detail.setTempAveIn(detail.getSumInTemp()
+ / detail.getSumInNum());
+ detail.setTempAveIn(NumberUtil.keepPrecision(
+ detail.getTempAveIn(), 1));
+ }
+
+ if (0 != detail.getSumOutNum()) {
+ detail.setTempAveOut(detail.getSumOutTemp()
+ / detail.getSumOutNum());
+ detail.setTempAveOut(NumberUtil.keepPrecision(
+ detail.getTempAveOut(), 1));
+ }
+ //杩囨护鎺夋瘮杈冪殑鏈�澶ф渶灏忕殑鍊�50鍜�-50
+ if (detail.getTempMax() == -50) {
+ detail.setTempMax(0.0);
+ }
+ if (detail.getTempMin() == 50) {
+ detail.setTempMin(0.0);
+ }
+ if (listHighTag.size() > 0) {
+ if (detail.getTempMax() > maxTemp) {
+ maxTemp = detail.getTempMax();
+ }
+ }
+ }
+ Random random = new Random();
+ Double randomValue;
+ //楂樻俯鐐规浛鎹负灞傚钩鍧囧��
+ if (null != depotConf && Constant.YN_Y.equals(depotConf.getGrainAuto())) {
+ if (listHighTag.size() > 0) {
+ for (Integer integer : listHighTag) {
+ point = listPoints.get(integer);
+ // 鑾峰彇褰撳墠灞傜殑淇℃伅
+ lay = listLays.get(point.getZ());
+ randomValue = lay.getTempMin() + (lay.getTempMax() - lay.getTempMin()) * random.nextDouble();
+ point.setTemp(NumberUtil.keepPrecision(randomValue, 1));
+ attr[integer] = NumberUtil.keepPrecision(randomValue, 1) + "";
+ listPoints.set(integer, point);
+ }
+ //璁剧疆鏈�楂樻俯
+ result.setTempMax(maxTemp);
+ }
+ }
+ // 鏈�鍚庢牴鎹叏灞�鍙傛暟鍒ゆ柇鏄惁闇�瑕佽皟鏁村紓甯哥偣鏁版嵁杩涜璋冩暣
+ if (null != depotConf && Constant.YN_Y.equals(depotConf.getGrainAuto())) {
+ if (listErrorTag.size() > 0) {
+ for (Integer integer : listErrorTag) {
+ point = listPoints.get(integer);
+ // 鑾峰彇褰撳墠灞傜殑淇℃伅
+ lay = listLays.get(point.getZ());
+ point.setTemp(lay.getTempAve());
+
+ listPoints.set(integer, point);
+ }
+ }
+ }
+
+ result.setListPoints(listPoints);
+ result.setListLays(listLays);
+ result.setPoints(StringUtils.join(attr, ","));
+ return result;
+ }
+
+
+ /**
+ * 娌圭瓛浠撹В鏋愶紝鏇存柊灞曠ず鏁堟灉鏁版嵁锛岃В鏋愭柟寮忓悓鏅�氱瓛浠撲俊鎭�
+ *
+ * @param listPoints
+ * @param listLays
+ * @param listRows
+ * @param result
+ * @param depotConf
+ * @return
+ */
+ private static GrainData buildLLaysAndRows3(List<GrainPoint> listPoints,
+ List<GrainLay> listLays, List<GrainRow> listRows,
+ GrainData result, DepotConf depotConf) {
+ if (StringUtils.isEmpty(result.getOilHeight())) {
+ result.setOilHeight("0.0-0.0");
+ log.warn("娌规《浠�={} 瑙f瀽杩囩▼涓病鏈夎幏鍙栧埌娌归潰楂樺害淇℃伅锛岄粯璁ゆ樉绀轰负0", depotConf.getDepotId());
+ } else {
+ if (result.getOilHeight().indexOf("-") == -1) {
+ result.setOilHeight(result.getOilHeight() + "-"
+ + result.getOilHeight());
+ log.warn("娌规《浠�={} 瑙f瀽涓病鏈夎幏鍙栧缓绛戠墿鐨勯珮搴︿俊鎭紝榛樿寤虹瓚鐗╅珮搴︾瓑浜庢恫浣嶉珮搴�",
+ depotConf.getDepotId());
+ }
+ }
+
+ return buildLLaysAndRows2(listPoints, listLays, listRows, result, depotConf);
+ }
+
+ /**
+ * @param listLays
+ * @param cableX
+ * @param cableY
+ * @param cableZ
+ */
+ private static void updateListLays(List<GrainLay> listLays, int cableX,
+ int cableY, int cableZ) {// 灞備粠1寮�濮�
+ GrainLay lay;
+ for (int i = 1; i <= cableZ; i++) {
+ lay = new GrainLay(i, i - 1);
+ lay.setSumNum(cableY * cableX);
+ lay.setSumInNum((cableY - 2) * (cableX - 2));
+ lay.setSumOutNum(2 * cableY + 2 * cableX - 4);
+ lay.setTempMin(50.0);
+ lay.setTempMax(-50.0);
+ listLays.add(lay);
+ }
+ }
+
+ /**
+ * @param listRows
+ * @param cableX
+ * @param cableY
+ * @param cableZ
+ */
+ private static void updateListRows(List<GrainRow> listRows, int cableX,
+ int cableY, int cableZ) {// 浠�0寮�濮�
+ GrainRow row;
+ for (int i = 0; i < cableY; i++) {
+ row = new GrainRow(i);
+ row.setSumNum(cableZ * cableX);
+ row.setTempMin(50.0);
+ row.setTempMax(-50.0);
+ listRows.add(row);
+ }
+ }
+
+ /**
+ * 鍦嗙瓛浠�--浠撴俯搴﹁В鏋�
+ *
+ * @param listLays
+ * @param cableRuleAtt
+ * @param cableCirAtt
+ * @param layMax
+ * @param cableCone
+ */
+ private static void updateListLaysCir(List<GrainLay> listLays,
+ String[] cableRuleAtt, String[] cableCirAtt, int layMax, String cableCone) {
+ GrainLay lay;
+
+ Map<String, GrainLay> layMap = new HashMap<>();
+ for (int j = 0; j < cableRuleAtt.length; j++) {
+
+ for (int i = 1; i <= layMax; i++) {
+ if (layMap.containsKey(i + "")) {
+ lay = layMap.get(i + "");
+ } else {
+ lay = new GrainLay(i, i);
+ }
+ int sumNum = lay.getSumNum();
+
+ if (cableCone.equals(Constant.CABLE_CONE_2)) {
+ if (Integer.parseInt(cableCirAtt[j]) >= i) {
+ sumNum += Integer.parseInt(cableRuleAtt[j]);
+ }
+ } else {
+ if (layMax - Integer.parseInt(cableCirAtt[j]) < i) {
+ sumNum += Integer.parseInt(cableRuleAtt[j]);
+ }
+ }
+ lay.setSumNum(sumNum);
+ lay.setSumInNum(1);
+ lay.setSumOutNum(1);
+ lay.setTempMin(50.0);
+ lay.setTempMax(-50.0);
+ layMap.put(i + "", lay);
+ }
+ }
+ for (int i = 1; i <= layMax; i++) {
+ listLays.add(layMap.get(i + ""));
+ }
+ }
+
+ /**
+ * 鍦嗙瓛浠�--浠撴俯搴﹁В鏋�
+ *
+ * @param listLays
+ * @param cableRuleAtt
+ * @param cableCirAtt
+ * @param layMax
+ */
+ private static void updateListLaysCir(List<GrainLay> listLays,
+ String[] cableRuleAtt, String[] cableCirAtt, int layMax) {
+ GrainLay lay;
+ for (int i = 1; i <= layMax; i++) {
+ lay = new GrainLay(i, i);
+ int sumNum = 0;
+
+ for (int j = 0; j < cableRuleAtt.length; j++) {
+ if (Integer.valueOf(cableCirAtt[j]) >= i) {
+ sumNum += Integer.valueOf(cableRuleAtt[j]);
+ }
+ }
+
+ lay.setSumNum(sumNum);
+ lay.setSumInNum(1);
+ lay.setSumOutNum(1);
+ lay.setTempMin(50.0);
+ lay.setTempMax(-50.0);
+ listLays.add(lay);
+ }
+ }
+
+ /**
+ * 鏍规嵁绮儏娓╁害锛屽垽鏂槸鍚﹁鍛婂�硷紝鐒跺悗杞崲涓洪〉闈㈤渶瑕佹覆鏌撶殑鍊硷紝涓昏澶囩敤鍜屾晠闅滅殑鍊肩殑璋冩暣
+ *
+ * @param temp
+ * @return
+ */
+ public static String renderTempValue(Double temp) {
+
+
+ if (temp > 45) return "鏁呴殰";
+
+ if (temp == Constant.ERROR_TEMP) return "澶囩敤";
+ if (temp == Constant.FAULT_TEMP) return "鏁呴殰";
+ if (temp == Constant.ADD_TEMP) return "--";
+
+ return temp + "";
+ }
+
+ /**
+ * 绛掍粨鎶ヨ〃鏁版嵁灏佽
+ *
+ * @param result
+ * @param depotConf
+ */
+ private static void buildLays2(GrainDataReport result, DepotConf depotConf) {
+
+ String points = result.getPoints();
+ String cableRule = result.getCable();
+ String cableCir = result.getCableCir();
+ // 鑾峰彇甯冪嚎瑙勫垯
+ if (StringUtils.isEmpty(cableRule) || StringUtils.isEmpty(cableCir)) {
+ return;
+ }
+ if (StringUtils.isEmpty(points)) {
+ return;
+ }
+
+ // 姣忎竴鍦堝垪鏁�
+ String[] cableRuleAtt = result.getCable().split("-");
+ // 姣忎竴鍦堝眰鏁�
+ String[] cableCirAtt = result.getCableCir().split("-");
+
+ if (cableRuleAtt.length != cableCirAtt.length) {
+ return;
+ }
+
+ // 鑾峰彇鏈�澶х殑灞傞厤缃�--榛樿姣忎竴鍦堥兘涓�鏍�
+ int layMax = Integer.valueOf(cableCirAtt[0]);
+ for (int i = 0; i < cableCirAtt.length; i++) {
+ if (Integer.valueOf(cableCirAtt[i]) >= layMax) layMax = Integer.valueOf(cableCirAtt[i]);
+ }
+ result.setMaxZ(layMax);
+ List<GrainLay> listLays = new ArrayList<>();// 灞傛暟鎹�
+ List<GrainPoint> listPoints = new ArrayList<>();
+ // 鏍规嵁灞傛洿鏂板眰鍒楄〃淇℃伅
+ updateListLaysCir(listLays, cableRuleAtt, cableCirAtt, layMax);
+
+ String[] attr = points.split(",");
+
+ GrainPoint point;
+ Double tempT;
+ GrainLay lay;
+ int x = 0, y = 0, z = 1, fz = 0;// x=鎵�鍦ㄥ湀锛屼粠0寮�濮嬶紱y浠h〃鐢电紗鏍瑰彿浠�0寮�濮嬶紝z=浠h〃鎵�鍦ㄥ眰浠�1寮�濮�
+ List<Integer> listErrorTag = new ArrayList<>();// 鏁呴殰鎴栬�呴敊璇殑鐐�
+ List<Integer> listHighTag = new ArrayList<>();// 楂樻俯鐐�
+
+ int layNum = layMax;// 褰撳墠鍦堢殑灞傛暟
+ int rowNum = 1;// 褰撳墠鍦堢殑鏍规暟
+ int index = 0;// 褰撳墠娓╁害鐐圭殑浣嶇疆
+ int startRow = 0;//褰撳墠绮儏鐢电紗鏍瑰彿
+ for (int i = 0; i < cableRuleAtt.length; i++) {
+ x = i;
+ rowNum = Integer.valueOf(cableRuleAtt[i]);// 鏍规暟
+ for (int k = 0; k < rowNum; k++) {
+ y = k;
+ for (int j = 0; j < layNum; j++) {
+ z = j;
+ fz = j + 1;
+ tempT = Double.valueOf(attr[index]);
+ index++;
+
+ point = new GrainPoint(tempT, x, startRow, z, fz);
+
+ // 缁熻姣忓眰鏁版嵁 --鍒濆鍖栨暟鎹�
+ lay = listLays.get(z);
+ point.setTemp(tempT);
+ listPoints.add(point);
+
+ if (tempT <= Constant.ERROR_TEMP) {
+ if (tempT != Constant.ADD_TEMP) {
+ lay.setSumNum(lay.getSumNum() - 1);
+ }
+ } else {
+ //鍒ゆ柇鏄惁楂樻俯浼樺寲
+ if (null != depotConf && Constant.YN_Y.equals(depotConf.getGrainAuto())) {
+
+ lay.setSumTemp(lay.getSumTemp() + tempT);
+ // 灞傛渶楂樻渶浣�
+ if (tempT > lay.getTempMax()) {
+ lay.setTempMax(tempT);
+ }
+ if (tempT < lay.getTempMin()) {
+ lay.setTempMin(tempT);
+ }
+
+ } else {
+ lay.setSumTemp(lay.getSumTemp() + tempT);
+ // 灞傛渶楂樻渶浣�
+ if (tempT > lay.getTempMax()) {
+ lay.setTempMax(tempT);
+ }
+ if (tempT < lay.getTempMin()) {
+ lay.setTempMin(tempT);
+ }
+ }
+ }
+ if (tempT == Constant.ERROR_TEMP || tempT == Constant.FAULT_TEMP) {
+ listErrorTag.add(listPoints.size() - 1);
+ }
+ }
+
+ startRow++;
+ }
+
+ }
+
+ Double maxTemp = -50.0; //姣旇緝鏈�楂樻俯
+ // 璋冩暣灞備俊鎭�
+ for (GrainLay detail : listLays) {
+ if (0 != detail.getSumNum()) {
+ detail.setTempAve(detail.getSumTemp() / detail.getSumNum());
+ detail.setTempAve(NumberUtil.keepPrecision(detail.getTempAve(),
+ 1));
+ }
+
+ if (0 != detail.getSumInNum()) {
+ detail.setTempAveIn(detail.getSumInTemp()
+ / detail.getSumInNum());
+ detail.setTempAveIn(NumberUtil.keepPrecision(
+ detail.getTempAveIn(), 1));
+ }
+
+ if (0 != detail.getSumOutNum()) {
+ detail.setTempAveOut(detail.getSumOutTemp()
+ / detail.getSumOutNum());
+ detail.setTempAveOut(NumberUtil.keepPrecision(
+ detail.getTempAveOut(), 1));
+ }
+ //杩囨护鎺夋瘮杈冪殑鏈�澶ф渶灏忕殑鍊�50鍜�-50
+ if (detail.getTempMax() == -50) {
+ detail.setTempMax(0.0);
+ }
+ if (detail.getTempMin() == 50) {
+ detail.setTempMin(0.0);
+ }
+ if (listHighTag.size() > 0) {
+ if (detail.getTempMax() > maxTemp) {
+ maxTemp = detail.getTempMax();
+ }
+ }
+ // 灏嗗眰鏁版嵁杞崲涓鸿鏁版嵁
+ updateReportLayInfo(result, detail);
+ }
+ }
+
+ private static void buildLays(GrainDataReport report) {
+ String points = report.getPoints();
+ String cable = report.getCable();
+ // 鑾峰彇甯冪嚎瑙勫垯
+ if (StringUtils.isEmpty(cable)) {
+ return;
+ }
+ if (StringUtils.isEmpty(points)) {
+ return;
+ }
+
+ String[] attr = cable.split("-");
+ int cableZ = Integer.valueOf(attr[0]);
+ int cableY = Integer.valueOf(attr[1]);
+ int cableX = Integer.valueOf(attr[2]);
+ report.setMaxZ(cableZ);
+ List<GrainPoint> listPoints = new ArrayList<GrainPoint>();
+ List<GrainLay> listLays = initDetail(cableX, cableY, cableZ);
+
+ attr = points.split(",");
+
+ GrainPoint point;
+ Double tempT;
+ GrainLay lay;
+ List<Integer> listErrorTag = new ArrayList<>();// 鏁呴殰鎴栬�呴敊璇殑鐐�
+ Double sumAll = 0.0;
+
+ Double sumAllTemp = 0.0;
+
+ int sumAllNum = 0;
+ int x = 0, y = 0, z = 0, fz = 0;
+ for (int i = 0; i < attr.length; i++) {
+ z = i % cableZ;
+ fz = z + 1;
+ x = i / (cableZ * cableY);
+ y = x * (cableZ * cableY);
+ y = (i - y) / cableZ;
+
+ // 鍊掕浆X杞�
+ x = cableX - 1 - x;
+
+ tempT = Double.valueOf(attr[i]);
+ point = new GrainPoint(tempT, x, y, z, fz);
+
+ // 缁熻姣忓眰鏁版嵁 --鍒濆鍖栨暟鎹�
+ lay = listLays.get(z);
+
+ if (tempT <= Constant.ERROR_TEMP) {
+ listErrorTag.add(i);
+
+ lay.setSumNum(lay.getSumNum() - 1);
+
+ if (x == (cableX - 1) || y == (cableY - 1) || x == 0 || y == 0) {
+ lay.setSumOutNum(lay.getSumOutNum() - 1);
+ } else {
+ lay.setSumInNum(lay.getSumInNum() - 1);
+ }
+ } else {
+ sumAllTemp += tempT;
+
+ if (tempT > report.getTempMax()) {
+ report.setTempMax(tempT);
+ }
+
+ // 灞傝鍒楄ˉ鍏�
+ lay.setSumTemp(lay.getSumTemp() + tempT);
+
+ if (x == (cableX - 1) || y == (cableY - 1) || x == 0 || y == 0) {
+ lay.setSumOutTemp(lay.getSumOutTemp() + tempT);
+ } else {
+ lay.setSumInTemp(lay.getSumInTemp() + tempT);
+ }
+
+ // 灞傛渶楂樻渶浣�
+ if (tempT > lay.getTempMax()) {
+ lay.setTempMax(tempT);
+ }
+ if (tempT < lay.getTempMin()) {
+ lay.setTempMin(tempT);
+ }
+
+ // log.info("----娓╁害鐐�={}",tempT);
+ sumAll += tempT;
+ sumAllNum = sumAllNum + 1;
+ point.setTemp(tempT);
+ }
+
+ listPoints.add(point);
+ }
+
+ // 璋冩暣灞備俊鎭�
+ for (GrainLay detail : listLays) {
+ if (0 != detail.getSumNum()) {
+ detail.setTempAve(detail.getSumTemp() / detail.getSumNum());
+ detail.setTempAve(NumberUtil.keepPrecision(detail.getTempAve(),
+ 1));
+ }
+
+ if (0 != detail.getSumInNum()) {
+ detail.setTempAveIn(detail.getSumInTemp()
+ / detail.getSumInNum());
+ detail.setTempAveIn(NumberUtil.keepPrecision(
+ detail.getTempAveIn(), 1));
+ }
+
+ if (0 != detail.getSumOutNum()) {
+ detail.setTempAveOut(detail.getSumOutTemp()
+ / detail.getSumOutNum());
+ detail.setTempAveOut(NumberUtil.keepPrecision(
+ detail.getTempAveOut(), 1));
+ }
+
+ // 灏嗗眰鏁版嵁杞崲涓鸿鏁版嵁
+ updateReportLayInfo(report, detail);
+ }
+ }
+
+ private static void updateReportLayInfo(GrainDataReport report, GrainLay lay) {
+
+ if (1 == lay.getFz()) {// 绗�1灞�
+ report.setZ1(lay.getFz());
+ report.setTempAve1(lay.getTempAve() + "");
+ report.setTempMax1(lay.getTempMax() + "");
+ report.setTempMin1(lay.getTempMin() + "");
+ }
+ if (2 == lay.getFz()) {// 绗�2灞�
+ report.setZ2(lay.getFz());
+ report.setTempAve2(lay.getTempAve() + "");
+ report.setTempMax2(lay.getTempMax() + "");
+ report.setTempMin2(lay.getTempMin() + "");
+ }
+
+ if (3 == lay.getFz()) {// 绗�3灞�
+ report.setZ3(lay.getFz());
+ report.setTempAve3(lay.getTempAve() + "");
+ report.setTempMax3(lay.getTempMax() + "");
+ report.setTempMin3(lay.getTempMin() + "");
+ }
+
+ if (4 == lay.getFz()) {// 绗�4灞�
+ report.setZ4(lay.getFz());
+ report.setTempAve4(lay.getTempAve() + "");
+ report.setTempMax4(lay.getTempMax() + "");
+ report.setTempMin4(lay.getTempMin() + "");
+ }
+
+ if (5 == lay.getFz()) {// 绗�5灞�
+ report.setZ5(lay.getFz());
+ report.setTempAve5(lay.getTempAve() + "");
+ report.setTempMax5(lay.getTempMax() + "");
+ report.setTempMin5(lay.getTempMin() + "");
+ }
+ if (6 == lay.getFz()) {// 绗�6灞�
+ report.setZ6(lay.getFz());
+ report.setTempAve6(lay.getTempAve() + "");
+ report.setTempMax6(lay.getTempMax() + "");
+ report.setTempMin6(lay.getTempMin() + "");
+ }
+ if (7 == lay.getFz()) {// 绗�7灞�
+ report.setZ7(lay.getFz());
+ report.setTempAve7(lay.getTempAve() + "");
+ report.setTempMax7(lay.getTempMax() + "");
+ report.setTempMin7(lay.getTempMin() + "");
+ }
+ if (8 == lay.getFz()) {// 绗�8灞�
+ report.setZ8(lay.getFz());
+ report.setTempAve8(lay.getTempAve() + "");
+ report.setTempMax8(lay.getTempMax() + "");
+ report.setTempMin8(lay.getTempMin() + "");
+ }
+ if (9 == lay.getFz()) {// 绗�9灞�
+ report.setZ9(lay.getFz());
+ report.setTempAve9(lay.getTempAve() + "");
+ report.setTempMax9(lay.getTempMax() + "");
+ report.setTempMin9(lay.getTempMin() + "");
+ }
+ if (10 == lay.getFz()) {// 绗�10灞�
+ report.setZ10(lay.getFz());
+ report.setTempAve10(lay.getTempAve() + "");
+ report.setTempMax10(lay.getTempMax() + "");
+ report.setTempMin10(lay.getTempMin() + "");
+ }
+ if (11 == lay.getFz()) {// 绗�11灞�
+ report.setZ11(lay.getFz());
+ report.setTempAve11(lay.getTempAve() + "");
+ report.setTempMax11(lay.getTempMax() + "");
+ report.setTempMin11(lay.getTempMin() + "");
+ }
+ if (12 == lay.getFz()) {// 绗�12灞�
+ report.setZ12(lay.getFz());
+ report.setTempAve12(lay.getTempAve() + "");
+ report.setTempMax12(lay.getTempMax() + "");
+ report.setTempMin12(lay.getTempMin() + "");
+ }
+ if (13 == lay.getFz()) {// 绗�13灞�
+ report.setZ13(lay.getFz());
+ report.setTempAve13(lay.getTempAve() + "");
+ report.setTempMax13(lay.getTempMax() + "");
+ report.setTempMin13(lay.getTempMin() + "");
+ }
+ if (14 == lay.getFz()) {// 绗�14灞�
+ report.setZ14(lay.getFz());
+ report.setTempAve14(lay.getTempAve() + "");
+ report.setTempMax14(lay.getTempMax() + "");
+ report.setTempMin14(lay.getTempMin() + "");
+ }
+ if (15 == lay.getFz()) {// 绗�15灞�
+ report.setZ15(lay.getFz());
+ report.setTempAve15(lay.getTempAve() + "");
+ report.setTempMax15(lay.getTempMax() + "");
+ report.setTempMin15(lay.getTempMin() + "");
+ }
+ if (16 == lay.getFz()) {// 绗�16灞�
+ report.setZ16(lay.getFz());
+ report.setTempAve16(lay.getTempAve() + "");
+ report.setTempMax16(lay.getTempMax() + "");
+ report.setTempMin16(lay.getTempMin() + "");
+ }
+ if (17 == lay.getFz()) {// 绗�17灞�
+ report.setZ17(lay.getFz());
+ report.setTempAve17(lay.getTempAve() + "");
+ report.setTempMax17(lay.getTempMax() + "");
+ report.setTempMin17(lay.getTempMin() + "");
+ }
+ if (18 == lay.getFz()) {// 绗�18灞�
+ report.setZ18(lay.getFz());
+ report.setTempAve18(lay.getTempAve() + "");
+ report.setTempMax18(lay.getTempMax() + "");
+ report.setTempMin18(lay.getTempMin() + "");
+ }
+ if (19 == lay.getFz()) {// 绗�19灞�
+ report.setZ19(lay.getFz());
+ report.setTempAve19(lay.getTempAve() + "");
+ report.setTempMax19(lay.getTempMax() + "");
+ report.setTempMin19(lay.getTempMin() + "");
+ }
+ if (20 == lay.getFz()) {// 绗�20灞�
+ report.setZ20(lay.getFz());
+ report.setTempAve20(lay.getTempAve() + "");
+ report.setTempMax20(lay.getTempMax() + "");
+ report.setTempMin20(lay.getTempMin() + "");
+ }
+ if (21 == lay.getFz()) {// 绗�21灞�
+ report.setZ21(lay.getFz());
+ report.setTempAve21(lay.getTempAve() + "");
+ report.setTempMax21(lay.getTempMax() + "");
+ report.setTempMin21(lay.getTempMin() + "");
+ }
+ if (22 == lay.getFz()) {// 绗�22灞�
+ report.setZ22(lay.getFz());
+ report.setTempAve22(lay.getTempAve() + "");
+ report.setTempMax22(lay.getTempMax() + "");
+ report.setTempMin22(lay.getTempMin() + "");
+ }
+ if (23 == lay.getFz()) {// 绗�23灞�
+ report.setZ23(lay.getFz());
+ report.setTempAve23(lay.getTempAve() + "");
+ report.setTempMax23(lay.getTempMax() + "");
+ report.setTempMin23(lay.getTempMin() + "");
+ }
+ if (24 == lay.getFz()) {// 绗�24灞�
+ report.setZ24(lay.getFz());
+ report.setTempAve24(lay.getTempAve() + "");
+ report.setTempMax24(lay.getTempMax() + "");
+ report.setTempMin24(lay.getTempMin() + "");
+ }
+ if (25 == lay.getFz()) {// 绗�25灞�
+ report.setZ25(lay.getFz());
+ report.setTempAve25(lay.getTempAve() + "");
+ report.setTempMax25(lay.getTempMax() + "");
+ report.setTempMin25(lay.getTempMin() + "");
+ }
+ }
+
+ private static List<GrainLay> initDetail(int cableX, int cableY, int cableZ) {
+ List<GrainLay> result = new ArrayList<>();
+ GrainLay lay;
+ for (int i = 1; i <= cableZ; i++) {
+ lay = new GrainLay(i, i - 1);
+ lay.setSumNum(cableY * cableX);
+ lay.setSumInNum((cableY - 2) * (cableX - 2));
+ lay.setSumOutNum(2 * cableY + 2 * cableX - 4);
+ lay.setTempMin(50.0);
+ lay.setTempMax(-50.0);
+ result.add(lay);
+ }
+ return result;
+ }
+}
--
Gitblit v1.9.3