From c3510da29a7974c6af7ff3de1ade3db429d6f848 Mon Sep 17 00:00:00 2001
From: 李宇 <986321569@qq.com>
Date: 星期三, 18 八月 2021 14:27:59 +0800
Subject: [PATCH] 申购管理申请履历显示所有历史单据,提交时如有无效试剂耗材报错

---
 src/main/java/com/nanometer/smartlab/service/OpeApplyServiceImpl.java |   54 +++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 41 insertions(+), 13 deletions(-)

diff --git a/src/main/java/com/nanometer/smartlab/service/OpeApplyServiceImpl.java b/src/main/java/com/nanometer/smartlab/service/OpeApplyServiceImpl.java
index a4e9fc5..b1aa118 100644
--- a/src/main/java/com/nanometer/smartlab/service/OpeApplyServiceImpl.java
+++ b/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.*;
@@ -70,7 +71,7 @@
     @Transactional(propagation = Propagation.REQUIRED)
     public List<OpeApply> getOpeApplyList(String reagentName, Timestamp startDeadline, Timestamp endDeadline, Integer status,
                                           String applyUserId, String approveUserId, String queryCas,
-                                          Integer first, Integer pageSize,String applyCode,String applyUserName) {
+                                          Integer first, Integer pageSize,String applyCode,String applyUserName,Byte isShow) {
         try {
             Map<String, Object> params = new HashMap<String, Object>();
             if (StringUtils.isNotBlank(reagentName)) {
@@ -79,6 +80,7 @@
             params.put("startDeadline", startDeadline);
             params.put("endDeadline", endDeadline);
             params.put("status", status);
+            params.put("isShow", isShow);
 
             if (StringUtils.isNotBlank(applyUserId)) {
     			SysUser sysUser = sysUserService.getSysUser(applyUserId);
@@ -191,7 +193,7 @@
 
     @Transactional(propagation = Propagation.REQUIRED)
     public int getOpeApplyTotalCount(String reagentName, Timestamp startDeadline, Timestamp endDeadline, Integer status,
-                                     String applyUserId, String approveUserId, String queryCas,String applyCode,String applyUserName) {
+                                     String applyUserId, String approveUserId, String queryCas,String applyCode,String applyUserName,Byte isShow) {
         try {
             Map<String, Object> params = new HashMap<String, Object>();
             if (StringUtils.isNotBlank(reagentName)) {
@@ -200,6 +202,7 @@
             params.put("startDeadline", startDeadline);
             params.put("endDeadline", endDeadline);
             params.put("status", status);
+            params.put("isShow", isShow);
 
     		if (StringUtils.isNotBlank(applyUserId)) {
     			SysUser sysUser = sysUserService.getSysUser(applyUserId);
@@ -776,12 +779,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 +813,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;
-                try {
-                    applyDate = dateFormat.parse(applyDateStr);
-                } catch (ParseException e) {
-                    e.printStackTrace();
-                    throw new BusinessException(ExceptionEnumCode.PARAM_NO_EXIST, i+"行:申购日期不合法,应如2016-10-09,导入失败");
+                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 = 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
@@ -842,7 +865,7 @@
                 //申购数量
                 opeApply.setNum(num);
                 //申购人
-                opeApply.setApplyUserId(user.getId());
+                opeApply.setApplyUserId(applyUser.getId());
                 //选择的审批人
                 opeApply.setApproveUserId(approveUser.getId());
                 //选择的课题组信息
@@ -858,4 +881,9 @@
 
     }
 
+    @Override
+    public OpeApplyReserve getOpeApplyReserveListByNameForRowData(String rowKey) {
+        return opeApplyDao.getOpeApplyReserveListByNameForRowData(rowKey);
+    }
+
 }

--
Gitblit v1.9.2