瀏覽代碼

3.3.2 update

xiaofei 1 年之前
父節點
當前提交
f119b3b6ac

+ 15 - 66
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TPMatrix.java

@@ -1,12 +1,12 @@
 package com.qmth.distributed.print.business.entity;
 
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import java.io.Serializable;
+import com.qmth.teachcloud.common.base.BaseEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
+import java.io.Serializable;
+
 /**
  * <p>
  * 专业认证毕业要求支撑矩阵
@@ -16,14 +16,11 @@ import io.swagger.annotations.ApiModelProperty;
  * @since 2024-04-22
  */
 @TableName("t_p_matrix")
-@ApiModel(value="TPMatrix对象", description="专业认证毕业要求支撑矩阵")
-public class TPMatrix implements Serializable {
+@ApiModel(value = "TPMatrix对象", description = "专业认证毕业要求支撑矩阵")
+public class TPMatrix extends BaseEntity implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    @TableId(value = "id", type = IdType.INPUT)
-    private Long id;
-
     @ApiModelProperty(value = "专业ID")
     private Long professionalId;
 
@@ -39,25 +36,6 @@ public class TPMatrix implements Serializable {
     @ApiModelProperty(value = "指标值")
     private Double content;
 
-    @ApiModelProperty(value = "创建人ID")
-    private Long createId;
-
-    @ApiModelProperty(value = "创建时间")
-    private Long createTime;
-
-    @ApiModelProperty(value = "更新人ID")
-    private Long updateId;
-
-    @ApiModelProperty(value = "更新时间")
-    private Long updateTime;
-
-    public Long getId() {
-        return id;
-    }
-
-    public void setId(Long id) {
-        this.id = id;
-    }
     public Long getProfessionalId() {
         return professionalId;
     }
@@ -65,6 +43,7 @@ public class TPMatrix implements Serializable {
     public void setProfessionalId(Long professionalId) {
         this.professionalId = professionalId;
     }
+
     public Long getCourseId() {
         return courseId;
     }
@@ -72,6 +51,7 @@ public class TPMatrix implements Serializable {
     public void setCourseId(Long courseId) {
         this.courseId = courseId;
     }
+
     public Long getRequirementId() {
         return requirementId;
     }
@@ -79,6 +59,7 @@ public class TPMatrix implements Serializable {
     public void setRequirementId(Long requirementId) {
         this.requirementId = requirementId;
     }
+
     public String getSubName() {
         return subName;
     }
@@ -86,6 +67,7 @@ public class TPMatrix implements Serializable {
     public void setSubName(String subName) {
         this.subName = subName;
     }
+
     public Double getContent() {
         return content;
     }
@@ -93,48 +75,15 @@ public class TPMatrix implements Serializable {
     public void setContent(Double content) {
         this.content = content;
     }
-    public Long getCreateId() {
-        return createId;
-    }
-
-    public void setCreateId(Long createId) {
-        this.createId = createId;
-    }
-    public Long getCreateTime() {
-        return createTime;
-    }
-
-    public void setCreateTime(Long createTime) {
-        this.createTime = createTime;
-    }
-    public Long getUpdateId() {
-        return updateId;
-    }
-
-    public void setUpdateId(Long updateId) {
-        this.updateId = updateId;
-    }
-    public Long getUpdateTime() {
-        return updateTime;
-    }
-
-    public void setUpdateTime(Long updateTime) {
-        this.updateTime = updateTime;
-    }
 
     @Override
     public String toString() {
         return "TPMatrix{" +
-            "id=" + id +
-            ", professionalId=" + professionalId +
-            ", courseId=" + courseId +
-            ", requirementId=" + requirementId +
-            ", subName=" + subName +
-            ", content=" + content +
-            ", createId=" + createId +
-            ", createTime=" + createTime +
-            ", updateId=" + updateId +
-            ", updateTime=" + updateTime +
-        "}";
+                ", professionalId=" + professionalId +
+                ", courseId=" + courseId +
+                ", requirementId=" + requirementId +
+                ", subName=" + subName +
+                ", content=" + content +
+                "}";
     }
 }

+ 6 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TPMatrixService.java

@@ -1,8 +1,10 @@
 package com.qmth.distributed.print.business.service;
 
 import com.qmth.distributed.print.business.bean.dto.professional.MatrixDto;
+import com.qmth.distributed.print.business.entity.TPCourse;
 import com.qmth.distributed.print.business.entity.TPMatrix;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.distributed.print.business.entity.TPRequirement;
 
 import javax.servlet.http.HttpServletResponse;
 import java.util.List;
@@ -22,4 +24,8 @@ public interface TPMatrixService extends IService<TPMatrix> {
     boolean saveMatrix(Long id, Double content);
 
     void downloadMatrix(Long professionalId, HttpServletResponse response);
+
+    List<TPMatrix> listMatrixByCondition(Long professionalId, Long courseId, Long requirementId);
+
+    void updateMatrixForNodeCount(TPCourse tpCourse, TPRequirement tpRequirement);
 }

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

@@ -5,11 +5,14 @@ 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.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.entity.SysUser;
 import com.qmth.teachcloud.common.util.ServletUtil;
+import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -29,6 +32,11 @@ import java.util.concurrent.atomic.AtomicInteger;
 @Service
 public class TPCourseServiceImpl extends ServiceImpl<TPCourseMapper, TPCourse> implements TPCourseService {
 
+    @Resource
+    private TPRequirementService tpRequirementService;
+    @Resource
+    private TPMatrixService tpMatrixService;
+
     @Override
     public List<TPCourse> listCourse(Long professionalId) {
         QueryWrapper<TPCourse> queryWrapper = new QueryWrapper<>();
@@ -37,6 +45,7 @@ public class TPCourseServiceImpl extends ServiceImpl<TPCourseMapper, TPCourse> i
         return this.list(queryWrapper);
     }
 
+    @Transactional
     @Override
     public boolean saveCourse(TPCourseParam tpCourseParam) {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
@@ -51,7 +60,19 @@ public class TPCourseServiceImpl extends ServiceImpl<TPCourseMapper, TPCourse> i
             tpCourse.insertInfo(sysUser.getId());
             tpCourseList.add(tpCourse);
         });
-        return this.saveBatch(tpCourseList);
+
+        List<TPRequirement> tpRequirementList = tpRequirementService.listRequirement(tpCourseParam.getProfessionalId());
+        if (CollectionUtils.isNotEmpty(tpRequirementList)) {
+            // 增加矩阵数据
+            for (TPCourse tpCourse : tpCourseList) {
+                for (TPRequirement tpRequirement : tpRequirementList) {
+                    tpMatrixService.updateMatrixForNodeCount(tpCourse, tpRequirement);
+                }
+            }
+        }
+
+        this.saveBatch(tpCourseList);
+        return true;
     }
 
     @Transactional

+ 82 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TPMatrixServiceImpl.java

@@ -1,5 +1,6 @@
 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.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -19,6 +20,8 @@ import com.qmth.distributed.print.business.service.TPMatrixService;
 import com.qmth.distributed.print.business.service.TPProfessionalService;
 import com.qmth.distributed.print.business.service.TPRequirementService;
 import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.common.entity.SysUser;
+import com.qmth.teachcloud.common.util.ServletUtil;
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.stereotype.Service;
 
@@ -136,4 +139,83 @@ public class TPMatrixServiceImpl extends ServiceImpl<TPMatrixMapper, TPMatrix> i
             }
         }
     }
+
+    @Override
+    public List<TPMatrix> listMatrixByCondition(Long professionalId, Long courseId, Long requirementId) {
+        QueryWrapper<TPMatrix> queryWrapper = new QueryWrapper<>();
+        LambdaQueryWrapper<TPMatrix> lambda = queryWrapper.lambda();
+        lambda.eq(TPMatrix::getProfessionalId, professionalId);
+        if (courseId != null) {
+            lambda.eq(TPMatrix::getCourseId, courseId);
+        }
+        if (requirementId != null) {
+            lambda.eq(TPMatrix::getRequirementId, requirementId);
+        }
+        return this.list(queryWrapper);
+    }
+
+    @Override
+    public void updateMatrixForNodeCount(TPCourse tpCourse, TPRequirement tpRequirement) {
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        List<TPMatrix> matrixList = this.listMatrixByCondition(tpRequirement.getProfessionalId(), tpCourse.getId(), tpRequirement.getId());
+        List<TPMatrix> tpMatrixAddList = new ArrayList<>();
+        List<Long> tpMatrixRemoveList = new ArrayList<>();
+        // 新增
+        if (CollectionUtils.isEmpty(matrixList)) {
+            if (tpRequirement.getNodeCount() == null) {
+                TPMatrix tpMatrix = new TPMatrix();
+                tpMatrix.insertInfo(sysUser.getId());
+                tpMatrix.setProfessionalId(tpRequirement.getProfessionalId());
+                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);
+                }
+            }
+        }
+        // 修改
+        else {
+            if (tpRequirement.getNodeCount() == null) {
+                for (int i = 0; i < matrixList.size(); i++) {
+                    tpMatrixRemoveList.add(matrixList.get(i).getId());
+                }
+                TPMatrix tpMatrix = new TPMatrix();
+                tpMatrix.insertInfo(sysUser.getId());
+                tpMatrix.setProfessionalId(tpRequirement.getProfessionalId());
+                tpMatrix.setCourseId(tpCourse.getId());
+                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);
+                    }
+                } else if (tpRequirement.getNodeCount() < matrixList.size()) {
+                    for (int i = tpRequirement.getNodeCount(); i <= matrixList.size() - 1; i++) {
+                        tpMatrixRemoveList.add(matrixList.get(i).getId());
+                    }
+                }
+            }
+        }
+        if (CollectionUtils.isNotEmpty(tpMatrixAddList)) {
+            this.saveOrUpdateBatch(tpMatrixAddList);
+        }
+        if (CollectionUtils.isNotEmpty(tpMatrixRemoveList)) {
+            this.removeByIds(tpMatrixRemoveList);
+        }
+    }
 }

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

