Forráskód Böngészése

SAI检查管理:开项数据导入、计算装置自查人均扣分

wangggziwen 2 éve
szülő
commit
5dce0ccc4e

+ 60 - 1
master/src/main/java/com/ruoyi/project/production/controller/TSaiController.java

@@ -1,6 +1,9 @@
 package com.ruoyi.project.production.controller;
 
 import java.io.IOException;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.math.RoundingMode;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.List;
@@ -8,6 +11,8 @@ import java.util.List;
 import com.alibaba.fastjson.JSON;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.file.ExcelUtils;
+import com.ruoyi.project.plant.domain.TStaffmgr;
+import com.ruoyi.project.plant.service.ITStaffmgrService;
 import com.ruoyi.project.production.controller.vo.SaiQueryVO;
 import com.ruoyi.project.system.domain.SysDept;
 import com.ruoyi.project.system.mapper.SysDeptMapper;
@@ -56,6 +61,47 @@ public class TSaiController extends BaseController
     @Autowired
     private SysDeptMapper sysDeptMapper;
 
+    @Autowired
+    private ITStaffmgrService staffmgrService;
+
+    /**
+     * 计算当年装置自查人均扣分
+     */
+    @PreAuthorize("@ss.hasPermi('production:sai:query')")
+    @GetMapping(value = "/calcScoreByYear/{saiYear}")
+    public AjaxResult calcScoreByYear(@PathVariable("saiYear") int saiYear)
+    {
+        String score = "未知";
+        SaiQueryVO tSai = new SaiQueryVO();
+        tSai.setSaiYear(saiYear);
+        List<TSai> tSais = tSaiService.selectTSaiListByYear(tSai);
+        BigDecimal sum = BigDecimal.ZERO;
+        BigDecimal avg = BigDecimal.ZERO;
+        for (TSai sai : tSais) {
+            if (sai.getSource().equals("装置") || sai.getSource().equals("督导")) {
+                Long saiLevel = sai.getSaiLevel();
+                if (saiLevel == 1L) {
+                    sum = sum.add(new BigDecimal("1"));
+                }
+                if (saiLevel == 2L) {
+                    sum = sum.add(new BigDecimal("2"));
+                }
+                if (saiLevel == 3L) {
+                    sum = sum.add(new BigDecimal("3"));
+                }
+            }
+        }
+        TStaffmgr staffmgr = new TStaffmgr();
+        staffmgr.setDeptId(103L);
+        List<TStaffmgr> tStaffmgrs = staffmgrService.selectTStaffmgrList(staffmgr);
+        int num = tStaffmgrs.size();
+        if (sum.compareTo(BigDecimal.ZERO) != 0 && num != 0) {
+            avg = sum.divide(new BigDecimal(num), 3, RoundingMode.HALF_UP);
+            score = avg.toString();
+        }
+        return AjaxResult.success(score);
+    }
+
     /**
      * 查询SAI信息列表
      */
@@ -213,7 +259,20 @@ public class TSaiController extends BaseController
     @PostMapping
     public AjaxResult add(@RequestBody TSai tSai)
     {
-        return toAjax(tSaiService.insertTSai(tSai));
+        Long saiApplyId = tSai.getSaiApplyId();
+        if (saiApplyId != null) {
+            TSai sai = new TSai();
+            sai.setSaiApplyId(saiApplyId);
+            List<TSai> tSais = tSaiService.selectTSaiList(sai);
+            if (tSais.size() != 0) {
+                tSai.setSaiId(tSais.get(0).getSaiId());
+                return toAjax(tSaiService.updateTSai(tSai));
+            } else {
+                return toAjax(tSaiService.insertTSai(tSai));
+            }
+        } else {
+            return toAjax(tSaiService.insertTSai(tSai));
+        }
     }
 
     /**

+ 12 - 0
master/src/main/java/com/ruoyi/project/production/domain/TSai.java

@@ -55,6 +55,18 @@ public class TSai extends BaseEntity
     @Excel(name = "数据来源")
     private String source;
 
+    /** SAI开项申请编号 */
+    @Excel(name = "SAI开项申请编号")
+    private Long saiApplyId;
+
+    public Long getSaiApplyId() {
+        return saiApplyId;
+    }
+
+    public void setSaiApplyId(Long saiApplyId) {
+        this.saiApplyId = saiApplyId;
+    }
+
     /** 删除状态 */
     private String delFlag;
 

