Commit 184318be authored by 李松's avatar 李松

修改bug

parent 69f008f1
......@@ -67,6 +67,9 @@ public class AdpterService {
@Value("${goal.jdbc.ip.dlbuss}")
String dlBuss;
@Value("${goal.jdbc.ip.relation}")
String relation;
@Value("${goal.jdbc.ip.dlcom}")
String dlCom;
String driver = "com.mysql.cj.jdbc.Driver";
......@@ -719,11 +722,29 @@ public class AdpterService {
String replace = new String(Files.readAllBytes(resource.getFile().toPath()));
String sql = replace.replace("#{gatewayId}", gatewayId);
List<Map<String, Object>> list = query(dlBuss, sql);
getRelation(list);
ArrayList<DeviceExcelModel> deviceList = new ArrayList<>();
setData(list, deviceList);
return deviceList;
}
public void getRelation(List<Map<String, Object>> list) {
String relationSql = "SELECT * from iot_index_relation";
List<Map<String, Object>> relationList = query(relation, relationSql);
list.forEach(dev -> {
List<Map<String, Object>> collect = relationList.stream().filter(r -> !ObjectUtils.isEmpty(dev.get("equipmentIndexKey")) && !ObjectUtils.isEmpty(dev.get("equipTypeCode")) && r.get("oldIndexCode").toString().equals(dev.get("equipmentIndexKey").toString())
&& r.get("oldequipTypeCode").toString().equals(dev.get("equipTypeCode").toString())).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(collect) && collect.size() == 1) {
Map<String, Object> objectMap = collect.get(0);
dev.put("iotProperName", objectMap.get("newIndexName"));
dev.put("deviceType", objectMap.get("newEquipType"));
} else {
dev.put("iotProperName", dev.get("iotProperName")+"-"+(!ObjectUtils.isEmpty(dev.get("equipmentIndexKey"))?dev.get("equipmentIndexKey"):"").toString()+"缺失");
dev.put("deviceType", dev.get("deviceType")+"-"+(!ObjectUtils.isEmpty(dev.get("equipTypeCode"))?dev.get("equipTypeCode"):"").toString()+"缺失");
}
});
}
public void syncMainDeviceRelation() throws IOException {
// 获取主设备关联物联设备记录
Resource mainResource = new ClassPathResource("sql/mainDeviceRelation.sql");
......@@ -746,7 +767,7 @@ public class AdpterService {
params.forEach(p -> {
try {
StringBuilder sql = new StringBuilder();
sql.append("INSERT INTO iot_device_bind_relation_test (SEQUENCE_NBR" +
sql.append("INSERT INTO iot_device_bind_relation (SEQUENCE_NBR" +
", DEVICE_SEQ" +
", SUB_DEVICE_SEQ" +
",SUB_DEVICE_ID" +
......@@ -787,9 +808,9 @@ public class AdpterService {
}
});
// 更新数据
finalStatement.addBatch("UPDATE iot_device_bind_relation_test a " +
"JOIN iot_device_info_test b1 ON b1.DEVICE_CODE = a.DEVICE_ID " +
"JOIN iot_device_info_test b2 ON b2.DEVICE_CODE = a.SUB_DEVICE_ID " +
finalStatement.addBatch("UPDATE iot_device_bind_relation a " +
"JOIN iot_device_info b1 ON b1.DEVICE_CODE = a.DEVICE_ID " +
"JOIN iot_device_info b2 ON b2.DEVICE_CODE = a.SUB_DEVICE_ID " +
"SET a.DEVICE_SEQ = b1.SEQUENCE_NBR," +
" a.DEVICE_ID = b1.DEVICE_ID," +
" a.SUB_DEVICE_SEQ = b2.SEQUENCE_NBR," +
......
......@@ -18,5 +18,5 @@ from (
) a,
wl_form_instance i
WHERE i.instance_id = a.id
group by a.id
group by a.id,i.group_type
) temp
\ No newline at end of file
......@@ -14,7 +14,7 @@ from (
temp.`NAME` AS pointName,
temp.FIELD_NAME,
temp.equipment_index_name AS iotProperName,
temp.equipment_index_key,
temp.equipment_index_key as equipmentIndexKey,
wes.`code` AS deviceCode,
wed.equipment_name AS deviceType,
wes.`name` AS deviceName,
......@@ -25,7 +25,8 @@ from (
we.maintenance_cycle AS mainDate,
we.expiry_date AS scraplife,
wes.warranty_period AS period,
ffs.`name` AS `system`
ffs.`name` AS `system`,
SUBSTR(temp.PRODUCT_KEY, 3) AS equipTypeCode
FROM (
SELECT gdp.DATA_TYPE,
gdp.PRODUCT_KEY,
......
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