智慧保安后台管理-外网
src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java
@@ -4,9 +4,13 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springblade.common.utils.DesensitizedUtil;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.modules.FTP.FtpUtil;
import org.springblade.modules.FTP.Monitor;
import org.springblade.modules.FTP.Result;
import org.springblade.modules.apply.entity.Apply;
import org.springblade.modules.apply.service.ApplyService;
import org.springblade.modules.exam.entity.*;
@@ -187,7 +191,7 @@
            myAsyncService.FTP(s);
         }
         //模拟考试
         //培训考试
         if (paper.getExamType() == 2) {
            TrainingRegistration trainingRegistration = new TrainingRegistration();
            trainingRegistration.setCandidateNo(examScore.getCandidateNo());
@@ -210,7 +214,8 @@
            //FtpUtil.sqlFileUpload(s);
            myAsyncService.FTP(s);
         }
         //设置提交时间
         examScore.setExamEndTime(new Date());
         //设置考试ID
         examScore.setExamId(examScore.getPapersId().toString());
         //设置理论得分
@@ -303,17 +308,51 @@
                                 //去生成保安证编号
                                 String pre = SecurityPaperUtil.getSecurityPaper();
                                 //查询当前年份已有的保安证编号
                                 int count = userService.getSecurityPaperCount(pre);
//                                 int count = userService.getSecurityPaperCount(pre);
                                 //需调用内网查询
                                 //生成随机数
                                 String uuid = UUID.randomUUID().toString();
                                 //数据推送
                                 Map<String, Object> map = new HashMap<>(1);
                                 map.put(uuid,pre);
                                 myAsyncService.FTPSecurityNumberBit(map);
                                 int count = 0;
                                 Result result0 = new Result();
                                 //调用ftp获取返回数据
                                 while (true){
                                    try {
                                       Thread.sleep(1000);
                                    } catch (InterruptedException e) {
                                       e.printStackTrace();
                                    }
                                    //调用ftp获取返回数据
                                    result0 = Monitor.getSecurityNumberBit(uuid);
                                    //如果返回true,就退处
                                    if (result0.getCode()==200){
                                       break;
                                    }else{
                                       //计数
                                       count++;
                                       //如果超过100s 没有读取到,则退出
                                       if (count == 100) {
                                          break;
                                       }
                                    }
                                 }
                                 int max = Integer.parseInt(result0.getMsg());
                                 String result = null;
                                 if (count == 0) {
                                 if (max == 0) {
                                    result = pre + "00001";
                                 } else {
                                    //格式化
                                    DecimalFormat decimalFormat = new DecimalFormat("00000");
                                    count++;
                                    result = pre + (decimalFormat.format(count));
                                    max++;
                                    result = pre + (decimalFormat.format(max));
                                 }
                                 user.setSecuritynumber(result);
                                 //脱敏处理
                                 user.setSecuritynumber(DesensitizedUtil.desensitizedSecurityNumber(result));
                                 //修改为持证保安
                                 user.setHold("1");
                                 user.setUpdateTime(new Date());
@@ -330,32 +369,32 @@
                                 securityPaper.setExamId(Long.parseLong(examScore.getExamId()));
                                 securityPaper.setApplyId(examScore.getApplyId());
                                 securityPaper.setSource(1);
                                 //内网对象
                                 SecurityPaper paper = Objects.requireNonNull(BeanUtil.copy(securityPaper,SecurityPaper.class));
                                 //新增保安员证信息
                                 securityPaper.setNumber(DesensitizedUtil.desensitizedSecurityNumber(result));
                                 securityPaper.setIdCardNo("");
                                 securityPaperService.save(securityPaper);
                                 //设置id
                                 paper.setId(securityPaper.getId());
                                 //内网同步
                                 String s1 =
                                    "insert into sys_security_paper(id,number,create_time,people_name,id_card_no,user_id,apply_id,exam_id,source) " +
                                       "values(" + "'" + paper.getId() + "'"
                                       + "," + "'" + paper.getNumber() +"'"
                                       + "," + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(paper.getCreateTime()) +"'"
                                       + "," + "'" + paper.getPeopleName() + "'"
                                       + "," + "'" + paper.getIdCardNo() + "'"
                                       + "," + "'" + paper.getUserId() + "'"
                                       + "," + "'" + paper.getApplyId() + "'"
                                       + "," + "'" + paper.getExamId() + "'"
                                       + "," +"'" + paper.getSource() + "'" + ");" +
                                    "update blade_user set hold = " + "'" + user.getHold() + "'" +
                                       ",securitynumber = " + "'" + user.getSecuritynumber() + "'" +
                                       ",securitynumber = " + "'" + result + "'" +
                                       ",update_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getUpdateTime()) + "'" +
                                       ",user_type = " + "'" + user.getUserType() + "'" +
                                       " " + "where id = " + "'" + user.getId() + "'";
//                                 String s1 =
//                                    "insert into sys_security_paper(id,number,create_time,people_name,id_card_no,user_id,apply_id,exam_id) " +
//                                       "values(" + "'" + securityPaper.getId() + "'"
//                                       + "," + "'" + securityPaper.getNumber() +"'"
//                                       + "," + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(securityPaper.getCreateTime()) +"'"
//                                       + "," + "'" + securityPaper.getPeopleName() + "'"
//                                       + "," + "'" + securityPaper.getIdCardNo() + "'"
//                                       + "," + "'" + securityPaper.getUserId() + "'"
//                                       + "," + "'" + securityPaper.getApplyId() + "'"
//                                       + "," +"'" + securityPaper.getExamId() + "'" + ");" +
//                                    "update blade_user set hold = " + "'" + user.getHold() + "'" +
//                                       ",securitynumber = " + "'" + user.getSecuritynumber() + "'" +
//                                       ",update_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getUpdateTime()) + "'" +
//                                       ",user_type = " + "'" + user.getUserType() + "'" +
//                                       " " + "where id = " + "'" + user.getId() + "'";
                                 //FtpUtil.sqlFileUpload(s1);
                                 myAsyncService.FTP(s1);
                              }
                           }
@@ -391,7 +430,7 @@
                        //更新成绩数据
                        baseMapper.updateById(examScore);
                     } else {
                        errorList.add(examScoreExcel.getIdCardNo());
                        errorList.add(examScoreExcel.getName());
                        status.set(false);
                     }
                  });