yangdamao 2 жил өмнө
parent
commit
c2abe5a734

+ 117 - 98
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/ClassGradeServiceImpl.java

@@ -6,9 +6,12 @@ import cn.hutool.core.lang.Validator;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.Page;
 import com.zhongzheng.common.annotation.DataScope;
 import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
@@ -20,7 +23,9 @@ import com.zhongzheng.modules.base.bo.ConsoleQueryBo;
 import com.zhongzheng.modules.course.bo.CourseBusinessQueryBo;
 import com.zhongzheng.modules.course.bo.CourseEducationTypeQueryBo;
 import com.zhongzheng.modules.course.bo.CourseProjectTypeQueryBo;
-import com.zhongzheng.modules.course.domain.*;
+import com.zhongzheng.modules.course.domain.CourseBusiness;
+import com.zhongzheng.modules.course.domain.CourseEducationType;
+import com.zhongzheng.modules.course.domain.CourseSubject;
 import com.zhongzheng.modules.course.service.*;
 import com.zhongzheng.modules.course.vo.*;
 import com.zhongzheng.modules.goods.domain.Goods;
@@ -28,6 +33,7 @@ import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
 import com.zhongzheng.modules.grade.bo.*;
 import com.zhongzheng.modules.grade.domain.*;
+import com.zhongzheng.modules.grade.mapper.ClassGradeMapper;
 import com.zhongzheng.modules.grade.service.*;
 import com.zhongzheng.modules.grade.vo.*;
 import com.zhongzheng.modules.inform.bo.InformUserAddBo;
