智慧保安后台管理-外网
Administrator
2022-05-09 3ffd660f8ae78880695fcee78fb16565cf61576d
模拟考试修改
9 files modified
194 ■■■■ changed files
src/main/java/org/springblade/modules/FTP/DataHandler.java 19 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/FTP/Monitor.java 4 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java 10 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/simulateexam/service/impl/SimulateExamRecordServiceImpl.java 95 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/controller/UserController.java 35 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/dto/UserDTO.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/service/MyAsyncService.java 3 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java 12 ●●●● patch | view | raw | blame | history
src/main/resources/application-test.yml 14 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/FTP/DataHandler.java
@@ -6,6 +6,7 @@
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.service.IUserService;
import org.springblade.modules.system.service.MyAsyncService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
@@ -33,6 +34,9 @@
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private MyAsyncService myAsyncService;
    /**
     * 初始化
@@ -42,6 +46,7 @@
        handler = this;
        handler.userService = this.userService;
        handler.redisTemplate = this.redisTemplate;
        handler.myAsyncService = this.myAsyncService;
    }
    /**
@@ -113,6 +118,9 @@
//                boolean save = handler.userService.insert(user);
                boolean save = handler.userService.save(user);
                if (save){
                    //异步同步到群防群控
                    handler.myAsyncService.qfqkUserSave(user);
                    //返回
                    return new Result(200,null,"新增成功",null);
                }else {
                    return new Result(400,null,"新增失败",null);
@@ -125,6 +133,9 @@
                //数据修改
                boolean b = handler.userService.updateById(user);
                if (b) {
                    //异步同步到群防群控
                    handler.myAsyncService.updateUserByQfqk(user);
                    //返回
                    return new Result(200, null, "修改成功", null);
                } else {
                    return new Result(400, null, "修改失败", null);
@@ -136,6 +147,10 @@
                user.setId(result.getUserId());
                //插入数据库
                boolean save = handler.userService.save(user);
                if (save) {
                    //异步同步到群防群控
                    handler.myAsyncService.qfqkUserSave(user);
                }
                //失败,返回保安员证编号校验失败消息
                return new Result(203,null,result.getMsg(),null);
            }else if (result.getCode()==204){
@@ -145,6 +160,10 @@
                user.setId(result.getUserId());
                //数据修改
                boolean b = handler.userService.updateById(user);
                if (b){
                    //异步同步到群防群控
                    handler.myAsyncService.updateUserByQfqk(user);
                }
                //失败,返回保安员证编号校验失败消息
                return new Result(202,null,result.getMsg(),null);
            }else {
src/main/java/org/springblade/modules/FTP/Monitor.java
@@ -17,7 +17,7 @@
import static org.springblade.common.config.FtpConfig.*;
/**
 * FTP读取文件
 * FTP 监听器,监听文件
 * @author
 * @since 2021-04-26 修改
 */
