Commit 37a1d1c095f290bd8abc65174562c31d108c7714
1 parent
248d518e
创建考生
Showing
5 changed files
with
27 additions
and
101 deletions
src/main/java/com/bsth/controller/ddexam/DdexamController.java
| @@ -23,8 +23,8 @@ public class DdexamController { | @@ -23,8 +23,8 @@ public class DdexamController { | ||
| 23 | 23 | ||
| 24 | //创建账号 | 24 | //创建账号 |
| 25 | @RequestMapping("initialization") | 25 | @RequestMapping("initialization") |
| 26 | - public Map initializationAll(@RequestParam Integer rs ,@RequestParam Long userName){ | ||
| 27 | - return ddexamService.initializationAll(rs,userName); | 26 | + public Map initializationAll(@RequestParam String name ,@RequestParam Long userName){ |
| 27 | + return ddexamService.initializationAll(name,userName); | ||
| 28 | } | 28 | } |
| 29 | //初始化 | 29 | //初始化 |
| 30 | @RequestMapping("initialization2") | 30 | @RequestMapping("initialization2") |
src/main/java/com/bsth/entity/sys/SysUser.java
| 1 | package com.bsth.entity.sys; | 1 | package com.bsth.entity.sys; |
| 2 | 2 | ||
| 3 | +import com.bsth.security.util.SecurityUtils; | ||
| 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | 4 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
| 5 | +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | ||
| 4 | 6 | ||
| 5 | import javax.persistence.*; | 7 | import javax.persistence.*; |
| 6 | import java.io.Serializable; | 8 | import java.io.Serializable; |
| @@ -144,4 +146,16 @@ public class SysUser implements Serializable { | @@ -144,4 +146,16 @@ public class SysUser implements Serializable { | ||
| 144 | public void setParentID(String parentID) { | 146 | public void setParentID(String parentID) { |
| 145 | this.parentID = parentID; | 147 | this.parentID = parentID; |
| 146 | } | 148 | } |
| 149 | + | ||
| 150 | + public SysUser(){ | ||
| 151 | + } | ||
| 152 | + public SysUser(String name,String userName,SysUser loginUser){ | ||
| 153 | + this.createDate=new Date(); | ||
| 154 | + this.enabled=true; | ||
| 155 | + this.name=name; | ||
| 156 | + this.password=new BCryptPasswordEncoder(4).encode("123456"); | ||
| 157 | + this.userName=userName; | ||
| 158 | + this.ksstatus="1"; //状态 表示今日账户已用 | ||
| 159 | + this.parentID=String.valueOf(loginUser.getId()); | ||
| 160 | + } | ||
| 147 | } | 161 | } |
src/main/java/com/bsth/service/ddexam/DdexamService.java
| @@ -8,7 +8,7 @@ import java.util.Map; | @@ -8,7 +8,7 @@ import java.util.Map; | ||
| 8 | 8 | ||
| 9 | public interface DdexamService { | 9 | public interface DdexamService { |
| 10 | 10 | ||
| 11 | - public Map initializationAll(Integer rs,Long userName); | 11 | + public Map initializationAll(String name,Long userName); |
| 12 | 12 | ||
| 13 | public Map initializationAll2(Long userName); | 13 | public Map initializationAll2(Long userName); |
| 14 | 14 |
src/main/java/com/bsth/service/ddexam/impl/DdexamServiceImpl.java
| @@ -194,12 +194,12 @@ public class DdexamServiceImpl implements DdexamService { | @@ -194,12 +194,12 @@ public class DdexamServiceImpl implements DdexamService { | ||
| 194 | //考生人初始化 单线程 测试1:执行中途再次执行是否同步 测试2: | 194 | //考生人初始化 单线程 测试1:执行中途再次执行是否同步 测试2: |
| 195 | @Override | 195 | @Override |
| 196 | @Transactional //事务 | 196 | @Transactional //事务 |
| 197 | - public synchronized Map initializationAll(Integer rs,Long userName) { | 197 | + public synchronized Map initializationAll(String name,Long userName) { |
| 198 | Long start = System.currentTimeMillis(); | 198 | Long start = System.currentTimeMillis(); |
| 199 | Map m = new HashMap<>(); | 199 | Map m = new HashMap<>(); |
| 200 | try { //用户当天分配完直接改状态 无二次分配的可能 | 200 | try { //用户当天分配完直接改状态 无二次分配的可能 |
| 201 | + SysUser loginUser=SecurityUtils.getCurrentUser(); | ||
| 201 | List<SysUser> userList = sysUserRepository.findBySusUserAll(); //已有的用户 不考虑用户角色表 正常情况下创建必分配 | 202 | List<SysUser> userList = sysUserRepository.findBySusUserAll(); //已有的用户 不考虑用户角色表 正常情况下创建必分配 |
| 202 | - Map suerMap = new HashMap(); | ||
| 203 | for (SysUser s :userList){ | 203 | for (SysUser s :userList){ |
| 204 | if(Long.parseLong(s.getUserName()) == userName ){ | 204 | if(Long.parseLong(s.getUserName()) == userName ){ |
| 205 | m.put("code","创建失败 账号重复"); | 205 | m.put("code","创建失败 账号重复"); |
| @@ -209,7 +209,8 @@ public class DdexamServiceImpl implements DdexamService { | @@ -209,7 +209,8 @@ public class DdexamServiceImpl implements DdexamService { | ||
| 209 | 209 | ||
| 210 | new Thread() { | 210 | new Thread() { |
| 211 | public synchronized void run() { | 211 | public synchronized void run() { |
| 212 | - if(usercreateType(rs,userName)){ | 212 | + SysUser user = new SysUser(name,String.valueOf(userName),loginUser); |
| 213 | + if(createUser(user)){ | ||
| 213 | log.info("考试初始化创建成功"); | 214 | log.info("考试初始化创建成功"); |
| 214 | kk(); | 215 | kk(); |
| 215 | } | 216 | } |
| @@ -358,83 +359,7 @@ public class DdexamServiceImpl implements DdexamService { | @@ -358,83 +359,7 @@ public class DdexamServiceImpl implements DdexamService { | ||
| 358 | return true; | 359 | return true; |
| 359 | } | 360 | } |
| 360 | 361 | ||
| 361 | - //创建考试人数 并分配线路信息 | ||
| 362 | - public synchronized Boolean usercreateType(int st,Long userName){ | ||
| 363 | - int usernum = sysUserRepository.findAll_distinct().size(); | ||
| 364 | - SysUser user = new SysUser();//总人数 | ||
| 365 | - for (int i = 0; i < st; i++) { //创建考试人数 | ||
| 366 | - int username = usernum++; | ||
| 367 | - user = new SysUser(); | ||
| 368 | - user.setCreateDate(new Date()); | ||
| 369 | - user.setEnabled(true); | ||
| 370 | - user.setName(String.valueOf(userName + i)); | ||
| 371 | - user.setPassword(new BCryptPasswordEncoder(4).encode("123456")); | ||
| 372 | - user.setUserName(String.valueOf(userName + i)); | ||
| 373 | - user.setKsstatus("1"); //状态 表示今日账户已用 | ||
| 374 | - sysUserRepository.save(user); //添加 -------**-- | ||
| 375 | - | ||
| 376 | - BsthCSysUserRoles userRoles = new BsthCSysUserRoles(); | ||
| 377 | - userRoles.setUsers(user.getId()); | ||
| 378 | - userRoles.setRoles(73); //统一用73考生 | ||
| 379 | - bsthCSysUserRolesRepository.save(userRoles); //添加 -------**-- | ||
| 380 | - List<LineConfigSt> lineConfigList = lineConfigStRepository.findAll(); //线调 线路相关配置信息 | ||
| 381 | - Integer linebumber = lineRepository.findAll().size(); //线路数量 线路code | ||
| 382 | - String [] mtline = {"A线","B线","C线","D线","E线","F线"}; //对应模板6条线 换成线路name | ||
| 383 | - List<LineInformationSt> litst = (List<LineInformationSt>) LineInformationStRepository.findAll(); //所有模板线路标准和线路 | ||
| 384 | - if(litst.size() != 6){ | ||
| 385 | - return false; | ||
| 386 | - } | ||
| 387 | - String lineCodeStr = ""; | ||
| 388 | - for(int j = 0 ; j < litst.size() ; j++){ //6个 <6 | ||
| 389 | - LineSt linest = litst.get(j).getLine(); //旧line | ||
| 390 | - LineInformationSt Limst = litst.get(j); | ||
| 391 | - Line line = new Line(); | ||
| 392 | - BeanUtils.copyProperties(linest,line); //copy | ||
| 393 | - Integer linecodeId = linebumber++ ; | ||
| 394 | - line.setId(linecodeId); | ||
| 395 | - line.setLineCode(linecodeId.toString()); | ||
| 396 | - line.setName(mtline[j]+"-"+user.getName()); | ||
| 397 | - line.setCoLineCode(linest.getLineCode()); | ||
| 398 | - lineRepository.save(line); //线路添加 | ||
| 399 | - //----------------线路--------------------------// | ||
| 400 | - LineInformation lifat = new LineInformation(); //线路标准 | ||
| 401 | - BeanUtils.copyProperties(Limst,lifat); | ||
| 402 | - lifat.setLine(line); | ||
| 403 | - lineInformationRepository.save(lifat); //线路标准信息条件 | ||
| 404 | - //-------------------线路标准-----------------------// | ||
| 405 | - for(LineConfigSt cfgt : lineConfigList){ | ||
| 406 | - if(cfgt.getLine().getLineCode().equals(linest.getLineCode())){ | ||
| 407 | - LineConfig config = new LineConfig(); | ||
| 408 | - BeanUtils.copyProperties(cfgt,config); //copy | ||
| 409 | - config.setLine(line); | ||
| 410 | - lineConfigRepository.save(config); | ||
| 411 | - } | ||
| 412 | - } | ||
| 413 | - //-------------------线调 线路相关配置信息-----------------------// | ||
| 414 | - | ||
| 415 | - List<StationRouteSt> srstList = stationRouteStRepository.findByLine(linest.getLineCode()); | ||
| 416 | - List<StationRoute> srstListAll = new ArrayList<>(); | ||
| 417 | - for(StationRouteSt route : srstList){ | ||
| 418 | - StationRoute srt = new StationRoute(); | ||
| 419 | - BeanUtils.copyProperties(route,srt); //copy | ||
| 420 | - srt.setLine(line); | ||
| 421 | - srt.setLineCode(linecodeId.toString()); | ||
| 422 | - srstListAll.add(srt); | ||
| 423 | - } | ||
| 424 | - stationRouteRepository.saveAll(srstListAll);//添加站点 | ||
| 425 | - //-------------------站点-----------------------// | ||
| 426 | - lineCodeStr += linecodeId.toString()+","; //线调线路 | ||
| 427 | - inforealType(line); | ||
| 428 | - } | ||
| 429 | - RealControAuthority raty = new RealControAuthority(); | ||
| 430 | - raty.setUserId(user.getId()); | ||
| 431 | - raty.setLineCodeStr(lineCodeStr); | ||
| 432 | - raty.setPattern(1); //可用 | ||
| 433 | - realControAuthorityRepository.save(raty); | ||
| 434 | - //-------------------分配本次线调权限-----------------------// | ||
| 435 | - } | ||
| 436 | - return true; | ||
| 437 | - } | 362 | + |
| 438 | 363 | ||
| 439 | //添加排班 | 364 | //添加排班 |
| 440 | public void inforealType(Line line){ | 365 | public void inforealType(Line line){ |
| @@ -495,19 +420,10 @@ public class DdexamServiceImpl implements DdexamService { | @@ -495,19 +420,10 @@ public class DdexamServiceImpl implements DdexamService { | ||
| 495 | continue; | 420 | continue; |
| 496 | textList.add(text + ";"); | 421 | textList.add(text + ";"); |
| 497 | } | 422 | } |
| 498 | - SysUser loginUser = SecurityUtils.getCurrentUser(); | ||
| 499 | for(int i = 0; i < textList.size(); i++) { | 423 | for(int i = 0; i < textList.size(); i++) { |
| 500 | String text = textList.get(i); | 424 | String text = textList.get(i); |
| 501 | String[] split = text.split(","); | 425 | String[] split = text.split(","); |
| 502 | - SysUser user = new SysUser(); | ||
| 503 | - user.setCreateDate(new Date()); | ||
| 504 | - user.setEnabled(true); | ||
| 505 | - user.setName(split[1].trim()); | ||
| 506 | - user.setPassword(new BCryptPasswordEncoder(4).encode("123456")); | ||
| 507 | - user.setUserName(split[0].trim()); | ||
| 508 | - user.setKsstatus("1"); //状态 表示今日账户已用 | ||
| 509 | - user.setLastLoginDate(new Date()); | ||
| 510 | - user.setParentID(String.valueOf(loginUser.getId())); | 426 | + SysUser user = new SysUser(split[1].trim(),split[0].trim(),SecurityUtils.getCurrentUser()); |
| 511 | userList.add(user); | 427 | userList.add(user); |
| 512 | } | 428 | } |
| 513 | List<SysUser> users = sysUserRepository.findBySusUserAll(); | 429 | List<SysUser> users = sysUserRepository.findBySusUserAll(); |
src/main/resources/static/pages/ddexam/index.html
| @@ -55,14 +55,14 @@ | @@ -55,14 +55,14 @@ | ||
| 55 | <div class="tes"> | 55 | <div class="tes"> |
| 56 | <label class="col-md-12 sizell">请输入学号:</label> | 56 | <label class="col-md-12 sizell">请输入学号:</label> |
| 57 | <div class="col-md-9 scm"> | 57 | <div class="col-md-9 scm"> |
| 58 | - <input id="userName" type="text" class="form-control" name="rnumber" autocomplete="off" oninput="value=value.replace(/[^\d]/g,'')"/> | 58 | + <input id="userName" type="text" class="form-control" name="userName" autocomplete="off" oninput="value=value.replace(/[^\d]/g,'')"/> |
| 59 | 59 | ||
| 60 | </div> | 60 | </div> |
| 61 | 61 | ||
| 62 | - <label class="col-md-12 sizell">请输入考试人数:</label> | 62 | + <label class="col-md-12 sizell">请输入姓名:</label> |
| 63 | <div class="col-md-9 scm"> | 63 | <div class="col-md-9 scm"> |
| 64 | 64 | ||
| 65 | - <input id="rnumber" type="text" class="form-control" name="rnumber" autocomplete="off" oninput="value=value.replace(/[^\d]/g,'')"/> | 65 | + <input id="name" type="text" class="form-control" name="name" autocomplete="off" /> |
| 66 | <h6>人数过大时,耗时较久,请耐心等待</h6> | 66 | <h6>人数过大时,耗时较久,请耐心等待</h6> |
| 67 | </div> | 67 | </div> |
| 68 | 68 | ||
| @@ -140,13 +140,9 @@ | @@ -140,13 +140,9 @@ | ||
| 140 | 140 | ||
| 141 | 141 | ||
| 142 | function onckil(){ | 142 | function onckil(){ |
| 143 | - if($("#rnumber").val() == undefined || $("#rnumber").val() == null || $("#rnumber").val() == "" || $("#rnumber").val() > 100){ | ||
| 144 | - layer.msg('考试人数未输入或人数过大,请正确输入...'); | ||
| 145 | - return | ||
| 146 | - } | ||
| 147 | var params ={ | 143 | var params ={ |
| 148 | userName : $("#userName").val(), | 144 | userName : $("#userName").val(), |
| 149 | - rs : $("#rnumber").val() | 145 | + name : $("#name").val() |
| 150 | } | 146 | } |
| 151 | var i = layer.load(2); | 147 | var i = layer.load(2); |
| 152 | $.post('/ddexam/initialization',params,function(data) { | 148 | $.post('/ddexam/initialization',params,function(data) { |