Эх сурвалжийг харах

Merge remote-tracking branch 'origin/feature-201831-wangcz' into feature-201831-wangcz

yujia 7 жил өмнө
parent
commit
9447a10e85
17 өөрчлөгдсөн 666 нэмэгдсэн , 703 устгасан
  1. 19 0
      src/main/java/com/uas/platform/b2c/prod/commodity/controller/ProductController.java
  2. 1 0
      src/main/java/com/uas/platform/b2c/prod/commodity/dao/ProductDao.java
  3. 1 0
      src/main/java/com/uas/platform/b2c/prod/commodity/model/CommodityInOutbound.java
  4. 12 13
      src/main/java/com/uas/platform/b2c/prod/commodity/model/Goods.java
  5. 5 0
      src/main/java/com/uas/platform/b2c/prod/commodity/model/InOutboundDetail.java
  6. 1 3
      src/main/java/com/uas/platform/b2c/prod/commodity/model/Product.java
  7. 18 2
      src/main/java/com/uas/platform/b2c/prod/commodity/model/ProductPerson.java
  8. 11 45
      src/main/java/com/uas/platform/b2c/prod/commodity/service/GoodsService.java
  9. 27 32
      src/main/java/com/uas/platform/b2c/prod/commodity/service/ProductService.java
  10. 49 362
      src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/GoodsServiceImpl.java
  11. 336 238
      src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ProductServiceImpl.java
  12. 5 0
      src/main/java/com/uas/platform/b2c/prod/commodity/type/ProductConstant.java
  13. 30 0
      src/main/java/com/uas/platform/b2c/prod/store/controller/StoreApplyController.java
  14. 84 0
      src/main/java/com/uas/platform/b2c/prod/store/model/StoreInfoAndProdExport.java
  15. 12 0
      src/main/java/com/uas/platform/b2c/prod/store/service/StoreApplyService.java
  16. 55 8
      src/main/java/com/uas/platform/b2c/prod/store/service/impl/StoreApplyServiceImpl.java
  17. BIN
      src/main/resources/jxls-tpl/product/storeInfo.xls

+ 19 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/controller/ProductController.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.uas.platform.b2c.core.constant.SplitChar;
 import com.uas.platform.b2c.core.support.SystemSession;
+import com.uas.platform.b2c.core.support.log.UsageBufferedLogger;
 import com.uas.platform.b2c.core.support.view.JxlsExcelView;
 import com.uas.platform.b2c.prod.commodity.facade.ProductFacade;
 import com.uas.platform.b2c.prod.commodity.model.Goods;
@@ -17,6 +18,7 @@ import com.uas.platform.b2c.prod.commodity.service.ProductService;
 import com.uas.platform.b2c.prod.commodity.type.ProductConstant;
 import com.uas.platform.b2c.trade.support.CodeType;
 import com.uas.platform.b2c.trade.support.ResultMap;
+import com.uas.platform.core.logging.BufferedLoggerManager;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.PageParams;
 import org.apache.commons.collections.CollectionUtils;
@@ -63,6 +65,11 @@ public class ProductController {
 
 	private final Logger logger = Logger.getLogger(getClass());
 
+    /**
+     * 系统操作日志
+     */
+    private static final UsageBufferedLogger USELOG = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
+
     /**
      * Instantiates a new Product controller.
      *
@@ -461,4 +468,16 @@ public class ProductController {
 	public ResultMap countProduct(Long fromDate, Long toDate) {
 		return productService.countProduct(fromDate, toDate);
 	}
+
+    /**
+     * 卖家中心添加单个物料录入
+     *
+     * @param jsonObject 前端数据
+     * @return ResultMap
+     */
+	@RequestMapping(value = "/edit/one", method = RequestMethod.POST)
+	public ResultMap editOne(@RequestBody JSONObject jsonObject) {
+        USELOG.log("卖家中心物料", "单个物料录入操作");
+	    return productService.editOne(jsonObject);
+    }
 }

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

@@ -218,4 +218,5 @@ public interface ProductDao extends JpaSpecificationExecutor<Product>, JpaReposi
      * @return
      */
     List<Product> findByCmpCode(String cmpCode);
+
 }

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

@@ -23,6 +23,7 @@ import java.util.Set;
 
 /**
  * 出入库的历史记录
+ * @author US50
  */
 @Entity
 @Table(name = "trade$commodity_in_outbound")

+ 12 - 13
src/main/java/com/uas/platform/b2c/prod/commodity/model/Goods.java

