Commit 8ea3c844 authored by 赵啸非's avatar 赵啸非

设备列表导出优化

parent 3f175afd
......@@ -234,7 +234,7 @@ public class DeviceApiController {
if (ObjectUtils.isEmpty(firmList)) deviceInitResp.setFirmList(new ArrayList<>());
SitePdu sitePdu = new SitePdu();
sitePdu.setSize(-1);
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(new SitePdu());
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
if (resp.getCode() == 1) {
List<SitePdu> sitePduList = resp.getData().getData();
List<SiteInfo> siteInfoList = sitePduList.stream().map(site -> {
......
......@@ -3,9 +3,11 @@ package com.mortals.xhx.daemon.applicationservice;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.mortals.framework.common.Rest;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.springcloud.service.IApplicationService;
import com.mortals.framework.springcloud.service.IApplicationStartedService;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.site.SitePdu;
import com.mortals.xhx.common.utils.SendTaskThreadPool;
import com.mortals.xhx.common.utils.SmsQueueManager;
......@@ -77,14 +79,15 @@ public class DeviceStartService implements IApplicationStartedService {
//初始化站点缓存
String resp = siteFeign.list(new SitePdu());
JSONObject jsonObject = JSONObject.parseObject(resp);
if (jsonObject.getInteger("code") == 1) {
List<SitePdu> sitePduList = jsonObject.getJSONObject("data").getObject("data", new TypeReference<List<SitePdu>>() {
});
SitePdu sitePdu = new SitePdu();
sitePdu.setSize(-1);
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
if (resp.getCode() == 1) {
List<SitePdu> sitePduList = resp.getData().getData();
sitePduList.stream().forEach(sitePdu -> {
cacheService.hset(KEY_SITE_CACHE, sitePdu.getId().toString(), sitePdu.getSiteName());
sitePduList.stream().forEach(site -> {
cacheService.hset(KEY_SITE_CACHE, site.getId().toString(), site.getSiteName());
});
}
......
......@@ -102,7 +102,9 @@ public class DeviceTotalStatTaskImpl implements ITaskExcuteService {
deviceStatEntity.setDeviceAddCount(deviceTotalCount - yesterdayDeviceStat.getDeviceTotalCount());
//站点数量
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(new SitePdu());
SitePdu sitePdu = new SitePdu();
sitePdu.setSize(-1);
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
if(resp.getCode()==1) {
List<SitePdu> sitePduList = resp.getData().getData();
......
......@@ -14,6 +14,7 @@ import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.DeviceMethodEnum;
import com.mortals.xhx.common.code.DeviceStatusEnum;
import com.mortals.xhx.common.key.ParamKey;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.site.SitePdu;
import com.mortals.xhx.feign.site.ISiteFeign;
import com.mortals.xhx.module.device.model.DeviceLogEntity;
......@@ -49,15 +50,13 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
private ISiteFeign siteFeign;
@Override
public void excuteTask(ITask task) throws AppException {
String resp = siteFeign.list(new SitePdu());
JSONObject jsonObject = JSONObject.parseObject(resp);
if (jsonObject.getInteger("code") == 1) {
List<SitePdu> sitePduList = jsonObject.getJSONObject("data").getObject("data", new TypeReference<List<SitePdu>>() {
});
SitePdu sitePdu = new SitePdu();
sitePdu.setSize(-1);
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
if (resp.getCode() == 1) {
List<SitePdu> sitePduList = resp.getData().getData();
sitePduList.stream().forEach(site -> {
SitestatEntity sitestatEntity = new SitestatEntity();
sitestatEntity.initAttrValue();
......@@ -67,6 +66,7 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
sitestatService.updateSiteStat(sitestatEntity, null);
});
}
}
......
......@@ -3,10 +3,12 @@ package com.mortals.xhx.module.sitestat.web;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.IAuthTokenService;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.site.SitePdu;
import com.mortals.xhx.common.pdu.user.UserPdu;
import com.mortals.xhx.feign.site.ISiteFeign;
......@@ -20,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
......@@ -113,8 +116,8 @@ public class SitestatController extends BaseCRUDJsonBodyMappingController<Sitest
SitePdu sitePdu = new SitePdu();
sitePdu.setPage(1);
sitePdu.setSize(-1);
String siteListResp = siteFeign.list(sitePdu);
return siteListResp;
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
return JSON.toJSONString(resp);
} catch (Exception e) {
log.error("站点异常", e);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
......@@ -134,11 +137,9 @@ public class SitestatController extends BaseCRUDJsonBodyMappingController<Sitest
String busiDesc = this.getModuleDesc() + "获取站点";
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
try {
String resp = siteFeign.info(siteId);
JSONObject respJson = JSON.parseObject(resp);
Integer code = respJson.getInteger("code");
if (code == YesNoEnum.YES.getValue()) {
jsonObject.put(KEY_RESULT_DATA, respJson.getJSONObject("data"));
Rest<SitePdu> resp = siteFeign.info(siteId);
if (resp.getCode() == YesNoEnum.YES.getValue()) {
jsonObject.put(KEY_RESULT_DATA, resp.getData());
}
jsonObject.put(KEY_RESULT_MSG, busiDesc + "成功!");
} catch (Exception e) {
......
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