From 33ac6593e7c6cb1e62ef564d87348ab58dd8282c Mon Sep 17 00:00:00 2001 From: "hechao.zhu" Date: Thu, 21 Sep 2023 20:27:54 +0800 Subject: [PATCH] =?UTF-8?q?cms=E9=A6=96=E9=A1=B5-=E7=BD=AE=E9=A1=B6?= =?UTF-8?q?=E5=9F=B9=E5=85=BB=E6=96=B9=E6=A1=88=20=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E4=B8=8E=E6=AF=95=E4=B8=9A=E8=A6=81=E6=B1=82=E5=85=B3=E7=B3=BB?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=B7=BB=E5=8A=A0=209.21?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/common/util/ComputeUtils.java | 13 +++ .../CmsHomeTrainingPlanServiceImpl.java | 82 +++++++++++-------- 2 files changed, 62 insertions(+), 33 deletions(-) diff --git a/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ComputeUtils.java b/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ComputeUtils.java index d276ae7..6ef35b4 100644 --- a/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ComputeUtils.java +++ b/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ComputeUtils.java @@ -60,4 +60,17 @@ public class ComputeUtils { BigDecimal b2 = BigDecimal.valueOf(v2); return b1.divide(b2, DEF_DIV_SCALE, BigDecimal.ROUND_HALF_UP).doubleValue(); } + + public static double div2(double v1, double v2) { + BigDecimal b1 = BigDecimal.valueOf(v1); + BigDecimal b2 = BigDecimal.valueOf(v2); + return b1.divide(b2, 2, BigDecimal.ROUND_HALF_UP).doubleValue(); + } + + public static void main(String[] args) { +// System.out.println("args = " + div(39,64)); + System.out.println("args2 = " + div2(39,64)); + + System.out.println("args = " + mul(div2(39,64),new Double(2))); + } } diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/cms/service/CmsHomeTrainingPlanServiceImpl.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/cms/service/CmsHomeTrainingPlanServiceImpl.java index e554184..5b519dd 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/cms/service/CmsHomeTrainingPlanServiceImpl.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/cms/service/CmsHomeTrainingPlanServiceImpl.java @@ -1,16 +1,14 @@ package org.jeecg.modules.cms.service; -import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import lombok.extern.slf4j.Slf4j; -import org.jeecg.modules.course.entity.SeChapter; +import org.jeecg.common.util.ComputeUtils; import org.jeecg.modules.course.entity.SeCourse; +import org.jeecg.modules.course.entity.SeCourseobjectives; import org.jeecg.modules.course.service.ISeChapterService; import org.jeecg.modules.course.service.ISeCourseService; -import org.jeecg.modules.course.service.ISeCourseobjectivesService1; -import org.jeecg.modules.course.vo.SeChapterVo; -import org.jeecg.modules.course.vo.SeCourseobjectives1; +import org.jeecg.modules.course.service.ISeCourseobjectivesService; import org.jeecg.modules.demo.knowcourse.entity.Knowcourse; import org.jeecg.modules.demo.knowcourse.service.IKnowcourseService; import org.jeecg.modules.py.entity.*; @@ -27,6 +25,7 @@ import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import java.util.*; +import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; /** @@ -65,7 +64,7 @@ public class CmsHomeTrainingPlanServiceImpl implements ICmsHomeTrainingPlanServi private ISeCourseService iSeCourseService; @Autowired - private ISeCourseobjectivesService1 seCourseobjectivesService1; + private ISeCourseobjectivesService seCourseobjectivesService; @Autowired private ISeChapterService seChapterService; @@ -235,53 +234,70 @@ public class CmsHomeTrainingPlanServiceImpl implements ICmsHomeTrainingPlanServi // 3,行与列对应的坐标值,统计每门课程与每个二级毕业要求的学分 - /** - * 邱栋: - * 学分这里是算出来的,根据学时占比,自动计算的 - * - * 邱栋: - * 课程知识点支撑课程目标,课程知识点有学时安排 - * - * 邱栋: - * 支撑某一个课程目标的知识点学时和/总学时=学时占比 - * - * 邱栋: - * 学时占比*学分,就是该课程目标占的学分,它支撑那个毕业要求,就支撑多少学分。 - */ - // 统计培养方案每门课程与每个二级毕业要求的学分 if (!ObjectUtils.isEmpty(seCourseList)) { for (SeCourse seCourse : seCourseList) { //1,该课程的课程目标 - List seCourseobjectivesList = seCourseobjectivesService1.list(new LambdaQueryWrapper() - .eq(SeCourseobjectives1::getCourseid, seCourse.getId()) - .ne(SeCourseobjectives1::getPid, "0")); + List seCourseobjectivesList = seCourseobjectivesService.list(new LambdaQueryWrapper() + .eq(SeCourseobjectives::getCourseid, seCourse.getId()) + .eq(SeCourseobjectives::getIsrelated, "1") + .ne(SeCourseobjectives::getPid, "0")); + + if (ObjectUtils.isEmpty(seCourseobjectivesList)) continue; //2,课程对应的章节 - seChapterService.list(new LambdaQueryWrapper() - .eq(SeChapter::getCourseid, seCourse.getId()) - .ne(SeChapter::getPid, "0")); +// seChapterService.list(new LambdaQueryWrapper() +// .eq(SeChapter::getCourseid, seCourse.getId()) +// .ne(SeChapter::getPid, "0")); //3,章节对应的知识点 List knowcourseList = knowcourseService.list(new LambdaQueryWrapper() - .eq(Knowcourse::getKcid, seCourse.getId())); + .eq(Knowcourse::getKcid, seCourse.getId()) + .in(Knowcourse::getKcmbid, seCourseobjectivesList.stream().map(o -> o.getId()).collect(Collectors.toSet())) + + ); + if (!ObjectUtils.isEmpty(knowcourseList)) { //课程知识点支撑的课程目标 // 【课程目标与课程知识点一对多(一个知识点只能支撑一个课程目标,多个知识点可以共同支撑一个课程目标)】 //根据课程目标分组统计知识点 - Map> mbkcFenzuMap = knowcourseList.stream().collect(Collectors.groupingBy(Knowcourse::getKcmbid)); + Map> mbkcFenzuMap = knowcourseList.stream() + .collect(Collectors.groupingBy(Knowcourse::getKcmbid)); + + //课程总学分 + AtomicReference courseTotalCredit = new AtomicReference<>(new Double(0)); if (!ObjectUtils.isEmpty(mbkcFenzuMap)) { - //TODO mbkcFenzuMap.forEach((k, v) -> { - List knowcoursegroup = v; - long count = knowcoursegroup.stream().map(e -> e.getXs()).count(); - System.out.println(k+",的学时总数--------------count = " + count); + /** + * 邱栋: + * 学分这里是算出来的,根据学时占比,自动计算的 + * + * 邱栋: + * 课程知识点支撑课程目标,课程知识点有学时安排 + * 邱栋: + * 支撑某一个课程目标的知识点学时和/总学时=学时占比 + * + * 邱栋: + * 学时占比*学分,就是该课程目标占的学分,它支撑那个毕业要求,就支撑多少学分。 + */ + + //某一课程同一课程目标的总学时(支撑某一个课程目标的知识点学时和) + Double totalXs = v.stream().map(e -> e.getXs()).reduce(Double.valueOf(0), Double::sum); + log.info("课程:" + seCourse.getName() + ",的课程目标:" + v.get(0).getKcmb() + ",的总学时数:" + totalXs); + //某一课程同一课程目标的总学时占比 + Double kcXueshiBilue = ComputeUtils.div2(totalXs, new Double(seCourse.getClasshours())); + log.info("课程:" + seCourse.getName() + ",的课程目标:" + v.get(0).getKcmb() + ",的学时占比数:" + kcXueshiBilue); + //某一课程同一课程目标的总学时占比学分 + double kcXuefen = ComputeUtils.mul(kcXueshiBilue, seCourse.getCredit().doubleValue()); + courseTotalCredit.updateAndGet(v1 -> v1 + kcXuefen); + log.info("课程:" + seCourse.getName() + ",的课程目标:" + v.get(0).getKcmb() + ",的学分数:" + kcXuefen); }); + log.info("课程:" + seCourse.getName() + ",总学分数:" + courseTotalCredit.get().intValue()); } + //TODO } - } }