@@ -3,15 +3,23 @@ package com.qmth.distributed.print.business.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.qmth.distributed.print.business.bean.dto.professional.MatrixDto;
 import com.qmth.distributed.print.business.entity.TPCourse;
+import com.qmth.distributed.print.business.entity.TPMatrix;
 import com.qmth.distributed.print.business.entity.TPRequirement;
 import com.qmth.distributed.print.business.mapper.TPRequirementMapper;
+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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.util.ServletUtil;
+import org.activiti.bpmn.converter.export.CollaborationExport;
+import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.Resource;
 import java.util.List;
 
 /**
@@ -25,6 +33,11 @@ import java.util.List;
 @Service
 public class TPRequirementServiceImpl extends ServiceImpl<TPRequirementMapper, TPRequirement> implements TPRequirementService {
 
+    @Resource
+    private TPCourseService tpCourseService;
+    @Resource
+    private TPMatrixService tpMatrixService;
+
     @Override
     public List<TPRequirement> listRequirement(Long professionalId) {
         QueryWrapper<TPRequirement> queryWrapper = new QueryWrapper<>();
@@ -33,11 +46,12 @@ public class TPRequirementServiceImpl extends ServiceImpl<TPRequirementMapper, T
         return this.list();
     }
 
+    @Transactional
     @Override
     public boolean saveRequirement(TPRequirement tpRequirement) {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         // 修改
-        if(tpRequirement.getId() != null){
+        if (tpRequirement.getId() != null) {
             tpRequirement.updateInfo(sysUser.getId());
         }
         // 新增
@@ -45,6 +59,12 @@ public class TPRequirementServiceImpl extends ServiceImpl<TPRequirementMapper, T
             tpRequirement.insertInfo(sysUser.getId());
         }
         // todo 节点数变动后,修改矩阵数据
+        List<TPCourse> tpCourseList = tpCourseService.listCourse(tpRequirement.getProfessionalId());
+        if (CollectionUtils.isNotEmpty(tpCourseList)) {
+            for (TPCourse tpCourse : tpCourseList) {
+                tpMatrixService.updateMatrixForNodeCount(tpCourse, tpRequirement);
+            }
+        }
         this.saveOrUpdate(tpRequirement);
         return true;
     }