Przeglądaj źródła

ly 培训定时添加

ly 2 tygodni temu
rodzic
commit
b5239dbd9a
16 zmienionych plików z 481 dodań i 121 usunięć
  1. 14 5
      master/src/main/java/com/ruoyi/framework/task/trainingbcc/TrainingMatrixTask.java
  2. 8 0
      master/src/main/java/com/ruoyi/project/plant/mapper/TStaffmgrMapper.java
  3. 8 0
      master/src/main/java/com/ruoyi/project/plant/service/ITStaffmgrService.java
  4. 6 0
      master/src/main/java/com/ruoyi/project/plant/service/impl/TStaffmgrServiceImpl.java
  5. 136 7
      master/src/main/java/com/ruoyi/project/training/controller/TTrainingMatrixController.java
  6. 144 109
      master/src/main/java/com/ruoyi/project/training/controller/TTrainingbccRegularController.java
  7. 2 0
      master/src/main/java/com/ruoyi/project/training/elearn/service/impl/TElPaperServiceImpl.java
  8. 8 0
      master/src/main/java/com/ruoyi/project/training/mapper/TTrainingMatrixMapper.java
  9. 8 0
      master/src/main/java/com/ruoyi/project/training/mapper/TTrainingbccRegularMapper.java
  10. 8 0
      master/src/main/java/com/ruoyi/project/training/service/ITTrainingMatrixService.java
  11. 8 0
      master/src/main/java/com/ruoyi/project/training/service/ITTrainingbccRegularService.java
  12. 12 0
      master/src/main/java/com/ruoyi/project/training/service/impl/TTrainingMatrixServiceImpl.java
  13. 12 0
      master/src/main/java/com/ruoyi/project/training/service/impl/TTrainingbccRegularServiceImpl.java
  14. 66 0
      master/src/main/resources/mybatis/plant/TStaffmgrMapper.xml
  15. 13 0
      master/src/main/resources/mybatis/training/TTrainingMatrixMapper.xml
  16. 28 0
      master/src/main/resources/mybatis/training/TTrainingbccRegularMapper.xml

+ 14 - 5
master/src/main/java/com/ruoyi/framework/task/trainingbcc/TrainingMatrixTask.java

@@ -73,7 +73,8 @@ public class TrainingMatrixTask extends BaseController
         TTrainingMatrix tTrainingMatrix = new TTrainingMatrix();
         tTrainingMatrix.setDeptId(103l);
         tTrainingMatrix.setTrainingLevel("14");
-        List<TTrainingMatrix> list = tTrainingMatrixService.selectTTrainingMatrixList(tTrainingMatrix);
+        // 使用不带数据权限的查询方法,避免定时任务权限问题
+        List<TTrainingMatrix> list = tTrainingMatrixService.selectTTrainingMatrixListWithoutScope(tTrainingMatrix);
         logger.info("===========" + list.size() + "");
         int currentYear = LocalDate.now().getYear();
         int resNum = 0;
@@ -88,8 +89,8 @@ public class TrainingMatrixTask extends BaseController
                     if (fqYear > 0) {
                         // 根据最新的一次regular记录来判断是否需要添加培训
                         tr.setItem(matrix.getItem());
-                        // 查询该培训项目的所有regular记录,按年份排序
-                        List<TTrainingbccRegular> allRegulars = tTrainingbccRegularService.selectTTrainingbccRegularList(tr);
+                        // 查询该培训项目的所有regular记录,按年份排序(使用不带数据权限的方法)
+                        List<TTrainingbccRegular> allRegulars = tTrainingbccRegularService.selectTTrainingbccRegularListWithoutScope(tr);
                         
                         if (allRegulars.isEmpty()) {
                             // 如果没有任何记录,则添加培训
@@ -172,7 +173,8 @@ public class TrainingMatrixTask extends BaseController
                     TStaffmgr staffmgr = new TStaffmgr();
                     staffmgr.setActualposts(tTrainingRegular.getActualpostId());
                     staffmgr.setDeptId(tTrainingRegular.getDeptId());
-                    List<TStaffmgr> staffmgrs = tStaffmgrService.selectAllTStaffmgrList(staffmgr);
+                    // 使用不带数据权限的查询方法,避免定时任务权限问题
+                    List<TStaffmgr> staffmgrs = tStaffmgrService.selectAllTStaffmgrListWithoutScope(staffmgr);
                     try {
                         //判断离职
                         if (!StringUtils.isEmpty(tTrainingRegular.getYear())) {
@@ -196,6 +198,8 @@ public class TrainingMatrixTask extends BaseController
                         tTrainingDevice.setRegularId(trainingId);
                         tTrainingDevice.setStartDate(tTrainingRegular.getPlanTrainingdate());
                         tTrainingDevice.setSupplementary("0");
+                        // 设置初始完成时间为空,表示尚未完成
+                        tTrainingDevice.setFinishDate(null);
                         trainingbccDeviceService.insertTTrainingbccDevice(tTrainingDevice);
                     }
                 }
@@ -209,6 +213,8 @@ public class TrainingMatrixTask extends BaseController
                         tTrainingDevice.setRegularId(trainingId);
                         tTrainingDevice.setStartDate(tTrainingRegular.getPlanTrainingdate());
                         tTrainingDevice.setSupplementary("0");
+                        // 设置初始完成时间为空,表示尚未完成
+                        tTrainingDevice.setFinishDate(null);
                         trainingbccDeviceService.insertTTrainingbccDevice(tTrainingDevice);
                     }
                 }
@@ -217,7 +223,8 @@ public class TrainingMatrixTask extends BaseController
                     logger.info("涉及MOC人员");
                     TStaffmgr staffmgrMoc = new TStaffmgr();
                     staffmgrMoc.setActualposts(tTrainingRegular.getDesignatedOther());
