|
@@ -19,13 +19,10 @@ 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.CourseBusiness;
|
|
|
-import com.zhongzheng.modules.course.domain.CourseEducationType;
|
|
|
-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.domain.*;
|
|
|
+import com.zhongzheng.modules.course.service.*;
|
|
|
import com.zhongzheng.modules.course.vo.*;
|
|
|
+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.*;
|
|
@@ -42,6 +39,8 @@ import com.zhongzheng.modules.inform.service.IInformUserService;
|
|
|
import com.zhongzheng.modules.inform.vo.InformRemindBusinessVo;
|
|
|
import com.zhongzheng.modules.inform.vo.InformRemindVo;
|
|
|
import com.zhongzheng.modules.order.mapper.OrderMapper;
|
|
|
+import com.zhongzheng.modules.system.domain.SysTenant;
|
|
|
+import com.zhongzheng.modules.system.service.ISysTenantService;
|
|
|
import com.zhongzheng.modules.user.bo.SubjectStudyRecordQueryBo;
|
|
|
import com.zhongzheng.modules.user.bo.UserUpdateQueryBo;
|
|
|
import com.zhongzheng.modules.user.domain.*;
|
|
@@ -50,6 +49,7 @@ import com.zhongzheng.modules.user.service.IUserStudyRecordService;
|
|
|
import com.zhongzheng.modules.user.service.IUserUpdateService;
|
|
|
import com.zhongzheng.modules.user.vo.SubjectStudyRecordVo;
|
|
|
import com.zhongzheng.modules.user.vo.UserVo;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.http.Header;
|
|
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
import org.apache.http.util.EntityUtils;
|
|
@@ -88,9 +88,15 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
|
|
|
@Autowired
|
|
|
private IGoodsService iGoodsService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysTenantService sysTenantService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ICourseEducationTypeService courseEducationTypeService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ICourseSubjectService iCourseSubjectService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ICourseProjectTypeService courseProjectTypeService;
|
|
|
|
|
@@ -133,6 +139,12 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
|
|
|
@Autowired
|
|
|
private ICourseBusinessService iCourseBusinessService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IMajorService iMajorService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IClassGradeGoodsService iClassGradeGoodsService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private com.zhongzheng.modules.alisms.service.IAliSmsService IAliSmsService;
|
|
|
|
|
@@ -211,6 +223,51 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
|
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
|
throw new RuntimeException("班级名称不能重复");
|
|
|
}
|
|
|
+ //是否创建官方班级编号
|
|
|
+ if (bo.getClassGradeGoodsAddBos() != null &&
|
|
|
+ (ObjectUtils.isNull(bo.getClassStatus()) || 0 == bo.getClassStatus())) {
|
|
|
+ Long goodsId = bo.getClassGradeGoodsAddBos()[0];
|
|
|
+ Goods goods = iGoodsService.getById(goodsId);
|
|
|
+ CourseBusiness business = iCourseBusinessService.getById(goods.getBusinessId());
|
|
|
+ if (ObjectUtils.isNotNull(business) && ObjectUtils.isNotNull(business.getTemplateStatus()) && business.getTemplateStatus() == 1){
|
|
|
+ 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);
|
|
|
+ //获取业务层次下所有班级
|
|
|
+ ClassGradeListBo bgListBo = new ClassGradeListBo();
|
|
|
+ bgListBo.setAliasName(business.getAliasName());
|
|
|
+ bgListBo.setSubIds(subIds);
|
|
|
+ List<ClassGrade> classGrades = baseMapper.getGradeListByTenant(bgListBo);
|
|
|
+ if (CollectionUtils.isEmpty(classGrades)){
|
|
|
+ //生成预报名官方编号
|
|
|
+ add.setRegisterCode(ServletUtils.getEncoded("PIY"));
|
|
|
+ add.setClassStatus(0);
|
|
|
+ }else {
|
|
|
+ //获取班级创建最多的机构
|
|
|
+ Map<Long, List<ClassGrade>> map = classGrades.stream().collect(Collectors.groupingBy(ClassGrade::getTenantId));
|
|
|
+ List<ClassGradeSortBo> sortList = new ArrayList<>();
|
|
|
+ map.forEach((k,v) -> {
|
|
|
+ ClassGradeSortBo sortBo = new ClassGradeSortBo();
|
|
|
+ sortBo.setKey(k);
|
|
|
+ sortBo.setSize(v.size());
|
|
|
+ sortList.add(sortBo);
|
|
|
+ });
|
|
|
+ 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());
|
|
|
+ //获取当前机构商品下的班级
|
|
|
+ List<ClassGradeGoods> gradeGoods = iClassGradeGoodsService.getGradeGoodsList(goodsId);
|
|
|
+ if(gradeGoods.size() < classGradesMax.size()){
|
|
|
+ ClassGrade classGrade = classGradesMax.get(gradeGoods.size());
|
|
|
+ add.setRegisterCode(classGrade.getRegisterCode());
|
|
|
+ add.setClassStatus(0);
|
|
|
+ }else {
|
|
|
+ //生成预报名官方编号
|
|
|
+ add.setRegisterCode(ServletUtils.getEncoded("PIY"));
|
|
|
+ add.setClassStatus(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
boolean save = this.save(add);
|
|
|
//添加班级商品
|
|
|
if (bo.getClassGradeGoodsAddBos() != null) {
|
|
@@ -796,7 +853,7 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
|
|
|
log.info("查询业务系统班级人数失败参数" + params, "");
|
|
|
throw new CustomException("同步查询班级人数请求错误" + e.getMessage());
|
|
|
}
|
|
|
- if ((peopleNum + oldGradeNum) >= 3) { //全系统平台二建班级人数不能超300
|
|
|
+ if ((peopleNum + oldGradeNum) >= 300) { //全系统平台二建班级人数不能超300
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
@@ -908,6 +965,142 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
|
|
|
return vo;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<ClassNpUserInfoVo> officialGradeDetail(ClassNpUserInfoBo bo) {
|
|
|
+ List<ClassNpUserInfoVo> result = baseMapper.getGradeDetailByTenant(bo);
|
|
|
+ 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.getCreateTimeLong(),date));
|
|
|
+ item.setDoTime(DateUtils.timestampToDateFormat(item.getDoTimeLong(),date));
|
|
|
+ //机构名称
|
|
|
+ SysTenant tenant = sysTenantService.getById(item.getTenantId());
|
|
|
+ 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));
|
|
|
+ }
|
|
|
+ //科目名称
|
|
|
+ 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(",")));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getOfficialGradeNum(ClassOfficialNumBo bo) {
|
|
|
+ List<Long> subIds = iCourseSubjectService.getIdsByTenant(Arrays.asList(bo.getSubName()));
|
|
|
+ //获取业务层次下所有班级
|
|
|
+ ClassGradeListBo bgListBo = new ClassGradeListBo();
|
|
|
+ bgListBo.setAliasName(bo.getAliasName());
|
|
|
+ bgListBo.setSubIds(subIds);
|
|
|
+ List<ClassGrade> classGrades = baseMapper.getGradeListByTenant(bgListBo);
|
|
|
+ //祥粤云
|
|
|
+ Long tenantId = 867735392558919680L;
|
|
|
+ bgListBo.setTenantId(tenantId);
|
|
|
+ List<Long> goodsIds = baseMapper.getGoodsIdByBoTenant(bgListBo);
|
|
|
+ if (CollectionUtils.isEmpty(goodsIds)){
|
|
|
+ throw new CustomException("改业务层次下不存在商品,请检查!");
|
|
|
+ }
|
|
|
+ ServletUtils.getRequestAttributes().getRequest().setAttribute("TenantId",String.valueOf(tenantId));
|
|
|
+ //生成预报名官方编号
|
|
|
+ String encoded = ServletUtils.getEncoded("PIY");
|
|
|
+ if (CollectionUtils.isEmpty(classGrades)){
|
|
|
+ //创建新预报名班级
|
|
|
+ creatClass(goodsIds.get(0),encoded);
|
|
|
+ }else {
|
|
|
+ //获取班级创建最多的机构
|
|
|
+ Map<Long, List<ClassGrade>> map = classGrades.stream().collect(Collectors.groupingBy(ClassGrade::getTenantId));
|
|
|
+ List<ClassGradeSortBo> sortList = new ArrayList<>();
|
|
|
+ map.forEach((k,v) -> {
|
|
|
+ ClassGradeSortBo sortBo = new ClassGradeSortBo();
|
|
|
+ sortBo.setKey(k);
|
|
|
+ sortBo.setSize(v.size());
|
|
|
+ sortList.add(sortBo);
|
|
|
+ });
|
|
|
+ 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()){
|
|
|
+ ClassGrade classGrade = classGradesMax.get(bo.getSortNum());
|
|
|
+ return classGrade.getRegisterCode();
|
|
|
+ }else {
|
|
|
+ //创建新预报名班级
|
|
|
+ creatClass(goodsIds.get(0),encoded);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return encoded;
|
|
|
+ }
|
|
|
+
|
|
|
+ //创建预开班班级
|
|
|
+ private void creatClass(Long goodsId,String code){
|
|
|
+ //创建新班级
|
|
|
+ Goods goods = iGoodsService.getById(goodsId);
|
|
|
+ CourseBusinessVo businessVo = iCourseBusinessService.queryById(goods.getBusinessId());
|
|
|
+ boolean isConfigTp = false; //商品是否有配置选班模板
|
|
|
+ if (Validator.isNotEmpty(businessVo) && Validator.isNotEmpty(businessVo.getTemplateStatus()) && businessVo.getTemplateStatus() == 1) {
|
|
|
+ isConfigTp = true;
|
|
|
+ }
|
|
|
+ ClassGrade classGrade = new ClassGrade();
|
|
|
+ classGrade.setCreateTime(DateUtils.getNowTime());
|
|
|
+ if (isConfigTp) {
|
|
|
+ classGrade.setClassStatus(0);
|
|
|
+ classGrade.setLearningStatus(2);//待定
|
|
|
+ classGrade.setStudentUpper(ClassGrade.INIT_UPPER); //上限300
|
|
|
+ //生成官方班级编号
|
|
|
+ classGrade.setRegisterCode(code);
|
|
|
+ }
|
|
|
+ classGrade.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ classGrade.setStatus(1);
|
|
|
+ String gradeCode = ServletUtils.getEncoded("BJ");
|
|
|
+ classGrade.setGradeCode(gradeCode);
|
|
|
+// classGrade.setClassName(goodsName + gradeCode);
|
|
|
+ //班级名称 年份+期数+业务层次(俗名)+教育类型+科目(存在多个科目时,显示多个科目,用“+”分割)
|
|
|
+ String businessName = businessVo.getAliasName();
|
|
|
+ CourseEducationType educationType = courseEducationTypeService.getById(goods.getEducationTypeId());
|
|
|
+ String educationName = educationType.getEducationName();
|
|
|
+ String className = businessName + educationName;
|
|
|
+ if (net.polyv.common.v1.util.StringUtils.isNotBlank(goods.getSubjectIds())){
|
|
|
+ List<CourseSubject> subjects = iCourseSubjectService.listByIds(Arrays.stream(goods.getSubjectIds().split(",")).collect(Collectors.toList()));
|
|
|
+ List<String> names = subjects.stream().map(CourseSubject::getSubjectName).collect(Collectors.toList());
|
|
|
+ className = String.format("%s(%s)",className,org.apache.commons.lang3.StringUtils.join(names,'+'));
|
|
|
+ }
|
|
|
+ Integer nameSort = 1;
|
|
|
+ //获取排序值
|
|
|
+ List<ClassGrade> list = list(new LambdaQueryWrapper<ClassGrade>()
|
|
|
+ .like(ClassGrade::getClassName, className));
|
|
|
+ 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)){
|
|
|
+ Integer integer = collect.stream().sorted(Comparator.reverseOrder()).findFirst().get();
|
|
|
+ nameSort = integer + 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ classGrade.setClassName(String.format("%s年第%s期%s",goods.getYear(),nameSort,className));
|
|
|
+
|
|
|
+ save(classGrade);
|
|
|
+ //绑定班级商品
|
|
|
+ ClassGradeGoods classGradeGoods = new ClassGradeGoods();
|
|
|
+ classGradeGoods.setGradeId(classGrade.getGradeId());
|
|
|
+ classGradeGoods.setGoodsId(goodsId);
|
|
|
+ classGradeGoods.setCreateTime(DateUtils.getNowTime());
|
|
|
+ classGradeGoods.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ iClassGradeGoodsService.save(classGradeGoods);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 实体类转化成视图对象
|