Browse Source

教育培训代码提交

jingyuanchao 2 years ago
parent
commit
d970916374
20 changed files with 323 additions and 29 deletions
  1. 6 0
      soc-api/soc-api-system/src/main/java/com/xunmei/system/api/RemoteOrgService.java
  2. 11 0
      soc-api/soc-api-system/src/main/java/com/xunmei/system/api/factory/RemoteOrgFallbackFactory.java
  3. 12 0
      soc-api/soc-api-system/src/main/java/com/xunmei/system/api/function/RemoteCallHandler.java
  4. 22 0
      soc-api/soc-api-system/src/main/java/com/xunmei/system/api/function/RemoteCallHandlerExecutor.java
  5. 2 4
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/edu/domain/CoreEduTrainingPlan.java
  6. 8 2
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/edu/dto/CoreEduTrainingPlanInsertDto.java
  7. 13 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/edu/vo/CoreEduTrainingPlanPageVo.java
  8. 19 7
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/edu/controller/CoreEduTrainingPlanController.java
  9. 11 0
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/edu/mapper/CoreEduTrainingPlanToExecOrgMapper.java
  10. 11 0
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/edu/mapper/CoreEduTrainingPlanToRoleMapper.java
  11. 2 0
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/edu/service/ICoreEduTrainingPlanService.java
  12. 11 0
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/edu/service/ICoreEduTrainingPlanToExecOrgService.java
  13. 11 0
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/edu/service/ICoreEduTrainingPlanToRoleService.java
  14. 111 11
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/edu/service/impl/CoreEduTrainingPlanServiceImpl.java
  15. 15 0
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/edu/service/impl/CoreEduTrainingPlanToExecOrgServiceImpl.java
  16. 15 0
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/edu/service/impl/CoreEduTrainingPlanToRoleServiceImpl.java
  17. 6 3
      soc-modules/soc-modules-core/src/main/resources/mapper/edu/CoreEduTrainingPlanMapper.xml
  18. 27 2
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/controller/SysDeptController.java
  19. 2 0
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/ISysOrgService.java
  20. 8 0
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysOrgServiceImpl.java

+ 6 - 0
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/RemoteOrgService.java

@@ -42,4 +42,10 @@ public interface RemoteOrgService {
 
     @GetMapping("/dept/top")
     SysOrg selectTopOrg(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
+
+    @GetMapping("/dept/selectByOrgType/{orgType}")
+    List<SysOrg> selectByOrgType(@PathVariable("orgType") Integer orgType, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
+
+    @PostMapping("/dept/selectOrgByIdList")
+    List<SysOrg> selectOrgByIdList(List<Long> orgList, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
 }

+ 11 - 0
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/factory/RemoteOrgFallbackFactory.java

@@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.cloud.openfeign.FallbackFactory;
 import org.springframework.stereotype.Component;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -69,6 +70,16 @@ public class RemoteOrgFallbackFactory implements FallbackFactory<RemoteOrgServic
             public SysOrg selectOrgById(Long orgId, String source) {
                 return null;
             }
+
+            @Override
+            public List<SysOrg> selectByOrgType(Integer orgType, String source) {
+                return new ArrayList<>();
+            }
+
+            @Override
+            public List<SysOrg> selectOrgByIdList(List<Long> orgList, String source) {
+                return new ArrayList<>();
+            }
         };
     }
 }

+ 12 - 0
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/function/RemoteCallHandler.java

@@ -0,0 +1,12 @@
+package com.xunmei.system.api.function;
+
+/**
+ * @author jingyuanchao
+ * @date 2023/8/25 17:19
+ */
+@FunctionalInterface
+public interface RemoteCallHandler<T>{
+
+    T handle() throws Exception;
+
+}

+ 22 - 0
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/function/RemoteCallHandlerExecutor.java

@@ -0,0 +1,22 @@
+package com.xunmei.system.api.function;
+
+import com.xunmei.common.core.exception.SystemException;
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * @author jingyuanchao
+ * @date 2023/8/25 17:21
+ */
+@Slf4j
+public class RemoteCallHandlerExecutor {
+
+    public static  <T> T executeRemoteCall(RemoteCallHandler<T> handler, String errorMessage) {
+        try {
+            return handler.handle();
+        } catch (Exception e) {
+            log.error("远程调用错误: " + errorMessage + ", {}", e.getMessage());
+            throw new SystemException("远程调用错误: " + errorMessage);
+        }
+    }
+}

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

