xiaofei 1 жил өмнө
parent
commit
983f909113

+ 67 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/ProfessionalCourseSelectResult.java

@@ -0,0 +1,67 @@
+package com.qmth.distributed.print.business.bean.result;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * 专业认证课程选择
+ */
+public class ProfessionalCourseSelectResult {
+
+    @ApiModelProperty(value = "课程名称")
+    private String courseName;
+
+    @ApiModelProperty(value = "课程编号")
+    private String courseCode;
+
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "开课机构ID")
+    private Long orgId;
+
+    @ApiModelProperty(value = "开课机构名称")
+    private String orgName;
+
+    @ApiModelProperty(value = "是否可选")
+    private boolean canSelect;
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
+    public String getCourseCode() {
+        return courseCode;
+    }
+
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
+    }
+
+    public Long getOrgId() {
+        return orgId;
+    }
+
+    public void setOrgId(Long orgId) {
+        this.orgId = orgId;
+    }
+
+    public String getOrgName() {
+        return orgName;
+    }
+
+    public void setOrgName(String orgName) {
+        this.orgName = orgName;
+    }
+
+    public boolean isCanSelect() {
+        return canSelect;
+    }
+
+    public void setCanSelect(boolean canSelect) {
+        this.canSelect = canSelect;
+    }
+}

+ 6 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/TPCourseMapper.java

@@ -1,7 +1,12 @@
 package com.qmth.distributed.print.business.mapper;
 