-                    List<TStaffmgr> staffmgrsMoc = tStaffmgrService.selectAllTStaffmgrList(staffmgrMoc);
+                    // 使用不带数据权限的查询方法,避免定时任务权限问题
+                    List<TStaffmgr> staffmgrsMoc = tStaffmgrService.selectAllTStaffmgrListWithoutScope(staffmgrMoc);
                     try {
                         //判断离职
                         if (!StringUtils.isEmpty(tTrainingRegular.getYear())) {
@@ -241,6 +248,8 @@ public class TrainingMatrixTask extends BaseController
                         tTrainingDevice.setRegularId(trainingId);
                         tTrainingDevice.setStartDate(tTrainingRegular.getPlanTrainingdate());
                         tTrainingDevice.setSupplementary("0");
+                        // 设置初始完成时间为空,表示尚未完成
+                        tTrainingDevice.setFinishDate(null);
                         trainingbccDeviceService.insertTTrainingbccDevice(tTrainingDevice);
                     }
                 }

+ 8 - 0
master/src/main/java/com/ruoyi/project/plant/mapper/TStaffmgrMapper.java

@@ -81,6 +81,14 @@ public interface TStaffmgrMapper
     @DataScope(deptAlias = "d")
     public List<TStaffmgr> selectAllTStaffmgrList(TStaffmgr tStaffmgr);
 
+    /**
+     * 查询人员管理列表(无数据权限过滤,供定时任务使用)
+     *
+     * @param tStaffmgr 人员管理
+     * @return 人员管理集合
+     */
+    public List<TStaffmgr> selectAllTStaffmgrListWithoutScope(TStaffmgr tStaffmgr);
+
     public List<TStaffmgr> selectTStaffmgrListByDeptAndTeam(TStaffmgr tStaffmgr);
 
     /**

+ 8 - 0
master/src/main/java/com/ruoyi/project/plant/service/ITStaffmgrService.java

@@ -47,6 +47,14 @@ public interface ITStaffmgrService
      */
     public List<TStaffmgr> selectTStaffmgrList(TStaffmgr tStaffmgr);
     public List<TStaffmgr> selectAllTStaffmgrList(TStaffmgr tStaffmgr);
+    
+    /**
+     * 查询人员管理列表(无数据权限过滤,供定时任务使用)
+     *
+     * @param tStaffmgr 人员管理
+     * @return 人员管理集合
+     */
+    public List<TStaffmgr> selectAllTStaffmgrListWithoutScope(TStaffmgr tStaffmgr);
     public List<TStaffmgr> selectTStaffmgrListByDeptAndTeam(TStaffmgr tStaffmgr);
 
     /**

+ 6 - 0
master/src/main/java/com/ruoyi/project/plant/service/impl/TStaffmgrServiceImpl.java

@@ -77,6 +77,12 @@ public class TStaffmgrServiceImpl implements ITStaffmgrService
     {
         return tStaffmgrMapper.selectAllTStaffmgrList(tStaffmgr);
     }
+    
+    @Override
+    public List<TStaffmgr> selectAllTStaffmgrListWithoutScope(TStaffmgr tStaffmgr)
+    {
+        return tStaffmgrMapper.selectAllTStaffmgrListWithoutScope(tStaffmgr);
+    }
     @Override
     public List<TStaffmgr> selectTStaffmgrListByDeptAndTeam(TStaffmgr tStaffmgr)
     {

+ 136 - 7
master/src/main/java/com/ruoyi/project/training/controller/TTrainingMatrixController.java

@@ -9,16 +9,14 @@ 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.plant.domain.TStaffmgr;
+import com.ruoyi.project.plant.service.ITStaffmgrService;
 import com.ruoyi.project.system.domain.SysDept;
 import com.ruoyi.project.system.domain.SysDictData;
 import com.ruoyi.project.system.service.ISysDeptService;
 import com.ruoyi.project.system.service.ISysDictTypeService;
-import com.ruoyi.project.training.domain.TTrainingCompanylevel;
-import com.ruoyi.project.training.domain.TTrainingMatrix;
-import com.ruoyi.project.training.domain.TTrainingRegular;
-import com.ruoyi.project.training.service.ITTrainingCompanylevelService;
-import com.ruoyi.project.training.service.ITTrainingMatrixService;
-import com.ruoyi.project.training.service.ITTrainingRegularService;
+import com.ruoyi.project.training.domain.*;
+import com.ruoyi.project.training.service.*;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
@@ -29,8 +27,10 @@ import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
+import java.time.LocalDate;
 import java.util.ArrayList;
 import java.util.Calendar;
+import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -54,7 +54,14 @@ public class TTrainingMatrixController extends BaseController {
     private ITTrainingRegularService tTrainingRegularService;
     @Autowired
     private ITTrainingCompanylevelService tTrainingCompanylevelService;
-
+    @Autowired
+    private ITStaffmgrService tStaffmgrService;
+    @Autowired
+    private ITTrainingbccRegularService tTrainingbccRegularService;
+    @Autowired
+    private ITTrainingbccService trainingbccService;
+    @Autowired
+    private ITTrainingbccDeviceService trainingbccDeviceService;
     /**
      * 查询培训矩阵列表
      */
@@ -167,6 +174,128 @@ public class TTrainingMatrixController extends BaseController {
             tr.setYear(String.valueOf(cal.get(Calendar.YEAR)));
             int doInsert = tTrainingRegularService.insertTTrainingRegular(tr);
         }
