ソースを参照

增加对日期格式的单元格的支持

QuYueTing 7 ヶ月 前
コミット
5e8e4b0c19

+ 40 - 33
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ContractServiceImpl.java

@@ -793,7 +793,12 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
                 boolean TypeExists = false;
                 for (int i = 0; i < 30; i++) {
                     if (row.getCell(i) != null) {
-                        row.getCell(i).setCellType(CellType.STRING);
+                        if (i == 12 || i == 13 || i == 14 || i == 15) {
+                            //日期类型的
+                            row.getCell(i).setCellType(CellType.NUMERIC);
+                        } else {
+                            row.getCell(i).setCellType(CellType.STRING);
+                        }
                     }
                 }
                 if (row.getCell(1) == null) {
@@ -816,18 +821,46 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
                 customItem.setUndertaker(row.getCell(10)==null?null:row.getCell(10).getStringCellValue());
                 customItem.setAgent(row.getCell(11)==null?null:row.getCell(11).getStringCellValue());
                 if (row.getCell(12)!=null) {
-                    customItem.setSignDate(row.getCell(12).getStringCellValue());
+                    if (row.getCell(12).getCellTypeEnum().equals(CellType.NUMERIC)) {
+                        //日期类型的
+                        java.util.Date signDate = row.getCell(12).getDateCellValue();
+                        customItem.setSignDate(simpleDateFormat.format(signDate));
+                    } else {
+                        customItem.setSignDate(row.getCell(12).getStringCellValue());
+                    }
                 }
                 String startDate = null;
                 if (row.getCell(13) != null) {
-                    startDate = row.getCell(13).getStringCellValue();
-                    System.out.println("startDate========="+startDate);
+                    //判断是否是日期格式
+                    if (row.getCell(13).getCellTypeEnum().equals(CellType.NUMERIC)) {
+                        //日期类型的
+                        java.util.Date start = row.getCell(13).getDateCellValue();
+                        startDate = simpleDateFormat.format(start);
+                    } else {
+                        startDate = row.getCell(13).getStringCellValue();
+                    }
                 }
 
-                String endDate = row.getCell(14)==null?null:row.getCell(14).getStringCellValue();
+                String endDate = null;
+                if (row.getCell(14) != null) {
+                    //判断是否是日期格式
+                    if (row.getCell(14).getCellTypeEnum().equals(CellType.NUMERIC)) {
+                        //日期类型的
+                        java.util.Date end = row.getCell(14).getDateCellValue();
+                        endDate = simpleDateFormat.format(end);
+                    } else {
+                        endDate = row.getCell(14).getStringCellValue();
+                    }
+                }
                 if (row.getCell(15)!=null) {
-                    String filingDate = row.getCell(15).getStringCellValue();
-                    customItem.setFilingsDate(filingDate);
+                    //判断是否是日期格式
+                    if (row.getCell(15).getCellTypeEnum().equals(CellType.NUMERIC)) {
+                        //日期类型的
+                        java.util.Date filingDate = row.getCell(15).getDateCellValue();
+                        customItem.setFilingsDate(simpleDateFormat.format(filingDate));
+                    } else {
+                        customItem.setFilingsDate(row.getCell(15).getStringCellValue());
+                    }
                 }
 
                 String amounts = row.getCell(16)==null?null:row.getCell(16).getStringCellValue();
@@ -846,32 +879,6 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
                 }
                 customItem.setCurrency(row.getCell(20)==null?null:row.getCell(20).getStringCellValue());
 
-//                String s = row.getCell(21) == null ? null : row.getCell(21).getStringCellValue();
-                /*if (StringUtils.isNotBlank(s)){
-                    customItem.setPayedAmount(new BigDecimal(s));
-                }*/
-//                String s1 = (row.getCell(22) == null) ? null : row.getCell(22).getStringCellValue();
-                /*if (StringUtils.isNotBlank(s1)){
-                    if ("预付".equals(s1)) {
-                        customItem.setPayWay(1);
-                    } else {
-                        customItem.setPayWay(2);
-                    }
-                }*/
-                /*customItem.setBillNumber(row.getCell(22)==null?null:row.getCell(22).getStringCellValue());
-                String s2 = row.getCell(23) == null ? null : row.getCell(23).getStringCellValue();
-                if (StringUtils.isNotBlank(s2)){
-                    customItem.setReservedAmounts(new BigDecimal(s2));
-                }
-                customItem.setReservedBillNumber(row.getCell(24)==null?null:row.getCell(24).getStringCellValue());
-                String s3 = row.getCell(25) == null ? null : row.getCell(25).getStringCellValue();
-                if (StringUtils.isNotBlank(s3)){
-                    customItem.setTotalPayedAmounts(new BigDecimal(s3));
-                }
-                String s4 = row.getCell(26) == null ? null : row.getCell(26).getStringCellValue();
-                if (StringUtils.isNotBlank(s4)){
-                    customItem.setPendingAmounts(new BigDecimal(s4));
-                }*/
                 String status = row.getCell(21)==null?null:row.getCell(21).getStringCellValue();
                 if (StringUtils.isNotBlank(status)){
                     if ("履约中".equals(status)) {