+import com.qmth.distributed.print.business.bean.result.ProfessionalCourseSelectResult;
 import com.qmth.distributed.print.business.entity.TPCourse;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Set;
 
 /**
  * <p>
@@ -13,4 +18,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface TPCourseMapper extends BaseMapper<TPCourse> {
 
+    List<ProfessionalCourseSelectResult> queryList(@Param("professionalId") Long professionalId, @Param("orgIdSet") Set<Long> orgIdSet);
 }

+ 3 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TPCourseService.java

@@ -2,6 +2,7 @@ package com.qmth.distributed.print.business.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.distributed.print.business.bean.params.professional.TPCourseParam;
+import com.qmth.distributed.print.business.bean.result.ProfessionalCourseSelectResult;
 import com.qmth.distributed.print.business.entity.TPCourse;
 
 import java.util.List;
@@ -23,4 +24,6 @@ public interface TPCourseService extends IService<TPCourse> {
     boolean saveSort(TPCourseParam tpCourseParam);
 
     boolean removeCourse(Long id);
+
+    List<ProfessionalCourseSelectResult> queryList(Long orgId, Long professionalId);
 }

+ 3 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TPMatrixService.java

@@ -21,11 +21,13 @@ public interface TPMatrixService extends IService<TPMatrix> {
 
     List<MatrixDto> listMatrix(Long professionalId);
 
-    boolean saveMatrix(Long id, Double content);
+    boolean saveMatrix(TPMatrix tpMatrix);
 
     void downloadMatrix(Long professionalId, HttpServletResponse response);
 
     List<TPMatrix> listMatrixByCondition(Long professionalId, Long courseId, Long requirementId);
 
     void updateMatrixForNodeCount(TPCourse tpCourse, TPRequirement tpRequirement);
+
+    void removeMatrixByCondition(Long professionalId, Long courseId, Long requirementId);
 }

+ 22 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TPCourseServiceImpl.java

@@ -4,22 +4,29 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.distributed.print.business.bean.params.professional.TPCourseParam;
+import com.qmth.distributed.print.business.bean.result.ProfessionalCourseSelectResult;
 import com.qmth.distributed.print.business.entity.TPCourse;
 import com.qmth.distributed.print.business.entity.TPRequirement;
 import com.qmth.distributed.print.business.mapper.TPCourseMapper;
 import com.qmth.distributed.print.business.service.TPCourseService;
 import com.qmth.distributed.print.business.service.TPMatrixService;
 import com.qmth.distributed.print.business.service.TPRequirementService;
+import com.qmth.teachcloud.common.bean.result.TeachCourseSelectResult;
+import com.qmth.teachcloud.common.entity.BasicCourse;
+import com.qmth.teachcloud.common.entity.SysOrg;
 import com.qmth.teachcloud.common.entity.SysUser;
+import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
+import com.qmth.teachcloud.common.service.SysOrgService;
 import com.qmth.teachcloud.common.util.ServletUtil;
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * <p>
@@ -36,6 +43,8 @@ public class TPCourseServiceImpl extends ServiceImpl<TPCourseMapper, TPCourse> i
     private TPRequirementService tpRequirementService;
     @Resource
     private TPMatrixService tpMatrixService;
+    @Resource
+    private SysOrgService sysOrgService;
 
     @Override
     public List<TPCourse> listCourse(Long professionalId) {
@@ -92,7 +101,17 @@ public class TPCourseServiceImpl extends ServiceImpl<TPCourseMapper, TPCourse> i
     @Transactional
     @Override
     public boolean removeCourse(Long id) {
-        // todo 是否删除矩阵数据
+        tpMatrixService.removeMatrixByCondition(null, id, null);
         return this.removeById(id);
     }
+
+    @Override
+    public List<ProfessionalCourseSelectResult> queryList(Long orgId, Long professionalId) {
+        if (orgId == null) {
+            throw ExceptionResultEnum.ERROR.exception("请选择学院");
+        }
+        Set<Long> orgIdSet = sysOrgService.findDeepOrgIdListByOrgIdList(Arrays.asList(orgId));
+
+        return this.baseMapper.queryList(professionalId, orgIdSet);
+    }
 }

+ 64 - 25
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TPMatrixServiceImpl.java

@@ -2,6 +2,7 @@ package com.qmth.distributed.print.business.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.boot.tools.excel.ExcelWriter;
@@ -87,10 +88,10 @@ public class TPMatrixServiceImpl extends ServiceImpl<TPMatrixMapper, TPMatrix> i
     }
 
     @Override
-    public boolean saveMatrix(Long id, Double content) {
+    public boolean saveMatrix(TPMatrix tpMatrix) {
         UpdateWrapper<TPMatrix> updateWrapper = new UpdateWrapper<>();
-        updateWrapper.lambda().set(TPMatrix::getContent, content)
-                .eq(TPMatrix::getId, id);
+        updateWrapper.lambda().set(TPMatrix::getContent, tpMatrix.getContent())
+                .eq(TPMatrix::getId, tpMatrix.getId());
         return this.update(updateWrapper);
     }
 
@@ -169,16 +170,6 @@ public class TPMatrixServiceImpl extends ServiceImpl<TPMatrixMapper, TPMatrix> i
                 tpMatrix.setCourseId(tpCourse.getId());
                 tpMatrix.setRequirementId(tpRequirement.getId());
                 tpMatrixAddList.add(tpMatrix);
-            } else {
-                for (int i = 1; i <= tpRequirement.getNodeCount(); i++) {
-                    TPMatrix tpMatrix = new TPMatrix();
-                    tpMatrix.insertInfo(sysUser.getId());
-                    tpMatrix.setProfessionalId(tpRequirement.getProfessionalId());
-                    tpMatrix.setCourseId(tpCourse.getId());
-                    tpMatrix.setRequirementId(tpRequirement.getId());
-                    tpMatrix.setSubName(tpRequirement.getSortNum() + "-" + i);
-                    tpMatrixAddList.add(tpMatrix);
-                }
             }
         }
         // 修改
@@ -194,19 +185,51 @@ public class TPMatrixServiceImpl extends ServiceImpl<TPMatrixMapper, TPMatrix> i
                 tpMatrix.setRequirementId(tpRequirement.getId());
                 tpMatrixAddList.add(tpMatrix);
             } else {
-                if (tpRequirement.getNodeCount() > matrixList.size()) {
-                    for (int i = matrixList.size() + 1; i <= tpRequirement.getNodeCount(); i++) {
-                        TPMatrix tpMatrix = new TPMatrix();
-                        tpMatrix.insertInfo(sysUser.getId());
-                        tpMatrix.setProfessionalId(tpRequirement.getProfessionalId());
-                        tpMatrix.setCourseId(tpCourse.getId());
-                        tpMatrix.setRequirementId(tpRequirement.getId());
-                        tpMatrix.setSubName(tpRequirement.getSortNum() + "-" + i);
-                        tpMatrixAddList.add(tpMatrix);
+                if (matrixList.size() == 1) {
+                    if(matrixList.get(0).getSubName() == null){
+                        tpMatrixRemoveList.add(matrixList.get(0).getId());
+
+                        for (int i = 1; i <= tpRequirement.getNodeCount(); i++) {
+                            TPMatrix tpMatrix = new TPMatrix();
+                            tpMatrix.insertInfo(sysUser.getId());
+                            tpMatrix.setProfessionalId(tpRequirement.getProfessionalId());
+                            tpMatrix.setCourseId(tpCourse.getId());
+                            tpMatrix.setRequirementId(tpRequirement.getId());
+                            tpMatrix.setSubName(tpRequirement.getSortNum() + "-" + i);
+                            tpMatrixAddList.add(tpMatrix);
+                        }
+                    } else {
+                        if (tpRequirement.getNodeCount() > matrixList.size()) {
+                            for (int i = matrixList.size() + 1; i <= tpRequirement.getNodeCount(); i++) {
+                                TPMatrix tpMatrix = new TPMatrix();
+                                tpMatrix.insertInfo(sysUser.getId());
+                                tpMatrix.setProfessionalId(tpRequirement.getProfessionalId());
+                                tpMatrix.setCourseId(tpCourse.getId());
+                                tpMatrix.setRequirementId(tpRequirement.getId());
+                                tpMatrix.setSubName(tpRequirement.getSortNum() + "-" + i);
+                                tpMatrixAddList.add(tpMatrix);
+                            }
+                        } else if (tpRequirement.getNodeCount() < matrixList.size()) {
+                            for (int i = tpRequirement.getNodeCount(); i <= matrixList.size() - 1; i++) {
+                                tpMatrixRemoveList.add(matrixList.get(i).getId());
+                            }
+                        }
                     }
-                } else if (tpRequirement.getNodeCount() < matrixList.size()) {
-                    for (int i = tpRequirement.getNodeCount(); i <= matrixList.size() - 1; i++) {
-                        tpMatrixRemoveList.add(matrixList.get(i).getId());
+                } else {
+                    if (tpRequirement.getNodeCount() > matrixList.size()) {
+                        for (int i = matrixList.size() + 1; i <= tpRequirement.getNodeCount(); i++) {
+                            TPMatrix tpMatrix = new TPMatrix();
+                            tpMatrix.insertInfo(sysUser.getId());
+                            tpMatrix.setProfessionalId(tpRequirement.getProfessionalId());
+                            tpMatrix.setCourseId(tpCourse.getId());
+                            tpMatrix.setRequirementId(tpRequirement.getId());
+                            tpMatrix.setSubName(tpRequirement.getSortNum() + "-" + i);
+                            tpMatrixAddList.add(tpMatrix);
+                        }
+                    } else if (tpRequirement.getNodeCount() < matrixList.size()) {
+                        for (int i = tpRequirement.getNodeCount(); i <= matrixList.size() - 1; i++) {
+                            tpMatrixRemoveList.add(matrixList.get(i).getId());
+                        }
                     }
                 }
             }
@@ -218,4 +241,20 @@ public class TPMatrixServiceImpl extends ServiceImpl<TPMatrixMapper, TPMatrix> i
             this.removeByIds(tpMatrixRemoveList);
         }
     }
+
+    @Override
+    public void removeMatrixByCondition(Long professionalId, Long courseId, Long requirementId) {
+        UpdateWrapper<TPMatrix> updateWrapper = new UpdateWrapper<>();
+        LambdaUpdateWrapper<TPMatrix> lambda = updateWrapper.lambda();
+        if (professionalId != null) {
+            lambda.eq(TPMatrix::getProfessionalId, professionalId);
+        }
+        if (courseId != null) {
+            lambda.eq(TPMatrix::getCourseId, courseId);
+        }
+        if (requirementId != null) {
+            lambda.eq(TPMatrix::getRequirementId, requirementId);
+        }
+        this.remove(updateWrapper);
+    }
 }

+ 3 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TPRequirementServiceImpl.java

@@ -58,6 +58,7 @@ public class TPRequirementServiceImpl extends ServiceImpl<TPRequirementMapper, T
         else {
             tpRequirement.insertInfo(sysUser.getId());
         }
+        this.saveOrUpdate(tpRequirement);
         // todo 节点数变动后,修改矩阵数据
         List<TPCourse> tpCourseList = tpCourseService.listCourse(tpRequirement.getProfessionalId());
         if (CollectionUtils.isNotEmpty(tpCourseList)) {
@@ -65,7 +66,6 @@ public class TPRequirementServiceImpl extends ServiceImpl<TPRequirementMapper, T
                 tpMatrixService.updateMatrixForNodeCount(tpCourse, tpRequirement);
             }
         }
-        this.saveOrUpdate(tpRequirement);
         return true;
     }
 
@@ -82,8 +82,10 @@ public class TPRequirementServiceImpl extends ServiceImpl<TPRequirementMapper, T
         return true;
     }
 
+    @Transactional
     @Override
     public boolean removeRequirement(Long id) {
+        tpMatrixService.removeMatrixByCondition(null, null, id);
         return this.removeById(id);
     }
 }

+ 32 - 0
distributed-print-business/src/main/resources/mapper/TPCourseMapper.xml

@@ -14,5 +14,37 @@
         <result column="update_id" property="updateId" />
         <result column="update_time" property="updateTime" />
     </resultMap>
+    <select id="queryList"
+            resultType="com.qmth.distributed.print.business.bean.result.ProfessionalCourseSelectResult">
+        SELECT
+            bc.code courseCode,
+            bc.name courseName,
+            bc.teaching_room_id orgId,
+            so.name orgName,
+            CASE
+                WHEN tpc.id IS NULL THEN TRUE
+                ELSE FALSE
+                END canSelect
+        FROM
+            (SELECT
+                 *
+             FROM
+                 basic_course
+             WHERE
+                 teaching_room_id IN
+             <foreach collection="orgIdSet" item="orgId" separator="," open="(" close=")">
+                 #{orgId}
+             </foreach>
+             ) bc
+                LEFT JOIN
+            (SELECT
+                 *
+             FROM
+                 t_p_course
+             WHERE
+                 professional_id = #{professionalId}) tpc ON bc.code = tpc.course_code
+                LEFT JOIN
+            sys_org so ON bc.teaching_room_id = so.id
+    </select>
 
 </mapper>

+ 6 - 7
distributed-print/src/main/java/com/qmth/distributed/print/api/TPProfessionalController.java

@@ -69,9 +69,9 @@ public class TPProfessionalController {
     @ApiOperation(value = "课程管理-选择课程")
     @RequestMapping(value = "/course/query_list", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "分页查询", response = TPCourse.class)})
-    public Result queryList(@ApiParam(value = "机构ID", required = true) @RequestParam Long orgId) {
-//        return ResultUtil.ok(tpCourseService.listCourse(professionalId));
-        return null;
+    public Result queryList(@ApiParam(value = "机构ID", required = true) @RequestParam Long orgId,
+                            @ApiParam(value = "机构ID", required = true) @RequestParam Long professionalId) {
+        return ResultUtil.ok(tpCourseService.queryList(orgId, professionalId));
     }
 
     @ApiOperation(value = "课程管理-查询")
@@ -131,7 +131,7 @@ public class TPProfessionalController {
     }
 
     @ApiOperation(value = "毕业矩阵支撑-查询")
-    @RequestMapping(value = "/matrix/list", method = RequestMethod.POST)
+    @RequestMapping(value = "/matrix/get", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "分页查询", response = MatrixDto.class)})
     public Result listMatrix(@ApiParam(value = "专业ID", required = true) @RequestParam Long professionalId) {
         return ResultUtil.ok(tpMatrixService.listMatrix(professionalId));
@@ -140,9 +140,8 @@ public class TPProfessionalController {
     @ApiOperation(value = "毕业矩阵支撑-提交")
     @RequestMapping(value = "/matrix/save", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "分页查询", response = Boolean.class)})
-    public Result saveMatrix(@ApiParam(value = "毕业矩阵支撑ID", required = true) @RequestParam Long id,
-                             @ApiParam(value = "毕业矩阵支撑值", required = true) @RequestParam Double content) {
-        return ResultUtil.ok(tpMatrixService.saveMatrix(id, content));
+    public Result saveMatrix(@RequestBody TPMatrix tpMatrix) {
+        return ResultUtil.ok(tpMatrixService.saveMatrix(tpMatrix));
     }
 
     @ApiOperation(value = "毕业矩阵支撑-下载")