Browse Source

教培计划代码提交

jingyuanchao 2 năm trước cách đây
mục cha
commit
8af2390cc9

+ 1 - 1
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/edu/domain/CoreEduTrainingPlan.java

@@ -95,7 +95,7 @@ public class CoreEduTrainingPlan extends BaseEntity {
     @ApiModelProperty(value = "是否是标准计划,0:否,1:是")
     private Integer standard;
 
-    @ApiModelProperty(value = "是否已下发或当前为被下发计划", notes = "0:否,1:是")
+    @ApiModelProperty(value = "是否已下发", notes = "0:否,1:是")
     @TableField("issue")
     private Integer issue;
 

+ 4 - 3
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/edu/vo/CoreEduTrainingTaskDetailVo.java

@@ -17,10 +17,11 @@ public class CoreEduTrainingTaskDetailVo {
 
     @JsonSerialize(using = com.fasterxml.jackson.databind.ser.std.ToStringSerializer.class)
     private Long id;
-
+    @JsonSerialize(using = com.fasterxml.jackson.databind.ser.std.ToStringSerializer.class)
     @ApiModelProperty(value = "教育培训计划Id")
     private Long planId;
 
+    @JsonSerialize(using = com.fasterxml.jackson.databind.ser.std.ToStringSerializer.class)
     @ApiModelProperty(value = "机构")
     private Long orgId;
 
@@ -40,7 +41,7 @@ public class CoreEduTrainingTaskDetailVo {
     @ApiModelProperty(value = "类型名称")
     private String typeText;
 
-
+    @JsonSerialize(using = com.fasterxml.jackson.databind.ser.std.ToStringSerializer.class)
     @ApiModelProperty(value = "主持人")
     private Long hostId;
 
@@ -48,7 +49,7 @@ public class CoreEduTrainingTaskDetailVo {
     @ApiModelProperty(value = "主持人名称")
     private String hostName;
 
-
+    @JsonSerialize(using = com.fasterxml.jackson.databind.ser.std.ToStringSerializer.class)
     @ApiModelProperty(value = "记录人")
     private Long recorderId;
 

+ 1 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/edu/mapper/CoreEduTrainingPlanToExecOrgMapper.java

@@ -15,4 +15,5 @@ public interface CoreEduTrainingPlanToExecOrgMapper extends BaseMapper<CoreEduTr
     List<CoreEduTrainingPlanToExecOrg> selectLisByPlanId(@Param("planId") Long planId);
 
 
+    List<Long> selectOrgIdByPlanId(@Param("planId") Long planId);
 }

+ 2 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/edu/mapper/CoreEduTrainingPlanToRoleMapper.java

@@ -15,4 +15,6 @@ public interface CoreEduTrainingPlanToRoleMapper extends BaseMapper<CoreEduTrain
     List<CoreEduTrainingPlanRoleVo> selectRoleNameByPlanId(@Param("planId") Long planId);
 
     List<CoreEduTrainingPlanToRole> selectListByPlanId(@Param("planId") Long planId);
+
+    List<Long> selectRoleIdByPlanId(@Param("planId") Long planId);
 }

+ 63 - 11
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/edu/service/impl/CoreEduTrainingPlanServiceImpl.java

@@ -1,9 +1,11 @@
 package com.xunmei.core.edu.service.impl;
 
 import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.collection.ListUtil;
 import cn.hutool.core.map.MapUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson2.JSON;
+import com.alibaba.nacos.common.utils.CollectionUtils;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
@@ -239,16 +241,13 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
     @Override
     @Transactional(rollbackFor = Exception.class)
     public int updateCoreEduTrainingPlan(CoreEduTrainingPlanEditDto request) {
-
-        if (ObjectUtil.isAllEmpty(request.getExecOrgType(), request.getPlanExecOrgIdList())) {
-            throw new RuntimeException("培训机构类型和执行机构不能同时为空!");
-        }
-
         final CoreEduTrainingPlan plan = getById(request.getId());
-        //如果是下发的计划,执行频次不应低于省联社下发时设定的次数
-        if (ObjectUtil.equal(plan.getStandard(), 0) && request.getExecTimes() < plan.getExecTimes()) {
-            throw new RuntimeException("执行次数不应低于基准次数!");
+        //此处判断能否修改,如果可以 需要删除任务,且还需要判断是否需要生成任务
+        Boolean can = checkCanUpdate(request, plan);
+        if (!can) {
+            throw new RuntimeException("当前任务已生成且存在已执行情况,无法修改培训机构类型,具体培训机构,培训角色,培训周期等信息!");
         }
+        //可以修改计划
         BeanUtils.copyProperties(request, plan);
         plan.setUpdateTime(DateUtils.getNowDate());
         plan.setFileList(ObjectUtil.isNotEmpty(request.getFileList()) ? JSON.toJSONString(request.getFileList()) : null);
@@ -258,8 +257,8 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
         batchSavePlanToRole(request.getPlanRoleId(), plan.getId());
         batchSavePlanToExecOrg(request.getPlanExecOrgIdList(), plan.getId());
         final int i = coreEduTrainingPlanMapper.updateById(plan);
-        if (ObjectUtil.equal(plan.getStandard(), 0) && ObjectUtil.equal(plan.getIssue(), 0)) {
-            //说明是行方己创计划,修改后需要重新下发
+        if (ObjectUtil.equal(plan.getStandard(), 0)) {
+            //自建计划
             Integer exit = coreEduTrainingTaskMapper.checkHasTask(request.getId());
             Integer hasDone = coreEduTrainingTaskMapper.checkHasTaskIsDone(Collections.singletonList(request.getId()));
             if (ObjectUtil.equal(exit, 1) && ObjectUtil.isNull(hasDone)) {
@@ -273,6 +272,53 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
         return i;
     }
 
+    private Boolean checkCanUpdate(CoreEduTrainingPlanEditDto request, CoreEduTrainingPlan plan) {
+        if (ObjectUtil.isAllEmpty(request.getExecOrgType(), request.getPlanExecOrgIdList())) {
+            throw new RuntimeException("培训机构类型和执行机构不能同时为空!");
+        }
+        //如果是下发的计划,执行频次不应低于省联社下发时设定的次数
+        if (ObjectUtil.equal(plan.getStandard(), 0) && request.getExecTimes() < plan.getExecTimes()) {
+            throw new RuntimeException("执行次数不应低于基准次数!");
+        }
+        final Long planId = plan.getId();
+        //判断计划是否有任务已经执行过
+        final Integer done = coreEduTrainingTaskMapper.checkHasTaskIsDone(Arrays.asList(planId));
+        boolean flag = true;
+        //计划周期
+        if (ObjectUtil.notEqual(request.getPlanCycle(), plan.getPlanCycle())) {
+            flag = false;
+        }
+        //执行机构类型
+        if (ObjectUtil.notEqual(request.getExecOrgType(), plan.getExecOrgType())) {
+            flag = false;
+        }
+        //执行角色
+        List<Long> roleIdLit = coreEduTrainingPlanToRoleMapper.selectRoleIdByPlanId(planId);
+        List<Long> planRoleId = request.getPlanRoleId();
+        if (ObjectUtil.isEmpty(planRoleId)) {
+            flag = false;
+        }
+        for (Long roleId : roleIdLit) {
+            if (!planRoleId.contains(roleId)) {
+                flag = false;
+                break;
+            }
+        }
+        //执行机构
+        List<Long> execOrgIdList = coreEduTrainingPlanToExecOrgMapper.selectOrgIdByPlanId(planId);
+        final List<Long> planExecOrgIdList = request.getPlanExecOrgIdList();
+        if (execOrgIdList.size() != planExecOrgIdList.size()) {
+            flag = false;
+        }
+        for (Long orgId : execOrgIdList) {
+            if (!planExecOrgIdList.contains(orgId)) {
+                flag = false;
+                break;
+            }
+        }
+        return null == done || flag;
+    }
+
     @Override
     public CoreEduTrainingPlanDataVo getCoreEduTrainingPlanDataVo(Long id) {
         final CoreEduTrainingPlanDataVo dataVo = coreEduTrainingPlanMapper.getDetailPlanData(id);
@@ -379,7 +425,6 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
         // 下发 按钮显示逻辑:仅省联社安全保卫管理人员进入且由省联社管理安全保卫人员创建的计划才显示
         //todo 判断当前人的角色信息
 
-
         //获取执行角色
         LambdaQueryWrapper<CoreEduTrainingPlanToRole> ros = new LambdaQueryWrapper<>();
         ros.eq(CoreEduTrainingPlanToRole::getPlanId, plan.getId());
@@ -417,6 +462,13 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
         if (list.size() > 0) {
             this.saveBatch(list);
         }
+        for (CoreEduTrainingPlan trainingPlan : list) {
+            //如果不是省联社或者办事处,状态启用,并且是无周期或者立即生效
+            if ((ObjectUtil.equal(0, plan.getPlanStatus()) && (ObjectUtil.equal(0, plan.getPlanCycle()) || ObjectUtil.equal(1, plan.getBuildTaskNow())))) {
+                CoreEduTrainingPlanDataVo detailPlanData = this.getCoreEduTrainingPlanDataVo(trainingPlan.getId());
+                coreEduTrainingTaskService.createTaskForNow(detailPlanData, plan.getStartDate(), plan.getEndDate());
+            }
+        }
         if (insertPlanRoleList.size() > 0) {
             coreEduTrainingPlanToRoleService.saveBatch(insertPlanRoleList);
         }

+ 2 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/edu/service/impl/CoreEduTrainingTaskServiceImpl.java

@@ -46,6 +46,7 @@ import com.xunmei.system.api.function.RemoteCallHandlerExecutor;
 import io.netty.util.internal.StringUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
@@ -269,6 +270,7 @@ public class CoreEduTrainingTaskServiceImpl extends ServiceImpl<CoreEduTrainingT
     }
 
     @Override
+    @Async
     @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
     public void createTaskForNow(CoreEduTrainingPlanDataVo plan, Date start, Date end) {
 

+ 6 - 0
soc-modules/soc-modules-core/src/main/resources/mapper/edu/CoreEduTrainingPlanToExecOrgMapper.xml

@@ -9,4 +9,10 @@
                  inner join sys_org o on g.org_id = o.id
         where g.plan_id = #{planId}
     </select>
+
+    <select id="selectOrgIdByPlanId" resultType="java.lang.Long">
+        select distinct org_id
+        from core_edu_training_plan_to_exec_org
+        where plan_id = #{planId}
+    </select>
 </mapper>

+ 6 - 0
soc-modules/soc-modules-core/src/main/resources/mapper/edu/CoreEduTrainingPlanToRoleMapper.xml

@@ -16,4 +16,10 @@
                  inner join sys_role r on pr.role_id = r.id
         where plan_id = #{planId}
     </select>
+
+    <select id="selectRoleIdByPlanId" resultType="java.lang.Long">
+        select distinct role_id
+        from core_edu_training_plan_to_role
+        where plan_id = #{planId}
+    </select>
 </mapper>