|
@@ -1,16 +1,15 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.ym.mec.biz.dal.dao.ChargeTypeOrganizationFeeDao;
|
|
|
-import com.ym.mec.biz.dal.dao.StudentRegistrationDao;
|
|
|
-import com.ym.mec.biz.dal.dao.SubjectDao;
|
|
|
-import com.ym.mec.biz.dal.dao.SubjectGoodsMapperDao;
|
|
|
+import com.ym.mec.biz.dal.dao.*;
|
|
|
import com.ym.mec.biz.dal.dto.ConditionDto;
|
|
|
import com.ym.mec.biz.dal.dto.SubFeeSettingDto;
|
|
|
import com.ym.mec.biz.dal.dto.SubjectApplyDetailDto;
|
|
|
import com.ym.mec.biz.dal.entity.ChargeTypeOrganizationFee;
|
|
|
+import com.ym.mec.biz.dal.entity.MusicGroup;
|
|
|
import com.ym.mec.biz.dal.entity.Subject;
|
|
|
import com.ym.mec.biz.dal.entity.SubjectGoodsMapper;
|
|
|
+import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
|
|
|
import com.ym.mec.biz.dal.enums.YesOrNoEnum;
|
|
|
import com.ym.mec.biz.dal.page.SubjectQueryInfo;
|
|
|
import com.ym.mec.biz.service.SubjectService;
|
|
@@ -28,7 +27,7 @@ import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
-public class SubjectServiceImpl extends BaseServiceImpl<Integer, Subject> implements SubjectService {
|
|
|
+public class SubjectServiceImpl extends BaseServiceImpl<Integer, Subject> implements SubjectService {
|
|
|
|
|
|
@Autowired
|
|
|
private SubjectDao subjectDao;
|
|
@@ -38,6 +37,8 @@ public class SubjectServiceImpl extends BaseServiceImpl<Integer, Subject> imple
|
|
|
private SubjectGoodsMapperDao subjectGoodsMapperDao;
|
|
|
@Autowired
|
|
|
private ChargeTypeOrganizationFeeDao chargeTypeOrganizationFeeDao;
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupDao musicGroupDao;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Integer, Subject> getDAO() {
|
|
@@ -52,19 +53,19 @@ public class SubjectServiceImpl extends BaseServiceImpl<Integer, Subject> imple
|
|
|
@Override
|
|
|
public PageInfo<Subject> queryPageTree(SubjectQueryInfo queryInfo) {
|
|
|
PageInfo<Subject> pageInfo = queryPage(queryInfo);
|
|
|
- for (Subject subject:pageInfo.getRows()) {
|
|
|
- subject = getTree(subject,queryInfo.getDelFlag(),queryInfo.getTenantId());
|
|
|
+ for (Subject subject : pageInfo.getRows()) {
|
|
|
+ subject = getTree(subject, queryInfo.getDelFlag(), queryInfo.getTenantId());
|
|
|
}
|
|
|
return pageInfo;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Subject> findDefaultSubByChargeTypeId(Integer chargeTypeId,Integer organId,Integer number) {
|
|
|
+ public List<Subject> findDefaultSubByChargeTypeId(Integer chargeTypeId, Integer organId, Integer number) {
|
|
|
List<Subject> subByChargeTypeId = subjectDao.findDefaultSubByChargeTypeId(chargeTypeId);
|
|
|
ChargeTypeOrganizationFee byOrganId = chargeTypeOrganizationFeeDao.findByOrganId(chargeTypeId, organId);
|
|
|
- if(byOrganId != null){
|
|
|
+ if (byOrganId != null) {
|
|
|
BigDecimal bigDecimal = new BigDecimal(number);
|
|
|
- subByChargeTypeId.forEach(e->{
|
|
|
+ subByChargeTypeId.forEach(e -> {
|
|
|
e.setFee(byOrganId.getCourseFee().multiply(bigDecimal));
|
|
|
});
|
|
|
}
|
|
@@ -74,41 +75,44 @@ public class SubjectServiceImpl extends BaseServiceImpl<Integer, Subject> imple
|
|
|
@Override
|
|
|
public List<SubjectApplyDetailDto> findSubApplyDetail(String musicGroupId) {
|
|
|
List<SubjectApplyDetailDto> subApplyDetail = subjectDao.findSubApplyDetail(musicGroupId);
|
|
|
+ MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
|
|
|
// //统计当前乐团不同声部的报名人数
|
|
|
- Map<Integer,Integer> applyNum = JSONObject.parseObject(JSONObject.toJSONString(MapUtil.convertIntegerMap(studentRegistrationDao.countApplyNum(musicGroupId))),HashMap.class);
|
|
|
- Map<Integer, Integer> payNumMap = JSONObject.parseObject(JSONObject.toJSONString(MapUtil.convertIntegerMap(studentRegistrationDao.countPayNum(musicGroupId))),HashMap.class);
|
|
|
- subApplyDetail.forEach(detail ->{
|
|
|
+ Map<Integer, Integer> applyNum = JSONObject.parseObject(JSONObject.toJSONString(MapUtil.convertIntegerMap(studentRegistrationDao.countApplyNum(musicGroupId))), HashMap.class);
|
|
|
+ Map<Integer, Integer> payNumMap = JSONObject.parseObject(JSONObject.toJSONString(MapUtil.convertIntegerMap(studentRegistrationDao.countPayNum(musicGroupId))), HashMap.class);
|
|
|
+ subApplyDetail.forEach(detail -> {
|
|
|
Integer num = payNumMap.get(detail.getSubjectId());
|
|
|
- detail.setPayNum(num == null?0:num);
|
|
|
- num = applyNum.get(detail.getSubjectId());
|
|
|
- detail.setApplyStudentNum(num == null?0:num);
|
|
|
+ detail.setPayNum(num == null ? 0 : num);
|
|
|
+ if (!musicGroup.getCourseViewType().equals(CourseViewTypeEnum.CLOUD_TEACHER)) {
|
|
|
+ num = applyNum.get(detail.getSubjectId());
|
|
|
+ detail.setApplyStudentNum(num == null ? 0 : num);
|
|
|
+ }
|
|
|
});
|
|
|
return subApplyDetail;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void upSetSubject(Subject subject) {
|
|
|
- if(subject.getDelFlag() == YesOrNoEnum.YES){
|
|
|
+ if (subject.getDelFlag() == YesOrNoEnum.YES) {
|
|
|
subjectDao.delete(subject.getId());
|
|
|
return;
|
|
|
}
|
|
|
Integer parentId = upset(subject, null);
|
|
|
List<Subject> subjects = subject.getSubjects();
|
|
|
- if(subjects != null && subjects.size() > 0){
|
|
|
- subjects.forEach(e->{
|
|
|
+ if (subjects != null && subjects.size() > 0) {
|
|
|
+ subjects.forEach(e -> {
|
|
|
upset(e, parentId);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private Integer upset(Subject subject,Integer parentId){
|
|
|
- if(parentId != null){
|
|
|
+ private Integer upset(Subject subject, Integer parentId) {
|
|
|
+ if (parentId != null) {
|
|
|
subject.setParentSubjectId(parentId);
|
|
|
}
|
|
|
- if(subject.getId() != null){
|
|
|
+ if (subject.getId() != null) {
|
|
|
subject.setUpdateTime(new Date());
|
|
|
subjectDao.update(subject);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
subjectDao.insert(subject);
|
|
|
}
|
|
|
return subject.getId();
|
|
@@ -116,36 +120,36 @@ public class SubjectServiceImpl extends BaseServiceImpl<Integer, Subject> imple
|
|
|
|
|
|
@Override
|
|
|
public void markGoods(List<SubjectGoodsMapper> subjectGoodsMappers) {
|
|
|
- subjectGoodsMappers.forEach(e->{
|
|
|
+ subjectGoodsMappers.forEach(e -> {
|
|
|
upsetGoods(e);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private void upsetGoods(SubjectGoodsMapper subjectGoodsMapper){
|
|
|
- if(subjectGoodsMapper.getId() != null){
|
|
|
- if(subjectGoodsMapper.getDelFlag()){
|
|
|
+ private void upsetGoods(SubjectGoodsMapper subjectGoodsMapper) {
|
|
|
+ if (subjectGoodsMapper.getId() != null) {
|
|
|
+ if (subjectGoodsMapper.getDelFlag()) {
|
|
|
subjectGoodsMapperDao.delete(subjectGoodsMapper.getId());
|
|
|
return;
|
|
|
}
|
|
|
subjectGoodsMapper.setUpdateTime(new Date());
|
|
|
subjectGoodsMapperDao.update(subjectGoodsMapper);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
subjectGoodsMapperDao.insert(subjectGoodsMapper);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
- private Subject getTree(Subject sub,YesOrNoEnum yesOrNoEnum,Integer tenantId){
|
|
|
+ private Subject getTree(Subject sub, YesOrNoEnum yesOrNoEnum, Integer tenantId) {
|
|
|
//得到根节点对象
|
|
|
//获取子节点list
|
|
|
- List<Subject> subjects = subjectDao.findByParentId(sub.getId(),yesOrNoEnum,tenantId);
|
|
|
+ List<Subject> subjects = subjectDao.findByParentId(sub.getId(), yesOrNoEnum, tenantId);
|
|
|
//如果存在子节点
|
|
|
- if(subjects != null && subjects.size() > 0) {
|
|
|
+ if (subjects != null && subjects.size() > 0) {
|
|
|
//将子节点list放入父节点对象
|
|
|
sub.setSubjects(subjects);
|
|
|
//遍历子节点....
|
|
|
for (Subject subject : subjects) {
|
|
|
- getTree(subject,yesOrNoEnum,tenantId);
|
|
|
+ getTree(subject, yesOrNoEnum, tenantId);
|
|
|
}
|
|
|
}
|
|
|
return sub;
|
|
@@ -163,15 +167,15 @@ public class SubjectServiceImpl extends BaseServiceImpl<Integer, Subject> imple
|
|
|
|
|
|
@Override
|
|
|
public Map<Long, String> findSubjectMapBySubjectIdsList(List<String> subjectIdsList) {
|
|
|
- if(CollectionUtils.isEmpty(subjectIdsList)){
|
|
|
+ if (CollectionUtils.isEmpty(subjectIdsList)) {
|
|
|
return new HashMap<>();
|
|
|
}
|
|
|
String subjectIdsString = StringUtils.join(subjectIdsList, ",");
|
|
|
String[] split = subjectIdsString.split(",");
|
|
|
- List<String> subjectIds=new ArrayList<>(Arrays.asList(split));
|
|
|
+ List<String> subjectIds = new ArrayList<>(Arrays.asList(split));
|
|
|
subjectIds = subjectIds.stream().distinct().collect(Collectors.toList());
|
|
|
- List<Map<Long, String>> bySubjecIds = subjectDao.findBySubjecIds(StringUtils.join(subjectIds,","));
|
|
|
- Map<Long,String> subjectIdAndName = MapUtil.convertMybatisMap(bySubjecIds);
|
|
|
+ List<Map<Long, String>> bySubjecIds = subjectDao.findBySubjecIds(StringUtils.join(subjectIds, ","));
|
|
|
+ Map<Long, String> subjectIdAndName = MapUtil.convertMybatisMap(bySubjecIds);
|
|
|
return subjectIdAndName;
|
|
|
}
|
|
|
|
|
@@ -182,7 +186,7 @@ public class SubjectServiceImpl extends BaseServiceImpl<Integer, Subject> imple
|
|
|
|
|
|
@Override
|
|
|
public List<Subject> findBySubjectByIdList(List<Integer> subjectIdList) {
|
|
|
- return subjectDao.findBySubjectByIdList(StringUtils.join(subjectIdList,","));
|
|
|
+ return subjectDao.findBySubjectByIdList(StringUtils.join(subjectIdList, ","));
|
|
|
}
|
|
|
|
|
|
@Override
|