Просмотр исходного кода

求购增加类目,规格字段

liusw 8 лет назад
Родитель
Сommit
056cd6771b

+ 15 - 0
src/main/java/com/uas/platform/b2c/trade/seek/model/SeekPurchaseByBatch.java

@@ -85,6 +85,12 @@ public class SeekPurchaseByBatch {
     @Column(name = "sp_kind")
     @Column(name = "sp_kind")
     private String kind;
     private String kind;
 
 
+    /**
+     * 规格
+     */
+    @Column(name = "sp_spec")
+    private String spec;
+
     /**
     /**
      * 求购发布时间
      * 求购发布时间
      */
      */
@@ -109,6 +115,15 @@ public class SeekPurchaseByBatch {
     @Transient
     @Transient
     private List<Map<String, Object>> brandWord;
     private List<Map<String, Object>> brandWord;
 
 
+
+    public String getSpec() {
+        return spec;
+    }
+
+    public void setSpec(String spec) {
+        this.spec = spec;
+    }
+
     public Long getId() {
     public Long getId() {
         return id;
         return id;
     }
     }

+ 80 - 35
src/main/java/com/uas/platform/b2c/trade/seek/service/impl/SeekPurchaseBomServiceImpl.java

@@ -50,6 +50,8 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.regex.Pattern;
 
 
 /**
 /**
+ * bom求购实现类
+ *
  * @author liusw
  * @author liusw
  * @version 2018/1/19 15:06
  * @version 2018/1/19 15:06
  */
  */
@@ -94,9 +96,24 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
 
 
     private static final UsageBufferedLogger logger = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
     private static final UsageBufferedLogger logger = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
 
 
-    private int mallColNum = 8;
+    private int mallColNum = 10;
     private int mallRowNum = 500;
     private int mallRowNum = 500;
 
 
+    /**
+     * excel列名
+     */
+    public static final int CODENUM = 0;
+    public static final int BRANDNUM = 1;
+    public static final int DEADLINENUM = 2;
+    public static final int AMOUNTNUM = 3;
+    public static final int CURRENCYNUM = 4;
+    public static final int UNITPRICENUM = 5;
+    public static final int ENCAPSULATIONNUM = 8;
+    public static final int PRODUCEDATENUM = 9;
+    public static final int KINDNUM = 6;
+    public static final int SPECNUM = 7;
+
+
     /**
     /**
      * 导入bom
      * 导入bom
      * @param workbook
      * @param workbook
@@ -125,7 +142,6 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
         seekPurchaseBom = seekPurchaseBomDao.save(seekPurchaseBom);
         seekPurchaseBom = seekPurchaseBomDao.save(seekPurchaseBom);
         // 获取第一行的信息
         // 获取第一行的信息
         Row headerRow = sheet.getRow(0);
         Row headerRow = sheet.getRow(0);
-        int total = 0;
         int blankNum = 0;
         int blankNum = 0;
         if (headerRow != null) {
         if (headerRow != null) {
             // 验证是否为商城模板
             // 验证是否为商城模板
@@ -162,14 +178,14 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
      * @return
      * @return
      */
      */
     private boolean vaidSample(Row row) {
     private boolean vaidSample(Row row) {
-        Object codeCellObj = readWorkBookCell(row.getCell(0), Cell.CELL_TYPE_STRING,
-                0, 0);
+        Object codeCellObj = readWorkBookCell(row.getCell(CODENUM), Cell.CELL_TYPE_STRING,
+                0, CODENUM);
         String codeString = StringUtilB2C.getStr(codeCellObj);
         String codeString = StringUtilB2C.getStr(codeCellObj);
-        Object brandCellObj = readWorkBookCell(row.getCell(1), Cell.CELL_TYPE_STRING,
-                0, 1);
+        Object brandCellObj = readWorkBookCell(row.getCell(BRANDNUM), Cell.CELL_TYPE_STRING,
+                0, BRANDNUM);
         String brandString = StringUtilB2C.getStr(brandCellObj);
         String brandString = StringUtilB2C.getStr(brandCellObj);
-        Object produceDateCellObj = readWorkBookCell(row.getCell(7), Cell.CELL_TYPE_STRING,
-                0, 7);
+        Object produceDateCellObj = readWorkBookCell(row.getCell(PRODUCEDATENUM), Cell.CELL_TYPE_STRING,
+                0, PRODUCEDATENUM);
         String produceDateString = StringUtilB2C.getStr(produceDateCellObj);
         String produceDateString = StringUtilB2C.getStr(produceDateCellObj);
         if ("只能填数字、英文、英文特殊符号".equals(codeString) || "请勿用中文特殊符号".equals(brandCellObj) || "不超过6个汉字或12个字符".equals(produceDateString)) {
         if ("只能填数字、英文、英文特殊符号".equals(codeString) || "请勿用中文特殊符号".equals(brandCellObj) || "不超过6个汉字或12个字符".equals(produceDateString)) {
             return true;
             return true;
@@ -183,23 +199,23 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
      * @return
      * @return
      */
      */
     private boolean vaildTemplete(Row headerRow) {
     private boolean vaildTemplete(Row headerRow) {
-        Object codeCellObj = readWorkBookCell(headerRow.getCell(0), Cell.CELL_TYPE_STRING,
-                0, 0);
+        Object codeCellObj = readWorkBookCell(headerRow.getCell(CODENUM), Cell.CELL_TYPE_STRING,
+                0, CODENUM);
         if (!"产品型号".equals(StringUtilB2C.getStr(codeCellObj))) {
         if (!"产品型号".equals(StringUtilB2C.getStr(codeCellObj))) {
             return false;
             return false;
         }
         }
-        Object brandCellObj = readWorkBookCell(headerRow.getCell(1), Cell.CELL_TYPE_STRING,
-                0, 1);
+        Object brandCellObj = readWorkBookCell(headerRow.getCell(BRANDNUM), Cell.CELL_TYPE_STRING,
+                0, BRANDNUM);
         if (!"品牌名称".equals(StringUtilB2C.getStr(brandCellObj))) {
         if (!"品牌名称".equals(StringUtilB2C.getStr(brandCellObj))) {
             return false;
             return false;
         }
         }
-        Object deadlineCellObj = readWorkBookCell(headerRow.getCell(2), Cell.CELL_TYPE_STRING,
-                0, 2);
+        Object deadlineCellObj = readWorkBookCell(headerRow.getCell(DEADLINENUM), Cell.CELL_TYPE_STRING,
+                0, DEADLINENUM);
         if (!"截止时间".equals(StringUtilB2C.getStr(deadlineCellObj))) {
         if (!"截止时间".equals(StringUtilB2C.getStr(deadlineCellObj))) {
             return false;
             return false;
         }
         }
-        Object produceDateCellObj = readWorkBookCell(headerRow.getCell(7), Cell.CELL_TYPE_STRING,
-                0, 7);
+        Object produceDateCellObj = readWorkBookCell(headerRow.getCell(PRODUCEDATENUM), Cell.CELL_TYPE_STRING,
+                0, PRODUCEDATENUM);
         if (!"生产日期".equals(StringUtilB2C.getStr(produceDateCellObj))) {
         if (!"生产日期".equals(StringUtilB2C.getStr(produceDateCellObj))) {
             return false;
             return false;
         }
         }
@@ -217,8 +233,8 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
         // 统计为空的个数
         // 统计为空的个数
         int result = 0;
         int result = 0;
         // 型号
         // 型号
-        Object codeValue = readWorkBookCell(row.getCell(0), Cell.CELL_TYPE_STRING,
-                rowNum, 0);
+        Object codeValue = readWorkBookCell(row.getCell(CODENUM), Cell.CELL_TYPE_STRING,
+                rowNum, CODENUM);
         if (StringUtils.isEmpty(codeValue)) {
         if (StringUtils.isEmpty(codeValue)) {
             result += 1;
             result += 1;
         } else {
         } else {
@@ -235,8 +251,8 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
         }
         }
 
 
         // 品牌
         // 品牌
-        Object brandValue = readWorkBookCell(row.getCell(1), Cell.CELL_TYPE_STRING,
-                rowNum, 1);
+        Object brandValue = readWorkBookCell(row.getCell(BRANDNUM), Cell.CELL_TYPE_STRING,
+                rowNum, BRANDNUM);
         if (StringUtils.isEmpty(brandValue)) {
         if (StringUtils.isEmpty(brandValue)) {
             result += 1;
             result += 1;
         } else {
         } else {
@@ -249,12 +265,12 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
             } catch (UnsupportedEncodingException e) {
             } catch (UnsupportedEncodingException e) {
                 e.printStackTrace();
                 e.printStackTrace();
             }
             }
-            seekPurchaseByBatch.setBrand(StringUtilB2C.replaceLineBreak(StringUtilB2C.getStr(brandValue)));
+            seekPurchaseByBatch.setBrand(brand);
         }
         }
 
 
         // 截止日期
         // 截止日期
-        Object deadlineValue = readWorkBookCell(row.getCell(2), Cell.CELL_TYPE_STRING,
-                rowNum, 2);
+        Object deadlineValue = readWorkBookCell(row.getCell(DEADLINENUM), Cell.CELL_TYPE_STRING,
+                rowNum, DEADLINENUM);
         if (StringUtils.isEmpty(deadlineValue)) {
         if (StringUtils.isEmpty(deadlineValue)) {
             result += 1;
             result += 1;
         } else {
         } else {
@@ -282,8 +298,8 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
         }
         }
 
 
         // 求购数量
         // 求购数量
-        Object amountValue = readWorkBookCell(row.getCell(3), Cell.CELL_TYPE_STRING,
-                rowNum, 3);
+        Object amountValue = readWorkBookCell(row.getCell(AMOUNTNUM), Cell.CELL_TYPE_STRING,
+                rowNum, AMOUNTNUM);
         if (!StringUtils.isEmpty(amountValue)) {
         if (!StringUtils.isEmpty(amountValue)) {
             try {
             try {
                 Double amount = Double.valueOf(StringUtilB2C.replaceLineBreak(StringUtilB2C.getStr(amountValue)));
                 Double amount = Double.valueOf(StringUtilB2C.replaceLineBreak(StringUtilB2C.getStr(amountValue)));
@@ -298,8 +314,8 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
         }
         }
 
 
         // 币别
         // 币别
-        Object currencyValue = readWorkBookCell(row.getCell(4), Cell.CELL_TYPE_STRING,
-                rowNum, 4);
+        Object currencyValue = readWorkBookCell(row.getCell(CURRENCYNUM), Cell.CELL_TYPE_STRING,
+                rowNum, CURRENCYNUM);
         if (!StringUtils.isEmpty(currencyValue)) {
         if (!StringUtils.isEmpty(currencyValue)) {
             try {
             try {
                 String currency = StringUtilB2C.replaceLineBreak(StringUtilB2C.getStr(currencyValue));
                 String currency = StringUtilB2C.replaceLineBreak(StringUtilB2C.getStr(currencyValue));
@@ -310,8 +326,8 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
         }
         }
 
 
         // 单价
         // 单价
-        Object unitPriceValue = readWorkBookCell(row.getCell(5), Cell.CELL_TYPE_STRING,
-                rowNum, 5);
+        Object unitPriceValue = readWorkBookCell(row.getCell(UNITPRICENUM), Cell.CELL_TYPE_STRING,
+                rowNum, UNITPRICENUM);
         if (!StringUtils.isEmpty(unitPriceValue)) {
         if (!StringUtils.isEmpty(unitPriceValue)) {
             try {
             try {
                 Double unitPrice = Double.valueOf(StringUtilB2C.replaceLineBreak(StringUtilB2C.getStr(unitPriceValue)));
                 Double unitPrice = Double.valueOf(StringUtilB2C.replaceLineBreak(StringUtilB2C.getStr(unitPriceValue)));
@@ -329,8 +345,8 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
         }
         }
 
 
         // 封装
         // 封装
-        Object encapsulationValue = readWorkBookCell(row.getCell(6), Cell.CELL_TYPE_STRING,
-                rowNum, 6);
+        Object encapsulationValue = readWorkBookCell(row.getCell(ENCAPSULATIONNUM), Cell.CELL_TYPE_STRING,
+                rowNum, ENCAPSULATIONNUM);
         if (!StringUtils.isEmpty(encapsulationValue)) {
         if (!StringUtils.isEmpty(encapsulationValue)) {
             try {
             try {
                 String encapsulation = StringUtilB2C.replaceLineBreak(StringUtilB2C.getStr(encapsulationValue));
                 String encapsulation = StringUtilB2C.replaceLineBreak(StringUtilB2C.getStr(encapsulationValue));
@@ -343,8 +359,8 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
 
 
 
 
         // 生产日期
         // 生产日期
-        Object produceDateValue = readWorkBookCell(row.getCell(7), Cell.CELL_TYPE_STRING,
-                rowNum, 7);
+        Object produceDateValue = readWorkBookCell(row.getCell(PRODUCEDATENUM), Cell.CELL_TYPE_STRING,
+                rowNum, PRODUCEDATENUM);
         if (!StringUtils.isEmpty(produceDateValue)) {
         if (!StringUtils.isEmpty(produceDateValue)) {
             try {
             try {
                 String produceDate = StringUtilB2C.replaceLineBreak(StringUtilB2C.getStr(produceDateValue));
                 String produceDate = StringUtilB2C.replaceLineBreak(StringUtilB2C.getStr(produceDateValue));
@@ -354,6 +370,35 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
                 seekPurchaseByBatch.setProduceDate(null);
                 seekPurchaseByBatch.setProduceDate(null);
             }
             }
         }
         }
+
+        // 规格
+        Object specValue = readWorkBookCell(row.getCell(SPECNUM), Cell.CELL_TYPE_STRING,
+                rowNum, SPECNUM);
+        if (!StringUtils.isEmpty(specValue)) {
+            try {
+                String spec = StringUtilB2C.replaceLineBreak(StringUtilB2C.getStr(specValue));
+                spec = com.uas.platform.b2c.fa.payment.utils.StringUtils.cutOutString(spec, 20);
+                if (!match(spec)) {
+                    spec = null;
+                }
+                seekPurchaseByBatch.setSpec(spec);
+            } catch (Exception e) {
+                seekPurchaseByBatch.setSpec(null);
+            }
+        }
+
+        // 类目
+        Object kindValue = readWorkBookCell(row.getCell(KINDNUM), Cell.CELL_TYPE_STRING,
+                rowNum, KINDNUM);
+        if (!StringUtils.isEmpty(kindValue)) {
+            try {
+                String kind = StringUtilB2C.replaceLineBreak(StringUtilB2C.getStr(kindValue));
+                kind = com.uas.platform.b2c.fa.payment.utils.StringUtils.cutOutString(kind, 20);
+                seekPurchaseByBatch.setKind(kind);
+            } catch (Exception e) {
+                seekPurchaseByBatch.setKind(null);
+            }
+        }
         return result;
         return result;
     }
     }
 
 
@@ -468,9 +513,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
             SeekPurchase seekPurchase = new SeekPurchase();
             SeekPurchase seekPurchase = new SeekPurchase();
             Calendar now = Calendar.getInstance();
             Calendar now = Calendar.getInstance();
             now.add(Calendar.DAY_OF_MONTH, 91);
             now.add(Calendar.DAY_OF_MONTH, 91);
-            //Date deadlineMax = DateUtils.addTime(new Date(System.currentTimeMillis()), 90, 23, 59 ,59);
             if (!StringUtils.isEmpty(batch.getCode()) && !StringUtils.isEmpty(batch.getBrand()) && !StringUtils.isEmpty(batch.getDeadline()) && batch.getDeadline().compareTo(now.getTime()) != 1) {
             if (!StringUtils.isEmpty(batch.getCode()) && !StringUtils.isEmpty(batch.getBrand()) && !StringUtils.isEmpty(batch.getDeadline()) && batch.getDeadline().compareTo(now.getTime()) != 1) {
-                //seekPurchase = (SeekPurchase) batch;
                 PurcInquiryItem inquiryItem = new PurcInquiryItem();
                 PurcInquiryItem inquiryItem = new PurcInquiryItem();
                 inquiryItem.setProdTitle(batch.getCode());
                 inquiryItem.setProdTitle(batch.getCode());
                 inquiryItem.setUserUU(user.getUserUU());
                 inquiryItem.setUserUU(user.getUserUU());
@@ -485,6 +528,8 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
                 inquiryItem.setProduceDate(batch.getProduceDate());
                 inquiryItem.setProduceDate(batch.getProduceDate());
                 inquiryItem.setDate(new Date());
                 inquiryItem.setDate(new Date());
                 inquiryItem.setEndDate(batch.getDeadline());
                 inquiryItem.setEndDate(batch.getDeadline());
+                inquiryItem.setProdTitle(batch.getKind());
+                inquiryItem.setSpec(batch.getSpec());
                 if (StringUtils.isEmpty(endDate)) {
                 if (StringUtils.isEmpty(endDate)) {
                     endDate = batch.getDeadline();
                     endDate = batch.getDeadline();
                 } else {
                 } else {

BIN
src/main/resources/jxls-tpl/trade/seekPurchaseByBatch.xls