|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package com.ruoyi.business.controller;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
@ -8,6 +9,8 @@ import com.ruoyi.business.domain.*;
|
|
|
|
|
import com.ruoyi.business.domain.VO.*;
|
|
|
|
|
import com.ruoyi.business.service.*;
|
|
|
|
|
import com.ruoyi.business.utils.ExcelUtils;
|
|
|
|
|
import com.ruoyi.business.utils.UnitExcelUtils;
|
|
|
|
|
import com.ruoyi.common.core.annotation.Excel;
|
|
|
|
|
import com.ruoyi.common.core.constant.HwDictConstants;
|
|
|
|
|
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
|
|
|
|
import com.ruoyi.common.core.web.controller.BaseController;
|
|
|
|
@ -29,7 +32,11 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
|
import java.sql.*;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
@ -48,6 +55,7 @@ public class HwMonitorPlatformController extends BaseController {
|
|
|
|
|
private IHwElectronicFenceService hwElectronicFenceService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private IHwAlarmInfoService hwAlarmInfoService;
|
|
|
|
|
@Autowired HwMonitorUnitAttributeService hwMonitorUnitAttributeService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IHwMonitorPlatformService hwMonitorPlatformService;
|
|
|
|
@ -444,6 +452,7 @@ public class HwMonitorPlatformController extends BaseController {
|
|
|
|
|
@GetMapping("/getDeviceByAreaId/{tenantId}")
|
|
|
|
|
public AjaxResult getDeviceByAreaId(@PathVariable("tenantId") Long tenantId){
|
|
|
|
|
List<HwMonitorUnit> deviceList = hwDeviceService.getDeviceByAreaId(tenantId);
|
|
|
|
|
|
|
|
|
|
return success(deviceList);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
@ -451,10 +460,51 @@ public class HwMonitorPlatformController extends BaseController {
|
|
|
|
|
* */
|
|
|
|
|
@PostMapping("/AlarmInfosExport")
|
|
|
|
|
@RequiresPermissions("business:monitor:alarm")
|
|
|
|
|
public void AlarmInfosExport(HttpServletResponse response,Date startTime,Date endTime) {
|
|
|
|
|
List<AlarmInfoExportVo> alarmInfoExportVos = hwAlarmInfoService.selectAlarmInfoExport(startTime,endTime);
|
|
|
|
|
ExcelUtil<AlarmInfoExportVo> util = new ExcelUtil<AlarmInfoExportVo>(AlarmInfoExportVo.class);
|
|
|
|
|
util.exportExcel(response,alarmInfoExportVos,"报警数据导出");
|
|
|
|
|
public void AlarmInfosExport(HttpServletResponse response,Date startTime,Date endTime) throws IOException, NoSuchFieldException, IllegalAccessException {
|
|
|
|
|
List<Long> list1 = hwAlarmInfoService.selectUnitId();
|
|
|
|
|
HashMap<Long, List<LinkedHashMap>> map = new HashMap<>();
|
|
|
|
|
for (Long unitId : list1) {
|
|
|
|
|
List<AlarmInfoExportVo> list2 = hwAlarmInfoService.selectAlarmInfoExport1(unitId,startTime,endTime);
|
|
|
|
|
List<HwMonitorUnitAttribute> attributes = hwMonitorUnitAttributeService.selectAttributes(unitId);
|
|
|
|
|
|
|
|
|
|
List<LinkedHashMap> excelMap = new ArrayList<LinkedHashMap>();
|
|
|
|
|
LinkedHashMap attributeMap = new LinkedHashMap();
|
|
|
|
|
for (HwMonitorUnitAttribute attribute : attributes) {
|
|
|
|
|
attributeMap.put(attribute.getAttributeName(),attribute.getAttributeValue());
|
|
|
|
|
}
|
|
|
|
|
for (AlarmInfoExportVo alarmInfo : list2) {
|
|
|
|
|
LinkedHashMap voMap = new LinkedHashMap<>();
|
|
|
|
|
Class<AlarmInfoExportVo> clazz = AlarmInfoExportVo.class;
|
|
|
|
|
Field[] fields = clazz.getDeclaredFields();
|
|
|
|
|
for (Field field : fields) {
|
|
|
|
|
Excel annotation = field.getAnnotation(Excel.class);
|
|
|
|
|
String name = annotation.name();
|
|
|
|
|
field.setAccessible(true);
|
|
|
|
|
if (field.getName().equals("alarmInfoId")){
|
|
|
|
|
Long alarmInfoId =(Long)field.get(alarmInfo);
|
|
|
|
|
voMap.put(name,alarmInfoId);
|
|
|
|
|
}else {
|
|
|
|
|
String value = null;
|
|
|
|
|
if (field.get(alarmInfo)!=null){
|
|
|
|
|
value = field.get(alarmInfo).toString();
|
|
|
|
|
}
|
|
|
|
|
voMap.put(name,value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
voMap.putAll(attributeMap);
|
|
|
|
|
excelMap.add(voMap);
|
|
|
|
|
}
|
|
|
|
|
if (CollectionUtil.isNotEmpty(excelMap)){
|
|
|
|
|
map.put(unitId,excelMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
UnitExcelUtils unitExcelUtils = new UnitExcelUtils();
|
|
|
|
|
unitExcelUtils.exportAlarmInfos(response,map);
|
|
|
|
|
// List<AlarmInfoExportVo> alarmInfoExportVos = hwAlarmInfoService.selectAlarmInfoExport(startTime,endTime);
|
|
|
|
|
// ExcelUtil<AlarmInfoExportVo> util = new ExcelUtil<AlarmInfoExportVo>(AlarmInfoExportVo.class);
|
|
|
|
|
// util.exportExcel(response,alarmInfoExportVos,"报警数据导出");
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 导入excel,同一个租户重复导入时会覆盖之前的excel
|
|
|
|
|