Browse Source

-修改特种设备首页压力管道长度计算功能

jiangbiao 2 years ago
parent
commit
7104081fcd

+ 84 - 61
master/src/main/java/com/ruoyi/project/sems/controller/SpecHomeController.java

@@ -2,47 +2,29 @@ package com.ruoyi.project.sems.controller;
 
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.ruoyi.common.utils.document.DocumentHandler;
-import com.ruoyi.common.utils.document.PDFTemplateUtil;
+import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.poi.ExcelUtil;
-import com.ruoyi.framework.aspectj.lang.annotation.Log;
-import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
 import com.ruoyi.framework.web.controller.BaseController;
 import com.ruoyi.framework.web.domain.AjaxResult;
 import com.ruoyi.framework.web.page.TableDataInfo;
-import com.ruoyi.project.approve.damain.DevTask;
-import com.ruoyi.project.listener.semsApprove.*;
 import com.ruoyi.project.sems.domain.*;
-import com.ruoyi.project.sems.mapper.TApproveMapper;
 import com.ruoyi.project.sems.service.*;
 import com.ruoyi.project.system.domain.SysDictData;
 import com.ruoyi.project.system.domain.SysPlant;
-import com.ruoyi.project.system.domain.SysUser;
 import com.ruoyi.project.system.service.ISysDictTypeService;
 import com.ruoyi.project.system.service.ISysPlantService;
 import com.ruoyi.project.system.service.ISysUserService;
-import freemarker.template.Template;
-import org.activiti.engine.*;
-import org.activiti.engine.history.HistoricProcessInstance;
-import org.activiti.engine.history.HistoricTaskInstance;
-import org.activiti.engine.history.HistoricTaskInstanceQuery;
-import org.activiti.engine.impl.identity.Authentication;
-import org.activiti.engine.runtime.ProcessInstance;
-import org.activiti.engine.task.Comment;
-import org.activiti.engine.task.Task;
-import org.apache.commons.lang.StringUtils;
+import org.activiti.engine.HistoryService;
+import org.activiti.engine.RuntimeService;
+import org.activiti.engine.TaskService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.OutputStream;
 import java.math.BigDecimal;
 import java.text.DecimalFormat;
