“djh”
3 天以前 c0f16750cb9097a8db7b68f8c1794c2aec28ca15
新增
已修改15个文件
266 ■■■■ 文件已修改
multi-admin/src/main/java/com/gkhy/exam/admin/controller/web/CompanyBasicController.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
multi-system/src/main/java/com/gkhy/exam/system/mapper/ExPaperStudentMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
multi-system/src/main/java/com/gkhy/exam/system/mapper/ExStudentAnswerMapper.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
multi-system/src/main/java/com/gkhy/exam/system/mapper/SysCompanyMapper.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
multi-system/src/main/java/com/gkhy/exam/system/service/CompanyBasicService.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
multi-system/src/main/java/com/gkhy/exam/system/service/CompanySummaryService.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
multi-system/src/main/java/com/gkhy/exam/system/service/SysCompanyService.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
multi-system/src/main/java/com/gkhy/exam/system/service/impl/CompanyBasicServiceImpl.java 105 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
multi-system/src/main/java/com/gkhy/exam/system/service/impl/CompanyIndustryTemplateServiceImpl.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
multi-system/src/main/java/com/gkhy/exam/system/service/impl/CompanySummaryServiceImpl.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
multi-system/src/main/java/com/gkhy/exam/system/service/impl/ExPaperStudentServiceImpl.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysCompanyServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
multi-system/src/main/resources/mapper/system/ExPaperStudentMapper.xml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
multi-system/src/main/resources/mapper/system/ExStudentAnswerMapper.xml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
multi-system/src/main/resources/mapper/system/SysCompanyMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
multi-admin/src/main/java/com/gkhy/exam/admin/controller/web/CompanyBasicController.java
@@ -86,6 +86,12 @@
        return companyBasicService.deletedCompanyBasic(companyBasicId);
    }
    @ApiOperation(value = "企业基础信息导入")
    @PostMapping("/upload/basic")
    public CommonResult uploadCompanyBasic(@RequestParam("file")MultipartFile file) {
        return companyBasicService.uploadBasic(file);
    }
    /**
     * 企业概况列表
@@ -135,6 +141,11 @@
        return companySummaryService.deletedCompanySummary(companySummaryId);
    }
    @ApiOperation(value = "企业概况导入")
    @PostMapping("/upload/summary")
    public CommonResult uploadCompanySummary(@RequestParam("file")MultipartFile file,@RequestParam("companyId") Integer companyId) {
        return companySummaryService.uploadSummary(file,companyId);
    }
    /**
     * 企业资质列表
multi-system/src/main/java/com/gkhy/exam/system/mapper/ExPaperStudentMapper.java
@@ -91,4 +91,6 @@
    void deleteByPaperStudentId(@Param("paperId") Long paperId, @Param("studentId") Long studentId);
    void updateByPaperStudentId(ExPaperStudent exPaperStudent);
}
multi-system/src/main/java/com/gkhy/exam/system/mapper/ExStudentAnswerMapper.java
@@ -1,5 +1,6 @@
package com.gkhy.exam.system.mapper;
import com.gkhy.exam.system.domain.ExPaperStudent;
import com.gkhy.exam.system.domain.ExStudentAnswer;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
@@ -35,4 +36,6 @@
    ExStudentAnswer getStudentAnswer(ExStudentAnswer studentAnswer);
    void deletedByPaperStudentId(@Param("paperId") Long paperId, @Param("studentId") Long studentId);
    void updateState(ExPaperStudent exPaperStudent);
}
multi-system/src/main/java/com/gkhy/exam/system/mapper/SysCompanyMapper.java
@@ -68,4 +68,5 @@
    List<SysCompany> selectCompanyListS();
    SysCompany selectByCompanyName(@Param("companyName") String companyName);
}
multi-system/src/main/java/com/gkhy/exam/system/service/CompanyBasicService.java
@@ -4,6 +4,7 @@
import com.gkhy.exam.common.api.CommonPage;
import com.gkhy.exam.common.api.CommonResult;
import com.gkhy.exam.system.domain.CompanyBasic;
import org.springframework.web.multipart.MultipartFile;
public interface CompanyBasicService extends IService<CompanyBasic> {
    CommonPage selectCompanyBasicList(Integer companyId);
@@ -13,4 +14,6 @@
    CommonResult updateCompanyBasic(CompanyBasic companyBasic);
    CommonResult deletedCompanyBasic(Integer companyBasicId);
    CommonResult uploadBasic(MultipartFile file);
}
multi-system/src/main/java/com/gkhy/exam/system/service/CompanySummaryService.java
@@ -4,6 +4,7 @@
import com.gkhy.exam.common.api.CommonPage;
import com.gkhy.exam.common.api.CommonResult;
import com.gkhy.exam.system.domain.CompanySummary;
import org.springframework.web.multipart.MultipartFile;
public interface CompanySummaryService extends IService<CompanySummary> {
    CommonPage selectCompanySummaryList(Integer companyId);
@@ -13,4 +14,6 @@
    CommonResult updateCompanySummary(CompanySummary companySummary);
    CommonResult deletedCompanySummary(Integer companySummaryId);
    CommonResult uploadSummary(MultipartFile file,Integer companyId);
}
multi-system/src/main/java/com/gkhy/exam/system/service/SysCompanyService.java
@@ -79,4 +79,5 @@
    List<SysCompany> selectCompanyLists();
    SysCompany selectCompanyByName(String stringCellValue);
}
multi-system/src/main/java/com/gkhy/exam/system/service/impl/CompanyBasicServiceImpl.java
@@ -1,5 +1,6 @@
package com.gkhy.exam.system.service.impl;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gkhy.exam.common.api.CommonPage;
import com.gkhy.exam.common.api.CommonResult;
@@ -7,15 +8,23 @@
import com.gkhy.exam.common.exception.ApiException;
import com.gkhy.exam.common.utils.PageUtils;
import com.gkhy.exam.common.utils.SecurityUtils;
import com.gkhy.exam.common.utils.StringUtils;
import com.gkhy.exam.system.domain.CompanyBasic;
import com.gkhy.exam.system.domain.ExQuestion;
import com.gkhy.exam.system.domain.SysCompany;
import com.gkhy.exam.system.mapper.CompanyBasicMapper;
import com.gkhy.exam.system.service.CompanyBasicService;
import com.gkhy.exam.system.service.SysCompanyService;
import org.apache.poi.ss.usermodel.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@Service
@@ -87,4 +96,100 @@
        }
        return CommonResult.failed();
    }
    @Override
    @Transactional
    public CommonResult uploadBasic(MultipartFile file) {
        Workbook workbook = null;
        List<CompanyBasic> companyBasicslist = new ArrayList<>();
        StringBuffer stringBuffer = new StringBuffer();
        Integer t=0;
        try {
            workbook = WorkbookFactory.create(file.getInputStream());
            Sheet sheetAt = workbook.getSheetAt(0);
            LoginUserDetails loginUser = SecurityUtils.getLoginUser();
            for (int i = 1; i <= sheetAt.getLastRowNum(); i++) {
                Row row = sheetAt.getRow(i);
                String cellValueAsString = getCellValueAsString(row.getCell(1));
                if (StringUtils.isEmpty(cellValueAsString)){
                    continue;
                }
                CompanyBasic companyBasic = new CompanyBasic();
                if (row!=null ){
                    companyBasic.setBasic(getCellValueAsString(row.getCell(1)));
                    companyBasic.setIntroduce(getCellValueAsString(row.getCell(2)));
                    companyBasic.setTarget(getCellValueAsString(row.getCell(3)));
                    companyBasic.setQuality(getCellValueAsString(row.getCell(4)));
                    companyBasic.setActivity(getCellValueAsString(row.getCell(5)));
                    companyBasic.setAudit(getCellValueAsString(row.getCell(6)));
                    companyBasic.setEpiboly(getCellValueAsString(row.getCell(7)));
                    companyBasic.setResource(getCellValueAsString(row.getCell(8)));
                    companyBasic.setCreateTime(LocalDateTime.now());
                    companyBasic.setCreateBy(SecurityUtils.getUsername());
                    SysCompany sysCompany = sysCompanyService.selectCompanyByName(getCellValueAsString(row.getCell(0)));
                    companyBasic.setCompanyName(sysCompany.getName());
                    companyBasic.setCompanyId(Math.toIntExact(sysCompany.getId()));
                }
                companyBasicslist.add(companyBasic);
            }
            for (CompanyBasic companyBasic : companyBasicslist) {
                List<CompanyBasic> companyBasics = companyBasicMapper.selectCompanyBasicList(companyBasic.getCompanyId());
                if (companyBasics.size()>0){
                    stringBuffer.append(companyBasic.getCompanyName()).append(",");
                }else {
                    if (!SecurityUtils.adminUser()){
                        if (companyBasic.getCompanyId() != null && SecurityUtils.getCompanyId() == companyBasic.getCompanyId().longValue()) {
                            t+=companyBasicMapper.insert(companyBasic);
                        } else {
                            stringBuffer.append(companyBasic.getCompanyName()).append(",");
                        }
                    }else {
                        t+=companyBasicMapper.insert(companyBasic);
                    }
                }
            }
            if (t<1){
                throw new ApiException("导入公司基本信息失败");
            }
            workbook.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        if (stringBuffer.length()>0){
            return CommonResult.failed("只能导入本企业数据或该企业已有数据 ["+stringBuffer.toString()+"]");
        }
        return CommonResult.success();
    }
    /**
     * 安全获取单元格值
     */
    private String getCellValueAsString(Cell cell) {
        if (cell == null) return "";
        switch (cell.getCellType()) {
            case STRING:
                return cell.getStringCellValue().trim();
            case NUMERIC:
                if (DateUtil.isCellDateFormatted(cell)) {
                    return cell.getDateCellValue().toString();
                } else {
                    return String.valueOf((long) cell.getNumericCellValue());
                }
            case BOOLEAN:
                return String.valueOf(cell.getBooleanCellValue());
            case FORMULA:
                try {
                    return cell.getStringCellValue();
                } catch (IllegalStateException e) {
                    return String.valueOf(cell.getNumericCellValue());
                }
            default:
                return "";
        }
    }
}
multi-system/src/main/java/com/gkhy/exam/system/service/impl/CompanyIndustryTemplateServiceImpl.java
@@ -196,13 +196,9 @@
        for (List<CompanyIndustryTemplate> industryTemplates : split) {
            int affectedRows = companyIndustryTemplateMapper.insertIndustrys(industryTemplates);
        }
        // 8. 批量插入
