From fe2d7c404c69700404814e18a70d5e606916486b Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期四, 24 七月 2025 15:04:12 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_ztns' into dev_ztns
---
cnas-device/src/main/java/com/ruoyi/device/service/impl/DeviceServiceImpl.java | 14 +++
cnas-device/src/main/resources/mapper/DeviceMaintenanceMapper.xml | 4
inspect-server/pom.xml | 7 +
cnas-device/src/main/java/com/ruoyi/device/pojo/Device.java | 7 +
cnas-device/src/main/java/com/ruoyi/device/utils/DataAcquisition.java | 194 +++++++++++++++++++++++++++++++++++++++++++++++-
cnas-device/src/main/java/com/ruoyi/device/dto/DeviceCollectionDto.java | 6 +
6 files changed, 222 insertions(+), 10 deletions(-)
diff --git a/cnas-device/src/main/java/com/ruoyi/device/dto/DeviceCollectionDto.java b/cnas-device/src/main/java/com/ruoyi/device/dto/DeviceCollectionDto.java
index 29a7c53..6d84b56 100644
--- a/cnas-device/src/main/java/com/ruoyi/device/dto/DeviceCollectionDto.java
+++ b/cnas-device/src/main/java/com/ruoyi/device/dto/DeviceCollectionDto.java
@@ -25,4 +25,10 @@
@ApiModelProperty(value = "閲囬泦鐨勬楠岄」id")
private List<Integer> itemIds;
+ //鏁版嵁搴撶敤鎴峰悕
+ @ApiModelProperty(value = "鏁版嵁搴撶敤鎴峰悕")
+ private String dbUserName;
+ //鏁版嵁搴撳瘑鐮�
+ @ApiModelProperty(value = "鏁版嵁搴撳瘑鐮�")
+ private String dbPassword;
}
diff --git a/cnas-device/src/main/java/com/ruoyi/device/pojo/Device.java b/cnas-device/src/main/java/com/ruoyi/device/pojo/Device.java
index d403f5a..a3dbdc8 100644
--- a/cnas-device/src/main/java/com/ruoyi/device/pojo/Device.java
+++ b/cnas-device/src/main/java/com/ruoyi/device/pojo/Device.java
@@ -134,5 +134,10 @@
@ApiModelProperty("浜у湴")
private String origin;
-
+ //鏁版嵁搴撶敤鎴峰悕
+ @ApiModelProperty("鏁版嵁搴撶敤鎴峰悕")
+ private String dbUserName;
+ //鏁版嵁搴撳瘑鐮�
+ @ApiModelProperty("鏁版嵁搴撳瘑鐮�")
+ private String dbPassword;
}
diff --git a/cnas-device/src/main/java/com/ruoyi/device/service/impl/DeviceServiceImpl.java b/cnas-device/src/main/java/com/ruoyi/device/service/impl/DeviceServiceImpl.java
index c743869..a9ac09f 100644
--- a/cnas-device/src/main/java/com/ruoyi/device/service/impl/DeviceServiceImpl.java
+++ b/cnas-device/src/main/java/com/ruoyi/device/service/impl/DeviceServiceImpl.java
@@ -35,6 +35,7 @@
import lombok.AllArgsConstructor;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -194,6 +195,8 @@
@Override
public Result<?> dataAcquisition(HttpServletRequest request, DeviceCollectionDto dto) {
+
+
// 鏌ヨ妫�楠岄」
List<Integer> itemIds = dto.getItemIds();
if (CollectionUtils.isEmpty(itemIds)) {
@@ -234,18 +237,25 @@
// 鏁伴噰杩斿洖淇℃伅
Map<String, Object> map = new HashMap<>();
for (Device device : deviceList) {
+
+ Device device1 = deviceMapper.selectById(device.getId());
+ dto.setDbUserName(device1.getDbUserName());
+ dto.setDbPassword(device1.getDbPassword());
String ip = device.getIp();
+
// 鏍规嵁妫�楠岄」鑾峰彇config
List<DataConfig> list = dataConfigService.list(Wrappers.<DataConfig>lambdaQuery()
.in(DataConfig::getStructureItemParameterId, itemParameterIds)
.eq(DataConfig::getDeviceId, device.getId()));
// 鑾峰彇璁惧閰嶇疆绫�
- // 鍒ゆ柇璁惧鏄惁鏄暟瀛楃洿妗�
+ // 鍒ゆ柇璁惧鏄惁鏄暟瀛楃洿妗CZX-ZB-ER02022
if (device.getManagementNumber().equals("JCZX-ZB-ER02022")) {
map.putAll(dataCollectBridge(list, device, dto.getEntrustCode()));
+
} else {
- map.putAll(DataAcquisition.dataAcquisitionEntrance(list, device, dto.getEntrustCode(), dto.getEntrustCode(), ip, insProducts.get(0).getCableTag()));
+ map.putAll(DataAcquisition.dataAcquisitionEntrance(list, device, dto.getEntrustCode(), dto.getEntrustCode(), ip, insProducts.get(0).getCableTag(),dto.getDbUserName(),dto.getDbPassword()));
+
}
}
diff --git a/cnas-device/src/main/java/com/ruoyi/device/utils/DataAcquisition.java b/cnas-device/src/main/java/com/ruoyi/device/utils/DataAcquisition.java
index 5065c0b..98c1942 100644
--- a/cnas-device/src/main/java/com/ruoyi/device/utils/DataAcquisition.java
+++ b/cnas-device/src/main/java/com/ruoyi/device/utils/DataAcquisition.java
@@ -7,6 +7,7 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.ruoyi.device.dto.DeviceCollectionDto;
import com.ruoyi.device.pojo.DataConfig;
import com.ruoyi.device.pojo.Device;
import com.ruoyi.framework.exception.ErrorException;
@@ -42,7 +43,7 @@
* @param device
* @return
*/
- public static Map<String, Object> dataAcquisitionEntrance(List<DataConfig> dataConfig, Device device, String entrustCode, String sampleCode, String ip, String cableTag) {
+ public static Map<String, Object> dataAcquisitionEntrance(List<DataConfig> dataConfig, Device device, String entrustCode, String sampleCode, String ip, String cableTag, String dbUserName, String dbPassword) {
// 鍒ゆ柇鏄惁鏄奖鍍忔祴閲忎华
if (device.getManagementNumber().equals("JCZX-ZB-OP07001")) {
if (device.getFileType().equals(".xlsx")) {
@@ -75,10 +76,14 @@
"&sampleCode=" + sampleCode +
"&mdbEntrustCode=" + device.getEntrustCode() +
"&mdbSampleCode=" + device.getSampleCode() +
- "&dbFileName=" + device.getDbFileName();
+ "&dbFileName=" + device.getDbFileName()+
+ "&dbUserName=" + dbUserName +
+ "&dbPassword=" + dbPassword;
+ System.out.println("璇锋眰鐨� URL: " + http);
String result = null;
try {
result = HttpUtil.get(http);
+ System.out.println("璇锋眰杩斿洖缁撴灉: " + result);
} catch (IORuntimeException e) {
e.printStackTrace();
throw new ErrorException("鎵�鍦ㄧ數鑴戞湭瀹夎鎴栨湭鍚姩锛歀IMS鏂囦欢閲囬泦鍣紒");
@@ -113,6 +118,9 @@
case ".xlsx":
map = analysisList(data, userMap, device, entrustCode, sampleCode);
break;
+ case ".xls":
+ map = analysisTxt(data, userMap, device, entrustCode, sampleCode);
+ break;
case ".txt":
map = analysisTxt(data, userMap, device, entrustCode, sampleCode);
break;
@@ -120,7 +128,7 @@
map = analysisList(data, userMap, device, entrustCode, sampleCode);
break;
case ".mdb":
- // 鍒ゆ柇鏄惁鏄媺鍔涙満
+ // 鍒ゆ柇鏄惁鏄媺鍔涙満JCZX-ZB-FF01014
if (device.getManagementNumber().equals("JCZX-ZB-FF01014")) {
map = analysisMdbByPull(data, userMap, device, cableTag);
} else {
@@ -128,6 +136,7 @@
}
break;
case ".db":
+// map = analysisDb1(data, userMap, device);
map = analysisDb(data, userMap, device);
break;
case ".png":
@@ -181,6 +190,56 @@
return "1";
}
+ private static Map<String, Object> analysisDb1(String data, Map<String, List<DataConfig>> dataConfig, Device device) {
+ JSONObject jsonObject = JSON.parseObject(data);
+ Map<String, Object> map = new HashMap<>();
+ if (jsonObject.isEmpty()) {
+ return map;
+ }
+ // 浠� JSON 鏁版嵁涓彁鍙� data 鏁扮粍
+ JSONArray dataList = JSONArray.parseArray(jsonObject.get("data").toString());
+ dataConfig.forEach((k, v) -> {
+ AtomicInteger numberOfDataEntries = new AtomicInteger();
+ List<Object> list = new ArrayList<>();
+ for (int config = 0; config < v.size(); config++) {
+ String refery = getRefer(v.get(config).getRefery());
+ for (int i = 0; i < dataList.size(); i++) {
+ JSONObject jsonObject1 = JSON.parseObject(dataList.get(i).toString());
+ if (ObjectUtils.isNotEmpty(jsonObject1.get(refery))) {
+ numberOfDataEntries.addAndGet(1);
+ list.add(jsonObject1.get(refery));
+ }
+// Object o = jsonObject1.get(refery);
+// if (ObjectUtils.isNotEmpty(o)) {
+// numberOfDataEntries.addAndGet(1);
+// list.add(o);
+// }
+ }
+ }
+ // 鎷兼帴鏁伴噰閰嶇疆
+ List<Object> result = new ArrayList<>();
+ for (int i = 0; i < numberOfDataEntries.get(); i++) {
+ StringBuilder aggregate = new StringBuilder();
+ for (int j = 0; j < v.size(); j++) {
+ int index;
+ if (j == 0) {
+ index = i;
+ } else {
+ index = numberOfDataEntries.get() + i;
+ }
+ aggregate.append(list.get(index).toString()).append(",");
+ }
+ if (aggregate.length() > 0) {
+ aggregate.setLength(aggregate.length() - 1);
+ }
+ result.add(aggregate.toString());
+ }
+ // 杩涜鍏紡璁$畻
+ Object resultValue = calculationFormula(result, v.get(0), k, device);
+ map.put(k, resultValue);
+ });
+ return map;
+ }
/**
* 闇�瑕侀�氳繃X,Y杞村畾浣�
@@ -189,17 +248,20 @@
* @param dataConfig
* @return
*/
+
private static Map<String, Object> analysisDb(String data, Map<String, List<DataConfig>> dataConfig, Device device) {
JSONObject jsonObject = JSON.parseObject(data);
Map<String, Object> map = new HashMap<>();
if (jsonObject.isEmpty()) {
return map;
}
+ // 浠� JSON 鏁版嵁涓彁鍙� data 鏁扮粍
JSONArray dataList = JSONArray.parseArray(jsonObject.get("data").toString());
dataConfig.forEach((k, v) -> {
AtomicInteger numberOfDataEntries = new AtomicInteger();
List<Object> list = new ArrayList<>();
for (int config = 0; config < v.size(); config++) {
+// String refery = v.get(config).getRefery();
String refery = getRefer(v.get(config).getRefery());
for (int i = 0; i < dataList.size(); i++) {
JSONObject jsonObject1 = JSON.parseObject(dataList.get(i).toString());
@@ -473,6 +535,7 @@
String firstNumber = lastLine.split("\t")[0];
list.add(firstNumber);
} else {
+
list = analyzeData(data, v, k, ",");
}
// 濮旀墭缂栧彿涓庢牱鍝佺紪鍙峰瓨鍦�
@@ -625,7 +688,117 @@
private static String getRefer(String refer) {
return ObjectUtils.isNotEmpty(refer) ? refer.replaceAll(" ", "") : "";
}
+ /**
+ * 濮旀墭缂栧彿涓庢牱鍝佺紪鍙烽兘涓虹┖鎵ц
+ *
+ * @param data 閲囬泦鍒扮殑鏂囦欢瀛楃涓�
+ * @param v 鐢ㄦ埛閰嶇疆濂界殑x,y杞村畾浣嶆暟鎹笌鍙傜収鐗�
+ * @param k 妫�楠岄」鍚嶇О
+ * @param split 鍒嗗壊绗�
+ * @return 鎻愬彇鐨勬暟鎹垪琛�
+ */
+ public static List<Object> analyzeData1(String data, List<DataConfig> v, String k, String split) {
+ List<Object> list = new ArrayList<>();
+ // 棰勫鐞嗘暟鎹細绉婚櫎澶氫綑绌烘牸骞朵繚鐣欏叧閿垎闅旂
+ String processedData = data.replaceAll("\\s+", " ").trim();
+ for (int configIndex = 0; configIndex < v.size(); configIndex++) {
+ // 鍙栦袱涓敤鎴烽厤缃殑鍙傜収鐗�
+ String referx = getRefer(v.get(configIndex).getReferx());
+ String refery = getRefer(v.get(configIndex).getRefery());
+ if (ObjectUtils.isEmpty(refery) && ObjectUtils.isEmpty(referx)) {
+ System.out.println("鍙傜収鐗╀负绌猴紝璺宠繃褰撳墠閰嶇疆锛宬: " + k);
+ continue;
+ }
+ // 鏈�缁堢粨鏋�
+ List<Object> result = new ArrayList<>();
+ // 閫氳繃\n灏嗗瓧绗︿覆鍒嗗壊涓鸿
+ String[] aColumnY = processedData.replaceAll(" ", "").split("\n");
+ Integer end = null;
+ // 閲囬泦鏁版嵁锛歒杞�
+ for (int i = 0; i < aColumnY.length; i++) {
+ String line = aColumnY[i].trim();
+ if (line.isEmpty()) continue; // 璺宠繃绌鸿
+ // 濡傛灉Y鍙傜収涓嶄负绌轰笌X鍙傜収涓虹┖鍒欐墽琛岋紝鍚屾椂璇ヨ鍖呭惈Y鍙傜収
+ if (ObjectUtils.isNotEmpty(refery) && ObjectUtils.isEmpty(referx) && line.contains(refery)) {
+ try {
+ // 鍙朰鍧愭爣鍊�
+ int y = getXOrY(v.get(configIndex).getY(), k, "Y");
+ String[] aLineX = line.split(split);
+ for (int j = 0; j < aLineX.length; j++) {
+ if (aLineX[j].contains(refery)) {
+ if (i + y >= aColumnY.length) {
+ System.err.println(k + "锛歒杞村畾浣嶈秴鍑烘暟鎹寖鍥达紝褰撳墠鏁版嵁琛屾暟: " + aColumnY.length + "锛屽皾璇曡闂: " + (i + y));
+ continue;
+ }
+ String[] split1 = aColumnY[i + y].split(split);
+ if (j >= split1.length) {
+ System.err.println(k + "锛歑杞村畾浣嶈秴鍑烘暟鎹寖鍥达紝褰撳墠琛屽厓绱犱釜鏁�: " + split1.length + "锛屽皾璇曡闂綅缃�: " + j);
+ continue;
+ }
+ result.add(split1[j]);
+ }
+ }
+ } catch (Exception e) {
+ System.err.println(k + "锛氬湪澶勭悊浠匶鍙傜収閫昏緫鏃跺嚭鐜板紓甯�: " + e.getMessage());
+ }
+ }
+ // 濡傛灉Y鍙傜収涓嶄负绌轰笌X鍙傜収涓嶄负绌哄垯鎵ц,姝ゅY瀹氬尯鍩�
+ else if (ObjectUtils.isNotEmpty(refery) && ObjectUtils.isNotEmpty(referx)) {
+ try {
+ // 鍙杧鐨勫�硷紝闃叉鎶ラ敊
+ int x = getXOrY(v.get(configIndex).getX(), k, "X");
+ // 鍙朰鍧愭爣鍊�
+ int y = getXOrY(v.get(configIndex).getY(), k, "Y");
+ // 缂撳瓨Y鐨勭粨鏉熷��
+ if (ObjectUtils.isEmpty(end) && line.contains(refery)) {
+ end = i + y;
+ }
+ // 鍒ゆ柇鏄惁鍦ㄥ弬鐓х墿涓鸿捣鐐癸紝Y鍧愭爣鍊间负鏈�缁堣寖鍥�
+ if (ObjectUtils.isNotEmpty(end) && i <= end) {
+ String[] aLineX = line.split(split);
+ for (int j = 0; j < aLineX.length; j++) {
+ if (aLineX[j].contains(referx)) {
+ if (j + x >= aLineX.length) {
+ System.err.println(k + "锛歑杞村畾浣嶈秴鍑烘暟鎹寖鍥达紝褰撳墠琛屽厓绱犱釜鏁�: " + aLineX.length + "锛屽皾璇曡闂綅缃�: " + (j + x));
+ continue;
+ }
+ result.add(aLineX[j + x]);
+ break;
+ }
+ }
+ }
+ } catch (Exception e) {
+ System.err.println(k + "锛氬湪澶勭悊XY鍙傜収閫昏緫鏃跺嚭鐜板紓甯�: " + e.getMessage());
+ }
+ }
+ // 濡傛灉X鍙傜収涓嶄负绌哄悓鏃惰琛屽寘鍚玐鍙傜収锛屽垯鎵ц涓嬮潰鐨勪唬鐮�
+ else if (line.contains(referx) && ObjectUtils.isEmpty(refery)) {
+ try {
+ String[] aLineX = line.split(split);
+ // 鍙杧鐨勫�硷紝闃叉鎶ラ敊
+ int x = getXOrY(v.get(configIndex).getX(), k, "X");
+ for (int j = 0; j < aLineX.length; j++) {
+ if (aLineX[j].contains(referx)) {
+ if (j + x >= aLineX.length) {
+ System.err.println(k + "锛歑杞村畾浣嶈秴鍑烘暟鎹寖鍥达紝褰撳墠琛屽厓绱犱釜鏁�: " + aLineX.length + "锛屽皾璇曡闂綅缃�: " + (j + x));
+ continue;
+ }
+ result.add(aLineX[j + x]);
+ }
+ }
+ } catch (Exception e) {
+ System.err.println(k + "锛氬湪澶勭悊浠匵鍙傜収閫昏緫鏃跺嚭鐜板紓甯�: " + e.getMessage());
+ }
+ }
+ }
+ // 闃叉璁$畻鍏紡鐨勬椂鍊欏嚭鐜帮細[null] 杩欑鏁版嵁
+ if (ObjectUtils.isNotEmpty(result)) {
+ list.addAll(result);
+ }
+ }
+ return list;
+ }
/**
* 濮旀墭缂栧彿涓庢牱鍝佺紪鍙烽兘涓虹┖鎵ц
*
@@ -637,6 +810,10 @@
*/
public static List<Object> analyzeData(String data, List<DataConfig> v, String k, String split) {
List<Object> list = new ArrayList<>();
+
+ // 棰勫鐞嗘暟鎹細绉婚櫎澶氫綑绌烘牸骞朵繚鐣欏叧閿垎闅旂
+// String processedData = data.replaceAll("\\s+", " ").trim();
+
for (int config = 0; config < v.size(); config++) {
// 鍙栦袱涓敤鎴烽厤缃殑鍙傜収鐗�
String referx = getRefer(v.get(config).getReferx());
@@ -651,11 +828,14 @@
Integer end = null;
// 閲囬泦鏁版嵁锛歒杞�
for (int i = 0; i < aColumnY.length; i++) {
+// String line = aColumnY[i].trim();
+// if (line.isEmpty()) continue; // 璺宠繃绌鸿
// 濡傛灉Y鍙傜収涓嶄负绌轰笌X鍙傜収涓虹┖鍒欐墽琛岋紝鍚屾椂璇ヨ鍖呭惈Y鍙傜収
- if (ObjectUtils.isNotEmpty(refery) && ObjectUtils.isEmpty(referx) && aColumnY[i].contains(refery)) {
+ if (ObjectUtils.isNotEmpty(refery) && ObjectUtils .isEmpty(referx) && aColumnY[i].contains(refery)) {
// 鍙朰鍧愭爣鍊�
int y = getXOrY(v.get(config).getY(), k, "Y");
String[] aLineX = aColumnY[i].split(split);
+// String[] aLineX = line.split(split);
for (int j = 0; j < aLineX.length; j++) {
if (aLineX[j].contains(refery)) {
String[] split1 = new String[0];
@@ -665,7 +845,9 @@
throw new ErrorException(k + "锛歒杞村畾浣嶈秴鍑猴紒");
}
try {
+// System.out.println("----------");
result.add(split1[j]);
+
} catch (Exception e) {
throw new ErrorException(k + "锛歑杞村畾浣嶈秴鍑猴紒");
}
@@ -687,6 +869,7 @@
for (int j = 0; j < aLineX.length; j++) {
if (aLineX[j].contains(referx)) {
try {
+// System.out.println("77777777777777");
result.add(aLineX[j + x]);
} catch (Exception e) {
throw new ErrorException(k + "锛歑杞村畾浣嶈秴鍑猴紒");
@@ -703,6 +886,7 @@
for (int j = 0; j < aLineX.length; j++) {
if (aLineX[j].contains(referx)) {
try {
+// System.out.println("4444444444444444");
result.add(aLineX[j + x]);
} catch (Exception e) {
throw new ErrorException(k + "锛歑杞村畾浣嶈秴鍑猴紒");
@@ -711,7 +895,7 @@
}
}
}
- // 闃叉璁$畻鍏紡鐨勬椂鍊欏嚭鐜帮細[null] 杩欑鏁版嵁
+// 闃叉璁$畻鍏紡鐨勬椂鍊欏嚭鐜帮細[null] 杩欑鏁版嵁
if (ObjectUtils.isNotEmpty(result)) {
// String formatProcessing = getFormatProcessing(result);
list.addAll(result);
diff --git a/cnas-device/src/main/resources/mapper/DeviceMaintenanceMapper.xml b/cnas-device/src/main/resources/mapper/DeviceMaintenanceMapper.xml
index b6ab4cc..326ff4f 100644
--- a/cnas-device/src/main/resources/mapper/DeviceMaintenanceMapper.xml
+++ b/cnas-device/src/main/resources/mapper/DeviceMaintenanceMapper.xml
@@ -8,8 +8,8 @@
<select id="selectDeviceMaintenancePage" resultType="com.ruoyi.device.dto.DeviceMaintenanceDto">
select * from (
select db.*,
- d.device_name,
- d.management_number
+ d.device_name as d_device_name,
+ d.management_number as d_management_number
from device_maintenance db
left join device d on db.device_id = d.id)a
<if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
diff --git a/inspect-server/pom.xml b/inspect-server/pom.xml
index d3d0bd6..38ae884 100644
--- a/inspect-server/pom.xml
+++ b/inspect-server/pom.xml
@@ -50,10 +50,17 @@
<!--word杞琾df-->
<!--mvn install:install-file -Dfile=aspose-words-15.12.0-jdk16.jar -DgroupId=com.aspose -DartifactId=aspose-words -Dversion=15.12.0 -Dpackaging=jar-->
+<!-- <dependency>-->
+<!-- <groupId>com.aspose</groupId>-->
+<!-- <artifactId>aspose-words</artifactId>-->
+<!-- <version>15.12.0</version>-->
+<!-- </dependency>-->
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-words</artifactId>
<version>15.12.0</version>
+<!-- <scope>system</scope>-->
+<!-- <systemPath>D:/aspose-words-15.12.0-jdk16.jar</systemPath>-->
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
--
Gitblit v1.9.3