|
@@ -0,0 +1,328 @@
|
|
|
+package com.ruoyi.project.sems.controller;
|
|
|
+
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.ruoyi.framework.web.controller.BaseController;
|
|
|
+
|
|
|
+import com.ruoyi.framework.web.domain.AjaxResult;
|
|
|
+import com.ruoyi.project.officeConvert.OfficeConvertController;
|
|
|
+
|
|
|
+import com.ruoyi.project.sems.domain.TMeasureThickness;
|
|
|
+import com.ruoyi.project.sems.domain.TSpecdevYlgd;
|
|
|
+import com.ruoyi.project.sems.mapper.TMeasureStressMapper;
|
|
|
+import com.ruoyi.project.sems.service.ITMeasureLoopService;
|
|
|
+import com.ruoyi.project.sems.service.ITMeasureRecordService;
|
|
|
+import com.ruoyi.project.sems.service.ITMeasureStressService;
|
|
|
+import com.ruoyi.project.sems.service.ITMeasureThicknessService;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.Year;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 定点测厚Controller
|
|
|
+ *
|
|
|
+ * @author ruoyi
|
|
|
+ * @date 2021-07-07
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/sems/cuihome")
|
|
|
+public class TMeasureCuiHomeController extends BaseController {
|
|
|
+ @Autowired
|
|
|
+ private ITMeasureThicknessService tMeasureThicknessService;
|
|
|
+ @Autowired
|
|
|
+ private ITMeasureRecordService tMeasureRecordService;
|
|
|
+ @Autowired
|
|
|
+ private OfficeConvertController officeConvertController;
|
|
|
+ @Resource
|
|
|
+ private TMeasureStressMapper tMeasureStressMapper;
|
|
|
+ @Autowired
|
|
|
+ private ITMeasureStressService tMeasureStressService;
|
|
|
+ @Autowired
|
|
|
+ private ITMeasureLoopService tMeasureLoopService;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 首页数据
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "data")
|
|
|
+ public AjaxResult homeData(@RequestBody Map<String, Object> params) {
|
|
|
+ logger.info(JSON.toJSONString(params));
|
|
|
+ LocalDate today = LocalDate.now();
|
|
|
+ LocalDate oneMonthLater = today.plusMonths(1);
|
|
|
+ Date sqlDate = java.sql.Date.valueOf(oneMonthLater);
|
|
|
+
|
|
|
+ List plantIds = (List) params.get("plantIds");
|
|
|
+ if (plantIds == null) {
|
|
|
+ plantIds = new ArrayList();
|
|
|
+ }
|
|
|
+ if (plantIds.size() == 0) {
|
|
|
+ plantIds.add("1");
|
|
|
+ }
|
|
|
+ int sbAll = tMeasureThicknessService.count(new QueryWrapper<TMeasureThickness>()
|
|
|
+ .in("plant_code",plantIds)
|
|
|
+ .eq("dev_type" , "设备")
|
|
|
+ .eq("del_flag" , 0)
|
|
|
+ );
|
|
|
+ int gdAll = tMeasureThicknessService.count(new QueryWrapper<TMeasureThickness>()
|
|
|
+ .in("plant_code",plantIds)
|
|
|
+ .and(wrapper -> wrapper
|
|
|
+ .ne("dev_type", "设备") // 排除 dev_type = '设备'
|
|
|
+ .or() // 或
|
|
|
+ .isNull("dev_type") // 包含 dev_type 为 null 的记录
|
|
|
+ )
|
|
|
+ .eq("del_flag" , 0)
|
|
|
+ );
|
|
|
+
|
|
|
+ int sbWarn = tMeasureThicknessService.count(new QueryWrapper<TMeasureThickness>()
|
|
|
+ .in("plant_code",plantIds)
|
|
|
+ .eq("dev_type" , "设备")
|
|
|
+ .eq("del_flag" , 0)
|
|
|
+ .isNotNull("NEXT_WARN_DATE") // 添加非空条件
|
|
|
+ .and(wrapper -> wrapper
|
|
|
+ .le("NEXT_WARN_DATE", sqlDate)
|
|
|
+ )
|
|
|
+
|
|
|
+ );
|
|
|
+
|
|
|
+ int gdWarn = tMeasureThicknessService.count(new QueryWrapper<TMeasureThickness>()
|
|
|
+ .in("plant_code",plantIds)
|
|
|
+ .and(wrapper -> wrapper
|
|
|
+ .ne("dev_type", "设备") // 排除 dev_type = '设备'
|
|
|
+ .or() // 或
|
|
|
+ .isNull("dev_type") // 包含 dev_type 为 null 的记录
|
|
|
+ )
|
|
|
+ .eq("del_flag" , 0)
|
|
|
+ .isNotNull("NEXT_WARN_DATE") // 添加非空条件
|
|
|
+ .and(wrapper -> wrapper
|
|
|
+ .le("NEXT_WARN_DATE", sqlDate)
|
|
|
+ )
|
|
|
+ );
|
|
|
+ //
|
|
|
+ Map<String, Object> res = new HashMap<String, Object>();
|
|
|
+ res.put("sbAll" ,sbAll) ;
|
|
|
+ res.put("gdAll" ,gdAll) ;
|
|
|
+ res.put("sbWarn" ,sbWarn) ;
|
|
|
+ res.put("gdWarn" ,gdWarn) ;
|
|
|
+ return AjaxResult.success(res);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 管道预估寿命数据
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "gdData")
|
|
|
+ public AjaxResult gdData(@RequestBody Map<String, Object> params) {
|
|
|
+ List plantIds = (List) params.get("plantIds");
|
|
|
+ if (plantIds == null) {
|
|
|
+ plantIds = new ArrayList();
|
|
|
+ }
|
|
|
+ if (plantIds.size() == 0) {
|
|
|
+ plantIds.add("1");
|
|
|
+ }
|
|
|
+ // 1. 获取当前年份
|
|
|
+ int currentYear = Year.now().getValue();
|
|
|
+
|
|
|
+ // 2. 创建包含当前年份及未来十年的年份列表
|
|
|
+ List<Integer> targetYears = new ArrayList<>();
|
|
|
+ for (int i = 0; i <= 10; i++) {
|
|
|
+ targetYears.add(currentYear + i);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 存储查询结果(年份 -> 过期数据)
|
|
|
+ Map<Integer, List<String>> expiredDataByYear = new HashMap<>();
|
|
|
+ List<Integer> resData = new ArrayList<>();
|
|
|
+ // 4. 遍历每个年份并查询数据
|
|
|
+ for (int year : targetYears) {
|
|
|
+ TMeasureThickness t = new TMeasureThickness();
|
|
|
+ int estRemainMin =year - currentYear;
|
|
|
+ int gd = tMeasureThicknessService.count(new QueryWrapper<TMeasureThickness>()
|
|
|
+ .in("plant_code", plantIds)
|
|
|
+ .and(wrapper -> wrapper
|
|
|
+ .ne("dev_type", "设备") // 排除 dev_type = '设备'
|
|
|
+ .or() // 或
|
|
|
+ .isNull("dev_type") // 包含 dev_type 为 null 的记录
|
|
|
+ )
|
|
|
+ .eq("del_flag", 0)
|
|
|
+ .between("EST_REMAIN", estRemainMin, estRemainMin + 1)
|
|
|
+ );
|
|
|
+ resData.add(gd);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> res = new HashMap<String, Object>();
|
|
|
+ res.put("targetYears" ,targetYears) ;
|
|
|
+ res.put("resData" ,resData) ;
|
|
|
+ return AjaxResult.success(res);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 管道预估寿命数据
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "sbData")
|
|
|
+ public AjaxResult sbData(@RequestBody Map<String, Object> params) {
|
|
|
+ List plantIds = (List) params.get("plantIds");
|
|
|
+ if (plantIds == null) {
|
|
|
+ plantIds = new ArrayList();
|
|
|
+ }
|
|
|
+ if (plantIds.size() == 0) {
|
|
|
+ plantIds.add("1");
|
|
|
+ }
|
|
|
+ // 1. 获取当前年份
|
|
|
+ int currentYear = Year.now().getValue();
|
|
|
+
|
|
|
+ // 2. 创建包含当前年份及未来十年的年份列表
|
|
|
+ List<Integer> targetYears = new ArrayList<>();
|
|
|
+ for (int i = 0; i <= 10; i++) {
|
|
|
+ targetYears.add(currentYear + i);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 存储查询结果(年份 -> 过期数据)
|
|
|
+ Map<Integer, List<String>> expiredDataByYear = new HashMap<>();
|
|
|
+ List<Integer> resData = new ArrayList<>();
|
|
|
+ // 4. 遍历每个年份并查询数据
|
|
|
+ for (int year : targetYears) {
|
|
|
+ TMeasureThickness t = new TMeasureThickness();
|
|
|
+ int estRemainMin =year - currentYear;
|
|
|
+ int gd = tMeasureThicknessService.count(new QueryWrapper<TMeasureThickness>()
|
|
|
+ .in("plant_code", plantIds)
|
|
|
+ .eq("dev_type" , "设备")
|
|
|
+ .eq("del_flag", 0)
|
|
|
+ .between("EST_REMAIN", estRemainMin, estRemainMin + 1)
|
|
|
+ );
|
|
|
+ resData.add(gd);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> res = new HashMap<String, Object>();
|
|
|
+ res.put("targetYears" ,targetYears) ;
|
|
|
+ res.put("resData" ,resData) ;
|
|
|
+ return AjaxResult.success(res);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 管道预估寿命数据
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "gdDataPie")
|
|
|
+ public AjaxResult gdDataPie(@RequestBody Map<String, Object> params) {
|
|
|
+ List plantIds = (List) params.get("plantIds");
|
|
|
+ if (plantIds == null) {
|
|
|
+ plantIds = new ArrayList();
|
|
|
+ }
|
|
|
+ if (plantIds.size() == 0) {
|
|
|
+ plantIds.add("1");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 3. 存储查询结果(年份 -> 过期数据)
|
|
|
+ List<Integer> resData = new ArrayList<>();
|
|
|
+ // 4. 遍历每个年份并查询数据
|
|
|
+ int gd = tMeasureThicknessService.count(new QueryWrapper<TMeasureThickness>()
|
|
|
+ .in("plant_code", plantIds)
|
|
|
+ .and(wrapper -> wrapper
|
|
|
+ .ne("dev_type", "设备") // 排除 dev_type = '设备'
|
|
|
+ .or() // 或
|
|
|
+ .isNull("dev_type") // 包含 dev_type 为 null 的记录
|
|
|
+ )
|
|
|
+ .eq("del_flag", 0)
|
|
|
+ .between("EST_REMAIN", 0, 3)
|
|
|
+ );
|
|
|
+ resData.add(gd);
|
|
|
+
|
|
|
+ int gd2 = tMeasureThicknessService.count(new QueryWrapper<TMeasureThickness>()
|
|
|
+ .in("plant_code", plantIds)
|
|
|
+ .and(wrapper -> wrapper
|
|
|
+ .ne("dev_type", "设备") // 排除 dev_type = '设备'
|
|
|
+ .or() // 或
|
|
|
+ .isNull("dev_type") // 包含 dev_type 为 null 的记录
|
|
|
+ )
|
|
|
+ .eq("del_flag", 0)
|
|
|
+ .between("EST_REMAIN", 3, 6)
|
|
|
+ );
|
|
|
+ resData.add(gd2);
|
|
|
+
|
|
|
+ int gd3 = tMeasureThicknessService.count(new QueryWrapper<TMeasureThickness>()
|
|
|
+ .in("plant_code", plantIds)
|
|
|
+ .and(wrapper -> wrapper
|
|
|
+ .ne("dev_type", "设备") // 排除 dev_type = '设备'
|
|
|
+ .or() // 或
|
|
|
+ .isNull("dev_type") // 包含 dev_type 为 null 的记录
|
|
|
+ )
|
|
|
+ .eq("del_flag", 0)
|
|
|
+ .between("EST_REMAIN", 6, 10)
|
|
|
+ );
|
|
|
+ resData.add(gd3);
|
|
|
+
|
|
|
+ int gd4 = tMeasureThicknessService.count(new QueryWrapper<TMeasureThickness>()
|
|
|
+ .in("plant_code", plantIds)
|
|
|
+ .and(wrapper -> wrapper
|
|
|
+ .ne("dev_type", "设备") // 排除 dev_type = '设备'
|
|
|
+ .or() // 或
|
|
|
+ .isNull("dev_type") // 包含 dev_type 为 null 的记录
|
|
|
+ )
|
|
|
+ .eq("del_flag", 0)
|
|
|
+ .between("EST_REMAIN", 10, 999)
|
|
|
+ );
|
|
|
+ resData.add(gd4);
|
|
|
+
|
|
|
+ Map<String, Object> res = new HashMap<String, Object>();
|
|
|
+ res.put("resData" ,resData) ;
|
|
|
+ return AjaxResult.success(res);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 管道预估寿命数据
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "sbDataPie")
|
|
|
+ public AjaxResult sbDataPie(@RequestBody Map<String, Object> params) {
|
|
|
+ List plantIds = (List) params.get("plantIds");
|
|
|
+ if (plantIds == null) {
|
|
|
+ plantIds = new ArrayList();
|
|
|
+ }
|
|
|
+ if (plantIds.size() == 0) {
|
|
|
+ plantIds.add("1");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 3. 存储查询结果(年份 -> 过期数据)
|
|
|
+ List<Integer> resData = new ArrayList<>();
|
|
|
+ // 4. 遍历每个年份并查询数据
|
|
|
+ int gd = tMeasureThicknessService.count(new QueryWrapper<TMeasureThickness>()
|
|
|
+ .in("plant_code", plantIds)
|
|
|
+ .eq("dev_type" , "设备")
|
|
|
+ .eq("del_flag", 0)
|
|
|
+ .between("EST_REMAIN", 0, 3)
|
|
|
+ );
|
|
|
+ resData.add(gd);
|
|
|
+
|
|
|
+ int gd2 = tMeasureThicknessService.count(new QueryWrapper<TMeasureThickness>()
|
|
|
+ .in("plant_code", plantIds)
|
|
|
+ .eq("dev_type" , "设备")
|
|
|
+ .eq("del_flag", 0)
|
|
|
+ .between("EST_REMAIN", 3, 6)
|
|
|
+ );
|
|
|
+ resData.add(gd2);
|
|
|
+
|
|
|
+ int gd3 = tMeasureThicknessService.count(new QueryWrapper<TMeasureThickness>()
|
|
|
+ .in("plant_code", plantIds)
|
|
|
+ .eq("dev_type" , "设备")
|
|
|
+ .eq("del_flag", 0)
|
|
|
+ .between("EST_REMAIN", 6, 10)
|
|
|
+ );
|
|
|
+ resData.add(gd3);
|
|
|
+
|
|
|
+ int gd4 = tMeasureThicknessService.count(new QueryWrapper<TMeasureThickness>()
|
|
|
+ .in("plant_code", plantIds)
|
|
|
+ .eq("dev_type" , "设备")
|
|
|
+ .eq("del_flag", 0)
|
|
|
+ .between("EST_REMAIN", 10, 999)
|
|
|
+ );
|
|
|
+ resData.add(gd4);
|
|
|
+
|
|
|
+ Map<String, Object> res = new HashMap<String, Object>();
|
|
|
+ res.put("resData" ,resData) ;
|
|
|
+ return AjaxResult.success(res);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|