|
|
@ -7,16 +7,16 @@ import cn.hutool.poi.excel.BigExcelWriter; |
|
|
|
import cn.hutool.poi.excel.ExcelUtil; |
|
|
|
import cn.hutool.poi.excel.ExcelWriter; |
|
|
|
import com.alibaba.fastjson2.JSONObject; |
|
|
|
import com.lzbi.bi.domain.DcDymicHeaderQueryVo; |
|
|
|
import com.lzbi.bi.domain.DcDymicReportHeaderVo; |
|
|
|
import com.lzbi.bi.domain.LogTimeThreeQueryParamVo; |
|
|
|
import com.lzbi.bi.domain.LogTimescaleHistoryThreeVo; |
|
|
|
import com.lzbi.asset.domain.DcBaseAssetInfo; |
|
|
|
import com.lzbi.bi.domain.*; |
|
|
|
import com.lzbi.code.domain.WeatherReportVO; |
|
|
|
import com.lzbi.code.service.LogTimesacleHistoryThreeService; |
|
|
|
import com.lzbi.common.core.controller.BaseController; |
|
|
|
import com.lzbi.common.core.domain.AjaxResult; |
|
|
|
import com.lzbi.common.utils.StringUtils; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
@ -33,12 +33,14 @@ import java.util.stream.Collectors; |
|
|
|
* @author : zhousq |
|
|
|
* @date : 2024-02-5 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Api(tags = "生产设备参数统计明细表功能接口") |
|
|
|
@RestController |
|
|
|
@RequestMapping("/dc/hisDetailReport") |
|
|
|
public class DcBusiHisReportController extends BaseController { |
|
|
|
@Resource |
|
|
|
private LogTimesacleHistoryThreeService logTimesacleHistoryThreeService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 分页列表查询 |
|
|
|
* |
|
|
@ -161,6 +163,7 @@ public class DcBusiHisReportController extends BaseController { |
|
|
|
return AjaxResult.success(dataInfo); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private String validatorator(LogTimeThreeQueryParamVo queryVo) { |
|
|
|
if (StringUtils.isNull(queryVo.getBeginTime()) || StringUtils.isEmpty(queryVo.getBeginTime())) { |
|
|
|
return "查询失败,开始时间不能为空!"; |
|
|
@ -173,6 +176,7 @@ public class DcBusiHisReportController extends BaseController { |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
///按时间 设备+参数 形成数据--时间分组
|
|
|
|
private List<Map<String, Object>> getMapList(List<LogTimescaleHistoryThreeVo> list, List<DcDymicReportHeaderVo> dcDymicReportHeaderVos) { |
|
|
|
Map<String, List<LogTimescaleHistoryThreeVo>> collect = list.stream().collect(Collectors.groupingBy(LogTimescaleHistoryThreeVo::getTimeStampString)); |
|
|
@ -190,12 +194,13 @@ public class DcBusiHisReportController extends BaseController { |
|
|
|
return map; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
/// 设备+参数 形成数据--设备-参数分组
|
|
|
|
private List<Map<String, Object>> getMapListDevice(List<LogTimescaleHistoryThreeVo> list, List<DcDymicReportHeaderVo> dcDymicReportHeaderVos) { |
|
|
|
Map<String, List<LogTimescaleHistoryThreeVo>> collect = list.stream().collect(Collectors.groupingBy(item -> item.getDeviceUuid() + "_" + item.getParamCode())); |
|
|
|
List<Map<String, Object>> collect1 = collect.entrySet().stream().map(entry -> { |
|
|
|
Map<String, Object> map = new LinkedHashMap<>(); |
|
|
|
entry.getValue().stream().sorted(Comparator.comparing(LogTimescaleHistoryThreeVo::getTimestampKey).thenComparing(LogTimescaleHistoryThreeVo::getParamCode)).forEach(vo -> { |
|
|
|
entry.getValue().stream().sorted(Comparator.comparing(LogTimescaleHistoryThreeVo::getTimeStampString).thenComparing(LogTimescaleHistoryThreeVo::getParamCode)).forEach(vo -> { |
|
|
|
String key = vo.getDeviceUuid() + "_" + vo.getParamCode(); |
|
|
|
Optional<DcDymicReportHeaderVo> first = dcDymicReportHeaderVos.stream().filter(vos -> vos.getColCode().equals(key)).findFirst(); |
|
|
|
if (first.isPresent()) { |
|
|
@ -218,6 +223,7 @@ public class DcBusiHisReportController extends BaseController { |
|
|
|
List<Map<String, Object>> mapList = getExcellData(queryVo, 2); |
|
|
|
toExcel(response, mapList); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("生产设备参数统计明细表导出功能-时间横向") |
|
|
|
@PostMapping("/export2") |
|
|
|
public void export2(HttpServletResponse response, LogTimeThreeQueryParamVo queryVo) throws IOException { |
|
|
@ -226,6 +232,7 @@ public class DcBusiHisReportController extends BaseController { |
|
|
|
toExcel(response, mapList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//获取excel数据 1 excel设备参数为列模式 2 excel时间为列模式 3 浏览器设备参数为列模式
|
|
|
|
//注意 excel有最大列数显示255 ,超出列数会报错
|
|
|
|
private List<Map<String, Object>> getExcellData(LogTimeThreeQueryParamVo queryVo, int type) { |
|
|
@ -260,11 +267,13 @@ public class DcBusiHisReportController extends BaseController { |
|
|
|
//此处记得关闭输出Servlet流
|
|
|
|
IoUtil.close(out); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("获取生产IOT系统参数模版列表") |
|
|
|
@GetMapping("/getParamClass") |
|
|
|
public AjaxResult getParamClass() { |
|
|
|
return AjaxResult.success(logTimesacleHistoryThreeService.selectParamModels()); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("获取生产IOT系统设备列表") |
|
|
|
@GetMapping("/getDevicie/{orgCode}") |
|
|
|
public AjaxResult selectDevices(@PathVariable Long orgCode) { |
|
|
@ -273,4 +282,18 @@ public class DcBusiHisReportController extends BaseController { |
|
|
|
} |
|
|
|
return AjaxResult.success(logTimesacleHistoryThreeService.selectDevices(orgCode)); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("根据父id获取下级地区--级联数据") |
|
|
|
@GetMapping("/selectAreaElementCascaderByParentId") |
|
|
|
public AjaxResult selectAreaElementCascaderByParentId(@RequestParam("parentId") Integer parentId) { |
|
|
|
return AjaxResult.success(logTimesacleHistoryThreeService.selectAreaElementCascaderByParentId(parentId)); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("天气报表") |
|
|
|
@PostMapping("/exportWeather") |
|
|
|
public void exportWeather(HttpServletResponse response, ExportWeatherReq exportWeatherReq) throws IOException { |
|
|
|
List<WeatherReportVO> weatherReport = logTimesacleHistoryThreeService.getWeatherReport(exportWeatherReq); |
|
|
|
com.lzbi.common.utils.poi.ExcelUtil<WeatherReportVO> util = new com.lzbi.common.utils.poi.ExcelUtil<WeatherReportVO>(WeatherReportVO.class); |
|
|
|
util.exportExcel(response, weatherReport, "天气报表"); |
|
|
|
} |
|
|
|
} |