yangdamao 2 سال پیش
والد
کامیت
fcb22252c7

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/domain/CourseFile.java

@@ -47,4 +47,9 @@ private static final long serialVersionUID=1L;
     private Long parentId;
     /** 类型:1文件 2文件夹 */
     private Integer type;
+
+    private Long tenantId;
+
+    @TableField(exist = false)
+    private Long oldId;
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/mapper/CourseFileMapper.java

@@ -1,7 +1,9 @@
 package com.zhongzheng.modules.course.mapper;
 
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.zhongzheng.modules.course.domain.CourseFile;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 文件Mapper接口
@@ -11,4 +13,6 @@ import com.zhongzheng.modules.course.domain.CourseFile;
  */
 public interface CourseFileMapper extends BaseMapper<CourseFile> {
 
+    @InterceptorIgnore(tenantLine = "true")
+    void deleteByTenant(@Param("handoutsId") Long handoutsId,@Param("newTenantId") Long newTenantId);
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/ICourseFileService.java

@@ -51,4 +51,6 @@ public interface ICourseFileService extends IService<CourseFile> {
 	boolean editHandouts(CourseHandoutsEditBo bo);
 
     boolean addHandouts(CourseHandoutsAddBo bo);
+
+    void deleteByTenant(Long newId, Long newTenantId);
 }

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseFileServiceImpl.java

@@ -163,4 +163,9 @@ public class CourseFileServiceImpl extends ServiceImpl<CourseFileMapper, CourseF
         return true;
     }
 
+    @Override
+    public void deleteByTenant(Long handoutsId, Long newTenantId) {
+        baseMapper.deleteByTenant(handoutsId, newTenantId);
+    }
+
 }

+ 42 - 4
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsServiceImpl.java

@@ -157,6 +157,8 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
     private ICourseHandoutsService iCourseHandoutsService;
     @Autowired
     private ICourseHandoutsBusinessService iCourseHandoutsBusinessService;
+    @Autowired
+    private ICourseFileService iCourseFileService;
 
     @Autowired
     private ICourseEducationTierService iCourseEducationTierService;
@@ -1518,10 +1520,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
                     if (ObjectUtil.isNotNull(courseHandouts)){
                         Long oid = courseHandouts.getHandoutsId();
                         Long newId = getNewIdByTenant(oid, GoodsCopyEnum.COURSE_HANDOUTS.getType(),newTenantId);
-//                    CourseHandouts newCourseHandouts = iCourseHandoutsService.getHandoutsByTenant(courseHandouts.getEncoder(),newTenantId);
-                        if (ObjectUtil.isNotNull(newId)){
-                            goods.setHandoutsId(newId);
-                        }else {
+                        if (ObjectUtil.isNull(newId)){
                             //讲义业务层次
                             List<CourseHandoutsBusiness> handoutsBusinessList = iCourseHandoutsBusinessService
                                     .list(new LambdaQueryWrapper<CourseHandoutsBusiness>()
@@ -1529,6 +1528,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
                             courseHandouts.setHandoutsId(null);
                             courseHandouts.setTenantId(newTenantId);
                             iCourseHandoutsService.save(courseHandouts);
+                            newId = courseHandouts.getHandoutsId();
                             addSysGoodsRecord(oid,courseHandouts.getHandoutsId(),GoodsCopyEnum.COURSE_HANDOUTS.getType(),newTenantId,recordList);
                             goods.setHandoutsId(courseHandouts.getHandoutsId());
                             if (CollectionUtils.isNotEmpty(handoutsBusinessList)){
@@ -1548,6 +1548,14 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
                                 iCourseHandoutsBusinessService.saveBatch(collect);
                             }
                         }
+                        goods.setHandoutsId(newId);
+                        //讲义文件
+                        iCourseFileService.deleteByTenant(newId,newTenantId);
+                        List<CourseFile> courseFileList = iCourseFileService.list(new LambdaQueryWrapper<CourseFile>().eq(CourseFile::getHandoutsId, oid).eq(CourseFile::getStatus, 1));
+                        if (CollectionUtils.isNotEmpty(courseFileList)){
+                            //重新添加讲义文件
+                            handleCourseFile(courseFileList,newId,newTenantId);
+                        }
                     }
                 }
 
@@ -1751,6 +1759,36 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
         return true;
     }
 
+    private void handleCourseFile(List<CourseFile> courseFileList, Long newId, Long newTenantId) {
+        //父级
+        List<CourseFile> collect = courseFileList.stream().filter(x -> ObjectUtils.isNull(x.getParentId()) || x.getParentId() == 0).collect(Collectors.toList());
+        List<CourseFile> collect1 = courseFileList.stream().filter(x -> ObjectUtils.isNotNull(x.getParentId()) && x.getParentId() != 0).collect(Collectors.toList());
+        for (CourseFile item : collect) {
+            item.setOldId(item.getFileId());
+            item.setFileId(null);
+            item.setHandoutsId(newId);
+            item.setTenantId(newTenantId);
+            iCourseFileService.save(item);
+            recursionHandle(item,collect1,newId,newTenantId);
+        }
+
+    }
+
+    private void recursionHandle(CourseFile file, List<CourseFile> courseFiles, Long newId, Long newTenantId) {
+        List<CourseFile> collect = courseFiles.stream().filter(x -> x.getParentId().equals(file.getOldId())).collect(Collectors.toList());
+        if (CollectionUtils.isNotEmpty(collect)){
+            for (CourseFile courseFile : collect) {
+                courseFile.setOldId(courseFile.getFileId());
+                courseFile.setFileId(null);
+                courseFile.setHandoutsId(newId);
+                courseFile.setTenantId(newTenantId);
+                courseFile.setParentId(file.getFileId());
+                iCourseFileService.save(courseFile);
+                recursionHandle(courseFile,courseFiles,newId,newTenantId);
+            }
+        }
+    }
+
     public boolean goodsCopyOne(GoodsBatchCopyTenantBo bo){
 
         log.info("一建商品复制开始:"+ DateUtils.getTime());

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserSubscribeServiceImpl.java

@@ -2373,7 +2373,7 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
         this.save(add);
 
         //发送预约考试消息
-//        sendExamSucceed(bo);
+        sendExamSucceed(userSubscribeAddBo);
     }
 
 

+ 3 - 0
zhongzheng-system/src/main/resources/mapper/modules/course/CourseFileMapper.xml

@@ -16,5 +16,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="sort" column="sort"/>
     </resultMap>
 
+    <delete id="deleteByTenant" parameterType="map">
+        DELETE FROM course_file WHERE handouts_id = #{handoutsId} AND tenant_id = #{newTenantId}
+    </delete>
 
 </mapper>