Browse Source

Merge branch 'release-201840-wangcz' into dev

wangcz 7 years ago
parent
commit
2c587d4b4f

+ 9 - 1
src/main/java/com/uas/platform/b2c/prod/commodity/dao/ProductDao.java

@@ -205,13 +205,21 @@ public interface ProductDao extends JpaSpecificationExecutor<Product>, JpaReposi
     List<Product> findProductInId(@Param("idList") List<Long> idList);
 
     /**
-     * 根据enuu查询所有的prids
+     * 根据enuu和standard查询所有的prids
      * @param enuu
      * @return
      */
     @Query(value = "select p.id from Product p where p.enUU = :enuu and p.standard = :standard")
     List<Long> findPridsByEnuuAndStardand(@Param("enuu") Long enuu, @Param("standard") Integer standard);
 
+    /**
+     * 根据enuu查询所有的prids
+     * @param enuu
+     * @return
+     */
+    @Query(value = "select p.id from Product p where p.enUU = :enuu")
+    List<Long> findPridsByEnuu(@Param("enuu") Long enuu);
+
     /**
      * 更新物料信息为已上传
      * @param list

+ 14 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/model/Goods.java

@@ -301,6 +301,12 @@ public class Goods implements Serializable {
 	@Column(name = "go_returninweek")
 	private Short returnInWeek = (short)0;
 
+	/**
+	 * 上架时间
+	 */
+	@Column(name = "go_publish_time")
+	private Date publishTime;
+
 	/**
 	 * 当前登录企业是否对此批次已送样(默认False)
 	 */
@@ -2126,4 +2132,12 @@ public class Goods implements Serializable {
 		this.costPrice = costPrice;
 		return this;
 	}
+
+	public Date getPublishTime() {
+		return publishTime;
+	}
+
+	public void setPublishTime(Date publishTime) {
+		this.publishTime = publishTime;
+	}
 }

+ 49 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/service/ProductService.java

@@ -489,4 +489,53 @@ public interface ProductService {
      * @return Goods
      */
     Goods checkPrice(Goods goods);
+
+    /**
+     * 校验传入的物料信息
+     *
+     * @param product 物料信息
+     * @return ResultMap
+     */
+    ResultMap checkProductInfo(Product product);
+
+    /**
+     * 物料信息赋值
+     *
+     * @param enUU 企业UU
+     * @param userUU 用户UU
+     * @param product 物料信息
+     */
+    void setDefaultInfo(Long enUU, Long userUU, Product product);
+
+    /**
+     * 判断是否是标准物料
+     *
+     * @param productInfo product
+     */
+    void checkStandard(Product productInfo);
+
+    /**
+     * 保存物料信息,做兼容处理
+     *
+     * @param productInfo 物料信息
+     * @return 保存后的物料信息
+     */
+    Product saveAndCheck(Product productInfo);
+
+    /**
+     * 保存到商城私有库
+     *
+     * @param productInfo 商城根据数据处理查找的物料信息
+     * @param product 前端传入的物料信息
+     */
+    void addToPrivate(Product productInfo, Product product);
+
+    /**
+     * 绑定到个人物料库
+     *
+     * @param productInfo 物料信息
+     * @param userUU 用户UU
+     * @param enUU 企业UU
+     */
+    void bindToPerson(Product productInfo, Long userUU, Long enUU);
 }

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

