|
|
@@ -5,9 +5,8 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.tofly.common.core.util.StringUtil;
|
|
|
-import com.tofly.third.common.res.ResultRespone;
|
|
|
import com.tofly.third.common.util.HttpRequestUtil;
|
|
|
-import com.tofly.third.config.QdjcznbConfig;
|
|
|
+import com.tofly.third.config.Znbconfig;
|
|
|
import com.tofly.third.entity.YhCbkxx;
|
|
|
import com.tofly.third.entity.ZnbCbLog;
|
|
|
import com.tofly.third.entity.ZnbZlLog;
|
|
|
@@ -27,7 +26,7 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class ZnbZlLogService extends ServiceImpl<ZnbZlLogMapper, ZnbZlLog> {
|
|
|
@Autowired
|
|
|
- private QdjcznbConfig qdjcznbConfig;
|
|
|
+ private Znbconfig znbconfig;
|
|
|
@Autowired
|
|
|
private YhCbkxxService yhCbkxxService;
|
|
|
|
|
|
@@ -64,7 +63,7 @@ public class ZnbZlLogService extends ServiceImpl<ZnbZlLogMapper, ZnbZlLog> {
|
|
|
.eq(ZnbZlLog::getClLock, "0")
|
|
|
.eq(ZnbZlLog::getClCljg, "0")
|
|
|
.lt(ZnbZlLog::getQqNum, 5)//请求次数小于五
|
|
|
- .in(ZnbZlLog::getSccj, "7")
|
|
|
+ .in(ZnbZlLog::getSccj, "2", "3", "4")
|
|
|
.orderByAsc(ZnbZlLog::getCzsj)
|
|
|
.list();
|
|
|
if (znbZlLogs.isEmpty()) {
|
|
|
@@ -77,15 +76,21 @@ public class ZnbZlLogService extends ServiceImpl<ZnbZlLogMapper, ZnbZlLog> {
|
|
|
.setSql("QQ_NUM=nvl(QQ_NUM,0)+1")
|
|
|
.in(ZnbZlLog::getId, znbZlLogs.stream().map(ZnbZlLog::getId).collect(Collectors.toList()))
|
|
|
.update();
|
|
|
- //查询出青岛积成的阀控指令
|
|
|
- List<ZnbZlLog> znbZlLogs_qdjc = znbZlLogs.stream().filter(o -> "7".equals(o.getSccj())).collect(Collectors.toList());
|
|
|
- if (!znbZlLogs_qdjc.isEmpty()) {
|
|
|
- qdjckgf(znbZlLogs_qdjc);
|
|
|
+ //查询出山东冠翔的阀控指令
|
|
|
+ List<ZnbZlLog> znbZlLogs_sdgx = znbZlLogs.stream().filter(o -> "2".equals(o.getSccj())).collect(Collectors.toList());
|
|
|
+ if (!znbZlLogs_sdgx.isEmpty()) {
|
|
|
+ sdgxkgf(znbZlLogs_sdgx);
|
|
|
+ }
|
|
|
+ //查询出山东晨晖的阀控指令
|
|
|
+ List<ZnbZlLog> znbZlLogs_sdch = znbZlLogs.stream().filter(o -> "3".equals(o.getSccj())).collect(Collectors.toList());
|
|
|
+ if (!znbZlLogs_sdch.isEmpty()) {
|
|
|
+
|
|
|
+ }
|
|
|
+ //查询出成都优艾特的阀控指令
|
|
|
+ List<ZnbZlLog> znbZlLogs_cdyat = znbZlLogs.stream().filter(o -> "4".equals(o.getSccj())).collect(Collectors.toList());
|
|
|
+ if (!znbZlLogs_cdyat.isEmpty()) {
|
|
|
+
|
|
|
}
|
|
|
- //查询出其他积成的阀控指令
|
|
|
-// znbZlLogs.stream().filter(o -> !"3".equals(o.getSccj())).forEach(o -> {
|
|
|
-//
|
|
|
-// });
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
log.error("执行开关阀命令失败");
|
|
|
@@ -93,44 +98,33 @@ public class ZnbZlLogService extends ServiceImpl<ZnbZlLogMapper, ZnbZlLog> {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 青岛积成水表开关阀指令发送
|
|
|
+ * 山东冠翔开关阀指令发送
|
|
|
*
|
|
|
* @param list
|
|
|
*/
|
|
|
- private void qdjckgf(List<ZnbZlLog> list) {
|
|
|
- String baseUrl = qdjcznbConfig.getBaseUrl() + "/ws/laiyang/valveControl";
|
|
|
- List<Map> mapList = new ArrayList<>();
|
|
|
+ private void sdgxkgf(List<ZnbZlLog> list) {
|
|
|
+ String baseUrl = znbconfig.getSdgxznbconfig().getBaseUrl();
|
|
|
for (ZnbZlLog item : list) {
|
|
|
Map map = new HashMap();
|
|
|
- map.put("steal_no", item.getBjbh());//水表钢印号,用于唯一标识水表
|
|
|
- map.put("zlId", item.getId());//指令ID
|
|
|
- map.put("type", "0".equals(item.getZlvalue()) ? "1" : "0");//阀门操作类型:0 = 开阀1 = 关阀
|
|
|
- map.put("sign", qdjcznbConfig.getSign());//公司签名标识,用于验证调用方身份
|
|
|
- mapList.add(map);
|
|
|
- }
|
|
|
- String params = JSONObject.toJSONString(mapList);
|
|
|
- log.info("指令发送参数:" + params);
|
|
|
- String result = HttpRequestUtil.POSTRequest(baseUrl, params);
|
|
|
- log.info("指令发送结果:" + result);
|
|
|
- if (StringUtil.isEmpty(result)) {
|
|
|
- this.lambdaUpdate()
|
|
|
- .set(ZnbZlLog::getClLock, "0")
|
|
|
- .set(ZnbZlLog::getClCljg, "0")
|
|
|
- .set(ZnbZlLog::getClRemessage, "指令发送失败")
|
|
|
- .set(ZnbZlLog::getClClsj, new Date())
|
|
|
- .in(ZnbZlLog::getId, list.stream().map(ZnbZlLog::getId).collect(Collectors.toList()))
|
|
|
- .update();
|
|
|
- } else {
|
|
|
- log.info("指令发送成功:" + result);
|
|
|
- JSONArray jsonArray = JSONArray.parseArray(result);
|
|
|
- if (!jsonArray.isEmpty()) {
|
|
|
- List<ZnbZlLog> updates = new ArrayList<>();
|
|
|
- jsonArray.forEach(item -> {
|
|
|
- JSONObject info = (JSONObject) item;
|
|
|
- ZnbZlLog znbZlLog = list.stream().filter(o -> o.getId().equals(info.getString("zlId"))).findFirst().get();
|
|
|
+ map.put("bjbh", item.getBjbh());//水表钢印号,用于唯一标识水表
|
|
|
+ map.put("zlID", item.getId());//指令ID
|
|
|
+ map.put("zlvalue", item.getZlvalue());//阀门操作类型:1 = 开阀 0= 关阀
|
|
|
+ String params = JSONObject.toJSONString(map);
|
|
|
+ log.info("指令发送参数:" + params);
|
|
|
+ String result = HttpRequestUtil.POSTRequest(baseUrl, params);
|
|
|
+ log.info("指令发送结果:" + result);
|
|
|
+ if (StringUtil.isEmpty(result)) {
|
|
|
+ updateZllog(item.getId());
|
|
|
+ } else {
|
|
|
+ log.info("指令发送成功:" + result);
|
|
|
+ //成功返回{"code":0,"message":"Success","timestamp":"2026-05-29 11:11:01","result":null}
|
|
|
+ //失败返回{"code":1,"message":"操作失败","timestamp":"2026-05-29 11:13:19","result":null}
|
|
|
+ JSONObject info = JSONObject.parseObject(result);
|
|
|
+ if (info != null) {
|
|
|
+ List<ZnbZlLog> updates = new ArrayList<>();
|
|
|
ZnbZlLog updateLog = new ZnbZlLog();
|
|
|
- updateLog.setId(znbZlLog.getId()); // 必须 set ID
|
|
|
- if ("0".equals(info.getString("returnvalue"))) {
|
|
|
+ updateLog.setId(item.getId()); // 必须 set ID
|
|
|
+ if ("0".equals(info.getString("code"))) {
|
|
|
updateLog.setClCljg("8");
|
|
|
updateLog.setClLock("0");
|
|
|
updateLog.setClRemessage("指令已发送等待回传");
|
|
|
@@ -138,7 +132,7 @@ public class ZnbZlLogService extends ServiceImpl<ZnbZlLogMapper, ZnbZlLog> {
|
|
|
updates.add(updateLog);
|
|
|
yhCbkxxService.lambdaUpdate()
|
|
|
.set(YhCbkxx::getFmzt, "1")
|
|
|
- .in(YhCbkxx::getCbkid, znbZlLog.getCbkid())
|
|
|
+ .in(YhCbkxx::getCbkid, item.getCbkid())
|
|
|
.update();
|
|
|
} else {
|
|
|
updateLog.setClCljg("0");
|
|
|
@@ -147,17 +141,22 @@ public class ZnbZlLogService extends ServiceImpl<ZnbZlLogMapper, ZnbZlLog> {
|
|
|
updateLog.setClClsj(LocalDateTime.now());
|
|
|
updates.add(updateLog);
|
|
|
}
|
|
|
- });
|
|
|
- this.updateBatchById(updates);
|
|
|
- } else {
|
|
|
- this.lambdaUpdate()
|
|
|
- .set(ZnbZlLog::getClLock, "0")
|
|
|
- .set(ZnbZlLog::getClCljg, "0")
|
|
|
- .set(ZnbZlLog::getClRemessage, "指令发送失败")
|
|
|
- .set(ZnbZlLog::getClClsj, new Date())
|
|
|
- .in(ZnbZlLog::getId, list.stream().map(ZnbZlLog::getId).collect(Collectors.toList()))
|
|
|
- .update();
|
|
|
+ this.updateBatchById(updates);
|
|
|
+ } else {
|
|
|
+ updateZllog(item.getId());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ private void updateZllog(String id) {
|
|
|
+ this.lambdaUpdate()
|
|
|
+ .set(ZnbZlLog::getClLock, "0")
|
|
|
+ .set(ZnbZlLog::getClCljg, "0")
|
|
|
+ .set(ZnbZlLog::getClRemessage, "指令发送失败")
|
|
|
+ .set(ZnbZlLog::getClClsj, new Date())
|
|
|
+ .eq(ZnbZlLog::getId, id)
|
|
|
+ .update();
|
|
|
+ }
|
|
|
}
|