RtAnalogDataServiceImpl.java 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965
  1. package com.bizmatics.service.impl;
  2. import cn.afterturn.easypoi.excel.ExcelExportUtil;
  3. import cn.afterturn.easypoi.excel.entity.ExportParams;
  4. import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
  5. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  6. import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  7. import com.bizmatics.common.core.exception.BusinessException;
  8. import com.bizmatics.common.core.util.*;
  9. import com.bizmatics.common.mvc.base.AbstractCrudService;
  10. import com.bizmatics.common.spring.util.GlobalUtils;
  11. import com.bizmatics.model.*;
  12. import com.bizmatics.persistence.mapper.RtAnalogDataMapper;
  13. import com.bizmatics.service.DeviceAttributeService;
  14. import com.bizmatics.service.DeviceService;
  15. import com.bizmatics.service.RtAnalogDataService;
  16. import com.bizmatics.service.SiteDynamicPropertiesService;
  17. import com.bizmatics.service.util.SecurityUtils;
  18. import com.bizmatics.service.vo.RadCountVO;
  19. import com.bizmatics.service.vo.RealScoreVO;
  20. import org.apache.commons.lang3.ArrayUtils;
  21. import org.apache.poi.ss.usermodel.Workbook;
  22. import org.springframework.beans.factory.annotation.Autowired;
  23. import org.springframework.stereotype.Service;
  24. import java.io.File;
  25. import java.io.FileNotFoundException;
  26. import java.io.FileOutputStream;
  27. import java.io.IOException;
  28. import java.util.*;
  29. import java.util.concurrent.atomic.AtomicReference;
  30. /**
  31. * <p>
  32. * 服务实现类
  33. * </p>
  34. *
  35. * @author ya
  36. * @since 2021-07-07
  37. */
  38. @Service
  39. public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMapper, RtAnalogData> implements RtAnalogDataService {
  40. @Autowired
  41. private DeviceService deviceService;
  42. @Autowired
  43. private SiteDynamicPropertiesService siteDynamicPropertiesService;
  44. @Autowired
  45. private DeviceAttributeService deviceAttributeService;
  46. @Override
  47. public RadCountVO selectCount() {
  48. Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
  49. AtomicReference<Integer> heavyLoad = new AtomicReference<>(0);
  50. AtomicReference<Integer> easyLoad = new AtomicReference<>(0);
  51. AtomicReference<Integer> norMalLoad = new AtomicReference<>(0);
  52. AtomicReference<Integer> count = new AtomicReference<>(0);
  53. List<Device> deviceList = deviceService.list(userId, null, null, null, null, null);
  54. List<RtAnalogData> list = baseMapper.list(userId);
  55. for (Device device : deviceList) {
  56. list.stream()
  57. .filter(rtAnalogData -> device.getDeviceCode().equals(rtAnalogData.getDeviceName())).findAny()
  58. .ifPresent(rtAnalogData -> {
  59. String installedCapacity = device.getInstalledCapacity();
  60. double installedCapacityDouble = 0.00;
  61. if (StringUtils.isNotBlank(installedCapacity)) {
  62. installedCapacityDouble = Double.parseDouble(installedCapacity);
  63. if (installedCapacityDouble > 0) {
  64. installedCapacityDouble = Arith.div(rtAnalogData.getP(), installedCapacityDouble);
  65. }
  66. }
  67. if (installedCapacityDouble < 0.4) {
  68. easyLoad.getAndSet(easyLoad.get() + 1);
  69. } else if (installedCapacityDouble >= 0.4 && installedCapacityDouble <= 0.8) {
  70. norMalLoad.getAndSet(norMalLoad.get() + 1);
  71. } else {
  72. heavyLoad.getAndSet(heavyLoad.get() + 1);
  73. }
  74. count.getAndSet(count.get() + 1);
  75. });
  76. }
  77. RadCountVO radCountVO = new RadCountVO();
  78. radCountVO.setHeavyLoad(subRadio(heavyLoad.get(), count.get()));
  79. radCountVO.setEasyLoad(subRadio(easyLoad.get(), count.get()));
  80. radCountVO.setNorMalLoad(Arith.sub(1, Arith.add(radCountVO.getEasyLoad(), radCountVO.getHeavyLoad())));
  81. return radCountVO;
  82. }
  83. public Double subRadio(Integer typeCount, Integer count) {
  84. return Optional.of(count).filter(total -> total != 0).map(sub -> Arith.div(typeCount, sub)).orElse(0.00);
  85. }
  86. @Override
  87. public List<Map<String, Object>> getOne(Integer siteId) {
  88. List<Map<String, Object>> list = new ArrayList<>();
  89. Map<String, Object> radMap = baseMapper.getOneMap(siteId);
  90. Optional.ofNullable(radMap).ifPresent(rad -> {
  91. for (String name : rad.keySet()) {
  92. Map<String, Object> map = new HashMap<>();
  93. map.put("name", name);
  94. map.put("value", rad.get(name));
  95. list.add(map);
  96. }
  97. });
  98. return list;
  99. }
  100. @Override
  101. public Double getEpLoad(Integer siteId) {
  102. Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
  103. return baseMapper.selectTotalLoad(userId, siteId);
  104. }
  105. @Override
  106. public List<String> realScore(String deviceName) {
  107. LambdaQueryWrapper<RtAnalogData> queryWrapper = Wrappers.lambdaQuery();
  108. queryWrapper.eq(RtAnalogData::getDeviceName,deviceName);
  109. RtAnalogData rtAnalogData = getOne(queryWrapper);
  110. return null;
  111. }
  112. /**
  113. * 填充实时数据
  114. */
  115. public void fillRealScoreData(RtAnalogData rtAnalogData, SiteDynamicProperties siteDynamicProperties,DeviceAttribute deviceAttribute){
  116. List<Double> checkList = new ArrayList<>();
  117. RealScoreVO realScoreVo = BeanMapperUtils.map(rtAnalogData, RealScoreVO.class);
  118. checkList.add(realScoreVo.getIa());
  119. checkList.add(realScoreVo.getIb());
  120. checkList.add(realScoreVo.getIc());
  121. //电流不平衡
  122. realScoreVo.setElBalun(checkBalun(checkList));
  123. checkList.clear();
  124. checkList.add(realScoreVo.getUa());
  125. checkList.add(realScoreVo.getUb());
  126. checkList.add(realScoreVo.getUc());
  127. //电压不平衡
  128. realScoreVo.setVtBalun(checkBalun(checkList));
  129. //电压合格率
  130. realScoreVo.setUaQualified(Arith.sub(rtAnalogData.getUa(), Double.parseDouble(siteDynamicProperties.getVoltageLevel())));
  131. realScoreVo.setUbQualified(Arith.sub(rtAnalogData.getUb(), Double.parseDouble(siteDynamicProperties.getVoltageLevel())));
  132. realScoreVo.setUcQualified(Arith.sub(rtAnalogData.getUc(), Double.parseDouble(siteDynamicProperties.getVoltageLevel())));
  133. //电流负载率
  134. realScoreVo.setIaLoad(Arith.div(realScoreVo.getIa(),deviceAttribute.getRatedCurrent()));
  135. realScoreVo.setIbLoad(Arith.div(realScoreVo.getIb(),deviceAttribute.getRatedCurrent()));
  136. realScoreVo.setIcLoad(Arith.div(realScoreVo.getIc(),deviceAttribute.getRatedCurrent()));
  137. //金
  138. }
  139. /**
  140. * 计算电流/电压不平衡
  141. * @param list
  142. * @return
  143. */
  144. public Double checkBalun(List<Double> list){
  145. Double max = list.stream().max(Double::compareTo).get();
  146. Double min = list.stream().min(Double::compareTo).get();
  147. return Arith.div(Arith.sub(max,min),max);
  148. }
  149. /**
  150. * 添加数据单位
  151. *
  152. * @return
  153. */
  154. public String addUnit(String name, String value) {
  155. if (name.endsWith("电压")) {
  156. return value + "V";
  157. } else if (name.endsWith("电流")) {
  158. return value + "A";
  159. } else if (name.endsWith("温度")) {
  160. return value + "C";
  161. } else if (name.endsWith("频率")) {
  162. return value + "Hz";
  163. } else if (name.endsWith("有功功率") || name.endsWith("需量")) {
  164. return value + "KW";
  165. } else if (name.endsWith("无功功率")) {
  166. return value + "KVar";
  167. } else if (name.endsWith("不平衡度") || name.endsWith("电压畸变率")) {
  168. return value + "%";
  169. } else if (name.endsWith("次数")) {
  170. return value + "次";
  171. } else if (name.endsWith("电度") || name.endsWith("有功")) {
  172. return value + "KWh";
  173. }
  174. return value;
  175. }
  176. @Override
  177. public List<Map<String, Object>> getDataReport(Integer siteId, Date startTime, Date endTime, String queryType) {
  178. List<Map<String, Object>> list = new ArrayList<>();
  179. List<HtAnalogData> rtAnalogDataList = null;
  180. long diff = endTime.getTime() - startTime.getTime();
  181. long days = diff / (1000 * 60 * 60);
  182. if (days <= 24) {
  183. rtAnalogDataList = baseMapper.getDataReportMap(siteId, startTime, endTime);
  184. } else if (days < 360 && days > 24) {
  185. List<Device> device_list = baseMapper.getDeviceListMap(siteId);
  186. rtAnalogDataList = baseMapper.getDataReportMMap(device_list, startTime, endTime);
  187. } else if (days >= 360) {
  188. List<Device> device_list = baseMapper.getDeviceListMap(siteId);
  189. rtAnalogDataList = baseMapper.getDataReportDMap(device_list, startTime, endTime);
  190. }
  191. String[] result = queryType.split(",");
  192. if (rtAnalogDataList.size() > 0) {
  193. rtAnalogDataList.forEach(rtAnalogData -> {
  194. Map<String, Object> map = new HashMap<>();
  195. if (ArrayUtils.contains(result, "I")) {
  196. map.put("Ia", rtAnalogData.getIa());
  197. map.put("Ib", rtAnalogData.getIb());
  198. map.put("Ic", rtAnalogData.getIc());
  199. if (ArrayUtils.contains(result, "P")) {
  200. map.put("P", rtAnalogData.getP());
  201. map.put("Q", rtAnalogData.getQ());
  202. map.put("Pa", rtAnalogData.getPa());
  203. map.put("Pb", rtAnalogData.getPb());
  204. map.put("Pc", rtAnalogData.getPc());
  205. map.put("Qa", rtAnalogData.getQa());
  206. map.put("Qb", rtAnalogData.getQb());
  207. map.put("Qc", rtAnalogData.getQc());
  208. map.put("Demand", rtAnalogData.getDemand());
  209. if (ArrayUtils.contains(result, "KWh")) {
  210. map.put("Epn", rtAnalogData.getEpn());
  211. map.put("Epp", rtAnalogData.getEpp());
  212. map.put("Eqn", rtAnalogData.getEqn());
  213. map.put("Eqp", rtAnalogData.getEqp());
  214. if (ArrayUtils.contains(result, "V")) {
  215. map.put("Ua", rtAnalogData.getUa());
  216. map.put("Ub", rtAnalogData.getUb());
  217. map.put("Uc", rtAnalogData.getUc());
  218. map.put("Uab", rtAnalogData.getUab());
  219. map.put("Ubc", rtAnalogData.getUbc());
  220. map.put("Uca", rtAnalogData.getUca());
  221. map.put("Ul", rtAnalogData.getUl());
  222. if (ArrayUtils.contains(result, "C")) {
  223. map.put("T1", rtAnalogData.getT1());
  224. map.put("T2", rtAnalogData.getT2());
  225. map.put("T3", rtAnalogData.getT3());
  226. map.put("T4", rtAnalogData.getT4());
  227. map.put("DeviceTemp", rtAnalogData.getDeviceTemp());
  228. if (ArrayUtils.contains(result, "HZ")) {
  229. map.put("F", rtAnalogData.getF());
  230. if (ArrayUtils.contains(result, "PS")) {
  231. map.put("COSa", rtAnalogData.getCOSa());
  232. map.put("COSb", rtAnalogData.getCOSb());
  233. map.put("COSc", rtAnalogData.getCOSc());
  234. map.put("COS", rtAnalogData.getCos());
  235. if (ArrayUtils.contains(result, "RMS")) {
  236. map.put("IHa", rtAnalogData.getIHa());
  237. map.put("IHb", rtAnalogData.getIHb());
  238. map.put("IHc", rtAnalogData.getIHc());
  239. if (ArrayUtils.contains(result, "DDB")) {
  240. map.put("SignalIntensity", rtAnalogData.getSignalIntensity());
  241. if (ArrayUtils.contains(result, "VT")) {
  242. map.put("Upt", rtAnalogData.getUpt());
  243. map.put("Udt", rtAnalogData.getUdt());
  244. map.put("Ust", rtAnalogData.getUst());
  245. }
  246. }
  247. }
  248. }
  249. }
  250. }
  251. }
  252. }
  253. }
  254. }
  255. if (days <= 24) {
  256. map.put("dataTime", DateUtils.format(rtAnalogData.getDataTime(), "MM-dd HH:mm"));
  257. } else if (days < 360 && days > 24) {
  258. map.put("dataTime", DateUtils.format(rtAnalogData.getDataTime(), "MM-dd HH:mm"));
  259. } else if (days >= 360) {
  260. map.put("dataTime", DateUtils.format(rtAnalogData.getDataTime(), DateUtils.PARSE_PATTERNS[8]));
  261. }
  262. list.add(map);
  263. });
  264. }
  265. return list;
  266. }
  267. @Override
  268. public List<Map<String, Object>> getHistoricalCurve(Integer siteId, Date startTime, Date endTime, String queryType) {
  269. List<Map<String, Object>> list = new ArrayList<>();
  270. List<Map<String, Object>> listdataTime = new ArrayList<>();
  271. List<Map<String, Object>> list1 = new ArrayList<>();
  272. List<Map<String, Object>> list2 = new ArrayList<>();
  273. List<Map<String, Object>> list3 = new ArrayList<>();
  274. List<Map<String, Object>> list4 = new ArrayList<>();
  275. List<Map<String, Object>> list5 = new ArrayList<>();
  276. List<Map<String, Object>> list6 = new ArrayList<>();
  277. List<Map<String, Object>> list7 = new ArrayList<>();
  278. List<Map<String, Object>> list8 = new ArrayList<>();
  279. List<Map<String, Object>> list9 = new ArrayList<>();
  280. List<HtAnalogData> rtAnalogDataList = null;
  281. long diff = endTime.getTime() - startTime.getTime();
  282. long days = diff / (1000 * 60 * 60);
  283. if (days <= 24) {
  284. rtAnalogDataList = baseMapper.getDataReportMap(siteId, startTime, endTime);
  285. } else if (days < 360 && days > 24) {
  286. List<Device> device_list = baseMapper.getDeviceListMap(siteId);
  287. rtAnalogDataList = baseMapper.getDataReportMMap(device_list, startTime, endTime);
  288. } else if (days >= 360) {
  289. List<Device> device_list = baseMapper.getDeviceListMap(siteId);
  290. rtAnalogDataList = baseMapper.getDataReportDMap(device_list, startTime, endTime);
  291. }
  292. String[] result = queryType.split(",");
  293. if (rtAnalogDataList.size() > 0) {
  294. Map<String, Object> mapIe1 = new HashMap<>();
  295. Map<String, Object> mapIe2 = new HashMap<>();
  296. Map<String, Object> mapIe3 = new HashMap<>();
  297. Map<String, Object> mapIe4 = new HashMap<>();
  298. Map<String, Object> mapIe5 = new HashMap<>();
  299. Map<String, Object> mapIe6 = new HashMap<>();
  300. Map<String, Object> mapIe7 = new HashMap<>();
  301. Map<String, Object> mapIe8 = new HashMap<>();
  302. Map<String, Object> mapIe9 = new HashMap<>();
  303. for (int i = 0; i < rtAnalogDataList.size(); i++) {
  304. Map<String, Object> map = new HashMap<>();
  305. Map<String, Object> map1 = new HashMap<>();
  306. Map<String, Object> map2 = new HashMap<>();
  307. Map<String, Object> map3 = new HashMap<>();
  308. Map<String, Object> map4 = new HashMap<>();
  309. Map<String, Object> map5 = new HashMap<>();
  310. Map<String, Object> map6 = new HashMap<>();
  311. Map<String, Object> map7 = new HashMap<>();
  312. Map<String, Object> map8 = new HashMap<>();
  313. Map<String, Object> map9 = new HashMap<>();
  314. HtAnalogData rtAnalogData = (HtAnalogData) rtAnalogDataList.get(i);
  315. // if (days<=24){
  316. // map.put("dataTime",DateUtils.format(rtAnalogData.getDataTime(),"MM-dd HH:mm"));
  317. // }else if (days<360&&days>24){
  318. // map.put("dataTime", DateUtils.format(rtAnalogData.getDataTime(),"MM-dd HH:mm"));
  319. // }else if (days>=360){
  320. // map.put("dataTime",DateUtils.format(rtAnalogData.getDataTime(),DateUtils.PARSE_PATTERNS[8]));
  321. // }
  322. map.put("dataTime", rtAnalogData.getDataTime());
  323. if (ArrayUtils.contains(result, "I")) {
  324. map1.put("Ia", rtAnalogData.getIa());
  325. map2.put("Ib", rtAnalogData.getIb());
  326. map3.put("Ic", rtAnalogData.getIc());
  327. } else if (ArrayUtils.contains(result, "P")) {
  328. map1.put("P", rtAnalogData.getP());
  329. map2.put("Q", rtAnalogData.getQ());
  330. map3.put("Pa", rtAnalogData.getPa());
  331. map4.put("Pb", rtAnalogData.getPb());
  332. map5.put("Pc", rtAnalogData.getPc());
  333. map6.put("Qa", rtAnalogData.getQa());
  334. map7.put("Qb", rtAnalogData.getQb());
  335. map8.put("Qc", rtAnalogData.getQc());
  336. map9.put("Demand", rtAnalogData.getDemand());
  337. } else if (ArrayUtils.contains(result, "KWh")) {
  338. map1.put("Epn", rtAnalogData.getEpn());
  339. map2.put("Epp", rtAnalogData.getEpp());
  340. map3.put("Eqn", rtAnalogData.getEqn());
  341. map4.put("Eqp", rtAnalogData.getEqp());
  342. } else if (ArrayUtils.contains(result, "V")) {
  343. map1.put("Ua", rtAnalogData.getUa());
  344. map2.put("Ub", rtAnalogData.getUb());
  345. map3.put("Uc", rtAnalogData.getUc());
  346. map4.put("Uab", rtAnalogData.getUab());
  347. map5.put("Ubc", rtAnalogData.getUbc());
  348. map6.put("Uca", rtAnalogData.getUca());
  349. map7.put("Ul", rtAnalogData.getUl());
  350. } else if (ArrayUtils.contains(result, "C")) {
  351. map1.put("T1", rtAnalogData.getT1());
  352. map2.put("T2", rtAnalogData.getT2());
  353. map3.put("T3", rtAnalogData.getT3());
  354. map4.put("T4", rtAnalogData.getT4());
  355. map5.put("DeviceTemp", rtAnalogData.getDeviceTemp());
  356. } else if (ArrayUtils.contains(result, "HZ")) {
  357. map1.put("F", rtAnalogData.getF());
  358. } else if (ArrayUtils.contains(result, "PS")) {
  359. map1.put("COSa", rtAnalogData.getCOSa());
  360. map2.put("COSb", rtAnalogData.getCOSb());
  361. map3.put("COSc", rtAnalogData.getCOSc());
  362. map4.put("COS", rtAnalogData.getCos());
  363. } else if (ArrayUtils.contains(result, "RMS")) {
  364. map1.put("IHa", rtAnalogData.getIHa());
  365. map2.put("IHb", rtAnalogData.getIHb());
  366. map3.put("IHc", rtAnalogData.getIHc());
  367. } else if (ArrayUtils.contains(result, "DDB")) {
  368. map1.put("SignalIntensity", rtAnalogData.getSignalIntensity());
  369. } else if (ArrayUtils.contains(result, "VT")) {
  370. map1.put("Upt", rtAnalogData.getUpt());
  371. map2.put("Udt", rtAnalogData.getUdt());
  372. map3.put("Ust", rtAnalogData.getUst());
  373. }
  374. listdataTime.add(map);
  375. list1.add(map1);
  376. list2.add(map2);
  377. list3.add(map3);
  378. list4.add(map4);
  379. list5.add(map5);
  380. list6.add(map6);
  381. list7.add(map7);
  382. list8.add(map8);
  383. list9.add(map9);
  384. }
  385. Object arre1[][] = new Object[listdataTime.size()][2];
  386. Object arre2[][] = new Object[listdataTime.size()][2];
  387. Object arre3[][] = new Object[listdataTime.size()][2];
  388. Object arre4[][] = new Object[listdataTime.size()][2];
  389. Object arre5[][] = new Object[listdataTime.size()][2];
  390. Object arre6[][] = new Object[listdataTime.size()][2];
  391. Object arre7[][] = new Object[listdataTime.size()][2];
  392. Object arre8[][] = new Object[listdataTime.size()][2];
  393. Object arre9[][] = new Object[listdataTime.size()][2];
  394. if (ArrayUtils.contains(result, "I")) {
  395. for (int i = 0; i < listdataTime.size(); i++) {
  396. arre1[i][0] = listdataTime.get(i).get("dataTime");
  397. arre1[i][1] = list1.get(i).get("Ia");
  398. arre2[i][0] = listdataTime.get(i).get("dataTime");
  399. arre2[i][1] = list2.get(i).get("Ib");
  400. arre3[i][0] = listdataTime.get(i).get("dataTime");
  401. arre3[i][1] = list3.get(i).get("Ic");
  402. }
  403. mapIe1.put("name", "A相电流");
  404. mapIe1.put("arr", arre1);
  405. mapIe2.put("name", "B相电流");
  406. mapIe2.put("arr", arre2);
  407. mapIe3.put("name", "C相电流");
  408. mapIe3.put("arr", arre3);
  409. list.add(mapIe1);
  410. list.add(mapIe2);
  411. list.add(mapIe3);
  412. } else if (ArrayUtils.contains(result, "P")) {
  413. for (int i = 0; i < listdataTime.size(); i++) {
  414. arre1[i][0] = listdataTime.get(i).get("dataTime");
  415. arre1[i][1] = list1.get(i).get("P");
  416. arre2[i][0] = listdataTime.get(i).get("dataTime");
  417. arre2[i][1] = list2.get(i).get("Q");
  418. arre3[i][0] = listdataTime.get(i).get("dataTime");
  419. arre3[i][1] = list3.get(i).get("Pa");
  420. arre4[i][0] = listdataTime.get(i).get("dataTime");
  421. arre4[i][1] = list4.get(i).get("Pb");
  422. arre5[i][0] = listdataTime.get(i).get("dataTime");
  423. arre5[i][1] = list5.get(i).get("Pc");
  424. arre6[i][0] = listdataTime.get(i).get("dataTime");
  425. arre6[i][1] = list6.get(i).get("Qa");
  426. arre7[i][0] = listdataTime.get(i).get("dataTime");
  427. arre7[i][1] = list7.get(i).get("Qb");
  428. arre8[i][0] = listdataTime.get(i).get("dataTime");
  429. arre8[i][1] = list8.get(i).get("Qc");
  430. arre9[i][0] = listdataTime.get(i).get("dataTime");
  431. arre9[i][1] = list9.get(i).get("Demand");
  432. }
  433. mapIe1.put("name", "总有功功率");
  434. mapIe1.put("arr", arre1);
  435. mapIe2.put("name", "总无功功率");
  436. mapIe2.put("arr", arre2);
  437. mapIe3.put("name", "A相有功功率");
  438. mapIe3.put("arr", arre3);
  439. mapIe4.put("name", "B相有功功率");
  440. mapIe4.put("arr", arre4);
  441. mapIe5.put("name", "C相有功功率");
  442. mapIe5.put("arr", arre5);
  443. mapIe6.put("name", "A相无功功率");
  444. mapIe6.put("arr", arre6);
  445. mapIe7.put("name", "B相无功功率");
  446. mapIe7.put("arr", arre7);
  447. mapIe8.put("name", "C相无功功率");
  448. mapIe8.put("arr", arre8);
  449. mapIe9.put("name", "实时需量");
  450. mapIe9.put("arr", arre9);
  451. list.add(mapIe1);
  452. list.add(mapIe2);
  453. list.add(mapIe3);
  454. list.add(mapIe4);
  455. list.add(mapIe5);
  456. list.add(mapIe6);
  457. list.add(mapIe7);
  458. list.add(mapIe8);
  459. list.add(mapIe9);
  460. } else if (ArrayUtils.contains(result, "KWh")) {
  461. for (int i = 0; i < listdataTime.size(); i++) {
  462. arre1[i][0] = listdataTime.get(i).get("dataTime");
  463. arre1[i][1] = list1.get(i).get("Epn");
  464. arre2[i][0] = listdataTime.get(i).get("dataTime");
  465. arre2[i][1] = list2.get(i).get("Epp");
  466. arre3[i][0] = listdataTime.get(i).get("dataTime");
  467. arre3[i][1] = list3.get(i).get("Eqn");
  468. arre4[i][0] = listdataTime.get(i).get("dataTime");
  469. arre4[i][1] = list4.get(i).get("Eqp");
  470. }
  471. mapIe1.put("name", "负有功电度");
  472. mapIe1.put("arr", arre1);
  473. mapIe2.put("name", "正有功电度");
  474. mapIe2.put("arr", arre2);
  475. mapIe3.put("name", "负无功电度");
  476. mapIe3.put("arr", arre3);
  477. mapIe4.put("name", "正无功电度");
  478. mapIe4.put("arr", arre4);
  479. list.add(mapIe1);
  480. list.add(mapIe2);
  481. list.add(mapIe3);
  482. list.add(mapIe4);
  483. } else if (ArrayUtils.contains(result, "V")) {
  484. for (int i = 0; i < listdataTime.size(); i++) {
  485. arre1[i][0] = listdataTime.get(i).get("dataTime");
  486. arre1[i][1] = list1.get(i).get("Ua");
  487. arre2[i][0] = listdataTime.get(i).get("dataTime");
  488. arre2[i][1] = list2.get(i).get("Ub");
  489. arre3[i][0] = listdataTime.get(i).get("dataTime");
  490. arre3[i][1] = list3.get(i).get("Uc");
  491. arre4[i][0] = listdataTime.get(i).get("dataTime");
  492. arre4[i][1] = list4.get(i).get("Uab");
  493. arre5[i][0] = listdataTime.get(i).get("dataTime");
  494. arre5[i][1] = list5.get(i).get("Ubc");
  495. arre6[i][0] = listdataTime.get(i).get("dataTime");
  496. arre6[i][1] = list6.get(i).get("Uca");
  497. arre7[i][0] = listdataTime.get(i).get("dataTime");
  498. arre7[i][1] = list7.get(i).get("Ul");
  499. }
  500. mapIe1.put("name", "A相电压");
  501. mapIe1.put("arr", arre1);
  502. mapIe2.put("name", "B相电压");
  503. mapIe2.put("arr", arre2);
  504. mapIe3.put("name", "C相电压");
  505. mapIe3.put("arr", arre3);
  506. mapIe4.put("name", "AB线电压");
  507. mapIe4.put("arr", arre4);
  508. mapIe5.put("name", "BC线电压");
  509. mapIe5.put("arr", arre5);
  510. mapIe6.put("name", "CA线电压");
  511. mapIe6.put("arr", arre6);
  512. mapIe7.put("name", "回路电压");
  513. mapIe7.put("arr", arre7);
  514. list.add(mapIe1);
  515. list.add(mapIe2);
  516. list.add(mapIe3);
  517. list.add(mapIe4);
  518. list.add(mapIe5);
  519. list.add(mapIe6);
  520. list.add(mapIe7);
  521. } else if (ArrayUtils.contains(result, "C")) {
  522. for (int i = 0; i < listdataTime.size(); i++) {
  523. arre1[i][0] = listdataTime.get(i).get("dataTime");
  524. arre1[i][1] = list1.get(i).get("T1");
  525. arre2[i][0] = listdataTime.get(i).get("dataTime");
  526. arre2[i][1] = list2.get(i).get("T2");
  527. arre3[i][0] = listdataTime.get(i).get("dataTime");
  528. arre3[i][1] = list3.get(i).get("T3");
  529. arre4[i][0] = listdataTime.get(i).get("dataTime");
  530. arre4[i][1] = list4.get(i).get("T4");
  531. arre5[i][0] = listdataTime.get(i).get("dataTime");
  532. arre5[i][1] = list5.get(i).get("DeviceTemp");
  533. }
  534. mapIe1.put("name", "外接温度1");
  535. mapIe1.put("arr", arre1);
  536. mapIe2.put("name", "外接温度1");
  537. mapIe2.put("arr", arre2);
  538. mapIe3.put("name", "外接温度1");
  539. mapIe3.put("arr", arre3);
  540. mapIe4.put("name", "外接温度1");
  541. mapIe4.put("arr", arre4);
  542. mapIe5.put("name", "环境温度");
  543. mapIe5.put("arr", arre5);
  544. list.add(mapIe1);
  545. list.add(mapIe2);
  546. list.add(mapIe3);
  547. list.add(mapIe4);
  548. list.add(mapIe5);
  549. } else if (ArrayUtils.contains(result, "HZ")) {
  550. for (int i = 0; i < listdataTime.size(); i++) {
  551. arre1[i][0] = listdataTime.get(i).get("dataTime");
  552. arre1[i][1] = list1.get(i).get("F");
  553. }
  554. mapIe1.put("name", "频率");
  555. mapIe1.put("arr", arre1);
  556. list.add(mapIe1);
  557. } else if (ArrayUtils.contains(result, "PS")) {
  558. for (int i = 0; i < listdataTime.size(); i++) {
  559. arre1[i][0] = listdataTime.get(i).get("dataTime");
  560. arre1[i][1] = list1.get(i).get("COSa");
  561. arre2[i][0] = listdataTime.get(i).get("dataTime");
  562. arre2[i][1] = list2.get(i).get("COSb");
  563. arre3[i][0] = listdataTime.get(i).get("dataTime");
  564. arre3[i][1] = list3.get(i).get("COSc");
  565. arre4[i][0] = listdataTime.get(i).get("dataTime");
  566. arre4[i][1] = list4.get(i).get("COS");
  567. }
  568. mapIe1.put("name", "A相功率因数");
  569. mapIe1.put("arr", arre1);
  570. mapIe2.put("name", "B相功率因数");
  571. mapIe2.put("arr", arre2);
  572. mapIe3.put("name", "C相功率因数");
  573. mapIe3.put("arr", arre3);
  574. mapIe4.put("name", "功率因数");
  575. mapIe4.put("arr", arre4);
  576. list.add(mapIe1);
  577. list.add(mapIe2);
  578. list.add(mapIe3);
  579. list.add(mapIe4);
  580. } else if (ArrayUtils.contains(result, "RMS")) {
  581. for (int i = 0; i < listdataTime.size(); i++) {
  582. arre1[i][0] = listdataTime.get(i).get("dataTime");
  583. arre1[i][1] = list1.get(i).get("IHa");
  584. arre2[i][0] = listdataTime.get(i).get("dataTime");
  585. arre2[i][1] = list2.get(i).get("IHb");
  586. arre3[i][0] = listdataTime.get(i).get("dataTime");
  587. arre3[i][1] = list3.get(i).get("IHc");
  588. }
  589. mapIe1.put("name", "Ia总谐波电流");
  590. mapIe1.put("arr", arre1);
  591. mapIe2.put("name", "Ib总谐波电流");
  592. mapIe2.put("arr", arre2);
  593. mapIe3.put("name", "Ic总谐波电流");
  594. mapIe3.put("arr", arre3);
  595. list.add(mapIe1);
  596. list.add(mapIe2);
  597. list.add(mapIe3);
  598. } else if (ArrayUtils.contains(result, "DDB")) {
  599. for (int i = 0; i < listdataTime.size(); i++) {
  600. arre1[i][0] = listdataTime.get(i).get("dataTime");
  601. arre1[i][1] = list1.get(i).get("SignalIntensity");
  602. }
  603. mapIe1.put("name", "设备信号强度");
  604. mapIe1.put("arr", arre1);
  605. list.add(mapIe1);
  606. } else if (ArrayUtils.contains(result, "VT")) {
  607. for (int i = 0; i < listdataTime.size(); i++) {
  608. arre1[i][0] = listdataTime.get(i).get("dataTime");
  609. arre1[i][1] = list1.get(i).get("Upt");
  610. arre2[i][0] = listdataTime.get(i).get("dataTime");
  611. arre2[i][1] = list2.get(i).get("Udt");
  612. arre3[i][0] = listdataTime.get(i).get("dataTime");
  613. arre3[i][1] = list3.get(i).get("Ust");
  614. }
  615. mapIe1.put("name", "电压暂升次数");
  616. mapIe1.put("arr", arre1);
  617. mapIe2.put("name", "电压暂降次数");
  618. mapIe2.put("arr", arre2);
  619. mapIe3.put("name", "电压中断次数");
  620. mapIe3.put("arr", arre3);
  621. list.add(mapIe1);
  622. list.add(mapIe2);
  623. list.add(mapIe3);
  624. }
  625. }
  626. return list;
  627. }
  628. @Override
  629. public String DataReportExport(Integer siteId, Date startTime, Date endTime, String queryType) {
  630. Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
  631. Workbook workbook = null;
  632. File file = null;
  633. long diff = endTime.getTime() - startTime.getTime();
  634. long days = diff / (1000 * 60 * 60);
  635. ExportParams params = new ExportParams("数据报表", "数据报表");
  636. List<HtAnalogData> page1 = null;
  637. if (days <= 24) {
  638. page1 = baseMapper.getDataReportMap(siteId, startTime, endTime);
  639. } else if (days < 360 && days > 24) {
  640. List<Device> device_list = baseMapper.getDeviceListMap(siteId);
  641. page1 = baseMapper.getDataReportMMap(device_list, startTime, endTime);
  642. } else if (days >= 360) {
  643. List<Device> device_list = baseMapper.getDeviceListMap(siteId);
  644. page1 = baseMapper.getDataReportDMap(device_list, startTime, endTime);
  645. }
  646. String[] result = queryType.split(",");
  647. try {
  648. List<ExcelExportEntity> colList = new ArrayList<ExcelExportEntity>();
  649. ExcelExportEntity colEntity = new ExcelExportEntity("序号", "xh");
  650. colEntity.setNeedMerge(true);
  651. colList.add(colEntity);
  652. colEntity = new ExcelExportEntity("时间", "dataTime");
  653. colEntity.setNeedMerge(true);
  654. colList.add(colEntity);
  655. if (ArrayUtils.contains(result, "I")) {
  656. colEntity = new ExcelExportEntity("A相电流", "Ia");
  657. colEntity.setNeedMerge(true);
  658. colList.add(colEntity);
  659. colEntity = new ExcelExportEntity("B相电流", "Ib");
  660. colEntity.setNeedMerge(true);
  661. colList.add(colEntity);
  662. colEntity = new ExcelExportEntity("C相电流", "Ic");
  663. colEntity.setNeedMerge(true);
  664. colList.add(colEntity);
  665. if (ArrayUtils.contains(result, "P")) {
  666. colEntity = new ExcelExportEntity("总有功功率", "P");
  667. colEntity.setNeedMerge(true);
  668. colList.add(colEntity);
  669. colEntity = new ExcelExportEntity("总无功功率", "Q");
  670. colEntity.setNeedMerge(true);
  671. colList.add(colEntity);
  672. colEntity = new ExcelExportEntity("A相有功功率", "Pa");
  673. colEntity.setNeedMerge(true);
  674. colList.add(colEntity);
  675. colEntity = new ExcelExportEntity("B相有功功率", "Pb");
  676. colEntity.setNeedMerge(true);
  677. colList.add(colEntity);
  678. colEntity = new ExcelExportEntity("C相有功功率", "Pc");
  679. colEntity.setNeedMerge(true);
  680. colList.add(colEntity);
  681. colEntity = new ExcelExportEntity("A相无功功率", "Qa");
  682. colEntity.setNeedMerge(true);
  683. colList.add(colEntity);
  684. colEntity = new ExcelExportEntity("B相无功功率", "Qb");
  685. colEntity.setNeedMerge(true);
  686. colList.add(colEntity);
  687. colEntity = new ExcelExportEntity("C相无功功率", "Qc");
  688. colEntity.setNeedMerge(true);
  689. colList.add(colEntity);
  690. colEntity = new ExcelExportEntity("实时需量", "Demand");
  691. colEntity.setNeedMerge(true);
  692. colList.add(colEntity);
  693. if (ArrayUtils.contains(result, "KWh")) {
  694. colEntity = new ExcelExportEntity("负有功电度", "Epn");
  695. colEntity.setNeedMerge(true);
  696. colList.add(colEntity);
  697. colEntity = new ExcelExportEntity("正有功电度", "Epp");
  698. colEntity.setNeedMerge(true);
  699. colList.add(colEntity);
  700. colEntity = new ExcelExportEntity("负无功电度", "Eqn");
  701. colEntity.setNeedMerge(true);
  702. colList.add(colEntity);
  703. colEntity = new ExcelExportEntity("正无功电度", "Eqp");
  704. colEntity.setNeedMerge(true);
  705. colList.add(colEntity);
  706. if (ArrayUtils.contains(result, "V")) {
  707. colEntity = new ExcelExportEntity("A相电压", "Ua");
  708. colEntity.setNeedMerge(true);
  709. colList.add(colEntity);
  710. colEntity = new ExcelExportEntity("B相电压", "Ub");
  711. colEntity.setNeedMerge(true);
  712. colList.add(colEntity);
  713. colEntity = new ExcelExportEntity("C相电压", "Ub");
  714. colEntity.setNeedMerge(true);
  715. colList.add(colEntity);
  716. colEntity = new ExcelExportEntity("AB线电压", "Uab");
  717. colEntity.setNeedMerge(true);
  718. colList.add(colEntity);
  719. colEntity = new ExcelExportEntity("BC线电压", "Ubc");
  720. colEntity.setNeedMerge(true);
  721. colList.add(colEntity);
  722. colEntity = new ExcelExportEntity("CA线电压", "Uca");
  723. colEntity.setNeedMerge(true);
  724. colList.add(colEntity);
  725. colEntity = new ExcelExportEntity("回路电压", "Ul");
  726. colEntity.setNeedMerge(true);
  727. colList.add(colEntity);
  728. if (ArrayUtils.contains(result, "C")) {
  729. colEntity = new ExcelExportEntity("外接温度1", "T1");
  730. colEntity.setNeedMerge(true);
  731. colList.add(colEntity);
  732. colEntity = new ExcelExportEntity("外接温度2", "T2");
  733. colEntity.setNeedMerge(true);
  734. colList.add(colEntity);
  735. colEntity = new ExcelExportEntity("外接温度3", "T3");
  736. colEntity.setNeedMerge(true);
  737. colList.add(colEntity);
  738. colEntity = new ExcelExportEntity("外接温度4", "T4");
  739. colEntity.setNeedMerge(true);
  740. colList.add(colEntity);
  741. colEntity = new ExcelExportEntity("环境温度", "DeviceTemp");
  742. colEntity.setNeedMerge(true);
  743. colList.add(colEntity);
  744. if (ArrayUtils.contains(result, "HZ")) {
  745. colEntity = new ExcelExportEntity("频率", "F");
  746. colEntity.setNeedMerge(true);
  747. colList.add(colEntity);
  748. // map.put("F",rtAnalogData.getF());
  749. if (ArrayUtils.contains(result, "PS")) {
  750. colEntity = new ExcelExportEntity("A相功率因数", "COSa");
  751. colEntity.setNeedMerge(true);
  752. colList.add(colEntity);
  753. colEntity = new ExcelExportEntity("B相功率因数", "COSb");
  754. colEntity.setNeedMerge(true);
  755. colList.add(colEntity);
  756. colEntity = new ExcelExportEntity("C相功率因数", "COSc");
  757. colEntity.setNeedMerge(true);
  758. colList.add(colEntity);
  759. colEntity = new ExcelExportEntity("功率因数", "COS");
  760. colEntity.setNeedMerge(true);
  761. colList.add(colEntity);
  762. if (ArrayUtils.contains(result, "RMS")) {
  763. colEntity = new ExcelExportEntity("Ia总谐波电流", "IHa");
  764. colEntity.setNeedMerge(true);
  765. colList.add(colEntity);
  766. colEntity = new ExcelExportEntity("Ib总谐波电流", "IHb");
  767. colEntity.setNeedMerge(true);
  768. colList.add(colEntity);
  769. colEntity = new ExcelExportEntity("Ic总谐波电流", "IHc");
  770. colEntity.setNeedMerge(true);
  771. colList.add(colEntity);
  772. if (ArrayUtils.contains(result, "DDB")) {
  773. colEntity = new ExcelExportEntity("设备信号强度", "SignalIntensity");
  774. colEntity.setNeedMerge(true);
  775. colList.add(colEntity);
  776. if (ArrayUtils.contains(result, "VT")) {
  777. colEntity = new ExcelExportEntity("电压暂升次数", "Upt");
  778. colEntity.setNeedMerge(true);
  779. colList.add(colEntity);
  780. colEntity = new ExcelExportEntity("电压暂降次数", "Udt");
  781. colEntity.setNeedMerge(true);
  782. colList.add(colEntity);
  783. colEntity = new ExcelExportEntity("电压中断次数", "Ust");
  784. colEntity.setNeedMerge(true);
  785. colList.add(colEntity);
  786. }
  787. }
  788. }
  789. }
  790. }
  791. }
  792. }
  793. }
  794. }
  795. }
  796. List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
  797. for (int i = 0; i < page1.size(); i++) {
  798. Map<String, Object> valMap = new HashMap<String, Object>();
  799. valMap.put("xh", i + 1);
  800. if (days <= 24) {
  801. valMap.put("dataTime", DateUtils.format(page1.get(i).getDataTime(), "MM-dd HH:mm"));
  802. } else if (days < 360 && days > 24) {
  803. valMap.put("dataTime", DateUtils.format(page1.get(i).getDataTime(), "MM-dd HH:mm"));
  804. } else if (days >= 360) {
  805. valMap.put("dataTime", DateUtils.format(page1.get(i).getDataTime(), DateUtils.PARSE_PATTERNS[8]));
  806. }
  807. if (ArrayUtils.contains(result, "I")) {
  808. valMap.put("Ia", page1.get(i).getIa());
  809. valMap.put("Ib", page1.get(i).getIb());
  810. valMap.put("Ic", page1.get(i).getIc());
  811. if (ArrayUtils.contains(result, "P")) {
  812. valMap.put("P", page1.get(i).getP());
  813. valMap.put("Q", page1.get(i).getQ());
  814. valMap.put("Pa", page1.get(i).getPa());
  815. valMap.put("Pb", page1.get(i).getPb());
  816. valMap.put("Pc", page1.get(i).getPc());
  817. valMap.put("Qa", page1.get(i).getQa());
  818. valMap.put("Qb", page1.get(i).getQb());
  819. valMap.put("Qc", page1.get(i).getQc());
  820. valMap.put("Demand", page1.get(i).getDemand());
  821. if (ArrayUtils.contains(result, "KWh")) {
  822. valMap.put("Epn", page1.get(i).getEpn());
  823. valMap.put("Epp", page1.get(i).getEpp());
  824. valMap.put("Eqn", page1.get(i).getEqn());
  825. valMap.put("Eqp", page1.get(i).getEqp());
  826. if (ArrayUtils.contains(result, "V")) {
  827. valMap.put("Ua", page1.get(i).getUa());
  828. valMap.put("Ub", page1.get(i).getUb());
  829. valMap.put("Uc", page1.get(i).getUc());
  830. valMap.put("Uab", page1.get(i).getUab());
  831. valMap.put("Ubc", page1.get(i).getUbc());
  832. valMap.put("Uca", page1.get(i).getUca());
  833. valMap.put("Ul", page1.get(i).getUl());
  834. if (ArrayUtils.contains(result, "C")) {
  835. valMap.put("T1", page1.get(i).getT1());
  836. valMap.put("T2", page1.get(i).getT2());
  837. valMap.put("T3", page1.get(i).getT3());
  838. valMap.put("T4", page1.get(i).getT4());
  839. valMap.put("DeviceTemp", page1.get(i).getDeviceTemp());
  840. if (ArrayUtils.contains(result, "HZ")) {
  841. valMap.put("F", page1.get(i).getF());
  842. if (ArrayUtils.contains(result, "PS")) {
  843. valMap.put("COSa", page1.get(i).getCOSa());
  844. valMap.put("COSb", page1.get(i).getCOSb());
  845. valMap.put("COSc", page1.get(i).getCOSc());
  846. valMap.put("COS", page1.get(i).getCos());
  847. if (ArrayUtils.contains(result, "RMS")) {
  848. valMap.put("IHa", page1.get(i).getIHa());
  849. valMap.put("IHb", page1.get(i).getIHb());
  850. valMap.put("IHc", page1.get(i).getIHc());
  851. if (ArrayUtils.contains(result, "DDB")) {
  852. valMap.put("SignalIntensity", page1.get(i).getSignalIntensity());
  853. if (ArrayUtils.contains(result, "VT")) {
  854. valMap.put("Upt", page1.get(i).getUpt());
  855. valMap.put("Udt", page1.get(i).getUdt());
  856. valMap.put("Ust", page1.get(i).getUst());
  857. }
  858. }
  859. }
  860. }
  861. }
  862. }
  863. }
  864. }
  865. }
  866. }
  867. list.add(valMap);
  868. }
  869. workbook = ExcelExportUtil.exportExcel(params, colList, list);
  870. if (null != workbook) {
  871. file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "数据报表", System.currentTimeMillis() + ""));
  872. FileUtils.createFile(file.getAbsolutePath());
  873. FileOutputStream allListingFileOutputStream = new FileOutputStream(file);
  874. workbook.write(allListingFileOutputStream);
  875. } else {
  876. throw new BusinessException("表格数据为空");
  877. }
  878. } catch (FileNotFoundException e) {
  879. log.error("导出文件失败", e);
  880. throw new BusinessException("导出文件失败");
  881. } catch (IOException e) {
  882. e.printStackTrace();
  883. }
  884. return file.getName();
  885. }
  886. // @Override
  887. // public String DataReportExport(Integer siteId,Date startTime, Date endTime,String queryType){
  888. // Integer userId = UserUtil.getUserId();
  889. // Workbook workbook = null;
  890. // File file = null;
  891. // long diff = endTime.getTime() - startTime.getTime();
  892. // long days = diff / (1000 * 60 * 60);
  893. // try {
  894. // ExportParams params = new ExportParams(null, "数据报表");
  895. // workbook = ExcelExportUtil.exportBigExcel(params, HtAnalogDataExportVO.class,
  896. // (o, i) -> {
  897. // Page<HtAnalogData> page = new Page<>(i, 30);
  898. // if (days<=24){
  899. // page = baseMapper.getDataReportMap1(page,siteId, startTime, endTime);
  900. // }else if (days<360&&days>24){
  901. // List<Device> device_list = baseMapper.getDeviceListMap(siteId);
  902. // page = baseMapper.getDataReportMMap1(page,device_list,startTime, endTime);
  903. // }else if (days>=360){
  904. // List<Device> device_list = baseMapper.getDeviceListMap(siteId);
  905. // page = baseMapper.getDataReportDMap1(page,device_list,startTime, endTime);
  906. // }
  907. //
  908. // return new ArrayList<>(BeanMapperUtils.mapList(page.getRecords(), HtAnalogData.class, HtAnalogDataExportVO.class));
  909. // },null);
  910. // if (null != workbook) {
  911. // file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "数据报表", System.currentTimeMillis() + ""));
  912. // FileUtils.createFile(file.getAbsolutePath());
  913. // FileOutputStream allListingFileOutputStream = new FileOutputStream(file);
  914. // workbook.write(allListingFileOutputStream);
  915. // } else {
  916. // throw new BusinessException("表格数据为空");
  917. // }
  918. // } catch (Exception e) {
  919. // log.error("导出文件失败", e);
  920. // throw new BusinessException("导出文件失败");
  921. // } finally {
  922. // if (workbook != null) {
  923. // try {
  924. // workbook.close();
  925. // } catch (IOException e) {
  926. // log.error("===export spec=== 关闭workbook失败", e);
  927. // }
  928. // }
  929. // }
  930. // return file.getName();
  931. // }
  932. }