소스 검색

上岗证/作业证书一览表 - 同步人员数据

wangggziwen 1 년 전
부모
커밋
6c36704749

+ 87 - 0
master/src/main/java/com/ruoyi/project/training/controller/TWorklicenseCertificateController.java

@@ -1,6 +1,12 @@
 package com.ruoyi.project.training.controller;
 
+import java.util.ArrayList;
 import java.util.List;
+
+import com.ruoyi.project.plant.domain.TStaffmgr;
+import com.ruoyi.project.plant.service.ITStaffmgrService;
+import com.ruoyi.project.system.domain.SysDictData;
+import com.ruoyi.project.system.service.ISysDictTypeService;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -33,6 +39,87 @@ public class TWorklicenseCertificateController extends BaseController
     @Autowired
     private ITWorklicenseCertificateService tWorklicenseCertificateService;
 
+    @Autowired
+    private ITStaffmgrService staffmgrService;
+
+    @Autowired
+    private ISysDictTypeService iSysDictTypeService;
+
+    /**
+     * 同步人员数据
+     */
+    @PreAuthorize("@ss.hasPermi('training:worklicensecertificate:add')")
+    @GetMapping("/syncStaff")
+    public AjaxResult syncStaff()
+    {
+        //字典查询
+        List<SysDictData> teamDivideDict = iSysDictTypeService.selectDictDataByType("TEAM_DIVIDE");
+        List<SysDictData> actualPostDict = iSysDictTypeService.selectDictDataByType("ACTUALPOST");
+        String teamValueA = "";
+        String teamValueB = "";
+        String teamValueC = "";
+        String teamValueD = "";
+        for (SysDictData sysDictData : teamDivideDict) {
+            if (sysDictData.getDictLabel().equals("A")) {
+                teamValueA = sysDictData.getDictValue();
+            }
+            if (sysDictData.getDictLabel().equals("B")) {
+                teamValueB = sysDictData.getDictValue();
+            }
+            if (sysDictData.getDictLabel().equals("C")) {
+                teamValueC = sysDictData.getDictValue();
+            }
+            if (sysDictData.getDictLabel().equals("D")) {
+                teamValueD = sysDictData.getDictValue();
+            }
+        }
+        // 员工表
+        List<TStaffmgr> tStaffmgrs = new ArrayList<TStaffmgr>();
+        List<TStaffmgr> tStaffmgrAll = staffmgrService.selectTStaffmgrList(new TStaffmgr());
+        for (TStaffmgr tStaffmgr : tStaffmgrAll) {
+            String team = tStaffmgr.getTeam();
+            if (teamValueA.equals(team) || teamValueB.equals(team) || teamValueC.equals(team) || teamValueD.equals(team)) {
+                tStaffmgrs.add(tStaffmgr);
+            }
+        }
+        // 上岗证/作业证书表
+        List<TWorklicenseCertificate> tWorklicenseCertificates = tWorklicenseCertificateService.selectTWorklicenseCertificateList(new TWorklicenseCertificate());
+        // 新增列表
+        List<TWorklicenseCertificate> tWorklicenseCertificatesAdd = new ArrayList<TWorklicenseCertificate>();
+        // 对比两张表
+        for (TStaffmgr tStaffmgr : tStaffmgrs) {
+            String staffid = tStaffmgr.getStaffid();
+            boolean isAddFlag = false;
+            for (TWorklicenseCertificate tWorklicenseCertificate : tWorklicenseCertificates) {
+                String employeeid = tWorklicenseCertificate.getEmployeeid();
+                if (employeeid.equals(staffid)) {
+                    isAddFlag = true;
+                }
+            }
+            if (!isAddFlag) {
+                TWorklicenseCertificate cert = new TWorklicenseCertificate();
+                cert.setDeptId(tStaffmgr.getDeptId());
+                cert.setName(tStaffmgr.getName());
+                cert.setEmployeeid(tStaffmgr.getStaffid());
+                for (SysDictData sysDictData : teamDivideDict) {
+                    if (sysDictData.getDictValue().equals(tStaffmgr.getTeam())) {
+                        cert.setClasses(sysDictData.getDictLabel());
+                    }
+                }
+                for (SysDictData sysDictData : actualPostDict) {
+                    if (sysDictData.getDictValue().equals(tStaffmgr.getActualpost())) {
+                        cert.setPost(sysDictData.getDictLabel());
+                    }
+                }
+                tWorklicenseCertificatesAdd.add(cert);
+            }
+        }
+        for (TWorklicenseCertificate tWorklicenseCertificate : tWorklicenseCertificatesAdd) {
+            tWorklicenseCertificateService.insertTWorklicenseCertificate(tWorklicenseCertificate);
+        }
+        return AjaxResult.success();
+    }
+
     /**
      * 查询上岗证/作业证书一览列表
      */