@@ -3,14 +3,11 @@ package com.xunmei.common.core.domain.edu.domain;
 import java.util.Date;
 import java.util.List;
 
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.*;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.IdType;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -110,6 +107,7 @@ public class CoreEduTrainingPlan extends BaseEntity {
     @TableField("file_list")
     private List<String> fileList;
 
+    @TableLogic(value = "0", delval = "1")
     @TableField(value = "deleted")
     @ApiModelProperty(value = "是否删除", notes = "0:否,1:是")
     private Integer deleted;

+ 8 - 2
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/edu/dto/CoreEduTrainingPlanInsertDto.java

@@ -5,6 +5,9 @@ import com.baomidou.mybatisplus.annotation.TableId;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
 import java.util.Date;
 import java.util.List;
 
@@ -16,9 +19,11 @@ import java.util.List;
 public class CoreEduTrainingPlanInsertDto {
 
 
+    @NotBlank(message = "计划名称不能为空")
     @ApiModelProperty(value = "计划名称")
     private String planName;
 
+    @NotNull(message = "计划周期不能为空")
     @ApiModelProperty(value = "计划周期")
     private Integer planCycle;
 
@@ -26,7 +31,7 @@ public class CoreEduTrainingPlanInsertDto {
     private Date startDate;
     @ApiModelProperty(value = "计划结束时间")
     private Date endDate;
-
+    @NotNull(message = "执行次数不能为空")
     @ApiModelProperty(value = "执行次数")
     private Integer execTimes;
 
@@ -36,8 +41,9 @@ public class CoreEduTrainingPlanInsertDto {
     @ApiModelProperty(value = "是否立即生效", notes = "0:否,1:是")
     private Boolean buildTaskNow=Boolean.FALSE;
 
+    @Size(min = 1,message = "计划培训角色")
     @ApiModelProperty(value = "计划执行角色")
-    private List<Long> planRoleIdList;
+    private List<Long> planRoleId;
 
     @ApiModelProperty(value = "培训机构类型")
     private Integer execOrgType;

+ 13 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/edu/vo/CoreEduTrainingPlanPageVo.java

@@ -1,6 +1,8 @@
 package com.xunmei.common.core.domain.edu.vo;
 
 import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
@@ -13,6 +15,10 @@ public class CoreEduTrainingPlanPageVo {
     @ApiModelProperty(value = "序号")
     private int no;
 
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "id")
+    private Long id;
+
     @ApiModelProperty(value = "计划名称")
     private String planName;
 
@@ -21,6 +27,10 @@ public class CoreEduTrainingPlanPageVo {
 
     @ApiModelProperty(value = "计划创建机构名称")
     private String createOrgName;
+    @ApiModelProperty(value = "计划所属机构id")
+    private Long belongOrgId;
+    @ApiModelProperty(value = "计划所属机构名称")
+    private String belongOrgName;
 
     @ApiModelProperty(value = "培训机构类型")
     private Integer execOrgType;
@@ -54,4 +64,7 @@ public class CoreEduTrainingPlanPageVo {
 
     @ApiModelProperty(value = "下发计划id", notes = "标准计划此字段为空")
     private Long parentId;
+
+    @ApiModelProperty(value = "是否由顶级机构创建",notes = "0:否 1:是")
+    private int createByTopOrg;
 }

+ 19 - 7
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/edu/controller/CoreEduTrainingPlanController.java

@@ -5,6 +5,7 @@ import com.xunmei.common.core.domain.edu.dto.CoreEduTrainingPlanInsertDto;
 import com.xunmei.common.core.domain.edu.dto.CoreEduTrainingPlanPageDto;
 import com.xunmei.core.edu.service.ICoreEduTrainingPlanService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PutMapping;
@@ -39,7 +40,7 @@ public class CoreEduTrainingPlanController extends BaseController {
      * 查询教育培训计划列表
      */
     @ApiOperation(value = "查询CoreEduTrainingPlan列表")
-    @RequiresPermissions("system:plan:list")
+    @RequiresPermissions("core:plan:list")
     @GetMapping("/list")
     public TableDataInfo list(CoreEduTrainingPlanPageDto coreEduTrainingPlan) {
         return coreEduTrainingPlanService.selectPage(coreEduTrainingPlan);
@@ -50,7 +51,7 @@ public class CoreEduTrainingPlanController extends BaseController {
      * 获取教育培训计划详细信息
      */
     @ApiOperation(value = "获取CoreEduTrainingPlan详细信息")
-    @RequiresPermissions("system:plan:query")
+    @RequiresPermissions("core:plan:query")
     @GetMapping(value = "/{id}")
     public AjaxResult getInfo(@PathVariable("id") Long id) {
         return success(coreEduTrainingPlanService.selectCoreEduTrainingPlanById(id));
@@ -60,10 +61,10 @@ public class CoreEduTrainingPlanController extends BaseController {
      * 新增教育培训计划
      */
     @ApiOperation(value = "新增CoreEduTrainingPlan")
-    @RequiresPermissions("system:plan:add")
+    @RequiresPermissions("core:plan:add")
     @Log(title = "教育培训计划", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody CoreEduTrainingPlanInsertDto coreEduTrainingPlan) {
+    public AjaxResult add(@RequestBody @Validated CoreEduTrainingPlanInsertDto coreEduTrainingPlan) {
         return toAjax(coreEduTrainingPlanService.insertCoreEduTrainingPlan(coreEduTrainingPlan));
     }
 
@@ -71,7 +72,7 @@ public class CoreEduTrainingPlanController extends BaseController {
      * 修改教育培训计划
      */
     @ApiOperation(value = "修改CoreEduTrainingPlan")
-    @RequiresPermissions("system:plan:edit")
+    @RequiresPermissions("core:plan:edit")
     @Log(title = "教育培训计划", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@RequestBody CoreEduTrainingPlan coreEduTrainingPlan) {
@@ -82,7 +83,7 @@ public class CoreEduTrainingPlanController extends BaseController {
      * 删除教育培训计划
      */
     @ApiOperation(value = "删除CoreEduTrainingPlan")
-    @RequiresPermissions("system:plan:remove")
+    @RequiresPermissions("core:plan:remove")
     @Log(title = "教育培训计划", businessType = BusinessType.DELETE)
     @DeleteMapping("/{ids}")
     public AjaxResult remove(@PathVariable Long[] ids) {
@@ -93,9 +94,20 @@ public class CoreEduTrainingPlanController extends BaseController {
      * 获取机构下的教育培训计划关联的角色信息
      */
     @ApiOperation(value = "获取机构下的教育培训计划关联的角色信息")
-    @RequiresPermissions("system:plan:query")
+    @RequiresPermissions("core:plan:query")
     @GetMapping("/role/list")
     public AjaxResult listPlanRole(Long orgId) {
         return success(coreEduTrainingPlanService.listPlanRole(orgId));
     }
+
+    /**
+     * 计划下发
+     */
+    @ApiOperation(value = "计划下发")
+    @RequiresPermissions("core:plan:publish")
+    @GetMapping("/publish/{planId}")
+    public AjaxResult publishPlan(@PathVariable("planId") Long planId) {
+        coreEduTrainingPlanService.publishPlan(planId);
+        return AjaxResult.success();
+    }
 }

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

@@ -0,0 +1,11 @@
+package com.xunmei.core.edu.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.xunmei.common.core.domain.edu.domain.CoreEduTrainingPlanToExecOrg;
+
+/**
+ * @author jingyuanchao
+ * @date 2023/8/25 14:27
+ */
+public interface CoreEduTrainingPlanToExecOrgMapper extends BaseMapper<CoreEduTrainingPlanToExecOrg> {
+}

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

@@ -0,0 +1,11 @@
+package com.xunmei.core.edu.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.xunmei.common.core.domain.edu.domain.CoreEduTrainingPlanToRole;
+
+/**
+ * @author jingyuanchao
+ * @date 2023/8/25 14:27
+ */
+public interface CoreEduTrainingPlanToRoleMapper extends BaseMapper<CoreEduTrainingPlanToRole> {
+}

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

@@ -74,4 +74,6 @@ public interface ICoreEduTrainingPlanService extends IService<CoreEduTrainingPla
 
     List<CoreEduTrainingPlanRoleVo> listPlanRole(Long orgId);
 
+    void publishPlan(Long planId);
+
 }

+ 11 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/edu/service/ICoreEduTrainingPlanToExecOrgService.java

@@ -0,0 +1,11 @@
+package com.xunmei.core.edu.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.xunmei.common.core.domain.edu.domain.CoreEduTrainingPlanToExecOrg;
+
+/**
+ * @author jingyuanchao
+ * @date 2023/8/25 14:30
+ */
+public interface ICoreEduTrainingPlanToExecOrgService extends IService<CoreEduTrainingPlanToExecOrg> {
+}

+ 11 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/edu/service/ICoreEduTrainingPlanToRoleService.java

@@ -0,0 +1,11 @@
+package com.xunmei.core.edu.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.xunmei.common.core.domain.edu.domain.CoreEduTrainingPlanToRole;
+
+/**
+ * @author jingyuanchao
+ * @date 2023/8/25 14:29
+ */
+public interface ICoreEduTrainingPlanToRoleService extends IService<CoreEduTrainingPlanToRole> {
+}

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

@@ -1,33 +1,47 @@
 package com.xunmei.core.edu.service.impl;
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.xunmei.common.core.constant.SecurityConstants;
 import com.xunmei.common.core.domain.R;
+import com.xunmei.common.core.domain.edu.domain.CoreEduTrainingPlanToExecOrg;
+import com.xunmei.common.core.domain.edu.domain.CoreEduTrainingPlanToRole;
 import com.xunmei.common.core.domain.edu.dto.CoreEduTrainingPlanInsertDto;
 import com.xunmei.common.core.domain.edu.dto.CoreEduTrainingPlanPageDto;
 import com.xunmei.common.core.domain.edu.vo.CoreEduTrainingPlanPageVo;
 import com.xunmei.common.core.domain.edu.vo.CoreEduTrainingPlanRoleVo;
+import com.xunmei.common.core.exception.SystemException;
 import com.xunmei.common.core.utils.DateUtils;
 import com.xunmei.common.security.utils.SecurityUtils;
 import com.xunmei.core.edu.mapper.CoreEduTrainingPlanMapper;
+import com.xunmei.core.edu.mapper.CoreEduTrainingPlanToExecOrgMapper;
+import com.xunmei.core.edu.mapper.CoreEduTrainingPlanToRoleMapper;
 import com.xunmei.core.edu.service.ICoreEduTrainingPlanService;
+import com.xunmei.core.edu.service.ICoreEduTrainingPlanToExecOrgService;
+import com.xunmei.core.edu.service.ICoreEduTrainingPlanToRoleService;
 import com.xunmei.system.api.RemoteOrgService;
 import com.xunmei.system.api.domain.SysOrg;
+import com.xunmei.system.api.function.RemoteCallHandlerExecutor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.BooleanUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.Arrays;
+import java.util.stream.Collectors;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.common.core.domain.edu.domain.CoreEduTrainingPlan;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.Assert;
 
 /**
  * 教育培训计划Service业务层处理
@@ -41,6 +55,14 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
     @Autowired
     private CoreEduTrainingPlanMapper coreEduTrainingPlanMapper;
     @Autowired
+    private ICoreEduTrainingPlanToRoleService coreEduTrainingPlanToRoleService;
+    @Autowired
+    private CoreEduTrainingPlanToRoleMapper coreEduTrainingPlanToRoleMapper;
+    @Autowired
+    private ICoreEduTrainingPlanToExecOrgService coreEduTrainingPlanToExecOrgService;
+    @Autowired
+    private CoreEduTrainingPlanToExecOrgMapper coreEduTrainingPlanToExecOrgMapper;
+    @Autowired
     private RemoteOrgService orgService;
 
     @Override
@@ -54,18 +76,28 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
         }
         //下穿
         if (request.getCheckSub()) {
-            R<SysOrg> r;
+            SysOrg r;
             try {
-                r = orgService.selectSysOrgById(request.getBelongOrgId(), SecurityConstants.INNER);
+                r = orgService.selectOrgById(request.getBelongOrgId(), SecurityConstants.INNER);
             } catch (Exception e) {
                 throw new RuntimeException("远程调用错误:获取机构信息失败!");
             }
-            request.setBelongOrgPath(r.getData().getPath());
+            request.setBelongOrgPath(r.getPath());
         }
         //获取数据
         page = coreEduTrainingPlanMapper.selectPageData(page, request);
+        SysOrg sysOrg;
+        try {
+            sysOrg = orgService.selectTopOrg(SecurityConstants.INNER);
+        } catch (Exception e) {
+            log.error("远程调用错误:获取机构信息失败!");
+            throw new RuntimeException(e);
+        }
         for (CoreEduTrainingPlanPageVo record : page.getRecords()) {
             record.setNo(page.getRecords().indexOf(record) + 1);
+            if (ObjectUtil.equal(record.getCreateOrgId(), sysOrg.getId())) {
+                record.setCreateByTopOrg(1);
+            }
         }
         //抓换为TableDataInfo适配前端
         TableDataInfo tableDataInfo = new TableDataInfo();
@@ -110,26 +142,56 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
     @Override
     @Transactional(rollbackFor = Exception.class)
     public int insertCoreEduTrainingPlan(CoreEduTrainingPlanInsertDto request) {
+        if (ObjectUtil.isAllEmpty(request.getExecOrgType(), request.getPlanExecOrgIdList())) {
+            throw new RuntimeException("培训机构类型和执行机构不能同时为空!");
+        }
         CoreEduTrainingPlan plan = new CoreEduTrainingPlan();
         BeanUtils.copyProperties(request, plan);
+        plan.setId(IdWorker.getId());
         plan.setCreateTime(new Date());
         plan.setUpdateTime(new Date());
         plan.setCreateBy(SecurityUtils.getUserId().toString());
         plan.setUpdateBy(SecurityUtils.getUserId().toString());
-        plan.setBuildTaskNow(request.getBuildTaskNow() ? 1 : 0);
+        plan.setBuildTaskNow(Boolean.TRUE.equals(request.getBuildTaskNow()) ? 1 : 0);
         final Long orgId = SecurityUtils.getLoginUser().getSysUser().getOrgId();
         SysOrg r;
+        SysOrg topOrg;
         try {
             r = orgService.selectOrgById(orgId, SecurityConstants.INNER);
+            topOrg = orgService.selectTopOrg(SecurityConstants.INNER);
         } catch (Exception e) {
             log.error("远程调用错误:获取机构信息失败!");
             throw new RuntimeException(e);
         }
-        plan.setCreateOrgId(SecurityUtils.getLoginUser().getSysUser().getOrgId());
+        plan.setCreateOrgId(orgId);
         plan.setCreateOrgName(r.getName());
         plan.setCreateOrgPath(r.getPath());
+        plan.setBelongOrgId(orgId);
+        plan.setBelongOrgName(r.getName());
+        plan.setBelongOrgPath(r.getPath());
+        if (ObjectUtil.equal(orgId, topOrg.getId())) {
+            plan.setStandard(1);
+            plan.setIssue(0);
+        }
 
-
+        List<CoreEduTrainingPlanToRole> planRoleList = new ArrayList<>();
+        for (Long roleId : request.getPlanRoleId()) {
+            CoreEduTrainingPlanToRole role = new CoreEduTrainingPlanToRole();
+            role.setRoleId(roleId);
+            role.setPlanId(plan.getId());
+            planRoleList.add(role);
+        }
+        coreEduTrainingPlanToRoleService.saveBatch(planRoleList);
+        if (ObjectUtil.isNotEmpty(request.getPlanExecOrgIdList())) {
+            List<CoreEduTrainingPlanToExecOrg> planOrgList = new ArrayList<CoreEduTrainingPlanToExecOrg>();
+            for (Long orgId1 : request.getPlanExecOrgIdList()) {
+                CoreEduTrainingPlanToExecOrg org = new CoreEduTrainingPlanToExecOrg();
+                org.setOrgId(orgId1);
+                org.setPlanId(plan.getId());
+                planOrgList.add(org);
+            }
+            coreEduTrainingPlanToExecOrgService.saveBatch(planOrgList);
+        }
         return coreEduTrainingPlanMapper.insert(plan);
     }
 
@@ -140,8 +202,10 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
      * @return 结果
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public int updateCoreEduTrainingPlan(CoreEduTrainingPlan coreEduTrainingPlan) {
         coreEduTrainingPlan.setUpdateTime(DateUtils.getNowDate());
+        coreEduTrainingPlan.setUpdateBy(SecurityUtils.getLoginUser().getSysUser().getId().toString());
         return coreEduTrainingPlanMapper.updateById(coreEduTrainingPlan);
     }
 
@@ -152,6 +216,7 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
      * @return 结果
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public int deleteCoreEduTrainingPlanByIds(Long[] ids) {
         return coreEduTrainingPlanMapper.deleteBatchIds(Arrays.asList((ids)));
     }
@@ -163,22 +228,57 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
      * @return 结果
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public int deleteCoreEduTrainingPlanById(Long id) {
         return coreEduTrainingPlanMapper.deleteById(id);
     }
 
     @Override
+
     public List<CoreEduTrainingPlanRoleVo> listPlanRole(Long orgId) {
         if (orgId == null) {
-            SysOrg r;
+            SysOrg r = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectTopOrg(SecurityConstants.INNER), "获取机构信息失败!");
+            orgId = r.getId();
+        }
+        return coreEduTrainingPlanMapper.selectPlanRole(orgId);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void publishPlan(Long planId) {
+        final CoreEduTrainingPlan plan = coreEduTrainingPlanMapper.selectById(planId);
+        if (plan == null) {
+            throw new SystemException("计划不存在!");
+        }
+        // 下发 按钮显示逻辑:仅省联社安全保卫管理人员进入且由省联社管理安全保卫人员创建的计划才显示
+        //todo 判断当前人的角色信息
+
+
+        //获取执行角色
+        QueryWrapper<CoreEduTrainingPlanToRole> ros = new QueryWrapper<>();
+        ros.lambda().eq(CoreEduTrainingPlanToRole::getPlanId, plan.getId());
+        List<CoreEduTrainingPlanToRole> planRoleList = coreEduTrainingPlanToRoleMapper.selectList(ros);
+
+
+        final Integer execOrgType = plan.getExecOrgType();
+        List<SysOrg> orgList;
+        if (execOrgType != null) {
+            //获取具体执行检查的机构
             try {
-                r = orgService.selectTopOrg(SecurityConstants.INNER);
-                orgId = r.getId();
+                orgList = orgService.selectByOrgType(execOrgType, SecurityConstants.INNER);
             } catch (Exception e) {
                 log.error("远程调用错误:获取机构信息失败!,{}", e.getMessage());
-                throw new RuntimeException("远程调用错误:获取机构信息失败!");
+                throw new SystemException("远程调用错误:获取机构信息失败!");
             }
+            Assert.notEmpty(orgList, "无法根据培训机构类型找到具体机构,请修改计划内容!");
+        } else {
+            QueryWrapper<CoreEduTrainingPlanToExecOrg> eos = new QueryWrapper<>();
+            eos.lambda().eq(CoreEduTrainingPlanToExecOrg::getPlanId, plan.getId());
+            List<CoreEduTrainingPlanToExecOrg> execOrg = coreEduTrainingPlanToExecOrgMapper.selectList(eos);
+            Assert.notEmpty(execOrg, "未能查找到具体的培训机构,请联系管理员!");
+            final List<Long> list = execOrg.stream().map(CoreEduTrainingPlanToExecOrg::getOrgId).collect(Collectors.toList());
+            orgList = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectOrgByIdList(list, SecurityConstants.INNER), "未能查找到具体的培训机构,请联系管理员!");
         }
-        return coreEduTrainingPlanMapper.selectPlanRole(orgId);
+
     }
 }

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

@@ -0,0 +1,15 @@
+package com.xunmei.core.edu.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xunmei.common.core.domain.edu.domain.CoreEduTrainingPlanToExecOrg;
+import com.xunmei.core.edu.mapper.CoreEduTrainingPlanToExecOrgMapper;
+import com.xunmei.core.edu.service.ICoreEduTrainingPlanToExecOrgService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author jingyuanchao
+ * @date 2023/8/25 14:31
+ */
+@Service
+public class CoreEduTrainingPlanToExecOrgServiceImpl extends ServiceImpl<CoreEduTrainingPlanToExecOrgMapper, CoreEduTrainingPlanToExecOrg> implements ICoreEduTrainingPlanToExecOrgService {
+}

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

@@ -0,0 +1,15 @@
+package com.xunmei.core.edu.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xunmei.common.core.domain.edu.domain.CoreEduTrainingPlanToRole;
+import com.xunmei.core.edu.mapper.CoreEduTrainingPlanToRoleMapper;
+import com.xunmei.core.edu.service.ICoreEduTrainingPlanToRoleService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author jingyuanchao
+ * @date 2023/8/25 14:32
+ */
+@Service
+public class CoreEduTrainingPlanToRoleServiceImpl extends ServiceImpl<CoreEduTrainingPlanToRoleMapper, CoreEduTrainingPlanToRole> implements ICoreEduTrainingPlanToRoleService {
+}

+ 6 - 3
soc-modules/soc-modules-core/src/main/resources/mapper/edu/CoreEduTrainingPlanMapper.xml

@@ -349,15 +349,18 @@
     </delete>
 
     <select id="selectPageData" resultType="com.xunmei.common.core.domain.edu.vo.CoreEduTrainingPlanPageVo">
-        select p.plan_name,
+        select p.id              as id,
+               p.plan_name,
                p.create_org_id,
                p.create_org_name,
                p.exec_org_type,
                p.plan_cycle,
                p.exec_times,
                p.remark,
-               u.name as updateBy,
-               p.plan_status
+               u.name            as updateBy,
+               p.plan_status,
+               P.belong_org_id   as belongOrgId,
+               P.belong_org_name as belongOrgName
         from core_edu_training_plan p
                  left join sys_user u on p.update_by = u.id
     </select>

+ 27 - 2
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/controller/SysDeptController.java

@@ -1,5 +1,6 @@
 package com.xunmei.system.controller;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.xunmei.common.core.constant.Constants;
 import com.xunmei.common.core.domain.R;
@@ -23,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -166,6 +168,7 @@ public class SysDeptController extends BaseController {
 
     /**
      * 获取顶级机构
+     *
      * @return
      */
     @GetMapping("/top")
@@ -173,13 +176,35 @@ public class SysDeptController extends BaseController {
     public SysOrg selectSysOrgById() {
         return orgService.selectByParentId(Constants.TOP_ORG_PARENT_ID);
     }
+
     /**
-     * 获取顶级机构
+     * 获取单个机构
+     *
      * @return
      */
     @GetMapping("/get/{orgId}")
     @InnerAuth
     public SysOrg selectOrgById(@PathVariable("orgId") Long orgId) {
-         return orgService.getById(orgId);
+        return orgService.getById(orgId);
+    }
+
+
+    /**
+     * 根据机构类型获取机构数组
+     *
+     * @return
+     */
+    @InnerAuth
+    @GetMapping("/dept/selectByOrgType/{orgType}")
+    List<SysOrg> selectByOrgType(@PathVariable("orgType") Integer orgType) {
+        return orgService.selectByOrgType(orgType);
+    }
+
+    @PostMapping("/dept/selectOrgByIdList")
+    List<SysOrg> selectByOrgType(List<Long> orgList){
+        if (ObjectUtil.isEmpty(orgList)){
+            return new ArrayList<>();
+        }
+        return orgService.listByIds(orgList);
     }
 }

+ 2 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/ISysOrgService.java

@@ -73,4 +73,6 @@ public interface ISysOrgService extends IService<SysOrg> {
     String selectPathById(Long orgId);
 
     SysOrg selectByParentId(Long orgId);
+
+    List<SysOrg> selectByOrgType(Integer orgType);
 }

+ 8 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysOrgServiceImpl.java

@@ -164,4 +164,12 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
         wrapper.eq(SysOrg::getParentId, orgId);
         return sysOrgMapper.selectOne(wrapper);
     }
+
+    @Override
+    public List<SysOrg> selectByOrgType(Integer orgType) {
+        LambdaQueryWrapper<SysOrg> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(SysOrg::getType, orgType);
+        wrapper.eq(SysOrg::getDeleted, 0);
+        return sysOrgMapper.selectList(wrapper);
+    }
 }