智慧保安后台管理-外网
Administrator
2022-01-20 cb04ed62736efe70cf5babe534220b4ae4c1ca67
src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java
@@ -18,9 +18,12 @@
import org.springblade.modules.exam.service.ExamScoreService;
import org.springblade.modules.exam.service.ExamSubjectChoicesService;
import org.springblade.modules.exam.util.SecurityPaperUtil;
import org.springblade.modules.exam.vo.ExamResultVO;
import org.springblade.modules.exam.vo.ExamScoreVO;
import org.springblade.modules.exam.vo.UpdateParamVo;
import org.springblade.modules.exam.vo.*;
import org.springblade.modules.information.entity.Information;
import org.springblade.modules.information.service.IInformationService;
import org.springblade.modules.information.vo.InformationVO;
import org.springblade.modules.securitypaper.entity.SecurityPaper;
import org.springblade.modules.securitypaper.service.SecurityPaperService;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.service.IRoleService;
import org.springblade.modules.system.service.IUserService;
@@ -61,11 +64,15 @@
   private TrainingRegistrationService trainingRegistrationService;
   @Autowired
   private IRoleService roleService;
   private SecurityPaperService securityPaperService;
   @Autowired
   private ExamAnswerRecordService examAnswerRecordService;
   @Autowired
   private IInformationService informationService;
   /**
    * 自定义分页数据
@@ -273,45 +280,72 @@
                     if (null!=examScore) {
                        //查询当前保安信息
                        UserVO user = userService.getUserAgeById(Long.parseLong(examScore.getUserId()));
                        //设置实操成绩
                        examScore.setLearnGrade(examScoreExcel.getLearnGrade());
                        if (examScore.getTheoryGrade() >= 60 && examScore.getLearnGrade() >= 60) {
                           //合格
                           examScore.setQualified(0);
                           //修改制证状态为未制证
                           user.setUserType(7);
                           //正式考试通过生成保安证编号
//                     if (examPaper.getExamType()==1) {
                           //如果已有保安证编号,不更新用户信息
                           if (null==user.getSecuritynumber() || user.getSecuritynumber().equals("")) {
                              //去生成保安证编号
                              String pre = SecurityPaperUtil.getSecurityPaper();
                              //查询当前年份已有的保安证编号
                              int count = userService.getSecurityPaperCount(pre);
                              String result = null;
                              if (count == 0) {
                                 result = pre + "00001";
                              } else {
                                 //格式化
                                 DecimalFormat decimalFormat = new DecimalFormat("00000");
                                 count++;
                                 result = pre + (decimalFormat.format(count));
                              }
                              user.setSecuritynumber(result);
                              //发证日期
//                        user.setPaperTime(new Date());
                              //修改为持证保安
                              user.setHold("1");
                              user.setUpdateTime(new Date());
                              //更新保安数据
                              userService.updateById(user);
                        if (null!=examScore.getTheoryGrade()){
                           if (examScore.getTheoryGrade() >= 60 && examScore.getLearnGrade() >= 60) {
                              //合格
                              examScore.setQualified(0);
                              //修改制证状态为未制证
                              user.setUserType(7);
                              //如果已有保安证编号,不更新用户信息
                              if (null == user.getSecuritynumber() || user.getSecuritynumber().equals("")) {
                                 //去生成保安证编号
                                 String pre = SecurityPaperUtil.getSecurityPaper();
                                 //查询当前年份已有的保安证编号
                                 int count = userService.getSecurityPaperCount(pre);
                                 String result = null;
                                 if (count == 0) {
                                    result = pre + "00001";
                                 } else {
                                    //格式化
                                    DecimalFormat decimalFormat = new DecimalFormat("00000");
                                    count++;
                                    result = pre + (decimalFormat.format(count));
                                 }
                                 user.setSecuritynumber(result);
                                 //修改为持证保安
                                 user.setHold("1");
                                 user.setUpdateTime(new Date());
                                 //更新保安数据
                                 userService.updateById(user);
                              String s1 =
                                 "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);
                                 //生成保安证的同时向保安证管理表中插入一条数据
                                 SecurityPaper securityPaper = new SecurityPaper();
                                 securityPaper.setUserId(user.getId());
                                 securityPaper.setNumber(result);
                                 securityPaper.setCreateTime(new Date());
                                 securityPaper.setIdCardNo(user.getCardid());
                                 securityPaper.setPeopleName(user.getRealName());
                                 securityPaper.setExamId(Long.parseLong(examScore.getExamId()));
                                 securityPaper.setApplyId(examScore.getApplyId());
                                 //新增保安员证信息
                                 securityPaperService.save(securityPaper);
                                 String s1 =
                                    "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() + "'";
//                                 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);
                              }
                           }
                        } else {
                           //不合格
@@ -455,8 +489,8 @@
   }
   @Override
   public IPage<ExamScoreVO> scorePage(IPage page, String deptid, String jurisdiction) {
      return page.setRecords(baseMapper.scorePage(page,deptid,jurisdiction));
   public IPage<ExamScoreVO> scorePage(IPage page, ExamScoreVO examScore) {
      return page.setRecords(baseMapper.scorePage(page,examScore));
   }
   /**
@@ -797,4 +831,52 @@
      }
      return false;
   }
   /**
    * 考试情况统计,按月统计各个培训学校考试合格人数和不合格人数
    * @param
    */
   @Override
   public Object getExamStatisInfo(InformationVO information) {
      //获取培训学校信息
      Information information2 = new Information();
      information2.setStats("1");
      List<Information> informationList = informationService.list(Condition.getQueryWrapper(information2));
      //创建 objectList 集合
      List<Object> objectList = new ArrayList<>();
      for (Information information1 : informationList) {
         //查询各个培训学校本年每月考试情况统计,不是测试学校
         if(!information1.getId().equals(469)) {
            //合格和不合格
            ExamSocreStatisVo statisVo = new ExamSocreStatisVo();
            ExamSocreStatisVo statisVo1 = new ExamSocreStatisVo();
            information.setDepartmentid(information1.getDepartmentid());
            //统计数据查询
            List<ExamSocreStatis> examStatisInfo = baseMapper.getExamStatisInfo(information);
            //数据转换
            List<Integer> list = new ArrayList<>();
            List<Integer> list1 = new ArrayList<>();
            for (ExamSocreStatis examSocreStatis : examStatisInfo) {
               //合格人数集合
               list.add(examSocreStatis.getHgnum());
               //不合格人数集合
               list1.add(examSocreStatis.getBhgnum());
            }
            //合格
            statisVo.setName(information1.getEnterprisename());
            statisVo.setType(1);
            statisVo.setExamSocreStatis(list);
            //不合格
            statisVo1.setName(information1.getEnterprisename());
            statisVo1.setType(2);
            statisVo1.setExamSocreStatis(list1);
            //数据封装
            objectList.add(statisVo);
            objectList.add(statisVo1);
         }
      }
      //返回数据
      return objectList;
   }
}