Commit cdefa307b8cc260dd760d0ade53068723a8ff13b

Authored by yiming
1 parent 93a5e244

考试排班初始化

src/main/java/com/bsth/repository/LineInformationRepository.java
... ... @@ -2,6 +2,7 @@ package com.bsth.repository;
2 2  
3 3 import java.util.List;
4 4  
  5 +import org.springframework.data.jpa.repository.Modifying;
5 6 import org.springframework.data.jpa.repository.Query;
6 7 import org.springframework.stereotype.Repository;
7 8  
... ... @@ -31,4 +32,8 @@ public interface LineInformationRepository extends BaseRepository<LineInformatio
31 32 List<LineInformation> findByLine(List<String> lineCodes);
32 33  
33 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&lt;Line, Integer&gt; {
101 101 @Query(value = "UPDATE bsth_c_line_file_version set version_count=?2 WHERE line = ?1", nativeQuery = true)
102 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&lt;StationRoute, Int
508 508 @Modifying
509 509 @Query(value="update bsth_c_stationroute set industry_code =?2 where id = ?1 ", nativeQuery=true)
510 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 import org.springframework.data.domain.Pageable;
7 7 import org.springframework.data.jpa.domain.Specification;
8 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 11 import org.springframework.stereotype.Repository;
10 12  
11 13 import com.bsth.entity.realcontrol.LineConfig;
... ... @@ -26,4 +28,8 @@ public interface LineConfigRepository extends BaseRepository&lt;LineConfig, Integer
26 28 @Override
27 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&lt;ScheduleRealI
240 240 @Query(value="select count(*) from ScheduleRealInfo s where s.scheduleDateStr = ?1 and s.xlBm = ?2")
241 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 2  
3 3 import com.bsth.entity.sys.RealControAuthority;
4 4 import com.bsth.repository.BaseRepository;
  5 +import org.springframework.data.jpa.repository.Modifying;
5 6 import org.springframework.data.jpa.repository.Query;
6 7 import org.springframework.stereotype.Repository;
7 8  
  9 +import java.util.List;
  10 +
8 11 /**
9 12 * Created by panzhao on 2017/2/14.
10 13 */
... ... @@ -13,4 +16,8 @@ public interface RealControAuthorityRepository extends BaseRepository&lt;RealContro
13 16  
14 17 @Query("select t from RealControAuthority t where t.userId=?1")
15 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 80 LineConfigStRepository lineConfigStRepository;
81 81 @Autowired
82 82 LineConfigData lineConfigData;
83   -
84   -
  83 + @Autowired
  84 + ScheduleRealInfoRepository scheduleRealInfoRepository;
85 85  
86 86 @Autowired
87 87 LineConfigRepository lineConfigRepository;
... ... @@ -248,7 +248,7 @@ public class DdexamServiceImpl implements DdexamService {
248 248 List<SysUser> finalUserList = userList;
249 249 new Thread() {
250 250 public synchronized void run() {
251   - if (snt(finalUserList)) {
  251 + if (snt(finalUserList,false)) {
252 252 kk();
253 253 }
254 254 }
... ... @@ -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 340 for (int i = 0 ; i < userList.size() ; i++ ){ //已rs人数为准
341 341 SysUser user = userList.get(i);
342 342 if (realControAuthorityRepository.findByUserId(user.getId()) != null) {
343   - useryType(user);
  343 + useryType(user,type);
344 344 System.out.println("分配班次...");
345 345 sysUserRepository.changeKsStatus(user.getId()); ////状态 表示今日账户已用
346 346 }
... ... @@ -348,13 +348,20 @@ public class DdexamServiceImpl implements DdexamService {
348 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 353 RealControAuthority hoit = realControAuthorityRepository.findByUserId(user.getId());
354 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 366 return true;
360 367 }
... ... @@ -522,4 +529,13 @@ public class DdexamServiceImpl implements DdexamService {
522 529 //-------------------分配本次线调权限-----------------------//
523 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 10 import com.bsth.repository.subject.SubjectUserRepository;
11 11 import com.bsth.repository.sys.SysUserRepository;
12 12 import com.bsth.security.util.SecurityUtils;
  13 +import com.bsth.service.ddexam.impl.DdexamServiceImpl;
13 14 import com.bsth.service.impl.BaseServiceImpl;
14 15 import com.bsth.service.subject.SubjectUserService;
15 16 import com.bsth.util.subject.subEnum;
... ... @@ -39,6 +40,10 @@ public class SubjectUserServiceImpl extends BaseServiceImpl&lt;SubjectUser, Integer
39 40 @Autowired
40 41 SysUserRepository sysUserRepository;
41 42  
  43 + @Autowired
  44 + DdexamServiceImpl ddexamService;
  45 +
  46 +
42 47 public List<SubjectUser> userAll(){
43 48 SysUser user = SecurityUtils.getCurrentUser();
44 49 Integer userId = user.getId();
... ... @@ -213,8 +218,11 @@ public class SubjectUserServiceImpl extends BaseServiceImpl&lt;SubjectUser, Integer
213 218 for (SysUser user : userList) {
214 219 userIds.add(user.getId());
215 220 }
  221 + //清除考生考题
216 222 subjectUserRepository.deleteSubjectUserByUserIds(rq,userIds);
217 223 for (SysUser user : userList) {
  224 + //清除考生排班
  225 + ddexamService.clearScheduleRealInfo(user);
218 226 for (String s : arr) {
219 227 SubjectUser subjectUser=new SubjectUser();
220 228 subjectUser.setUserId(user.getId());
... ... @@ -226,5 +234,13 @@ public class SubjectUserServiceImpl extends BaseServiceImpl&lt;SubjectUser, Integer
226 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 }
... ...