李宇
2021-07-12 cf6b965a86065a537a40c74f67e88a04447d2582
修改导入申购
已修改1个文件
33 ■■■■ 文件已修改
src/main/java/com/nanometer/smartlab/service/OpeApplyServiceImpl.java 33 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/nanometer/smartlab/service/OpeApplyServiceImpl.java
@@ -36,6 +36,7 @@
import java.io.InputStream;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -776,12 +777,12 @@
                for (int index = 0; index < totalCells; index++) {
                    String cellInfo = "";
                    if (row.getCell(index) != null) {
                        if (row.getCell(index).getCellTypeEnum() == CellType.BLANK && index != 9) {
                        if (row.getCell(index).getCellType() == CellType.BLANK && index != 9) {
                            throw new BusinessException(ExceptionEnumCode.PARAM_NULL, "第" + ++i + "行:除了课题组都不能为空");
                        }
                        if (row.getCell(index).getCellTypeEnum() == CellType.NUMERIC) {
                            cellInfo = String.valueOf(row.getCell(index).getNumericCellValue());
                        if (row.getCell(index).getCellType() == CellType.NUMERIC) {
                            DecimalFormat df = new DecimalFormat("#######");  //格式化number String字符
                            cellInfo = df.format(row.getCell(index).getNumericCellValue());
                        }else{
                            cellInfo = row.getCell(index).getStringCellValue();
                        }
@@ -810,16 +811,36 @@
                if (applyUser == null)  throw new BusinessException(ExceptionEnumCode.PARAM_NO_EXIST, i+"行:申购人不存在或者申购人姓名存在重复,导入失败");
                //课题组名称
                String objective = valuesList.get(9);
                String applyDateStr = valuesList.get(10);
                String format = "yyyy-MM-dd";
                SimpleDateFormat dateFormat = new SimpleDateFormat(format);
                Date applyDate = null;
                int cellnum = 10;
                CellType type = row.getCell(cellnum).getCellType();
                Object value = row.getCell(cellnum);
                if (null == value || StringUtils.isBlank(value.toString())) {
                    throw new BusinessException(ExceptionEnumCode.PARAM_NO_EXIST, i+"行,申购日期不能为空");
                } else {
                    if (type.equals(CellType.NUMERIC)) {
                try {
                    applyDate = dateFormat.parse(applyDateStr);
                            applyDate = row.getCell(cellnum).getDateCellValue();
                        } catch (Exception e) {
                            e.printStackTrace();
                            throw new BusinessException(ExceptionEnumCode.PARAM_NO_EXIST, i+"行,申购日期解析错误,请检查是否有无效字符");
                        }
                    } else if (type.equals(CellType.STRING)) {
                        String cellInfo = row.getCell(10).getStringCellValue();
                        try {
                            applyDate = dateFormat.parse(cellInfo);
                } catch (ParseException e) {
                    e.printStackTrace();
                    throw new BusinessException(ExceptionEnumCode.PARAM_NO_EXIST, i+"行:申购日期不合法,应如2016-10-09,导入失败");
                }
                    } else {
                        throw new BusinessException(ExceptionEnumCode.PARAM_NO_EXIST, i+"行:申购日期解析错误,请检查是否有无效字符");
                    }
                }
                //选择的审批人姓名
                String approveUserName = valuesList.get(11);
                //根据姓名获取用户信息的id