@@ -58,18 +64,12 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.github.pagehelper.Page;
-import com.zhongzheng.modules.grade.mapper.ClassGradeMapper;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;
-import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 
 /**
@@ -149,6 +149,9 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
     @Autowired
     private ISysOldOrgService iSysOldOrgService;
 
+    @Autowired
+    private ISysOldOrgService sysOldOrgService;
+
     @Autowired
     private com.zhongzheng.modules.alisms.service.IAliSmsService IAliSmsService;
 
@@ -233,9 +236,14 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
         if (CollectionUtils.isNotEmpty(list)) {
             throw new RuntimeException("班级名称不能重复");
         }
+        //企业ID
+        String tenant = ServletUtils.getRequest().getHeader("TenantId");
+        SysOldOrg org = sysOldOrgService.list(new LambdaQueryWrapper<SysOldOrg>()
+                .eq(SysOldOrg::getTenantId, tenant)
+                .last("limit 1")).stream().findFirst().orElse(null);
         //校验是否二建/二造商品创建班级
         if (bo.getClassGradeGoodsAddBos() != null &&
-                (ObjectUtils.isNull(bo.getClassStatus()) || 1 == bo.getClassStatus())) {
+                (ObjectUtils.isNull(bo.getClassStatus()) || 1 == bo.getClassStatus()) && org.getShareClass() == 1) {
             Long goodsId = bo.getClassGradeGoodsAddBos()[0];
             Goods goods = iGoodsService.getById(goodsId);
             CourseBusinessQueryBo businessQueryBo = new CourseBusinessQueryBo();
@@ -248,7 +256,7 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
 
         //是否创建官方班级编号
         if (bo.getClassGradeGoodsAddBos() != null &&
-                (ObjectUtils.isNull(bo.getClassStatus()) || 0 == bo.getClassStatus())) {
+                (ObjectUtils.isNull(bo.getClassStatus()) || 0 == bo.getClassStatus()) && org.getShareClass() == 1) {
             Long goodsId = bo.getClassGradeGoodsAddBos()[0];
             Goods goods = iGoodsService.getById(goodsId);
             CourseBusiness business = iCourseBusinessService.getById(goods.getBusinessId());
@@ -259,17 +267,17 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
                 List<Goods> goodsList = iGoodsService.list(new LambdaQueryWrapper<Goods>()
                         .eq(Goods::getEducationTypeId, goods.getEducationTypeId())
                         .eq(Goods::getBusinessId, goods.getBusinessId())
-                        .eq(Goods::getStatus,1)
-                        .eq(Goods::getGoodsStatus,1)
+                        .eq(Goods::getStatus, 1)
+                        .eq(Goods::getGoodsStatus, 1)
                         .eq(Goods::getProjectId, goods.getProjectId())
                         .eq(Goods::getSubjectIds, goods.getSubjectIds()));
-                if (goodsList.size() > 1){
+                if (goodsList.size() > 1) {
                     //该业务层次下有多个商品
                     List<Long> goodsIds = goodsList.stream().filter(item -> !item.getGoodsId().equals(goodsId)).map(Goods::getGoodsId).collect(Collectors.toList());
                     List<ClassGradeGoods> goodsGradeList = iClassGradeGoodsService
                             .list(new LambdaQueryWrapper<ClassGradeGoods>()
                                     .in(ClassGradeGoods::getGoodsId, goodsIds));
-                    if (CollectionUtils.isNotEmpty(goodsGradeList)){
+                    if (CollectionUtils.isNotEmpty(goodsGradeList)) {
                         Map<Long, List<ClassGradeGoods>> map = goodsGradeList.stream().collect(Collectors.groupingBy(ClassGradeGoods::getGoodsId));
                         List<ClassGradeSortBo> sortList = new ArrayList<>();
                         map.forEach((k, v) -> {
@@ -286,10 +294,10 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
                         List<ClassGradeGoods> gradeGoods = iClassGradeGoodsService.getGradeGoodsList(goods.getGoodsId());
                         if (gradeGoods.size() < listGrade.size()) {
                             ClassGrade grade = list.get(gradeGoods.size());
-                            if (checkEjjjPeopleNumLimit(business.getId(),grade.getGradeId())){
+                            if (checkEjjjPeopleNumLimit(business.getId(), grade.getGradeId())) {
                                 add.setOfficialName(list.get(gradeGoods.size()).getOfficialName());
                                 add.setClassStatus(0);
-                            }else {
+                            } else {
                                 add.setOfficialName(ServletUtils.getEncoded("PIY"));
                                 add.setClassStatus(0);
                             }
@@ -297,7 +305,7 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
                     }
                 }
 
-                if (StringUtils.isBlank(add.getOfficialName())){
+                if (StringUtils.isBlank(add.getOfficialName())) {
                     List<CourseSubject> courseSubjectList = iCourseSubjectService.listByIds(Arrays.asList(goods.getSubjectIds().split(",")));
                     List<String> subNames = courseSubjectList.stream().map(CourseSubject::getSubjectName).collect(Collectors.toList());
                     List<Long> subIds = iCourseSubjectService.getIdsByTenant(subNames);
@@ -306,15 +314,15 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
                     bgListBo.setAliasName(business.getAliasName());
                     bgListBo.setSubIds(subIds);
                     List<ClassGrade> classGrades = baseMapper.getGradeListByTenant(bgListBo);
-                    if (CollectionUtils.isEmpty(classGrades)){
+                    if (CollectionUtils.isEmpty(classGrades)) {
                         //生成预报名官方编号
                         add.setOfficialName(ServletUtils.getEncoded("PIY"));
                         add.setClassStatus(0);
-                    }else {
+                    } else {
                         //获取班级创建最多的机构
                         Map<Long, List<ClassGrade>> map = classGrades.stream().collect(Collectors.groupingBy(ClassGrade::getTenantId));
                         List<ClassGradeSortBo> sortList = new ArrayList<>();
-                        map.forEach((k,v) -> {
+                        map.forEach((k, v) -> {
                             ClassGradeSortBo sortBo = new ClassGradeSortBo();
                             sortBo.setKey(k);
                             Map<String, List<ClassGrade>> collect = v.stream().collect(Collectors.groupingBy(ClassGrade::getOfficialName));
@@ -326,17 +334,17 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
                         //去重
                         List<String> codeStrs = new ArrayList<>();
                         for (ClassGrade gradesMax : classGradesMax) {
-                            if (codeStrs.contains(gradesMax.getOfficialName())){
+                            if (codeStrs.contains(gradesMax.getOfficialName())) {
                                 continue;
                             }
                             codeStrs.add(gradesMax.getOfficialName());
                         }
                         //获取当前机构商品下的班级
                         List<ClassGradeGoods> gradeGoods = iClassGradeGoodsService.getGradeGoodsList(goodsId);
-                        if(gradeGoods.size() < codeStrs.size()){
+                        if (gradeGoods.size() < codeStrs.size()) {
                             add.setOfficialName(codeStrs.get(gradeGoods.size()));
                             add.setClassStatus(0);
-                        }else {
+                        } else {
                             //生成预报名官方编号
                             add.setOfficialName(ServletUtils.getEncoded("PIY"));
                             add.setClassStatus(0);
@@ -382,30 +390,36 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
         validEntityBeforeSave(update);
         update.setUpdateTime(DateUtils.getNowTime());
 
-        ClassGradeGoods gradeGoods = iClassGradeGoodsService.getOne(new LambdaQueryWrapper<ClassGradeGoods>().eq(ClassGradeGoods::getGradeId,update.getGradeId()));
-        if (ObjectUtils.isNull(gradeGoods)){
+        ClassGradeGoods gradeGoods = iClassGradeGoodsService.getOne(new LambdaQueryWrapper<ClassGradeGoods>().eq(ClassGradeGoods::getGradeId, update.getGradeId()));
+        if (ObjectUtils.isNull(gradeGoods)) {
             throw new RuntimeException("班级商品信息查询失败");
         }
+        //企业ID
+        String tenant = ServletUtils.getRequest().getHeader("TenantId");
+        SysOldOrg org = sysOldOrgService.list(new LambdaQueryWrapper<SysOldOrg>()
+                .eq(SysOldOrg::getTenantId, tenant)
+                .last("limit 1")).stream().findFirst().orElse(null);
+
         Goods goods = iGoodsService.getById(gradeGoods.getGoodsId());
         CourseBusinessQueryBo businessQueryBo = new CourseBusinessQueryBo();
         businessQueryBo.setId(goods.getBusinessId());
         String fullName = iCourseBusinessService.queryFullName(businessQueryBo);
 
-        if (("继续教育二级建造师".equals(fullName)) || ("继续教育二级造价师".equals(fullName))) {
+        if ((("继续教育二级建造师".equals(fullName)) || ("继续教育二级造价师".equals(fullName)))&& org.getShareClass() == 1) {
             if (update.getClassStatus() != null && update.getClassStatus().equals(1)) {
                 //二造和二建班级开班校验班级人数(300人)
-                if (!checkClassUserNum(goods.getBusinessId(),update.getGradeId())){
+                if (!checkClassUserNum(goods.getBusinessId(), update.getGradeId())) {
                     throw new RuntimeException("班级人数超过上限,不能开班,请检查!");
                 }
                 ClassGrade gradeGrade = getById(update.getGradeId());
-                if (StringUtils.isNotBlank(gradeGrade.getOfficialName())){
+                if (StringUtils.isNotBlank(gradeGrade.getOfficialName())) {
                     update.setRegisterCode(gradeGrade.getOfficialName());
                 }
                 //二建/二造官方信息推送开关打开
                 List<ClassGradeInterface> interfaceList = iClassGradeInterfaceService
                         .list(new LambdaQueryWrapper<ClassGradeInterface>()
-                        .eq(ClassGradeInterface::getType, 1).last("limit 1"));
-                if (CollectionUtils.isNotEmpty(interfaceList)){
+                                .eq(ClassGradeInterface::getType, 1).last("limit 1"));
+                if (CollectionUtils.isNotEmpty(interfaceList)) {
                     update.setInterfacePushId(interfaceList.get(0).getId());
                 }
             }
@@ -435,7 +449,7 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
                 throw new RuntimeException("班级还有学员,无法删除");
             }
             ClassGrade grade = getById(bo.getGradeId());
-            if (StringUtils.isNotBlank(grade.getOfficialName())){
+            if (StringUtils.isNotBlank(grade.getOfficialName())) {
                 throw new RuntimeException("二建/二造班级无法删除,请联系技术人员!");
             }
         }
@@ -449,7 +463,7 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
                     throw new RuntimeException("班级还有学员,无法设置为无效");
                 }
             }
-            if (StringUtils.isNotBlank(oldGrade.getOfficialName())){
+            if (StringUtils.isNotBlank(oldGrade.getOfficialName()) && org.getShareClass() == 1) {
                 throw new RuntimeException("二建/二造班级无法设置为无效,请联系技术人员!");
             }
         }
@@ -491,9 +505,9 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
         this.updateById(update);
 
         ClassGrade grade = getById(update.getGradeId());
-        if (("继续教育二级建造师".equals(fullName)) || ("继续教育二级造价师".equals(fullName))) {
+        if ((("继续教育二级建造师".equals(fullName)) || ("继续教育二级造价师".equals(fullName))) && org.getShareClass() == 1) {
             if (ObjectUtils.isNotNull(grade) && ObjectUtils.isNotNull(grade.getClassStatus())
-                    && StringUtils.isNotBlank(grade.getOfficialName()) && grade.getClassStatus() == 1){
+                    && StringUtils.isNotBlank(grade.getOfficialName()) && grade.getClassStatus() == 1) {
 //                List<ClassGrade> list = list(new LambdaQueryWrapper<ClassGrade>().eq(ClassGrade::getOfficialName, update.getRegisterCode()));
 //                if (CollectionUtils.isNotEmpty(list)){
 //                    update(new LambdaUpdateWrapper<ClassGrade>()
@@ -519,7 +533,7 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
                 this.openOfficialGrade(openBo);
                 //官方班级开班通知旧系统
                 Long nowTime = DateUtils.getNowTime();
-                String sign = ToolsUtils.EncoderByMd5(nowTime.toString()+"pubilc2022");
+                String sign = ToolsUtils.EncoderByMd5(nowTime.toString() + "pubilc2022");
                 openBo.setSign(sign);
                 openBo.setStamp(nowTime);
                 JSONObject param = JSONObject.parseObject(JSONObject.toJSONString(openBo));
@@ -531,7 +545,7 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
                         throw new CustomException("同步请求错误" + respone);
                     }
                 } catch (Exception e) {
-                    throw new CustomException("同步请求错误"+e.getMessage());
+                    throw new CustomException("同步请求错误" + e.getMessage());
                 }
             }
         }
@@ -980,10 +994,15 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
 
     @Override
     public boolean checkEjjjPeopleNumLimit(Long businessId, Long gradeId) {
+        //企业ID
+        String tenant = ServletUtils.getRequest().getHeader("TenantId");
+        SysOldOrg org = sysOldOrgService.list(new LambdaQueryWrapper<SysOldOrg>()
+                .eq(SysOldOrg::getTenantId, tenant)
+                .last("limit 1")).stream().findFirst().orElse(null);
         CourseBusinessQueryBo businessQueryBo = new CourseBusinessQueryBo();
         businessQueryBo.setId(businessId);
         String fullName = iCourseBusinessService.queryFullName(businessQueryBo);
-        if (("继续教育二级建造师".equals(fullName)) || ("继续教育二级造价师".equals(fullName))) {
+        if ((("继续教育二级建造师".equals(fullName)) || ("继续教育二级造价师".equals(fullName))) && org.getShareClass() == 1) {
             //继教二建或者继教二造班级
             ClassGradeVo gradeVo = queryById(gradeId);
             if (Validator.isNotEmpty(gradeVo) && Validator.isNotEmpty(gradeVo.getOfficialName())) {
@@ -1099,9 +1118,9 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
                 throw new CustomException("同步查询班级人数请求错误" + e.getMessage());
             }
             numAll = peopleNum + oldGradeNum;
-        }else {
+        } else {
             Long num = baseMapper.getClassUserNumByTenant(gradeId);
-            if (ObjectUtils.isNotNull(num)){
+            if (ObjectUtils.isNotNull(num)) {
                 numAll = num.intValue();
             }
         }
@@ -1156,7 +1175,7 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
     @Override
     public ClassGradeVo getClassGradeVo(Long gradeId) {
         ClassGrade gradeVo = getById(gradeId);
-        if (ObjectUtils.isNull(gradeVo)){
+        if (ObjectUtils.isNull(gradeVo)) {
             return null;
         }
         ClassGradeVo vo = BeanUtil.toBean(gradeVo, ClassGradeVo.class);
@@ -1173,28 +1192,28 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
     @Override
     public List<ClassNpUserInfoVo> officialGradeDetail(ClassNpUserInfoBo bo) {
         List<ClassNpUserInfoVo> result = baseMapper.getGradeDetailByTenant(bo);
-        if (CollectionUtils.isEmpty(result)){
+        if (CollectionUtils.isEmpty(result)) {
             return new ArrayList<>();
         }
         result.forEach(item -> {
             String date = "yyyy-MM-dd HH:mm:ss";
-            item.setOrderTime(DateUtils.timestampToDateFormat(item.getOrderTimeLong(),date));
-            item.setCreateTime(DateUtils.timestampToDateFormat(item.getOrderTimeLong(),date));
-            item.setDoTime(DateUtils.timestampToDateFormat(item.getDoTimeLong(),date));
+            item.setOrderTime(DateUtils.timestampToDateFormat(item.getOrderTimeLong(), date));
+            item.setCreateTime(DateUtils.timestampToDateFormat(item.getOrderTimeLong(), date));
+            item.setDoTime(DateUtils.timestampToDateFormat(item.getDoTimeLong(), date));
             //机构名称
             SysTenant tenant = sysTenantService.getById(item.getTenantId());
-            if (ObjectUtils.isNotNull(tenant)){
+            if (ObjectUtils.isNotNull(tenant)) {
                 item.setOrgName(tenant.getTenantName());
             }
             //获取学习开始时间和结束时间
-            UserStudyRecord startRecord = iUserStudyRecordService.getStudyRecord(item.getUserId(),item.getGradeId(),"ASC");
-            if (ObjectUtils.isNotNull(startRecord)){
-                item.setBeginTime(DateUtils.timestampToDateFormat(startRecord.getCreateTime(),date));
-                UserStudyRecord endRecord = iUserStudyRecordService.getStudyRecord(item.getUserId(),item.getGradeId(),"DESC");
-                item.setApplyTime(DateUtils.timestampToDateFormat(endRecord.getCreateTime(),date));
+            UserStudyRecord startRecord = iUserStudyRecordService.getStudyRecord(item.getUserId(), item.getGradeId(), "ASC");
+            if (ObjectUtils.isNotNull(startRecord)) {
+                item.setBeginTime(DateUtils.timestampToDateFormat(startRecord.getCreateTime(), date));
+                UserStudyRecord endRecord = iUserStudyRecordService.getStudyRecord(item.getUserId(), item.getGradeId(), "DESC");
+                item.setApplyTime(DateUtils.timestampToDateFormat(endRecord.getCreateTime(), date));
             }
             //科目名称
-            if(StringUtils.isNotBlank(item.getSubjectIds())){
+            if (StringUtils.isNotBlank(item.getSubjectIds())) {
                 List<CourseSubject> courseSubjectList = iCourseSubjectService.getListByIDs(Arrays.asList(item.getSubjectIds().split(",")).stream().map(x -> Long.valueOf(x)).collect(Collectors.toList()));
                 item.setMajorName(courseSubjectList.stream().filter(x -> StringUtils.isNotBlank(x.getSubjectName())).map(CourseSubject::getSubjectName).collect(Collectors.joining(",")));
             }
@@ -1214,19 +1233,19 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
         Long tenantId = 867735392558919680L;
         bgListBo.setTenantId(tenantId);
         List<Long> goodsIds = baseMapper.getGoodsIdByBoTenant(bgListBo);
-        if (CollectionUtils.isEmpty(goodsIds)){
+        if (CollectionUtils.isEmpty(goodsIds)) {
             throw new CustomException("改业务层次下不存在商品,请检查!");
         }
         //生成预报名官方编号
         String encoded = ServletUtils.getEncoded("PIY");
-        if (CollectionUtils.isEmpty(classGrades)){
+        if (CollectionUtils.isEmpty(classGrades)) {
             //创建新预报名班级
-            creatClass(goodsIds.get(0),tenantId,encoded);
-        }else {
+            creatClass(goodsIds.get(0), tenantId, encoded);
+        } else {
             //获取班级创建最多的机构
             Map<Long, List<ClassGrade>> map = classGrades.stream().collect(Collectors.groupingBy(ClassGrade::getTenantId));
             List<ClassGradeSortBo> sortList = new ArrayList<>();
-            map.forEach((k,v) -> {
+            map.forEach((k, v) -> {
                 ClassGradeSortBo sortBo = new ClassGradeSortBo();
                 sortBo.setKey(k);
                 Map<String, List<ClassGrade>> collect = v.stream().collect(Collectors.groupingBy(ClassGrade::getOfficialName));
@@ -1235,18 +1254,18 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
             });
             ClassGradeSortBo sortBo = sortList.stream().sorted(Comparator.comparing(ClassGradeSortBo::getSize).reversed()).findFirst().orElse(null);
             List<ClassGrade> classGradesMax = map.get(sortBo.getKey()).stream().sorted(Comparator.comparing(ClassGrade::getCreateTime)).collect(Collectors.toList());
-            if(bo.getSortNum() < classGradesMax.size()){
+            if (bo.getSortNum() < classGradesMax.size()) {
                 ClassGrade classGrade = classGradesMax.get(bo.getSortNum());
                 ClassUserNumBo classUserNumBo = new ClassUserNumBo();
                 classUserNumBo.setOfficialName(classGrade.getOfficialName());
                 ClassGradeQueryBo classGradeQueryBo = new ClassGradeQueryBo();
                 classGradeQueryBo.setOfficialName(classGrade.getOfficialName());
                 Integer count = baseMapper.queryOfficialGradeCount(classGradeQueryBo);
-                classUserNumBo.setNum(ObjectUtils.isNotNull(count)?count:0);
-               return classUserNumBo;
-            }else {
+                classUserNumBo.setNum(ObjectUtils.isNotNull(count) ? count : 0);
+                return classUserNumBo;
+            } else {
                 //创建新预报名班级
-                creatClass(goodsIds.get(0),tenantId,encoded);
+                creatClass(goodsIds.get(0), tenantId, encoded);
             }
         }
 
@@ -1255,7 +1274,7 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
         ClassGradeQueryBo classGradeQueryBo = new ClassGradeQueryBo();
         classGradeQueryBo.setOfficialName(encoded);
         Integer count = baseMapper.queryOfficialGradeCount(classGradeQueryBo);
-        classUserNumBo.setNum(ObjectUtils.isNotNull(count)?count:0);
+        classUserNumBo.setNum(ObjectUtils.isNotNull(count) ? count : 0);
         return classUserNumBo;
     }
 
@@ -1266,10 +1285,10 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
 
     @Override
     public void openOfficialGrade(ClassGradeOpenBo bo) {
-       List<ClassGrade> list = baseMapper.getGradeListByCodeTenant(bo.getRegisterCode());
-       if (CollectionUtils.isEmpty(list)){
-           return;
-       }
+        List<ClassGrade> list = baseMapper.getGradeListByCodeTenant(bo.getRegisterCode());
+        if (CollectionUtils.isEmpty(list)) {
+            return;
+        }
         List<Long> ids = list.stream().map(ClassGrade::getGradeId).collect(Collectors.toList());
         //保留预报名编号
         baseMapper.UpGradeCodeByIdTenant(ids);
@@ -1287,8 +1306,8 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
 
         //开启官方信息推送
         list.forEach(item -> {
-            ClassGradeInterface interfaceInterface = iClassGradeInterfaceService.getInfterFaceByTenant(1,item.getTenantId());
-            if (ObjectUtils.isNotNull(interfaceInterface)){
+            ClassGradeInterface interfaceInterface = iClassGradeInterfaceService.getInfterFaceByTenant(1, item.getTenantId());
+            if (ObjectUtils.isNotNull(interfaceInterface)) {
                 ClassGradeOpenUpBo upBo = new ClassGradeOpenUpBo();
                 upBo.setGradeId(item.getGradeId());
                 upBo.setInterfacePushId(interfaceInterface.getId());
@@ -1301,50 +1320,50 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
     @Override
     public List<ClassNpUserInfoVo> otherClassUserList(ClassNpUserInfoBo bo) {
         ClassGrade grade = getById(bo.getGradeId());
-        if (ObjectUtils.isNull(grade) || StringUtils.isBlank(grade.getOfficialName())){
+        if (ObjectUtils.isNull(grade) || StringUtils.isBlank(grade.getOfficialName())) {
             throw new CustomException("班级信息有有误,请联系管理员!");
         }
         //查询旧机构对应新系统ID
-        if (ObjectUtils.isNotNull(bo.getTrainOrgId())){
+        if (ObjectUtils.isNotNull(bo.getTrainOrgId())) {
             List<SysOldOrg> list = iSysOldOrgService.list(new LambdaQueryWrapper<SysOldOrg>()
                     .eq(SysOldOrg::getOrgId, bo.getTrainOrgId())
                     .eq(SysOldOrg::getStatus, 1));
-            if (CollectionUtils.isNotEmpty(list)){
+            if (CollectionUtils.isNotEmpty(list)) {
                 SysOldOrg sysOldOrg = list.get(0);
-                bo.setTenantId(ObjectUtils.isNotNull(sysOldOrg.getTenantId())?sysOldOrg.getTenantId():0L);
-            }else {
+                bo.setTenantId(ObjectUtils.isNotNull(sysOldOrg.getTenantId()) ? sysOldOrg.getTenantId() : 0L);
+            } else {
                 bo.setTenantId(0L);
             }
         }
         bo.setOfficialName(grade.getOfficialName());
         //新系统二建/二造班级学员信息
         List<ClassNpUserInfoVo> result = baseMapper.getGradeDetailByTenant(bo);
-        if (CollectionUtils.isNotEmpty(result)){
+        if (CollectionUtils.isNotEmpty(result)) {
             result.forEach(item -> {
                 String date = "yyyy-MM-dd HH:mm:ss";
-                item.setOrderTime(DateUtils.timestampToDateFormat(item.getOrderTimeLong(),date));
-                item.setCreateTime(DateUtils.timestampToDateFormat(item.getOrderTimeLong(),date));
-                item.setDoTime(DateUtils.timestampToDateFormat(item.getDoTimeLong(),date));
+                item.setOrderTime(DateUtils.timestampToDateFormat(item.getOrderTimeLong(), date));
+                item.setCreateTime(DateUtils.timestampToDateFormat(item.getOrderTimeLong(), date));
+                item.setDoTime(DateUtils.timestampToDateFormat(item.getDoTimeLong(), date));
                 //机构名称
                 SysTenant tenant = sysTenantService.getById(item.getTenantId());
-                if (ObjectUtils.isNotNull(tenant)){
+                if (ObjectUtils.isNotNull(tenant)) {
                     item.setOrgName(tenant.getTenantName());
                 }
                 //获取学习开始时间和结束时间
-                UserStudyRecord startRecord = iUserStudyRecordService.getStudyRecord(item.getUserId(),item.getGradeId(),"ASC");
-                if (ObjectUtils.isNotNull(startRecord)){
-                    item.setBeginTime(DateUtils.timestampToDateFormat(startRecord.getCreateTime(),date));
-                    item.setApplyTime(DateUtils.timestampToDateFormat(item.getApplyTimeLong(),date));
+                UserStudyRecord startRecord = iUserStudyRecordService.getStudyRecord(item.getUserId(), item.getGradeId(), "ASC");
+                if (ObjectUtils.isNotNull(startRecord)) {
+                    item.setBeginTime(DateUtils.timestampToDateFormat(startRecord.getCreateTime(), date));
+                    item.setApplyTime(DateUtils.timestampToDateFormat(item.getApplyTimeLong(), date));
                 }
                 //科目名称
-                if(StringUtils.isNotBlank(item.getSubjectIds())){
+                if (StringUtils.isNotBlank(item.getSubjectIds())) {
                     List<CourseSubject> courseSubjectList = iCourseSubjectService.listByIds(Arrays.asList(item.getSubjectIds().split(",")));
                     item.setMajorName(courseSubjectList.stream().filter(x -> StringUtils.isNotBlank(x.getSubjectName())).map(CourseSubject::getSubjectName).collect(Collectors.joining(",")));
                 }
-                if (ObjectUtils.isNull(item.getReportStatu())){
+                if (ObjectUtils.isNull(item.getReportStatu())) {
                     item.setReportStatu(0);
                 }
-                if (ObjectUtils.isNull(item.getStudyQueueStatus())){
+                if (ObjectUtils.isNull(item.getStudyQueueStatus())) {
                     item.setStudyQueueStatus(0);
                 }
             });
@@ -1352,7 +1371,7 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
         //旧系统二建/二造班级学员信息
         bo.setClassNo(bo.getOfficialName());
         Long nowTime = DateUtils.getNowTime();
-        String sign = ToolsUtils.EncoderByMd5(nowTime.toString()+"pubilc2022");
+        String sign = ToolsUtils.EncoderByMd5(nowTime.toString() + "pubilc2022");
         bo.setSign(sign);
         bo.setStamp(nowTime);
         JSONObject param = JSONObject.parseObject(JSONObject.toJSONString(bo));
@@ -1365,21 +1384,21 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
             }
             JSONObject jsonObject = (JSONObject) JSONObject.parse(respone);
             JSONArray dataArray = jsonObject.getJSONArray("Message");
-            if (ObjectUtils.isNotNull(dataArray)){
+            if (ObjectUtils.isNotNull(dataArray)) {
                 List<ClassNpUserInfoVo> voList = JSONArray.parseArray(JSONArray.toJSONString(dataArray), ClassNpUserInfoVo.class);
                 result.addAll(voList);
             }
         } catch (Exception e) {
-            throw new CustomException("同步请求错误"+e.getMessage());
+            throw new CustomException("同步请求错误" + e.getMessage());
         }
         return result;
     }
 
     //创建预开班班级
-    private void creatClass(Long goodsId,Long tenantId,String code){
+    private void creatClass(Long goodsId, Long tenantId, String code) {
         //创建新班级
-        Goods goods = iGoodsService.getGoodsByIdTenant(goodsId,tenantId);
-        CourseBusiness businessVo = iCourseBusinessService.getBusinessByIdTenant(goods.getBusinessId(),tenantId);
+        Goods goods = iGoodsService.getGoodsByIdTenant(goodsId, tenantId);
+        CourseBusiness businessVo = iCourseBusinessService.getBusinessByIdTenant(goods.getBusinessId(), tenantId);
         boolean isConfigTp = false; //商品是否有配置选班模板
         if (Validator.isNotEmpty(businessVo) && Validator.isNotEmpty(businessVo.getTemplateName()) && businessVo.getTemplateName().equals("班级")) {
             isConfigTp = true;
@@ -1400,32 +1419,32 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
 //        classGrade.setClassName(goodsName + gradeCode);
         //班级名称 年份+期数+业务层次(俗名)+教育类型+科目(存在多个科目时,显示多个科目,用“+”分割)
         String businessName = businessVo.getAliasName();
-        CourseEducationType educationType = courseEducationTypeService.getEducationByIdtenant(goods.getEducationTypeId(),tenantId);
+        CourseEducationType educationType = courseEducationTypeService.getEducationByIdtenant(goods.getEducationTypeId(), tenantId);
         String educationName = educationType.getEducationName();
         String className = businessName + educationName;
-        if (net.polyv.common.v1.util.StringUtils.isNotBlank(goods.getSubjectIds())){
+        if (net.polyv.common.v1.util.StringUtils.isNotBlank(goods.getSubjectIds())) {
             ClassGradeListBo bgListBo = new ClassGradeListBo();
             bgListBo.setSubIds(Arrays.stream(goods.getSubjectIds().split(",")).map(x -> Long.valueOf(x)).collect(Collectors.toList()));
             bgListBo.setTenantId(tenantId);
             List<CourseSubject> subjects = iCourseSubjectService.listByIdsTenant(bgListBo);
             List<String> names = subjects.stream().map(CourseSubject::getSubjectName).collect(Collectors.toList());
-            className = String.format("%s(%s)",className,org.apache.commons.lang3.StringUtils.join(names,'+'));
+            className = String.format("%s(%s)", className, org.apache.commons.lang3.StringUtils.join(names, '+'));
         }
         Integer nameSort = 1;
         //获取排序值
-        List<ClassGrade> list = baseMapper.queryListByNameTenantId(className,tenantId);
-        if (CollectionUtils.isNotEmpty(list)){
+        List<ClassGrade> list = baseMapper.queryListByNameTenantId(className, tenantId);
+        if (CollectionUtils.isNotEmpty(list)) {
             List<Integer> collect = list.stream().filter(x -> x.getClassName().contains("第") && x.getClassName().contains("期")).map(item -> {
                 String name = item.getClassName();
                 String substring = name.substring(name.indexOf("第") + 1, name.indexOf("期"));
                 return Integer.parseInt(substring);
             }).collect(Collectors.toList());
-            if (CollectionUtils.isNotEmpty(collect)){
+            if (CollectionUtils.isNotEmpty(collect)) {
                 Integer integer = collect.stream().sorted(Comparator.reverseOrder()).findFirst().get();
                 nameSort = integer + 1;
             }
         }
-        classGrade.setClassName(String.format("%s年第%s期%s",goods.getYear(),nameSort,className));
+        classGrade.setClassName(String.format("%s年第%s期%s", goods.getYear(), nameSort, className));
         classGrade.setTenantId(tenantId);
         save(classGrade);
         //绑定班级商品

+ 19 - 31
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/ClassGradeUserServiceImpl.java

@@ -4,48 +4,41 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.IdUtil;
-import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.Page;
 import com.zhongzheng.common.annotation.DataScope;
-import com.zhongzheng.common.config.RuoYiConfig;
 import com.zhongzheng.common.core.domain.AjaxResult;
 import com.zhongzheng.common.core.redis.RedisCache;
 import com.zhongzheng.common.core.redis.RedisLockEntity;
 import com.zhongzheng.common.exception.CustomException;
-import com.zhongzheng.common.utils.AES;
 import com.zhongzheng.common.utils.DateUtils;
+import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.common.utils.ToolsUtils;
 import com.zhongzheng.common.utils.file.FileUtils;
 import com.zhongzheng.common.utils.http.HttpUtils;
-import com.zhongzheng.common.utils.polyv.PolyvUtils;
 import com.zhongzheng.modules.alioss.service.OssService;
-import com.zhongzheng.modules.base.domain.UserProfile;
 import com.zhongzheng.modules.base.service.IUserProfileService;
 import com.zhongzheng.modules.course.bo.CourseBusinessQueryBo;
 import com.zhongzheng.modules.course.bo.CourseProjectTypeQueryBo;
-import com.zhongzheng.modules.course.domain.CourseBusiness;
-import com.zhongzheng.modules.course.domain.CourseEducationType;
-import com.zhongzheng.modules.course.domain.CourseMenuExam;
-import com.zhongzheng.modules.course.domain.CourseProjectType;
 import com.zhongzheng.modules.course.service.ICourseBusinessService;
 import com.zhongzheng.modules.course.service.ICourseEducationTypeService;
 import com.zhongzheng.modules.course.service.ICourseProjectTypeService;
 import com.zhongzheng.modules.course.vo.CourseBusinessVo;
 import com.zhongzheng.modules.course.vo.CourseChapterVo;
 import com.zhongzheng.modules.course.vo.CourseProjectTypeVo;
-import com.zhongzheng.modules.course.vo.CourseSectionVo;
-import com.zhongzheng.modules.goods.bo.GoodsQueryBo;
 import com.zhongzheng.modules.goods.domain.Goods;
 import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
 import com.zhongzheng.modules.grade.bo.*;
-import com.zhongzheng.modules.grade.domain.ClassGrade;
 import com.zhongzheng.modules.grade.domain.ClassGradeInterface;
+import com.zhongzheng.modules.grade.domain.ClassGradeUser;
 import com.zhongzheng.modules.grade.domain.StudyCountLog;
+import com.zhongzheng.modules.grade.mapper.ClassGradeUserMapper;
 import com.zhongzheng.modules.grade.service.*;
 import com.zhongzheng.modules.grade.vo.*;
 import com.zhongzheng.modules.order.bo.OrderGoodsQueryBo;
@@ -53,41 +46,28 @@ import com.zhongzheng.modules.order.domain.OrderGoods;
 import com.zhongzheng.modules.order.service.IOrderGoodsService;
 import com.zhongzheng.modules.order.service.IOrderService;
 import com.zhongzheng.modules.order.vo.OrderGoodsVo;
-import com.zhongzheng.modules.system.domain.SysTenant;
+import com.zhongzheng.modules.system.domain.SysOldOrg;
+import com.zhongzheng.modules.system.service.ISysOldOrgService;
 import com.zhongzheng.modules.user.bo.SubjectStudyRecordQueryBo;
 import com.zhongzheng.modules.user.bo.UserBankRecordQueryBo;
 import com.zhongzheng.modules.user.bo.UserQueryBo;
 import com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo;
 import com.zhongzheng.modules.user.domain.User;
-import com.zhongzheng.modules.user.domain.UserBankRecord;
-import com.zhongzheng.modules.user.domain.UserPlan;
 import com.zhongzheng.modules.user.domain.UserStudyRecordPhoto;
-import com.zhongzheng.modules.user.mapper.UserMapper;
 import com.zhongzheng.modules.user.mapper.UserStudyRecordPhotoMapper;
 import com.zhongzheng.modules.user.service.IUserBankRecordService;
 import com.zhongzheng.modules.user.service.IUserStudyRecordPhotoService;
 import com.zhongzheng.modules.user.service.IUserStudyRecordService;
 import com.zhongzheng.modules.user.vo.*;
-import org.apache.commons.codec.binary.Base64;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.github.pagehelper.Page;
-import com.zhongzheng.modules.grade.domain.ClassGradeUser;
-import com.zhongzheng.modules.grade.mapper.ClassGradeUserMapper;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
-import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
 import java.util.*;
 import java.util.stream.Collectors;
 import java.util.zip.ZipOutputStream;
@@ -177,6 +157,9 @@ public class ClassGradeUserServiceImpl extends ServiceImpl<ClassGradeUserMapper,
     @Autowired
     private  IUserPeriodService iUserPeriodService;
 
+    @Autowired
+    private ISysOldOrgService sysOldOrgService;
+
     @Override
     public ClassGradeUserVo queryById(Long id) {
         ClassGradeUser db = this.baseMapper.selectById(id);
@@ -653,8 +636,13 @@ public class ClassGradeUserServiceImpl extends ServiceImpl<ClassGradeUserMapper,
      */
     @Override
     public String pushOfficialPeriod(ClassGradeUserQueryBo bo) {
-        //暂时先关闭学时推送入口
-        if (true){
+        //企业ID
+        String tenant = ServletUtils.getRequest().getHeader("TenantId");
+        SysOldOrg org = sysOldOrgService.list(new LambdaQueryWrapper<SysOldOrg>()
+                .eq(SysOldOrg::getTenantId, tenant)
+                .last("limit 1")).stream().findFirst().orElse(null);
+        //共享班级关闭学时推送入口
+        if (org.getShareClass() == 1){
             return "";
         }
 

+ 24 - 15
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/UserPeriodServiceImpl.java

@@ -1,15 +1,16 @@
 package com.zhongzheng.modules.grade.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
-import cn.hutool.core.convert.Convert;
 import cn.hutool.core.lang.Validator;
-import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.Page;
 import com.zhongzheng.common.core.domain.model.LoginUser;
 import com.zhongzheng.common.core.redis.RedisCache;
 import com.zhongzheng.common.exception.CustomException;
@@ -34,12 +35,18 @@ import com.zhongzheng.modules.goods.service.IGoodsCourseService;
 import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
 import com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo;
+import com.zhongzheng.modules.grade.bo.UserPeriodAddBo;
+import com.zhongzheng.modules.grade.bo.UserPeriodEditBo;
+import com.zhongzheng.modules.grade.bo.UserPeriodQueryBo;
 import com.zhongzheng.modules.grade.domain.ClassGrade;
 import com.zhongzheng.modules.grade.domain.ClassGradeUser;
+import com.zhongzheng.modules.grade.domain.UserPeriod;
 import com.zhongzheng.modules.grade.domain.UserPeriodStatus;
 import com.zhongzheng.modules.grade.mapper.ClassGradeUserMapper;
+import com.zhongzheng.modules.grade.mapper.UserPeriodMapper;
 import com.zhongzheng.modules.grade.service.IClassGradeService;
 import com.zhongzheng.modules.grade.service.IClassGradeUserService;
+import com.zhongzheng.modules.grade.service.IUserPeriodService;
 import com.zhongzheng.modules.grade.service.IUserPeriodStatusService;
 import com.zhongzheng.modules.grade.vo.*;
 import com.zhongzheng.modules.inform.bo.InformUserAddBo;
@@ -48,8 +55,8 @@ import com.zhongzheng.modules.inform.service.IInformUserService;
 import com.zhongzheng.modules.inform.vo.InformRemindVo;
 import com.zhongzheng.modules.order.domain.OrderGoods;
 import com.zhongzheng.modules.order.service.IOrderGoodsService;
-import com.zhongzheng.modules.polyv.domain.TokenResponse;
-import com.zhongzheng.modules.user.domain.User;
+import com.zhongzheng.modules.system.domain.SysOldOrg;
+import com.zhongzheng.modules.system.service.ISysOldOrgService;
 import com.zhongzheng.modules.user.domain.UserStudyRecordPhoto;
 import com.zhongzheng.modules.user.service.IUserService;
 import com.zhongzheng.modules.user.service.IUserStudyRecordPhotoService;
@@ -61,16 +68,6 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.github.pagehelper.Page;
-import com.zhongzheng.modules.grade.bo.UserPeriodAddBo;
-import com.zhongzheng.modules.grade.bo.UserPeriodQueryBo;
-import com.zhongzheng.modules.grade.bo.UserPeriodEditBo;
-import com.zhongzheng.modules.grade.domain.UserPeriod;
-import com.zhongzheng.modules.grade.mapper.UserPeriodMapper;
-import com.zhongzheng.modules.grade.service.IUserPeriodService;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.io.IOException;
@@ -149,6 +146,9 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
     @Autowired
     private IGoodsCourseService iGoodsCourseService;
 
+    @Autowired
+    private ISysOldOrgService sysOldOrgService;
+
     @Autowired
     private ICourseMenuService iCourseMenuService;
 
@@ -518,6 +518,15 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
 
     @Override
     public SyncUserCourseStudyRec syncStudyLogToOld(UserPeriodEditBo bo) {
+        //企业ID
+        String tenant = ServletUtils.getRequest().getHeader("TenantId");
+        SysOldOrg org = sysOldOrgService.list(new LambdaQueryWrapper<SysOldOrg>()
+                .eq(SysOldOrg::getTenantId, tenant)
+                .last("limit 1")).stream().findFirst().orElse(null);
+        if (org.getShareClass() == 0){
+            //有职能的机构学时不推送旧系统
+            return null;
+        }
         CourseEducationType educationType = iCourseEducationTypeService.getOne(new LambdaQueryWrapper<CourseEducationType>().eq(CourseEducationType::getStatus, 1).eq(CourseEducationType::getEducationName,"继续教育").last("limit 1"));
         CourseProjectType projectType = iCourseProjectTypeService.getOne(new LambdaQueryWrapper<CourseProjectType>().eq(CourseProjectType::getStatus, 1).eq(CourseProjectType::getEducationId,educationType.getId()).eq(CourseProjectType::getProjectName,"建造师").last("limit 1"));
         CourseBusiness business = iCourseBusinessService.getOne(new LambdaQueryWrapper<CourseBusiness>().eq(CourseBusiness::getStatus, 1).eq(CourseBusiness::getProjectId,projectType.getId()).eq(CourseBusiness::getBusinessName,"二级").last("limit 1"));

+ 23 - 17
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderServiceImpl.java

@@ -5,8 +5,12 @@ import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.Page;
 import com.zhongzheng.common.core.redis.RedisCache;
 import com.zhongzheng.common.core.redis.RedisLockEntity;
 import com.zhongzheng.common.exception.CustomException;
@@ -16,13 +20,10 @@ import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.common.utils.ToolsUtils;
 import com.zhongzheng.modules.activity.domain.ActivityOrder;
 import com.zhongzheng.modules.activity.service.IActivityOrderService;
-import com.zhongzheng.modules.bank.domain.QuestionChapterExam;
 import com.zhongzheng.modules.base.bo.ConsoleQueryBo;
 import com.zhongzheng.modules.base.service.IProfileTpService;
 import com.zhongzheng.modules.base.service.IShoppingCartService;
 import com.zhongzheng.modules.course.bo.CourseBusinessQueryBo;
-import com.zhongzheng.modules.course.bo.CourseMenuQueryBo;
-import com.zhongzheng.modules.course.domain.CourseBusiness;
 import com.zhongzheng.modules.course.domain.CourseEducationType;
 import com.zhongzheng.modules.course.domain.CourseSubject;
 import com.zhongzheng.modules.course.service.ICourseBusinessService;
@@ -30,53 +31,50 @@ import com.zhongzheng.modules.course.service.ICourseEducationTypeService;
 import com.zhongzheng.modules.course.service.ICourseMenuService;
 import com.zhongzheng.modules.course.service.ICourseSubjectService;
 import com.zhongzheng.modules.course.vo.CourseBusinessVo;
-import com.zhongzheng.modules.course.vo.CourseMenuVo;
 import com.zhongzheng.modules.course.vo.CourseModuleFreeExamVo;
-import com.zhongzheng.modules.course.vo.CourseVo;
 import com.zhongzheng.modules.goods.bo.GoodsAttachedAddBo;
 import com.zhongzheng.modules.goods.bo.GoodsBankAddBo;
 import com.zhongzheng.modules.goods.bo.GoodsFreeBankAddBo;
 import com.zhongzheng.modules.goods.domain.Goods;
 import com.zhongzheng.modules.goods.domain.GoodsFreeBank;
-import com.zhongzheng.modules.goods.service.IGoodsCourseService;
 import com.zhongzheng.modules.goods.service.IGoodsFreeBankService;
 import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.grade.bo.ClassGradeListBo;
 import com.zhongzheng.modules.grade.bo.ClassGradeQueryBo;
 import com.zhongzheng.modules.grade.bo.ClassGradeSortBo;
 import com.zhongzheng.modules.grade.bo.ClassGradeUserTempQueryBo;
-import com.zhongzheng.modules.grade.domain.*;
+import com.zhongzheng.modules.grade.domain.ClassGrade;
+import com.zhongzheng.modules.grade.domain.ClassGradeGoods;
+import com.zhongzheng.modules.grade.domain.ClassGradeUser;
+import com.zhongzheng.modules.grade.domain.ClassGradeUserTemp;
 import com.zhongzheng.modules.grade.service.IClassGradeGoodsService;
 import com.zhongzheng.modules.grade.service.IClassGradeService;
 import com.zhongzheng.modules.grade.service.IClassGradeUserService;
 import com.zhongzheng.modules.grade.service.IClassGradeUserTempService;
 import com.zhongzheng.modules.grade.vo.ClassGradeUserTempVo;
 import com.zhongzheng.modules.grade.vo.ClassGradeVo;
-import com.zhongzheng.modules.inform.service.IInformRemindService;
-import com.zhongzheng.modules.inform.service.IInformUserService;
 import com.zhongzheng.modules.order.bo.*;
 import com.zhongzheng.modules.order.domain.*;
 import com.zhongzheng.modules.order.mapper.OrderMapper;
 import com.zhongzheng.modules.order.service.*;
-import com.zhongzheng.modules.order.vo.*;
+import com.zhongzheng.modules.order.vo.OrderGoodsVo;
+import com.zhongzheng.modules.order.vo.OrderListVo;
+import com.zhongzheng.modules.order.vo.OrderPayVo;
+import com.zhongzheng.modules.order.vo.OrderVo;
+import com.zhongzheng.modules.system.domain.SysOldOrg;
+import com.zhongzheng.modules.system.service.ISysOldOrgService;
 import com.zhongzheng.modules.user.domain.User;
 import com.zhongzheng.modules.user.domain.UserExamGoods;
 import com.zhongzheng.modules.user.service.IUserExamGoodsService;
-import com.zhongzheng.modules.user.service.IUserMockSubscribeService;
 import com.zhongzheng.modules.user.service.IUserService;
 import com.zhongzheng.modules.user.vo.UserVo;
 import com.zhongzheng.modules.wx.service.IWxPayService;
 import net.polyv.common.v1.util.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.github.pagehelper.Page;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
-import java.math.RoundingMode;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
@@ -142,6 +140,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
     @Autowired
     private IOrderGoodsFreeService iOrderGoodsFreeService;
 
+    @Autowired
+    private ISysOldOrgService sysOldOrgService;
+
     @Autowired
     private RedisCache redisCache;
 
@@ -1755,10 +1756,15 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             classGrade.setLearningStatus(2);//待定
             classGrade.setStudentUpper(ClassGrade.INIT_UPPER); //上限300
 
+            //企业ID
+            String tenant = ServletUtils.getRequest().getHeader("TenantId");
+            SysOldOrg org = sysOldOrgService.list(new LambdaQueryWrapper<SysOldOrg>()
+                    .eq(SysOldOrg::getTenantId, tenant)
+                    .last("limit 1")).stream().findFirst().orElse(null);
             CourseBusinessQueryBo businessQueryBo = new CourseBusinessQueryBo();
             businessQueryBo.setId(businessId);
             String fullName = iCourseBusinessService.queryFullName(businessQueryBo);
-            if (("继续教育二级建造师".equals(fullName)) || ("继续教育二级造价师".equals(fullName))) {
+            if ((("继续教育二级建造师".equals(fullName)) || ("继续教育二级造价师".equals(fullName))) && org.getShareClass() == 1) {
                 //生成预开班编号
                 classGrade.setOfficialName(createGradeCode(goodsId, businessVo));
             }

+ 1 - 0
zhongzheng-system/src/main/resources/mapper/modules/course/CourseSubjectMapper.xml

@@ -136,6 +136,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="getIdsByTenant" parameterType="java.lang.String"  resultType="java.lang.Long">
         select id from course_subject cs where cs.`status` = 1
+        AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cs.tenant_id AND sog.share_class = 1) > 0
         <if test="subNames != null and subNames.size()!=0 ">
             AND cs.subject_name in
             <foreach collection="subNames" item="item" index="index" open="(" close=")" separator=",">

+ 9 - 3
zhongzheng-system/src/main/resources/mapper/modules/grade/ClassGradeMapper.xml

@@ -892,6 +892,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                  WHERE
                      cg.official_name = #{officialName}
                    AND cgu.`status` = 1
+                   AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cgu.tenant_id AND sog.share_class = 1) > 0
              ) + (
                  SELECT
                      count(*)
@@ -901,6 +902,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                  WHERE
                      cg.official_name = #{officialName}
                    AND cgu.`status` = 1
+                   AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cgu.tenant_id AND sog.share_class = 1) > 0
              ))
 
     </select>
