Browse Source

Merge branch 'dev' into release-201846-wangcz

yuj 7 years ago
parent
commit
64e35ad6fe

+ 20 - 0
src/main/java/com/uas/platform/b2c/core/constant/ExcelConstant.java

@@ -23,6 +23,26 @@ public class ExcelConstant {
      */
     public static final Integer PER_SHEET_WRITE_COUNT = 100;
 
+    /**
+     * 客户最大上传量
+     */
+    public static final Integer CUSTOMER_MAX_UPLOAD = 2000;
+
+    /**
+     * 管理员最大上传量
+     */
+    public static final Integer ADMIN_MAX_UPLOAD = 20000;
+
+
+    /**
+     *  xls 表格
+     */
+    public static final String EXCEL_XLS = "xls";
+
+    /**
+     * xlsx 表格
+     */
+    public static final String EXCEL_XLSX = "xlsx";
 
 }
 

+ 5 - 0
src/main/java/com/uas/platform/b2c/core/constant/SplitChar.java

@@ -16,6 +16,11 @@ public class SplitChar {
 	 */
 	public static final String COMMA = ",";
 
+	/**
+	 * 点 . 字符串
+	 */
+	public static final String DOT = ".";
+
 	/**
 	 * 与字符  & 字符串
 	 */

+ 32 - 1
src/main/java/com/uas/platform/b2c/core/utils/PoiUtil.java

@@ -1,16 +1,23 @@
 package com.uas.platform.b2c.core.utils;
 
+import com.uas.platform.b2c.common.base.model.FileUpload;
 import com.uas.platform.b2c.core.constant.ExcelConstant;
+import com.uas.platform.b2c.core.constant.SplitChar;
+import com.uas.platform.core.exception.IllegalOperatorException;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.streaming.SXSSFWorkbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.Date;
 
@@ -133,6 +140,30 @@ public class PoiUtil {
     }
 
 
-
+    /**
+     * 解析文件,生成Excel
+     *
+     * @param uploadItem
+     * @return
+     */
+    public static Workbook resolveExcel(FileUpload uploadItem) {
+        String fileName = uploadItem.getFile().getOriginalFilename();
+        String suffix = fileName.substring(fileName.lastIndexOf(SplitChar.DOT) + 1);
+        InputStream is = null;
+        Workbook workbook = null;
+        try {
+            is = uploadItem.getFile().getInputStream();
+            if (ExcelConstant.EXCEL_XLS.equals(suffix)) {
+                workbook = new HSSFWorkbook(is);
+            } else if (ExcelConstant.EXCEL_XLSX.equals(suffix)) {
+                workbook = new XSSFWorkbook(is);
+            } else {
+                throw new IllegalOperatorException("文件格式不正确!请上传.xls或.xlsx格式的文件");
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return workbook;
+    }
 
 }

+ 17 - 2
src/main/java/com/uas/platform/b2c/prod/commodity/controller/ReleaseProductByBatchController.java

@@ -1,9 +1,11 @@
 package com.uas.platform.b2c.prod.commodity.controller;
 
 import com.uas.platform.b2c.common.base.model.FileUpload;
+import com.uas.platform.b2c.core.constant.ExcelConstant;
 import com.uas.platform.b2c.core.constant.IntegerConstant;
 import com.uas.platform.b2c.core.support.view.JxlsExcelView;
 import com.uas.platform.b2c.core.utils.FastjsonUtils;
+import com.uas.platform.b2c.core.utils.PoiUtil;
 import com.uas.platform.b2c.prod.commodity.dao.ReleaseProductByBatchDao;
 import com.uas.platform.b2c.prod.commodity.model.GoodsQtyPrice;
 import com.uas.platform.b2c.prod.commodity.model.ReleaseProductByBatch;
@@ -237,7 +239,7 @@ public class ReleaseProductByBatchController {
             } else {
                 throw new IllegalOperatorException("文件格式不正确!请上传.xls或.xlsx格式的文件");
             }
-            map = releaseProductByBatchService.releaseByWorkbook(workbook, selfSale, currency, isPerson, ignoreImport, false);
+            map = releaseProductByBatchService.releaseByWorkbook(workbook, selfSale, currency, isPerson, ignoreImport, false, ExcelConstant.CUSTOMER_MAX_UPLOAD);
         } catch (IOException e) {
             e.printStackTrace();
         }
@@ -245,6 +247,19 @@ public class ReleaseProductByBatchController {
         return map;
     }
 
+    /**
+     * 通过excel批量导入PCB商品发布(大量)
+     * @param uploadItem 上传内容
+     * @return
+     */
+    @RequestMapping(value = "/release/excel/admin", method = RequestMethod.POST)
+    public ModelMap adminReleaseExcel(FileUpload uploadItem) {
+        Workbook workbook = PoiUtil.resolveExcel(uploadItem);
+        ModelMap map = releaseProductByBatchService.adminReleaseExcel(workbook);
+        logger.info("批量上架模块", "导入Excel批量上传商品");
+        return map;
+    }
+
     /**
      * 通过excel批量导入PCB商品发布(大量)
      * @param uploadItem 上传内容
@@ -269,7 +284,7 @@ public class ReleaseProductByBatchController {
                 throw new IllegalOperatorException("文件格式不正确!请上传.xls或.xlsx格式的文件");
             }
             // pcb都为店铺自营、非个人上传、属于PCB模块上传
-            map = releaseProductByBatchService.releaseByWorkbook(workbook, true, currency, IntegerConstant.NO_SHORT.intValue(), ignoreImport, true);
+            map = releaseProductByBatchService.releaseByWorkbook(workbook, true, currency, IntegerConstant.NO_SHORT.intValue(), ignoreImport, true, ExcelConstant.CUSTOMER_MAX_UPLOAD);
         } catch (IOException e) {
             e.printStackTrace();
         }

+ 1 - 1
src/main/java/com/uas/platform/b2c/prod/commodity/model/Product.java

@@ -238,7 +238,7 @@ public class Product {
 	/**
 	 * 匹配结果
 	 */
-	@OneToMany(mappedBy = "product", cascade = { CascadeType.REFRESH }, fetch = FetchType.EAGER)
+	@OneToMany(mappedBy = "product", cascade = { CascadeType.REFRESH }, fetch = FetchType.LAZY)
 	private Set<ProductMatchResult> matchresults;
 
 	/**

+ 11 - 1
src/main/java/com/uas/platform/b2c/prod/commodity/service/ReleaseProductByBatchService.java

@@ -1,5 +1,6 @@
 package com.uas.platform.b2c.prod.commodity.service;
 
+import com.uas.platform.b2c.common.base.model.FileUpload;
 import com.uas.platform.b2c.prod.commodity.model.ReleaseProductByBatch;
 import com.uas.platform.b2c.prod.store.model.StoreIn;
 import com.uas.platform.core.model.PageInfo;
@@ -34,9 +35,18 @@ public interface ReleaseProductByBatchService {
      * @param selfSale 是否自售
      * @param currency
      * @param isPcb 是否PCB模块上传
+     * @param maxUploadNum 最大上传量
      * @return model map
      */
-    public ModelMap releaseByWorkbook(Workbook workbook, Boolean selfSale, String currency, Integer isPerson, Integer repeatImport, boolean isPcb);
+    public ModelMap releaseByWorkbook(Workbook workbook, Boolean selfSale, String currency, Integer isPerson, Integer repeatImport, boolean isPcb, Integer maxUploadNum);
+
+    /**
+     * 管理员批量导入信息
+     *
+     * @param workbook
+     * @return
+     */
+    ModelMap adminReleaseExcel(Workbook workbook);
 
     /**
      * 通过Excel上传资料修改商品

+ 22 - 8
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ReleaseProductByBatchServiceImpl.java

@@ -3,10 +3,7 @@ package com.uas.platform.b2c.prod.commodity.service.impl;
 import com.uas.platform.b2c.common.account.service.EnterpriseService;
 import com.uas.platform.b2c.common.base.dao.CommonDao;
 import com.uas.platform.b2c.core.config.SysConf;
-import com.uas.platform.b2c.core.constant.IntegerConstant;
-import com.uas.platform.b2c.core.constant.ReleaseStatus;
-import com.uas.platform.b2c.core.constant.SplitChar;
-import com.uas.platform.b2c.core.constant.Status;
+import com.uas.platform.b2c.core.constant.*;
 import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.core.utils.NumberUtil;
 import com.uas.platform.b2c.core.utils.RegexConstant;
@@ -232,10 +229,11 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 	 * @param currency  当前选中的币别  (RMB/USD)
 	 * @param isPerson 是否是个人上传产品
 	 * @param ignoreImport 1是忽略导入,0是覆盖导入
+	 * @param maxUploadNum 最大上传量
 	 * @author hejq
 	 */
 	@Override
-	public ModelMap releaseByWorkbook(Workbook workbook, Boolean selfSale, String currency, Integer isPerson, Integer ignoreImport, boolean isPcb) {
+	public ModelMap releaseByWorkbook(Workbook workbook, Boolean selfSale, String currency, Integer isPerson, Integer ignoreImport, boolean isPcb, Integer maxUploadNum) {
 		// 是否上传个人物料
 		boolean isAPerson = false;
 		if (null != isPerson && isPerson.intValue() == IntegerConstant.YES_SHORT.intValue()) {
@@ -258,8 +256,8 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 				throw new IllegalOperatorException("表格模板不正确!请重新下载最新模板");
 		}
 		int rowNum = SheetUtil.getSheetLastNum(sheet, isPcb ? UploadConstant.MAX_TOTAL_COLUMN_PCB : UploadConstant.MAX_TOTAL_COLUMN);
-		if (rowNum > 2002) {
-			throw new IllegalOperatorException("您上传的信息超过2000条,请拆分成2000以下再上传");
+		if (rowNum > (maxUploadNum + 2)) {
+			throw new IllegalOperatorException("您上传的信息超过"+ maxUploadNum + "条,请拆分成" + maxUploadNum + "以下再上传");
 		}
 		if (rowNum < 2) {
 			throw new IllegalOperatorException("请填写上传信息");
@@ -341,7 +339,23 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 		return modelMap;
 	}
 
-    /**
+	/**
+	 * 管理员批量导入信息
+	 *
+	 * @param workbook
+	 * @return
+	 */
+	@Override
+	public ModelMap adminReleaseExcel(Workbook workbook) {
+		StoreIn storeIn = storeInService.findByEnUU(SystemSession.getUser().getEnterprise().getUu());
+		Boolean selfSale = (storeIn == null || storeIn.getStatus() != StoreStatus.OPENED) ? false : true;
+		ResultMap resultMap = enterpriseService.getCurrencyByRegisterAddress();
+		String currency = (resultMap.getCode() == CodeType.OK.code()) ? (String) resultMap.getData() : Currency.RMB;
+		ModelMap map = releaseByWorkbook(workbook, selfSale, currency, IntegerConstant.NO_SHORT.intValue(), IntegerConstant.YES_SHORT, false, ExcelConstant.ADMIN_MAX_UPLOAD);
+		return map;
+	}
+
+	/**
      * 统计批量上传数据相关
      *
      * @param modelMap ModelMap

+ 8 - 5
src/main/webapp/resources/view/usercenter/b2b/fa/arCheck.html

@@ -516,6 +516,12 @@
       <!--<i class="fa fa-plus-square fa-fw"></i>新增对账单-->
       <!--</a>-->
       <!--</li>-->
+
+      <li style="float: right;font-size: 14px;cursor: pointer;" ng-show="active !== 'all'">
+        <div class="btn-group btn-group-sm"  style="float: right;font-size: 14px;cursor: pointer;text-align: right;height: 40px;line-height: 40px; margin-right: 20px;"  ng-click="setActive('all')">
+          <img src="static/img/vendor/images/backIcon.png" width="20"/>返回
+        </div>
+      </li>
       <li style="float: right;font-size: 14px;cursor: pointer;" ng-show="active === 'all'">
         <div class="btn-group btn-group-sm"  style="float: right;
     font-size: 14px;
@@ -531,11 +537,6 @@
           <!--<b class="new-dot" ng-if="unread.cancelled > 0">{{unread.cancelled > 99 ? '99+' : unread.cancelled}}</b>-->
         </div>
       </li>
-      <li style="float: right;font-size: 14px;cursor: pointer;" ng-show="active !== 'all'">
-        <div class="btn-group btn-group-sm"  style="float: right;font-size: 14px;cursor: pointer;text-align: right;height: 40px;line-height: 40px; margin-right: 20px;"  ng-click="setActive('all')">
-          <img src="static/img/vendor/images/backIcon.png" width="20"/>返回
-        </div>
-      </li>
 
     </ul>
   </div>
@@ -1037,6 +1038,7 @@
             <!--<th width="70">客户<br>名称</th>-->
             <th width="70">采购单</th>
             <th width="60">发货单</th>
+            <th width="90">单据日期</th>
             <th width="60">验收单</th>
             <th width="70">物料编号</th>
             <th width="70">物料名称</th>
@@ -1065,6 +1067,7 @@
           <tr ng-repeat="check in data" ng-click="checkOne(check);getTotalMoney()" class="thAlign" style="height: 40px;">
             <td width="70">{{::check.ordercode}}</td>
             <td width="60">{{::check.sendcode}}</td>
+            <td width="90">{{::check.pidate | date:'yyyy年MM月dd日'  || '-'}}</td>
             <td width="60">{{::check.inoutno}}</td>
             <td width="70" title="{{check.prodcode}}">
               <div style="display: -webkit-box; text-overflow: ellipsis; overflow: hidden; text-overflow: ellipsis; -webkit-line-clamp: 3; -webkit-box-orient: vertical;">{{::check.prodcode}}</div>

+ 14 - 12
src/main/webapp/resources/view/usercenter/b2b/fa/arCheck_detail.html

@@ -318,12 +318,14 @@
       <table class="block table table-default table-striped table-hover">
         <thead>
         <tr class="header">
-          <th width="40" style="padding:8px 0;font-size: 16px">行号</th>
-          <th width="150" style="font-size: 16px">商品</th>
+          <!--<th width="40" style="padding:8px 0;font-size: 16px">行号</th>-->
           <th width="80" style="font-size: 16px">采购单号</th>
-          <th style="font-size: 16px">采购序号</th>
           <th width="100" style="font-size: 16px">验收单</th>
-          <th style="font-size: 16px">验收单序号</th>
+          <th width="150" style="font-size: 16px">商品</th>
+
+          <!--<th style="font-size: 16px">采购序号</th>-->
+
+          <!--<th style="font-size: 16px">验收单序号</th>-->
           <th style="font-size: 16px">单价</th>
           <!--<th width="80">单据类型</th>-->
           <th style="font-size: 16px">税率</th>
@@ -333,15 +335,17 @@
         </thead>
         <tbody>
         <tr ng-repeat="item in order.items track by item.id">
-          <td ng-bind="item.number" style="padding:8px 0;"></td>
+          <!--<td ng-bind="item.number" style="padding:8px 0;"></td>-->
+          <td ng-bind="item.orderCode"></td>
+          <td ng-bind="item.inoutno"></td>
           <td style="max-width: 250px;" class="text-left">
             <div>编号: <span ng-bind="item.prodCode"></span></div>
             <div>规格: <span ng-bind="item.prodSpec"></span></div>
           </td>
-          <td ng-bind="item.orderCode"></td>
-          <td style="text-align: center" ng-bind="item.orderDetno"></td>
-          <td ng-bind="item.inoutno"></td>
-          <td style="text-align: center" ng-bind="item.inoutnodetno"></td>
+
+          <!--<td style="text-align: center" ng-bind="item.orderDetno"></td>-->
+
+          <!--<td style="text-align: center" ng-bind="item.inoutnodetno"></td>-->
 
           <!--<td ng-bind="item.orderClass"></td>-->
           <td ng-bind="isUser?'-':item.price"></td>
@@ -350,9 +354,7 @@
           <td style="text-align: center" ng-bind="isUser?'-':(item.amount | number:2)"></td>
         </tr>
         <tr>
-          <td></td>
-          <td></td>
-          <td></td>
+
           <td></td>
           <td></td>
           <td></td>

+ 8 - 5
src/main/webapp/resources/view/vendor/b2b/apCheck.html

@@ -515,6 +515,12 @@
           <!--<i class="fa fa-plus-square fa-fw"></i>新增对账单-->
         <!--</a>-->
       <!--</li>-->
+
+        <li style="float: right;font-size: 14px;cursor: pointer;" ng-show="active !== 'all'">
+            <div class="btn-group btn-group-sm"  style="float: right;font-size: 14px;cursor: pointer;text-align: right;height: 40px;line-height: 40px; margin-right: 20px;"  ng-click="setActive('all')">
+                <img src="static/img/vendor/images/backIcon.png" width="20"/>返回
+            </div>
+        </li>
         <li style="float: right;font-size: 14px;cursor: pointer;" ng-show="active === 'all'">
             <div class="btn-group btn-group-sm"  style="    float: right;
     font-size: 14px;
@@ -530,11 +536,6 @@
                 <!--<b class="new-dot" ng-if="unread.cancelled > 0">{{unread.cancelled > 99 ? '99+' : unread.cancelled}}</b>-->
             </div>
         </li>
-        <li style="float: right;font-size: 14px;cursor: pointer;" ng-show="active !== 'all'">
-            <div class="btn-group btn-group-sm"  style="float: right;font-size: 14px;cursor: pointer;text-align: right;height: 40px;line-height: 40px; margin-right: 20px;"  ng-click="setActive('all')">
-                <img src="static/img/vendor/images/backIcon.png" width="20"/>返回
-            </div>
-        </li>
 
     </ul>
   </div>
@@ -1042,6 +1043,7 @@
                   <!--<th width="70">客户<br>名称</th>-->
                   <th width="70">采购单</th>
                   <th width="60">发货单</th>
+                  <th width="90">单据日期</th>
                   <th width="60">验收单</th>
                   <th width="70">物料编号</th>
                   <th width="70">物料名称</th>
@@ -1075,6 +1077,7 @@
                   </td>
                   <td width="70">{{::check.ordercode}}</td>
                   <td width="60">{{::check.sendcode}}</td>
+                  <td width="90">{{::check.pidate | date:'yyyy年MM月dd日'  || '-'}}</td>
                   <td width="60">{{::check.inoutno}}</td>
                   <td width="70" title="{{check.prodcode}}">
                       <div style="display: -webkit-box; text-overflow: ellipsis; overflow: hidden; text-overflow: ellipsis; -webkit-line-clamp: 3; -webkit-box-orient: vertical;">{{::check.prodcode}}</div>

+ 3 - 3
src/main/webapp/resources/view/vendor/b2b/apCheck_detail.html

@@ -282,10 +282,10 @@
       <table class="block table table-default table-striped table-hover">
         <thead>
         <tr class="header">
-          <th width="40">采购单号</th>
-          <th width="100">验收单</th>
+          <th width="150">采购单号</th>
+          <th width="150">验收单</th>
           <!--<th width="30" style="padding:8px 0;">行号</th>-->
-          <th width="120">商品</th>
+          <th width="150">商品</th>
           <!--<th>采购序号</th>-->
           <!--<th>验收单序号</th>-->
           <th>单价</th>