|
@@ -3,8 +3,10 @@ package com.zcxk.rmcp.web.service.impl;
|
|
|
import cn.hutool.core.date.DatePattern;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.map.MapUtil;
|
|
|
+import com.zcxk.core.common.exception.BusinessException;
|
|
|
import com.zcxk.core.utils.export.EasyExcelUtil;
|
|
|
import com.zcxk.rmcp.api.dto.device.DeviceDataDto;
|
|
|
+import com.zcxk.rmcp.api.enums.RmcpErrorEnum;
|
|
|
import com.zcxk.rmcp.api.vo.DeviceDataVo;
|
|
|
import com.zcxk.rmcp.api.vo.MeasuringPointVo;
|
|
|
import com.zcxk.rmcp.api.vo.ProductMeasuringDictVo;
|
|
@@ -73,6 +75,13 @@ public class DeviceDataServiceImpl implements DeviceDataService {
|
|
|
deviceDataDto.getEndDate());
|
|
|
}
|
|
|
|
|
|
+ /*
|
|
|
+ * @description 导出Excel
|
|
|
+ * @param deviceDataDto
|
|
|
+ * @param httpServletResponse
|
|
|
+ * @return
|
|
|
+ * @author linqingwei
|
|
|
+ **/
|
|
|
@Override
|
|
|
public void getDataExcel(DeviceDataDto deviceDataDto, HttpServletResponse httpServletResponse) {
|
|
|
List<DeviceDataItem> list = deviceDataDao.queryDeviceDataItem(deviceDataDto.getDeviceId(),deviceDataDto.getStartDate(),
|
|
@@ -91,7 +100,7 @@ public class DeviceDataServiceImpl implements DeviceDataService {
|
|
|
List<Object> item = new ArrayList<>();
|
|
|
item.add(DateUtil.format(new Date(deviceDataItem.getReceiveTime()), DatePattern.NORM_DATETIME_PATTERN));
|
|
|
for (MeasuringPointVo vo : measuringList) {
|
|
|
- item.add(getRowsValue(vo,deviceDataItem.getMeasureData()));
|
|
|
+ item.add(getMeasuringValue(vo,deviceDataItem.getMeasureData()));
|
|
|
}
|
|
|
dataList.add(item);
|
|
|
}
|
|
@@ -99,12 +108,19 @@ public class DeviceDataServiceImpl implements DeviceDataService {
|
|
|
|
|
|
EasyExcelUtil.excelDynamicWrite(httpServletResponse,"历史数据",head,dataList);
|
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ throw BusinessException.builder(RmcpErrorEnum.RMCP_DOWNLOAD_ERROR);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- private Object getRowsValue(MeasuringPointVo vo, Map<String, Object> measureData) {
|
|
|
+ /*
|
|
|
+ * @description 获取测点值
|
|
|
+ * @param vo
|
|
|
+ * @param measureData
|
|
|
+ * @return
|
|
|
+ * @author linqingwei
|
|
|
+ **/
|
|
|
+ private Object getMeasuringValue(MeasuringPointVo vo, Map<String, Object> measureData) {
|
|
|
|
|
|
String value = MapUtil.getStr(measureData,vo.getMeasuringCode());
|
|
|
if (value != null) {
|
|
@@ -117,6 +133,12 @@ public class DeviceDataServiceImpl implements DeviceDataService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /*
|
|
|
+ * @description 获取表头
|
|
|
+ * @param measuringList
|
|
|
+ * @return
|
|
|
+ * @author linqingwei
|
|
|
+ **/
|
|
|
private List<String> getHeadList(List<MeasuringPointVo> measuringList){
|
|
|
List<String> head = new ArrayList<>();
|
|
|
head.add("上报时间");
|