xiaofei hace 1 año
padre
commit
2dec13e783

+ 3 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TPRequirement.java

@@ -1,5 +1,7 @@
 package com.qmth.distributed.print.business.entity;
 
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.qmth.teachcloud.common.base.BaseEntity;
 import io.swagger.annotations.ApiModel;
@@ -29,6 +31,7 @@ public class TPRequirement extends BaseEntity implements Serializable {
     private String name;
 
     @ApiModelProperty(value = "节点数量")
+    @TableField(updateStrategy = FieldStrategy.IGNORED)
     private Integer nodeCount;
 
     @ApiModelProperty(value = "排序值")

+ 3 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/TPMatrixMapper.java

@@ -3,6 +3,8 @@ package com.qmth.distributed.print.business.mapper;
 import com.qmth.distributed.print.business.entity.TPMatrix;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
+import java.util.List;
+
 /**
  * <p>
  * 专业认证毕业要求支撑矩阵 Mapper 接口
@@ -13,4 +15,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface TPMatrixMapper extends BaseMapper<TPMatrix> {
 
+    List<TPMatrix> listMatrix(Long professionalId);
 }

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

@@ -26,4 +26,6 @@ public interface TPCourseService extends IService<TPCourse> {
     boolean removeCourse(Long id);
 
     List<ProfessionalCourseSelectResult> queryList(Long orgId, Long professionalId);
+
+    int getMaxSortNum(Long professionalId);
 }

+ 2 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TPRequirementService.java

@@ -23,4 +23,6 @@ public interface TPRequirementService extends IService<TPRequirement> {
     boolean saveSort(List<TPRequirement> requirementList);
 
     boolean removeRequirement(Long id);
+
+    int getMaxSortNum(Long professionalId);
 }

+ 16 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TPCourseServiceImpl.java

@@ -60,12 +60,13 @@ public class TPCourseServiceImpl extends ServiceImpl<TPCourseMapper, TPCourse> i
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         List<TPCourse> tpCourseList = new ArrayList<>();
         AtomicInteger i = new AtomicInteger(1);
+        int maxSortNum = this.getMaxSortNum(tpCourseParam.getProfessionalId());
         tpCourseParam.getCourses().forEach(t -> {
             TPCourse tpCourse = new TPCourse();
             tpCourse.setProfessionalId(tpCourseParam.getProfessionalId());
             tpCourse.setCourseCode(t.getCourseCode());
             tpCourse.setCourseName(t.getCourseName());
-            tpCourse.setSortNum(i.getAndIncrement());
+            tpCourse.setSortNum(maxSortNum + i.getAndIncrement());
             tpCourse.insertInfo(sysUser.getId());
             tpCourseList.add(tpCourse);
         });
@@ -114,4 +115,18 @@ public class TPCourseServiceImpl extends ServiceImpl<TPCourseMapper, TPCourse> i
 
         return this.baseMapper.queryList(professionalId, orgIdSet);
     }
+
+    @Override
+    public int getMaxSortNum(Long professionalId) {
+        QueryWrapper<TPCourse> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(TPCourse::getProfessionalId, professionalId)
+                .orderByDesc(TPCourse::getSortNum)
+                .last("limit 1");
+        TPCourse tpCourse = this.getOne(queryWrapper);
+        if (tpCourse == null) {
+            return 0;
+        } else {
+            return tpCourse.getSortNum();
+        }
+    }
 }

+ 11 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TPMatrixServiceImpl.java

@@ -53,7 +53,7 @@ public class TPMatrixServiceImpl extends ServiceImpl<TPMatrixMapper, TPMatrix> i
 
     @Override
     public List<MatrixDto> listMatrix(Long professionalId) {
-        List<TPMatrix> tpMatrixList = this.list(new QueryWrapper<TPMatrix>().lambda().eq(TPMatrix::getProfessionalId, professionalId));
+        List<TPMatrix> tpMatrixList = this.baseMapper.listMatrix(professionalId);
         if (CollectionUtils.isNotEmpty(tpMatrixList)) {
             List<MatrixDto> matrixDtoList = new ArrayList<>();
             Map<Long, List<TPMatrix>> courseMap = tpMatrixList.stream().collect(Collectors.groupingBy(TPMatrix::getCourseId));
@@ -170,6 +170,16 @@ 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);
+                }
             }
         }
         // 修改

+ 15 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TPRequirementServiceImpl.java

@@ -56,6 +56,7 @@ public class TPRequirementServiceImpl extends ServiceImpl<TPRequirementMapper, T
         }
         // 新增
         else {
+            tpRequirement.setSortNum(this.getMaxSortNum(tpRequirement.getProfessionalId()) + 1);
             tpRequirement.insertInfo(sysUser.getId());
         }
         this.saveOrUpdate(tpRequirement);
@@ -88,4 +89,18 @@ public class TPRequirementServiceImpl extends ServiceImpl<TPRequirementMapper, T
         tpMatrixService.removeMatrixByCondition(null, null, id);
         return this.removeById(id);
     }
+
+    @Override
+    public int getMaxSortNum(Long professionalId) {
+        QueryWrapper<TPRequirement> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(TPRequirement::getProfessionalId, professionalId)
+                .orderByDesc(TPRequirement::getSortNum)
+                .last("limit 1");
+        TPRequirement requirement = this.getOne(queryWrapper);
+        if (requirement == null) {
+            return 0;
+        } else {
+            return requirement.getSortNum();
+        }
+    }
 }

+ 13 - 0
distributed-print-business/src/main/resources/mapper/TPMatrixMapper.xml

@@ -15,5 +15,18 @@
         <result column="update_id" property="updateId" />
         <result column="update_time" property="updateTime" />
     </resultMap>
+    <select id="listMatrix" resultType="com.qmth.distributed.print.business.entity.TPMatrix">
+        SELECT
+            tpm.*
+        FROM
+            t_p_matrix tpm
+                LEFT JOIN
+            t_p_course tpc ON tpm.course_id = tpc.id
+                LEFT JOIN
+            t_p_requirement tpr ON tpm.requirement_id = tpr.id
+        WHERE
+            tpm.professional_id = #{professionalId}
+        ORDER BY tpc.sort_num , tpr.sort_num
+    </select>
 
 </mapper>