-import java.text.SimpleDateFormat;
 import java.util.*;
 
 /**
@@ -113,43 +95,43 @@ public class SpecHomeController extends BaseController
 
         );
         //查询管道长度
-        List<TSpecdevYlgd> gdList = tSpecdevYlgdService.list(new QueryWrapper<TSpecdevYlgd>()
-                        .eq("STATUS" , 1)
-                        .eq("del_flag" , 0)
-                        .in("plant_code",plantIds)
-//                        .in("unit",unitIds)
-//                .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
-//                        .and(unitIds.size()>0 ,i -> i.in("unit",unitIds).or().in("plant_code",unitIds).or().isNull("unit"))
-        );
-        double allLength = 0;
-        for (int i = 0; i < gdList.size(); i++) {
-            double gdLength = 0;
-            if (!StringUtils.isBlank(gdList.get(i).getLength())) {
-                if (gdList.get(i).getLength().indexOf("\n") > -1) {
-                    String[] arr = gdList.get(i).getLength().split("\n");
-                    for (int j = 0; j < arr.length; j++) {
-                        try {
-                            gdLength += Double.parseDouble(arr[j]);
-                        }catch (NumberFormatException e) {
-                            logger.error(JSON.toJSONString(e));
-                            continue;
-                        }
-                    }
-                }else {
-                    try {
-                        gdLength = Double.parseDouble(gdList.get(i).getLength());
-                    }catch (NumberFormatException e) {
-                        logger.error(JSON.toJSONString(e));
-                    }
-                }
-            }
-            allLength += gdLength;
-        }
-        DecimalFormat df = new DecimalFormat("0.00#");
-        System.out.println(df.format(allLength));
+//        List<TSpecdevYlgd> gdList = tSpecdevYlgdService.list(new QueryWrapper<TSpecdevYlgd>()
+//                        .eq("STATUS" , 1)
+//                        .eq("del_flag" , 0)
+//                        .in("plant_code",plantIds)
+////                        .in("unit",unitIds)
+////                .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
+////                        .and(unitIds.size()>0 ,i -> i.in("unit",unitIds).or().in("plant_code",unitIds).or().isNull("unit"))
+//        );
+//        double allLength = 0;
+//        for (int i = 0; i < gdList.size(); i++) {
+//            double gdLength = 0;
+//            if (!StringUtils.isBlank(gdList.get(i).getLength())) {
+//                if (gdList.get(i).getLength().indexOf("\n") > -1) {
+//                    String[] arr = gdList.get(i).getLength().split("\n");
+//                    for (int j = 0; j < arr.length; j++) {
+//                        try {
+//                            gdLength += Double.parseDouble(arr[j]);
+//                        }catch (NumberFormatException e) {
+//                            logger.error(JSON.toJSONString(e));
+//                            continue;
+//                        }
+//                    }
+//                }else {
+//                    try {
+//                        gdLength = Double.parseDouble(gdList.get(i).getLength());
+//                    }catch (NumberFormatException e) {
+//                        logger.error(JSON.toJSONString(e));
+//                    }
+//                }
+//            }
+//            allLength += gdLength;
+//        }
+        //DecimalFormat df = new DecimalFormat("0.00#");
+        //System.out.println(df.format(allLength));
         Map<String, Object> mapylgd = new HashMap<String, Object>();
         mapylgd.put("ylgdAll_num", ylgdAll);
-        mapylgd.put("ylgd_length", df.format(allLength));
+        //mapylgd.put("ylgd_length", df.format(allLength));
         //压力容器
         int ylrqAll = tSpecdevYlrqService.count(new QueryWrapper<TSpecdevYlrq>()
                 .eq("STATUS" , 1)
@@ -219,6 +201,47 @@ public class SpecHomeController extends BaseController
         return AjaxResult.success(res);
     }
 
+    @RequestMapping(value="ylgcLength")
+    public AjaxResult sumYlgcLength(@RequestBody Map<String, Object> params){
+        List plantIds = (List) params.get("plantIds");
+//        查询管道长度
+        List<TSpecdevYlgd> gdList = tSpecdevYlgdService.list(new QueryWrapper<TSpecdevYlgd>()
+                        .eq("STATUS" , 1)
+                        .eq("del_flag" , 0)
+                        .in("plant_code",plantIds)
+//                        .in("unit",unitIds)
+//                .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
+//                        .and(unitIds.size()>0 ,i -> i.in("unit",unitIds).or().in("plant_code",unitIds).or().isNull("unit"))
+        );
+        double allLength = 0;
+        for (int i = 0; i < gdList.size(); i++) {
+            double gdLength = 0;
+            if (!StringUtils.isBlank(gdList.get(i).getLength())) {
+                if (gdList.get(i).getLength().indexOf("\n") > -1) {
+                    String[] arr = gdList.get(i).getLength().split("\n");
+                    for (int j = 0; j < arr.length; j++) {
+                        try {
+                            gdLength += Double.parseDouble(arr[j]);
+                        }catch (NumberFormatException e) {
+                            logger.error(JSON.toJSONString(e));
+                            continue;
+                        }
+                    }
+                }else {
+                    try {
+                        gdLength = Double.parseDouble(gdList.get(i).getLength());
+                    }catch (NumberFormatException e) {
+                        logger.error(JSON.toJSONString(e));
+                    }
+                }
+            }
+            allLength += gdLength;
+        }
+        DecimalFormat df = new DecimalFormat("0.00#");
+        System.out.println(df.format(allLength));
+        return AjaxResult.success(df.format(allLength));
+    }
+
     /**
      * 压力容器数据
      */

+ 6 - 0
ui/src/api/sems/home.js

@@ -24,6 +24,12 @@ export function devData(data) {
     method: 'post',
     data: data
   })
