|
@@ -5,7 +5,6 @@ import com.alibaba.excel.ExcelWriter;
|
|
import com.alibaba.excel.write.metadata.WriteSheet;
|
|
import com.alibaba.excel.write.metadata.WriteSheet;
|
|
import com.alibaba.excel.write.metadata.fill.FillConfig;
|
|
import com.alibaba.excel.write.metadata.fill.FillConfig;
|
|
import com.alibaba.fastjson2.JSON;
|
|
import com.alibaba.fastjson2.JSON;
|
|
-import com.github.pagehelper.PageHelper;
|
|
|
|
import com.ruoyi.business.domain.*;
|
|
import com.ruoyi.business.domain.*;
|
|
import com.ruoyi.business.mapper.*;
|
|
import com.ruoyi.business.mapper.*;
|
|
import com.ruoyi.business.req.AssayReq;
|
|
import com.ruoyi.business.req.AssayReq;
|
|
@@ -14,25 +13,19 @@ import com.ruoyi.business.res.*;
|
|
import com.ruoyi.business.service.IBusinessService;
|
|
import com.ruoyi.business.service.IBusinessService;
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
import com.ruoyi.common.core.domain.R;
|
|
import com.ruoyi.common.core.domain.R;
|
|
-import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
import com.ruoyi.common.enums.DataSourceType;
|
|
import com.ruoyi.common.enums.DataSourceType;
|
|
-import com.ruoyi.common.utils.DateUtils;
|
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
-import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
|
import com.ruoyi.framework.datasource.DynamicDataSourceContextHolder;
|
|
import com.ruoyi.framework.datasource.DynamicDataSourceContextHolder;
|
|
-import com.ruoyi.framework.web.domain.server.Sys;
|
|
|
|
-import com.ruoyi.quartz.domain.SysJob;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.Objects;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@@ -64,6 +57,11 @@ public class BusinessController extends BaseController {
|
|
@Value("${assay.report.countDir}")
|
|
@Value("${assay.report.countDir}")
|
|
private String countDir;
|
|
private String countDir;
|
|
|
|
|
|
|
|
+ @Value("${assay.report.continuousCountDir}")
|
|
|
|
+ private String continuousCountDir;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
@GetMapping("/hello")
|
|
@GetMapping("/hello")
|
|
public String hello() {
|
|
public String hello() {
|
|
return "hello world";
|
|
return "hello world";
|
|
@@ -263,4 +261,173 @@ public class BusinessController extends BaseController {
|
|
return R.ok(map);
|
|
return R.ok(map);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 接口9:导出 通过日期范围加水厂(可选)获取连续监测的报表统计信息到Excel
|
|
|
|
+ * @param response
|
|
|
|
+ */
|
|
|
|
+// @PostMapping("/exportAssayPageListByDeviceNoAndDate")
|
|
|
|
+ @GetMapping("/exportContinuousAssayCountByDates")
|
|
|
|
+ public void exportContinuousAssayCountByDates(HttpServletResponse response, AssayReq assayReq)
|
|
|
|
+ {
|
|
|
|
+ log.info("进入了 导出 通过日期范围加水厂(可选)获取连续监测的报表统计信息到Excel 接口,请求参数是{}", JSON.toJSONString(assayReq));
|
|
|
|
+ DynamicDataSourceContextHolder.setDataSourceType(DataSourceType.SLAVE.name());
|
|
|
|
+ Map<String, Map<String, List<ContinuousAssayResultRes>>> map = this.businessService.continuousAssayCountByDates(assayReq);
|
|
|
|
+ DynamicDataSourceContextHolder.clearDataSourceType();
|
|
|
|
+ // 输出文件路径
|
|
|
|
+ log.info("配置的输出文件路径及名称是{}", continuousCountDir);
|
|
|
|
+
|
|
|
|
+ //表头
|
|
|
|
+ List<List<String>> headers = new ArrayList<>();
|
|
|
|
+ headers.add(Arrays.asList("检测点位", "检测指标"));
|
|
|
|
+ //业务数据
|
|
|
|
+ List<List<Object>> dates = new ArrayList<>();
|
|
|
|
+// dates.add();
|
|
|
|
+// List<String> itemList = Arrays.asList("实际检测数量", "最小值", "最大值", "合格率(%)", "标线(%)", "合格率偏差");
|
|
|
|
+ //存放业务数据的各个集合
|
|
|
|
+ List<Integer> collect0 = new ArrayList<>();
|
|
|
|
+ List<Double> collect1 = new ArrayList<>();
|
|
|
|
+ List<Double> collect2 = new ArrayList<>();
|
|
|
|
+ List<String> collect3 = new ArrayList<>();
|
|
|
|
+ List<String> collect4 = new ArrayList<>();
|
|
|
|
+ List<String> collect5 = new ArrayList<>();
|
|
|
|
+ //拼接表头和业务数据
|
|
|
|
+ map.forEach((outKey, outMap) ->{
|
|
|
|
+ outMap.forEach((innerKey, list) ->{
|
|
|
|
+ List<String> headerList = new ArrayList<>();
|
|
|
|
+ for (ContinuousAssayResultRes continuousAssayResultRes : list) {
|
|
|
|
+ //表头
|
|
|
|
+ headerList.add(outKey);
|
|
|
|
+ headerList.add(innerKey);
|
|
|
|
+ headers.add(headerList);
|
|
|
|
+ //业务数据
|
|
|
|
+ collect0.add(continuousAssayResultRes.getAssayCounts());
|
|
|
|
+ collect1.add(continuousAssayResultRes.getMinVal());
|
|
|
|
+ collect2.add(continuousAssayResultRes.getMaxVal());
|
|
|
|
+ collect3.add(continuousAssayResultRes.getPassedRates());
|
|
|
|
+ collect4.add(continuousAssayResultRes.getBx());
|
|
|
|
+ collect5.add(continuousAssayResultRes.getRatesDeviation());
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ //处理业务数据
|
|
|
|
+ ArrayList<Object> list0 = new ArrayList<>();
|
|
|
|
+ list0.add("实际检测数量");
|
|
|
|
+ list0.addAll(collect0);
|
|
|
|
+ dates.add(list0);
|
|
|
|
+
|
|
|
|
+ ArrayList<Object> list1 = new ArrayList<>();
|
|
|
|
+ list1.add("最小值");
|
|
|
|
+ list1.addAll(collect1);
|
|
|
|
+ dates.add(list1);
|
|
|
|
+
|
|
|
|
+ ArrayList<Object> list2 = new ArrayList<>();
|
|
|
|
+ list2.add("最大值");
|
|
|
|
+ list2.addAll(collect2);
|
|
|
|
+ dates.add(list2);
|
|
|
|
+
|
|
|
|
+ ArrayList<Object> list3 = new ArrayList<>();
|
|
|
|
+ list3.add("合格率(%)");
|
|
|
|
+ list3.addAll(collect3);
|
|
|
|
+ dates.add(list3);
|
|
|
|
+
|
|
|
|
+ ArrayList<Object> list4 = new ArrayList<>();
|
|
|
|
+ list4.add("标线(%)");
|
|
|
|
+ list4.addAll(collect4);
|
|
|
|
+ dates.add(list4);
|
|
|
|
+
|
|
|
|
+ ArrayList<Object> list5 = new ArrayList<>();
|
|
|
|
+ list5.add("合格率偏差");
|
|
|
|
+ list5.addAll(collect5);
|
|
|
|
+ dates.add(list5);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// log.info("动态Excel的表头是{}", JSON.toJSONString(headers));
|
|
|
|
+ log.info("动态Excel的数据列表是{}", JSON.toJSONString(dates));
|
|
|
|
+
|
|
|
|
+ EasyExcel.write(continuousCountDir)
|
|
|
|
+ // 动态头
|
|
|
|
+ .head(headers)
|
|
|
|
+ .sheet()
|
|
|
|
+ // 表格数据
|
|
|
|
+ .doWrite(dates);
|
|
|
|
+
|
|
|
|
+ //测试动态生成表头 单元格合并
|
|
|
|
+ /*EasyExcel.write(continuousCountDir)
|
|
|
|
+ // 动态头
|
|
|
|
+ .head(head())
|
|
|
|
+ .sheet()
|
|
|
|
+ // 表格数据
|
|
|
|
+ .doWrite(getLists());*/
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static List<List<Object>> getLists() {
|
|
|
|
+ List<List<Object>> list = new ArrayList<>();
|
|
|
|
+ List<Object> data1 = new ArrayList<>();
|
|
|
|
+ data1.add("0");
|
|
|
|
+ data1.add("1");
|
|
|
|
+ data1.add("2");
|
|
|
|
+ data1.add("3");
|
|
|
|
+ data1.add("4");
|
|
|
|
+ data1.add("5");
|
|
|
|
+ list.add(data1);
|
|
|
|
+
|
|
|
|
+ List<Object> data2 = new ArrayList<>();
|
|
|
|
+ data2.add("00");
|
|
|
|
+ data2.add("11");
|
|
|
|
+ data2.add("22");
|
|
|
|
+ data2.add("33");
|
|
|
|
+ data2.add("44");
|
|
|
|
+ data2.add("55");
|
|
|
|
+ list.add(data2);
|
|
|
|
+
|
|
|
|
+ List<Object> data3 = new ArrayList<>();
|
|
|
|
+ data3.add("000");
|
|
|
|
+ data3.add("111");
|
|
|
|
+ data3.add("222");
|
|
|
|
+ data3.add("333");
|
|
|
|
+ data3.add("444");
|
|
|
|
+ data3.add("555");
|
|
|
|
+ list.add(data3);
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static List<List<String>> head() {
|
|
|
|
+ List<List<String>> list = new ArrayList<List<String>>();
|
|
|
|
+ List<String> head0 = new ArrayList<String>();
|
|
|
|
+ head0.add("部门");
|
|
|
|
+ head0.add("用户名称");
|
|
|
|
+ List<String> head1 = new ArrayList<String>();
|
|
|
|
+ head1.add("运营部");
|
|
|
|
+ head1.add("性别");
|
|
|
|
+ List<String> head2 = new ArrayList<String>();
|
|
|
|
+ head2.add("运营部");
|
|
|
|
+ head2.add("年龄");
|
|
|
|
+ List<String> head3 = new ArrayList<String>();
|
|
|
|
+ head3.add("时间");
|
|
|
|
+ head3.add("出生日期");
|
|
|
|
+ List<String> head4 = new ArrayList<String>();
|
|
|
|
+ head4.add("2024-04-09");
|
|
|
|
+ head4.add("学历");
|
|
|
|
+ List<String> head5 = new ArrayList<String>();
|
|
|
|
+ head5.add("2024-04-09");
|
|
|
|
+ head5.add("电话号码");
|
|
|
|
+ list.add(head0);
|
|
|
|
+ list.add(head1);
|
|
|
|
+ list.add(head2);
|
|
|
|
+ list.add(head3);
|
|
|
|
+ list.add(head4);
|
|
|
|
+ list.add(head5);
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static void main(String[] args) {
|
|
|
|
+ System.out.println(head());
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|