@@ -25,7 +25,7 @@
public class Monitor {
    /**
     * 读取文件(对象)
     * 读取文件(用户对象)单用户新增
     * @param uuid 随机数
     * @return
     */
src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java
@@ -122,6 +122,7 @@
    public Boolean saveExamScore(ExamScoreVO examScore) {
        //取出考试结果
        if (examScore.getExamResultVOS().size() > 0) {
            ExamScore score = this.getById(examScore.getId());
            List<ExamResultVO> examResultVOS = examScore.getExamResultVOS();
            //获取试卷的内容(题号,答案)
//            ExamPaper examPaper = new ExamPaper();
@@ -193,10 +194,11 @@
            }
            //培训考试
            if (paper.getExamType() == 2) {
                TrainingRegistration trainingRegistration = new TrainingRegistration();
                trainingRegistration.setCandidateNo(examScore.getCandidateNo());
                trainingRegistration.setCancel(1);
                TrainingRegistration trainingRegistration1 = trainingRegistrationService.getOne(Condition.getQueryWrapper(trainingRegistration));
//                TrainingRegistration trainingRegistration = new TrainingRegistration();
//                trainingRegistration.setCandidateNo(examScore.getCandidateNo());
//                trainingRegistration.setCancel(1);
//                TrainingRegistration trainingRegistration1 = trainingRegistrationService.getOne(Condition.getQueryWrapper(trainingRegistration));
                TrainingRegistration trainingRegistration1 = trainingRegistrationService.getById(score.getApplyId());
                //查询用户年龄,根据年龄计算总分
                user = userService.getUserAgeById(Long.parseLong(trainingRegistration1.getUserId()));
                //修改用户的培训状态,理论考试结束
src/main/java/org/springblade/modules/simulateexam/service/impl/SimulateExamRecordServiceImpl.java
@@ -85,18 +85,13 @@
        //创建返回信息map
        Map<String, Object> map = new HashMap<>();
        //使用身份证号码匹配人员信息(user_id)
        User user = new User();
        user.setIsDeleted(0);
        user.setStatus(1);
        user.setCardid(simulateExamRecord.getIdCardNo());
        List<User> list = userService.list(Condition.getQueryWrapper(user));
        List<ExamSubjectChoicesVO> choicesVOList = new ArrayList<>();
        User user = userService.getById(simulateExamRecord.getIdCardNo());
        boolean status = false;
        if (list.size()>0){
            User user1 = list.get(0);
        List<ExamSubjectChoicesVO> choicesVOList = new ArrayList<>();
        if (null!=user){
            //查询当前人员是否已缴费
            VipTopic vipTopic = new VipTopic();
            vipTopic.setUserId(user1.getId());
            vipTopic.setUserId(user.getId());
            VipTopic topic = vipTopicService.getOne(Condition.getQueryWrapper(vipTopic));
            //从当前人员考试题库随机取60题存入
            if (null!=topic){
@@ -156,6 +151,88 @@
        return map;
    }
//    /**
//     * 首次点击开始考试,创建模拟考试,并返回考试
//     * @param simulateExamRecord 模拟考试记录对象信息
//     * @return
//     */
//    @Override
//    public Object insertSimulateExamRecord(SimulateExamRecord simulateExamRecord) {
//        //创建返回信息map
//        Map<String, Object> map = new HashMap<>();
//        //使用身份证号码匹配人员信息(user_id)
//        User user = new User();
//        user.setIsDeleted(0);
//        user.setStatus(1);
//        user.setCardid(simulateExamRecord.getIdCardNo());
//        List<User> list = userService.list(Condition.getQueryWrapper(user));
//        List<ExamSubjectChoicesVO> choicesVOList = new ArrayList<>();
//        boolean status = false;
//        if (list.size()>0){
//            User user1 = list.get(0);
//            //查询当前人员是否已缴费
//            VipTopic vipTopic = new VipTopic();
//            vipTopic.setUserId(user1.getId());
//            VipTopic topic = vipTopicService.getOne(Condition.getQueryWrapper(vipTopic));
//            //从当前人员考试题库随机取60题存入
//            if (null!=topic){
//                List<String> list1 = Arrays.asList(topic.getTopicIds().split(","));
//                //获取随机的题目
//                List<String> radio = list1.subList(0, 49);
//                List<String> checkbox = list1.subList(50, 69);
//                List<String> judge = list1.subList(70, 109);
//                List<String> sort = list1.subList(110, 119);
//                //随机题目
//                List<ExamSubjectChoicesVO> radioRandomSubjectList = examPaperService.queryRandomSubjectList(radio,25);
//                List<ExamSubjectChoicesVO> checkboxRandomSubjectList = examPaperService.queryRandomSubjectList(checkbox,10);
//                List<ExamSubjectChoicesVO> judgeRandomSubjectList = examPaperService.queryRandomSubjectList(judge,20);
//                List<ExamSubjectChoicesVO> sortRandomSubjectList = examPaperService.queryRandomSubjectList(sort,5);
//
//                //合并集合数据
//                choicesVOList.addAll(radioRandomSubjectList);
//                choicesVOList.addAll(checkboxRandomSubjectList);
//                choicesVOList.addAll(judgeRandomSubjectList);
//                choicesVOList.addAll(sortRandomSubjectList);
//            }else {
//                //未缴费人员从大题库随机抽取60道题目
//                choicesVOList = examPaperService.simulateQueryRandomSubjectList();
//            }
//            //取出考试id
//            List<Long> longList = choicesVOList.stream().map(ExamSubjectChoicesVO::getId).collect(Collectors.toList());
//            //装换为字符串
//            List<String> list2 = new ArrayList<>();
//            for (Long aLong : longList) {
//                list2.add(aLong.toString());
//            }
//            String collect = list2.stream().collect(Collectors.joining(","));
//            //设置题目信息
//            simulateExamRecord.setSubjectIds(collect);
//            simulateExamRecord.setStartTime(new Date());
//            //考试剩余时长初始值为60分钟
//            simulateExamRecord.setAnswerTime(60*60*1000L);
//            //考试中,开始计时
//            simulateExamRecord.setStatus(1);
//            //新增模拟考试记录信息
//            status = this.save(simulateExamRecord);
//
////                ExamSubjectChoices examSubjectChoices = new ExamSubjectChoices();
////                examSubjectChoices.setId(choicesVOList.get(0).getId());
////                ExamSubjectChoicesVO examSubjectChoicesVO = examSubjectChoicesService.selectExamSubjectChoicesInfo(examSubjectChoices);
//            if (status){
//                map.put("simulateExamRecord",simulateExamRecord);
//                map.put("examSubjectInfo",choicesVOList);
////                    map.put("examSubjectChoicesVO",examSubjectChoicesVO);
//                //返回信息
//                return map;
//            }
//        }else {
//            throw new ServiceException("未查询到该人员信息");
//        }
//        //返回数据
//        return map;
//    }
    /**
     * 暂停模拟考试
     * @param simulateExamRecord
src/main/java/org/springblade/modules/system/controller/UserController.java
@@ -572,6 +572,41 @@
        return R.data(200,null,"修改成功!");
    }
    /**
     * 账号修改
     * @param user
     * @return
     */
    @PostMapping("/update_account")
    public R updataAccount(@RequestBody User user){
        boolean status = false;
        //校验账户是否重复
        User user1 = new User();
        user1.setIsDeleted(0);
        user1.setStatus(1);
        user1.setAccount(user.getAccount());
        List<User> list = userService.list(new QueryWrapper<>(user1));
        if (list.size()>0){
            throw new ServiceException("账号:["+user.getAccount()+"]已存在!");
        }
        //如果不重复,则进行修改操作
        //更新用户账户信息
        status = userService.updateById(user);
        if (status){
            System.out.println("user = " + user);
            UserDTO userDTO = new UserDTO();
            userDTO.setAccount(user.getAccount());
            userDTO.setPassword(user.getPassword());
            userDTO.setSecurityId(user.getId().toString());
            userDTO.setPhone(user.getPhone());
            userDTO.setAvatar(user.getAvatar());
            //异步修改群防群控
            myAsyncService.updateUserByAccount(userDTO);
        }
        //返回
        return R.status(status);
    }
    /**
     * 修改
src/main/java/org/springblade/modules/system/dto/UserDTO.java
@@ -47,4 +47,6 @@
    private String cardid;
    private String oldCardid;
    private String securityId;
}
src/main/java/org/springblade/modules/system/service/MyAsyncService.java
@@ -35,6 +35,7 @@
        userDTO.setPhone(user.getPhone());
        userDTO.setIsDeleted(user.getIsDeleted());
        userDTO.setRealName(user.getRealName());
        userDTO.setSecurityId(user.getId().toString());
        //装换为 json
        JSONObject jsonObject = JSONObject.fromObject(userDTO);
        //发送请求
@@ -62,6 +63,7 @@
        userDTO.setSex(user.getSex());
        userDTO.setAvatar(user.getAvatar());
        userDTO.setExamination_type(user.getExaminationType());
        userDTO.setSecurityId(user.getId().toString());
        //装换为 json
        JSONObject jsonObject = JSONObject.fromObject(userDTO);
        //发送请求
@@ -156,6 +158,7 @@
            userDTO.setPhone(user.getPhone());
            userDTO.setIsDeleted(user.getIsDeleted());
            userDTO.setRealName(user.getRealName());
            userDTO.setSecurityId(user.getId().toString());
            //装换为 json
            JSONObject jsonObject = JSONObject.fromObject(userDTO);
            //发送请求
src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
@@ -1656,14 +1656,22 @@
                    User user = handlerUserInfo(uuid);
                    if (result1.getCode()==200){
                        user.setId(result1.getUserId());
                        this.save(user);
                        boolean save = this.save(user);
                        if (save){
                            //数据异步同步到群防群控
                            myAsyncService.qfqkUserSave(user);
                        }
                        //加入新增集合
//                        addList.add(user);
                    }
                    if (result1.getCode()==201){
                        user.setId(result1.getUserId());
                        user.setCreateTime(null);
                        this.updateById(user);
                        boolean update = this.updateById(user);
                        if (update){
                            //数据异步同步到群防群控
                            myAsyncService.updateUserByQfqk(user);
                        }
                        //加入更新集合
//                        updateList.add(user);
                    }
src/main/resources/application-test.yml
@@ -13,9 +13,9 @@
    #  commandTimeout: 5000
  datasource:
    # MySql
    url: jdbc:mysql://122.112.189.74:3306/zhbaw?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
    username: zhbaw
    password: Zhba@0426
    url: jdbc:mysql://36.134.81.48:3306/zhbaw-test?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
    username: root
    password: jfpt123
    # rabbitmq 设置
#  rabbitmq:
#    host: 192.168.0.191
@@ -54,7 +54,7 @@
#ftp 设置
ftp:
  sqlConnect: jdbc:mysql://122.112.189.74:3306/zhbaw?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
  sqlConnect: jdbc:mysql://36.134.81.48:3306/zhbaw-test?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
  ftpHost: 192.168.0.198
  ftpPort: 21
  ftpUserName: arsn
@@ -63,9 +63,9 @@
  localPath: E:\\anbao\\
  ip: http://61.131.136.25:2081
  jsonUrl: E:\\anbao\\
  username: zhbaw
  password: Zhba@0426
  qfqkBaseApiUrl: http://192.168.0.198:83
  username: root
  password: jfpt123
  qfqkBaseApiUrl: http://localhost:83
#  qfqkBaseApiUrl : http://61.131.136.25:2082/api
#第三方登陆