Parcourir la source

Merge remote-tracking branch 'origin/demo_' into demo_

hfxc226 il y a 2 ans
Parent
commit
0f658070e0

+ 18 - 1
platform-common/src/main/java/com/platform/common/util/StringUtils.java

@@ -1,5 +1,9 @@
 package com.platform.common.util;
 
+import org.apache.poi.ss.usermodel.Cell;
+
+import java.util.Locale;
+
 import static cn.hutool.core.util.StrUtil.EMPTY;
 
 /**
@@ -341,4 +345,17 @@ public class StringUtils {
 
     }
 
-}
+    public static String  getExcelString(Cell cell){
+        if(cell == null){
+            return "";
+        }else{
+            String str = cell.getStringCellValue();
+            if(isBlank(str)){
+                return str;
+            }else{
+                return str.trim();
+            }
+        }
+    }
+
+}

+ 85 - 85
platform-dao/src/main/java/com/platform/dao/util/CustomExcelImportUtil.java

@@ -304,8 +304,8 @@ public class CustomExcelImportUtil {
             String index = row.getCell(0).getStringCellValue();
             try {
                 //i,j i:行 j:列
-                record.setGoodsId(row.getCell(0).getStringCellValue().trim());
-                record.setNo(row.getCell(1).getStringCellValue().trim() + row.getCell(2).getStringCellValue());
+                record.setGoodsId(StringUtils.getExcelString(row.getCell(0)));
+                record.setNo(StringUtils.getExcelString(row.getCell(1)) + row.getCell(2).getStringCellValue());
                 record.setName(row.getCell(1).getStringCellValue());
                 record.setQuantity(BigDecimalUtil.round(new BigDecimal(row.getCell(3).getNumericCellValue()), 2));
                 String key = record.getGoodsId();
@@ -502,14 +502,14 @@ public class CustomExcelImportUtil {
             String index = i + "";
             try {
                 //i,j i:行 j:列
-                record.setId(row.getCell(0).getStringCellValue().trim());
-                record.setModel(row.getCell(1).getStringCellValue().trim());
-                record.setName(row.getCell(2).getStringCellValue().trim());
-                record.setNameModel(row.getCell(3).getStringCellValue().trim());
-                record.setTypeId(row.getCell(4).getStringCellValue().trim());
-                record.setUseType(getUseType(row.getCell(6).getStringCellValue().trim()));
+                record.setId(StringUtils.getExcelString(row.getCell(0)));
+                record.setModel(StringUtils.getExcelString(row.getCell(1)));
+                record.setName(StringUtils.getExcelString(row.getCell(2)));
+                record.setNameModel(StringUtils.getExcelString(row.getCell(3)));
+                record.setTypeId(StringUtils.getExcelString(row.getCell(4)));
+                record.setUseType(getUseType(StringUtils.getExcelString(row.getCell(6))));
                 record.setLevel(getLevel(row.getCell(8).getStringCellValue()));
-                record.setProducerId(row.getCell(9).getStringCellValue().trim());
+                record.setProducerId(StringUtils.getExcelString(row.getCell(9)));
                 record.setStatus(getStatus(row.getCell(12).getStringCellValue()));
                 record.setValue(new Double(getCellValue(row.getCell(13))));
                 record.setUnit("台");
@@ -694,7 +694,7 @@ public class CustomExcelImportUtil {
             String index = i + "";
             try {
                 //i,j i:行 j:列
-                record.setId(row.getCell(0).getStringCellValue().trim());
+                record.setId(StringUtils.getExcelString(row.getCell(0)));
                 String price = getCellValue(row.getCell(8));
                 if(StringUtils.isBlank(price)){
                     record.setPrice(new BigDecimal(0));
@@ -868,9 +868,9 @@ public class CustomExcelImportUtil {
             String index = row.getCell(1).getStringCellValue() + "";
             try {
                 //i,j i:行 j:列
-                record.setNo(row.getCell(1).getStringCellValue().trim());
+                record.setNo(StringUtils.getExcelString(row.getCell(1)));
                 record.setZbh(getCellValue(row.getCell(2)));
-                record.setName(row.getCell(3).getStringCellValue().trim().replace("'", ""));
+                record.setName(StringUtils.getExcelString(row.getCell(3)).replace("'", ""));
                 record.setModel(getCellValue(row.getCell(4)).trim());
                 String level = getCellValue(row.getCell(5));
                 if(StringUtils.isBlank(level)){
@@ -884,13 +884,13 @@ public class CustomExcelImportUtil {
                 }else{
                     record.setInitialValue(new Double(value));
                 }
-                record.setTypeName(row.getCell(7).getStringCellValue().trim());
-                record.setUseType(getUseType(row.getCell(8).getStringCellValue().trim()));
+                record.setTypeName(StringUtils.getExcelString(row.getCell(7)));
+                record.setUseType(getUseType(StringUtils.getExcelString(row.getCell(8))));
                 record.setZz(getCellValue(row.getCell(9)));
                 record.setPositionName(getCellValue(row.getCell(10)));
                 record.setZzh(getCellValue(row.getCell(11)));
-                record.setProducerId(row.getCell(12).getStringCellValue().trim());
-                record.setSaveUserName(row.getCell(13).getStringCellValue().trim());
+                record.setProducerId(StringUtils.getExcelString(row.getCell(12)));
+                record.setSaveUserName(StringUtils.getExcelString(row.getCell(13)));
                 if (StringUtils.isBlank(getCellValue(row.getCell(14)))) {
                     record.setBuyDate(DateUtils.strToLocalDate("2014-01-01", DateUtils.PATTERN_YMD));
                 } else {
@@ -928,13 +928,13 @@ public class CustomExcelImportUtil {
                     }
                 }
                 record.setStatus(getSbInfoStatus(row.getCell(16).getStringCellValue()));
-                record.setRemark(row.getCell(17).getStringCellValue().trim());
+                record.setRemark(StringUtils.getExcelString(row.getCell(17)));
                 System.out.println("row.getPhysicalNumberOfCells(): " + row.getPhysicalNumberOfCells());
                 // 主子设备和是否大屏显示
                 if(row.getPhysicalNumberOfCells()>18){
-                    record.setIsChild(getChild(row.getCell(18).getStringCellValue().trim()));
-                    record.setIsShow(getShow(row.getCell(19).getStringCellValue().trim()));
-                    //record.setParentNo(row.getCell(20).getStringCellValue().trim());
+                    record.setIsChild(getChild(StringUtils.getExcelString(row.getCell(18))));
+                    record.setIsShow(getShow(StringUtils.getExcelString(row.getCell(19))));
+                    //record.setParentNo(row.getCell(20).StringUtils.getExcelString());
                 }else{// 默认值
                     record.setIsChild(SbInfoChildEnum.IS_NORMAL.getValue());
                     record.setIsShow(SbInfoShowEnum.NOT_SHOW.getValue());
@@ -942,7 +942,7 @@ public class CustomExcelImportUtil {
 
             } catch (Exception e) {
                 e.printStackTrace();
-                error.append(index).append(",");
+                error.append(index).append("错误地址:第"+i+"行");
             }
             result.add(record);
         }
@@ -983,39 +983,39 @@ public class CustomExcelImportUtil {
             String index = row.getCell(1).getStringCellValue() + "";
             try {
                 //i,j i:行 j:列
-                record.setCardNo(row.getCell(1).getStringCellValue().trim());
-                record.setName(row.getCell(2).getStringCellValue().trim().replace("'", ""));
-                record.setZzh(row.getCell(3).getStringCellValue().trim().replace("'", ""));
+                record.setCardNo(StringUtils.getExcelString(row.getCell(1)));
+                record.setName(StringUtils.getExcelString(row.getCell(2)).replace("'", ""));
+                record.setZzh(StringUtils.getExcelString(row.getCell(3)).replace("'", ""));
                 record.setModel(getCellValue(row.getCell(4)).trim());
                 record.setZz(getCellValue(row.getCell(5)));
-                record.setUseDept(row.getCell(6).getStringCellValue().trim());
-                record.setCph(row.getCell(7).getStringCellValue().trim());
-                record.setFdjxh(row.getCell(8).getStringCellValue().trim());
+                record.setUseDept(StringUtils.getExcelString(row.getCell(6)));
+                record.setCph(StringUtils.getExcelString(row.getCell(7)));
+                record.setFdjxh(StringUtils.getExcelString(row.getCell(8)));
                 record.setStatus(getSbMeasureInfoStatus(row.getCell(9).getStringCellValue()));
                 if(StringUtils.isBlank(row.getCell(10).getStringCellValue())){
                     record.setCheckDate(null);
                 }else{
-                    record.setCheckDate(DateUtils.strToLocalDate(row.getCell(10).getStringCellValue().trim(), DateUtils.PATTERN_YMD));
+                    record.setCheckDate(DateUtils.strToLocalDate(StringUtils.getExcelString(row.getCell(10)), DateUtils.PATTERN_YMD));
                 }
                 record.setCheckPeriod(Double.valueOf(row.getCell(11).getStringCellValue()).intValue());
                 if(StringUtils.isBlank(row.getCell(12).getStringCellValue())){
                     record.setCheckDate(null);
                 }else{
-                    record.setNextCheckDate(DateUtils.strToLocalDate(row.getCell(12).getStringCellValue().trim(), DateUtils.PATTERN_YMD));
+                    record.setNextCheckDate(DateUtils.strToLocalDate(StringUtils.getExcelString(row.getCell(12)), DateUtils.PATTERN_YMD));
                 }
-                record.setProducerId(row.getCell(13).getStringCellValue().trim());
-                record.setDph(row.getCell(14).getStringCellValue().trim());
-                record.setZaiz(row.getCell(15).getStringCellValue().trim());
+                record.setProducerId(StringUtils.getExcelString(row.getCell(13)));
+                record.setDph(StringUtils.getExcelString(row.getCell(14)));
+                record.setZaiz(StringUtils.getExcelString(row.getCell(15)));
                 record.setRlType(getRlType(row.getCell(16).getStringCellValue()));
-                record.setColor(row.getCell(17).getStringCellValue().trim().equals("是")?1:0);
-                record.setSbdh(row.getCell(18).getStringCellValue().trim());
-                record.setZbh(row.getCell(19).getStringCellValue().trim());
-                record.setRemark(row.getCell(20).getStringCellValue().trim());
+                record.setColor(StringUtils.getExcelString(row.getCell(17)).equals("是")?1:0);
+                record.setSbdh(StringUtils.getExcelString(row.getCell(18)));
+                record.setZbh(StringUtils.getExcelString(row.getCell(19)));
+                record.setRemark(StringUtils.getExcelString(row.getCell(20)));
                 record.setSeatNumber(Double.valueOf(row.getCell(21).getStringCellValue()).intValue());
-                record.setIsFinancing(row.getCell(22).getStringCellValue().trim().equals("是")?1:0);
-                record.setFinancingNo(row.getCell(23).getStringCellValue().trim());
-                record.setNo(row.getCell(24).getStringCellValue().trim());
-                record.setRemark2(row.getCell(25).getStringCellValue().trim());
+                record.setIsFinancing(StringUtils.getExcelString(row.getCell(22)).equals("是")?1:0);
+                record.setFinancingNo(StringUtils.getExcelString(row.getCell(23)));
+                record.setNo(StringUtils.getExcelString(row.getCell(24)));
+                record.setRemark2(StringUtils.getExcelString(row.getCell(25)));
             } catch (Exception e) {
                 error.append(index).append(",");
             }
@@ -1057,39 +1057,39 @@ public class CustomExcelImportUtil {
             String index = row.getCell(0).getStringCellValue() + "";
             try {
                 //i,j i:行 j:列
-                record.setCardNo(row.getCell(1).getStringCellValue().trim());
-                record.setName(row.getCell(2).getStringCellValue().trim().replace("'", ""));
-                record.setZzh(row.getCell(3).getStringCellValue().trim().replace("'", ""));
+                record.setCardNo(StringUtils.getExcelString(row.getCell(1)));
+                record.setName(StringUtils.getExcelString(row.getCell(2)).replace("'", ""));
+                record.setZzh(StringUtils.getExcelString(row.getCell(3)).replace("'", ""));
                 record.setModel(getCellValue(row.getCell(4)).trim());
                 record.setZz(getCellValue(row.getCell(5)));
-                record.setUseDept(row.getCell(6).getStringCellValue().trim());
-                record.setCph(row.getCell(7).getStringCellValue().trim());
-                record.setFdjxh(row.getCell(8).getStringCellValue().trim());
+                record.setUseDept(StringUtils.getExcelString(row.getCell(6)));
+                record.setCph(StringUtils.getExcelString(row.getCell(7)));
+                record.setFdjxh(StringUtils.getExcelString(row.getCell(8)));
                 record.setStatus(getSbMeasureInfoStatus(row.getCell(9).getStringCellValue()));
                 if(StringUtils.isBlank(row.getCell(10).getStringCellValue())){
                     record.setCheckDate(null);
                 }else{
-                    record.setCheckDate(DateUtils.strToLocalDate(row.getCell(10).getStringCellValue().trim(), DateUtils.PATTERN_YMD));
+                    record.setCheckDate(DateUtils.strToLocalDate(StringUtils.getExcelString(row.getCell(10)), DateUtils.PATTERN_YMD));
                 }
                 record.setCheckPeriod(Double.valueOf(row.getCell(11).getStringCellValue()).intValue());
                 if(StringUtils.isBlank(row.getCell(12).getStringCellValue())){
                     record.setCheckDate(null);
                 }else{
-                    record.setNextCheckDate(DateUtils.strToLocalDate(row.getCell(12).getStringCellValue().trim(), DateUtils.PATTERN_YMD));
+                    record.setNextCheckDate(DateUtils.strToLocalDate(StringUtils.getExcelString(row.getCell(12)), DateUtils.PATTERN_YMD));
                 }
-                record.setProducerId(row.getCell(13).getStringCellValue().trim());
-                record.setDph(row.getCell(14).getStringCellValue().trim());
-                record.setZaiz(row.getCell(15).getStringCellValue().trim());
+                record.setProducerId(StringUtils.getExcelString(row.getCell(13)));
+                record.setDph(StringUtils.getExcelString(row.getCell(14)));
+                record.setZaiz(StringUtils.getExcelString(row.getCell(15)));
                 record.setRlType(getRlType(row.getCell(16).getStringCellValue()));
-                record.setColor(row.getCell(17).getStringCellValue().trim().equals("是")?1:0);
-                record.setSbdh(row.getCell(18).getStringCellValue().trim());
-                record.setZbh(row.getCell(19).getStringCellValue().trim());
+                record.setColor(StringUtils.getExcelString(row.getCell(17)).equals("是")?1:0);
+                record.setSbdh(StringUtils.getExcelString(row.getCell(18)));
+                record.setZbh(StringUtils.getExcelString(row.getCell(19)));
                 record.setSeatNumber(Double.valueOf(row.getCell(20).getStringCellValue()).intValue());
-                record.setIsFinancing(row.getCell(21).getStringCellValue().trim().equals("是")?1:0);
-                record.setFinancingNo(row.getCell(22).getStringCellValue().trim());
-                record.setNo(row.getCell(23).getStringCellValue().trim());
-                record.setRemark(row.getCell(24).getStringCellValue().trim());
-                record.setRemark2(row.getCell(25).getStringCellValue().trim());
+                record.setIsFinancing(StringUtils.getExcelString(row.getCell(21)).equals("是")?1:0);
+                record.setFinancingNo(StringUtils.getExcelString(row.getCell(22)));
+                record.setNo(StringUtils.getExcelString(row.getCell(23)));
+                record.setRemark(StringUtils.getExcelString(row.getCell(24)));
+                record.setRemark2(StringUtils.getExcelString(row.getCell(25)));
             } catch (Exception e) {
                 error.append(index).append(",");
             }
@@ -1154,10 +1154,10 @@ public class CustomExcelImportUtil {
         int type = 0;// 没有负责人的,1有
         if(sheet.getRow(4).getCell(10) != null && StringUtils.isNotBlank(sheet.getRow(4).getCell(10).getStringCellValue())){
             type = 0;
-            sbNo = sheet.getRow(4).getCell(10).getStringCellValue().trim();
+            sbNo = StringUtils.getExcelString(sheet.getRow(4).getCell(10));
         }else{
             type = 1;
-            sbNo = sheet.getRow(4).getCell(13).getStringCellValue().trim();
+            sbNo = StringUtils.getExcelString(sheet.getRow(4).getCell(13));
         }
         StringBuffer error = new StringBuffer();
         LOGGER.info("文件行数:" + rowCounts);
@@ -1261,11 +1261,11 @@ public class CustomExcelImportUtil {
                 break;
             }
             try {
-                record.setId(row.getCell(0).getStringCellValue().trim());
-                record.setName(row.getCell(5).getStringCellValue().trim());
-                record.setNo(row.getCell(6).getStringCellValue().trim());
-                record.setRequirement(row.getCell(7).getStringCellValue().trim());
-                record.setRemark(row.getCell(8).getStringCellValue().trim());
+                record.setId(StringUtils.getExcelString(row.getCell(0)));
+                record.setName(StringUtils.getExcelString(row.getCell(5)));
+                record.setNo(StringUtils.getExcelString(row.getCell(6)));
+                record.setRequirement(StringUtils.getExcelString(row.getCell(7)));
+                record.setRemark(StringUtils.getExcelString(row.getCell(8)));
                 String period = row.getCell(9).getStringCellValue();
                 record.setPeriod(Double.valueOf(period).intValue());
                 String periodType = row.getCell(10).getStringCellValue();
@@ -1293,7 +1293,7 @@ public class CustomExcelImportUtil {
                 if(StringUtils.isNotBlank(nextDate)){
                     record.setNextDate(DateUtils.strToLocalDate(nextDate, DateUtils.PATTERN_YMD));
                 }
-                String checkUserType = row.getCell(13).getStringCellValue().trim();
+                String checkUserType = StringUtils.getExcelString(row.getCell(13));
                 if(StringUtils.isBlank(checkUserType)){
                     if(record.getPeriodType()>1){
                         record.setCheckUserType(CheckUserTypeEnum.REPAIR_USER.getValue());
@@ -1347,7 +1347,7 @@ public class CustomExcelImportUtil {
         CheckStandard record = null;
         String sbNo = "" ;
         int type = 0;// 没有负责人的,1有
-        sbNo = sheet.getRow(4).getCell(11).getStringCellValue().trim();
+        sbNo = StringUtils.getExcelString(sheet.getRow(4).getCell(11));
         StringBuffer error = new StringBuffer();
         LOGGER.info("文件行数:" + rowCounts);
         int sort = 1;
@@ -1373,7 +1373,7 @@ public class CustomExcelImportUtil {
     private static void setPerson(String sbNo, Row row, CheckStandard record) {
         //i,j i:行 j:列
         setPeriod(row, record);
-        record.setRequirement(row.getCell(12).getStringCellValue().trim());
+        record.setRequirement(StringUtils.getExcelString(row.getCell(12)));
         int length = record.getRequirement().length();
         length = (length>20)?20:length;
         record.setName(record.getRequirement().substring(0,length));
@@ -1388,7 +1388,7 @@ public class CustomExcelImportUtil {
     private static void setNoPerson(String sbNo, Row row, CheckStandard record) {
         //i,j i:行 j:列
         setPeriod(row, record);
-        record.setRequirement(row.getCell(9).getStringCellValue().trim());
+        record.setRequirement(StringUtils.getExcelString(row.getCell(9)));
         int length = record.getRequirement().length();
         length = (length>20)?20:length;
         record.setName(record.getRequirement().substring(0,length));
@@ -1403,7 +1403,7 @@ public class CustomExcelImportUtil {
     private static void setNoPersonOldVersion(String sbNo, Row row, CheckStandard record) {
         //i,j i:行 j:列
         setPeriodOldVersion(row, record);
-        record.setRequirement(row.getCell(10).getStringCellValue().trim());
+        record.setRequirement(StringUtils.getExcelString(row.getCell(10)));
         int length = record.getRequirement().length();
         length = (length>20)?20:length;
         record.setName(record.getRequirement().substring(0,length));
@@ -1535,10 +1535,10 @@ public class CustomExcelImportUtil {
             String index = row.getCell(1).getStringCellValue() + "";
             try {
                 //i,j i:行 j:列
-                record.setId(row.getCell(0).getStringCellValue().trim());
-                record.setNo(row.getCell(1).getStringCellValue().trim());
+                record.setId(StringUtils.getExcelString(row.getCell(0)));
+                record.setNo(StringUtils.getExcelString(row.getCell(1)));
                 record.setZbh(getCellValue(row.getCell(2)));
-                record.setName(row.getCell(3).getStringCellValue().trim().replace("'", ""));
+                record.setName(StringUtils.getExcelString(row.getCell(3)).replace("'", ""));
                 record.setModel(getCellValue(row.getCell(4)).trim());
                 String level = getCellValue(row.getCell(5));
                 if(StringUtils.isBlank(level)){
@@ -1552,15 +1552,15 @@ public class CustomExcelImportUtil {
                 }else{
                     record.setInitialValue(new Double(value));
                 }
-                record.setTypeName(row.getCell(7).getStringCellValue().trim());
-                record.setUseType(getUseType(row.getCell(8).getStringCellValue().trim()));
+                record.setTypeName(StringUtils.getExcelString(row.getCell(7)));
+                record.setUseType(getUseType(StringUtils.getExcelString(row.getCell(8))));
                 record.setZz(getCellValue(row.getCell(9)));
                 record.setCph(getCellValue(row.getCell(10)));
                 record.setZzh(getCellValue(row.getCell(11)));
-                record.setProducerId(row.getCell(12).getStringCellValue().trim());
-                record.setSaveUserName(row.getCell(13).getStringCellValue().trim());
-                record.setRepairUserName(row.getCell(14).getStringCellValue().trim());
-                record.setRepairUserNameSecond(row.getCell(15).getStringCellValue().trim());
+                record.setProducerId(StringUtils.getExcelString(row.getCell(12)));
+                record.setSaveUserName(StringUtils.getExcelString(row.getCell(13)));
+                record.setRepairUserName(StringUtils.getExcelString(row.getCell(14)));
+                record.setRepairUserNameSecond(StringUtils.getExcelString(row.getCell(15)));
                 if (StringUtils.isBlank(getCellValue(row.getCell(16)))) {
                     record.setBuyDate(DateUtils.strToLocalDate("2014-01-01", DateUtils.PATTERN_YMD));
                 } else {
@@ -1598,13 +1598,13 @@ public class CustomExcelImportUtil {
                     }
                 }
                 record.setStatus(getSbInfoStatus(row.getCell(18).getStringCellValue()));
-                record.setRemark(row.getCell(19).getStringCellValue().trim());
+                record.setRemark(StringUtils.getExcelString(row.getCell(19)));
                 //System.out.println("row.getPhysicalNumberOfCells(): " + row.getPhysicalNumberOfCells());
                 // 主子设备和是否大屏显示
                 if(row.getPhysicalNumberOfCells()>20){
-                    record.setIsChild(getChild(row.getCell(20).getStringCellValue().trim()));
-                    record.setIsShow(getShow(row.getCell(21).getStringCellValue().trim()));
-                    record.setPositionName(row.getCell(22).getStringCellValue().trim());
+                    record.setIsChild(getChild(StringUtils.getExcelString(row.getCell(20))));
+                    record.setIsShow(getShow(StringUtils.getExcelString(row.getCell(21))));
+                    record.setPositionName(StringUtils.getExcelString(row.getCell(22)));
                 }else{// 默认值
                     record.setIsChild(SbInfoChildEnum.IS_NORMAL.getValue());
                     record.setIsShow(SbInfoShowEnum.NOT_SHOW.getValue());
@@ -1890,7 +1890,7 @@ public class CustomExcelImportUtil {
 
             record = new PurchaseList();
             Row row = sheet.getRow(i);
-            String no = row.getCell(0).getStringCellValue().trim();
+            String no = StringUtils.getExcelString(row.getCell(0));
             try {
                 //i,j i:行 j:列
                 record.setNo(no);

+ 2 - 2
platform-service/src/main/java/com/platform/service/sb/impl/SbInfoServiceImpl.java

@@ -1831,9 +1831,9 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
                             break;
                         }
                     }
-                    if (!findProdcuer) {
+                    /*if (!findProdcuer) {
                         throw new BusinessException("找不到生产商,请先添加:" + item.getProducerId());
-                    }
+                    }*/
                     addItems.add(item);
                 }
                 if (!CollectionUtils.isEmpty(addItems)) {