+ 9 - 1
ui/src/api/training/worklicensecertificate.js

@@ -1,5 +1,13 @@
 import request from '@/utils/request'
 
+// 同步人员数据
+export function syncStaff() {
+  return request({
+    url: '/training/worklicensecertificate/syncStaff',
+    method: 'get'
+  })
+}
+
 // 查询上岗证/作业证书一览列表
 export function listWorklicensecertificate(query) {
   return request({
@@ -50,4 +58,4 @@ export function exportWorklicensecertificate(query) {
     method: 'get',
     params: query
   })
-}
+}

+ 15 - 2
ui/src/views/training/worklicensecertificate/index.vue

@@ -72,12 +72,13 @@
           v-hasPermi="['training:worklicensecertificate:add']"
           icon="el-icon-refresh"
           size="mini"
+          @click="syncStaff"
         >同步人员数据</el-button>
       </el-col>
 	  <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
-    <el-table v-loading="loading" :data="worklicensecertificateList" @selection-change="handleSelectionChange" :height="clientHeight" border
+    <el-table v-loading="loading" :element-loading-text="loadingText" :data="worklicensecertificateList" @selection-change="handleSelectionChange" :height="clientHeight" border
               :cell-style="tableCellStyle"
               :header-cell-style="tableHeaderStyle">
       <el-table-column type="selection" width="55" align="center" />
@@ -604,7 +605,7 @@
 </template>
 
 <script>
-import { listWorklicensecertificate, getWorklicensecertificate, delWorklicensecertificate, addWorklicensecertificate, updateWorklicensecertificate, exportWorklicensecertificate, importTemplate} from "@/api/training/worklicensecertificate";
+import { syncStaff, listWorklicensecertificate, getWorklicensecertificate, delWorklicensecertificate, addWorklicensecertificate, updateWorklicensecertificate, exportWorklicensecertificate, importTemplate} from "@/api/training/worklicensecertificate";
 import { treeselect } from "@/api/system/dept";
 import { getToken } from "@/utils/auth";
 import Treeselect from "@riophae/vue-treeselect";
@@ -619,6 +620,7 @@ export default {
     return {
       // 遮罩层
       loading: true,
+      loadingText: "",
       // 选中数组
       ids: [],
       // 非单个禁用
@@ -782,6 +784,16 @@ export default {
     this.getTreeselect();
   },
   methods: {
+    // 同步人员数据
+    syncStaff() {
+      this.loading = true;
+      this.loadingText = '同步中...'
+      syncStaff({}).then(response => {
+        this.msgSuccess("同步成功");
+        this.loading = false;
+        this.getList();
+      });
+    },
     tableHeaderStyle({row, column, rowIndex, columnIndex}) {
       let style = "text-align:center;";
       if ((rowIndex === 0 && columnIndex === 8) || (rowIndex === 1 && columnIndex === 0)
@@ -974,6 +986,7 @@ export default {
     /** 查询上岗证/作业证书一览列表 */
     getList() {
       this.loading = true;
+      this.loadingText = '查询中...'
       listWorklicensecertificate(this.queryParams).then(response => {
         this.worklicensecertificateList = response.rows;
         this.total = response.total;