教育训练处考试制证系统后端
heheng
2025-01-22 56c9cd32e5728799118562c1ce0fe25fd7caaadb
exam-system/src/main/java/com/gkhy/exam/pay/service/impl/NonCoalPayStudentServiceImpl.java
@@ -3,6 +3,8 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gkhy.exam.institutionalaccess.enums.StudentSex;
import com.gkhy.exam.pay.dto.req.NonCoalPayStuImport;
import com.gkhy.exam.pay.dto.req.NonCoalPayStudentReqDto;
import com.gkhy.exam.pay.entity.NonCoalPay;
import com.gkhy.exam.pay.entity.NonCoalPayStudent;
@@ -164,14 +166,14 @@
    }
    @Override
    public String importData(List<NonCoalPayStudent> nonCoalPayStudents, String operName, Long nonCoalPayId) {
    public String importData(List<NonCoalPayStuImport> nonCoalPayStudents, String operName, Long nonCoalPayId) {
        if (StringUtils.isNull(nonCoalPayStudents) || nonCoalPayStudents.isEmpty()) {
            throw new ServiceException("导入数据不能为空!");
        }
        NonCoalPay nonCoalPay = checkNonCoalPay(nonCoalPayId);
        Integer payPersonType = nonCoalPay.getPayPersonType();
        Set<String> collect = nonCoalPayStudents.stream()
                .map(NonCoalPayStudent::getIdCard)
                .map(NonCoalPayStuImport::getIdCard)
                .collect(Collectors.toSet());
        if (collect.size() != nonCoalPayStudents.size()) {
            throw new ServiceException("导入数据不能有重复身份证号!");
@@ -192,17 +194,23 @@
        int failureNum = 0;
        StringBuilder successMsg = new StringBuilder();
        StringBuilder failureMsg = new StringBuilder();
        for (NonCoalPayStudent stu : nonCoalPayStudents) {
        for (NonCoalPayStuImport stu : nonCoalPayStudents) {
            try {
                if (StringUtils.isEmpty(stu.getIdCard()) || StringUtils.isEmpty(stu.getName()) || StringUtils.isEmpty(stu.getPhone()) || stu.getSex() == null) {
                    failureMsg.append("<br/>" + failureNum + "、导入数据为空: " + stu.getIdCard() + " 数据错误");
                } else if (idCardToNameMap.get(stu.getIdCard().trim()) != null) {
                    failureMsg.append("<br/>" + failureNum + "、身份证号: " + stu.getIdCard() + " 数据已存在");
                } else {
                    stu.setPayStatus(0L);
                    stu.setPayType(payPersonType.longValue());
                    stu.setNonCoalPayId(nonCoalPayId);
                    save(stu);
                    NonCoalPayStudent stu1 = new NonCoalPayStudent();
                    stu1.setPayStatus(0L);
                    stu1.setPayType(payPersonType.longValue());
                    stu1.setNonCoalPayId(nonCoalPayId);
                    stu1.setCreateBy(operName);
                    stu1.setName(stu.getName());
                    stu1.setIdCard(stu.getIdCard());
                    stu1.setPhone(stu.getPhone());
                    stu1.setSex(StudentSex.BOY.getStatus().equals(stu.getSex().trim()) ? 0L : 1L);
                    nonCoalPayStudentMapper.insertNonCoalPayStudent(stu1);
                    successNum++;
                    successMsg.append("<br/>" + successNum + "、身份证号 " + stu.getIdCard() + " 导入成功");
                    idCardToNameMap.put(stu.getIdCard(), stu.getIdCard());