@@ -1574,9 +1574,10 @@ public class GoodsServiceImpl implements GoodsService {
         if (!nowGoods.getStatus().equals(oldStatus)) {
             GoodsHistory goodsHistory = null;
             //做上下架判断
-            if ((oldStatus.equals(Status.NO_SHELVE.value()) || oldStatus.equals(Status.REMOVED.value())) && (nowGoods.getStatus().equals(Status.AVAILABLE.value()) || nowGoods.getStatus().equals(Status.UNAVAILABLE.value()))) {
+            if ((oldStatus.equals(Status.REMOVED.value())) && (nowGoods.getStatus().equals(Status.AVAILABLE.value()) || nowGoods.getStatus().equals(Status.UNAVAILABLE.value()) || nowGoods.getStatus().equals(Status.NO_SHELVE.value()))) {
                 goodsHistory = goodsHistoryService.converTGoodsHist(nowGoods, OperateType.Publish.getPhrase(), false);
-            } else if ((nowGoods.getStatus().equals(Status.NO_SHELVE) || nowGoods.getStatus().equals(Status.REMOVED.value())) && (oldStatus.equals(Status.UNAVAILABLE.value()) || oldStatus.equals(Status.AVAILABLE.value()))) {
+                nowGoods.setPublishTime(new Date());
+            } else if ((nowGoods.getStatus().equals(Status.REMOVED.value())) && (oldStatus.equals(Status.UNAVAILABLE.value()) || oldStatus.equals(Status.AVAILABLE.value()) || oldStatus.equals(Status.NO_SHELVE.value()))) {
                 goodsHistory = goodsHistoryService.converTGoodsHist(nowGoods, OperateType.Down.getPhrase(), false);
             }
             if (null != goodsHistory) {
@@ -2933,7 +2934,7 @@ public class GoodsServiceImpl implements GoodsService {
             orderService.save(orders);
 
             List<GoodsHistory> histories = new ArrayList<>();
-            if (goods.getStatus().equals(Status.AVAILABLE.value()) || goods.getStatus().equals(Status.UNAVAILABLE.value())) {
+            if (goods.getStatus().equals(Status.AVAILABLE.value()) || goods.getStatus().equals(Status.UNAVAILABLE.value()) || goods.getStatus().equals(Status.NO_SHELVE.value())) {
                 //先做下架记录
                 goods.setStatus(Status.REMOVED.value());
                 GoodsHistory goodsHistoryRemoved = goodsHistoryService.converTGoodsHist(goods, OperateType.Down.getPhrase(),false);
@@ -3226,7 +3227,7 @@ public class GoodsServiceImpl implements GoodsService {
         orderService.save(orders);
 
         List<GoodsHistory> histories = new ArrayList<>();
-        if (goods.getStatus().equals(Status.AVAILABLE.value()) || goods.getStatus().equals(Status.UNAVAILABLE.value())) {
+        if (goods.getStatus().equals(Status.AVAILABLE.value()) || goods.getStatus().equals(Status.UNAVAILABLE.value()) || goods.getStatus().equals(Status.NO_SHELVE.value())) {
             //先做下架记录
             goods.setStatus(Status.REMOVED.value());
             GoodsHistory goodsHistoryRemoved = goodsHistoryService.converTGoodsHist(goods, OperateType.Down.getPhrase(),false);
@@ -3298,7 +3299,7 @@ public class GoodsServiceImpl implements GoodsService {
                     List<GoodsHistory> histories = new ArrayList<>();
                     List<Goods> goodses1 = new ArrayList<>();
                     for (Goods goodse : goodses) {
-                        if (goodse.getStatus().equals(Status.AVAILABLE.value()) || goodse.getStatus().equals(Status.UNAVAILABLE.value())) {
+                        if (goodse.getStatus().equals(Status.AVAILABLE.value()) || goodse.getStatus().equals(Status.UNAVAILABLE.value()) || goodse.getStatus().equals(Status.NO_SHELVE.value())) {
                             goodse.setStatus(Status.REMOVED.value());
                             GoodsHistory goodsHistoryRemoved = goodsHistoryService.converTGoodsHist(goodse, OperateType.Down.getPhrase(), false);
                             goodsHistoryRemoved.setOperateUU(userUU);
@@ -3699,12 +3700,12 @@ public class GoodsServiceImpl implements GoodsService {
     private void convertPageInfo(PageInfo info, GoodsFilter goodsFilter) {
         if (!StringUtils.isEmpty(goodsFilter.getStartTime())) {
             java.sql.Date startDate = new java.sql.Date(goodsFilter.getStartTime());
-            info.expression(PredicateUtils.gte("updateDate", startDate, true));
+            info.expression(PredicateUtils.gte("publishTime", startDate, true));
         }
         if (!StringUtils.isEmpty(goodsFilter.getEndTime())) {
             // 截止日期是到当天23:59:59,java.sql.Date精确到天,这里采用加一天小于的方法设置截止日期判断
             java.sql.Date endDate = new java.sql.Date(goodsFilter.getEndTime() + IntegerConstant.ONE_DAY_MILLISECONDS);
-            info.expression(PredicateUtils.lt("updateDate", endDate, true));
+            info.expression(PredicateUtils.lt("publishTime", endDate, true));
         }
         if (!StringUtils.isEmpty(goodsFilter.getCode())) {
             info.filter("code", goodsFilter.getCode());

+ 79 - 65
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ProductServiceImpl.java

@@ -797,15 +797,16 @@ public class ProductServiceImpl implements ProductService {
      */
     @Override
     public ResultMap deletePersonalProductByBatch(String type) {
-        Integer standard;
         Integer success = 0;
         Long uu = SystemSession.getUser().getEnterprise().getUu();
-        if (ProductConstant.STANDARD.equals(type)) {
-            standard = IntegerConstant.YES_SHORT;
+        List<Long> prids = null;
+        if (ProductConstant.ALL.equals(type)) {
+            prids = productDao.findPridsByEnuu(uu);
         } else {
-            standard = IntegerConstant.NO_SHORT;
+            Integer standard = ProductConstant.STANDARD.equals(type) ? IntegerConstant.YES_SHORT : IntegerConstant.NO_SHORT;
+            prids = productDao.findPridsByEnuuAndStardand(uu, standard);
         }
-        List<Long> prids = productDao.findPridsByEnuuAndStardand(uu, standard);
+
         List<Long> personPrIds = null;
         if (CollectionUtils.isNotEmpty(prids)) {
             personPrIds = productPersonDao.findIdsInProductPerson(prids, SystemSession.getUser().getUserUU());
@@ -2536,47 +2537,27 @@ public class ProductServiceImpl implements ProductService {
             productInfo = product;
             needAddInventory = true;
         }
-        if (null == productInfo.getStandard()) {
-            // 判断传入的数据是否是标准的
-            ResultMap criterionResultMap = checkStandard(product);
-            if (Objects.equals(CodeType.ERROR.code(), criterionResultMap.getCode())) {
-                productInfo.setStandard(IntegerConstant.NO_SHORT);
-            } else {
-                productInfo.setStandard(IntegerConstant.YES_SHORT);
-                Component component = (Component) criterionResultMap.getData();
-                productInfo.setCmpUuId(component.getUuid());
-                productInfo.setKind(component.getKind().getNameCn());
-                productInfo.setKindid(component.getKindid());
-            }
-        }
-        if (StringUtilB2C.isEmpty(productInfo.getProdNum())) {
-            String code = "PNUM" + createNumberService.getTimeNumber("trade$product_import_num", 8);
-            productInfo.setProdNum(code);
-        }
-        // 最小包装数默认为1
-        Double minPackQty = productInfo.getMinPackQty() == null ? DoubleConstant.minReserve : productInfo.getMinPackQty();
-        productInfo.setMinPackQty(minPackQty);
-
-        // 最小起订量默认为最小包装数
-        Double minBuyQty = productInfo.getMinOrder() == null ? productInfo.getMinPackQty() : productInfo.getMinOrder();
-        productInfo.setMinOrder(minBuyQty);
+        checkStandard(productInfo);
         logger.info("单个物料保存: " + FlexJsonUtils.toJson(productInfo));
-        try {
-            productInfo = productDao.save(productInfo);
-        } catch (Exception e) {
-            //如果保存报错了,判断是否是唯一约束报错。
-            if (e.getMessage().contains("enuu_code")) {
-                CreateNumber tbname = createNumberDao.findByTbname("trade$product_import_num");
-                logger.info("物料编号信息" + FlexJsonUtils.toJson(tbname));
-                List<Product> products = productDao.findByProdNum(productInfo.getProdNum());
-                if (CollectionUtils.isEmpty(products)) {
-                    logger.info("重复编号,找不到对应物料" + productInfo.getProdNum());
-                } else {
-                    logger.info("重复编号的product:" + FlexJsonUtils.toJson(products.get(0)));
-                }
-            }
-        }
+        productInfo = saveAndCheck(productInfo);
+        // 保存上架信息相关
+        saveGoods(goods, productInfo, product, needAddInventory, inOutbound);
+        // 添加到个人物料库
+        bindToPerson(productInfo, userUU, enUU);
+        return ResultMap.success();
+    }
 
+    /**
+     * 保存物料信息
+     *
+     * @param goods 物料信息
+     * @param productInfo 通过判断后的物料信息
+     * @param product 前台传入的物料信息
+     * @param needAddInventory 是否需要增加出入库记录
+     * @param inOutbound 出入库历史记录
+     */
+    private void saveGoods(Goods goods, Product productInfo, Product product, boolean needAddInventory,
+                           CommodityInOutbound inOutbound ) {
         // 设置库存信息
         goods = bindProductToGoods(goods, productInfo);
         goods = checkPrice(goods);
@@ -2599,9 +2580,6 @@ public class ProductServiceImpl implements ProductService {
             inOutbound = commodityInOutboundDao.save(inOutbound);
             logger.info("出入库历史", "卖家中心单个物料上传进行入库操作", inOutbound.getType(), "", inOutbound.getId());
         }
-        // 添加到个人物料库
-        bindToPerson(productInfo, userUU, enUU);
-        return ResultMap.success();
     }
 
     /**
@@ -2656,7 +2634,8 @@ public class ProductServiceImpl implements ProductService {
      * @param userUU 用户UU
      * @param product 物料信息
      */
-    private void setDefaultInfo(Long enUU, Long userUU, Product product) {
+    @Override
+    public void setDefaultInfo(Long enUU, Long userUU, Product product) {
         product.setPbrand(product.getBrand());
         product.setPbranden(product.getBrand());
         product.setPcmpcode(product.getCmpCode());
@@ -2680,19 +2659,24 @@ public class ProductServiceImpl implements ProductService {
      * 判断是否是标准物料
      *
      * @param product product
-     * @return ResultMap
      */
-    private ResultMap checkStandard(Product product) {
-        List<Brand> brands = brandDao.findByName(product.getBrand());
-        // 先判断标准品牌信息
-        if (CollectionUtils.isNotEmpty(brands)) {
-            // 判断标准器件信息
-            List<Component> components = componentDao.findByBrandidAndCode(brands.get(0).getId(), product.getCmpCode());
-            if (CollectionUtils.isNotEmpty(components)) {
-               return ResultMap.success(components.get(0));
+    @Override
+    public void checkStandard(Product product) {
+        if (null == product.getStandard()) {
+            product.setStandard(IntegerConstant.NO_SHORT);
+            List<Brand> brands = brandDao.findByName(product.getBrand());
+            // 先判断标准品牌信息
+            if (CollectionUtils.isNotEmpty(brands)) {
+                // 判断标准器件信息
+                List<Component> components = componentDao.findByBrandidAndCode(brands.get(0).getId(), product.getCmpCode());
+                if (CollectionUtils.isNotEmpty(components)) {
+                    product.setStandard(IntegerConstant.YES_SHORT);
+                    product.setCmpUuId(components.get(0).getUuid());
+                    product.setKind(components.get(0).getKind().getNameCn());
+                    product.setKindid(components.get(0).getKindid());
+                }
             }
         }
-        return ResultMap.error(new NotFoundException("非标准物料"));
     }
 
     /**
@@ -2720,10 +2704,11 @@ public class ProductServiceImpl implements ProductService {
     /**
      * 保存到商城私有库
      *
-     * @param productInfo
-     * @param product
+     * @param productInfo 商城根据数据处理查找的物料信息
+     * @param product 前端传入的物料信息
      */
-    private void addToPrivate(Product productInfo, Product product) {
+    @Override
+    public void addToPrivate(Product productInfo, Product product) {
         List<ProductPrivate> productPrivates = productPrivateDao.findByPrId(productInfo.getId());
         if (CollectionUtils.isEmpty(productPrivates)) {
             ProductPrivate productPrivate = new ProductPrivate(productInfo.getId());
@@ -2744,7 +2729,8 @@ public class ProductServiceImpl implements ProductService {
      * @param product 物料信息
      * @return ResultMap
      */
-    private ResultMap checkProductInfo(Product product) {
+    @Override
+    public ResultMap checkProductInfo(Product product) {
         StringBuffer errMsg = new StringBuffer();
         String GBK_CHARSET_NAME = "GBK";
         // 验证品牌
@@ -2922,7 +2908,8 @@ public class ProductServiceImpl implements ProductService {
      * @param userUU 用户UU
      * @param enUU 企业UU
      */
-    private void bindToPerson(Product productInfo, Long userUU, Long enUU) {
+    @Override
+    public void bindToPerson(Product productInfo, Long userUU, Long enUU) {
         List<ProductPerson> productPersonList = productPersonDao.findByProductIdAndUserUU(productInfo.getId(), userUU);
         if (CollectionUtils.isEmpty(productPersonList)) {
             ProductPerson productPerson = new ProductPerson(enUU, userUU, productInfo.getId());
@@ -2968,19 +2955,20 @@ public class ProductServiceImpl implements ProductService {
                     || Status.NO_SHELVE.value() == goods.getStatus()) && (null == goods.getOldStatus() || Status.REMOVED.value() == goods.getOldStatus());
             if (publish) {
                 type = GoodsHistory.OperateType.Publish.getPhrase();
+                goods.setPublishTime(new Date());
             } else {
                 type = GoodsHistory.OperateType.Update.getPhrase();
             }
-            goodsHistory = goodsHistoryService.converTGoodsHist(goods, type, false);
         } else  {
             if (Status.AVAILABLE.value() == goods.getStatus() || Status.UNAVAILABLE.value() == goods.getStatus() || Status.NO_SHELVE.value() == goods.getStatus()) {
                 //如果现在是已上架,原先是未上架或者已下架,则做上架处理。否则做更新处理
                 type = GoodsHistory.OperateType.Publish.getPhrase();
+                goods.setPublishTime(new Date());
             } else {
                 type = GoodsHistory.OperateType.INIT.getPhrase();
             }
-            goodsHistory = goodsHistoryService.converTGoodsHist(goods, type, false);
         }
+        goodsHistory = goodsHistoryService.converTGoodsHist(goods, type, false);
         return goodsHistory;
     }
 
@@ -3256,4 +3244,30 @@ public class ProductServiceImpl implements ProductService {
         setGoodsInfo(privates);
         return privates;
     }
+
+    /**
+     * 保存物料信息,做兼容处理
+     *
+     * @param productInfo 物料信息
+     * @return 保存后的物料信息
+     */
+    @Override
+    public Product saveAndCheck(Product productInfo) {
+        try {
+            productInfo = productDao.save(productInfo);
+        } catch (Exception e) {
+            //如果保存报错了,判断是否是唯一约束报错。
+            if (e.getMessage().contains("enuu_code")) {
+                CreateNumber tbname = createNumberDao.findByTbname("trade$product_import_num");
+                logger.info("物料编号信息" + FlexJsonUtils.toJson(tbname));
+                List<Product> products = productDao.findByProdNum(productInfo.getProdNum());
+                if (CollectionUtils.isEmpty(products)) {
+                    logger.info("重复编号,找不到对应物料" + productInfo.getProdNum());
+                } else {
+                    logger.info("重复编号的product:" + FlexJsonUtils.toJson(products.get(0)));
+                }
+            }
+        }
+        return productInfo;
+    }
 }

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

@@ -1924,6 +1924,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 								if ((Status.AVAILABLE.value() == g.getStatus() || Status.UNAVAILABLE.value() == g.getStatus() || Status.NO_SHELVE.value() == g.getStatus()) &&  Status.REMOVED.value() == status) {
 									//如果现在是已上架,原先是未上架或者已下架,则做上架处理。否则做更新处理
 									goodsHistoryList.add(goodsHistoryService.converTGoodsHist(g, GoodsHistory.OperateType.Publish.getPhrase(), false));
+									g.setPublishTime(new Date());
 								} else {
 									goodsHistoryList.add(goodsHistoryService.converTGoodsHist(g, GoodsHistory.OperateType.Update.getPhrase(), false));
 								}
@@ -1941,11 +1942,8 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 				for (ReleaseProductByBatch releaseProductByBatch : insertGoods) {
 					goods = new Goods();
 					goods.setGoodsByReleaseProductByBatch(releaseProductByBatch, delayTime);
-					if ((Status.AVAILABLE.value() == goods.getStatus()) || (Status.UNAVAILABLE.value() == goods.getStatus()) || (Status.NO_SHELVE.value() == goods.getStatus())) {
-						goodsHistoryList.add(goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.Publish.getPhrase(), false));
-					} else {
-						goodsHistoryList.add(goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.INIT.getPhrase(), false));
-					}
+					goods.setPublishTime(new Date());
+					goodsHistoryList.add(goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.Publish.getPhrase(), false));
 					updateGoods.add(goods);
 				}
 			}

+ 26 - 6
src/main/java/com/uas/platform/b2c/trade/order/controller/PurchaseProductController.java

@@ -1,17 +1,21 @@
 package com.uas.platform.b2c.trade.order.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import com.uas.platform.b2c.common.base.model.FileUpload;
+import com.uas.platform.b2c.core.support.log.UsageBufferedLogger;
 import com.uas.platform.b2c.core.support.view.JxlsExcelView;
 import com.uas.platform.b2c.trade.order.service.PurchaseProductService;
 import com.uas.platform.b2c.trade.order.support.AjaxUtil;
 import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.core.exception.IllegalOperatorException;
+import com.uas.platform.core.logging.BufferedLoggerManager;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -21,8 +25,7 @@ import org.springframework.web.servlet.ModelAndView;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
 
 /**
  * 买家中心物料相关
@@ -38,7 +41,12 @@ public class PurchaseProductController {
     /**
      * 系统操作日志
      */
-    private final Logger logger = LoggerFactory.getLogger(PurchaseProductController.class);
+    private final Logger LOGGER = LoggerFactory.getLogger(PurchaseProductController.class);
+
+    /**
+     * 系统操作日志
+     */
+    private static final UsageBufferedLogger USELOG = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
 
     @Autowired
     private PurchaseProductService purchaseProductService;
@@ -50,7 +58,7 @@ public class PurchaseProductController {
      */
     @RequestMapping(value = "/release/template", method = RequestMethod.GET)
     public ModelAndView releasePersonalProductTemplate() {
-        logger.info("买家物料", "下载Excel批量上传个人物料模板");
+        LOGGER.info("买家物料", "下载Excel批量上传个人物料模板");
         ModelAndView modelAndView = new ModelAndView();
         modelAndView.setView(new JxlsExcelView("classpath:jxls-tpl/trade/releaseByBatch-person", "导入个人产品库-优软商城"));
         return modelAndView;
@@ -86,7 +94,7 @@ public class PurchaseProductController {
                 return ResultMap.error(new IllegalOperatorException("文件格式不正确!请上传.xls或.xlsx格式的文件"));
             }
             ResultMap resultMap = purchaseProductService.releasePersonalProductByExcel(workbook, ignoreImport);
-            logger.info("买家物料", "通过Excel批量上传个人物料-优软商城");
+            LOGGER.info("买家物料", "通过Excel批量上传个人物料-优软商城");
             return resultMap;
         } catch (IOException e) {
             return ResultMap.error(e);
@@ -115,8 +123,20 @@ public class PurchaseProductController {
         modelAndView.addObject("data", purchaseProductService.findFailureReleaseProductByBatch(batch));
         String url = "classpath:jxls-tpl/trade/releaseByBatchError-person";
         modelAndView.setView(new JxlsExcelView(url, "导出失败的个人物料-优软商城"));
-        logger.info("买家物料", "以Excel形式导出失败的个人物料");
+        LOGGER.info("买家物料", "以Excel形式导出失败的个人物料");
         session.setAttribute("load-error-ing", false);
         return modelAndView;
     }
+
+    /**
+     * 买家中心添加单个物料录入
+     *
+     * @param jsonObject 前端数据
+     * @return ResultMap
+     */
+    @RequestMapping(value = "/edit/one", method = RequestMethod.POST)
+    public ResultMap editOne(@RequestBody JSONObject jsonObject) {
+        USELOG.log("买家中心物料", "单个物料录入操作");
+        return purchaseProductService.editOne(jsonObject);
+    }
 }

+ 9 - 0
src/main/java/com/uas/platform/b2c/trade/order/service/PurchaseProductService.java

@@ -1,5 +1,6 @@
 package com.uas.platform.b2c.trade.order.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.uas.platform.b2c.prod.commodity.model.ReleaseProductByBatch;
 import com.uas.platform.b2c.trade.support.ResultMap;
 import org.apache.poi.ss.usermodel.Workbook;
@@ -31,4 +32,12 @@ public interface PurchaseProductService {
      * @return List<ReleaseProductByBatch>
      */
     List<ReleaseProductByBatch> findFailureReleaseProductByBatch(String batch);
+
+    /**
+     * 买家中心添加单个物料录入
+     *
+     * @param jsonObject 前端数据封装
+     * @return ResultMap
+     */
+    ResultMap editOne(JSONObject jsonObject);
 }

+ 78 - 53
src/main/java/com/uas/platform/b2c/trade/order/service/impl/PurchaseProductServiceImpl.java

@@ -1,37 +1,37 @@
 package com.uas.platform.b2c.trade.order.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 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.support.SystemSession;
 import com.uas.platform.b2c.core.support.log.UsageBufferedLogger;
 import com.uas.platform.b2c.core.utils.StringUtilB2C;
 import com.uas.platform.b2c.prod.commodity.constant.DoubleConstant;
 import com.uas.platform.b2c.prod.commodity.constant.ErrorInfoConstant;
 import com.uas.platform.b2c.prod.commodity.constant.UploadConstant;
-import com.uas.platform.b2c.prod.commodity.dao.GoodsDao;
-import com.uas.platform.b2c.prod.commodity.dao.GoodsHistoryDao;
+import com.uas.platform.b2c.prod.commodity.dao.ProductDao;
 import com.uas.platform.b2c.prod.commodity.dao.ProductPrivateDao;
 import com.uas.platform.b2c.prod.commodity.dao.ReleaseProductByBatchDao;
-import com.uas.platform.b2c.prod.commodity.model.Goods;
-import com.uas.platform.b2c.prod.commodity.model.GoodsHistory;
+import com.uas.platform.b2c.prod.commodity.dao.V_ProductPrivateDao;
+import com.uas.platform.b2c.prod.commodity.model.Product;
 import com.uas.platform.b2c.prod.commodity.model.ProductPrivate;
 import com.uas.platform.b2c.prod.commodity.model.ReleaseProductByBatch;
+import com.uas.platform.b2c.prod.commodity.model.V_ProductPrivate;
 import com.uas.platform.b2c.prod.commodity.service.GoodsService;
 import com.uas.platform.b2c.prod.commodity.service.ProductService;
 import com.uas.platform.b2c.prod.commodity.service.ReleaseProductByBatchService;
 import com.uas.platform.b2c.prod.commodity.type.ProductConstant;
 import com.uas.platform.b2c.prod.commodity.util.SheetUtil;
 import com.uas.platform.b2c.prod.product.common.service.CreateNumberService;
-import com.uas.platform.b2c.prod.store.model.StoreIn;
-import com.uas.platform.b2c.prod.store.model.StoreStatus;
 import com.uas.platform.b2c.prod.store.service.StoreInService;
 import com.uas.platform.b2c.trade.order.service.PurchaseProductService;
+import com.uas.platform.b2c.trade.support.CodeType;
 import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.core.exception.IllegalOperatorException;
 import com.uas.platform.core.logging.BufferedLoggerManager;
 import com.uas.platform.core.util.HttpUtil;
+import com.uas.platform.core.util.serializer.FlexJsonUtils;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Row;
@@ -39,6 +39,7 @@ import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
@@ -50,6 +51,7 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Objects;
 import java.util.Set;
 
 /**
@@ -77,10 +79,10 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
     private ProductPrivateDao productPrivateDao;
 
     @Autowired
-    private GoodsDao goodsDao;
+    private ProductDao productDao;
 
     @Autowired
-    private GoodsHistoryDao goodsHistoryDao;
+    private V_ProductPrivateDao v_productPrivateDao;
 
     @Autowired
     private GoodsService goodsService;
@@ -190,7 +192,7 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
             // 去重后的数据
             List<ReleaseProductByBatch> uniqueBatchList = releaseProductByBatchDao.findByRelbatchidAndReleaseCodeNot(userUU, batch, failCode);
             if (!CollectionUtils.isEmpty(uniqueBatchList)) {
-                assignNumber = assignBatch(uniqueBatchList, batch);
+                assignNumber = assignBatch(uniqueBatchList);
             }
             modelMap.put("assignSuccess", assignNumber);
             modelMap.put("assignFailure", total - assignNumber);
@@ -344,11 +346,10 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
      * 将去重的数据批量绑定到个人物料库
      *
      * @param uniqueBatchList 去重后的物料信息
-     * @param batch 批次号
      * @return 保存成功的数量
      */
-    private Integer assignBatch(List<ReleaseProductByBatch> uniqueBatchList, String batch) {
-        Set<Long> idSet = getProductIdSet(uniqueBatchList, batch);
+    private Integer assignBatch(List<ReleaseProductByBatch> uniqueBatchList) {
+        Set<Long> idSet = getProductIdSet(uniqueBatchList);
         if (CollectionUtils.isNotEmpty(idSet)) {
             HashMap<String, Object> params = new HashMap<>(5);
             ModelMap data = new ModelMap();
@@ -372,10 +373,9 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
      * 获取物料id字段
      *
      * @param uniqueBatchList 去重后的物料信息
-     * @param batchCode 批次号
      * @return 物料id集合
      */
-    private Set<Long> getProductIdSet(List<ReleaseProductByBatch> uniqueBatchList, String batchCode) {
+    private Set<Long> getProductIdSet(List<ReleaseProductByBatch> uniqueBatchList) {
         List<String> productCodeList = new ArrayList<>();
         Set<Long> idSet = new HashSet<>();
         List<ReleaseProductByBatch> batchList = new ArrayList<>();
@@ -384,7 +384,7 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
                 idSet.add(batch.getProductid());
             } else {
                 if (StringUtilB2C.isEmpty(batch.getProductNum())) {
-                    String code = "PNUM" + createNumberService.getTimeNumber("trade$product_import_num", 8);
+                    String code = "PNUM" + StringUtilB2C.getRandomNumber(6);
                     batch.setProductNum(code);
                 }
                 productCodeList.add(batch.getProductNum());
@@ -394,49 +394,14 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
         // 新增到物料库
         productService.saveByJdbcTemplate(batchList);
         List<com.uas.platform.b2c.prod.commodity.model.Product> productList = productService.findProductIdAndProdnumsByProdNums(productCodeList);
-        final StoreIn storeIn = storeInService.findByEnUU(SystemSession.getUser().getEnterprise().getUu());
         List<ProductPrivate> privateList = new ArrayList<>();
-        List<Goods> finalGoodsList = new ArrayList<>();
         productList.forEach(product -> {
-            Goods goods = new Goods(ProductConstant.DEFAULT_PACKING, ProductConstant.DEFAULT_BREAKUP, ProductConstant.DEFAULT_AUTO_PUBLISH,
-                    ProductConstant.DEFAULT_MAX_DELIVERY, ProductConstant.DEFAULT_MIN_DELIVERY, ProductConstant.DEFAULT_MIN_BUYQTY,
-                    ProductConstant.DEFAULT_MIN_PACKQTY, Status.NO_SHELVE.value());
-            goods = productService.bindProductToGoods(goods, product);
-            goods.setSelfSale((storeIn != null && storeIn.getStatus() == StoreStatus.OPENED) ? "1" : "0");
-            goodsService.setGoodsDefault(goods);
-            finalGoodsList.add(goods);
-            ProductPrivate productPrivate;
-            List<ProductPrivate> privates = productPrivateDao.findByPrId(product.getId());
-            if (CollectionUtils.isNotEmpty(privates)) {
-                productPrivate = privates.get(0);
-                productPrivate.setB2cEnabled(IntegerConstant.YES_SHORT);
-                productPrivate.setPrId(product.getId());
-                productPrivate.setBatchCount(IntegerConstant.NO_SHORT);
-            } else {
-                productPrivate = new ProductPrivate(product.getId());
-                productPrivate.setAttach(product.getAttachment());
-            }
+            ProductPrivate productPrivate = new ProductPrivate(product.getId());
+            productPrivate.setAttach(product.getAttachment());
             privateList.add(productPrivate);
             idSet.add(product.getId());
         });
 
-        // 保存goods
-        if (CollectionUtils.isNotEmpty(finalGoodsList)) {
-            List<Goods> goodsList = goodsDao.save(finalGoodsList);
-            USE_LOG.log("上架商品", "新增上架商品", "批量导入上架商品,数量 " + goodsList.size() + ", 批号 " + batchCode);
-            List<GoodsHistory> historyList = new ArrayList<>();
-            goodsList.forEach(goods -> {
-                GoodsHistory goodsHistory = productService.assignmentGoodsHistory(goods);
-                goodsHistory.setB2cMaxDelivery(goods.getMaxDelivery());
-                goodsHistory.setB2cMinDelivery(goods.getMinDelivery());
-                historyList.add(goodsHistory);
-            });
-            // 保存goodsHistory
-            if (CollectionUtils.isNotEmpty(historyList)) {
-                goodsHistoryDao.save(historyList);
-                USE_LOG.log("库存操作", "批量导入上架商品更新库存操作", "数量 " + historyList.size() + ", 批次号 " + batchCode);
-            }
-        }
         // 保存到私有库
         if (CollectionUtils.isNotEmpty(privateList)) {
             productPrivateDao.save(privateList);
@@ -485,4 +450,64 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
         }
     }
 
+    /**
+     * 买家中心添加单个物料录入
+     *
+     * @param jsonObject 前端数据封装
+     * @return ResultMap
+     */
+    @Override
+    public ResultMap editOne(JSONObject jsonObject) {
+        // 物料信息
+        Object productObject = jsonObject.get("product");
+        if (null == productObject) {
+            return ResultMap.error(new IllegalOperatorException("物料信息不能为空"));
+        }
+        Product product = JSONObject.parseObject(productObject.toString(), Product.class);
+        // 检验物料信息
+        ResultMap resultMap = productService.checkProductInfo(product);
+        if (Objects.equals(CodeType.ERROR.code(), resultMap.getCode())) {
+            return resultMap;
+        }
+        // PCB
+        Object pcbObject = jsonObject.get("isPcb");
+        Integer isPcb = null;
+        if (null != pcbObject) {
+            isPcb = Integer.valueOf(pcbObject.toString());
+        }
+        Long enUU = SystemSession.getUser().getEnterprise().getUu();
+        Long userUU = SystemSession.getUser().getUserUU();
+        productService.setDefaultInfo(enUU, userUU, product);
+        // PCB产品做标准判断处理
+        if (null != isPcb && Objects.equals(IntegerConstant.YES_SHORT, isPcb)) {
+            // 判断传入的数据是否是标准的
+            ResultMap criterionResultMap = productService.checkCriterion(product);
+            if (Objects.equals(CodeType.ERROR.code(), criterionResultMap.getCode())) {
+                return criterionResultMap;
+            }
+        }
+        Product productInfo = new Product();
+        // 物料存在,更新
+        List<V_ProductPrivate> existProducts = v_productPrivateDao.findProductByPcmpcodeAndPbrandenAndEnUU(product.getCmpCode(), product.getBrand(), enUU);
+        if (CollectionUtils.isNotEmpty(existProducts)) {
+            V_ProductPrivate productPrivate = existProducts.get(0);
+            productInfo = productInfo.setByPrivate(productPrivate);
+            BeanUtils.copyProperties(product, productInfo, Product.class);
+            productInfo.setStandard(productPrivate.getStandard());
+            productInfo.setId(productPrivate.getId());
+        } else {
+            // 物料不存在,新增操作
+            productInfo = product;
+        }
+        // 判断是否标准
+        productService.checkStandard(productInfo);
+        LOGGER.info("单个物料保存: " + FlexJsonUtils.toJson(productInfo));
+        productInfo = productService.saveAndCheck(productInfo);
+
+        // 保存到商城私有库
+        productService.addToPrivate(productInfo, product);
+        // 添加到个人物料库
+        productService.bindToPerson(productInfo, userUU, enUU);
+        return ResultMap.success();
+    }
 }

+ 5 - 0
src/main/webapp/resources/js/common/controllers/b2bCommonCtrls.js

@@ -76,6 +76,10 @@ define([ 'app/app' ], function(app) {
         $scope.result = null;
         $scope.loading = false;
         $scope.upload = function () {
+            if (!$scope.myFiles) {
+                toaster.pop('info', '提示', '请先选择文件上传!');
+                return;
+            }
             $scope.loading = true;
             var file = $scope.myFiles[0];
             $upload.upload({
@@ -88,6 +92,7 @@ define([ 'app/app' ], function(app) {
                 $scope.success = $scope.result.success;
                 $scope.total = $scope.result.total;
                 $scope.alters = $scope.result.alters;
+                toaster.pop('success', '成功', '文件上传成功!');
             }).error(function (response) {
                 $scope.loading = false;
                 toaster.pop('error', response.data || response);

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

@@ -37,7 +37,7 @@
 			</thead>
 			<tbody ng-if="thisUser.sys">
 			<!-- 当前用户是管理员时 -->
-			<tr ng-repeat="user in userinfos| filter: keyword track by $index" style="overflow-y:scroll; width:100%;max-height:500px" ng-if="!user.sys && thisUser.userUU != user.userUU">
+			<tr ng-repeat="user in userinfos| filter: keyword track by $index" style="overflow-y:scroll; width:100%;max-height:500px" ng-if="thisUser.userUU != user.userUU">
 				<td width="80px;">{{user.userUU}}</td>
 				<td width="100px;">{{user.userName}}</td>
 				<td width="40px;" style="text-align: center">
@@ -50,7 +50,7 @@
 			</tbody>
 			<tbody ng-if="!thisUser.sys && thisUser.transfer">
 			<!-- 当前用户是被管理员转移权限时 -->
-			<tr ng-repeat="user in userinfos| filter: keyword track by $index" ng-if="!user.sys && thisUser.userUU != user.userUU">
+			<tr ng-repeat="user in userinfos| filter: keyword track by $index" ng-if="thisUser.userUU != user.userUU">
 				<td width="80px;">{{user.userUU}}</td>
 				<td width="100px;">{{user.userName}}</td>
 				<td width="40px;" style="text-align: center">
@@ -63,7 +63,7 @@
 			</tbody>
 			<tbody ng-if="!thisUser.sys && !thisUser.transfer">
 			<!-- 当前用户是非管理员,但有查看权限时 -->
-			<tr ng-repeat="user in userinfos| filter: keyword track by $index" ng-if="!user.distribute && !user.sys && thisUser.userUU != user.userUU">
+			<tr ng-repeat="user in userinfos| filter: keyword track by $index" ng-if="!user.distribute && thisUser.userUU != user.userUU">
 				<td width="80px;">{{user.userUU}}</td>
 				<td width="100px;">{{user.userName}}</td>
 				<td width="40px;" style="text-align: center">