Commit cdefa307b8cc260dd760d0ade53068723a8ff13b
1 parent
93a5e244
考试排班初始化
Showing
8 changed files
with
71 additions
and
11 deletions
src/main/java/com/bsth/repository/LineInformationRepository.java
| @@ -2,6 +2,7 @@ package com.bsth.repository; | @@ -2,6 +2,7 @@ package com.bsth.repository; | ||
| 2 | 2 | ||
| 3 | import java.util.List; | 3 | import java.util.List; |
| 4 | 4 | ||
| 5 | +import org.springframework.data.jpa.repository.Modifying; | ||
| 5 | import org.springframework.data.jpa.repository.Query; | 6 | import org.springframework.data.jpa.repository.Query; |
| 6 | import org.springframework.stereotype.Repository; | 7 | import org.springframework.stereotype.Repository; |
| 7 | 8 | ||
| @@ -31,4 +32,8 @@ public interface LineInformationRepository extends BaseRepository<LineInformatio | @@ -31,4 +32,8 @@ public interface LineInformationRepository extends BaseRepository<LineInformatio | ||
| 31 | List<LineInformation> findByLine(List<String> lineCodes); | 32 | List<LineInformation> findByLine(List<String> lineCodes); |
| 32 | 33 | ||
| 33 | List<LineInformation> findByLine(Line line); | 34 | List<LineInformation> findByLine(Line line); |
| 35 | + | ||
| 36 | + @Modifying | ||
| 37 | + @Query(value = "delete from bsth_c_line_information where line in ( ?1 )", nativeQuery = true) | ||
| 38 | + void deleteLineInformationBylineCodes(List<String> lineCodes); | ||
| 34 | } | 39 | } |
src/main/java/com/bsth/repository/LineRepository.java
| @@ -101,4 +101,8 @@ public interface LineRepository extends BaseRepository<Line, Integer> { | @@ -101,4 +101,8 @@ public interface LineRepository extends BaseRepository<Line, Integer> { | ||
| 101 | @Query(value = "UPDATE bsth_c_line_file_version set version_count=?2 WHERE line = ?1", nativeQuery = true) | 101 | @Query(value = "UPDATE bsth_c_line_file_version set version_count=?2 WHERE line = ?1", nativeQuery = true) |
| 102 | public void editFileVersions(Integer lineId, Integer version_count); | 102 | public void editFileVersions(Integer lineId, Integer version_count); |
| 103 | 103 | ||
| 104 | + | ||
| 105 | + @Modifying | ||
| 106 | + @Query(value = "delete from Line l where l.lineCode in ( ?1 )") | ||
| 107 | + void deleteLineBylineCodes(List<String> lineCodes); | ||
| 104 | } | 108 | } |
src/main/java/com/bsth/repository/StationRouteRepository.java
| @@ -508,4 +508,8 @@ public interface StationRouteRepository extends BaseRepository<StationRoute, Int | @@ -508,4 +508,8 @@ public interface StationRouteRepository extends BaseRepository<StationRoute, Int | ||
| 508 | @Modifying | 508 | @Modifying |
| 509 | @Query(value="update bsth_c_stationroute set industry_code =?2 where id = ?1 ", nativeQuery=true) | 509 | @Query(value="update bsth_c_stationroute set industry_code =?2 where id = ?1 ", nativeQuery=true) |
| 510 | void updIndustryCode(Integer id,String IndustryCode); | 510 | void updIndustryCode(Integer id,String IndustryCode); |
| 511 | + | ||
| 512 | + @Modifying | ||
| 513 | + @Query(value = "delete from StationRoute sr where sr.lineCode in ( ?1 )") | ||
| 514 | + void deleteStationRouteBylineCodes(List<String> lineCodes); | ||
| 511 | } | 515 | } |
src/main/java/com/bsth/repository/realcontrol/LineConfigRepository.java
| @@ -6,6 +6,8 @@ import org.springframework.data.domain.Page; | @@ -6,6 +6,8 @@ import org.springframework.data.domain.Page; | ||
| 6 | import org.springframework.data.domain.Pageable; | 6 | import org.springframework.data.domain.Pageable; |
| 7 | import org.springframework.data.jpa.domain.Specification; | 7 | import org.springframework.data.jpa.domain.Specification; |
| 8 | import org.springframework.data.jpa.repository.EntityGraph; | 8 | import org.springframework.data.jpa.repository.EntityGraph; |
| 9 | +import org.springframework.data.jpa.repository.Modifying; | ||
| 10 | +import org.springframework.data.jpa.repository.Query; | ||
| 9 | import org.springframework.stereotype.Repository; | 11 | import org.springframework.stereotype.Repository; |
| 10 | 12 | ||
| 11 | import com.bsth.entity.realcontrol.LineConfig; | 13 | import com.bsth.entity.realcontrol.LineConfig; |
| @@ -26,4 +28,8 @@ public interface LineConfigRepository extends BaseRepository<LineConfig, Integer | @@ -26,4 +28,8 @@ public interface LineConfigRepository extends BaseRepository<LineConfig, Integer | ||
| 26 | @Override | 28 | @Override |
| 27 | List<LineConfig> findAll(); | 29 | List<LineConfig> findAll(); |
| 28 | 30 | ||
| 31 | + @Modifying | ||
| 32 | + @Query(value = "delete from bsth_c_line_config where line in ( ?1 )", nativeQuery = true) | ||
| 33 | + void deleteLineConfigBylineCodes(List<String> lineCodes); | ||
| 34 | + | ||
| 29 | } | 35 | } |
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
| @@ -240,5 +240,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI | @@ -240,5 +240,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI | ||
| 240 | @Query(value="select count(*) from ScheduleRealInfo s where s.scheduleDateStr = ?1 and s.xlBm = ?2") | 240 | @Query(value="select count(*) from ScheduleRealInfo s where s.scheduleDateStr = ?1 and s.xlBm = ?2") |
| 241 | int selectCountAll(String scheduleDateStr,String lineCode); | 241 | int selectCountAll(String scheduleDateStr,String lineCode); |
| 242 | 242 | ||
| 243 | - | 243 | + @Modifying |
| 244 | + @Query(value = "delete from ScheduleRealInfo sr where sr.xlBm in ( ?1 )") | ||
| 245 | + void deleteScheduleRealInfoBylineCodes(List<String> lineCodes); | ||
| 244 | } | 246 | } |
src/main/java/com/bsth/repository/sys/RealControAuthorityRepository.java
| @@ -2,9 +2,12 @@ package com.bsth.repository.sys; | @@ -2,9 +2,12 @@ package com.bsth.repository.sys; | ||
| 2 | 2 | ||
| 3 | import com.bsth.entity.sys.RealControAuthority; | 3 | import com.bsth.entity.sys.RealControAuthority; |
| 4 | import com.bsth.repository.BaseRepository; | 4 | import com.bsth.repository.BaseRepository; |
| 5 | +import org.springframework.data.jpa.repository.Modifying; | ||
| 5 | import org.springframework.data.jpa.repository.Query; | 6 | import org.springframework.data.jpa.repository.Query; |
| 6 | import org.springframework.stereotype.Repository; | 7 | import org.springframework.stereotype.Repository; |
| 7 | 8 | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 8 | /** | 11 | /** |
| 9 | * Created by panzhao on 2017/2/14. | 12 | * Created by panzhao on 2017/2/14. |
| 10 | */ | 13 | */ |
| @@ -13,4 +16,8 @@ public interface RealControAuthorityRepository extends BaseRepository<RealContro | @@ -13,4 +16,8 @@ public interface RealControAuthorityRepository extends BaseRepository<RealContro | ||
| 13 | 16 | ||
| 14 | @Query("select t from RealControAuthority t where t.userId=?1") | 17 | @Query("select t from RealControAuthority t where t.userId=?1") |
| 15 | RealControAuthority findByUserId(Integer userId); | 18 | RealControAuthority findByUserId(Integer userId); |
| 19 | + | ||
| 20 | + @Modifying | ||
| 21 | + @Query(value = "delete from RealControAuthority rca where rca.userId = ?1 ") | ||
| 22 | + void deleteRealControAuthorityBylineCodes(int userId); | ||
| 16 | } | 23 | } |
src/main/java/com/bsth/service/ddexam/impl/DdexamServiceImpl.java
| @@ -80,8 +80,8 @@ public class DdexamServiceImpl implements DdexamService { | @@ -80,8 +80,8 @@ public class DdexamServiceImpl implements DdexamService { | ||
| 80 | LineConfigStRepository lineConfigStRepository; | 80 | LineConfigStRepository lineConfigStRepository; |
| 81 | @Autowired | 81 | @Autowired |
| 82 | LineConfigData lineConfigData; | 82 | LineConfigData lineConfigData; |
| 83 | - | ||
| 84 | - | 83 | + @Autowired |
| 84 | + ScheduleRealInfoRepository scheduleRealInfoRepository; | ||
| 85 | 85 | ||
| 86 | @Autowired | 86 | @Autowired |
| 87 | LineConfigRepository lineConfigRepository; | 87 | LineConfigRepository lineConfigRepository; |
| @@ -248,7 +248,7 @@ public class DdexamServiceImpl implements DdexamService { | @@ -248,7 +248,7 @@ public class DdexamServiceImpl implements DdexamService { | ||
| 248 | List<SysUser> finalUserList = userList; | 248 | List<SysUser> finalUserList = userList; |
| 249 | new Thread() { | 249 | new Thread() { |
| 250 | public synchronized void run() { | 250 | public synchronized void run() { |
| 251 | - if (snt(finalUserList)) { | 251 | + if (snt(finalUserList,false)) { |
| 252 | kk(); | 252 | kk(); |
| 253 | } | 253 | } |
| 254 | } | 254 | } |
| @@ -336,11 +336,11 @@ public class DdexamServiceImpl implements DdexamService { | @@ -336,11 +336,11 @@ public class DdexamServiceImpl implements DdexamService { | ||
| 336 | } | 336 | } |
| 337 | //已创建好的用户分配排班 | 337 | //已创建好的用户分配排班 |
| 338 | 338 | ||
| 339 | - public Boolean snt(List<SysUser> userList){ | 339 | + public Boolean snt(List<SysUser> userList,boolean type){ |
| 340 | for (int i = 0 ; i < userList.size() ; i++ ){ //已rs人数为准 | 340 | for (int i = 0 ; i < userList.size() ; i++ ){ //已rs人数为准 |
| 341 | SysUser user = userList.get(i); | 341 | SysUser user = userList.get(i); |
| 342 | if (realControAuthorityRepository.findByUserId(user.getId()) != null) { | 342 | if (realControAuthorityRepository.findByUserId(user.getId()) != null) { |
| 343 | - useryType(user); | 343 | + useryType(user,type); |
| 344 | System.out.println("分配班次..."); | 344 | System.out.println("分配班次..."); |
| 345 | sysUserRepository.changeKsStatus(user.getId()); ////状态 表示今日账户已用 | 345 | sysUserRepository.changeKsStatus(user.getId()); ////状态 表示今日账户已用 |
| 346 | } | 346 | } |
| @@ -348,13 +348,20 @@ public class DdexamServiceImpl implements DdexamService { | @@ -348,13 +348,20 @@ public class DdexamServiceImpl implements DdexamService { | ||
| 348 | return true; | 348 | return true; |
| 349 | } | 349 | } |
| 350 | 350 | ||
| 351 | - | ||
| 352 | - public Boolean useryType(SysUser user){ | 351 | + //type true:考试 false:练习 考试只初始化A线路排班 |
| 352 | + public Boolean useryType(SysUser user,boolean type){ | ||
| 353 | RealControAuthority hoit = realControAuthorityRepository.findByUserId(user.getId()); | 353 | RealControAuthority hoit = realControAuthorityRepository.findByUserId(user.getId()); |
| 354 | String[] st = hoit.getLineCodeStr().split(","); | 354 | String[] st = hoit.getLineCodeStr().split(","); |
| 355 | - for (int k = 0 ; k < st.length ; k++){ | ||
| 356 | - Line l = lineRepository.findById(Integer.parseInt(st[k])).get(); | ||
| 357 | - inforealType(l); | 355 | + if(!type){ |
| 356 | + for (int k = 0 ; k < st.length ; k++){ | ||
| 357 | + Line l = lineRepository.findById(Integer.parseInt(st[k])).get(); | ||
| 358 | + inforealType(l); | ||
| 359 | + } | ||
| 360 | + }else { | ||
| 361 | + if(st.length>0){ | ||
| 362 | + Line l = lineRepository.findById(Integer.parseInt(st[0])).get(); | ||
| 363 | + inforealType(l); | ||
| 364 | + } | ||
| 358 | } | 365 | } |
| 359 | return true; | 366 | return true; |
| 360 | } | 367 | } |
| @@ -522,4 +529,13 @@ public class DdexamServiceImpl implements DdexamService { | @@ -522,4 +529,13 @@ public class DdexamServiceImpl implements DdexamService { | ||
| 522 | //-------------------分配本次线调权限-----------------------// | 529 | //-------------------分配本次线调权限-----------------------// |
| 523 | return true; | 530 | return true; |
| 524 | } | 531 | } |
| 532 | + | ||
| 533 | + public synchronized void clearScheduleRealInfo(SysUser user){ | ||
| 534 | + RealControAuthority hoit = realControAuthorityRepository.findByUserId(user.getId()); | ||
| 535 | + String[] st = hoit.getLineCodeStr().split(","); | ||
| 536 | + List<String> lines=Arrays.asList(st); | ||
| 537 | + //bsth_c_s_sp_info_real | ||
| 538 | + scheduleRealInfoRepository.deleteScheduleRealInfoBylineCodes(lines); | ||
| 539 | + } | ||
| 540 | + | ||
| 525 | } | 541 | } |
src/main/java/com/bsth/service/subject/impl/SubjectUserServiceImpl.java
| @@ -10,6 +10,7 @@ import com.bsth.repository.LineRepository; | @@ -10,6 +10,7 @@ import com.bsth.repository.LineRepository; | ||
| 10 | import com.bsth.repository.subject.SubjectUserRepository; | 10 | import com.bsth.repository.subject.SubjectUserRepository; |
| 11 | import com.bsth.repository.sys.SysUserRepository; | 11 | import com.bsth.repository.sys.SysUserRepository; |
| 12 | import com.bsth.security.util.SecurityUtils; | 12 | import com.bsth.security.util.SecurityUtils; |
| 13 | +import com.bsth.service.ddexam.impl.DdexamServiceImpl; | ||
| 13 | import com.bsth.service.impl.BaseServiceImpl; | 14 | import com.bsth.service.impl.BaseServiceImpl; |
| 14 | import com.bsth.service.subject.SubjectUserService; | 15 | import com.bsth.service.subject.SubjectUserService; |
| 15 | import com.bsth.util.subject.subEnum; | 16 | import com.bsth.util.subject.subEnum; |
| @@ -39,6 +40,10 @@ public class SubjectUserServiceImpl extends BaseServiceImpl<SubjectUser, Integer | @@ -39,6 +40,10 @@ public class SubjectUserServiceImpl extends BaseServiceImpl<SubjectUser, Integer | ||
| 39 | @Autowired | 40 | @Autowired |
| 40 | SysUserRepository sysUserRepository; | 41 | SysUserRepository sysUserRepository; |
| 41 | 42 | ||
| 43 | + @Autowired | ||
| 44 | + DdexamServiceImpl ddexamService; | ||
| 45 | + | ||
| 46 | + | ||
| 42 | public List<SubjectUser> userAll(){ | 47 | public List<SubjectUser> userAll(){ |
| 43 | SysUser user = SecurityUtils.getCurrentUser(); | 48 | SysUser user = SecurityUtils.getCurrentUser(); |
| 44 | Integer userId = user.getId(); | 49 | Integer userId = user.getId(); |
| @@ -213,8 +218,11 @@ public class SubjectUserServiceImpl extends BaseServiceImpl<SubjectUser, Integer | @@ -213,8 +218,11 @@ public class SubjectUserServiceImpl extends BaseServiceImpl<SubjectUser, Integer | ||
| 213 | for (SysUser user : userList) { | 218 | for (SysUser user : userList) { |
| 214 | userIds.add(user.getId()); | 219 | userIds.add(user.getId()); |
| 215 | } | 220 | } |
| 221 | + //清除考生考题 | ||
| 216 | subjectUserRepository.deleteSubjectUserByUserIds(rq,userIds); | 222 | subjectUserRepository.deleteSubjectUserByUserIds(rq,userIds); |
| 217 | for (SysUser user : userList) { | 223 | for (SysUser user : userList) { |
| 224 | + //清除考生排班 | ||
| 225 | + ddexamService.clearScheduleRealInfo(user); | ||
| 218 | for (String s : arr) { | 226 | for (String s : arr) { |
| 219 | SubjectUser subjectUser=new SubjectUser(); | 227 | SubjectUser subjectUser=new SubjectUser(); |
| 220 | subjectUser.setUserId(user.getId()); | 228 | subjectUser.setUserId(user.getId()); |
| @@ -226,5 +234,13 @@ public class SubjectUserServiceImpl extends BaseServiceImpl<SubjectUser, Integer | @@ -226,5 +234,13 @@ public class SubjectUserServiceImpl extends BaseServiceImpl<SubjectUser, Integer | ||
| 226 | subjectUserRepository.save(subjectUser); | 234 | subjectUserRepository.save(subjectUser); |
| 227 | } | 235 | } |
| 228 | } | 236 | } |
| 237 | + //初始化考生排班 只初始化A线 | ||
| 238 | + new Thread() { | ||
| 239 | + public synchronized void run() { | ||
| 240 | + if (ddexamService.snt(userList,true)) { | ||
| 241 | + ddexamService.kk(); | ||
| 242 | + } | ||
| 243 | + } | ||
| 244 | + }.start(); | ||
| 229 | } | 245 | } |
| 230 | } | 246 | } |