+}export function ylgdLength(data) {
+  return request({
+    url: '/sems/home/ylgcLength',
+    method: 'post',
+    data: data
+  })
 }
 
 // 查询压力容器

+ 20 - 5
ui/src/views/sems/specanalysis/index.vue

@@ -73,8 +73,10 @@
                 <div class="specFontSmall" style="margin-top: 0.3rem"><span style="font-size: 10px; color: #4a7d87;margin-right: 0.1rem">{{ $t('设备数') }}</span>{{
                     devDatas.ylgdData.ylgdAll_num
                   }}<span style="font-size: 10px; color: #4a7d87; margin-left: 0.1rem">{{ $t('条') }}</span></div>
-                <div class="specFontSmall"><span style="font-size: 10px; color: #4a7d87;margin-right: 0.1rem">{{ $t('总长度') }}</span>{{ devDatas.ylgdData.ylgd_length }}<span
-                  style="font-size: 10px; color: #4a7d87; margin-left: 0.1rem">{{ $t('米') }}</span></div>
+                <div class="specFontSmall"><span style="font-size: 10px; color: #4a7d87;margin-right: 0.1rem">{{ $t('总长度') }}</span>
+                  <span v-if="ylgd_length==''" style="font-size: 10px; color: #4a7d87; margin-left: 0.1rem">{{ $t('计算中') }}</span>
+                  {{ ylgd_length }}
+                  <span v-if="ylgd_length!=''" style="font-size: 10px; color: #4a7d87; margin-left: 0.1rem">{{ $t('米') }}</span></div>
               </div>
             </div>
           </div>
@@ -308,7 +310,7 @@ import approveChart from "./ApproveChart"
 import centerChart from "./centerChart"
 import finishChart from "./FinishChart"
 import {listPlant, listUnit, mylistPlant} from "@/api/system/plant";
-import {devData, devGlPerData} from "@/api/sems/home";
+import {devData, devGlPerData, ylgdLength} from "@/api/sems/home";
 import '@/common/flexible.js';
 
 export default {
@@ -327,6 +329,7 @@ export default {
     return {
       checked:true,
       waterVisible: true,
+      ylgd_length: '',
       devDatas: {
         ylrqData: {
           ylrqAll_num: 0,
@@ -334,8 +337,7 @@ export default {
         },
         ylgdData: {
           ylgdAll_num: 0,
-          ylgd_rate: 0,
-          ylgd_length: 0
+          ylgd_rate: 0
         },
         dzsbData: {
           dzsbAll_num: 0,
@@ -418,6 +420,7 @@ export default {
           this.plantIds = ['']
         }
         this.devData()
+        this.ylgdLength()
         this.$refs.pvChart.devYlrqData(this.plantIds, this.unitIds);
         this.$refs.boilerChart.devGlData(this.plantIds, this.unitIds);
         this.$refs.ppChart.devYlgdData(this.plantIds, this.unitIds);
@@ -445,6 +448,7 @@ export default {
         this.plantIds = ['']
       }
       this.devData()
+      this.ylgdLength()
     },
     handleCommand(val) {
       this.unitIds = []
@@ -463,6 +467,7 @@ export default {
         this.checked = false
       }
       this.devData()
+      this.ylgdLength()
     },
     // let allnames = []
     // //保留所有值
@@ -506,6 +511,7 @@ export default {
         this.plantIds = ['']
       }
       this.devData()
+      this.ylgdLength()
       this.$refs.pvChart.devYlrqData(this.plantIds, this.unitIds);
       this.$refs.boilerChart.devGlData(this.plantIds, this.unitIds);
       this.$refs.ppChart.devYlgdData(this.plantIds, this.unitIds);
@@ -525,6 +531,15 @@ export default {
       devData(params).then(response => {
         this.devDatas = response.data
       });
+    },
+    ylgdLength(){
+      let params = {
+        'plantIds': this.plantIds,
+        'unitIds': this.unitIds
+      }
+      ylgdLength(params).then(response => {
+        this.ylgd_length = response.msg
+      });
     }
   }
 };