yangdamao 1 week ago
parent
commit
18e102310a

+ 10 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseServiceImpl.java

@@ -27,6 +27,8 @@ import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.common.utils.ToolsUtils;
 import com.zhongzheng.common.utils.ToolsUtils;
 import com.zhongzheng.common.utils.http.HttpUtils;
 import com.zhongzheng.common.utils.http.HttpUtils;
+import com.zhongzheng.modules.activity.domain.ArtisanData;
+import com.zhongzheng.modules.activity.service.IArtisanDataService;
 import com.zhongzheng.modules.base.domain.UserProfile;
 import com.zhongzheng.modules.base.domain.UserProfile;
 import com.zhongzheng.modules.base.service.IUserProfileService;
 import com.zhongzheng.modules.base.service.IUserProfileService;
 import com.zhongzheng.modules.course.bo.*;
 import com.zhongzheng.modules.course.bo.*;
@@ -196,6 +198,8 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
     private ICourseSectionService iCourseSectionService;
     private ICourseSectionService iCourseSectionService;
     @Autowired
     @Autowired
     private ICourseSectionBusinessService iCourseSectionBusinessService;
     private ICourseSectionBusinessService iCourseSectionBusinessService;
+    @Autowired
+    private IArtisanDataService iArtisanDataService;
 
 
 
 
     @Override
     @Override
@@ -796,6 +800,12 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
             if(Validator.isEmpty(classGradeVo)){
             if(Validator.isEmpty(classGradeVo)){
                 continue;
                 continue;
             }
             }
+
+            if (ObjectUtils.isNotNull(goodsUserVo.getArtisanDataId())){
+                ArtisanData artisanData = iArtisanDataService.getById(goodsUserVo.getArtisanDataId());
+                goodsUserVo.setDataStr(artisanData.getDataStr());
+            }
+
             String fullName = goodsUserVo.getEducationName()+goodsUserVo.getBusinessName()+goodsUserVo.getProjectName();
             String fullName = goodsUserVo.getEducationName()+goodsUserVo.getBusinessName()+goodsUserVo.getProjectName();
             goodsUserVo.setErJianErZao(false);
             goodsUserVo.setErJianErZao(false);
             goodsUserVo.setUserProfile(0);
             goodsUserVo.setUserProfile(0);

+ 98 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsServiceImpl.java

@@ -84,8 +84,10 @@ import com.zhongzheng.modules.user.bo.UserPhoneBo;
 import com.zhongzheng.modules.user.bo.UserStudyRecordAddBo;
 import com.zhongzheng.modules.user.bo.UserStudyRecordAddBo;
 import com.zhongzheng.modules.user.domain.School;
 import com.zhongzheng.modules.user.domain.School;
 import com.zhongzheng.modules.user.domain.User;
 import com.zhongzheng.modules.user.domain.User;
+import com.zhongzheng.modules.user.domain.UserExamRecord;
 import com.zhongzheng.modules.user.domain.UserStudyRecord;
 import com.zhongzheng.modules.user.domain.UserStudyRecord;
 import com.zhongzheng.modules.user.service.ISchoolService;
 import com.zhongzheng.modules.user.service.ISchoolService;
+import com.zhongzheng.modules.user.service.IUserExamRecordService;
 import com.zhongzheng.modules.user.service.IUserService;
 import com.zhongzheng.modules.user.service.IUserService;
 import com.zhongzheng.modules.user.service.IUserStudyRecordService;
 import com.zhongzheng.modules.user.service.IUserStudyRecordService;
 import com.zhongzheng.modules.user.vo.SubjectStudyRecordVo;
 import com.zhongzheng.modules.user.vo.SubjectStudyRecordVo;
@@ -109,6 +111,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.regex.Pattern;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
+import java.util.stream.IntStream;
 
 
 import static java.math.RoundingMode.HALF_UP;
 import static java.math.RoundingMode.HALF_UP;
 
 
@@ -233,6 +236,8 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
     private ICertificateTpService iCertificateTpService;
     private ICertificateTpService iCertificateTpService;
     @Autowired
     @Autowired
     private IUserService iUserService;
     private IUserService iUserService;