+        for (int i = 0; i < ids.length; i++) {
+            TTrainingMatrix matrix = tTrainingMatrixService.selectTTrainingMatrixById(ids[i]);
+            if (matrix.getDeptId() != 103l) {
+                continue;
+            }
+            TTrainingbccRegular tTrainingRegular = new TTrainingbccRegular();
+            tTrainingRegular.setDeptId(matrix.getDeptId());
+            tTrainingRegular.setActualpostId(matrix.getActualpostId());
+            tTrainingRegular.setCourseCode(matrix.getCourseCode());
+            tTrainingRegular.setItem(matrix.getItem());
+            tTrainingRegular.setHour(matrix.getHour());
+            tTrainingRegular.setInvolvedMoc("false");
+            tTrainingRegular.setNotPlan("false");
+            tTrainingRegular.setYear(String.valueOf(LocalDate.now().getYear()));
+
+            int doInsert = tTrainingbccRegularService.insertTTrainingbccRegular(tTrainingRegular);
+
+            logger.info("regular:" + tTrainingRegular);
+            tTrainingRegular.setDeptId(103l); //bcc专用
+            //新增培训计划定期类
+            TTrainingbcc tTraining = new TTrainingbcc();
+            tTraining.setTrainingType("10");
+            tTraining.setYears(tTrainingRegular.getYear());
+            tTraining.setCourse(tTrainingRegular.getItem());
+            tTraining.setCourseid(tTrainingRegular.getCourseCode());
+            tTraining.setDuration(tTrainingRegular.getHour());
+            tTraining.setTrainer(tTrainingRegular.getLecturer());
+            tTraining.setPosition(tTrainingRegular.getActualpostId());
+            tTraining.setIsfinish(Long.parseLong("0"));
+            tTraining.setDeptId(tTrainingRegular.getDeptId());
+            tTraining.setRegularId(tTrainingRegular.getId());
+            trainingbccService.insertTTrainingbcc(tTraining);
+            Long trainingId = tTraining.getId();
+            //新增人员-装置级关系
+            // 参培岗位人员
+            if (tTrainingRegular.getActualpostId() != null) {
+                logger.info("参培岗位人员");
+                TStaffmgr staffmgr = new TStaffmgr();
+                staffmgr.setActualposts(tTrainingRegular.getActualpostId());
+                staffmgr.setDeptId(tTrainingRegular.getDeptId());
+                // 使用不带数据权限的查询方法,避免定时任务权限问题
+                List<TStaffmgr> staffmgrs = tStaffmgrService.selectAllTStaffmgrListWithoutScope(staffmgr);
+                try {
+                    //判断离职
+                    if (!org.apache.commons.lang.StringUtils.isEmpty(tTrainingRegular.getYear())) {
+                        Iterator<TStaffmgr> iterator = staffmgrs.iterator();
+                        while (iterator.hasNext()) {
+                            TStaffmgr t = iterator.next();
+                            if (t.getLeftDate() != null && t.getDelFlag() == 9){
+                                if (t.getLeftDate().getTime() - tTrainingRegular.getPlanTrainingdate().getTime() < 0l ) {
+                                    logger.debug(t.getName() + "离职时间小于培训时间");
+                                    iterator.remove();
+                                }
+                            }
+                        }
+                    }
+                }catch (Exception e) {
+                    logger.error(e.toString());
+                }
+                for (TStaffmgr s : staffmgrs) {
+                    TTrainingbccDevice tTrainingDevice = new TTrainingbccDevice();
+                    tTrainingDevice.setStaffId(s.getStaffid());
+                    tTrainingDevice.setRegularId(trainingId);
+                    tTrainingDevice.setStartDate(tTrainingRegular.getPlanTrainingdate());
+                    tTrainingDevice.setSupplementary("0");
+                    // 设置初始完成时间为空,表示尚未完成
+                    tTrainingDevice.setFinishDate(null);
+                    trainingbccDeviceService.insertTTrainingbccDevice(tTrainingDevice);
+                }
+            }
+            //指定岗位人员
+            if (tTrainingRegular.getDesignatedStaff() != null) {
+                logger.info("指定岗位人员");
+                String[] designatedStaffs = tTrainingRegular.getDesignatedStaff().split(",");
+                for (String staffId : designatedStaffs) {
+                    TTrainingbccDevice tTrainingDevice = new TTrainingbccDevice();
+                    tTrainingDevice.setStaffId(staffId);
+                    tTrainingDevice.setRegularId(trainingId);
+                    tTrainingDevice.setStartDate(tTrainingRegular.getPlanTrainingdate());
+                    tTrainingDevice.setSupplementary("0");
+                    // 设置初始完成时间为空,表示尚未完成
+                    tTrainingDevice.setFinishDate(null);
+                    trainingbccDeviceService.insertTTrainingbccDevice(tTrainingDevice);
+                }
+            }
+            //涉及其他部门
+            if (tTrainingRegular.getInvolvedMoc().equals("true")){
+                logger.info("涉及MOC人员");
+                TStaffmgr staffmgrMoc = new TStaffmgr();
+                staffmgrMoc.setActualposts(tTrainingRegular.getDesignatedOther());
+                // 使用不带数据权限的查询方法,避免定时任务权限问题
+                List<TStaffmgr> staffmgrsMoc = tStaffmgrService.selectAllTStaffmgrListWithoutScope(staffmgrMoc);
+                try {
+                    //判断离职
+                    if (!org.apache.commons.lang.StringUtils.isEmpty(tTrainingRegular.getYear())) {
+                        Iterator<TStaffmgr> iterator = staffmgrsMoc.iterator();
+                        while (iterator.hasNext()) {
+                            TStaffmgr t = iterator.next();
+                            if (t.getLeftDate() != null && t.getDelFlag() == 9){
+                                if (t.getLeftDate().getTime() - tTrainingRegular.getPlanTrainingdate().getTime() > 0l ) {
+                                    logger.debug(t.getName() + "离职时间小于培训时间");
+                                    iterator.remove();
+                                }
+                            }
+                        }
+                    }
+                }catch (Exception e) {
+                    logger.error(e.toString());
+                }
+                for (TStaffmgr s : staffmgrsMoc) {
+                    TTrainingbccDevice tTrainingDevice = new TTrainingbccDevice();
+                    tTrainingDevice.setStaffId(s.getStaffid());
+                    tTrainingDevice.setRegularId(trainingId);
+                    tTrainingDevice.setStartDate(tTrainingRegular.getPlanTrainingdate());
+                    tTrainingDevice.setSupplementary("0");
+                    // 设置初始完成时间为空,表示尚未完成
+                    tTrainingDevice.setFinishDate(null);
+                    trainingbccDeviceService.insertTTrainingbccDevice(tTrainingDevice);
+                }
+            }
+        }
+
         return AjaxResult.success();
     }
 

