| | |
| | | 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; |
| | |
| | | } |
| | | |
| | | @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("导入数据不能有重复身份证号!"); |
| | |
| | | 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()); |