+    @Autowired
+    private IUserExamRecordService iUserExamRecordService;
 
 
     @Autowired
     @Autowired
     private IUserStudyRecordService iUserStudyRecordService;
     private IUserStudyRecordService iUserStudyRecordService;
@@ -5783,16 +5788,107 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
     }
     }
 
 
     @Override
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public boolean disposeQuestion(Long goodsId) {
     public boolean disposeQuestion(Long goodsId) {
         Goods goods = getById(goodsId);
         Goods goods = getById(goodsId);
         if (Objects.isNull(goods)) {
         if (Objects.isNull(goods)) {
             throw new CustomException("商品ID有误");
             throw new CustomException("商品ID有误");
         }
         }
-        
+        if (goods.getGoodsType() != 2){
+            throw new CustomException("不是题库商品");
+        }
+        //获取所有试卷
+        List<GoodsAttached> list = iGoodsAttachedService.list(new LambdaQueryWrapper<GoodsAttached>().eq(GoodsAttached::getGoodsId, goods.getGoodsId()).eq(GoodsAttached::getType, 1));
+        //模块卷
+        if (CollectionUtils.isEmpty(list)){
+            return false;
+        }
+        for (GoodsAttached goodsAttached : list) {
+            List<QuestionModuleChapter> chapterList = iQuestionModuleChapterService.list(new LambdaQueryWrapper<QuestionModuleChapter>().eq(QuestionModuleChapter::getModuleExamId, goodsAttached.getMajorId()));
+            if (CollectionUtils.isEmpty(chapterList)){
+                continue;
+            }
+            List<Long> chapterIds = chapterList.stream().map(QuestionModuleChapter::getChapterExamId).collect(Collectors.toList());
+            List<QuestionChapterExam> chapterExams = iQuestionChapterExamService.list(new LambdaQueryWrapper<QuestionChapterExam>().in(QuestionChapterExam::getChapterExamId, chapterIds));
+            if (CollectionUtils.isEmpty(chapterExams)){
+                continue;
+            }
+            for (QuestionChapterExam chapterExam : chapterExams) {
+                List<ExamQuestion> examQuestions = iExamQuestionService.list(new LambdaQueryWrapper<ExamQuestion>().eq(ExamQuestion::getExamId, chapterExam.getExamId()));
+                if (CollectionUtils.isEmpty(examQuestions)){
+                    continue;
+                }
+                //获取所有题目id
+                List<Long> questionIds = examQuestions.stream().map(ExamQuestion::getQuestionId).collect(Collectors.toList());
+                //根据数量分割 100题为一组
+                int total = questionIds.size();
+                List<List<Long>> colquestionList = IntStream.range(0, (total + 100 - 1) / 100)
+                        .mapToObj(i -> questionIds.subList(
+                                i * 100,
+                                Math.min((i + 1) * 100, total)
+                        ))
+                        .collect(Collectors.toList());
+                Exam exam = iExamService.getById(chapterExam.getExamId());
+                List<QuestionBusiness> businesses = iQuestionBusinessService.list(new LambdaQueryWrapper<QuestionBusiness>()
+                        .eq(QuestionBusiness::getMajorId, exam.getExamId()).eq(QuestionBusiness::getType, 2));
+                //重新组装数据
+                for (int i = 0; i < colquestionList.size(); i++) {
+
+                    Exam bean = BeanUtil.toBean(exam, Exam.class);
+                    bean.setExamId(null);
+                    bean.setCode(ServletUtils.getEncoded("SJ"));
+                    bean.setExamName(String.format("%s(%s)",bean.getExamName(),i+1));
+                    iExamService.save(bean);
+
+                    List<QuestionBusiness> questionBusinesses = businesses.stream().map(y -> {
+                        y.setMajorId(bean.getExamId());
+                        y.setId(null);
+                        return y;
+                    }).collect(Collectors.toList());
+                    iQuestionBusinessService.saveBatch(questionBusinesses);
+
+                    List<Long> idList = colquestionList.get(i);
+                    List<ExamQuestion> examQuestionList = IntStream.range(0, idList.size())
+                            .mapToObj(index -> {
+                                Long questionId = idList.get(index);
+                                ExamQuestion examQuestion = new ExamQuestion();
+                                examQuestion.setExamId(bean.getExamId());
+                                examQuestion.setSort(index + 1);
+                                examQuestion.setQuestionId(questionId);
+                                examQuestion.setScore(BigDecimal.ZERO);
+                                examQuestion.setPartScore(BigDecimal.ZERO);
+                                return examQuestion;
+                            }).collect(Collectors.toList());
+                    iExamQuestionService.saveBatch(examQuestionList);
+
+                    //试卷章
+                    QuestionChapterExam questionChapterExam = new QuestionChapterExam();
+                    questionChapterExam.setChapterExamId(chapterExam.getChapterExamId());
+                    questionChapterExam.setExamId(bean.getExamId());
+                    questionChapterExam.setSort(i+1L);
+                    iQuestionChapterExamService.save(questionChapterExam);
+                }
+
+                //清除记录
+                List<UserExamRecord> records = iUserExamRecordService.list(new LambdaQueryWrapper<UserExamRecord>().eq(UserExamRecord::getExamId, exam.getExamId()));
+                if (CollectionUtils.isNotEmpty(records)){
+                    iUserExamRecordService.removeByIds(records.stream().map(UserExamRecord::getRecordId).collect(Collectors.toList()));
+                }
+
+                //删除之前的试卷
+                iExamService.removeById(exam.getExamId());
 
 
-        return false;
+                //删除之前试卷和题的关联关系
+                iExamQuestionService.removeByIds(examQuestions.stream().map(ExamQuestion::getId).collect(Collectors.toList()));
+
+            }
+            //删除之前试卷和章的关联关系
+            iQuestionChapterExamService.removeByIds(chapterExams.stream().map(QuestionChapterExam::getId).collect(Collectors.toList()));
+        }
+        return true;
     }
     }
 
 