+ 6 - 1
master/src/main/resources/mybatis/production/TSaiMapper.xml

@@ -20,10 +20,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="updateBy"    column="update_by"    />
         <result property="updateTime"    column="update_time"    />
         <result property="deptName" column="dept_name" />
+        <result property="saiApplyId"    column="sai_apply_id"    />
     </resultMap>
 
     <sql id="selectTSaiVo">
-        select d.sai_id, d.plant_id, d.inspection_date, d.dificiency, d.sai_level, d.category, d.actions, d.user_dept, d.source, d.del_flag, d.create_by, d.create_time, d.update_by, d.update_time ,d.dept_id, s.dept_name from t_sai d
+        select d.sai_id, d.plant_id, d.inspection_date, d.dificiency, d.sai_level, d.category, d.actions, d.user_dept, d.source, d.del_flag, d.create_by, d.create_time, d.update_by, d.update_time ,d.dept_id, d.sai_apply_id, s.dept_name from t_sai d
       left join sys_dept s on s.dept_id = d.dept_id
     </sql>
 
@@ -51,6 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="actions != null  and actions != ''"> and actions = #{actions}</if>
             <if test="userDept != null  and userDept != ''"> and user_dept = #{userDept}</if>
             <if test="source != null  and source != ''"> and source = #{source}</if>
+            <if test="saiApplyId != null "> and sai_apply_id = #{saiApplyId}</if>
             and d.del_flag = 0
         </where>
         <!-- 数据范围过滤 -->
@@ -83,6 +85,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">update_by,</if>
             <if test="updateTime != null">update_time,</if>
             <if test="deptId != null">dept_id,</if>
+            <if test="saiApplyId != null">sai_apply_id,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="saiId != null">#{saiId},</if>
@@ -100,6 +103,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="deptId != null">#{deptId},</if>
+            <if test="saiApplyId != null">#{saiApplyId},</if>
          </trim>
     </insert>
 
@@ -119,6 +123,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="saiApplyId != null">sai_apply_id = #{saiApplyId},</if>
         </trim>
         where sai_id = #{saiId}
     </update>

+ 8 - 0
ui/src/api/production/sai.js

@@ -1,5 +1,13 @@
 import request from '@/utils/request'
 
