Commit 119d33bd authored by luzhuang's avatar luzhuang

fix: b_p_lesson 统计数量变化自动变化

parent d95a1e0e
...@@ -5,6 +5,7 @@ import org.apache.commons.lang3.StringUtils; ...@@ -5,6 +5,7 @@ import org.apache.commons.lang3.StringUtils;
import org.rcisoft.business.bdiscuss.dto.BDiscussDto; import org.rcisoft.business.bdiscuss.dto.BDiscussDto;
import org.rcisoft.business.blesson.dao.BLessonRepository; import org.rcisoft.business.blesson.dao.BLessonRepository;
import org.rcisoft.business.blesson.entity.BLesson; import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.business.blesson.enums.LessonSycnEnum;
import org.rcisoft.business.blesson.enums.LessonTypeEnum; import org.rcisoft.business.blesson.enums.LessonTypeEnum;
import org.rcisoft.business.blesson.service.BLessonService; import org.rcisoft.business.blesson.service.BLessonService;
import org.rcisoft.business.bmessage.dao.BMessageRepository; import org.rcisoft.business.bmessage.dao.BMessageRepository;
...@@ -153,6 +154,10 @@ public class BDiscussServiceImpl implements BDiscussService { ...@@ -153,6 +154,10 @@ public class BDiscussServiceImpl implements BDiscussService {
int line = bDiscussRepository.insertSelective(bDiscuss); int line = bDiscussRepository.insertSelective(bDiscuss);
//重新统计b_lesson评论数 //重新统计b_lesson评论数
bLessonRepository.discussNumberReCount(bDiscuss.getLessonId()); bLessonRepository.discussNumberReCount(bDiscuss.getLessonId());
//如果 共享开启 重新统计b_p_lesson评论数
String flag = bMessageRepository.getSycnValue(curUser.getCorpId());
if(LessonSycnEnum.OPEN.getCode().equals(flag))
bLessonRepository.discussNumberReCount2(bDiscuss.getLessonId());
return new PersistModel(line); return new PersistModel(line);
} }
...@@ -173,6 +178,10 @@ public class BDiscussServiceImpl implements BDiscussService { ...@@ -173,6 +178,10 @@ public class BDiscussServiceImpl implements BDiscussService {
bDiscussRepository.logicalDeleteSon(bDiscuss); bDiscussRepository.logicalDeleteSon(bDiscuss);
if (bDiscuss1 != null && StringUtils.isNotEmpty(bDiscuss1.getLessonId())){ if (bDiscuss1 != null && StringUtils.isNotEmpty(bDiscuss1.getLessonId())){
bLessonRepository.discussNumberReCount(bDiscuss1.getLessonId()); bLessonRepository.discussNumberReCount(bDiscuss1.getLessonId());
//如果 共享开启 重新统计b_p_lesson评论数
String flag = bMessageRepository.getSycnValue(bDiscuss1.getCorpId());
if(LessonSycnEnum.OPEN.getCode().equals(flag))
bLessonRepository.discussNumberReCount2(bDiscuss1.getLessonId());
} }
return new PersistModel(line); return new PersistModel(line);
} }
......
...@@ -694,6 +694,22 @@ public interface BLessonRepository extends BaseMapper<BLesson> { ...@@ -694,6 +694,22 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
" where business_id = #{lessonId} </script>" ) " where business_id = #{lessonId} </script>" )
int personNumberReCount(@Param("lessonId") String lessonId, @Param("type") String lessonType); int personNumberReCount(@Param("lessonId") String lessonId, @Param("type") String lessonType);
/**
* 重新统计 共享缓存 在学人数
* @param lessonId
* @return
*/
@Update("<script>update b_p_lesson a set a.person_number = (" +
"select b.bc from (select count(1) bc from b_lesson_person blp " +
" left join b_lesson bl on blp.lesson_id = bl.business_id " +
" where 1=1 " +
" and blp.del_flag != 1 and blp.flag = 1 " +
" and bl.lesson_type = #{type}" +
" <if test=\"type!=null and type != '' and type == 0\">and blp.is_finish != 0 </if>" +
" and blp.lesson_id = #{lessonId}) as b )" +
" where business_id = #{lessonId} </script>" )
int personNumberReCount2(@Param("lessonId") String lessonId, @Param("type") String lessonType);
/** /**
* 在学人数 * 在学人数
* @param lessonId * @param lessonId
...@@ -723,6 +739,18 @@ public interface BLessonRepository extends BaseMapper<BLesson> { ...@@ -723,6 +739,18 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
"and lesson_id = #{lessonId}) " + "and lesson_id = #{lessonId}) " +
"where business_id = #{lessonId}" ) "where business_id = #{lessonId}" )
int collectNumberReCount(String lessonId); int collectNumberReCount(String lessonId);
/**
* 重新统计 共享缓存 收藏人数
* @param lessonId
* @return
*/
@Update("update b_p_lesson set collect_number = " +
"(select count(1) from b_collect where 1=1 " +
"and lesson_id = #{lessonId}) " +
"where business_id = #{lessonId}" )
int collectNumberReCount2(String lessonId);
/** /**
* 重新统计热度 * 重新统计热度
* @param lessonId * @param lessonId
...@@ -735,6 +763,18 @@ public interface BLessonRepository extends BaseMapper<BLesson> { ...@@ -735,6 +763,18 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
" </script>" ) " </script>" )
int hotNumberReCount(String lessonId); int hotNumberReCount(String lessonId);
/**
* 重新统计 共享缓存 热度
* @param lessonId
* @return
*/
@Update("<script>update b_p_lesson set hot_number = " +
"(select count(1) from b_hot where 1=1 " +
" and lesson_id = #{lessonId}) where 1=1 " +
" and business_id = #{lessonId} " +
" </script>" )
int hotNumberReCount2(String lessonId);
/** /**
* 重新统计评论数 * 重新统计评论数
* *
...@@ -749,6 +789,18 @@ public interface BLessonRepository extends BaseMapper<BLesson> { ...@@ -749,6 +789,18 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
" and business_id = #{lessonId} " + " and business_id = #{lessonId} " +
" </script>" ) " </script>" )
int discussNumberReCount(String lessonId); int discussNumberReCount(String lessonId);
/**
* 重新统计 共享缓存 评论数
* @param lessonId
* @return
*/
@Update("<script>update b_p_lesson set discuss_number = " +
"(select count(1) from b_discuss where 1=1 " +
" and del_flag='0' and flag = '1' " +
" and lesson_id = #{lessonId}) where 1=1 " +
" and business_id = #{lessonId} " +
" </script>" )
int discussNumberReCount2(String lessonId);
/** /**
* 列表页分页查询全部课程 * 列表页分页查询全部课程
......
...@@ -12,10 +12,7 @@ import org.rcisoft.business.blesson.entity.BHot; ...@@ -12,10 +12,7 @@ import org.rcisoft.business.blesson.entity.BHot;
import org.rcisoft.business.blesson.entity.BLesson; import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.business.blesson.dao.BLessonPersonRepository; import org.rcisoft.business.blesson.dao.BLessonPersonRepository;
import org.rcisoft.business.blesson.entity.BLessonPerson; import org.rcisoft.business.blesson.entity.BLessonPerson;
import org.rcisoft.business.blesson.enums.IsApplyEnum; import org.rcisoft.business.blesson.enums.*;
import org.rcisoft.business.blesson.enums.IsFinishEnum;
import org.rcisoft.business.blesson.enums.LessonTypeEnum;
import org.rcisoft.business.blesson.enums.ReleaseStateEnum;
import org.rcisoft.business.blesson.service.BLessonPersonService; import org.rcisoft.business.blesson.service.BLessonPersonService;
import org.rcisoft.business.bmessage.dao.BMessageRepository; import org.rcisoft.business.bmessage.dao.BMessageRepository;
import org.rcisoft.business.bmessage.entity.BMessage; import org.rcisoft.business.bmessage.entity.BMessage;
...@@ -110,6 +107,10 @@ public class BLessonPersonServiceImpl implements BLessonPersonService { ...@@ -110,6 +107,10 @@ public class BLessonPersonServiceImpl implements BLessonPersonService {
int line = bLessonPersonRepository.updateByPrimaryKeySelective(bLessonPerson); int line = bLessonPersonRepository.updateByPrimaryKeySelective(bLessonPerson);
//重新统计在学人数 //重新统计在学人数
bLessonRepository.personNumberReCount(quitAndSignDTO.getLessonId(),bLesson.getLessonType()); bLessonRepository.personNumberReCount(quitAndSignDTO.getLessonId(),bLesson.getLessonType());
//如果 共享开启 重新统计b_p_lesson 在学人数
String flag = bMessageRepository.getSycnValue(curUser.getCorpId());
if(LessonSycnEnum.OPEN.getCode().equals(flag))
bLessonRepository.personNumberReCount2(quitAndSignDTO.getLessonId(),bLesson.getLessonType());
return new PersistModel(line); return new PersistModel(line);
} }
...@@ -302,6 +303,10 @@ public class BLessonPersonServiceImpl implements BLessonPersonService { ...@@ -302,6 +303,10 @@ public class BLessonPersonServiceImpl implements BLessonPersonService {
if (count < 1){ if (count < 1){
bHotRepository.insertSelective(new BHot(IdGen.uuid(), lessonAndUserDTO.getUserId(), lessonAndUserDTO.getLessonId())); bHotRepository.insertSelective(new BHot(IdGen.uuid(), lessonAndUserDTO.getUserId(), lessonAndUserDTO.getLessonId()));
bLessonRepository.hotNumberReCount(lessonAndUserDTO.getLessonId()); bLessonRepository.hotNumberReCount(lessonAndUserDTO.getLessonId());
//如果 共享开启 重新统计b_p_lesson 热度
String flag = bMessageRepository.getSycnValue(curUser.getCorpId());
if(LessonSycnEnum.OPEN.getCode().equals(flag))
bLessonRepository.hotNumberReCount2(lessonAndUserDTO.getLessonId());
} }
List<BLessonPerson> bLessonPersons = bLessonPersonRepository.selectByPersonAndLesson(lessonAndUserDTO); List<BLessonPerson> bLessonPersons = bLessonPersonRepository.selectByPersonAndLesson(lessonAndUserDTO);
...@@ -315,6 +320,10 @@ public class BLessonPersonServiceImpl implements BLessonPersonService { ...@@ -315,6 +320,10 @@ public class BLessonPersonServiceImpl implements BLessonPersonService {
line = bLessonPersonRepository.updateByPrimaryKeySelective(bLessonPerson); line = bLessonPersonRepository.updateByPrimaryKeySelective(bLessonPerson);
//重新统计在学人数 //重新统计在学人数
bLessonRepository.personNumberReCount(lessonAndUserDTO.getLessonId(),"0"); bLessonRepository.personNumberReCount(lessonAndUserDTO.getLessonId(),"0");
//如果 共享开启 重新统计b_p_lesson 在学人数
String flag = bMessageRepository.getSycnValue(curUser.getCorpId());
if(LessonSycnEnum.OPEN.getCode().equals(flag))
bLessonRepository.personNumberReCount2(lessonAndUserDTO.getLessonId(),"0");
return new PersistModel(line); return new PersistModel(line);
} }
if (bLessonPersons == null || bLessonPersons.size() < 1){ //未指派 if (bLessonPersons == null || bLessonPersons.size() < 1){ //未指派
...@@ -344,6 +353,10 @@ public class BLessonPersonServiceImpl implements BLessonPersonService { ...@@ -344,6 +353,10 @@ public class BLessonPersonServiceImpl implements BLessonPersonService {
bLessonServiceImpl.addValueEvent(curUser.getUserId(),bPersonValue,userInfo.getLockNum()); bLessonServiceImpl.addValueEvent(curUser.getUserId(),bPersonValue,userInfo.getLockNum());
} }
bLessonRepository.personNumberReCount(lessonAndUserDTO.getLessonId(),"0"); bLessonRepository.personNumberReCount(lessonAndUserDTO.getLessonId(),"0");
//如果 共享开启 重新统计b_p_lesson 在学人数
String flag = bMessageRepository.getSycnValue(curUser.getCorpId());
if(LessonSycnEnum.OPEN.getCode().equals(flag))
bLessonRepository.personNumberReCount2(lessonAndUserDTO.getLessonId(),"0");
return new PersistModel(line); return new PersistModel(line);
} }
bLessonPerson = new BLessonPerson(); bLessonPerson = new BLessonPerson();
...@@ -363,6 +376,10 @@ public class BLessonPersonServiceImpl implements BLessonPersonService { ...@@ -363,6 +376,10 @@ public class BLessonPersonServiceImpl implements BLessonPersonService {
} }
//重新统计在学人数 //重新统计在学人数
bLessonRepository.personNumberReCount(lessonAndUserDTO.getLessonId(),"0"); bLessonRepository.personNumberReCount(lessonAndUserDTO.getLessonId(),"0");
//如果 共享开启 重新统计b_p_lesson 在学人数
String flag = bMessageRepository.getSycnValue(curUser.getCorpId());
if(LessonSycnEnum.OPEN.getCode().equals(flag))
bLessonRepository.personNumberReCount2(lessonAndUserDTO.getLessonId(),"0");
return new PersistModel(line); return new PersistModel(line);
} }
// if (bLessonPersons != null && bLessonPersons.size()>0){ // if (bLessonPersons != null && bLessonPersons.size()>0){
......
...@@ -222,6 +222,10 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -222,6 +222,10 @@ public class BLessonServiceImpl implements BLessonService {
if (count < 1) { if (count < 1) {
bHotRepository.insertSelective(new BHot(IdGen.uuid(), curUser.getUserId(), bLesson.getBusinessId())); bHotRepository.insertSelective(new BHot(IdGen.uuid(), curUser.getUserId(), bLesson.getBusinessId()));
bLessonRepository.hotNumberReCount(bLesson.getBusinessId()); bLessonRepository.hotNumberReCount(bLesson.getBusinessId());
//如果 共享开启 重新统计b_p_lesson 热度
String flag = bMessageRepository.getSycnValue(curUser.getCorpId());
if(LessonSycnEnum.OPEN.getCode().equals(flag))
bLessonRepository.hotNumberReCount2(bLesson.getBusinessId());
} }
return bLesson; return bLesson;
...@@ -471,7 +475,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -471,7 +475,7 @@ public class BLessonServiceImpl implements BLessonService {
UserUtil.setCurrentMergeOperation(model); UserUtil.setCurrentMergeOperation(model);
line = bLessonRepository.updateByPrimaryKeySelective(model); line = bLessonRepository.updateByPrimaryKeySelective(model);
//查询 当前资源共享状态 //查询 当前资源共享状态
String flag = bMessageRepository.getSycnValue(model.getCorpId()); String flag = bMessageRepository.getSycnValue(curUser.getCorpId());
//开启共享状态 编辑课程时 添加日志 //开启共享状态 编辑课程时 添加日志
if(LessonSycnEnum.OPEN.getCode().equals(flag) && LessonTypeEnum.LESSON.getCode().equals(model.getLessonType())){ if(LessonSycnEnum.OPEN.getCode().equals(flag) && LessonTypeEnum.LESSON.getCode().equals(model.getLessonType())){
// 保存日志 // 保存日志
...@@ -968,6 +972,10 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -968,6 +972,10 @@ public class BLessonServiceImpl implements BLessonService {
if (userIds == null || userIds.size() < 1) { if (userIds == null || userIds.size() < 1) {
int line = bAppointRepository.deleteByPrimaryKey(bAppoint); int line = bAppointRepository.deleteByPrimaryKey(bAppoint);
bLessonRepository.personNumberReCount(bLesson.getBusinessId(), bLesson.getLessonType()); bLessonRepository.personNumberReCount(bLesson.getBusinessId(), bLesson.getLessonType());
//如果 共享开启 重新统计b_p_lesson 在学人数
String flag = bMessageRepository.getSycnValue(appointLessonDTO.getCorpId());
if(LessonSycnEnum.OPEN.getCode().equals(flag))
bLessonRepository.personNumberReCount2(bLesson.getBusinessId(), bLesson.getLessonType());
return new AppointResDTO(1, bLesson, appointLessonDTO, noticePersonList); return new AppointResDTO(1, bLesson, appointLessonDTO, noticePersonList);
} }
//插入b_lesson_person表 //插入b_lesson_person表
...@@ -1036,12 +1044,20 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1036,12 +1044,20 @@ public class BLessonServiceImpl implements BLessonService {
//指派培训 //指派培训
line = trainInsert("1", bLesson, bLessonPersonOthers); line = trainInsert("1", bLesson, bLessonPersonOthers);
bLessonRepository.personNumberReCount(bLesson.getBusinessId(), "1"); bLessonRepository.personNumberReCount(bLesson.getBusinessId(), "1");
//如果 共享开启 重新统计b_p_lesson 在学人数
String flag = bMessageRepository.getSycnValue(appointLessonDTO.getCorpId());
if(LessonSycnEnum.OPEN.getCode().equals(flag))
bLessonRepository.personNumberReCount2(bLesson.getBusinessId(), "1");
return new AppointResDTO(line, bLesson, appointLessonDTO, noticePersonList); return new AppointResDTO(line, bLesson, appointLessonDTO, noticePersonList);
} }
//指派课程 //指派课程
line = bLessonPersonRepository.insertList(bLessonPersonOthers); line = bLessonPersonRepository.insertList(bLessonPersonOthers);
} }
bLessonRepository.personNumberReCount(bLesson.getBusinessId(), bLesson.getLessonType()); bLessonRepository.personNumberReCount(bLesson.getBusinessId(), bLesson.getLessonType());
//如果 共享开启 重新统计b_p_lesson 在学人数
String flag = bMessageRepository.getSycnValue(appointLessonDTO.getCorpId());
if(LessonSycnEnum.OPEN.getCode().equals(flag))
bLessonRepository.personNumberReCount2(bLesson.getBusinessId(), bLesson.getLessonType());
return new AppointResDTO(line, bLesson, appointLessonDTO, noticePersonList); return new AppointResDTO(line, bLesson, appointLessonDTO, noticePersonList);
} }
} }
...@@ -1315,6 +1331,10 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1315,6 +1331,10 @@ public class BLessonServiceImpl implements BLessonService {
int line = bCollectRepository.insertSelective(bCollect); int line = bCollectRepository.insertSelective(bCollect);
//重新统计课程收藏数 //重新统计课程收藏数
bLessonRepository.collectNumberReCount(lessonId); bLessonRepository.collectNumberReCount(lessonId);
//如果 共享开启 重新统计b_p_lesson收藏数
String flag = bMessageRepository.getSycnValue(curUser.getCorpId());
if(LessonSycnEnum.OPEN.getCode().equals(flag))
bLessonRepository.collectNumberReCount2(lessonId);
return new PersistModel(line); return new PersistModel(line);
} }
...@@ -1353,6 +1373,10 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1353,6 +1373,10 @@ public class BLessonServiceImpl implements BLessonService {
person.setIsApply("1"); person.setIsApply("1");
int line = bLessonPersonRepository.updateLessonPersonByUserId(person); int line = bLessonPersonRepository.updateLessonPersonByUserId(person);
bLessonRepository.personNumberReCount(lessonId, "1"); bLessonRepository.personNumberReCount(lessonId, "1");
//如果 共享开启 重新统计b_p_lesson 在学人数
String flag = bMessageRepository.getSycnValue(curUser.getCorpId());
if(LessonSycnEnum.OPEN.getCode().equals(flag))
bLessonRepository.personNumberReCount2(lessonId, "1");
return line; return line;
} }
if (person != null && "1".equals(person.getDelFlag())) { if (person != null && "1".equals(person.getDelFlag())) {
...@@ -1377,6 +1401,10 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1377,6 +1401,10 @@ public class BLessonServiceImpl implements BLessonService {
addValueEvent(curUser.getUserId(), bPersonValue, userInfo.getLockNum()); addValueEvent(curUser.getUserId(), bPersonValue, userInfo.getLockNum());
} }
bLessonRepository.personNumberReCount(bLesson.getBusinessId(), "1"); bLessonRepository.personNumberReCount(bLesson.getBusinessId(), "1");
//如果 共享开启 重新统计b_p_lesson 在学人数
String flag = bMessageRepository.getSycnValue(curUser.getCorpId());
if(LessonSycnEnum.OPEN.getCode().equals(flag))
bLessonRepository.personNumberReCount2(bLesson.getBusinessId(), "1");
return line; return line;
} }
List<BLessonPerson> bLessonPersons = new ArrayList<>(); List<BLessonPerson> bLessonPersons = new ArrayList<>();
...@@ -1408,6 +1436,10 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1408,6 +1436,10 @@ public class BLessonServiceImpl implements BLessonService {
addValueEvent(curUser.getUserId(), bPersonValue, userInfo.getLockNum()); addValueEvent(curUser.getUserId(), bPersonValue, userInfo.getLockNum());
} }
bLessonRepository.personNumberReCount(bLesson.getBusinessId(), "1"); bLessonRepository.personNumberReCount(bLesson.getBusinessId(), "1");
//如果 共享开启 重新统计b_p_lesson 在学人数
String flag = bMessageRepository.getSycnValue(curUser.getCorpId());
if(LessonSycnEnum.OPEN.getCode().equals(flag))
bLessonRepository.personNumberReCount2(bLesson.getBusinessId(), "1");
return line; return line;
} }
...@@ -1427,6 +1459,10 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1427,6 +1459,10 @@ public class BLessonServiceImpl implements BLessonService {
int line = bCollectRepository.insert(bCollect); int line = bCollectRepository.insert(bCollect);
//更新课程表收藏个数 //更新课程表收藏个数
bLessonRepository.collectNumberReCount(lessonId); bLessonRepository.collectNumberReCount(lessonId);
//如果 共享开启 重新统计b_p_lesson 收藏数
String flag = bMessageRepository.getSycnValue(curUser.getCorpId());
if(LessonSycnEnum.OPEN.getCode().equals(flag))
bLessonRepository.collectNumberReCount2(lessonId);
return new PersistModel(line); return new PersistModel(line);
} }
...@@ -1435,6 +1471,10 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1435,6 +1471,10 @@ public class BLessonServiceImpl implements BLessonService {
public PersistModel notColletLesson(CurUser curUser, String lessonId) { public PersistModel notColletLesson(CurUser curUser, String lessonId) {
int line = bCollectRepository.notColletLesson(curUser.getUserId(), lessonId); int line = bCollectRepository.notColletLesson(curUser.getUserId(), lessonId);
bLessonRepository.collectNumberReCount(lessonId); bLessonRepository.collectNumberReCount(lessonId);
//如果 共享开启 重新统计b_p_lesson 收藏数
String flag = bMessageRepository.getSycnValue(curUser.getCorpId());
if(LessonSycnEnum.OPEN.getCode().equals(flag))
bLessonRepository.collectNumberReCount2(lessonId);
return new PersistModel(line); return new PersistModel(line);
} }
...@@ -1498,6 +1538,10 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1498,6 +1538,10 @@ public class BLessonServiceImpl implements BLessonService {
if (count < 1) { if (count < 1) {
bHotRepository.insertSelective(new BHot(IdGen.uuid(), curUser.getUserId(), lessonId)); bHotRepository.insertSelective(new BHot(IdGen.uuid(), curUser.getUserId(), lessonId));
bLessonRepository.hotNumberReCount(lessonId); bLessonRepository.hotNumberReCount(lessonId);
//如果 共享开启 重新统计b_p_lesson 热度
String flag = bMessageRepository.getSycnValue(curUser.getCorpId());
if(LessonSycnEnum.OPEN.getCode().equals(flag))
bLessonRepository.hotNumberReCount2(lessonId);
} }
return bLesson; return bLesson;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment