|
@@ -1,6 +1,8 @@
|
|
|
package com.platform.rest.controller.report;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.platform.common.util.BeanConverterUtil;
|
|
|
import com.platform.common.util.DateUtils;
|
|
|
import com.platform.common.util.R;
|
|
@@ -15,20 +17,21 @@ import com.platform.dao.vo.export.repair.ExportRepairApplicationFormVO;
|
|
|
import com.platform.dao.vo.export.repair.ExportRepairFeeVO;
|
|
|
import com.platform.dao.vo.query.check.CheckJobVO;
|
|
|
import com.platform.dao.vo.repair.RepairApplicationFormVO;
|
|
|
-import com.platform.dao.vo.report.CheckJobReportVO;
|
|
|
-import com.platform.dao.vo.report.RepairReport24VO;
|
|
|
-import com.platform.dao.vo.report.RepairReportFee;
|
|
|
-import com.platform.dao.vo.report.RepairReportMttr;
|
|
|
+import com.platform.dao.vo.report.*;
|
|
|
import com.platform.rest.log.annotation.SysLog;
|
|
|
import com.platform.service.check.CheckJobService;
|
|
|
import com.platform.service.repair.RepairApplicationFormService;
|
|
|
import com.platform.service.repair.RepairFeeService;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -39,6 +42,7 @@ import java.util.List;
|
|
|
*/
|
|
|
@RestController
|
|
|
@AllArgsConstructor
|
|
|
+@Slf4j
|
|
|
@RequestMapping("/report/repair")
|
|
|
public class RepairReportController {
|
|
|
|
|
@@ -262,4 +266,153 @@ public class RepairReportController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 1:某个设备一年的故障统计仪表盘,多少次维修。非计划性维修多少次,计划性维修多少次,柱状图,按照年统计:2021,2022.
|
|
|
+ * 统计规则:
|
|
|
+ * 1:堆垛累加
|
|
|
+ * 2:总次数,计划性和非计划性各多少个
|
|
|
+ * 3:寿命曲线图,从哪一年开始的,到结束。如寿命5年,从2019年开始,则2019 5,2020 4,2021 3,2022 2,2023 1, 2024 0
|
|
|
+ *
|
|
|
+ * @param dto 查询条件
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @GetMapping("sbInfo")
|
|
|
+ @SysLog("设备维修统计")
|
|
|
+ public R getSbInfoReport(RepairApplicationFormDTO dto, @RequestParam(required = false) Integer year) {
|
|
|
+ List<RepairSbInfoReport> repairSbInfoReports = repairApplicationFormService.getSbInfoReport(dto, year);
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ // 转化列表为叠装柱状图需要的数据形式
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
+ if (CollectionUtil.isNotEmpty(repairSbInfoReports)) {
|
|
|
+ JSONObject plan = new JSONObject();
|
|
|
+ plan.put("name", "计划性");
|
|
|
+ JSONObject planNot = new JSONObject();
|
|
|
+ planNot.put("name", "非计划性");
|
|
|
+ List<Integer> yearList = new ArrayList<>();
|
|
|
+ for (RepairSbInfoReport repairSbInfoReport : repairSbInfoReports) {
|
|
|
+ plan.put(repairSbInfoReport.getYear() + "", repairSbInfoReport.getNum());
|
|
|
+ planNot.put(repairSbInfoReport.getYear() + "", repairSbInfoReport.getNum());
|
|
|
+ yearList.add(repairSbInfoReport.getYear());
|
|
|
+ }
|
|
|
+ jsonArray.add(plan);
|
|
|
+ jsonArray.add(planNot);
|
|
|
+ result.put("data", jsonArray);
|
|
|
+ result.put("fields", yearList);
|
|
|
+ result.put("dataTable", repairSbInfoReports);
|
|
|
+ }
|
|
|
+ // log.info(result.toJSONString());
|
|
|
+ return new R(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/sbInfo/export")
|
|
|
+ @SysLog("设备维修统计导出")
|
|
|
+ public void exportSbInfo(HttpServletResponse response, RepairApplicationFormDTO dto, @RequestParam(required = false) Integer year) {
|
|
|
+ List<RepairSbInfoReport> list = repairApplicationFormService.getSbInfoReport(dto, year);
|
|
|
+ ExcelUtil.exportResponseDict(response, RepairSbInfoReport.class, list, "设备维修统计导出");
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/sbInfo/export/year")
|
|
|
+ @SysLog("设备维修统计明细导出")
|
|
|
+ public void exportSbInfoYear(HttpServletResponse response, RepairApplicationFormDTO dto, @RequestParam(required = false) Integer year) {
|
|
|
+ List<RepairSbInfoReport> list = repairApplicationFormService.getSbInfoReport(dto, year);
|
|
|
+ String fileName = "";
|
|
|
+ fileName = year + "-设备维修统计明细导出";
|
|
|
+ if (CollectionUtil.isNotEmpty(list)) {
|
|
|
+ for (RepairSbInfoReport vo : list) {
|
|
|
+ if (vo.getYear().equals(year)) {
|
|
|
+ List<RepairApplicationFormVO> detailList = vo.getDetailList();
|
|
|
+ if (CollectionUtil.isNotEmpty(detailList)) {
|
|
|
+ ExcelUtil.exportResponseDict(response, ExportRepairApplicationFormVO.class, BeanConverterUtil.copyListProperties(detailList, ExportRepairApplicationFormVO.class), fileName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ Integer year = 2021;
|
|
|
+ Integer ss = 2021;
|
|
|
+ System.out.println(year == ss);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 费用月统计报表
|
|
|
+ * 统计规则:
|
|
|
+ * 1:所有费用
|
|
|
+ *
|
|
|
+ * @param dto 查询条件
|
|
|
+ * @param year 查询年份
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @GetMapping("/sbInfo/fee")
|
|
|
+ @SysLog("设备费用统计报表")
|
|
|
+ public R getSbInfoReportFee(RepairFeeDTO dto, @RequestParam(required = false) Integer year) {
|
|
|
+ List<RepairSbInfoReportFee> repairSbInfoReports = repairFeeService.getSbInfoReport(dto, year);
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ // 转化列表为叠装柱状图需要的数据形式
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
+ if (CollectionUtil.isNotEmpty(repairSbInfoReports)) {
|
|
|
+ JSONObject plan = new JSONObject();
|
|
|
+ plan.put("name", "计划性");
|
|
|
+ JSONObject planNot = new JSONObject();
|
|
|
+ planNot.put("name", "非计划性");
|
|
|
+ List<Integer> yearList = new ArrayList<>();
|
|
|
+ for (RepairSbInfoReportFee repairSbInfoReport : repairSbInfoReports) {
|
|
|
+ plan.put(repairSbInfoReport.getYear() + "", repairSbInfoReport.getNum());
|
|
|
+ planNot.put(repairSbInfoReport.getYear() + "", repairSbInfoReport.getNum());
|
|
|
+ yearList.add(repairSbInfoReport.getYear());
|
|
|
+ }
|
|
|
+ jsonArray.add(plan);
|
|
|
+ jsonArray.add(planNot);
|
|
|
+ result.put("data", jsonArray);
|
|
|
+ result.put("fields", yearList);
|
|
|
+ result.put("dataTable", repairSbInfoReports);
|
|
|
+ }
|
|
|
+ //log.info(result.toJSONString());
|
|
|
+ return new R(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 费用月统计报表
|
|
|
+ * 统计规则:
|
|
|
+ * 1:所有费用
|
|
|
+ *
|
|
|
+ * @param dto 查询条件
|
|
|
+ * @param year 查询年份
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @GetMapping("/sbInfo/fee/export")
|
|
|
+ @SysLog("设备费用统计报表导出")
|
|
|
+ public void exportSbInfoFee(HttpServletResponse response, RepairFeeDTO dto, @RequestParam(required = false) Integer year) {
|
|
|
+ List<RepairSbInfoReportFee> list = repairFeeService.getSbInfoReport(dto, year);
|
|
|
+ String fileName = "设备费用统计报表";
|
|
|
+ ExcelUtil.exportResponseDict(response, RepairSbInfoReportFee.class, list, fileName);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 费用统计报表
|
|
|
+ * 统计规则:
|
|
|
+ * 1:所有费用
|
|
|
+ *
|
|
|
+ * @param dto 查询条件
|
|
|
+ * @param year 查询年份
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @GetMapping("/sbInfo/fee/export/year")
|
|
|
+ @SysLog("费用月明细导出")
|
|
|
+ public void exportSbInfoFeeYear(HttpServletResponse response, RepairFeeDTO dto, @RequestParam(required = false) Integer year) {
|
|
|
+ List<RepairSbInfoReportFee> list = repairFeeService.getSbInfoReport(dto, year);
|
|
|
+ String fileName = year + "-费用月明细";
|
|
|
+ if (CollectionUtil.isNotEmpty(list)) {
|
|
|
+ for (RepairSbInfoReportFee vo : list) {
|
|
|
+ if (vo.getYear().equals(year)) {
|
|
|
+ List<RepairFee> detailList = vo.getDetailList();
|
|
|
+ if (CollectionUtil.isNotEmpty(detailList)) {
|
|
|
+ ExcelUtil.exportResponseDict(response, ExportRepairFeeVO.class, BeanConverterUtil.copyListProperties(detailList, ExportRepairFeeVO.class), fileName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|