//        int affectedRows = companyIndustryTemplateMapper.insertIndustrys(companyIndustryTemplates);
        workbook.close();
//        if (affectedRows < 1) {
//            throw new ApiException("导入行业模版失败");
//        }
        return CommonResult.success();
    }
        // 安全获取单元格值
@@ -212,52 +208,6 @@
            return formatter.formatCellValue(cell).trim();
        }
//    List<CompanyIndustryType> companyIndustryTypes = sysIndustryTypeMapper.selectIndustryTypeList();
//    List<SysCompany> list = sysCompanyService.selectCompanyLists();
//    Workbook workbook = WorkbookFactory.create(file.getInputStream());
//    Sheet sheetAt = workbook.getSheetAt(0);
//    List<CompanyIndustryTemplate> companyIndustryTemplates = new ArrayList<>();
//    LoginUserDetails loginUser = SecurityUtils.getLoginUser();
//    DataFormatter dataFormatter = new DataFormatter();
//    StringBuilder stringBuilder = new StringBuilder();
//        for (int i = 0; i <sheetAt.getLastRowNum(); i++) {
//        Row row = sheetAt.getRow(i + 1);
//        CompanyIndustryTemplate companyIndustryTemplate = new CompanyIndustryTemplate();
//        if (row!=null){
//            companyIndustryTemplate.setChapter(dataFormatter.formatCellValue(row.getCell(0)));
//            companyIndustryTemplate.setTemplateName(dataFormatter.formatCellValue(row.getCell(1)));
//            companyIndustryTemplate.setType(dataFormatter.formatCellValue(row.getCell(2)));
//            for (CompanyIndustryType companyIndustryType : companyIndustryTypes) {
//                if (dataFormatter.formatCellValue(row.getCell(3)).equals(companyIndustryType.getName())){
//                    companyIndustryTemplate.setIndustryType(companyIndustryType.getId());
//                }
//            }
//            if (companyIndustryTemplate.getIndustryType()==null){
//                stringBuilder.append("未找到对应行业类型:["+dataFormatter.formatCellValue(row.getCell(3))+"]   ,");
//            }
//            companyIndustryTemplate.setCreateBy(loginUser.getUsername());
//            companyIndustryTemplate.setCreateTime(LocalDateTime.now());
//            for (SysCompany sysCompany : list) {
//                if (dataFormatter.formatCellValue(row.getCell(4)).equals(sysCompany.getName())){
//                    companyIndustryTemplate.setCompanyId(sysCompany.getId());
//                }
//            }
//            if (companyIndustryTemplate.getCompanyId()==null){
//                stringBuilder.append("未找到对应企业:["+dataFormatter.formatCellValue(row.getCell(4))+"]");
//            }
//            companyIndustryTemplates.add(companyIndustryTemplate);
//        }
//    }
//        if (StringUtils.isNotBlank(stringBuilder)){
//        workbook.close();
//        return CommonResult.failed(stringBuilder.toString());
//    }
//    int i = companyIndustryTemplateMapper.insertIndustrys(companyIndustryTemplates);
//        if (i<1){
//        throw new ApiException("导入行业模版失败");
//    }
//        workbook.close();
//        return CommonResult.success();
}
multi-system/src/main/java/com/gkhy/exam/system/service/impl/CompanySummaryServiceImpl.java
@@ -12,9 +12,16 @@
import com.gkhy.exam.system.mapper.CompanySummaryMapper;
import com.gkhy.exam.system.service.CompanySummaryService;
import com.gkhy.exam.system.service.SysCompanyService;
import org.apache.poi.schemas.vmldrawing.XmlDocument;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.time.LocalDateTime;
import java.util.List;
@@ -86,4 +93,42 @@
        }
        return CommonResult.failed();
    }
    @Override
    public CommonResult uploadSummary(MultipartFile file,Integer companyId) {
        List<CompanySummary> companySummaries = companySummaryMapper.selectCompanySummaryList(Math.toIntExact(companyId == null ? SecurityUtils.getCompanyId() : companyId));
        if (companySummaries.size()>0){
            throw new ApiException("当前企业已有相关数据,请删除原有数据后重试");
        }
        try {
            String fileData = readWordToString(file);
            CompanySummary companySummary = new CompanySummary();
            companySummary.setCompanySummary(fileData);
            if (companyId==null){
                companySummary.setCompanyId(Math.toIntExact(SecurityUtils.getCompanyId()));
            }else {
                companySummary.setCompanyId(companyId);
            }
            companySummary.setCreateTime(LocalDateTime.now());
            companySummary.setCreateBy(SecurityUtils.getUsername());
            companySummaryMapper.insert(companySummary);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return CommonResult.success();
    }
    /**
     * 读取Word文档内容并转为字符串
     * @param file Word文件
     * @return 文档内容的字符串
     */
    public static String readWordToString(MultipartFile file) throws Exception {
        try (InputStream inputStream = file.getInputStream();
             XWPFDocument document = new XWPFDocument(inputStream);
             XWPFWordExtractor extractor = new XWPFWordExtractor(document)) {
            return extractor.getText();
        }
    }
}
multi-system/src/main/java/com/gkhy/exam/system/service/impl/ExPaperStudentServiceImpl.java
@@ -298,7 +298,7 @@
            }
            updateStudentAnswers.add(sa);
        }
        ExPaperStudent exPaperStudent = baseMapper.selectByPaperStudentId(paperStudent);
        studentAnswerService.saveOrUpdateBatch(updateStudentAnswers);
        paperStudent.setScore(totalScore);
        if(!easyViewFlag){
@@ -315,6 +315,11 @@
                l+=1;
                paperStudent.setNumber("AQSC-"+format+"-"+l);
            }
            if (exPaperStudent.getScore()>paperStudent.getScore()){
                paperStudent.setScore(exPaperStudent.getScore());
            }
        }
        int row=baseMapper.updateById(paperStudent);
        if(row<1){
@@ -325,14 +330,16 @@
    @Override
    @Transactional
    public void againExam(ExPaperStudent exPaperStudent) {
        baseMapper.deleteByPaperStudentId(exPaperStudent.getPaperId(),exPaperStudent.getStudentId());
        studentAnswerMapper.deletedByPaperStudentId(exPaperStudent.getPaperId(),exPaperStudent.getStudentId());
        BatchPaperStudentVO batchPaperStudentVO = new BatchPaperStudentVO();
        batchPaperStudentVO.setPaperId(exPaperStudent.getPaperId());
        List<Long> longs = new ArrayList<>();
        longs.add(exPaperStudent.getStudentId());
        batchPaperStudentVO.setStudentIds(longs);
        batchAddPaperStudent(batchPaperStudentVO);
//        baseMapper.deleteByPaperStudentId(exPaperStudent.getPaperId(),exPaperStudent.getStudentId());
//        studentAnswerMapper.deletedByPaperStudentId(exPaperStudent.getPaperId(),exPaperStudent.getStudentId());
//        BatchPaperStudentVO batchPaperStudentVO = new BatchPaperStudentVO();
//        batchPaperStudentVO.setPaperId(exPaperStudent.getPaperId());
//        List<Long> longs = new ArrayList<>();
//        longs.add(exPaperStudent.getStudentId());
//        batchPaperStudentVO.setStudentIds(longs);
//        batchAddPaperStudent(batchPaperStudentVO);
        baseMapper.updateByPaperStudentId(exPaperStudent);
        studentAnswerMapper.updateState(exPaperStudent);
    }
    private Integer getScore(ExExamPaper examPaper,Integer questionType){
multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysCompanyServiceImpl.java
@@ -106,4 +106,9 @@
    public List<SysCompany> selectCompanyLists() {
        return baseMapper.selectCompanyListS();
    }
    @Override
    public SysCompany selectCompanyByName(String stringCellValue) {
        return baseMapper.selectByCompanyName(stringCellValue);
    }
}
multi-system/src/main/resources/mapper/system/ExPaperStudentMapper.xml
@@ -107,6 +107,9 @@
            #{item}
        </foreach>
    </update>
    <update id="updateByPaperStudentId">
        update ex_paper_student set state = 0,start_time=null ,end_time = null where paper_id =#{paperId} and student_id =#{studentId}
    </update>
    <delete id="deleteByPaperStudentId">
        delete from ex_paper_student where paper_id =#{paperId} and student_id = #{studentId}
    </delete>
multi-system/src/main/resources/mapper/system/ExStudentAnswerMapper.xml
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gkhy.exam.system.mapper.ExStudentAnswerMapper">
    <update id="updateState">
        update ex_student_answer set answer = null where  paper_id = #{paperId} AND student_id = #{studentId}
    </update>
    <delete id="deletedByPaperStudentId">
        DELETE
        FROM
multi-system/src/main/resources/mapper/system/SysCompanyMapper.xml
@@ -155,4 +155,8 @@
        select id, name, credit_code, major, phone,remain_period,total_period,version, create_by, create_time, update_by, update_time, remark
        from sys_company where  del_flag = 0
    </select>
    <select id="selectByCompanyName" resultType="com.gkhy.exam.system.domain.SysCompany">
        <include refid="selectCompanyVo"/>
        where `name` = #{companyName} and del_flag = 0
    </select>
</mapper>