|
@@ -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();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查询上岗证/作业证书一览列表
|
|
|
*/
|