+ 144 - 109
master/src/main/java/com/ruoyi/project/training/controller/TTrainingbccRegularController.java

@@ -280,37 +280,64 @@ public class TTrainingbccRegularController extends BaseController
         int currentYear = LocalDate.now().getYear();
         int resNum = 0;
         for (TTrainingMatrix matrix: list
-             ) {
+        ) {
             int addFlag = 0;
-            if ("每年一次".equals(matrix.getFrequency()) || "每年至少一次".equals(matrix.getFrequency())) {
-                tr.setYear(String.valueOf(currentYear));
-                tr.setItem(matrix.getItem());
-                List<TTrainingbccRegular> regulars = tTrainingbccRegularService.selectTTrainingbccRegularList(tr);
-                if (regulars.size() == 0) {
-                    addFlag = 1;
-                }
-            }
-            if ("每年两次".equals(matrix.getFrequency()) || "每年2次".equals(matrix.getFrequency())) {
-                tr.setYear(String.valueOf(currentYear));
-                tr.setItem(matrix.getItem());
-                List<TTrainingbccRegular> regulars = tTrainingbccRegularService.selectTTrainingbccRegularList(tr);
-                if (regulars.size() < 2) {
-                    addFlag = 1;
+
+            // 新增:基于fq_year字段的判断逻辑
+            if (matrix.getFqYear() != null && !matrix.getFqYear().isEmpty()) {
+                try {
+                    int fqYear = Integer.parseInt(matrix.getFqYear());
+                    if (fqYear > 0) {
+                        // 根据最新的一次regular记录来判断是否需要添加培训
+                        tr.setItem(matrix.getItem());
+                        // 查询该培训项目的所有regular记录,按年份排序(使用不带数据权限的方法)
+                        List<TTrainingbccRegular> allRegulars = tTrainingbccRegularService.selectTTrainingbccRegularListWithoutScope(tr);
+
+                        if (allRegulars.isEmpty()) {
+                            // 如果没有任何记录,则添加培训
+                            addFlag = 1;
+                            logger.info("培训项目:" + matrix.getItem() + ",fq_year=" + fqYear +
+                                    ",无任何历史记录,需要添加培训");
+                        } else {
+                            // 找到最新的一次培训记录年份
+                            int latestYear = allRegulars.stream()
+                                    .mapToInt(r -> {
+                                        try {
+                                            return Integer.parseInt(r.getYear());
+                                        } catch (NumberFormatException e) {
+                                            return 0;
+                                        }
+                                    })
+                                    .max()
+                                    .orElse(0);
+
+                            // 计算距离最新培训的年数
+                            int yearsSinceLastTraining = currentYear - latestYear;
+
+                            logger.info("培训项目:" + matrix.getItem() + ",fq_year=" + fqYear +
+                                    ",最新培训年份=" + latestYear + ",距离最新培训年数=" + yearsSinceLastTraining);
+
+                            // 如果距离最新培训的年数 >= fq_year,则需要添加培训
+                            if (yearsSinceLastTraining >= fqYear) {
+                                addFlag = 1;
+                                logger.info("根据fq_year=" + fqYear + ",距离最新培训" + yearsSinceLastTraining +
+                                        "年,需要添加培训:" + matrix.getItem());
+                            } else {
+                                logger.info("培训项目:" + matrix.getItem() + ",fq_year=" + fqYear +
+                                        ",距离最新培训" + yearsSinceLastTraining + "年,无需添加培训");
+                            }
+                        }
+                    }
+                } catch (NumberFormatException e) {
+                    logger.warn("fq_year字段值不是有效数字:" + matrix.getFqYear() + ",培训项目:" + matrix.getItem());
                 }
             }
-            if ("每月一次".equals(matrix.getFrequency()) ) {
-                tr.setYear(String.valueOf(currentYear));
-                tr.setItem(matrix.getItem());
-                List<TTrainingbccRegular> regulars0 = tTrainingbccRegularService.selectTTrainingbccRegularList(tr);
-                tr.setPlanTrainingdate(new Date());
-                List<TTrainingbccRegular> regulars = tTrainingbccRegularService.selectTTrainingbccRegularList(tr);
-                if (regulars.size() == 0) {
-                    addFlag = 1;
-                }
-                if (regulars0.size() >= LocalDate.now().getMonthValue()) { //数量够了不需要增加了
-                    addFlag = 0;
-                }
+
+            // 如果fq_year字段为空或无效,则不添加培训
+            if (addFlag == 0) {
+                logger.info("培训项目:" + matrix.getItem() + ",fq_year字段为空或无效,跳过添加");
             }
+
             if (addFlag == 1) {
                 TTrainingbccRegular tTrainingRegular = new TTrainingbccRegular();
                 tTrainingRegular.setDeptId(matrix.getDeptId());
@@ -326,99 +353,107 @@ public class TTrainingbccRegularController extends BaseController
 
                 logger.info("regular:" + tTrainingRegular);
                 tTrainingRegular.setDeptId(103l); //bcc专用
-                    //新增培训计划定期类
-                    TTrainingbcc tTraining = new TTrainingbcc();
-                    tTraining.setTrainingType("10");
-                    tTraining.setYears(tTrainingRegular.getYear());
-                    tTraining.setCourse(tTrainingRegular.getItem());
-                    tTraining.setCourseid(tTrainingRegular.getCourseCode());
-                    tTraining.setDuration(tTrainingRegular.getHour());
-                    tTraining.setTrainer(tTrainingRegular.getLecturer());
-                    tTraining.setPosition(tTrainingRegular.getActualpostId());
-                    tTraining.setIsfinish(Long.parseLong("0"));
-                    tTraining.setDeptId(tTrainingRegular.getDeptId());
-                    tTraining.setRegularId(tTrainingRegular.getId());
-                    trainingbccService.insertTTrainingbcc(tTraining);
-                    Long trainingId = tTraining.getId();
-                    //新增人员-装置级关系
-                    // 参培岗位人员
-                    if (tTrainingRegular.getActualpostId() != null) {
-                        logger.info("参培岗位人员");
-                        TStaffmgr staffmgr = new TStaffmgr();
-                        staffmgr.setActualposts(tTrainingRegular.getActualpostId());
-                        staffmgr.setDeptId(tTrainingRegular.getDeptId());
-                        List<TStaffmgr> staffmgrs = tStaffmgrService.selectAllTStaffmgrList(staffmgr);
-                        try {
-                            //判断离职
-                            if (!StringUtils.isEmpty(tTrainingRegular.getYear())) {
-                                Iterator<TStaffmgr> iterator = staffmgrs.iterator();
-                                while (iterator.hasNext()) {
-                                    TStaffmgr t = iterator.next();
-                                    if (t.getLeftDate() != null && t.getDelFlag() == 9){
-                                        if (t.getLeftDate().getTime() - tTrainingRegular.getPlanTrainingdate().getTime() < 0l ) {
-                                            logger.debug(t.getName() + "离职时间小于培训时间");
-                                            iterator.remove();
-                                        }
+                //新增培训计划定期类
+                TTrainingbcc tTraining = new TTrainingbcc();
+                tTraining.setTrainingType("10");
+                tTraining.setYears(tTrainingRegular.getYear());
+                tTraining.setCourse(tTrainingRegular.getItem());
+                tTraining.setCourseid(tTrainingRegular.getCourseCode());
+                tTraining.setDuration(tTrainingRegular.getHour());
+                tTraining.setTrainer(tTrainingRegular.getLecturer());
+                tTraining.setPosition(tTrainingRegular.getActualpostId());
+                tTraining.setIsfinish(Long.parseLong("0"));
+                tTraining.setDeptId(tTrainingRegular.getDeptId());
+                tTraining.setRegularId(tTrainingRegular.getId());
+                trainingbccService.insertTTrainingbcc(tTraining);
+                Long trainingId = tTraining.getId();
+                //新增人员-装置级关系
+                // 参培岗位人员
+                if (tTrainingRegular.getActualpostId() != null) {
+                    logger.info("参培岗位人员");
+                    TStaffmgr staffmgr = new TStaffmgr();
+                    staffmgr.setActualposts(tTrainingRegular.getActualpostId());
+                    staffmgr.setDeptId(tTrainingRegular.getDeptId());
+                    // 使用不带数据权限的查询方法,避免定时任务权限问题
+                    List<TStaffmgr> staffmgrs = tStaffmgrService.selectAllTStaffmgrListWithoutScope(staffmgr);
+                    try {
+                        //判断离职
+                        if (!StringUtils.isEmpty(tTrainingRegular.getYear())) {
+                            Iterator<TStaffmgr> iterator = staffmgrs.iterator();
+                            while (iterator.hasNext()) {
+                                TStaffmgr t = iterator.next();
+                                if (t.getLeftDate() != null && t.getDelFlag() == 9){
+                                    if (t.getLeftDate().getTime() - tTrainingRegular.getPlanTrainingdate().getTime() < 0l ) {
+                                        logger.debug(t.getName() + "离职时间小于培训时间");
+                                        iterator.remove();
                                     }
                                 }
                             }
-                        }catch (Exception e) {
-                            logger.error(e.toString());
-                        }
-                        for (TStaffmgr s : staffmgrs) {
-                            TTrainingbccDevice tTrainingDevice = new TTrainingbccDevice();
-                            tTrainingDevice.setStaffId(s.getStaffid());
-                            tTrainingDevice.setRegularId(trainingId);
-                            tTrainingDevice.setStartDate(tTrainingRegular.getPlanTrainingdate());
-                            tTrainingDevice.setSupplementary("0");
-                            trainingbccDeviceService.insertTTrainingbccDevice(tTrainingDevice);
                         }
+                    }catch (Exception e) {
+                        logger.error(e.toString());
                     }
-                    //指定岗位人员
-                    if (tTrainingRegular.getDesignatedStaff() != null) {
-                        logger.info("指定岗位人员");
-                        String[] designatedStaffs = tTrainingRegular.getDesignatedStaff().split(",");
-                        for (String staffId : designatedStaffs) {
-                            TTrainingbccDevice tTrainingDevice = new TTrainingbccDevice();
-                            tTrainingDevice.setStaffId(staffId);
-                            tTrainingDevice.setRegularId(trainingId);
-                            tTrainingDevice.setStartDate(tTrainingRegular.getPlanTrainingdate());
-                            tTrainingDevice.setSupplementary("0");
-                            trainingbccDeviceService.insertTTrainingbccDevice(tTrainingDevice);
-                        }
+                    for (TStaffmgr s : staffmgrs) {
+                        TTrainingbccDevice tTrainingDevice = new TTrainingbccDevice();
+                        tTrainingDevice.setStaffId(s.getStaffid());
+                        tTrainingDevice.setRegularId(trainingId);
+                        tTrainingDevice.setStartDate(tTrainingRegular.getPlanTrainingdate());
+                        tTrainingDevice.setSupplementary("0");
+                        // 设置初始完成时间为空,表示尚未完成
+                        tTrainingDevice.setFinishDate(null);
+                        trainingbccDeviceService.insertTTrainingbccDevice(tTrainingDevice);
                     }
-                    //涉及其他部门
-                    if (tTrainingRegular.getInvolvedMoc().equals("true")){
-                        logger.info("涉及MOC人员");
-                        TStaffmgr staffmgrMoc = new TStaffmgr();
-                        staffmgrMoc.setActualposts(tTrainingRegular.getDesignatedOther());
-                        List<TStaffmgr> staffmgrsMoc = tStaffmgrService.selectAllTStaffmgrList(staffmgrMoc);
-                        try {
-                            //判断离职
-                            if (!StringUtils.isEmpty(tTrainingRegular.getYear())) {
-                                Iterator<TStaffmgr> iterator = staffmgrsMoc.iterator();
-                                while (iterator.hasNext()) {
-                                    TStaffmgr t = iterator.next();
-                                    if (t.getLeftDate() != null && t.getDelFlag() == 9){
-                                        if (t.getLeftDate().getTime() - tTrainingRegular.getPlanTrainingdate().getTime() > 0l ) {
-                                            logger.debug(t.getName() + "离职时间小于培训时间");
-                                            iterator.remove();
-                                        }
+                }
+                //指定岗位人员
+                if (tTrainingRegular.getDesignatedStaff() != null) {
+                    logger.info("指定岗位人员");
+                    String[] designatedStaffs = tTrainingRegular.getDesignatedStaff().split(",");
+                    for (String staffId : designatedStaffs) {
+                        TTrainingbccDevice tTrainingDevice = new TTrainingbccDevice();
+                        tTrainingDevice.setStaffId(staffId);
+                        tTrainingDevice.setRegularId(trainingId);
+                        tTrainingDevice.setStartDate(tTrainingRegular.getPlanTrainingdate());
+                        tTrainingDevice.setSupplementary("0");
+                        // 设置初始完成时间为空,表示尚未完成
+                        tTrainingDevice.setFinishDate(null);
+                        trainingbccDeviceService.insertTTrainingbccDevice(tTrainingDevice);
+                    }
+                }
+                //涉及其他部门
+                if (tTrainingRegular.getInvolvedMoc().equals("true")){
+                    logger.info("涉及MOC人员");
+                    TStaffmgr staffmgrMoc = new TStaffmgr();
+                    staffmgrMoc.setActualposts(tTrainingRegular.getDesignatedOther());
+                    // 使用不带数据权限的查询方法,避免定时任务权限问题
+                    List<TStaffmgr> staffmgrsMoc = tStaffmgrService.selectAllTStaffmgrListWithoutScope(staffmgrMoc);
+                    try {
+                        //判断离职
+                        if (!StringUtils.isEmpty(tTrainingRegular.getYear())) {
+                            Iterator<TStaffmgr> iterator = staffmgrsMoc.iterator();
+                            while (iterator.hasNext()) {
+                                TStaffmgr t = iterator.next();
+                                if (t.getLeftDate() != null && t.getDelFlag() == 9){
+                                    if (t.getLeftDate().getTime() - tTrainingRegular.getPlanTrainingdate().getTime() > 0l ) {
+                                        logger.debug(t.getName() + "离职时间小于培训时间");
+                                        iterator.remove();
                                     }
                                 }
                             }
-                        }catch (Exception e) {
-                            logger.error(e.toString());
-                        }
-                        for (TStaffmgr s : staffmgrsMoc) {
-                            TTrainingbccDevice tTrainingDevice = new TTrainingbccDevice();
-                            tTrainingDevice.setStaffId(s.getStaffid());
-                            tTrainingDevice.setRegularId(trainingId);
-                            tTrainingDevice.setStartDate(tTrainingRegular.getPlanTrainingdate());
-                            tTrainingDevice.setSupplementary("0");
-                            trainingbccDeviceService.insertTTrainingbccDevice(tTrainingDevice);
                         }
+                    }catch (Exception e) {
+                        logger.error(e.toString());
+                    }
+                    for (TStaffmgr s : staffmgrsMoc) {
+                        TTrainingbccDevice tTrainingDevice = new TTrainingbccDevice();
+                        tTrainingDevice.setStaffId(s.getStaffid());
+                        tTrainingDevice.setRegularId(trainingId);
+                        tTrainingDevice.setStartDate(tTrainingRegular.getPlanTrainingdate());
+                        tTrainingDevice.setSupplementary("0");
+                        // 设置初始完成时间为空,表示尚未完成
+                        tTrainingDevice.setFinishDate(null);
+                        trainingbccDeviceService.insertTTrainingbccDevice(tTrainingDevice);
                     }
+                }
                 resNum ++;
             }
         }

+ 2 - 0
master/src/main/java/com/ruoyi/project/training/elearn/service/impl/TElPaperServiceImpl.java

@@ -398,8 +398,10 @@ public class TElPaperServiceImpl implements ITElPaperService {
                                 long pass;
                                 if (objScore >= paper.getTotalScore()) {
                                     pass = 1; // 满分情况
+                                    d.setFinishDate(new Date());
                                 } else if (objScore >= paper.getQualifyScore()) {
                                     pass = 3; // 及格但未满分
+                                    d.setFinishDate(new Date());
                                 } else {
                                     pass = 0; // 不及格
                                 }

+ 8 - 0
master/src/main/java/com/ruoyi/project/training/mapper/TTrainingMatrixMapper.java

@@ -29,6 +29,14 @@ public interface TTrainingMatrixMapper
     @DataScope(deptAlias = "d")
     public List<TTrainingMatrix> selectTTrainingMatrixList(TTrainingMatrix tTrainingMatrix);
 
+    /**
+     * 查询培训矩阵列表(无数据权限过滤,供定时任务使用)
+     * 
+     * @param tTrainingMatrix 培训矩阵
+     * @return 培训矩阵集合
+     */
+    public List<TTrainingMatrix> selectTTrainingMatrixListWithoutScope(TTrainingMatrix tTrainingMatrix);
+
     /**
      * 新增培训矩阵
      * 

+ 8 - 0
master/src/main/java/com/ruoyi/project/training/mapper/TTrainingbccRegularMapper.java

@@ -29,6 +29,14 @@ public interface TTrainingbccRegularMapper
     @DataScope(deptAlias = "d")
     public List<TTrainingbccRegular> selectTTrainingbccRegularList(TTrainingbccRegular tTrainingbccRegular);
 
+    /**
+     * 查询装置培训计划列表(无数据权限过滤,供定时任务使用)
+     *
+     * @param tTrainingbccRegular 装置培训计划
+     * @return 装置培训计划集合
+     */
+    public List<TTrainingbccRegular> selectTTrainingbccRegularListWithoutScope(TTrainingbccRegular tTrainingbccRegular);
+
     /**
      * 新增装置培训计划
      *

+ 8 - 0
master/src/main/java/com/ruoyi/project/training/service/ITTrainingMatrixService.java

@@ -27,6 +27,14 @@ public interface ITTrainingMatrixService
      */
     public List<TTrainingMatrix> selectTTrainingMatrixList(TTrainingMatrix tTrainingMatrix);
 
+    /**
+     * 查询培训矩阵列表(无数据权限过滤,供定时任务使用)
+     * 
+     * @param tTrainingMatrix 培训矩阵
+     * @return 培训矩阵集合
+     */
+    public List<TTrainingMatrix> selectTTrainingMatrixListWithoutScope(TTrainingMatrix tTrainingMatrix);
+
     /**
      * 新增培训矩阵
      * 

+ 8 - 0
master/src/main/java/com/ruoyi/project/training/service/ITTrainingbccRegularService.java

@@ -27,6 +27,14 @@ public interface ITTrainingbccRegularService
      */
     public List<TTrainingbccRegular> selectTTrainingbccRegularList(TTrainingbccRegular tTrainingbccRegular);
 
+    /**
+     * 查询装置培训计划列表(无数据权限过滤,供定时任务使用)
+     *
+     * @param tTrainingbccRegular 装置培训计划
+     * @return 装置培训计划集合
+     */
+    public List<TTrainingbccRegular> selectTTrainingbccRegularListWithoutScope(TTrainingbccRegular tTrainingbccRegular);
+
     /**
      * 新增装置培训计划
      *

+ 12 - 0
master/src/main/java/com/ruoyi/project/training/service/impl/TTrainingMatrixServiceImpl.java

@@ -45,6 +45,18 @@ public class TTrainingMatrixServiceImpl implements ITTrainingMatrixService
         return tTrainingMatrixMapper.selectTTrainingMatrixList(tTrainingMatrix);
     }
 
+    /**
+     * 查询培训矩阵列表(无数据权限过滤,供定时任务使用)
+     *
+     * @param tTrainingMatrix 培训矩阵
+     * @return 培训矩阵
+     */
+    @Override
+    public List<TTrainingMatrix> selectTTrainingMatrixListWithoutScope(TTrainingMatrix tTrainingMatrix)
+    {
+        return tTrainingMatrixMapper.selectTTrainingMatrixListWithoutScope(tTrainingMatrix);
+    }
+
     /**
      * 新增培训矩阵
      *

+ 12 - 0
master/src/main/java/com/ruoyi/project/training/service/impl/TTrainingbccRegularServiceImpl.java

@@ -43,6 +43,18 @@ public class TTrainingbccRegularServiceImpl implements ITTrainingbccRegularServi
         return tTrainingbccRegularMapper.selectTTrainingbccRegularList(tTrainingbccRegular);
     }
 
+    /**
+     * 查询装置培训计划列表(无数据权限过滤,供定时任务使用)
+     *
+     * @param tTrainingbccRegular 装置培训计划
+     * @return 装置培训计划
+     */
+    @Override
+    public List<TTrainingbccRegular> selectTTrainingbccRegularListWithoutScope(TTrainingbccRegular tTrainingbccRegular)
+    {
+        return tTrainingbccRegularMapper.selectTTrainingbccRegularListWithoutScope(tTrainingbccRegular);
+    }
+
     /**
      * 新增装置培训计划
      *

+ 66 - 0
master/src/main/resources/mybatis/plant/TStaffmgrMapper.xml

@@ -270,6 +270,72 @@
         ORDER BY d.del_flag, s0.DICT_SORT, s1.DICT_SORT ,s2.DICT_SORT
     </select>
 
+    <select id="selectAllTStaffmgrListWithoutScope" parameterType="TStaffmgr" resultMap="TStaffmgrResult">
+        <include refid="selectTStaffmgrVo"/>
+        Left join SYS_DICT_DATA s0 on d.UNIT = s0.DICT_VALUE and s0.DICT_TYPE ='STAFF_UNIT'
+        LEFT JOIN SYS_DICT_DATA s2 on d.ACTUALPOST = s2.DICT_VALUE and s2.DICT_TYPE = 'ACTUALPOST'
+        LEFT JOIN SYS_DICT_DATA s1 on d.team = s1.DICT_VALUE and s1.DICT_TYPE = 'TEAM_DIVIDE'
+        <where>
+            <if test="name != null  and name != ''"> and name like concat(concat('%', #{name}), '%')</if>
+            <if test="sex != null  and sex != ''"> and sex = #{sex}</if>
+            <if test="unit != null  and unit != ''"> and unit = #{unit}</if>
+            <if test="specialDuty != null  and specialDuty != ''"> and special_duty like concat(concat('%', #{specialDuty}), '%')</if>
+            <if test="units != null  and units != ''">
+                and
+                unit in
+                <foreach collection="units.split(',')" item="item" index="index"
+                         open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+             </if>
+            <if test="team != null  and team != ''"> and team = #{team}</if>
+            <if test="teams != null  and teams != ''">
+                and
+                team in
+                <foreach collection="teams.split(',')" item="item" index="index"
+                         open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+             </if>
+            <if test="actualpost != null  and actualpost != ''"> and actualpost = #{actualpost}</if>
+            <if test="actualposts != null  and actualposts != ''">
+                and
+                actualpost in
+                <foreach collection="actualposts.split(',')" item="item" index="index"
+                         open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="education != null  and education != ''"> and education = #{education}</if>
+            <if test="educations != null  and educations != ''">
+                and
+                education in
+                <foreach collection="educations.split(',')" item="item" index="index"
+                         open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+             </if>
+            <if test="enAbility != null  and enAbility != ''"> and en_ability = #{enAbility}</if>
+            <if test="enAbilitys != null  and enAbilitys != ''">
+                and
+                en_ability in
+                <foreach collection="enAbilitys.split(',')" item="item" index="index"
+                         open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="haveEmail != null  and haveEmail != ''"> and mail IS NOT NULL</if>
+            <if test="deptId != null  and deptId != ''"> and d.dept_id = #{deptId}</if>
+            <if test="skillevaluation != null"> and team = 10
+                or team = 12
+                or team = 14
+                or team = 16
+            </if>
+            and (d.del_flag = 0 or d.del_flag = 9)
+        </where>
+        ORDER BY d.del_flag, s0.DICT_SORT, s1.DICT_SORT ,s2.DICT_SORT
+    </select>
+
     <select id="selectTStaffmgrListAll" parameterType="TStaffmgr" resultMap="TStaffmgrResult">
         <include refid="selectTStaffmgrVo"/>
         Left join SYS_DICT_DATA s0 on d.UNIT = s0.DICT_VALUE and s0.DICT_TYPE ='STAFF_UNIT'

+ 13 - 0
master/src/main/resources/mybatis/training/TTrainingMatrixMapper.xml

@@ -50,6 +50,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         order by d.id asc
     </select>
 
+    <select id="selectTTrainingMatrixListWithoutScope" parameterType="TTrainingMatrix" resultMap="TTrainingMatrixResult">
+        <include refid="selectTTrainingMatrixVo"/>
+        <where>
+            <if test="trainingLevel != null  and trainingLevel != ''"> and training_level = #{trainingLevel}</if>
+            <if test="item != null  and item != ''"> and item like concat(concat('%', #{item}), '%')</if>
+            <if test="courseCode != null  and courseCode != ''"> and d.course_code = #{courseCode}</if>
+            <if test="deptId != null  and deptId != ''"> and d.dept_id = #{deptId}</if>
+            <if test="isNewstaff != null  and isNewstaff != ''"> and d.is_newstaff = #{isNewstaff}</if>
+            and d.del_flag = 0
+        </where>
+        order by d.id asc
+    </select>
+
     <select id="selectTTrainingMatrixById" parameterType="Long" resultMap="TTrainingMatrixResult">
         <include refid="selectTTrainingMatrixVo"/>
         where id = #{id}

+ 28 - 0
master/src/main/resources/mybatis/training/TTrainingbccRegularMapper.xml

@@ -65,6 +65,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         order by year desc,plan_trainingdate
     </select>
 
+    <select id="selectTTrainingbccRegularListWithoutScope" parameterType="TTrainingbccRegular" resultMap="TTrainingbccRegularResult">
+        <include refid="selectTTrainingbccRegularVo"/>
+        <where>
+            <if test="courseCode != null  and courseCode != ''"> and course_code = #{courseCode}</if>
+            <if test="item != null  and item != ''"> and item = #{item}</if>
+            <if test="actualpostId != null  and actualpostId != ''"> and d.actualpost_id like concat(concat('%', #{actualpostId}), '%')</if>
+            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
+            <if test="createrCode != null  and createrCode != ''"> and creater_code = #{createrCode}</if>
+            <if test="createdate != null "> and createdate = #{createdate}</if>
+            <if test="updaterCode != null  and updaterCode != ''"> and updater_code = #{updaterCode}</if>
+            <if test="updatedate != null "> and updatedate = #{updatedate}</if>
+            <if test="deptId != null "> and dept_id = #{deptId}</if>
+            <if test="planTrainingdate != null "> and to_char(plan_trainingdate, 'yyyy-mm') = to_char(#{planTrainingdate}, 'yyyy-mm') </if>
+            <if test="actualCompletedate != null "> and actual_completedate = #{actualCompletedate}</if>
+            <if test="lecturer != null  and lecturer != ''"> and lecturer = #{lecturer}</if>
+            <if test="hour != null  and hour != ''"> and hour = #{hour}</if>
+            <if test="year != null  and year != ''"> and year = #{year}</if>
+            <if test="designatedPosition != null  and designatedPosition != ''"> and designated_position = #{designatedPosition}</if>
+            <if test="designatedStaff != null  and designatedStaff != ''"> and designated_staff = #{designatedStaff}</if>
+            <if test="involvedMoc != null  and involvedMoc != ''"> and involved_moc = #{involvedMoc}</if>
+            <if test="notPlan != null  and notPlan != ''"> and not_plan = #{notPlan}</if>
+            <if test="notTrainingdate != null  and notTrainingdate != ''"> and not_trainingdate = #{notTrainingdate}</if>
+            <if test="designatedOther != null  and designatedOther != ''"> and designated_other = #{designatedOther}</if>
+            and d.del_flag = 0 and new_staff is null
+        </where>
+        order by year desc,plan_trainingdate
+    </select>
+
     <select id="selectTTrainingbccRegularListNew" parameterType="TTrainingbccRegular" resultMap="TTrainingbccRegularResult">
         <include refid="selectTTrainingbccRegularVo"/>
         <where>