@@ -964,6 +966,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                     AND cb.tenant_id = #{tenantId}
                 </if>
         WHERE 1 = 1
+        AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cg.tenant_id AND sog.share_class = 1) > 0
         <if test="officialName != null and officialName !=''">
             AND cg.official_name = #{officialName}
         </if>
@@ -991,6 +994,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             LEFT JOIN course_business cb ON g.business_id = cb.id
         WHERE
             cb.alias_name = #{aliasName} AND cg.class_status = 0 AND cg.`status` = 1 AND g.goods_status = 1 AND cb.`status` = 1 AND g.`status` = 1
+            AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cg.tenant_id AND sog.share_class = 1) > 0
         <if test="subIds != null and subIds.size()!=0 ">
             AND (
             <foreach collection="subIds" item="id" index="index">
@@ -1013,6 +1017,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             LEFT JOIN course_business cb ON g.business_id = cb.id AND cb.tenant_id = #{tenantId}
         WHERE
         cb.alias_name = #{aliasName} AND g.`status` = 1 AND g.tenant_id = #{tenantId}
+        AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = g.tenant_id AND sog.share_class = 1) > 0
         <if test="subIds != null and subIds.size()!=0 ">
             AND (
             <foreach collection="subIds" item="id" index="index">
@@ -1037,10 +1042,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="getGradeListByCodeTenant" parameterType="java.lang.String" resultType="com.zhongzheng.modules.grade.domain.ClassGrade">
         SELECT
-            *
+            cg.*
         FROM
-            class_grade
-        where official_name = #{registerCode}
+            class_grade cg
+        where cg.official_name = #{registerCode}
+          AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cg.tenant_id AND sog.share_class = 1) > 0
     </select>
 
     <update id="UpGradeStatusByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeOpenUpBo" >