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 | 23 | |
| 24 | 24 | //创建账号 |
| 25 | 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 | 30 | @RequestMapping("initialization2") | ... | ... |
src/main/java/com/bsth/entity/sys/SysUser.java
| 1 | 1 | package com.bsth.entity.sys; |
| 2 | 2 | |
| 3 | +import com.bsth.security.util.SecurityUtils; | |
| 3 | 4 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
| 5 | +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | |
| 4 | 6 | |
| 5 | 7 | import javax.persistence.*; |
| 6 | 8 | import java.io.Serializable; |
| ... | ... | @@ -144,4 +146,16 @@ public class SysUser implements Serializable { |
| 144 | 146 | public void setParentID(String parentID) { |
| 145 | 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
src/main/java/com/bsth/service/ddexam/impl/DdexamServiceImpl.java
| ... | ... | @@ -194,12 +194,12 @@ public class DdexamServiceImpl implements DdexamService { |
| 194 | 194 | //考生人初始化 单线程 测试1:执行中途再次执行是否同步 测试2: |
| 195 | 195 | @Override |
| 196 | 196 | @Transactional //事务 |
| 197 | - public synchronized Map initializationAll(Integer rs,Long userName) { | |
| 197 | + public synchronized Map initializationAll(String name,Long userName) { | |
| 198 | 198 | Long start = System.currentTimeMillis(); |
| 199 | 199 | Map m = new HashMap<>(); |
| 200 | 200 | try { //用户当天分配完直接改状态 无二次分配的可能 |
| 201 | + SysUser loginUser=SecurityUtils.getCurrentUser(); | |
| 201 | 202 | List<SysUser> userList = sysUserRepository.findBySusUserAll(); //已有的用户 不考虑用户角色表 正常情况下创建必分配 |
| 202 | - Map suerMap = new HashMap(); | |
| 203 | 203 | for (SysUser s :userList){ |
| 204 | 204 | if(Long.parseLong(s.getUserName()) == userName ){ |
| 205 | 205 | m.put("code","创建失败 账号重复"); |
| ... | ... | @@ -209,7 +209,8 @@ public class DdexamServiceImpl implements DdexamService { |
| 209 | 209 | |
| 210 | 210 | new Thread() { |
| 211 | 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 | 214 | log.info("考试初始化创建成功"); |
| 214 | 215 | kk(); |
| 215 | 216 | } |
| ... | ... | @@ -358,83 +359,7 @@ public class DdexamServiceImpl implements DdexamService { |
| 358 | 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 | 365 | public void inforealType(Line line){ |
| ... | ... | @@ -495,19 +420,10 @@ public class DdexamServiceImpl implements DdexamService { |
| 495 | 420 | continue; |
| 496 | 421 | textList.add(text + ";"); |
| 497 | 422 | } |
| 498 | - SysUser loginUser = SecurityUtils.getCurrentUser(); | |
| 499 | 423 | for(int i = 0; i < textList.size(); i++) { |
| 500 | 424 | String text = textList.get(i); |
| 501 | 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 | 427 | userList.add(user); |
| 512 | 428 | } |
| 513 | 429 | List<SysUser> users = sysUserRepository.findBySusUserAll(); | ... | ... |
src/main/resources/static/pages/ddexam/index.html
| ... | ... | @@ -55,14 +55,14 @@ |
| 55 | 55 | <div class="tes"> |
| 56 | 56 | <label class="col-md-12 sizell">请输入学号:</label> |
| 57 | 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 | 60 | </div> |
| 61 | 61 | |
| 62 | - <label class="col-md-12 sizell">请输入考试人数:</label> | |
| 62 | + <label class="col-md-12 sizell">请输入姓名:</label> | |
| 63 | 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 | 66 | <h6>人数过大时,耗时较久,请耐心等待</h6> |
| 67 | 67 | </div> |
| 68 | 68 | |
| ... | ... | @@ -140,13 +140,9 @@ |
| 140 | 140 | |
| 141 | 141 | |
| 142 | 142 | function onckil(){ |
| 143 | - if($("#rnumber").val() == undefined || $("#rnumber").val() == null || $("#rnumber").val() == "" || $("#rnumber").val() > 100){ | |
| 144 | - layer.msg('考试人数未输入或人数过大,请正确输入...'); | |
| 145 | - return | |
| 146 | - } | |
| 147 | 143 | var params ={ |
| 148 | 144 | userName : $("#userName").val(), |
| 149 | - rs : $("#rnumber").val() | |
| 145 | + name : $("#name").val() | |
| 150 | 146 | } |
| 151 | 147 | var i = layer.load(2); |
| 152 | 148 | $.post('/ddexam/initialization',params,function(data) { | ... | ... |