+
     private void updateHandoutsId(Long goodsId, Long tenantId, Long handoutsId) {
     private void updateHandoutsId(Long goodsId, Long tenantId, Long handoutsId) {
         baseMapper.updateHandoutsId(goodsId, tenantId, handoutsId);
         baseMapper.updateHandoutsId(goodsId, tenantId, handoutsId);
     }
     }

+ 6 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/vo/GoodsUserVo.java

@@ -466,4 +466,10 @@ public class GoodsUserVo {
 
 
 	@ApiModelProperty("审核通过时间")
 	@ApiModelProperty("审核通过时间")
 	private Long periodTime;
 	private Long periodTime;
+
+	@ApiModelProperty("填写资料")
+	private String dataStr;
+
+	@ApiModelProperty("申报资料ID")
+	private Long artisanDataId;
 }
 }

+ 2 - 0
zhongzheng-system/src/main/resources/mapper/modules/course/CourseMapper.xml

@@ -206,6 +206,7 @@
         <result property="sevenYear" column="seven_year"/>
         <result property="sevenYear" column="seven_year"/>
         <result property="orderYear" column="order_year"/>
         <result property="orderYear" column="order_year"/>
         <result property="ogCreateTime" column="og_create_time"/>
         <result property="ogCreateTime" column="og_create_time"/>
+        <result property="artisanDataId" column="artisan_data_id"/>
 
 
         <result property="subExamStatus" column="sub_exam_status"/>
         <result property="subExamStatus" column="sub_exam_status"/>
         <result property="subPerformance" column="sub_performance"/>
         <result property="subPerformance" column="sub_performance"/>
@@ -548,6 +549,7 @@
         g.*,
         g.*,
         o.user_id,
         o.user_id,
         og.study_count as order_study_count,
         og.study_count as order_study_count,
+        og.artisan_data_id,
         og.order_goods_id,
         og.order_goods_id,
         og.grade_id,
         og.grade_id,
         og.service_start_time,
         og.service_start_time,