智慧保安后台管理-外网项目备份
Administrator
2021-08-13 d35732cfbf365e7ef423159a041408dfbe599d43
成绩计算接口修改,通知公告上传接口修改
14 files modified
217 ■■■■ changed files
src/main/java/org/springblade/modules/exam/controller/ExamScoreController.java 42 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/entity/ExamScore.java 10 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/excel/ExamScoreExcel.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml 18 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.xml 14 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/service/ExamPaperService.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/service/impl/ExamPaperServiceImpl.java 10 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java 73 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/vo/ExamScoreVO.java 7 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/location/controller/LiveLocationController.java 1 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/resource/endpoint/OssEndpoint.java 14 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/resource/entity/Attach.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/controller/ExamScoreController.java
@@ -10,9 +10,11 @@
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.exam.entity.ExamPaper;
import org.springblade.modules.exam.entity.ExamScore;
import org.springblade.modules.exam.excel.ExamScoreExcel;
import org.springblade.modules.exam.excel.ExamScoreImporter;
import org.springblade.modules.exam.service.ExamPaperService;
import org.springblade.modules.exam.service.ExamScoreService;
import org.springblade.modules.exam.util.SecurityPaperUtil;
import org.springblade.modules.exam.vo.ExamScoreVO;
@@ -39,6 +41,8 @@
    private final ExamScoreService examScoreService;
    private final IUserService userService;
    private final ExamPaperService examPaperService;
    /**
     * 自定义分页
@@ -95,29 +99,33 @@
     * @param examScore 考试成绩信息对象
     */
    @PostMapping("/updateExamScore")
    public R updateExamScore(@RequestBody ExamScore examScore) throws Exception {
    public R updateExamScore(@RequestBody ExamScore examScore){
        if (null!=examScore.getLearnGrade() && null!=examScore.getTheoryGrade()){
            ExamScore examScore1 = examScoreService.getById(examScore.getId());
            if (examScore.getTheoryGrade()>=60 && examScore.getLearnGrade()>=60){
                //合格
                examScore.setQualified(0);
                //去生成保安证编号
                //查询当前保安信息
                User user = userService.getById(examScore1.getUserId());
                String pre = SecurityPaperUtil.getSecurityPaper();
                //查询当前年份已有的保安证编号
                int count = userService.getSecurityPaperCount(pre);
                String result = null;
                if (count==0){
                    result = pre + "00000";
                }else {
                    //格式化
                    DecimalFormat decimalFormat = new DecimalFormat("00000");
                    result = pre + (decimalFormat.format(count++));
                //正式考试通过生成保安证编号
                ExamPaper paper = examPaperService.getById(examScore.getExamId());
                if (paper.getExamType()==1) {
                    //去生成保安证编号
                    //查询当前保安信息
                    User user = userService.getById(examScore1.getUserId());
                    String pre = SecurityPaperUtil.getSecurityPaper();
                    //查询当前年份已有的保安证编号
                    int count = userService.getSecurityPaperCount(pre);
                    String result = null;
                    if (count == 0) {
                        result = pre + "00000";
                    } else {
                        //格式化
                        DecimalFormat decimalFormat = new DecimalFormat("00000");
                        result = pre + (decimalFormat.format(count++));
                    }
                    user.setSecuritynumber(result);
                    //更新保安数据
                    userService.updateById(user);
                }
                user.setSecuritynumber(result);
                //更新保安数据
                userService.updateById(user);
            }else {
                //不合格
                examScore.setQualified(1);
src/main/java/org/springblade/modules/exam/entity/ExamScore.java
@@ -105,4 +105,14 @@
    private String userId;
    /**
     * 考试id
     */
    @TableField("exam_id")
    private String examId;
}
src/main/java/org/springblade/modules/exam/excel/ExamScoreExcel.java
@@ -37,6 +37,11 @@
    private static final long serialVersionUID = 1L;
    @ColumnWidth(25)
    @ExcelProperty("考试名称")
    private String examName;
    @ColumnWidth(20)
    @ExcelProperty("姓名")
    private String name;
src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.java
@@ -72,4 +72,11 @@
     * @return
     */
    List<TrainingRegistration> getTrainList(Long id);
    /**
     * 使用考试名称匹配考试信息
     * @param examName 考试名称
     * @return
     */
    ExamPaper getExamInfoByExamName(@Param("examName") String examName);
}
src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml
@@ -136,7 +136,7 @@
        (select
            ke.id,ke.exam_name examName,
            sa.candidate_no candidateNo,
            bu.real_name realName,bu.sex
            bu.real_name realName,bu.sex,bu.cardid idCardNo
        from
            ksxt_exam ke
        left join
@@ -148,6 +148,7 @@
        on
            bu.id = sa.user_id
        where sa.user_id = #{userId}
        and is_apply = 1
        and is_exam = 1
        and sa.apply_status = 2
        )
@@ -157,7 +158,7 @@
        (select
            ke.id,ke.exam_name examName,
            str.candidate_no candidateNo,
            bu.real_name realName,bu.sex
            bu.real_name realName,bu.sex,bu.cardid idCardNo
        from
            ksxt_exam ke
        left join
@@ -169,8 +170,10 @@
        on
            bu.id = str.user_id
        where str.user_id = #{userId}
        and bu.is_train = 1
        and is_exam = 1
        and str.cancel = 3
        and ke.audit_status = 1
        and str.cancel = 1
        )
    </select>
@@ -203,4 +206,13 @@
        and str.cancel = 1
    </select>
    <!--使用考试名称匹配考试信息-->
    <select id="getExamInfoByExamName" resultType="org.springblade.modules.exam.entity.ExamPaper">
        SELECT
            *
        FROM
            ksxt_exam
        where exam_name like concat('%', #{examName},'%')
    </select>
</mapper>
src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.java
@@ -37,7 +37,7 @@
     * @param idCardNo 身份证号
     * @return
     */
    ExamScore getExamScoreInfoByIdCardNo(@Param("idCardNo")String idCardNo);
    ExamScore getExamScoreInfoByIdCardNo(@Param("idCardNo")String idCardNo,@Param("examId")Long examId);
    List<Map<String,Object>> scoreStatistics();
}
src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.xml
@@ -6,7 +6,7 @@
    <select id="selectExamScorePage" resultType="org.springblade.modules.exam.vo.ExamScoreVO">
        SELECT
         es.id,es.theory_grade theoryGrade,ifnull(learn_grade,-1) learnGrade,es.user_id userId,
         exam_name examName,bu.real_name securityName,company,exam_time examTime,
         ke.exam_name examName,bu.real_name securityName,company,es.exam_time examTime,
         all_grade allGrade,exam_end_time examEndTime,qualified,
         bd.dept_name companyName
        FROM
@@ -19,10 +19,14 @@
            blade_dept bd
        on
            bd.id = es.company
        left join
            ksxt_exam ke
        on
            ke.id = es.exam_id
        WHERE
            1=1
        <if test="examScore.examName!=null and  examScore.examName!=''">
            and es.exam_name like concat('%', #{examScore.examName},'%')
            and ke.exam_name like concat('%', #{examScore.examName},'%')
        </if>
        <if test="examScore.companyName!=null and  examScore.companyName!=''">
            and bd.dept_name like concat('%', #{examScore.companyName},'%')
@@ -32,6 +36,9 @@
        </if>
        <if test="examScore.userId!=null and  examScore.userId!=''">
            and es.user_id = #{examScore.userId}
        </if>
        <if test="examScore.examType!=null and  examScore.examType!=''">
            and ke.exam_type = #{examScore.examType}
        </if>
        <if test="examScore.candidateNo!=null and  examScore.candidateNo!=''">
            and es.candidate_no = #{examScore.candidateNo}
@@ -75,7 +82,7 @@
        exam_score) b
    </select>
    <!---->
    <!--根据用户身份证号查询考试成绩-->
    <select id="getExamScoreInfoByIdCardNo" resultType="org.springblade.modules.exam.entity.ExamScore">
        select
            es.*
@@ -87,5 +94,6 @@
            bu.id = es.user_id
        where
            bu.cardid = #{idCardNo}
            and es.exam_id = #{examId}
    </select>
</mapper>
src/main/java/org/springblade/modules/exam/service/ExamPaperService.java
@@ -80,4 +80,11 @@
     * @return
     */
    List<TrainingRegistration> getTrainList(Long id);
    /**
     * 使用考试名称匹配考试信息
     * @param examName 考试名称
     * @return
     */
    ExamPaper getExamInfoByExamName(String examName);
}
src/main/java/org/springblade/modules/exam/service/impl/ExamPaperServiceImpl.java
@@ -108,4 +108,14 @@
    public List<TrainingRegistration> getTrainList(Long id) {
        return baseMapper.getTrainList(id);
    }
    /**
     * 使用考试名称匹配考试信息
     * @param examName 考试名称
     * @return
     */
    @Override
    public ExamPaper getExamInfoByExamName(String examName) {
        return baseMapper.getExamInfoByExamName(examName);
    }
}
src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java
@@ -5,6 +5,9 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springblade.common.utils.arg;
import org.springblade.core.mp.support.Condition;
import org.springblade.modules.apply.entity.Apply;
import org.springblade.modules.apply.service.ApplyService;
import org.springblade.modules.exam.entity.ExamExaminationSubject;
import org.springblade.modules.exam.entity.ExamPaper;
import org.springblade.modules.exam.entity.ExamScore;
@@ -19,6 +22,8 @@
import org.springblade.modules.exam.vo.ExamScoreVO;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.service.IUserService;
import org.springblade.modules.training.entity.TrainingRegistration;
import org.springblade.modules.training.service.TrainingRegistrationService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -40,6 +45,12 @@
    private final IUserService userService;
    private final ExamSubjectChoicesService examSubjectChoicesService;
    private final ExamPaperService examPaperService;
    private final ApplyService applyService;
    private final TrainingRegistrationService trainingRegistrationService;
    /**
     * 自定义分页数据
@@ -113,6 +124,28 @@
                    }
                }
            }
            //获取考试信息
            ExamPaper paper = examPaperService.getById(examScore.getPapersId());
            //使用准考证号查询报名信息,修改考试状态为已考试
            if(paper.getExamType()==1){
                Apply apply = new Apply();
                apply.setCandidateNo(examScore.getCandidateNo());
                Apply apply1 = applyService.getOne(Condition.getQueryWrapper(apply));
                //修改为已考试
                apply1.setIsExam(2);
                applyService.updateById(apply1);
            }
            //模拟考试
            if(paper.getExamType()==2){
                TrainingRegistration trainingRegistration = new TrainingRegistration();
                trainingRegistration.setCandidateNo(examScore.getCandidateNo());
                TrainingRegistration trainingRegistration1 = trainingRegistrationService.getOne(Condition.getQueryWrapper(trainingRegistration));
                //修改为已考试
                trainingRegistration1.setIsExam(2);
                trainingRegistrationService.updateById(trainingRegistration1);
            }
            //设置考试ID
            examScore.setExamId(examScore.getPapersId().toString());
            //设置理论得分
            examScore.setTheoryGrade(theoryGrade);
            //计算总成绩,此时没有实操成绩,总成绩为实操成绩和理论成绩和的一半
@@ -146,29 +179,35 @@
        if (examScoreExcelList.size()>0){
            examScoreExcelList.forEach(examScoreExcel -> {
                if (null!=examScoreExcel.getLearnGrade() && null!=examScoreExcel.getIdCardNo() && examScoreExcel.getIdCardNo()!=""){
                    ExamScore examScore = baseMapper.getExamScoreInfoByIdCardNo(examScoreExcel.getIdCardNo());
                    //使用考试名称匹配考试信息
                    ExamPaper examPaper = examPaperService.getExamInfoByExamName(examScoreExcel.getExamName());
                    //查询出成绩数据
                    ExamScore examScore = baseMapper.getExamScoreInfoByIdCardNo(examScoreExcel.getIdCardNo(),examPaper.getId());
                    if (null!=examScore) {
                        examScore.setLearnGrade(examScoreExcel.getLearnGrade());
                        if (examScore.getTheoryGrade() >= 60 && examScore.getLearnGrade() >= 60) {
                            //合格
                            examScore.setQualified(0);
                            //去生成保安证编号
                            //查询当前保安信息
                            User user = userService.getById(examScore.getUserId());
                            String pre = SecurityPaperUtil.getSecurityPaper();
                            //查询当前年份已有的保安证编号
                            int count = userService.getSecurityPaperCount(pre);
                            String result = null;
                            if (count==0){
                                result = pre + "00000";
                            }else {
                                //格式化
                                DecimalFormat decimalFormat = new DecimalFormat("00000");
                                result = pre + (decimalFormat.format(count++));
                            //正式考试通过生成保安证编号
                            if (examPaper.getExamType()==1) {
                                //去生成保安证编号
                                //查询当前保安信息
                                User user = userService.getById(examScore.getUserId());
                                String pre = SecurityPaperUtil.getSecurityPaper();
                                //查询当前年份已有的保安证编号
                                int count = userService.getSecurityPaperCount(pre);
                                String result = null;
                                if (count == 0) {
                                    result = pre + "00000";
                                } else {
                                    //格式化
                                    DecimalFormat decimalFormat = new DecimalFormat("00000");
                                    result = pre + (decimalFormat.format(count++));
                                }
                                user.setSecuritynumber(result);
                                //更新保安数据
                                userService.updateById(user);
                            }
                            user.setSecuritynumber(result);
                            //更新保安数据
                            userService.updateById(user);
                        } else {
                            //不合格
                            examScore.setQualified(1);
src/main/java/org/springblade/modules/exam/vo/ExamScoreVO.java
@@ -21,7 +21,7 @@
    private String companyName;
    /**
     * 试卷id
     * 考试id,提交成绩时用
     */
    private Long papersId;
@@ -29,4 +29,9 @@
     * 考勤提交的结果
     */
    private List<ExamResultVO> examResultVOS;
    /**
     * 考试类型
     */
    private Integer examType;
}
src/main/java/org/springblade/modules/location/controller/LiveLocationController.java
@@ -38,6 +38,7 @@
     * 自定义分页
     * @param query page,size
     * @param liveLocation 实时位置信息对象
     *
     */
    @GetMapping("/page")
    public R<IPage<LiveLocationVo>> page(LiveLocationVo liveLocation, Query query) {
src/main/java/org/springblade/modules/resource/endpoint/OssEndpoint.java
@@ -237,10 +237,10 @@
     */
    @SneakyThrows
    @PostMapping("/put-file-attach")
    public R<BladeFile> putFileAttach(@RequestParam MultipartFile file,String deptid,String type) {
    public R<BladeFile> putFileAttach(@RequestParam MultipartFile file,String deptid,String type,Long noticeId) {
        String fileName = file.getOriginalFilename();
        BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream());
        Long attachId = buildAttach(fileName, file.getSize(), bladeFile,deptid,type);
        Long attachId = buildAttach(fileName, file.getSize(), bladeFile,deptid,type,noticeId);
        bladeFile.setAttachId(attachId);
        return R.data(bladeFile);
    }
@@ -254,9 +254,9 @@
     */
    @SneakyThrows
    @PostMapping("/put-file-attach-by-name")
    public R<BladeFile> putFileAttach(@RequestParam String fileName, @RequestParam MultipartFile file,String deptid,String type) {
    public R<BladeFile> putFileAttach(@RequestParam String fileName, @RequestParam MultipartFile file,String deptid,String type,Long noticeId) {
        BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream());
        Long attachId = buildAttach(fileName, file.getSize(), bladeFile,deptid,type);
        Long attachId = buildAttach(fileName, file.getSize(), bladeFile,deptid,type,noticeId);
        bladeFile.setAttachId(attachId);
        return R.data(bladeFile);
    }
@@ -269,7 +269,7 @@
     * @param bladeFile 对象存储文件
     * @return attachId
     */
    private Long buildAttach(String fileName, Long fileSize, BladeFile bladeFile,String deptid,String type) throws Exception {
    private Long buildAttach(String fileName, Long fileSize, BladeFile bladeFile,String deptid,String type,Long noticeId) throws Exception {
        BladeUser user = AuthUtil.getUser();
        String fileExtension = FileUtil.getFileExtension(fileName);
        Attach attach = new Attach();
@@ -281,8 +281,10 @@
        attach.setExtension(fileExtension);
        attach.setDeptid(user.getDeptId());
        attach.setType(type);
        if (null!=noticeId){
            attach.setNoticeId(noticeId);
        }
        attachService.save(attach);
//        arg.test01(arg.url+"/blade-resource/attach/save",attach);
        return attach.getId();
    }
src/main/java/org/springblade/modules/resource/entity/Attach.java
@@ -16,6 +16,7 @@
 */
package org.springblade.modules.resource.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@@ -69,5 +70,11 @@
    private String deptid;
    private String type;
    /**
     * 通知公告id
     */
    @TableField("notice_id")
    private Long noticeId;
}