|
@@ -1,5 +1,6 @@
|
|
|
package com.xlht.xlhtproject.controller;
|
|
|
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
import com.xlht.xlhtproject.domain.TXlhtAddRecord;
|
|
|
import com.xlht.xlhtproject.respParse.bean.R;
|
|
|
import com.xlht.xlhtproject.service.ITXlhtAddRecordService;
|
|
@@ -12,8 +13,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 投药报表相关
|
|
@@ -33,12 +37,12 @@ public class TXlhtAddRecordController extends BaseController{
|
|
|
@GetMapping("/hourList")
|
|
|
public R<List<TXlhtAddRecord>> hourList(@RequestParam(required = false, name = "timeBegin") String timeBegin, @RequestParam(required = false, name = "timeEnd") String timeEnd)
|
|
|
{
|
|
|
- log.info("进入了 修改碳源投加 首页-报表信息 接口");
|
|
|
+ log.info("进入了 碳源投加 小时维度投药聚合报表 接口");
|
|
|
//2024年10月24日17:24:13 如果没有指定日期,那么这里给默认15天的数据
|
|
|
Date nowDate = DateUtils.getNowDate();
|
|
|
Date dayBefore14 = DateUtils.plusDate(-14, nowDate);
|
|
|
- timeEnd = StringUtils.isBlank(timeEnd) ? DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, nowDate) : timeEnd;
|
|
|
- timeBegin = StringUtils.isBlank(timeBegin) ? DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, dayBefore14) : timeBegin;
|
|
|
+ timeEnd = StringUtils.isBlank(timeEnd) ? DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH, nowDate) : timeEnd;
|
|
|
+ timeBegin = StringUtils.isBlank(timeBegin) ? DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH, dayBefore14) : timeBegin;
|
|
|
TXlhtAddRecord req = TXlhtAddRecord.builder().timeBegin(timeBegin).timeEnd(timeEnd).build();
|
|
|
return R.ok(this.txlhtAddRecordService.selectTXlhtAddRecordHourList(req));
|
|
|
}
|
|
@@ -47,10 +51,63 @@ public class TXlhtAddRecordController extends BaseController{
|
|
|
*首页-小时维度投药聚合报表
|
|
|
* @return
|
|
|
*/
|
|
|
+ @GetMapping("/hourExport")
|
|
|
+ public void hourExport(HttpServletResponse response, @RequestParam(required = false, name = "timeBegin") String timeBegin, @RequestParam(required = false, name = "timeEnd") String timeEnd) throws IOException {
|
|
|
+ log.info("进入了 碳源投加 小时维度投药聚合报表导出 接口");
|
|
|
+ //2024年10月24日17:24:13 如果没有指定日期,那么这里给默认15天的数据
|
|
|
+ Date nowDate = DateUtils.getNowDate();
|
|
|
+ Date dayBefore14 = DateUtils.plusDate(-14, nowDate);
|
|
|
+ timeEnd = StringUtils.isBlank(timeEnd) ? DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH, nowDate) : timeEnd;
|
|
|
+ timeBegin = StringUtils.isBlank(timeBegin) ? DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH, dayBefore14) : timeBegin;
|
|
|
+ TXlhtAddRecord req = TXlhtAddRecord.builder().timeBegin(timeBegin).timeEnd(timeEnd).build();
|
|
|
+ List<TXlhtAddRecord> list = this.txlhtAddRecordService.selectTXlhtAddRecordHourList(req);
|
|
|
+
|
|
|
+ List<List<String>> head = Arrays.asList(
|
|
|
+ Collections.singletonList("时间"),
|
|
|
+ Collections.singletonList("南池瞬时加药量(L/h)-秒级"),
|
|
|
+ Collections.singletonList("北池瞬时加药量(L/h)-秒级"),
|
|
|
+ Collections.singletonList("南池瞬时加药量(L/h)-5分钟"),
|
|
|
+ Collections.singletonList("南池瞬时加药量(L/h)-5分钟"),
|
|
|
+ Collections.singletonList("南池系统加药量(L/h)(系统显示)"),
|
|
|
+ Collections.singletonList("北池系统加药量(L/h)(系统显示)"),
|
|
|
+ Collections.singletonList("南池系统加药量(L/h)"),
|
|
|
+ Collections.singletonList("北池系统加药量(L/h)")
|
|
|
+ );
|
|
|
+ List<List<Object>> data = new ArrayList<>();
|
|
|
+ for (TXlhtAddRecord member : list) {
|
|
|
+ List<Object> row = new ArrayList<>();
|
|
|
+ row.add(DateUtils.parseDateToStr("YYYY-MM-dd HH", member.getCreateTime()));
|
|
|
+ row.add(Objects.nonNull(member.getInstantTwoAmount()) ? member.getInstantTwoAmount().setScale(2, RoundingMode.HALF_UP) : null);
|
|
|
+ row.add(Objects.nonNull(member.getInstantOneAmount()) ? member.getInstantOneAmount().setScale(2, RoundingMode.HALF_UP) : null);
|
|
|
+ row.add(Objects.nonNull(member.getTwoAmount()) ? member.getTwoAmount().setScale(2, RoundingMode.HALF_UP) : null);
|
|
|
+ row.add(Objects.nonNull(member.getOneAmount()) ? member.getOneAmount().setScale(2, RoundingMode.HALF_UP) : null);
|
|
|
+ row.add(Objects.nonNull(member.getRealTwoAmount()) ? member.getRealTwoAmount().setScale(2, RoundingMode.HALF_UP) : null);
|
|
|
+ row.add(Objects.nonNull(member.getRealOneAmount()) ? member.getRealOneAmount().setScale(2, RoundingMode.HALF_UP) : null);
|
|
|
+ row.add(Objects.nonNull(member.getTmpTwoAmount()) ? member.getTmpTwoAmount().setScale(2, RoundingMode.HALF_UP) : null);
|
|
|
+ row.add(Objects.nonNull(member.getTmpOneAmount()) ? member.getTmpOneAmount().setScale(2, RoundingMode.HALF_UP) : null);
|
|
|
+ data.add(row);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置响应头
|
|
|
+ String fileName = URLEncoder.encode("投药量数据统计_小时", "UTF-8").replaceAll("\\+", "%20");
|
|
|
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+ response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
|
|
|
+
|
|
|
+ EasyExcel.write(response.getOutputStream())
|
|
|
+ .sheet("投药量数据统计_小时")
|
|
|
+ .head(head)
|
|
|
+ .doWrite(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *首页-天维度投药聚合报表
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@GetMapping("/dayList")
|
|
|
public R<List<TXlhtAddRecord>> dayList(@RequestParam(required = false, name = "timeBegin") String timeBegin, @RequestParam(required = false, name = "timeEnd") String timeEnd)
|
|
|
{
|
|
|
- log.info("进入了 修改碳源投加 首页-报表信息 接口");
|
|
|
+ log.info("进入了 碳源投加 天维度投药聚合报表 接口");
|
|
|
//2024年10月24日17:24:13 如果没有指定日期,那么这里给默认15天的数据
|
|
|
Date nowDate = DateUtils.getNowDate();
|
|
|
Date dayBefore14 = DateUtils.plusDate(-14, nowDate);
|
|
@@ -59,4 +116,57 @@ public class TXlhtAddRecordController extends BaseController{
|
|
|
TXlhtAddRecord req = TXlhtAddRecord.builder().timeBegin(timeBegin).timeEnd(timeEnd).build();
|
|
|
return R.ok(this.txlhtAddRecordService.selectTXlhtAddRecordDayList(req));
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ *首页-天维度投药聚合报表
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/dayExport")
|
|
|
+ public void dayExport(HttpServletResponse response ,@RequestParam(required = false, name = "timeBegin") String timeBegin, @RequestParam(required = false, name = "timeEnd") String timeEnd) throws IOException {
|
|
|
+ log.info("进入了 碳源投加 天维度投药聚合报表导出 接口");
|
|
|
+ //2024年10月24日17:24:13 如果没有指定日期,那么这里给默认15天的数据
|
|
|
+ Date nowDate = DateUtils.getNowDate();
|
|
|
+ Date dayBefore14 = DateUtils.plusDate(-14, nowDate);
|
|
|
+ timeEnd = StringUtils.isBlank(timeEnd) ? DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, nowDate) : timeEnd;
|
|
|
+ timeBegin = StringUtils.isBlank(timeBegin) ? DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, dayBefore14) : timeBegin;
|
|
|
+ TXlhtAddRecord req = TXlhtAddRecord.builder().timeBegin(timeBegin).timeEnd(timeEnd).build();
|
|
|
+ List<TXlhtAddRecord> list = this.txlhtAddRecordService.selectTXlhtAddRecordDayList(req);
|
|
|
+
|
|
|
+ List<List<String>> head = Arrays.asList(
|
|
|
+ Collections.singletonList("时间"),
|
|
|
+ Collections.singletonList("南池瞬时加药量(L/h)-秒级"),
|
|
|
+ Collections.singletonList("北池瞬时加药量(L/h)-秒级"),
|
|
|
+ Collections.singletonList("南池瞬时加药量(L/h)-5分钟"),
|
|
|
+ Collections.singletonList("南池瞬时加药量(L/h)-5分钟"),
|
|
|
+ Collections.singletonList("南池系统加药量(L/h)(系统显示)"),
|
|
|
+ Collections.singletonList("北池系统加药量(L/h)(系统显示)"),
|
|
|
+ Collections.singletonList("南池系统加药量(L/h)"),
|
|
|
+ Collections.singletonList("北池系统加药量(L/h)")
|
|
|
+ );
|
|
|
+ List<List<Object>> data = new ArrayList<>();
|
|
|
+ for (TXlhtAddRecord member : list) {
|
|
|
+ List<Object> row = new ArrayList<>();
|
|
|
+ row.add(DateUtils.parseDateToStr("YYYY-MM-dd", member.getCreateTime()));
|
|
|
+ row.add(Objects.nonNull(member.getInstantTwoAmount()) ? member.getInstantTwoAmount().setScale(2, RoundingMode.HALF_UP) : null);
|
|
|
+ row.add(Objects.nonNull(member.getInstantOneAmount()) ? member.getInstantOneAmount().setScale(2, RoundingMode.HALF_UP) : null);
|
|
|
+ row.add(Objects.nonNull(member.getTwoAmount()) ? member.getTwoAmount().setScale(2, RoundingMode.HALF_UP) : null);
|
|
|
+ row.add(Objects.nonNull(member.getOneAmount()) ? member.getOneAmount().setScale(2, RoundingMode.HALF_UP) : null);
|
|
|
+ row.add(Objects.nonNull(member.getRealTwoAmount()) ? member.getRealTwoAmount().setScale(2, RoundingMode.HALF_UP) : null);
|
|
|
+ row.add(Objects.nonNull(member.getRealOneAmount()) ? member.getRealOneAmount().setScale(2, RoundingMode.HALF_UP) : null);
|
|
|
+ row.add(Objects.nonNull(member.getTmpTwoAmount()) ? member.getTmpTwoAmount().setScale(2, RoundingMode.HALF_UP) : null);
|
|
|
+ row.add(Objects.nonNull(member.getTmpOneAmount()) ? member.getTmpOneAmount().setScale(2, RoundingMode.HALF_UP) : null);
|
|
|
+ data.add(row);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置响应头
|
|
|
+ String fileName = URLEncoder.encode("投药量数据统计_天", "UTF-8").replaceAll("\\+", "%20");
|
|
|
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+ response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
|
|
|
+
|
|
|
+ EasyExcel.write(response.getOutputStream())
|
|
|
+ .sheet("投药量数据统计_天")
|
|
|
+ .head(head)
|
|
|
+ .doWrite(data);
|
|
|
+ }
|
|
|
}
|