@@ -386,7 +386,6 @@ public class Goods implements Serializable {
 	@Column(name = "go_batchid")
 	private String batchid;
 
-
 	/**
 	 * 店铺的id
 	 */
@@ -465,7 +464,6 @@ public class Goods implements Serializable {
 	@Column(name = "go_deliverydemintime")
 	private Short b2cDeliveryDemMinTime;
 
-
 	/**
 	 * 商城送货到香港最长交期
 	 */
@@ -1665,19 +1663,20 @@ public class Goods implements Serializable {
 
 	/**
 	 * 产品转goods
+	 * @param goods 传入的GOODS
+	 * @param product 传入的物料信息
 	 * @return
 	 */
-	public static Goods productConvertGoods(Product product) {
-		Goods g = new Goods();
-		g.setProdNum(product.getProdNum());
-		g.setKindNameCn(product.getKind());
-		g.setBrandNameEn(product.getPbranden());
-		g.setCode(product.getPcmpcode());
-		g.setEncapsulation(product.getEncapsulation());
-		g.setPackaging(product.getPackaging());
-		g.setProduceDate(product.getProduceDate());
-		g.setUuid(product.getCmpUuId());
-		return g;
+	public static Goods productConvertGoods(Goods goods, Product product) {
+		goods.setProdNum(product.getProdNum());
+		goods.setKindNameCn(product.getKind());
+		goods.setBrandNameEn(product.getPbranden());
+		goods.setCode(product.getPcmpcode());
+		goods.setEncapsulation(product.getEncapsulation());
+		goods.setPackaging(product.getPackaging());
+		goods.setProduceDate(product.getProduceDate());
+		goods.setUuid(product.getCmpUuId());
+		return goods;
 	}
 
 	public Short getAudited() {

+ 5 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/model/InOutboundDetail.java

@@ -16,6 +16,11 @@ import javax.persistence.ManyToOne;
 import javax.persistence.Table;
 import java.io.*;
 
+/**
+ * 出入库详情
+ *
+ * @author US50
+ */
 @Entity
 @Table(name = "trade$in_out_bound_detail")
 public class InOutboundDetail implements Serializable {

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

@@ -34,8 +34,6 @@ import java.util.Set;
 	@Index(name = "products_erpdown_index", columnList = "pr_erpdown"),
 	@Index(name = "pr_createtime_index", columnList = "pr_create_time")})
 @Logger
-//@Cacheable
-//@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "com.uas.platform.b2b.model.Product")
 public class Product {
 
 	@Id
@@ -151,7 +149,6 @@ public class Product {
 	@Column(name = "pr_sourceapp")
 	private String sourceApp;
 
-
 	/**
 	 * 类目(平台)(中文)
 	 */
@@ -199,6 +196,7 @@ public class Product {
 	 */
 	@Column(name = "pr_pcmpcode" ,length = 800)
 	private String pcmpcode;
+
 	/**
 	 * 是否是标准物料<br>
 	 * 1.YES<br>

+ 18 - 2
src/main/java/com/uas/platform/b2c/prod/commodity/model/ProductPerson.java

@@ -1,7 +1,15 @@
 package com.uas.platform.b2c.prod.commodity.model;
 
-import javax.persistence.*;
-import java.io.Serializable;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import java.io.*;
 import java.util.Date;
 
 /**
@@ -67,10 +75,18 @@ public class ProductPerson implements Serializable {
 
     }
 
+    /**
+     * 根据企业UU,用户UU,物料id设置个人物料信息
+     *
+     * @param enUU 企业UU
+     * @param userUU 用户UU
+     * @param productId 物料id
+     */
     public ProductPerson(Long enUU, Long userUU, Long productId) {
         this.setEnuu(enUU);
         this.setUserUU(userUU);
         this.setProductId(productId);
+        this.setTime(new Date(System.currentTimeMillis()));
     }
 
     public Long getId() {

+ 11 - 45
src/main/java/com/uas/platform/b2c/prod/commodity/service/GoodsService.java

@@ -274,21 +274,6 @@ public interface GoodsService {
      */
     List<Goods> findOvertime();
 
-    /**
-     * 添加商品操作记录,保存商品信息
-     *
-     * @param goods      the goods goods信息
-     * @param deviceInfo the device info 设备的数据
-     * @param type       库存变化类型
-     * @return goods
-     */
-    Goods saveGoods(Goods goods, String deviceInfo, GoodsHistory.OperateType type);
-
-//	/**
-//	 * 失效指定批次待确认的订单
-//	 */
-//	void invalidOrderDetail(String batchCode);
-
     /**
      * 根据goods的发货地区,设置交货延长时间
      *
@@ -604,16 +589,6 @@ public interface GoodsService {
      */
     Page<Goods> pageStoreCommoditiesWhenRecommendProduct(Long enUU, String uuid, String keyword, Double minPrice, Double maxPrice, String batchCode, PageInfo pageInfo);
 
-
-    /**
-     * 通过标准产品更新库存信息
-     *
-     * @param goods the goods 库存的信息
-     * @return result map
-     */
-    ResultMap updateGoodsByProductStandardPutOn(Goods goods);
-
-
     /**
      * 下架该公司所有的商品信息
      *
@@ -708,7 +683,7 @@ public interface GoodsService {
      * @param batchCode
      * @return
      */
-    public void addVisitCount(String batchCode);
+    void addVisitCount(String batchCode);
 
     /**
      * 根据分页参数和过滤对象分页获取数据
@@ -744,7 +719,7 @@ public interface GoodsService {
      * @param storeid
      * @return
      */
-    public Long findenUUByStoreid(String storeid);
+    Long findenUUByStoreid(String storeid);
 
     /**
      * 返回PCB商品信息
@@ -753,7 +728,7 @@ public interface GoodsService {
      * @param request
      * @return
      */
-    public ModelMap getPCBGoodsBySearch( String keyword, PageParams var2, HttpServletRequest request);
+    ModelMap getPCBGoodsBySearch( String keyword, PageParams var2, HttpServletRequest request);
 
     /**
      * 通过品牌uuid,类目id,关键词获取批次信息(暂时针对pcb模块)
@@ -765,15 +740,6 @@ public interface GoodsService {
      */
     Page<Goods> findGoods(PageParams params, String branduuid, String kindid, String keyword);
 
-
-    /**
-     * 更新货物的有效期
-     *
-     * @param products the operate type 操作的记录
-     * @param goodses       the param
-     */
-    void updateSpecByProducts(List<Product> products, List<Goods> goodses);
-
     /**
      * 获取pcb推荐物料
      * @return
@@ -803,14 +769,6 @@ public interface GoodsService {
      */
     Map<Long, Integer> batchGetCountByProductId(List<Long>  prIds);
 
-
-    /**
-     * 根据 batchid 获取本次上架的信息
-     * @param batchid 本批次上架标识
-     * @return  List<Goods>
-     */
-    List<Goods> findByBatchId(String batchid);
-
     /**
      * 根据ids获取物料信息
      * @param ids 物料的ids
@@ -845,4 +803,12 @@ public interface GoodsService {
      * @return  Product
      */
     Product getProductByPurchaseDetail(PurchaseDetail detail);
+
+    /**
+     * 检测批次各属性的正确性
+     *
+     * @param goods Goods
+     * @return ResultMap
+     */
+    ResultMap checkGoods(Goods goods);
 }

+ 27 - 32
src/main/java/com/uas/platform/b2c/prod/commodity/service/ProductService.java

@@ -31,6 +31,7 @@ public interface ProductService {
      * @param page    the page 一页数据
      * @param keyword the keyword
      * @param type    the type 标准or非标准
+     * @param userUU 用户UU
      * @return all products
      */
     Page<V_ProductPrivate> getAllProducts(PageInfo page, String keyword, String type, Long userUU);
@@ -47,6 +48,10 @@ public interface ProductService {
 
     /**
      * 绑定至个人产品库
+     *
+     * @param ids id
+     * @param isAll isAll
+     * @param isStardand 是否标准
      * @return all products
      */
     Integer setAllProductsByProductIds(String ids, Integer isAll, Integer isStardand);
@@ -55,6 +60,7 @@ public interface ProductService {
      * 批量保存个人替代物料信息
      * @param productId          替代物料id
      * @param productReplaceList 替代物料数组
+     * @return
      */
     boolean setProductReplacesByPerson(Long productId, List<ProductReplace> productReplaceList);
 
@@ -65,7 +71,6 @@ public interface ProductService {
      */
     List<ProductReplace> getReplacesByProductId(Long id);
 
-
     /**
      * 下载产品资料
      *
@@ -87,6 +92,7 @@ public interface ProductService {
      * 批量删除产品
      *
      * @param ids the ids 主键
+     * @param isPerson 是否个人物料
      */
     void deleteBatch(List<Long> ids, Integer isPerson);
 
@@ -94,6 +100,7 @@ public interface ProductService {
      * 批量删除产品
      *
      * @param type 批量删除的类型
+     * @param isPerson 是否个人物料
      */
     ResultMap deleteBatch(String type, Integer isPerson);
 
@@ -130,11 +137,11 @@ public interface ProductService {
 
     /**
      * 返回卖家标准和非标的数量
+     * @param isPerson 是否个人物料
      * @return
      */
     Map<String, Integer> getProductCount(Integer isPerson);
 
-
     /**
      * 修改物料的品牌、物料名称、型号、规格、规格书等信息
      *
@@ -243,7 +250,6 @@ public interface ProductService {
      */
     ProductDetail saveDetail(Long productId, Goods goods);
 
-
     /**
      * 用户批量上架
      *
@@ -253,25 +259,14 @@ public interface ProductService {
      */
     ResultMap batchPutOn(Integer standard, String ids);
 
-
     /**
      * 计算还剩多少空闲库存
      *
      * @param erpReserve erp 的空闲库存
-     * @param goodses1 需要减去 库存的的goods 的
+     * @param goodses 需要减去 库存的的goods 的
      * @return
      */
-    Double getGoodsReserveByErpReserve(Double erpReserve, List<Goods> goodses1);
-
-
-    /**
-     * 获取订单中还未上传到UAS的数量
-     *
-     * @param batches 批次信息
-     * @return
-     */
-    Double getQtyInOrderToBeUpload(List<String> batches);
-
+    Double getGoodsReserveByErpReserve(Double erpReserve, List<Goods> goodses);
 
     /**
      * 根据品牌和型号标准器件
@@ -281,7 +276,6 @@ public interface ProductService {
      */
     Component findBybrNameAndcmpCode(String brName, String cmpCode);
 
-
     /**
      * 更新物料信息根据标准器件
      * @param productid 物料id
@@ -320,7 +314,6 @@ public interface ProductService {
      */
     List<Product> findProductsByProdNums(List<String> prodNums);
 
-
     /**
      * 根物料标号,获取物料编号和物料id
      * @param prodNums  物料编号list
@@ -328,13 +321,6 @@ public interface ProductService {
      */
     List<Product> findProductIdAndProdnumsByProdNums(List<String> prodNums);
 
-    /**
-     * 根据物料编号找物料
-     * @param prodNum
-     * @return
-     */
-    Product findProductByProdNum(String prodNum);
-
     /**
      * 批量保存
      * @param list
@@ -349,14 +335,12 @@ public interface ProductService {
      */
     void updateProductsByReleaseProductByBatch(Set<Long> prIds, List<ReleaseProductByBatch> reList, Integer ignoreImport, Set<InOutboundDetail> newInOutboundDetail);
 
-
     /**
      * 因入库,需要修改物料信息
      * @param prids
      */
     void updateProductsByInBound(List<Long> prids);
 
-
     /**
      * 根据关键字匹配器件型号,获取物料信息
      * @param keyword
@@ -364,8 +348,6 @@ public interface ProductService {
      */
     List<Product> getProductsMatchCodeByKeyword(String keyword);
 
-
-
     /**
      * 根据物料id获取物料信息
      * @param ids 物料拼接
@@ -373,7 +355,6 @@ public interface ProductService {
      */
     List<Product> getProductByIds(String ids);
 
-
     /**
      * 根据物料编号或主键获取物料信息
      * @param productNum 物料编号
@@ -382,7 +363,6 @@ public interface ProductService {
      */
     Product getProductByProductNumAndProductid(String productNum, Long id);
 
-
     /**
      * 根据企业enuu、型号、品牌获取物料信息
      * @param enuu
@@ -392,7 +372,6 @@ public interface ProductService {
      */
     Product getProductByEnuuAndCodeAndBrand(Long enuu, String cmpCode, String branden);
 
-
     /**
      * 根据起止时间统计未审核品牌数
      *
@@ -401,4 +380,20 @@ public interface ProductService {
      * @return 返回时间
      */
     ResultMap countProduct(Long fromDate, Long toDate);
+
+    /**
+     * 卖家中心添加单个物料录入
+     *
+     * @param jsonObject 前端数据封装
+     * @return ResultMap
+     */
+    ResultMap editOne(JSONObject jsonObject);
+
+    /**
+     * 判断是否标准物料
+     *
+     * @param product 物料信息
+     * @return ResultMap
+     */
+    ResultMap checkCriterion(Product product);
 }

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

@@ -36,9 +36,32 @@ import com.uas.platform.b2c.prod.commodity.dao.PCBDao;
 import com.uas.platform.b2c.prod.commodity.dao.ProductDao;
 import com.uas.platform.b2c.prod.commodity.dao.ProductDetailDao;
 import com.uas.platform.b2c.prod.commodity.dao.ProductPrivateDao;
-import com.uas.platform.b2c.prod.commodity.model.*;
+import com.uas.platform.b2c.prod.commodity.model.CommodityInOutbound;
+import com.uas.platform.b2c.prod.commodity.model.Goods;
+import com.uas.platform.b2c.prod.commodity.model.GoodsFilter;
+import com.uas.platform.b2c.prod.commodity.model.GoodsHistory;
 import com.uas.platform.b2c.prod.commodity.model.GoodsHistory.OperateType;
-import com.uas.platform.b2c.prod.commodity.service.*;
+import com.uas.platform.b2c.prod.commodity.model.GoodsInfo;
+import com.uas.platform.b2c.prod.commodity.model.GoodsModifyInfo;
+import com.uas.platform.b2c.prod.commodity.model.GoodsPriceInfo;
+import com.uas.platform.b2c.prod.commodity.model.GoodsQtyPrice;
+import com.uas.platform.b2c.prod.commodity.model.GoodsSimple;
+import com.uas.platform.b2c.prod.commodity.model.InOutboundDetail;
+import com.uas.platform.b2c.prod.commodity.model.ModifyInfo;
+import com.uas.platform.b2c.prod.commodity.model.Product;
+import com.uas.platform.b2c.prod.commodity.model.ProductAttachSubmit;
+import com.uas.platform.b2c.prod.commodity.model.ProductDetail;
+import com.uas.platform.b2c.prod.commodity.model.ProductPrivate;
+import com.uas.platform.b2c.prod.commodity.model.V_ProductPrivate;
+import com.uas.platform.b2c.prod.commodity.service.CommodityInOutboundService;
+import com.uas.platform.b2c.prod.commodity.service.GoodsHistoryService;
+import com.uas.platform.b2c.prod.commodity.service.GoodsPriceInfoService;
+import com.uas.platform.b2c.prod.commodity.service.GoodsService;
+import com.uas.platform.b2c.prod.commodity.service.InOutboundDetailService;
+import com.uas.platform.b2c.prod.commodity.service.ProductAttachService;
+import com.uas.platform.b2c.prod.commodity.service.ProductPrivateService;
+import com.uas.platform.b2c.prod.commodity.service.ProductService;
+import com.uas.platform.b2c.prod.commodity.service.V_ProductPrivateService;
 import com.uas.platform.b2c.prod.commodity.status.ModifyInfoStatus;
 import com.uas.platform.b2c.prod.commodity.type.ModifyConstant;
 import com.uas.platform.b2c.prod.commodity.util.GoodsUtil;
@@ -88,7 +111,6 @@ import com.uas.platform.core.persistence.criteria.LogicalExpression;
 import com.uas.platform.core.persistence.criteria.PredicateUtils;
 import com.uas.platform.core.persistence.criteria.SimpleExpression;
 import com.uas.platform.core.util.StringUtil;
-import com.uas.platform.core.util.serializer.FlexJsonUtils;
 import org.apache.commons.beanutils.ConvertUtils;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.MapUtils;
@@ -135,6 +157,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -294,7 +317,8 @@ public class GoodsServiceImpl implements GoodsService {
      * @param goods
      * @return
      */
-    public static ResultMap checkGoods(Goods goods) {
+    @Override
+    public ResultMap checkGoods(Goods goods) {
         if (goods == null) {
             throw new IllegalOperatorException("商品信息Goods不能为空");
         }
@@ -517,13 +541,6 @@ public class GoodsServiceImpl implements GoodsService {
             throw new IllegalOperatorException("以下批次数量不满足最小起订量,请您重新选择:" + batchCode);
         }
         Double reserve = goods.getReserve() - number;
-        //更新相应标准上架和标准产品信息
-//		if(goods.getSourceId() == null) {
-//			ResultMap resultMap = productStandardPutOnInfoService.updateOnSaleQty(goods, reserve);
-//			if(resultMap.getCode() != CodeType.OK.code()) {
-//				return resultMap;
-//			}
-//		}
 
 		goods.setReserve(reserve);
 		// 检查是否小于最小发货量
@@ -544,21 +561,17 @@ public class GoodsServiceImpl implements GoodsService {
 		return ResultMap.success(null);
 	}
 
-    // 释放库存
+    /**
+     * 释放库存
+     *
+     * @param batchCode 批号
+     * @param number the number 数量
+     * @return
+     */
     @Override
     public ResultMap releaseReserve(String batchCode, Double number) {
         Goods goods = findGoodsByBatchCode(batchCode);
-        if (goods == null) {
-            GoodsHistory history = goodsHistoryDao.findNewByBatchCode(batchCode);
-//			if(history.getSourceId() == null) {
-//				productStandardPutOnInfoService.updateAvailableQty(history.getStandprodid(), number);
-//			}
-        } else {
-            //更新相应标准上架和标准产品信息
-//			ResultMap resultMap = productStandardPutOnInfoService.updateOnSaleQty(goods, NumberUtil.add(goods.getReserve(), number));
-//			if(resultMap.getCode() != CodeType.OK.code()) {
-//				return resultMap;
-//			}
+        if (goods != null) {
             Double reserve = goods.getReserve() + number;
             goods.setReserve(reserve);
             // 检查是否大于最小发货量
@@ -667,7 +680,6 @@ public class GoodsServiceImpl implements GoodsService {
         goods.setStatus();
     }
 
-
     /**
      * 设置上架商品基本属性
      *
@@ -745,7 +757,7 @@ public class GoodsServiceImpl implements GoodsService {
 		productDetail.convertFromGoods(goods, product);
 		productDetailDao.save(productDetail);
 		Goods saveGoods = publish(goods, deviceInfo);
-		return goods;
+		return saveGoods;
 	}
 
 	@Override
@@ -759,9 +771,6 @@ public class GoodsServiceImpl implements GoodsService {
 		for (String uuid : uuids) {
 			updateComponentTradeInfos(uuid);
 		}
-//		for (Goods goods : list) {// 更新价格库用到了线程,所以要单独提出来
-//			saveOrUpdatePriceInfos(goods, deviceInfo);
-//		}
 		return list;
 	}
 
@@ -825,40 +834,6 @@ public class GoodsServiceImpl implements GoodsService {
         System.out.println("goods保存到数据库" + (timeNow.getTime() - time.getTime()));
     }
 
-    /**
-     * 验证分段的数据是否正确。
-     *
-     * @param prices
-     * @param currencyName
-     */
-    public static ResultMap validFragmentPrice(List<GoodsQtyPrice> prices, String currencyName) {
-        if (StringUtils.isEmpty(currencyName)) {
-            return new ResultMap(CodeType.PARAMETER_ERROR.code(), "库存的币别信息缺失");
-        }
-        Double end = -1d;
-        for (GoodsQtyPrice price : prices) {
-            if (price.getStart().longValue() >= price.getEnd().longValue()) {
-                return new ResultMap(CodeType.PARAMETER_ERROR.code(), "分段价格中存在分段起始值大于分段结束值");
-            }
-            if (end.longValue() >= price.getStart().longValue()) {
-                return new ResultMap(CodeType.PARAMETER_ERROR.code(), "分段价格中存在前一个分段结束值大于等于分段起始值");
-            }
-            if (currencyName.contains("USD")) {
-                if (price.getUSDPrice() == null || price.getUSDPrice().longValue() < 0) {
-                    return new ResultMap(CodeType.PARAMETER_ERROR.code(), "库存的币别信息包含美金,而分段价格中的美金价格不存在或小于0");
-                }
-            }
-            if (currencyName.contains("RMB")) {
-                if (price.getRMBPrice() == null || price.getRMBPrice().longValue() < 0) {
-                    return new ResultMap(CodeType.PARAMETER_ERROR.code(), "库存的币别信息包含人民币,而分段价格中的人民币价格不存在或小于0");
-                }
-            }
-            end = price.getEnd();
-
-        }
-        return ResultMap.success(null);
-    }
-
     /**
      * 添加或修改商品价格信息
      *
@@ -886,7 +861,7 @@ public class GoodsServiceImpl implements GoodsService {
             }
 
             // 如果新旧价格不一样,则保存商品价格信息
-            if (priceInfo.getPrice() != priceInfo.getOldPrice()) {
+            if (!Objects.equals(priceInfo.getPrice(), priceInfo.getOldPrice())) {
                 goodsPriceInfoService.saveOrUpdate(priceInfo, deviceInfo);
             }
         } else if ("RMB-USD".equalsIgnoreCase(goods.getCurrencyName().trim())) {
@@ -899,7 +874,7 @@ public class GoodsServiceImpl implements GoodsService {
             GoodsPriceInfo priceInfoRMB = getGoodsPriceInfo(findGoods);
             priceInfoRMB.setPrice(goods.getPrices().get(0).getRMBPrice());
             // 如果新旧价格不一样,则保存商品价格信息
-            if (priceInfoRMB.getPrice() != priceInfoRMB.getOldPrice()) {
+            if (!Objects.equals(priceInfoRMB.getPrice(), priceInfoRMB.getOldPrice())) {
                 goodsPriceInfoService.saveOrUpdate(priceInfoRMB, deviceInfo);
             }
             // 保存美元的价格信息
@@ -907,7 +882,7 @@ public class GoodsServiceImpl implements GoodsService {
             GoodsPriceInfo priceInfoUSD = getGoodsPriceInfo(findGoods);
             priceInfoUSD.setPrice(goods.getPrices().get(0).getUSDPrice());
             // 如果新旧价格不一样,则保存商品价格信息
-            if (priceInfoUSD.getPrice() != priceInfoUSD.getOldPrice()) {
+            if (!Objects.equals(priceInfoUSD.getPrice(), priceInfoUSD.getOldPrice())) {
                 goodsPriceInfoService.saveOrUpdate(priceInfoUSD, deviceInfo);
             }
         } else {
@@ -946,61 +921,6 @@ public class GoodsServiceImpl implements GoodsService {
 
     @Override
     public void updateComponentTradeInfos(final String uuid) {
-//        final Runnable updateComponentRunnable = new Runnable() {
-//
-//            @Override
-//            public void run() {
-//                Date startDate = new Date();
-//                SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-//                Component component = componentDao.findByUuid(uuid);
-//                if (component != null) {
-//                    Double totalReserve = goodsDao.findTotalReserveByUuid(uuid, Status.AVAILABLE.value());
-//                    component.setReserve(totalReserve);
-//                    // 设置最小最大价格
-//                    Double minPriceRMB = goodsDao.findMinPriceRMBByUuid(uuid, Status.AVAILABLE.value());
-//                    component.setMinPriceRMB(minPriceRMB != null ? minPriceRMB : 0);
-//                    Double maxPriceRMB = goodsDao.findMaxPriceRMBByUuid(uuid, Status.AVAILABLE.value());
-//                    component.setMaxPriceRMB(maxPriceRMB != null ? maxPriceRMB : 0);
-//                    Double minPriceUSD = goodsDao.findMinPriceUSDByUuid(uuid, Status.AVAILABLE.value());
-//                    component.setMinPriceUSD(minPriceUSD != null ? minPriceUSD : 0);
-//                    Double maxPriceUSD = goodsDao.findMaxPriceUSDByUuid(uuid, Status.AVAILABLE.value());
-//                    component.setMaxPriceUSD(maxPriceUSD != null ? maxPriceUSD : 0);
-//                    // 设置最小购买量
-//                    Double minBuyQty = goodsDao.findMinBuyQtyByUuid(uuid, Status.AVAILABLE.value());
-//                    component.setMinBuyQty(minBuyQty != null ? minBuyQty : 0);
-//                    // 设置最小最大发布周期
-//                    Short minDemDelivery = goodsDao.findMinDemDeliveryByUuid(uuid, Status.AVAILABLE.value());
-//                    component.setMinDemDelivery(minDemDelivery != null ? minDemDelivery : 0);
-//                    Short maxDemDelivery = goodsDao.findMaxDemDeliveryByUuid(uuid, Status.AVAILABLE.value());
-//                    component.setMaxDemDelivery(maxDemDelivery != null ? maxDemDelivery : 0);
-//                    Short minHKDelivery = goodsDao.findMinHKDeliveryByUuid(uuid, Status.AVAILABLE.value());
-//                    component.setMinHKDelivery(minHKDelivery != null ? minHKDelivery : 0);
-//                    Short maxHKDelivery = goodsDao.findMaxHKDeliveryByUuid(uuid, Status.AVAILABLE.value());
-//                    component.setMaxHKDelivery(maxHKDelivery != null ? maxHKDelivery : 0);
-//                    // 剩余样品数
-//                    Double availableSampleQty = goodsDao.findAvailableSampleQtyByUuid(uuid, Status.AVAILABLE.value());
-//                    component.setSampleQty(availableSampleQty != null ? availableSampleQty : 0);
-//                    //已申请的样品数
-//                    Double applyedSampleQty = goodsDao.findApplyedSampleQty(uuid, Status.AVAILABLE.value());
-//                    component.setApplySampleQty(applyedSampleQty != null ? applyedSampleQty : 0);
-//                    // 现货
-//                    Double originalQty = goodsDao.findOriginalQtyByUuid(uuid, Status.AVAILABLE.value());
-//                    component.setOriginalQty(originalQty != null ? originalQty : 0);
-//                    // 呆滞库存
-//                    Double inactionStockQty = goodsDao.findInactionStockQtyByUuid(uuid, Status.AVAILABLE.value());
-//                    component.setInactionStockQty(inactionStockQty != null ? inactionStockQty : 0);
-//                    componentDao.save(component);
-//                }
-//                Date endDate = new Date();
-//                System.out.println(uuid + " execute time " + formatter.format(startDate) + " -> " + formatter.format(endDate) +
-//                        ", using mill seconds: " + (endDate.getTime() - startDate.getTime()));
-//            }
-//        };
-//        try {
-//            executor.submitTask(updateComponentRunnable);
-//        } catch (InterruptedException e) {
-//            e.printStackTrace();
-//        }
     }
 
 	/**
@@ -1168,14 +1088,6 @@ public class GoodsServiceImpl implements GoodsService {
                             }
                             goods.setMaxDelivery(delivery);
                             goods.setMinDelivery(delivery);
-//							if(goods.getCurrencyName().contains("RMB")) {
-//								goods.setSelfDeliveryDemMaxTime(delivery);
-//								goods.setSelfDeliveryDemMinTime(delivery);
-//							}else if(goods.getCurrencyName().contains("USD")){
-//								goods.setSelfDeliveryHKMaxTime(delivery);
-//								goods.setSelfDeliveryHKMinTime(delivery);
-//							}
-
                         }
 
                         // 备注
@@ -1273,45 +1185,6 @@ public class GoodsServiceImpl implements GoodsService {
         return pageGoods;
     }
 
-    public ResultMap saveModify(Goods goods, Boolean isSelfSupport) {
-        Long enUU = SystemSession.getUser().getEnterprise().getUu();
-        if (goods == null) {
-            return new ResultMap(CodeType.NO_INFO.code(), "提交的修改信息丢失");
-        }
-        // 检查身份
-        if (!goods.getEnUU().equals(enUU)) {
-            return new ResultMap(CodeType.NOT_PERMIT.code(), "您提交的批次号不属于您当前登陆公司");
-        }
-        if (goods.getSourceId() != null) {
-            return new ResultMap(CodeType.NOT_PERMIT.code(), "该库存的信息属于UAS上架,平台不能修改。");
-        }
-        if (goods.getReserve().doubleValue() != goods.getOldReserve().doubleValue()) {
-            return new ResultMap(CodeType.INFO_UPDATE.code(), "该库存的信息已经被修改了,请刷新界面之后重新操作。");
-        }
-        if (NumberUtil.compare(goods.getReserve(), goods.getMinBuyQty()) > -1) {
-            goods.setStatus(Status.AVAILABLE.value());
-        } else {
-            goods.setStatus(Status.UNAVAILABLE.value());
-        }
-
-        StoreIn store;
-        if (isSelfSupport) {
-            Enterprise enterprise = SystemSession.getUser().getEnterprise();
-            assert enterprise != null;
-            StoreIn storeIn = storeInService.findByEnUU(enterprise.getUu());
-            store = storeIn.getStatus() == StoreStatus.OPENED ? storeIn : null;
-        } else {
-            store = storeInService.findByUuid(sysConf.getStoreid());
-        }
-        if (store == null) {
-            return new ResultMap(CodeType.NOT_PERMIT, "请先开店,再上架自营商品");
-        }
-        goods.setStoreid(store.getUuid());
-        goods.setStoreName(store.getStoreName());
-
-        return null;
-    }
-
     /**
      * @TODO 各种检查
      * @MustBeDoneBefore 2016年4月25日11:54:00
@@ -1352,32 +1225,6 @@ public class GoodsServiceImpl implements GoodsService {
         return ResultMap.success(resultGoods);
     }
 
-
-    /**
-     * 比较是否修改了物料信息,如果修改了物料信息
-     * @param goodsFromFore 前端修改
-     * @param goodsFromSql 数据库获取的
-     * @return
-     */
-    public ResultMap compareGoodsIfModifyProductInfo(Goods goodsFromFore, Goods goodsFromSql) {
-        if (goodsFromFore == null || goodsFromSql == null) {
-            return new ResultMap(CodeType.OK, "信息未修改");
-        } else {
-            if ((!StringUtilB2C.equals(goodsFromFore.getSpec(), goodsFromSql.getSpec())) || (!StringUtilB2C.equals(goodsFromFore.getBrandNameEn(), goodsFromSql.getBrandNameEn())) || (!StringUtilB2C.equals(goodsFromFore.getCode(), goodsFromSql.getCode())) || (!StringUtilB2C.equals(goodsFromFore.getKindNameCn(), goodsFromSql.getKindNameCn()))) {
-                Product product = new Product();
-                product.setPbranden(goodsFromFore.getBrandNameEn());
-                product.setPcmpcode(goodsFromFore.getCode());
-                product.setId(goodsFromFore.getProductid());
-                product.setKind(goodsFromFore.getKindNameCn());
-                product.setSpec(goodsFromFore.getSpec());
-                ResultMap resultMap = productService.updateProduct(FlexJsonUtils.toJson(product), null);
-                return resultMap;
-            } else {
-                return new ResultMap(CodeType.OK, "物料未更新");
-            }
-        }
-    }
-
     /**
      * 比较两个Goods,得出修改后的信息
      * @param beforeGoods 原有的Goods
@@ -1385,12 +1232,6 @@ public class GoodsServiceImpl implements GoodsService {
      */
     private void compareGoodsWithModify(Goods beforeGoods, Goods afterGoods) {
         List<ModifyInfo> infoList = new ArrayList<>();
-//        String beforeProduce = beforeGoods.getProduceDate();
-//        String afterProduce = afterGoods.getProduceDate();
-//        if (!StringUtilB2C.equals(beforeProduce, afterProduce)) {
-//            ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_PRODUCE_DATE.getPhrase(), beforeGoods.getBatchCode(), StringUtilB2C.valueOf(beforeProduce), StringUtilB2C.valueOf(beforeProduce),  ModifyInfo.TYPE_BASIC);
-//            infoList.add(info);
-//        }
         Boolean beforeBreak = beforeGoods.getBreakUp();
         Boolean afterBreak = afterGoods.getBreakUp();
         if (!beforeBreak.equals(afterBreak)) {
@@ -1409,12 +1250,6 @@ public class GoodsServiceImpl implements GoodsService {
             ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_MIN_DELIVERY.getPhrase(), beforeGoods.getBatchCode(), StringUtilB2C.valueOf(beforeMinDelivery), StringUtilB2C.valueOf(afterMinDelivery), ModifyInfo.TYPE_SALE);
             infoList.add(info);
         }
-//        Integer beforeGoodsStatus = beforeGoods.getStatus();
-//        Integer afterGoodsStatus = afterGoods.getStatus();
-//        if (!beforeGoodsStatus.equals(afterGoodsStatus)) {
-//            ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_GOODS_STATUS.getPhrase(), beforeGoods.getBatchCode(), Status.valueStringOf(beforeGoodsStatus), Status.valueStringOf(afterGoodsStatus), ModifyInfo.TYPE_SALE);
-//            infoList.add(info);
-//        }
         Short beforeMaxDelivery = beforeGoods.getMaxDelivery();
         Short afterMaxDelivery = afterGoods.getMaxDelivery();
         if (!StringUtilB2C.equals(StringUtilB2C.valueOf(beforeMaxDelivery), StringUtilB2C.valueOf(afterMaxDelivery))) {
@@ -1847,21 +1682,6 @@ public class GoodsServiceImpl implements GoodsService {
         return nowGoods;
     }
 
-    /**
-     * 添加商品操作记录,保存商品信息
-     *
-     * @param goods
-     * @param deviceInfo
-     * @param type       库存交易的类型
-     * @return
-     */
-    @Override
-    public Goods saveGoods(Goods goods, String deviceInfo, GoodsHistory.OperateType type) {
-        updateGoodTransactional(goods);
-        updateComponentTradeInfos(goods.getUuid());
-        return goods;
-    }
-
     @Override
     public List<GoodsInfo> updateGoodses(List<Goods> goodses) {
         List<GoodsInfo> goodsInfos = new ArrayList<GoodsInfo>();
@@ -2020,27 +1840,6 @@ public class GoodsServiceImpl implements GoodsService {
         return goods;
     }
 
-    /**
-     * 根据批次号失效待确认的订单
-     */
-//	@Override
-//	public void invalidOrderDetail(String batchCode) {
-//		if (StringUtils.isEmpty(batchCode)) {
-//			throw new IllegalOperatorException("批次号为空");
-//		}
-//		List<OrderDetail> orderDetails = orderDetailDao.findByBatchCode(batchCode);
-//		for (int i = 0; i < orderDetails.size(); i++) {
-//			Order order = orderDetails.get(i).getOrder();
-//			Integer status = order.getStatus();
-//			if (status.intValue() == Status.TOBECONFIRMED.value()) {
-//				order.setStatusUnAvailable(SystemSession.getUser().getEnterprise().getUu());
-//				orderDetails.get(i).setStatusUnAvailable(SystemSession.getUser().getEnterprise().getUu());
-//				//还需要判断订单是否需要全部失效
-//				orderDao.save(order);
-//			}
-//		}
-//	}
-
     /**
      * 更新库存的信息,加上事务
      */
@@ -2089,10 +1888,11 @@ public class GoodsServiceImpl implements GoodsService {
     }
 
     @Transactional
+    @Override
     public Goods updateGoodsByErp(Goods goods) {
         Goods nowGoods = goodsDao.findByBatchCode(goods.getBatchCode());
         // 检查数据
-        GoodsServiceImpl.checkGoods(goods);
+        checkGoods(goods);
         goods.setUpdateDate(new Date());
 
         // 同步未税单价
@@ -2185,30 +1985,6 @@ public class GoodsServiceImpl implements GoodsService {
         return goodsInfos;
     }
 
-
-    @Override
-    public ResultMap updateGoodsByProductStandardPutOn(Goods goods) {
-        goods.setUpdateDate(new Date());
-        // 用含税单价同步未含税单价
-        goods.setWithOutTaxRMBPrice();
-        goods.setWithOutTaxUSDPrice();
-        //保留六位有效数字
-        goods.setSixFraction();
-        // 更新本批次最小最大价格信息
-        goods.setMinPriceRMB(GoodsUtil.getMinPriceRMB(goods.getPrices()));
-        goods.setMaxPriceRMB(GoodsUtil.getMaxPriceRMB(goods.getPrices()));
-        goods.setMinPriceUSD(GoodsUtil.getMinPriceUSD(goods.getPrices()));
-        goods.setMaxPriceUSD(GoodsUtil.getMaxPriceUSD(goods.getPrices()));
-        // 设置货到香港,货到大陆的延长时间
-        setB2CDelayTime(goods);
-        if (NumberUtil.compare(goods.getReserve(), goods.getMinBuyQty()) >= 0) {
-            goods.setStatus(Status.AVAILABLE.value());
-        } else {
-            goods.setStatus(Status.UNAVAILABLE.value());
-        }
-        return checkGoods(goods);
-    }
-
     /**
      * 查看操作的数据是否合法
      */
@@ -3305,8 +3081,9 @@ public class GoodsServiceImpl implements GoodsService {
         }
         List<Goods> goodsList = goodsDao.findByProductId(id);
         for (Goods goods : goodsList) {
-            if (goods.getStoreid() == null)
+            if (goods.getStoreid() == null) {
                 throw new IllegalOperatorException("商品店铺信息丢失");
+            }
             if (goods.getStoreid().equals(sysConf.getStoreid())) {
                 goods.setSelfSale("2");
             } else {
@@ -3322,8 +3099,9 @@ public class GoodsServiceImpl implements GoodsService {
             throw new IllegalOperatorException("产品主键丢失,刷新后重试");
         }
         List<Goods> goodsList = goodsDao.findByProductId(id);
-        if (CollectionUtils.isEmpty(goodsList))
+        if (CollectionUtils.isEmpty(goodsList)) {
             throw new IllegalOperatorException("对应Goods信息丢失");
+        }
         Goods goods = goodsList.get(0);
         goods.setSold(IntegerConstant.YES_INT);
         if (NumberUtil.compare(goods.getReserve(), goods.getMinBuyQty()) == -1) {
@@ -3385,7 +3163,6 @@ public class GoodsServiceImpl implements GoodsService {
         return ResultMap.success(null);
     }
 
-
     @Override
     public List<Goods> maxReserveLimitLength(Integer length) {
         List<Goods> goodses = goodsDao.maxReserveLimitLength(length);
@@ -3569,25 +3346,6 @@ public class GoodsServiceImpl implements GoodsService {
      */
     @Override
     public String arrangeGoods() {
-        /**
-         * 删除重复的SKU编码
-         */
-//        List<Long> greaterThenTwo = goodsDao.findSameGoodsGreaterThenTwo();
-//        List<GoodsHistory> histories = new ArrayList<>();
-//        for (Long aLong : greaterThenTwo) {
-//            Goods goods = goodsDao.findOne(aLong);
-//            List<Goods> goodsInProductId = goodsDao.findRepeatGoodsInProductId(goods.getProductid(), goods.getProduceDate(), goods.getPackaging(), goods.getMinPackQty(), goods.getMinBuyQty(), goods.getMaxDelivery(), goods.getMinDelivery(), goods.getUnit());
-//            Integer count = 0;
-//            for (Goods goods1 : goodsInProductId) {
-//                if(goods1.getId().longValue() != aLong.longValue()) {
-//                    goods1.setStatus(Status.GOODS_DELETE.value());
-//                    GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods1, OperateType.DELETE.getPhrase());
-//                    histories.add(goodsHistory);
-//                    goodsDao.delete(goods1.getId());
-//                }
-//            }
-//        }
-//        goodsHistoryService.save(histories);
         /**
          * 关联在售和产品库的信息, 分页获取 productid
          */
@@ -3645,20 +3403,6 @@ public class GoodsServiceImpl implements GoodsService {
             productDao.save(products);
         }
 
-//        List<GoodsHistory> failHistory = new ArrayList<>();
-//        List<Goods> goodses = goodsDao.findGoodsByTagIsNull();
-//        for (Goods goods : goodses) {
-//            if(goods.getProductid() != null) {
-//                Product product = productDao.findOne(goods.getProductid());
-//                if(product == null) {
-//                    goods.setStatus(Status.GOODS_DELETE.value());
-//                    GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, OperateType.DELETE.getPhrase());
-//                    failHistory.add(goodsHistory);
-//                    goodsDao.delete(goods.getId());
-//                }
-//            }
-//        }
-//        goodsHistoryService.save(failHistory);
         return String.valueOf(end);
     }
 
@@ -3748,7 +3492,7 @@ public class GoodsServiceImpl implements GoodsService {
     @Override
     public String modifyData() {
         Long countGoods = goodsDao.getCountGoods();
-        Long start = 0l, length = 1000l;
+        Long start = 0L, length = 1000L;
         List<GoodsHistory> histories = new ArrayList<>();
         List<Goods> goodses = new ArrayList<>();
         Boolean isModify = false;
@@ -3814,16 +3558,6 @@ public class GoodsServiceImpl implements GoodsService {
 		return page;
 	}
 
-    /**
-     * 获取未发货前订单的库存数
-     * @param detail
-     * @return
-     */
-    private Goods fillDataInGoods(ProductDetail detail) {
-        Goods goods = new Goods();
-        return goods;
-    }
-
     /**
      * 根据店铺id查找店铺所属企业enUU
      * @param storeid
@@ -4006,36 +3740,6 @@ public class GoodsServiceImpl implements GoodsService {
         }
 	}
 
-    /**
-     * 更新货物的有效期
-     *
-     * @param products the operate type 操作的记录
-     * @param goodses     the param
-     */
-    @Override
-    public void updateSpecByProducts(List<Product> products, List<Goods> goodses) {
-        List<Goods> goods = new ArrayList<>();
-        List<GoodsHistory> goodsHistories = new ArrayList<>();
-        if (CollectionUtils.isNotEmpty(products) && CollectionUtils.isNotEmpty(goodses)) {
-            for (Product product : products) {
-                for (Goods goodse : goodses) {
-                    if (goodse.getProductid() != null && (goodse.getProductid().longValue() ==  product.getId().longValue()) && (!StringUtils.isEmpty(product.getSpec())) && (!product.getSpec().equals(goodse.getSpec()))) {
-                        goodse.setSpec(product.getSpec());
-                        goods.add(goodse);
-                        GoodsHistory history = goodsHistoryService.converTGoodsHist(goodse, OperateType.Update.getPhrase(), false);
-                        goodsHistories.add(history);
-                    }
-                }
-            }
-        }
-        if (CollectionUtils.isNotEmpty(goods)) {
-            goodsDao.save(goods);
-        }
-        if (CollectionUtils.isNotEmpty(goodsHistories)) {
-            goodsHistoryService.save(goodsHistories);
-        }
-    }
-
     @Override
     public Map<String, List<Goods>> getCmsPcb() {
         Map<String, List<Goods>> map = new HashedMap();
@@ -4071,7 +3775,6 @@ public class GoodsServiceImpl implements GoodsService {
         return map;
     }
 
-
     /**
      * 根据产品更新在售产品
      *
@@ -4157,12 +3860,12 @@ public class GoodsServiceImpl implements GoodsService {
         }
     }
 
-
     /**
      *  根据物料主键统计该物料包含多少个批次
      * @param prIds 物料的主键信息
      * @return ap<Long, Integer>
      */
+    @Override
     public Map<Long, Integer> batchGetCountByProductId(List<Long>  prIds) {
         if (CollectionUtils.isEmpty(prIds)) {
             return new HashedMap();
@@ -4183,22 +3886,6 @@ public class GoodsServiceImpl implements GoodsService {
         }
     }
 
-    /**
-     * 根据 batchid 获取本次上架的信息
-     *
-     * @param batchid 本批次上架标识
-     * @return List<Goods>
-     */
-    @Override
-    public List<Goods> findByBatchId(String batchid) {
-        if (StringUtils.isEmpty(batchid)) {
-            return new ArrayList<>();
-        } else {
-            List<Goods> goodses = goodsDao.findByBatchid(batchid);
-            return goodses;
-        }
-    }
-
     /**
      * 根据ids获取物料信息
      *
@@ -4229,7 +3916,7 @@ public class GoodsServiceImpl implements GoodsService {
         if (CollectionUtils.isNotEmpty(v_productPrivates)) {
             V_ProductPrivate v_productPrivate = v_productPrivates.get(0);
             goods.setProductid(v_productPrivate.getId());
-            if (IntegerConstant.YES_INT != v_productPrivate.getB2cEnabled()) {
+            if (!Objects.equals(IntegerConstant.YES_INT, v_productPrivate.getB2cEnabled())) {
                 ProductPrivate productPrivate = productPrivateService.findByPrId(v_productPrivate.getId());
                 productPrivate.setB2cEnabled(com.uas.platform.b2c.core.constant.IntegerConstant.YES_SHORT);
                 productPrivate.setBatchCount(com.uas.platform.b2c.core.constant.IntegerConstant.YES_SHORT);

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

@@ -5,8 +5,6 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.TypeReference;
 import com.alibaba.fastjson.parser.Feature;
-import com.uas.platform.b2c.advertise.ad.service.RecommendProductService;
-import com.uas.platform.b2c.common.account.dao.UserDao;
 import com.uas.platform.b2c.common.account.model.Enterprise;
 import com.uas.platform.b2c.common.account.service.EnterpriseService;
 import com.uas.platform.b2c.common.base.dao.CommonDao;
@@ -19,26 +17,27 @@ import com.uas.platform.b2c.core.constant.ShortConstant;
 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.FastjsonUtils;
 import com.uas.platform.b2c.core.utils.NumberUtil;
 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.PublicProductUrl;
 import com.uas.platform.b2c.prod.commodity.constant.StringConstant;
+import com.uas.platform.b2c.prod.commodity.dao.CommodityInOutboundDao;
 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.MatchModelDao;
-import com.uas.platform.b2c.prod.commodity.dao.PCBDao;
 import com.uas.platform.b2c.prod.commodity.dao.ProductDao;
 import com.uas.platform.b2c.prod.commodity.dao.ProductDetailDao;
 import com.uas.platform.b2c.prod.commodity.dao.ProductMatchResultDao;
-import com.uas.platform.b2c.prod.commodity.dao.ProductModifyHistoryDao;
 import com.uas.platform.b2c.prod.commodity.dao.ProductPersonDao;
 import com.uas.platform.b2c.prod.commodity.dao.ProductPrivateDao;
 import com.uas.platform.b2c.prod.commodity.dao.ProductReplaceDao;
 import com.uas.platform.b2c.prod.commodity.dao.ProductStoreStatusDao;
 import com.uas.platform.b2c.prod.commodity.dao.V_ProductPersonDao;
 import com.uas.platform.b2c.prod.commodity.dao.V_ProductPrivateDao;
+import com.uas.platform.b2c.prod.commodity.model.CommodityInOutbound;
 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.model.GoodsQtyPrice;
@@ -58,11 +57,11 @@ import com.uas.platform.b2c.prod.commodity.model.V_ProductPerson;
 import com.uas.platform.b2c.prod.commodity.model.V_ProductPrivate;
 import com.uas.platform.b2c.prod.commodity.service.GoodsHistoryService;
 import com.uas.platform.b2c.prod.commodity.service.GoodsService;
-import com.uas.platform.b2c.prod.commodity.service.InOutboundDetailService;
 import com.uas.platform.b2c.prod.commodity.service.ProductAttachService;
 import com.uas.platform.b2c.prod.commodity.service.ProductPrivateService;
 import com.uas.platform.b2c.prod.commodity.service.ProductService;
 import com.uas.platform.b2c.prod.commodity.service.UASBatchPutOnPropertyService;
+import com.uas.platform.b2c.prod.commodity.type.InOutBoundType;
 import com.uas.platform.b2c.prod.commodity.type.ProductConstant;
 import com.uas.platform.b2c.prod.commodity.util.GoodsUtil;
 import com.uas.platform.b2c.prod.product.brand.dao.BrandDao;
@@ -72,7 +71,6 @@ import com.uas.platform.b2c.prod.product.component.dao.ComponentDao;
 import com.uas.platform.b2c.prod.product.component.dao.ComponentSubmitDao;
 import com.uas.platform.b2c.prod.product.component.modal.Component;
 import com.uas.platform.b2c.prod.product.component.modal.ComponentSubmit;
-import com.uas.platform.b2c.prod.product.kind.dao.KindInfoDao;
 import com.uas.platform.b2c.prod.product.kind.model.Kind;
 import com.uas.platform.b2c.prod.store.model.StoreIn;
 import com.uas.platform.b2c.prod.store.model.StoreStatus;
@@ -81,17 +79,16 @@ import com.uas.platform.b2c.trade.order.dao.OrderDetailDao;
 import com.uas.platform.b2c.trade.order.model.Order;
 import com.uas.platform.b2c.trade.order.model.OrderDetail;
 import com.uas.platform.b2c.trade.order.service.OrderDetailService;
-import com.uas.platform.b2c.trade.order.service.OrderService;
 import com.uas.platform.b2c.trade.order.status.OrderStatus;
 import com.uas.platform.b2c.trade.presale.dao.CartDao;
 import com.uas.platform.b2c.trade.presale.dao.GoodsBrowsingHistoryDao;
 import com.uas.platform.b2c.trade.presale.model.Cart;
 import com.uas.platform.b2c.trade.presale.model.GoodsBrowsingHistory;
-import com.uas.platform.b2c.trade.presale.service.CartService;
 import com.uas.platform.b2c.trade.support.CodeType;
 import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.b2c.trade.util.BoundedExecutor;
 import com.uas.platform.core.exception.IllegalOperatorException;
+import com.uas.platform.core.logging.BufferedLoggerManager;
 import com.uas.platform.core.model.Constant;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.PageParams;
@@ -99,10 +96,11 @@ import com.uas.platform.core.persistence.criteria.LogicalExpression;
 import com.uas.platform.core.persistence.criteria.PredicateUtils;
 import com.uas.platform.core.persistence.criteria.SimpleExpression;
 import com.uas.platform.core.util.serializer.FlexJsonUtils;
+import javassist.NotFoundException;
 import org.apache.commons.beanutils.ConvertUtils;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.map.HashedMap;
-import org.apache.log4j.Logger;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.dao.DataAccessException;
@@ -123,7 +121,6 @@ import javax.persistence.criteria.CriteriaBuilder;
 import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
-import java.lang.reflect.Field;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
@@ -138,19 +135,19 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
 /**
- * Created by wangyc on 2017/5/26.
+ * 物料服务
+ * @author wangyc
+ * @date 2017/5/26
  */
 @Service
 public class ProductServiceImpl implements ProductService {
 
-    private final Logger logger = Logger.getLogger(getClass());
-
     @Autowired
     private ProductDao productDao;
 
@@ -181,30 +178,18 @@ public class ProductServiceImpl implements ProductService {
     @Autowired
     private ProductPrivateDao productPrivateDao;
 
-    @Autowired
-    private ProductModifyHistoryDao productModifyHistoryDao;
-
     @Autowired
     private GoodsHistoryService goodsHistoryService;
 
     @Autowired
     private GoodsHistoryDao goodsHistoryDao;
 
-    @Autowired
-    private RecommendProductService recommendProductService;
-
-    @Autowired
-    private CartService cartService;
-
     @Autowired
     private GoodsBrowsingHistoryDao goodsBrowsingHistoryDao;
 
     @Autowired
     private OrderDetailService orderDetailService;
 
-    @Autowired
-    private OrderService orderService;
-
     @Autowired
     private ProductDetailDao productDetailDao;
 
@@ -250,26 +235,25 @@ public class ProductServiceImpl implements ProductService {
     @Autowired
     private ProductReplaceDao productReplaceDao;
 
-    @Autowired
-    private KindInfoDao kindInfoDao;
-
-    @Autowired
-    private PCBDao pcbDao;
-
-    @Autowired
-    private UserDao userDao;
-
     /**
      * 控制任务提交速度的线程池
      */
     private final BoundedExecutor executor;
 
+    /**
+     * 系统操作日志
+     */
+    private static final UsageBufferedLogger LOGGER = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
+
     @Autowired
     private SearchService searchService;
 
     @Autowired
     private ProductAttachService productAttachService;
 
+    @Autowired
+    private CommodityInOutboundDao commodityInOutboundDao;
+
     @Value("#{sys.productServiceIp}")
     private String productServiceIp;
 
@@ -278,9 +262,6 @@ public class ProductServiceImpl implements ProductService {
 
     private final CommonDao commonDao;
 
-    @Autowired
-    private InOutboundDetailService inOutboundDetailService;
-
     @Autowired
     public ProductServiceImpl(CommonDao commonDao) {
         this.commonDao = commonDao;
@@ -288,8 +269,6 @@ public class ProductServiceImpl implements ProductService {
         executor = new BoundedExecutor(executorService, 1600);
     }
 
-    private ConcurrentHashMap<String, Field> sortFields = new ConcurrentHashMap<String, Field>();
-
     @Override
     public Page<V_ProductPrivate> getAllProducts(final PageInfo page, String keyword, String type, Long userUU) {
         Long enUU = SystemSession.getUser().getEnterprise().getUu();
@@ -298,7 +277,7 @@ public class ProductServiceImpl implements ProductService {
         }
         SPage<Long> ids = searchService.getProducts(enUU, keyword, page.getPageNumber(), page.getPageSize(), type);
         if (ids == null || CollectionUtils.isEmpty(ids.getContent())) {
-            return new PageImpl<V_ProductPrivate>(new ArrayList<>(), page, 0);
+            return new PageImpl<>(new ArrayList<>(), page, 0);
         }
         List<Long> idList = ids.getContent();
         List<V_ProductPrivate> productList = v_productPrivateDao.findAll(idList);
@@ -340,7 +319,7 @@ public class ProductServiceImpl implements ProductService {
                 }
             }
         }
-        return new PageImpl<V_ProductPrivate>(productList, page, ids.getTotalElement());
+        return new PageImpl<>(productList, page, ids.getTotalElement());
     }
 
     @Override
@@ -352,12 +331,12 @@ public class ProductServiceImpl implements ProductService {
         if (StringUtils.isEmpty(type)) {
             type = "nStandard";
         }
-        page.filter("b2cEnabled", (short) 1);
-        if (type.contains("standard")) {
-            page.filter("standard", (short)1);
-        } else if (type.contains("nStandard")) {
-            page.filter("standard", (short)0);
-        } else if (type.contains("all")) {
+        page.filter("b2cEnabled", IntegerConstant.YES_SHORT);
+        if (type.contains(ProductConstant.STANDARD)) {
+            page.filter("standard", IntegerConstant.YES_SHORT);
+        } else if (type.contains(ProductConstant.NSTANDARD)) {
+            page.filter("standard", IntegerConstant.NO_SHORT);
+        } else if (type.contains(ProductConstant.ALL)) {
             page.sorting("createTime", Sort.Direction.DESC);
         }
 
@@ -418,7 +397,7 @@ public class ProductServiceImpl implements ProductService {
                     product.setProductReplaceList(productReplaces);
                 }
             }
-            return new PageImpl<V_ProductPerson>(productList, page, productPage.getTotalElements());
+            return new PageImpl<>(productList, page, productPage.getTotalElements());
         } else {
             return productPage;
         }
@@ -469,11 +448,7 @@ public class ProductServiceImpl implements ProductService {
             for (Long prId : prIds) {
                 List<ProductPerson> p = productPersonDao.findByProductIdAndUserUU(prId,useruu);
                 if (CollectionUtils.isEmpty(p)) {
-                    ProductPerson productPerson = new ProductPerson();
-                    productPerson.setUserUU(useruu);
-                    productPerson.setEnuu(SystemSession.getUser().getEnterprise().getUu());
-                    productPerson.setProductId(prId);
-                    productPerson.setTime(new Date());
+                    ProductPerson productPerson = new ProductPerson(useruu, SystemSession.getUser().getEnterprise().getUu(), prId);
                     productPersonDao.save(productPerson);
                     count++;
                 }
@@ -513,13 +488,13 @@ public class ProductServiceImpl implements ProductService {
         page.setPageNumber(1);
         page.setPageSize(10);
 
-        List<V_ProductPrivate> products = new ArrayList<>();
+        List<V_ProductPrivate> products;
         page.filter("enUU", SystemSession.getUser().getEnterprise().getUu());
         page.filter("b2cEnabled", com.uas.platform.b2c.prod.commodity.constant.IntegerConstant.YES_INT);
         page.sorting(Sort.Direction.DESC, "standard", "id");
-        if (type.contains("standard")) {
+        if (type.contains(ProductConstant.STANDARD)) {
             page.filter("standard", IntegerConstant.YES_SHORT);
-        } else if (type.contains("nStandard")) {
+        } else if (type.contains(ProductConstant.NSTANDARD)) {
             page.filter("standard", IntegerConstant.NO_SHORT);
         }
         if (StringUtils.hasText(keyword)) {
@@ -580,18 +555,15 @@ public class ProductServiceImpl implements ProductService {
             if (null != isPerson && isPerson.intValue() == IntegerConstant.YES_SHORT.intValue()) {
                 List<ProductPerson> productPersonList = productPersonDao.findByProductIdAndUserUU(id,SystemSession.getUser().getUserUU());
                 if (!CollectionUtils.isEmpty(productPersonList)) {
-//                    Map<String,Object> requestMap = new HashMap<>();
-//                    requestMap.put("userUU",productPersonList.get(0).getUserUU());
-//                    requestMap.put("productId",productPersonList.get(0).getProductId());
-//                    String res  = restTemplate.postForEntity( productServiceIp+"/product/assign/delete", null, String.class, requestMap).getBody();
                     Long ppid = productPersonList.get(0).getId();
                     productPersonDao.delete(ppid);
                 }
                 continue;
             }
             Product product = productDao.findOne(id);
-            if (product == null)
+            if (product == null) {
                 throw new IllegalOperatorException("选择的产品不存在,请重新选择");
+            }
             //查看是否存在正常未取消的订单
             List<Goods> goodses = goodsDao.findByProductId(product.getId());
             Boolean isExistOrder = false;
@@ -648,8 +620,8 @@ public class ProductServiceImpl implements ProductService {
      */
     @Override
     public ResultMap deleteBatch(String type, Integer isPerson) {
-        Integer standard = null;
-        List<ProductPerson> personList = new ArrayList<>();
+        Integer standard;
+        List<ProductPerson> personList;
         Integer fail = 0;
         Integer success = 0;
         Integer isHave = 0;
@@ -703,7 +675,6 @@ public class ProductServiceImpl implements ProductService {
                     Set<ProductMatchResult> productMatchResultSet =  product.getMatchresults();
                     productMatchResultDao.delete(productMatchResultSet);
                     goodsService.deleteGoods(goodses);
-                    //productDao.delete(product.getId());
                     ProductPrivate productPrivate = productPrivateService.findByPrId(product.getId());
                     if (null == productPrivate) {
                         productPrivate = new ProductPrivate();
@@ -753,14 +724,17 @@ public class ProductServiceImpl implements ProductService {
     @Override
     public Product match(Long id) {
         Product product = productDao.findOne(id);
-        if (product == null)
+        if (product == null) {
             throw new IllegalOperatorException("所选产品不存在");
-        if (product.getCmpCode() == null)
+        }
+        if (product.getCmpCode() == null) {
             throw new IllegalOperatorException("该产品尚无产品型号,无法匹配");
-        if (product.getBrand() == null)
+        }
+        if (product.getBrand() == null) {
             throw new IllegalOperatorException("该产品尚无品牌信息,无法匹配");
+        }
 
-        Long brandId = null;
+        Long brandId;
         List<Brand> brands = brandDao.findByUpperNameEn(product.getBrand());
         if (CollectionUtils.isEmpty(brands)) {
             brands = brandDao.findByUpperNameCn(product.getBrand());
@@ -774,8 +748,9 @@ public class ProductServiceImpl implements ProductService {
         }
 
         List<Component> components = componentDao.findByCodeAndBrandid(product.getCmpCode(), brandId);
-        if (CollectionUtils.isEmpty(components))
+        if (CollectionUtils.isEmpty(components)) {
             throw new IllegalOperatorException("匹配失败,商城暂无该型号信息,可前往“器件申请”,提出申请");
+        }
         product.setCmpUuId(components.get(0).getUuid());
         product.setPbrand(brands.get(0).getNameCn());
         product.setPbranden(brands.get(0).getNameEn());
@@ -815,60 +790,39 @@ public class ProductServiceImpl implements ProductService {
     @Override
     public ResultMap matchall(String matchtype) {
         Map<String, Integer> map = new HashMap<>();
-        boolean flag = true;
-        ProductStoreStatus status = productStoreStatusDao.findByEnuu(SystemSession.getUser().getEnterprise().getUu());
-        if (status != null) {
-            if (status.getStatus().equals(Status.RUNNING.value())) {// 有人正在操作这张单据,不能进行操作
-                Date date = new Date();
-                long l = date.getTime() - status.getDate().getTime();
-                if(l > 600000) {
-                    status.setStatus(Status.FINISH.value());
-                }else {
-                    return new ResultMap(CodeType.NOT_PERMIT, "当前有人正在进行匹配操作,无法进行匹配");
-                }
-            } else {
-                status.setStatus(Status.RUNNING.value());
-                status = productStoreStatusDao.save(status);
-            }
+        ResultMap resultMap = validateProductStatus(SystemSession.getUser().getEnterprise().getUu());
+        if (CodeType.NOT_PERMIT.equals(resultMap.getCode())) {
+            return resultMap;
+        }
+        ProductStoreStatus status = (ProductStoreStatus)resultMap.getData();
+        /**
+         * 目前 测试没有这个存储过程,暂时注释掉这个代码
+         */
+        //String result = productDao.upateResultByEnuuForB2C(SystemSession.getUser().getEnterprise().getUu());
+        String result = "0";
+        if (StringUtils.isEmpty(result)) {
+            map.put("size", 0);
+            map.put("redundance", 0);
         } else {
-            ProductStoreStatus stroestatus = new ProductStoreStatus();
-            stroestatus.setDate(new Date());
-            stroestatus.setEnuu(SystemSession.getUser().getEnterprise().getUu());
-            stroestatus.setUseruu(SystemSession.getUser().getUserUU());
-            stroestatus.setStatus(Status.RUNNING.value());
-            status = productStoreStatusDao.save(stroestatus);
-        }
-        Integer num = null;
-        if (flag) {
-            /**
-             * 目前 测试没有这个存储过程,暂时注释掉这个代码
-             */
-            //String result = productDao.upateResultByEnuuForB2C(SystemSession.getUser().getEnterprise().getUu());
-            String result = "0";
-            if (StringUtils.isEmpty(result)) {
-                map.put("size", 0);
-                map.put("redundance", 0);
-            } else {
-                String[] split = result.split("-");
-                map.put("size", Integer.valueOf(split[0]));
-//                map.put("redundance", Integer.valueOf(split[1]));
-            }
-            Integer fail = productDao.getCountByEnuuAndStatus(SystemSession.getUser().getEnterprise().getUu(), (short)0);
-            map.put("fail", fail);
-            status.setStatus(Status.FINISH.value());
-            productStoreStatusDao.save(status);
+            String[] split = result.split("-");
+            map.put("size", Integer.valueOf(split[0]));
         }
+        Integer fail = productDao.getCountByEnuuAndStatus(SystemSession.getUser().getEnterprise().getUu(), (short)0);
+        map.put("fail", fail);
+        status.setStatus(Status.FINISH.value());
+        productStoreStatusDao.save(status);
         return ResultMap.success(map);
     }
 
     private ResultMap validateProductStatus(Long enUU) {
         ProductStoreStatus status = productStoreStatusDao.findByEnuu(enUU);
+        Integer maxInterval = 600000;
         if (status != null) {
             // 有人正在操作这张单据,不能进行操作
             if (status.getStatus().equals(Status.RUNNING.value())) {
                 Date date = new Date();
                 long l = date.getTime() - status.getDate().getTime();
-                if (l > 600000) {
+                if (l > maxInterval) {
                     status.setStatus(Status.FINISH.value());
                 } else {
                     return new ResultMap(CodeType.NOT_PERMIT, "当前有人正在进行匹配操作,无法进行匹配");
@@ -904,12 +858,30 @@ public class ProductServiceImpl implements ProductService {
         ProductStoreStatus status = (ProductStoreStatus) statusResult.getData();
 
         int total = productDao.getCountByEnuuAndStatusAndEnabled(enUU, ShortConstant.NO_SHORT, IntegerConstant.YES_SHORT);
-        int success = 0;
-        int fail = 0;
+        int success;
+        int fail;
 
         String sql = "/*#mycat:db_type=master*/ call PRODUCT_MATCHES_V1(%s, %s, @out); select @out";
         final String formatSql = String.format(sql, enUU, uu);
-        success = jdbcTemplate.execute(new StatementCallback<Integer>() {
+        success = matchSuccess(formatSql);
+        fail = total - success;
+
+        status.setStatus(Status.FINISH.value());
+        productStoreStatusDao.save(status);
+        map.put("total", total);
+        map.put("fail", fail);
+        map.put("success", success);
+
+        return ResultMap.success(map);
+    }
+
+    /**
+     * 匹配成功数量
+     *
+     * @return 成功数量
+     */
+    private int matchSuccess(String formatSql) {
+        return jdbcTemplate.execute(new StatementCallback<Integer>() {
             @Override
             public Integer doInStatement(Statement statement) throws SQLException, DataAccessException {
                 statement.execute(formatSql);
@@ -921,15 +893,6 @@ public class ProductServiceImpl implements ProductService {
                 return 0;
             }
         });
-        fail = total - success;
-
-        status.setStatus(Status.FINISH.value());
-        productStoreStatusDao.save(status);
-        map.put("total", total);
-        map.put("fail", fail);
-        map.put("success", success);
-
-        return ResultMap.success(map);
     }
 
     @Override
@@ -949,23 +912,12 @@ public class ProductServiceImpl implements ProductService {
         String batch = createNumberService.getTimeNumber("product$match", 8);
         // 保存要匹配的id数据
         createMatchModel(idList, batch);
-        int success = 0;
-        int fail = 0;
+        int success;
+        int fail;
 
         String sql = "/*#mycat:db_type=master*/ call PRODUCT_MATCHES_SELECT_V1(%s, %s, %s, @out); select @out";
         final String formatSql = String.format(sql, batch, enUU, uu);
-        success = jdbcTemplate.execute(new StatementCallback<Integer>() {
-            @Override
-            public Integer doInStatement(Statement statement) throws SQLException, DataAccessException {
-                statement.execute(formatSql);
-                ResultSet rs = statement.getResultSet();
-                if (null != rs) {
-                    rs.next();
-                    return rs.getInt(1);
-                }
-                return 0;
-            }
-        });
+        success = matchSuccess(formatSql);
         fail = idList.size() - success;
 
         status.setStatus(Status.FINISH.value());
@@ -1194,7 +1146,7 @@ public class ProductServiceImpl implements ProductService {
     private List<List<Goods>> getRepeatGoodsList(Long oldId, Long productId) {
         List<Goods> oldList = goodsDao.findByProductId(oldId);
         List<List<Goods>> resultList = new ArrayList<>();
-        List<Goods> addList = null;
+        List<Goods> addList;
         for (Goods goods : oldList) {
             List<Goods> goodsList = goodsDao.findRepeatGoodsInProductId(productId, goods.getProduceDate(),
                     goods.getPackaging(), goods.getMinPackQty(), goods.getMinBuyQty(), goods.getMaxDelivery(),
@@ -1236,25 +1188,6 @@ public class ProductServiceImpl implements ProductService {
         }
     }
 
-    /**
-     * 更新GoodsHistory信息
-     */
-    private void updateGoodsHistoryInfo(Goods goods, List<GoodsHistory> history) {
-        for (GoodsHistory gh : history) {
-            gh.setCode(goods.getCode());
-            gh.setUuid(goods.getUuid());
-            gh.setKindNameCn(goods.getKindNameCn());
-            gh.setImg(goods.getImg());
-            gh.setBranduuid(goods.getBranduuid());
-            gh.setKindNameCn(goods.getKindNameCn());
-            gh.setKindUuid(goods.getKindUuid());
-            gh.setBrandNameCn(goods.getBrandNameCn());
-            gh.setBrandNameEn(goods.getBrandNameEn());
-            gh.setBranduuid(goods.getBranduuid());
-            gh.setBrandid(goods.getBrandid());
-        }
-    }
-
     /**
      *
      * @param goods
@@ -1291,7 +1224,7 @@ public class ProductServiceImpl implements ProductService {
      * @param json
      * @return
      */
-    @Transactional
+    @Transactional(rollbackFor = RuntimeException.class)
     @Override
     public ResultMap updateMatch(String json) {
         if(StringUtils.isEmpty(json)) {
@@ -1384,7 +1317,8 @@ public class ProductServiceImpl implements ProductService {
         ProductDetail productDetail = productDetailDao.findByProductId(id);
         if (productDetail != null) {
             Double b2cReserve = 0d;
-            if (product.getCmpUuId() != null) {// 获取当前商城已上架数量(含锁库存)
+            // 获取当前商城已上架数量(含锁库存)
+            if (product.getCmpUuId() != null) {
                 b2cReserve = goodsDao.getSumReserveByEnUUAndUuidAndStatus(SystemSession.getUser().getEnterprise().getUu(), product.getCmpUuId(), Status.AVAILABLE.value());
                 Double lockReserve = orderDetailDao.getSumReserveBySupEnUuAndUuidAndStatus(SystemSession.getUser().getEnterprise().getUu(), product.getCmpUuId(), Status.TOBEPAID.value());
                 b2cReserve = (b2cReserve == null ? 0d : b2cReserve) + (lockReserve == null ? 0d :lockReserve);
@@ -1430,22 +1364,28 @@ public class ProductServiceImpl implements ProductService {
     @Override
     public ResultMap validitonStandard(JSONObject jsonObject) {
         Component component = (Component)jsonObject.get("component");
-        if (component == null || component.getCode() == null)
+        if (component == null || component.getCode() == null) {
             throw new IllegalOperatorException("请填写器件原厂型号");
+        }
         Brand brand = (Brand)jsonObject.get("brand");
-        if (brand == null || brand.getNameEn() == null)
+        if (brand == null || brand.getNameEn() == null) {
             throw new IllegalOperatorException("请填写品牌英文名");
+        }
         List<Brand> brands = brandDao.findByNameEn(brand.getNameEn());
-        if (CollectionUtils.isEmpty(brands))
+        if (CollectionUtils.isEmpty(brands)) {
             throw new IllegalOperatorException(("商城不存在:" + brand.getNameEn() + " 品牌,请选择商城品牌或申请该品牌"));
+        }
         List<Component> componentMatched = componentDao.findByCodeAndBrandid(component.getCode(), brands.get(0).getId());
-        if (CollectionUtils.isEmpty(componentMatched)) {// 提交申请为非标准器件则转成器件申请
+        // 提交申请为非标准器件则转成器件申请
+        if (CollectionUtils.isEmpty(componentMatched)) {
             Kind kind = (Kind)jsonObject.get("kind");
-            if (kind == null || kind.getId() == null)
+            if (kind == null || kind.getId() == null) {
                 throw new IllegalOperatorException("请选择商城物料名称(类目)");
+            }
             String attach = jsonObject.getString("attach");
-            if (attach == null)
+            if (attach == null) {
                 throw new IllegalOperatorException("请上传规格书");
+            }
             ComponentSubmit submit = new ComponentSubmit();
             submit.setAttach(attach);
             submit.setBrandid(brands.get(0).getId());
@@ -1466,11 +1406,13 @@ public class ProductServiceImpl implements ProductService {
     @Override
     public ProductDetail saveDetail(Long productId, Goods goods) {
         Product product = productDao.findOne(productId);
-        if (product == null)
+        if (product == null) {
             throw new IllegalOperatorException("此物料信息不存在,请重新确认");
+        }
         ProductDetail productDetail = productDetailDao.findByProductId(productId);
-        if (productDetail == null)
+        if (productDetail == null) {
             productDetail = new ProductDetail();
+        }
 
         productDetail.setBreakUp(goods.getBreakUp());
         productDetail.setProduceDate(goods.getProduceDate());
@@ -1484,8 +1426,9 @@ public class ProductServiceImpl implements ProductService {
         productDetail.setMinPackQty(goods.getMinPackQty());
         productDetail.setPackaging(goods.getPackaging());
 
-        if (enterpriseService.getCurrencyByRegisterAddress().getData() == null)
+        if (enterpriseService.getCurrencyByRegisterAddress().getData() == null) {
             throw new IllegalOperatorException("注册地址为空,无法确认币别信息,请前往-优软云补充注册地址信息");
+        }
         String currency = enterpriseService.getCurrencyByRegisterAddress().getData().toString();
         List<GoodsQtyPrice> qtyPrice = FastjsonUtils.fromJsonArray(goods.getQtyPrice(), GoodsQtyPrice.class);
         if (!CollectionUtils.isEmpty(qtyPrice)) {
@@ -1560,7 +1503,7 @@ public class ProductServiceImpl implements ProductService {
         }
         Long uu = SystemSession.getUser().getEnterprise().getUu();
         ResultMap registerAddress = enterpriseService.getCurrencyByRegisterAddress();
-        String currency = null;
+        String currency;
         Set<String> uuids = new HashSet<>();
         if (registerAddress.getCode() != CodeType.OK.code()) {
             currency = StringConstant.RMB;
@@ -1568,7 +1511,7 @@ public class ProductServiceImpl implements ProductService {
             currency = registerAddress.getData().toString();
         }
         StoreIn storeIn = storeInService.findByEnUU(uu);
-        String storeName = null, storeid = null;
+        String storeName, storeid;
         if (storeIn == null || storeIn.getStatus() != StoreStatus.OPENED) {
             storeName = sysConf.getEnName();
             storeid = sysConf.getStoreid();
@@ -1580,7 +1523,7 @@ public class ProductServiceImpl implements ProductService {
         if (property == null) {
             return new ResultMap(CodeType.NOT_COMPLETE_INFO.code(), "请先设置上架参数", null);
         }
-        String sql = null;
+        String sql;
         Map<String, Object> map = new HashMap<>();
         if ((prIdLong != null) && (prIdLong.size() != 0)) {
             sql = "select p.pr_id from products p left join product$private pp on pp.pr_id = p.pr_id where p.pr_sourceapp = 'ERP' and p.pr_reserve <> 0 and ifnull(pp.pr_b2cenabled, 0) = 1 and p.pr_id in (:ids);";
@@ -1743,52 +1686,15 @@ public class ProductServiceImpl implements ProductService {
      */
     @Override
     public Double getGoodsReserveByErpReserve(Double erpReserve, List<Goods> goodses1) {
-        List<String> batches = new ArrayList<>();
         // 目前只统计goods 在售的库存,下架和保存状态的不做调整
         for (Goods goods : goodses1) {
             if (goods.getStatus().intValue() == Status.UNAVAILABLE.value() || goods.getStatus().intValue() == Status.AVAILABLE.value()) {
                 erpReserve = NumberUtil.sub(erpReserve, goods.getReserve());
             }
-            //batches.add(goods.getBatchCode());
         }
-        //Double qty = getQtyInOrderToBeUpload(batches);
-        // erpReserve = NumberUtil.sub(erpReserve, qty);
         return erpReserve;
     }
 
-    /**
-     * 获取订单中还未上传到UAS的数量
-     *
-     * @param batches 批次信息
-     * @return
-     */
-    @Override
-    public Double getQtyInOrderToBeUpload(List<String> batches) {
-        if (CollectionUtils.isEmpty(batches)) {
-            return DoubleConstant.zero;
-        } else {
-            List<Integer> statuses = new ArrayList<>();
-            statuses.add(Status.TOBEPAID.value());
-            statuses.add(Status.TOBEPAIDAGAGIN.value());
-            statuses.add(Status.CANCELTOBECONFIRMED.value());
-            Double orderDetailQty = orderDetailDao.getgetSumQtyByBatchcodesAndStatus(batches, statuses);
-
-            List<Integer> puStatus = new ArrayList<>();
-            puStatus.add(Status.CONFIRMED.value());
-            puStatus.add(Status.PAID.value());
-            //获取平台还未上传的销售单
-            String sql = "select sum(detail_number) from trade$purchase p left join trade$purchase_detail pd on p.id = pd.purchase_id where p.pu_sendstatus = 202 and pd.go_batch in (:batches) and pd.detail_status in (:status);";
-            HashMap<String, Object> map = new HashMap<>();
-            map.put("batches", batches);
-            map.put("status", puStatus);
-            Double purchaseDetailQty = namedParameterJdbcTemplate.queryForObject(sql, map, Double.class);
-            double qty = NumberUtil.add(orderDetailQty, purchaseDetailQty);
-            return qty;
-        }
-
-    }
-
-
     /**
      * 修改非标物料的品牌、物料名称、型号、规格、规格书等信息
      *
@@ -1796,7 +1702,7 @@ public class ProductServiceImpl implements ProductService {
      * @param attachUrl 规格书的地址
      * @return the string
      */
-    @Transactional
+    @Transactional(rollbackFor = RuntimeException.class)
     @Override
     public ResultMap updateProduct(String json, String attachUrl) {
         if (StringUtils.isEmpty(json)) {
@@ -1826,7 +1732,7 @@ public class ProductServiceImpl implements ProductService {
                 } else {
                     persistProduct.setSpec((String) specResultMap.getData());
                 }
-                if (productPrivate.getStandard() == IntegerConstant.NO_SHORT || StringUtils.isEmpty(productPrivate.getCmpUuId())) {
+                if (Objects.equals(productPrivate.getStandard(), IntegerConstant.NO_SHORT) || StringUtils.isEmpty(productPrivate.getCmpUuId())) {
                     Component component = findBybrNameAndcmpCode(productPrivate.getPbranden(), productPrivate.getPcmpcode());
                     if (component != null) {
                         //更新物料信息
@@ -2080,7 +1986,7 @@ public class ProductServiceImpl implements ProductService {
                         }
                         if (CollectionUtils.isNotEmpty(ids)) {
                             List<ProductPrivate> productPrivates = productPrivateDao.findByPrIds(ids);
-                            boolean isExist = false;
+                            boolean isExist;
                             List<ProductPrivate> productPrivatelist = new ArrayList<>();
                             for (Long id : ids) {
                                 isExist = false;
@@ -2113,8 +2019,6 @@ public class ProductServiceImpl implements ProductService {
                 } catch (InterruptedException e) {
                     e.printStackTrace();
                 }
-
-
                 return ResultMap.success("");
             } else {
                 return ResultMap.success("");
@@ -2134,11 +2038,11 @@ public class ProductServiceImpl implements ProductService {
         SPage<Long> ids = searchService.getProducts(null, keyword, params.getPage(), params.getCount(), null);
         PageInfo info = new PageInfo(params);
         if (null == ids) {
-            return new PageImpl<V_ProductPrivate>(Collections.emptyList(), info, 0);
+            return new PageImpl<>(Collections.emptyList(), info, 0);
         }
         List<Long> idList = ids.getContent();
         List<V_ProductPrivate> productList = v_productPrivateDao.findAll(idList);
-        return new PageImpl<V_ProductPrivate>(productList, info, ids.getTotalElement());
+        return new PageImpl<>(productList, info, ids.getTotalElement());
     }
 
     /**
@@ -2200,26 +2104,6 @@ public class ProductServiceImpl implements ProductService {
         }
     }
 
-
-    /**
-     * 根据物料编号找物料
-     *
-     * @param prodNum
-     * @return
-     */
-    @Override
-    public Product findProductByProdNum(String prodNum) {
-        if (StringUtils.isEmpty(prodNum)) {
-            return null;
-        } else {
-            List<Product> products = productDao.findByProdNum(prodNum);
-            if (CollectionUtils.isEmpty(products)) {
-                return null;
-            }
-            return products.get(0);
-        }
-    }
-
     /**
      * 批量保存,通过jdbctemplate
      *
@@ -2309,7 +2193,7 @@ public class ProductServiceImpl implements ProductService {
         }
         List<Product> products = productDao.findAll(prIds);
         List<Product> freshProducts = new ArrayList<>();
-        InOutboundDetail detail = null;
+        InOutboundDetail detail;
         for (Product product : products) {
             for (ReleaseProductByBatch productByBatch : reList) {
                 if (!productByBatch.getReleaseCode().equals(ReleaseStatus.failure.value()) &&
@@ -2331,7 +2215,7 @@ public class ProductServiceImpl implements ProductService {
                     if (StringUtils.isEmpty(product.getSpec()) || (ignoreImport == IntegerConstant.NO_SHORT)) {
                         product.setSpec(productByBatch.getSpec());
                     }
-                    if ((ignoreImport == IntegerConstant.NO_SHORT) || (NumberUtil.compare(product.getErpReserve(), productByBatch.getReserve()) != 0)) {
+                    if ((Objects.equals(ignoreImport, IntegerConstant.NO_SHORT)) || (NumberUtil.compare(product.getErpReserve(), productByBatch.getReserve()) != 0)) {
                         Double qty = NumberUtil.sub(productByBatch.getReserve(), product.getErpReserve());
                         if (NumberUtil.compare(qty, DoubleConstant.zero) != 0) {
                             //做出入库记录
@@ -2486,4 +2370,218 @@ public class ProductServiceImpl implements ProductService {
         }
         return null;
     }
+
+    /**
+     * 卖家中心添加单个物料录入
+     *
+     * @param jsonObject 前端数据封装
+     * @return ResultMap
+     */
+    @Override
+    public ResultMap editOne(JSONObject jsonObject) {
+        // 物料信息
+        Product product = (Product)jsonObject.get("product");
+        if (null == product) {
+            return ResultMap.error(new IllegalOperatorException("物料信息不能为空"));
+        }
+        // 库存信息
+        Goods goods = (Goods)jsonObject.get("goods");
+        if (null == goods) {
+            return ResultMap.error(new IllegalOperatorException("库存信息不能为空"));
+        }
+        // PCB
+        Integer isPcb = (Integer)jsonObject.get("isPcb");
+        Long enUU = SystemSession.getUser().getEnterprise().getUu();
+        Long userUU = SystemSession.getUser().getUserUU();
+        product.setPbrand(product.getBrand());
+        product.setPbranden(product.getBrand());
+        product.setPcmpcode(product.getCmpCode());
+        List<Product> existProducts = productDao.findProductByPcmpcodeAndPbrandenAndEnUU(product.getCmpCode(), product.getBrand(), enUU);
+        // PCB产品做标准判断处理
+        if (null != isPcb && Objects.equals(IntegerConstant.YES_SHORT, isPcb)) {
+            // 判断传入的数据是否是标准的
+            ResultMap resultMap = checkCriterion(product);
+            if (!Objects.equals(CodeType.OK.code(), resultMap.getCode())) {
+                return resultMap;
+            }
+        }
+        Product productInfo;
+        CommodityInOutbound inOutbound = null;
+        // 物料存在,更新
+        if (CollectionUtils.isNotEmpty(existProducts)) {
+            productInfo = existProducts.get(0);
+            // 用户填写库存量是需要做对应的出入库。如果新填写的库存数大于原库存数,做入库。否则做出库。
+            inOutbound = recordInventory(product, existProducts.get(0));
+            BeanUtils.copyProperties(product, productInfo, Product.class);
+        } else {
+            // 物料不存在,新增操作
+            productInfo = product;
+        }
+        // 最小包装数默认为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);
+        // 设置库存信息
+        assignmentGoods(goods, productInfo);
+        productInfo = productDao.save(productInfo);
+        // 保存出入库信息
+        if (null != inOutbound) {
+            inOutbound = commodityInOutboundDao.save(inOutbound);
+            LOGGER.log("出入库历史", "卖家中心单个物料上传进行入库操作", inOutbound.getType(), "", inOutbound.getId());
+        }
+        // 添加到个人物料库
+        bindToPerson(productInfo, userUU, enUU);
+        return ResultMap.success();
+    }
+
+    /**
+     * 记录出入库信息
+     * 如果新填写的库存数大于原库存数,做入库。否则做出库。
+     *
+     * @param product 前台传入的物料数据
+     * @param existProduct 数据库存在的物料信息
+     */
+    private CommodityInOutbound recordInventory(Product product, Product existProduct) {
+        // 入库
+        String type;
+        CommodityInOutbound inOutbound;
+        if (product.getErpReserve() > existProduct.getErpReserve()) {
+            type = InOutBoundType.OTHER_INBOUND;
+            inOutbound = new CommodityInOutbound(type);
+            goodsInventory(product.getErpReserve(), type, existProduct.getId());
+        } else {
+            // 出库
+            type = InOutBoundType.OTHER_OUTBOUND;
+            inOutbound = new CommodityInOutbound(InOutBoundType.OTHER_OUTBOUND);
+            goodsInventory(product.getErpReserve(), type, existProduct.getId());
+        }
+        InOutboundDetail inOutboundDetail = new InOutboundDetail(product);
+        Set<InOutboundDetail> detailSet = new HashSet<>();
+        detailSet.add(inOutboundDetail);
+        inOutbound.setInOutboundDetails(detailSet);
+        return inOutbound;
+    }
+
+    /**
+     * 设置库存出入库
+     * GOODS有对应的productId,根据出库时从goods的id最小的开始减,减了之后可能需要修改状态。
+     * 入库时,将新加的库存数加到id值最大的Goods中。
+     *
+     * @param erpReserve 本次传入的库存
+     * @param type 出入库类型
+     * @param productId  物料id
+     */
+    private void goodsInventory(Double erpReserve, String type, Long productId) {
+        // 按goodsId倒序
+        List<Goods> goodsList = goodsDao.findByProductId(productId);
+        if (CollectionUtils.isNotEmpty(goodsList)) {
+            // 入库
+            if (InOutBoundType.OTHER_INBOUND.equals(type)) {
+                final Double[] existReserve = {0D};
+                goodsList.forEach(goods -> existReserve[0] += goods.getReserve() != null ? goods.getReserve() : 0D);
+                Double addQty = erpReserve - existReserve[0];
+                Goods goods = goodsList.get(0);
+                Double reserve = goods.getReserve() != null ? goods.getReserve() : 0D + addQty;
+                goods.setReserve(reserve);
+                goodsDao.save(goods);
+                LOGGER.log("上架商品库存操作", "卖家中心单个物料上传进行入库操作", "增加库存: " + addQty, goods.getCode(), goods.getId());
+            } else if (InOutBoundType.OTHER_OUTBOUND.equals(type)) {
+                // 出库
+                int index = goodsList.size() - 1;
+                Double subQty = 0D;
+                for (int i = index; i >= 0; i --) {
+                    Double existQty = goodsList.get(i).getReserve() == null ? 0D : goodsList.get(i).getReserve();
+                    if (i == index) {
+                        subQty = erpReserve - existQty;
+                    } else {
+                        subQty -= subQty - existQty;
+                    }
+                    // 如果当前库存减去已存在的库存大于0,继续减去后面的库存数据
+                    Goods goods = goodsList.get(i);
+                    if (subQty >= 0) {
+                        goods.setReserve(0D);
+                        goods = goodsDao.save(goods);
+                    } else {
+                        goods.setReserve(Math.abs(subQty));
+                        goods = goodsDao.save(goods);
+                    }
+                    LOGGER.log("上架商品库存操作", "卖家中心单个物料上传进行出库操作", existQty + "->" + goods.getReserve(), goods.getCode(), goods.getId());
+                }
+            }
+        }
+    }
+
+
+    /**
+     * 判断是否标准物料
+     *
+     * @param product 物料信息
+     * @return ResultMap
+     */
+    @Override
+    public ResultMap checkCriterion(Product product) {
+        List<Brand> brands = brandDao.findByName(product.getBrand());
+        // 先判断标准品牌信息
+        if (CollectionUtils.isEmpty(brands)) {
+           return ResultMap.error(new NotFoundException("品牌为非标准品牌"));
+        }
+        // 判断标准器件信息
+        List<Component> components = componentDao.findByBrandidAndCode(brands.get(0).getId(), product.getCmpCode());
+        if (CollectionUtils.isEmpty(components)) {
+            return ResultMap.error(new NotFoundException("器件为非标准器件"));
+        }
+        return ResultMap.success();
+    }
+
+    /**
+     * 绑定到个人物料库
+     *
+     * @param productInfo 物料信息
+     * @param userUU 用户UU
+     * @param enUU 企业UU
+     */
+    private void bindToPerson(Product productInfo, Long userUU, Long enUU) {
+        List<ProductPerson> productPersonList = productPersonDao.findByProductIdAndUserUU(productInfo.getId(), userUU);
+        if (CollectionUtils.isEmpty(productPersonList)) {
+            ProductPerson productPerson = new ProductPerson(userUU, enUU, productInfo.getId());
+            productPerson = productPersonDao.save(productPerson);
+            LOGGER.log("个人物料", "新增个人物料", "通过卖家中心单个物料上传绑定个人物料", productPerson.getProduct().getProdNum(), productPerson.getId());
+        }
+    }
+
+    /**
+     * 设置库存信息
+     *
+     * @param goods 库存
+     * @param productInfo 物料信息
+     */
+    private void assignmentGoods(Goods goods, Product productInfo) {
+        goods = Goods.productConvertGoods(goods, productInfo);
+        goodsService.setGoodsDefault(goods);
+        boolean autoPublish = goods.getAutoPublish() == null ? true : goods.getAutoPublish();
+        goods.setAutoPublish(autoPublish);
+        final Double minBuyQty = goods.getMinBuyQty();
+        if (CollectionUtils.isNotEmpty(goods.getPrices())) {
+            goods.getPrices().forEach(subPrice -> {
+                // 分段数量不能超过最大数量
+                Double endQty = NumberUtil.compare(subPrice.getEnd(), DoubleConstant.maxReserve) == 1 ? DoubleConstant.maxReserve : subPrice.getEnd();
+                subPrice.setEnd(endQty);
+
+                // 起始数量不能大于最小订购数
+                Double startQty = NumberUtil.compare(minBuyQty, subPrice.getStart()) == 1 ? subPrice.getStart() : minBuyQty;
+                subPrice.setStart(startQty);
+            });
+        }
+        goods.setQtyPrice(JSON.toJSONString(goods.getPrices()));
+        StoreIn storeIn = storeInService.findByEnUU(SystemSession.getUser().getEnterprise().getUu());
+        if (storeIn != null && storeIn.getStatus() == StoreStatus.OPENED) {
+            goods.setStoreid(storeIn.getUuid());
+            goods.setStoreName(storeIn.getStoreName());
+        }
+        goods = goodsDao.save(goods);
+        LOGGER.log("上架商品", "新增上架商品", "通过卖家中心单个物料上传新增上架商品", goods.getCode(), goods.getId());
+    }
 }

+ 5 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/type/ProductConstant.java

@@ -16,4 +16,9 @@ public class ProductConstant {
      * 非标的标志
      */
     public final static String NSTANDARD = "nStandard";
+
+    /**
+     * 全部
+     */
+    public final static String ALL = "all";
 }

+ 30 - 0
src/main/java/com/uas/platform/b2c/prod/store/controller/StoreApplyController.java

@@ -2,8 +2,10 @@ package com.uas.platform.b2c.prod.store.controller;
 
 import com.uas.platform.b2c.common.account.model.User;
 import com.uas.platform.b2c.core.support.SystemSession;
+import com.uas.platform.b2c.core.support.view.JxlsExcelView;
 import com.uas.platform.b2c.prod.store.facade.StoreApplyFacade;
 import com.uas.platform.b2c.prod.store.model.StoreApply;
+import com.uas.platform.b2c.prod.store.model.StoreInfoAndProdExport;
 import com.uas.platform.b2c.prod.store.model.StoreType;
 import com.uas.platform.b2c.prod.store.service.StoreApplyService;
 import com.uas.platform.b2c.trade.support.ResultMap;
@@ -13,12 +15,17 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.web.PageableDefault;
+import org.springframework.format.annotation.DateTimeFormat;
 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;
 import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.servlet.ModelAndView;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -187,4 +194,27 @@ public class StoreApplyController {
 	public ResultMap findShopOwnerApplyByNormalStatus() {
 		return storeApplyService.findShopOwnerApplyByNormalStatus();
 	}
+
+	/**
+	 * 获取店铺信息
+	 */
+	@RequestMapping(value = "/storeinfo", method = RequestMethod.GET)
+	public com.uas.sso.support.Page<StoreInfoAndProdExport> getStoreInfoAndProdCount(@PageableDefault(value = 20, page = 1) Pageable pageable,
+					@DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime, @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime) {
+		return storeApplyService.getStoreInfoAndProdCount(pageable, startTime ,endTime);
+	}
+
+	/**
+	 * 获取店铺信息
+	 */
+	@RequestMapping(value = "/export", method = RequestMethod.GET)
+	public ModelAndView storeInfoAndProdCountExport(@DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime, @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime) {
+		ModelAndView modelAndView = new ModelAndView();
+		modelAndView.addObject("startTime", startTime);
+		modelAndView.addObject("endTime", endTime);
+		List<StoreInfoAndProdExport> exports = storeApplyService.storeInfoAndProdCountExport(startTime, endTime);
+		modelAndView.addObject("data", exports);
+		modelAndView.setView(new JxlsExcelView("classpath:jxls-tpl/product/storeInfo", "上传产品详情"));
+		return modelAndView;
+	}
 }

+ 84 - 0
src/main/java/com/uas/platform/b2c/prod/store/model/StoreInfoAndProdExport.java

@@ -0,0 +1,84 @@
+package com.uas.platform.b2c.prod.store.model;
+
+
+import java.util.Date;
+
+/**
+ * @Author: huj
+ * @Date: Created in 17:18 2018/10/8.
+ */
+public class StoreInfoAndProdExport {
+
+    /**
+     * 申请时间
+     */
+    private Date applyTime;
+    /**
+     * 店铺名称
+     */
+    private String storeName;
+    /**
+     * 企业uu
+     */
+    private Long enuu;
+    /**
+     * 审核时间
+     */
+    private Date agreeTime;
+    /**
+     * 审核人
+     */
+    private String agreeName;
+    /**
+     * 上传产品数
+     */
+    private String count;
+
+    public String getStoreName() {
+        return storeName;
+    }
+
+    public void setStoreName(String storeName) {
+        this.storeName = storeName;
+    }
+
+    public Long getEnuu() {
+        return enuu;
+    }
+
+    public void setEnuu(Long enuu) {
+        this.enuu = enuu;
+    }
+
+    public Date getApplyTime() {
+        return applyTime;
+    }
+
+    public void setApplyTime(Date applyTime) {
+        this.applyTime = applyTime;
+    }
+
+    public Date getAgreeTime() {
+        return agreeTime;
+    }
+
+    public void setAgreeTime(Date agreeTime) {
+        this.agreeTime = agreeTime;
+    }
+
+    public String getAgreeName() {
+        return agreeName;
+    }
+
+    public void setAgreeName(String agreeName) {
+        this.agreeName = agreeName;
+    }
+
+    public String getCount() {
+        return count;
+    }
+
+    public void setCount(String count) {
+        this.count = count;
+    }
+}

+ 12 - 0
src/main/java/com/uas/platform/b2c/prod/store/service/StoreApplyService.java

@@ -2,11 +2,14 @@ package com.uas.platform.b2c.prod.store.service;
 
 
 import com.uas.platform.b2c.prod.store.model.StoreApply;
+import com.uas.platform.b2c.prod.store.model.StoreInfoAndProdExport;
 import com.uas.platform.b2c.prod.store.model.StoreType;
 import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.core.model.PageInfo;
 import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -80,4 +83,13 @@ public interface StoreApplyService {
 	 * 获取当前店铺的待处理和已通过申请信息,应当有且只有一条记录
 	 */
 	ResultMap findShopOwnerApplyByNormalStatus();
+
+	/**
+	 * 导出店铺信息
+	 * @param pageable
+	 * @return
+	 */
+	com.uas.sso.support.Page<StoreInfoAndProdExport> getStoreInfoAndProdCount(Pageable pageable, Date startTime, Date endTime);
+
+	List<StoreInfoAndProdExport> storeInfoAndProdCountExport(Date startTime, Date endTime);
 }

+ 55 - 8
src/main/java/com/uas/platform/b2c/prod/store/service/impl/StoreApplyServiceImpl.java

@@ -3,17 +3,12 @@ package com.uas.platform.b2c.prod.store.service.impl;
 import com.uas.platform.b2c.common.account.dao.EnterpriseDao;
 import com.uas.platform.b2c.common.account.model.Enterprise;
 import com.uas.platform.b2c.common.account.model.User;
+import com.uas.platform.b2c.common.base.dao.CommonDao;
 import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.core.utils.UuidUtils;
 import com.uas.platform.b2c.prod.store.dao.StoreApplyDao;
 import com.uas.platform.b2c.prod.store.dao.StoreBrandInfoDao;
-import com.uas.platform.b2c.prod.store.model.EnterpriseSimple;
-import com.uas.platform.b2c.prod.store.model.Qualification;
-import com.uas.platform.b2c.prod.store.model.QualificationType;
-import com.uas.platform.b2c.prod.store.model.StoreApply;
-import com.uas.platform.b2c.prod.store.model.StoreBrandInfo;
-import com.uas.platform.b2c.prod.store.model.StoreIn;
-import com.uas.platform.b2c.prod.store.model.StoreType;
+import com.uas.platform.b2c.prod.store.model.*;
 import com.uas.platform.b2c.prod.store.service.StoreApplyService;
 import com.uas.platform.b2c.prod.store.service.StoreInService;
 import com.uas.platform.b2c.trade.support.CodeType;
@@ -23,7 +18,10 @@ import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.persistence.criteria.CriterionExpression;
 import com.uas.platform.core.persistence.criteria.SimpleExpression;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.convert.converter.Converter;
 import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -55,12 +53,16 @@ public class StoreApplyServiceImpl implements StoreApplyService {
 
 	private final StoreBrandInfoDao brandInfoDao;
 
+	private final CommonDao commonDao;
+
 	@Autowired
-	public StoreApplyServiceImpl(StoreApplyDao storeApplyDao, EnterpriseDao enterpriseDao, StoreInService storeInService, StoreBrandInfoDao brandInfoDao) {
+	public StoreApplyServiceImpl(StoreApplyDao storeApplyDao, EnterpriseDao enterpriseDao, StoreInService storeInService,
+								 StoreBrandInfoDao brandInfoDao, CommonDao commonDao) {
 		this.storeApplyDao = storeApplyDao;
 		this.enterpriseDao = enterpriseDao;
 		this.storeInService = storeInService;
 		this.brandInfoDao = brandInfoDao;
+		this.commonDao = commonDao;
 	}
 
 	@Override
@@ -305,4 +307,49 @@ public class StoreApplyServiceImpl implements StoreApplyService {
 			return new ResultMap(CodeType.ERROR_STATE, "数据操作异常");
 		}
 	}
+
+	@Override
+	public com.uas.sso.support.Page<StoreInfoAndProdExport> getStoreInfoAndProdCount(Pageable pageable, Date startTime, Date endTime) {
+		if (pageable == null) {
+			return null;
+		}
+		StringBuilder sql = new StringBuilder("select a.apply_create_time applyTime, a.apply_store_name storeName, "
+				+ "a.apply_store_enuu enuu,a.apply_auth_time agreeTime, a.apply_auth_person_name agreeName, " +
+				"ifnull(p.count, 0) count from `store$apply` a left join (select pr_enuu, count(1) count from products" +
+				" group by pr_enuu) p on p.pr_enuu = a.apply_store_enuu where a.apply_status='PASS' ");
+		if (!StringUtils.isEmpty(startTime)) {
+			sql.append(" and date(a.apply_create_time) >= '" + new java.sql.Date(startTime.getTime()) + "'");
+		}
+		if (!StringUtils.isEmpty(endTime)) {
+			sql.append(" and date(a.apply_create_time) <= '" + new java.sql.Date(endTime.getTime()) + "' ");
+		}
+		sql.append(" order by a.apply_create_time limit " + pageable.getPageNumber() * pageable.getPageSize() + ","
+				+ pageable.getPageSize());
+		StringBuilder totalSql = new StringBuilder("select count(1) from `store$apply` a where a.apply_status='PASS' ");
+		if (!StringUtils.isEmpty(startTime)) {
+			totalSql.append(" and date(a.apply_create_time) >= '" + new java.sql.Date(startTime.getTime()) + "'");
+		}
+		if (!StringUtils.isEmpty(endTime)) {
+			totalSql.append(" and date(a.apply_create_time) <= '" + new java.sql.Date(endTime.getTime()) + "' ");
+		}
+		Integer total = commonDao.queryForObject(totalSql.toString(), Integer.class);
+		List<StoreInfoAndProdExport> exports = commonDao.query(sql.toString(), StoreInfoAndProdExport.class);
+		return new com.uas.sso.support.Page<>(pageable.getPageNumber(), pageable.getPageSize(), exports, total);
+	}
+
+	@Override
+	public List<StoreInfoAndProdExport> storeInfoAndProdCountExport(Date startTime, Date endTime) {
+		StringBuilder sql = new StringBuilder("select a.apply_create_time applyTime, a.apply_store_name storeName, "
+				+ "a.apply_store_enuu enuu,a.apply_auth_time agreeTime, a.apply_auth_person_name agreeName, " +
+				"ifnull(p.count, 0) count from `store$apply` a left join (select pr_enuu, count(1) count from products" +
+				" group by pr_enuu) p on p.pr_enuu = a.apply_store_enuu where a.apply_status='PASS' ");
+		if (!StringUtils.isEmpty(startTime)) {
+			sql.append(" and date(a.apply_create_time) >= '" + new java.sql.Date(startTime.getTime()) + "'");
+		}
+		if (!StringUtils.isEmpty(endTime)) {
+			sql.append(" and date(a.apply_create_time) <= '" + new java.sql.Date(endTime.getTime()) + "' ");
+		}
+		sql.append(" order by a.apply_create_time");
+		return commonDao.query(sql.toString(), StoreInfoAndProdExport.class);
+	}
 }

BIN
src/main/resources/jxls-tpl/product/storeInfo.xls