Commit e0aa2e01 authored by YangZhaoJun1's avatar YangZhaoJun1

优化开课接口

parent b3302dbc
......@@ -23,6 +23,7 @@ import org.rcisoft.business.blesson.entity.BLessonDirection;
import org.rcisoft.business.brooms.dao.BRoomsRepository;
import org.rcisoft.business.bsl.dao.BSlRepository;
import org.rcisoft.business.bsl.entity.BSl;
import org.rcisoft.business.bslschedule.dao.BSlScheduleRepository;
import org.rcisoft.business.bterm.dao.BTermRepository;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.exception.ServiceException;
......@@ -70,7 +71,7 @@ public class BArrangeServiceImpl implements BArrangeService {
private BDirectionRepository bDirectionRepository;
@Autowired
private BClassRepository bClassRepository;
private BSlScheduleRepository bSlScheduleRepository;
@Autowired
private BRoomsRepository bRoomsRepository;
......@@ -336,20 +337,24 @@ public class BArrangeServiceImpl implements BArrangeService {
throw new ServiceException(ResultServiceEnums.NO_AGENCY_SUBMISSION);
}
List<BSl> sls = new ArrayList<>();
List<BLessonDirection> bLessonDirections = new ArrayList<>();
int maxSlCode = bTermRepository.queryMaxSlCodeByTermCode(termCode);
for(String subAgencyId : subAgencyIds){
//查询要开的课
List<ScheduleDto> schedules = bArrangeRepository.queryDtoBySubAgencyId(subAgencyId);
for(ScheduleDto schedule : schedules){
BSl sl = new BSl();
//根据lessonCode查询课程信息
BLesson bLesson = bLessonRepository.queryBLessonByCode(schedule.getLessonCode());
//学期编号+学期中存放的开课序号最大值+1作为新的开课序号
int maxSlCode = bTermRepository.queryMaxSlCodeByTermCode(termCode);
//验证开课序号是否重复
String slCode = "";
for(int i=1;i<99999;i++){
slCode = termCode+String.valueOf(maxSlCode+i);
if(bSlRepository.selectOne(new BSl(slCode,"0","1"))==null)
maxSlCode = maxSlCode + i;
break;
}
sl.setCode(slCode);//课序号
......@@ -362,17 +367,20 @@ public class BArrangeServiceImpl implements BArrangeService {
sl.setSource("1");
UserUtil.setCurrentPersistOperation(sl);
sls.add(sl);
bTermRepository.MaxSlCodeByTermCode(termCode);//将该学期的开课序号最大值+1
//修改b_sl_schedule slId
bSlScheduleRepository.updateSlIdBySubAgencyId(sl.getBusinessId(),subAgencyId);
//课程方向
BLessonDirection bLessonDirection = new BLessonDirection();
bLessonDirection.setBusinessId(IdGen.uuid());
bLessonDirection.setSlId(sl.getBusinessId());
bLessonDirection.setDirectionId(bLesson.getDirectionId());
bDirectionRepository.insertBLessonDirection(bLessonDirection);
bLessonDirections.add(bLessonDirection);
//复制章节及文件目录
chapterService.addBslFormLesson(null,sl.getLessonCode(), sl.getBusinessId());
}
bTermRepository.MaxSlCodeByTermCode(termCode,String.valueOf(maxSlCode));//将该学期的开课序号存入
bDirectionRepository.insertList(bLessonDirections);//批量插入课程方向
//批量插入
result =bSlRepository.insertList(sls);
}
......
......@@ -46,5 +46,12 @@ public interface BDirectionRepository extends BaseMapper<BDirection> {
@Select("<script>select * from b_direction where name = #{name} and del_flag = 0 and flag = 1 </script>")
@ResultMap(value = "BaseResultMap")
BDirection queryDirectionByName(String name);
@Insert("<script>INSERT INTO b_lesson_direction" +
"(business_id,direction_id,sl_id,lession_id)VALUES" +
"<foreach collection=\"list\" item=\"item\" separator=\",\">" +
"( #{item.businessId},#{item.directionId},#{item.slId},#{item.lessionId})" +
"</foreach></script>")
int insertList(List<BLessonDirection> bLessonDirections);
}
package org.rcisoft.business.bslschedule.dao;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.rcisoft.core.base.BaseMapper;
import org.rcisoft.business.bslschedule.entity.BSlSchedule;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.springframework.security.access.method.P;
import org.springframework.stereotype.Repository;
......@@ -38,5 +41,8 @@ public interface BSlScheduleRepository extends BaseMapper<BSlSchedule> {
List<BSlSchedule> queryMoreBSlSchedules(String minTime,String maxTime,String subAgencyId);
int insertList(List<BSlSchedule> bSlSchedules);
@Update("update b_sl_schedule set sl_id = #{slId} where sub_agency_id = #{subAgencyId} and del_flag = 0 and glag = 1")
int updateSlIdBySubAgencyId(@Param("slId") String slId, @Param("subAgencyId") String subAgencyId);
}
package org.rcisoft.business.bterm.dao;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.*;
import org.rcisoft.business.bterm.entity.BTerm;
import org.rcisoft.core.base.BaseMapper;
import org.springframework.stereotype.Repository;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import java.text.DateFormat;
import java.util.Date;
......@@ -55,8 +52,8 @@ public interface BTermRepository extends BaseMapper<BTerm> {
@Select("select max_sl_code from b_term where code = #{termCode}")
int queryMaxSlCodeByTermCode(String termCode);
@Update("update b_term set max_sl_code = max_sl_code+1 where code = #{termCode} ")
int MaxSlCodeByTermCode(String termCode);
@Update("update b_term set max_sl_code = #{maxSlCode} where code = #{termCode} ")
int MaxSlCodeByTermCode(@Param("termCode") String termCode,@Param("maxSlCode") String maxSlCode);
/*
......
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