Commit 56e31553 authored by 赵啸非's avatar 赵啸非

分组更新设备

parent 5b103540
package com.mortals.xhx.thread;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.service.ICacheService;
......@@ -112,7 +113,10 @@ public class DeviceDownMsgThread extends AbstractThread {
}
}
if (!ObjectUtils.isEmpty(deviceLogList)) {
deviceLogService.save(deviceLogList);
List<List<DeviceLogEntity>> partition = ListUtil.partition(deviceLogList, 100);
for (List<DeviceLogEntity> deviceLogEntities : partition) {
deviceLogService.save(deviceLogEntities);
}
}
}
}
......
......@@ -17,6 +17,9 @@ import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.List;
import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_PHP_IN_HTTP_URL;
import static com.mortals.xhx.common.key.RedisKey.KEY_DEVICE_THIRDPARTY_QUEUE;
......@@ -47,17 +50,33 @@ public class SendThirdPartyThread extends AbstractThread {
@Override
protected void process() {
// log.info("SendThirdPartyThread process");
DeviceReq deviceReq = cacheService.blpop(KEY_DEVICE_THIRDPARTY_QUEUE, 10, DeviceReq.class);
if (!ObjectUtils.isEmpty(deviceReq)) {
//设备上下线信息 不更新通知
if (DeviceMethodEnum.ONLINE.getValue() == deviceReq.getDeviceStatus() || DeviceMethodEnum.ONLINE.getValue() == deviceReq.getDeviceStatus()) {
return;
List<DeviceReq> deviceMsgReqs = new ArrayList<>();
while (true) {
DeviceReq deviceReq = cacheService.lpop(KEY_DEVICE_THIRDPARTY_QUEUE, DeviceReq.class);
if (ObjectUtils.isEmpty(deviceReq)) {
// log.info("deviceMsgReq:{}", deviceMsgReq == null);
break;
}
deviceMsgReqs.add(deviceReq);
}
if (!ObjectUtils.isEmpty(deviceMsgReqs)) {
// DeviceReq deviceReq = cacheService.lpop(KEY_DEVICE_THIRDPARTY_QUEUE, DeviceReq.class);
if (!ObjectUtils.isEmpty(deviceMsgReqs)) {
for (DeviceReq deviceMsgReq : deviceMsgReqs) {
//设备上下线信息 不更新通知
if (DeviceMethodEnum.ONLINE.getValue() == deviceMsgReq.getDeviceStatus() || DeviceMethodEnum.ONLINE.getValue() == deviceMsgReq.getDeviceStatus()) {
return;
}
//deviceReq.getReceiveMethod()
String phpInUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_IN_HTTP_URL, "http://127.0.0.1:11078/zwfw_api");
ApiResp<String> resp = messageService.sendThirdParty(UrlBuilder.of(phpInUrl).addPath(thirdPartyPath).build(), deviceMsgReq);
log.info("sendThirty req==>deviceCode:{} TYPE:{} \n resp ==>{}",deviceMsgReq.getDeviceCode(),DeviceMethodEnum.getByValue(deviceMsgReq.getDeviceStatus()).getDesc(), JSON.toJSONString(resp));
}
}
//deviceReq.getReceiveMethod()
String phpInUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_IN_HTTP_URL, "http://127.0.0.1:11078/zwfw_api");
ApiResp<String> resp = messageService.sendThirdParty(UrlBuilder.of(phpInUrl).addPath(thirdPartyPath).build(), deviceReq);
log.info("sendThirty req==>{} \n resp ==>{}", JSON.toJSONString(deviceReq), JSON.toJSONString(resp));
}
}
......
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