Commit 89641d4f authored by zhangqingle's avatar zhangqingle

修改接口

parent 5b483033
......@@ -298,7 +298,7 @@ public interface BLessonPersonRepository extends BaseMapper<BLessonPerson> {
@Select("select count(0) x ,(select max_apply_person from b_lesson where business_id = #{lessonId} ) y " +
"from b_lesson_person where lesson_id = #{lessonId} ")
"from b_lesson_person where del_flag='0' and flag = '1' and lesson_id = #{lessonId} ")
Map<String,Object> selecTraningNum(@Param("lessonId") String lessonId);
......
......@@ -625,15 +625,18 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
* @return
*/
@Update("<script>update b_lesson set person_number = " +
"(select count(1) from b_lesson_person where 1=1 " +
" and del_flag != 1 and flag = 1 " +
" and is_finish != 0 " +
" and lesson_id = #{lessonId})" +
" where business_id = #{lessonId} </script>" )
int personNumberReCount(String lessonId);
"(select count(1) 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}) " +
" where business_id = #{lessonId} </script> " )
int personNumberReCount(@Param("lessonId") String lessonId, @Param("type") String lessonType);
/**
* 重新统计在学人数
* 在学人数
* @param lessonId
* @return
*/
......
......@@ -58,6 +58,9 @@ public class BLessonPersonServiceImpl implements BLessonPersonService {
@Override
public PersistModel quit(QuitLessonDTO quitLessonDTO) {
BLessonPerson bLessonPerson = bLessonPersonRepository.selectById(quitLessonDTO.getBusinessId());
BLesson bLesson = new BLesson();
bLesson.setBusinessId(quitLessonDTO.getLessonId());
bLesson = bLessonRepository.selectByPrimaryKey(bLesson);
if ("1".equals(bLessonPerson.getIsAppoint())){
throw new ServiceException(ResultServiceEnums.APPOINT_NOT_CLOSE);
}
......@@ -66,7 +69,7 @@ public class BLessonPersonServiceImpl implements BLessonPersonService {
// int line = bLessonPersonRepository.quit(quitLessonDTO.getBusinessId());
int line = bLessonPersonRepository.updateByPrimaryKeySelective(bLessonPerson);
//重新统计在学人数
bLessonRepository.personNumberReCount(quitLessonDTO.getLessonId());
bLessonRepository.personNumberReCount(quitLessonDTO.getLessonId(),bLesson.getLessonType());
return new PersistModel(line);
}
......@@ -182,7 +185,7 @@ public class BLessonPersonServiceImpl implements BLessonPersonService {
bLessonPerson.setIsFinish("1");
line = bLessonPersonRepository.updateByPrimaryKeySelective(bLessonPerson);
//重新统计在学人数
bLessonRepository.personNumberReCount(addMyLearnLessonDTO.getLessonId());
bLessonRepository.personNumberReCount(addMyLearnLessonDTO.getLessonId(),"0");
return new PersistModel(line);
}
if (bLessonPersons == null || bLessonPersons.size() < 1){ //未指派
......@@ -203,7 +206,7 @@ public class BLessonPersonServiceImpl implements BLessonPersonService {
bLessonPerson.setPersonId(addMyLearnLessonDTO.getUserId());
line = bLessonPersonRepository.insertBLessonPerson(bLessonPerson);
//重新统计在学人数
bLessonRepository.personNumberReCount(addMyLearnLessonDTO.getLessonId());
bLessonRepository.personNumberReCount(addMyLearnLessonDTO.getLessonId(),"0");
return new PersistModel(line);
}
// if (bLessonPersons != null && bLessonPersons.size()>0){
......
......@@ -1200,6 +1200,7 @@ public class BLessonServiceImpl implements BLessonService {
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
synchronized int trainInsert(String type, BLesson bLesson, List<BLessonPerson> bLessonPersons){
int line = 0;
if ("0".equals(type)){
Map<String, Object> xy = bLessonPersonRepository.selecTraningNum(bLesson.getBusinessId());
......@@ -1208,8 +1209,9 @@ public class BLessonServiceImpl implements BLessonService {
if (y > 0 && x >= y) {
throw new ServiceException(ResultServiceEnums.PERSON_MAX);
}
return bLessonPersonRepository.insert(bLessonPersons.get(0));
line = bLessonPersonRepository.insert(bLessonPersons.get(0));
bLessonRepository.personNumberReCount(bLesson.getBusinessId(),"1");
return line;
}
if ("1".equals(type)){
//如果为培训的话 判断剩余学生加已有学生总数超过最大数 抛异常
......@@ -1219,10 +1221,12 @@ public class BLessonServiceImpl implements BLessonService {
if (Integer.parseInt(bLesson.getMaxApplyPerson()) > 0 && personNumber + bLessonPersons.size() > Integer.parseInt(bLesson.getMaxApplyPerson())){
throw new ServiceException("培训人数上限"+bLesson.getMaxApplyPerson()+",现已超出"+String.valueOf(personNumber + bLessonPersons.size()- Integer.parseInt(bLesson.getMaxApplyPerson())+"人,请重新选择"));
}
return bLessonPersonRepository.insertList(bLessonPersons);
line = bLessonPersonRepository.insertList(bLessonPersons);
bLessonRepository.personNumberReCount(bLesson.getBusinessId(),"1");
return line;
}
}
return 0;
return line;
}
}
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