+// 计算当年装置自查人均扣分
+export function calcScoreByYear(saiYear) {
+  return request({
+    url: '/production/sai/calcScoreByYear/' + saiYear,
+    method: 'get'
+  })
+}
+
 // 查询SAI信息列表
 export function listSaiByYear(query) {
   return request({

+ 91 - 9
ui/src/views/production/apply/all/index.vue

@@ -106,15 +106,15 @@
           v-hasPermi="['production:apply:add']"
         >新增申请单</el-button>
       </el-col>
-        <el-col :span="1.5">
-            <el-button
-                    type="info"
-                    icon="el-icon-upload2"
-                    size="mini"
-                    @click="handleImport"
-                    v-hasPermi="['production:apply:edit']"
-            >导入</el-button>
-        </el-col>
+      <el-col :span="1.5">
+          <el-button
+                  type="info"
+                  icon="el-icon-upload2"
+                  size="mini"
+                  @click="handleImport"
+                  v-hasPermi="['production:apply:edit']"
+          >导入</el-button>
+      </el-col>
       <el-col :span="1.5">
         <el-button
           type="warning"
@@ -123,6 +123,13 @@
           @click="handleExport"
           v-hasPermi="['production:apply:export']"
         >导出</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          size="mini"
+          @click="handleAddSai"
+          v-hasPermi="['production:sai:add']"
+        >统计至SAI检查台账</el-button>
       </el-col>
 	  <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
@@ -460,6 +467,41 @@
         <el-button @click="doc.open = false">{{ $t('返 回') }}</el-button>
       </div>
     </el-dialog>
+    <!-- 统计至SAI检查台账对话框 -->
+    <el-dialog title="统计至SAI检查台账" :visible.sync="saiOpen" width="80%" append-to-body>
+      <el-table v-loading="loading" :data="saiList" @selection-change="handleSelectionChange" :height="clientHeight" border>
+        <el-table-column type="selection" width="55" align="center" />
+        <el-table-column label="检查的装置/设施" align="center" prop="plantId" :show-overflow-tooltip="true"/>
+        <el-table-column label="检查日期/时间" align="center" prop="inspectionDate">
+          <template slot-scope="scope">
+            <span>{{ parseTime(scope.row.inspectionDate, '{y}-{m}-{d}') }}</span>
+          </template>
+        </el-table-column>
+        <el-table-column label="识别出的安全问题" align="center" prop="dificiency" :show-overflow-tooltip="true"/>
+        <el-table-column label="SAI级别" align="center" prop="saiLevel" :show-overflow-tooltip="true" width="100">
+          <template slot-scope="scope">
+            <el-select v-model="scope.row.saiLevel" placeholder="请选择">
+              <el-option key="1" label="1" value="1"></el-option>
+              <el-option key="2" label="2" value="2"></el-option>
+              <el-option key="3" label="3" value="3"></el-option>
+            </el-select>
+          </template>
+        </el-table-column>
+        <el-table-column label="SAI类别" align="center" prop="category" :show-overflow-tooltip="true">
+          <template slot-scope="scope">
+            <el-input v-model="scope.row.category" placeholder="请输入" />
+          </template>
+        </el-table-column>
+        <el-table-column label="采取或要采取的措施" align="center" prop="actions" :show-overflow-tooltip="true"/>
+        <el-table-column label="用户" align="center" prop="userDeptId" :show-overflow-tooltip="true"/>
+        <el-table-column label="数据来源" align="center" prop="source" :show-overflow-tooltip="true"/>
+      </el-table>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitSaiForm">确 定</el-button>
+        <el-button @click="cancel">取 消</el-button>
+      </div>
+    </el-dialog>
+
     <!-- 预览对话框 -->
     <el-dialog  v-loading="loadingFlash"     element-loading-background="rgba(0,0,0,0.2)"                 v-dialogDrag :title="pdf.title" :visible.sync="pdf.open"  width="1300px" :center="true" append-to-body>
       <div style="margin-top: -60px;float: right;margin-right: 40px;">
@@ -481,6 +523,7 @@
 
 <script>
 import { submitApply, listApply, getApply, delApply, addApply, updateApply, exportApply, importTemplate} from "@/api/production/apply";
+import { addSai } from "@/api/production/sai";
 import { treeselect, listDept } from "@/api/system/dept";
 import { getToken } from "@/utils/auth";
 import Treeselect from "@riophae/vue-treeselect";
@@ -539,6 +582,10 @@ export default {
       }
     };
     return {
+      // 统计至SAI检查台账的数据
+      saiList: [],
+      // 是显示用统计至SAI检查台账对话框
+      saiOpen: false,
       // 是否禁用开项编号输入框
       recordNoDisabled: true,
       // 当前登录员工
@@ -1083,6 +1130,7 @@ export default {
      },
     // 取消按钮
     cancel() {
+      this.saiOpen = false;
       this.open = false;
       this.reset();
     },
@@ -1186,6 +1234,16 @@ export default {
         }
       });
     },
+    /** 统计至SAI检查台账提交按钮 */
+    submitSaiForm() {
+      for (let i = 0; i < this.saiList.length; i++) {
+        this.saiList[i].plantId = 103;
+        this.saiList[i].userDeptId = 103;
+        addSai(this.saiList[i]);
+      }
+      this.msgSuccess("提交成功");
+      this.saiOpen = false;
+    },
     /** 延期提交按钮 */
     submitDelayForm() {
       this.$refs["delayForm"].validate(valid => {
@@ -1198,6 +1256,30 @@ export default {
         }
       });
     },
+    /** 统计至SAI检查台账按钮操作 */
+    handleAddSai(row) {
+      const saiApplyIds = row.saiApplyId || this.ids;
+      if(saiApplyIds.length != 0) {
+        this.saiList = [];
+        for (let i = 0; i < saiApplyIds.length; i ++) {
+          getApply(saiApplyIds[i]).then(response => {
+            let apply = response.data;
+            let sai = {};
+            sai.saiApplyId = apply.saiApplyId;
+            sai.plantId = "CBP/C";
+            sai.userDeptId = "CBP/C";
+            sai.inspectionDate = apply.applyDate;
+            sai.dificiency = apply.description;
+            sai.actions = apply.reaction;
+            sai.source = "公司";
+            sai.deptId = 103;
+            sai.saiLevel = "1";
+            this.saiList.push(sai);
+          });
+        }
+        this.saiOpen = true;
+      }
+    },
     /** 删除按钮操作 */
     handleDelete(row) {
       const saiApplyIds = row.saiApplyId || this.ids;

+ 3 - 4
ui/src/views/production/apply/index.vue

@@ -24,11 +24,10 @@ export default {
   components: { All },
   data() {
     return {
-      // 默认第一个Tab
-      activeName: 'first',
-      isFirst: true,
+      activeName: 'third',
+      isFirst: false,
       isSecond: false,
-      isThird: false,
+      isThird: true,
     }
   },
   methods: {

+ 32 - 18
ui/src/views/production/check/index.vue

@@ -2,7 +2,7 @@
   <div class="app-container">
     <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
       <el-form-item label="评估年度" prop="saiYear">
-        <el-date-picker clearable size="small" style="width: 200px"
+        <el-date-picker size="small" style="width: 200px"
           v-model="queryParams.saiYear"
           type="year"
           value-format="yyyy"
@@ -71,20 +71,19 @@
           v-hasPermi="['production:sai:export']"
         >导出</el-button>
       </el-col>
-	  <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+	  <right-toolbar :showSearch.sync="showSearch" @queryTable="getListByYear()"></right-toolbar>
     </el-row>
 
     <el-row class="colorMark">
       <span style="float:left;">
-        <svg-icon id="score" icon-class="rectangleGreen" class="rectangleGreen"></svg-icon>
-        安全行为指数:{{score}}
+        装置自查人均扣分:{{score}}
       </span>
-      <svg-icon icon-class="rectangleGreen" class="rectangleGreen"></svg-icon>
-      <span>合格</span>
-      <svg-icon icon-class="rectangleYellow" class="rectangleYellow"></svg-icon>
-      <span>预警</span>
-      <svg-icon icon-class="rectanglered" class="rectangleRed"></svg-icon>
-      <span>报警</span>
+      <!--<svg-icon icon-class="rectangleGreen" class="rectangleGreen"></svg-icon>-->
+      <!--<span>合格</span>-->
+      <!--<svg-icon icon-class="rectangleYellow" class="rectangleYellow"></svg-icon>-->
+      <!--<span>预警</span>-->
+      <!--<svg-icon icon-class="rectanglered" class="rectangleRed"></svg-icon>-->
+      <!--<span>报警</span>-->
     </el-row>
 
     <el-table v-loading="loading" :data="saiList" @selection-change="handleSelectionChange" :height="clientHeight" border>
@@ -96,8 +95,8 @@
         </template>
       </el-table-column>
       <el-table-column label="识别出的安全问题" align="center" prop="dificiency" :show-overflow-tooltip="true"/>
-      <el-table-column label="级别" align="center" prop="saiLevel" :show-overflow-tooltip="true"/>
-      <el-table-column label="类别" align="center" prop="category" :show-overflow-tooltip="true"/>
+      <el-table-column label="SAI级别" align="center" prop="saiLevel" :show-overflow-tooltip="true"/>
+      <el-table-column label="SAI类别" align="center" prop="category" :show-overflow-tooltip="true"/>
       <el-table-column label="采取或要采取的措施" align="center" prop="actions" :show-overflow-tooltip="true"/>
       <el-table-column label="用户" align="center" prop="userDeptName" :show-overflow-tooltip="true"/>
       <el-table-column label="数据来源" align="center" prop="source" :show-overflow-tooltip="true"/>
@@ -126,7 +125,7 @@
       :total="total"
       :page.sync="queryParams.pageNum"
       :limit.sync="queryParams.pageSize"
-      @pagination="getList"
+      @pagination="getListByYear"
     />
 
     <!-- 添加或修改SAI信息对话框 -->
@@ -147,10 +146,14 @@
           <el-input v-model="form.dificiency" placeholder="请输入识别出的安全问题" />
         </el-form-item>
         <el-form-item label="级别" prop="saiLevel">
-          <el-input v-model="form.saiLevel" placeholder="请输入级别" />
+          <el-select v-model="form.saiLevel" placeholder="请选择SAI级别">
+            <el-option key="1" label="1" value="1"></el-option>
+            <el-option key="2" label="2" value="2"></el-option>
+            <el-option key="3" label="3" value="3"></el-option>
+          </el-select>
         </el-form-item>
-        <el-form-item label="类别" prop="category">
-          <el-input v-model="form.category" placeholder="请输入类别" />
+        <el-form-item label="SAI类别" prop="category">
+          <el-input v-model="form.category" placeholder="请输入SAI类别" />
         </el-form-item>
         <el-form-item label="采取或要采取的措施" prop="actions">
           <el-input v-model="form.actions" placeholder="请输入采取或要采取的措施" />
@@ -212,7 +215,7 @@
 </template>
 
 <script>
-import { listSai, listSaiByYear, getSai, delSai, addSai, updateSai, exportSai, importTemplate} from "@/api/production/sai";
+import { calcScoreByYear, listSai, listSaiByYear, getSai, delSai, addSai, updateSai, exportSai, importTemplate} from "@/api/production/sai";
 import { treeselect, alltreeselect } from "@/api/system/dept";
 import { getToken } from "@/utils/auth";
 import Treeselect from "@riophae/vue-treeselect";
@@ -223,7 +226,7 @@ export default {
   components: { Treeselect },
   data() {
     return {
-      score: 0,
+      score: null,
       // 遮罩层
       loading: true,
       // 选中数组
@@ -301,9 +304,17 @@ export default {
       })
     // this.getList();
     this.getListByYear();
+    this.calcScoreByYear();
     this.getTreeselect();
   },
   methods: {
+    /** 计算当年装置自查人均扣分 */
+    calcScoreByYear() {
+      calcScoreByYear(this.queryParams.saiYear).then(response => {
+        this.score = response.msg;
+      });
+    },
+    /** 评估年度默认为当年 */
     setYear() {
       this.queryParams.saiYear = new Date().getFullYear().toString();
     },
@@ -314,6 +325,7 @@ export default {
         this.saiList = response.rows;
         this.total = response.total;
         this.loading = false;
+        this.calcScoreByYear();
       });
     },
     getList() {
@@ -396,12 +408,14 @@ export default {
               this.msgSuccess("修改成功");
               this.open = false;
               this.getListByYear();
+              this.calcScoreByYear();
             });
           } else {
             addSai(this.form).then(response => {
               this.msgSuccess("新增成功");
               this.open = false;
               this.getListByYear();
+              this.calcScoreByYear();
             });
           }
         }