Browse Source

【ERP接口】-- 调整erp空闲库存初始化、更新接口

wangyc 8 years ago
parent
commit
da5ce3d54d

+ 16 - 12
src/main/java/com/uas/platform/b2c/external/erp/commodity/service/impl/ProductDetailERPServiceImpl.java

@@ -57,12 +57,16 @@ public class ProductDetailERPServiceImpl implements ProductDetailERPService {
     @Override
     public boolean uploadProductDetailERP(List<ProductDetailERP> productDetailERPList) {
         List<ProductDetail> productDetails = new ArrayList<ProductDetail>();
+        List<Product> productList = new ArrayList<Product>();
         Long enuu = SystemSession.getUser().getEnterprise().getUu();
         for (ProductDetailERP productDetailERP : productDetailERPList) {
             ProductDetail productDetail = ModelConverter.convert(productDetailERP);
 
             List<Product> products = productDao.getProductByEnUUAndProdNum(enuu, productDetail.getCode());
             if (!CollectionUtils.isEmpty(products)) {
+                products.get(0).setErpReserve(productDetailERP.getReserve());
+                productList.add(products.get(0));
+
                 productDetail.setProductId(products.get(0).getId());
             }
             // 如果已存在物料交易信息删除之前那一条,保存新的物料交易信息
@@ -72,6 +76,8 @@ public class ProductDetailERPServiceImpl implements ProductDetailERPService {
             }
             productDetails.add(productDetail);
         }
+
+        productDao.save(productList);
         productDetailDao.save(productDetails);
         logger.log("物料交易详情", "初始化交易详情,企业:" + SystemSession.getUser().getEnterprise().getEnName() + ",数量:" + productDetails.size());
         return true;
@@ -85,16 +91,16 @@ public class ProductDetailERPServiceImpl implements ProductDetailERPService {
 
     @Override
     public void updateReserve(List<ProductDetailERP> productDetailERPList) {
-        List<ProductDetail> productDetails = new ArrayList<ProductDetail>();
+        List<Product> productList = new ArrayList<Product>();
         Long enuu = SystemSession.getUser().getEnterprise().getUu();
         for (ProductDetailERP productDetailERP : productDetailERPList) {
             List<Product> products = productDao.getProductByEnUUAndProdNum(enuu, productDetailERP.getCode());// 获取对应商城物料信息
             if (!CollectionUtils.isEmpty(products)) {
-                ProductDetail productDetail = productDetailDao.findByProductId(products.get(0).getId());// 获取商城物料信息
-                if (productDetail == null) {// 如果物料交易详情为空,新增物料交易详情
-                    productDetail = new ProductDetail();
-                    productDetail.setProductId(products.get(0).getId());
-                }
+//                ProductDetail productDetail = productDetailDao.findByProductId(products.get(0).getId());// 获取商城物料信息
+//                if (productDetail == null) {// 如果物料交易详情为空,新增物料交易详情
+//                    productDetail = new ProductDetail();
+//                    productDetail.setProductId(products.get(0).getId());
+//                }
 
                 if (products.get(0).getCmpUuId() != null) {// 如果为标准器件,更新在售商品信息
                     Double b2cReserve = goodsDao.getSumReserveByEnUUAndUuidAndStatus(enuu, products.get(0).getCmpUuId(), Status.AVAILABLE.value());
@@ -131,13 +137,11 @@ public class ProductDetailERPServiceImpl implements ProductDetailERPService {
                     }
                 }
 
-                if (productDetail != null) {
-                    productDetail.setReserve(productDetailERP.getReserve());
-                    productDetails.add(productDetail);
-                }
+                products.get(0).setErpReserve(productDetailERP.getReserve());
+                productList.add(products.get(0));
             }
         }
-        logger.log("物料详情", "更新物料库存信息,企业:" + SystemSession.getUser().getEnterprise().getEnName() + ",数量:" + productDetails.size());
-        productDetailDao.save(productDetails);
+        logger.log("物料详情", "更新物料库存信息,企业:" + SystemSession.getUser().getEnterprise().getEnName() + ",数量:" + productList.size());
+        productDao.save(productList);
     }
 }

+ 2 - 1
src/main/java/com/uas/platform/b2c/external/erp/commodity/util/ModelConverter.java

@@ -197,7 +197,8 @@ public class ModelConverter {
 		productDetail.setPackaging(productDetailERP.getPackaging());
 		productDetail.setPrice(productDetailERP.getPrice());
 		productDetail.setProduceDate(productDetailERP.getProduceDate());
-		productDetail.setReserve(productDetailERP.getReserve());
+		// 暂时将ERP空闲库存放置在product中
+//		productDetail.setReserve(productDetailERP.getReserve());
 		productDetail.setCode(productDetailERP.getCode());
 		productDetail.setBreakUp(productDetailERP.getBreakUp());
 		return productDetail;

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

@@ -570,9 +570,9 @@ public class GoodsServiceImpl implements GoodsService {
 		ProductDetail productDetail = productDetailDao.findByProductId(product.getId());
 		if (productDetail == null) {
 			productDetail = new ProductDetail();
-		} else if (productDetail.getReserve() != null) {
+		} else if (product.getErpReserve() != null) {
 			ProductDetail newProductDetail = productService.findByProductId(product.getId());
-			if (productDetail.getReserve() < goods.getReserve() + newProductDetail.getB2cReserve()) {
+			if (product.getErpReserve() < goods.getReserve() + newProductDetail.getB2cReserve()) {
 				throw new IllegalOperatorException("本次上架数量和已上架数量之和不可超过ERP空闲库存数量");
 			}
 		}

+ 8 - 1
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_materialCtrl.js

@@ -1,6 +1,6 @@
 define([ 'app/app', 'jquery-uploadify' ], function(app) {
 	'use strict';
-	app.register.controller('vendor_materialCtrl', ['$scope', '$rootScope', 'Material', 'toaster', 'ComponentActive', 'Enterprise', '$q', 'NumberService', '$location', '$stateParams', 'Search', '$modal', 'ComponentActiveAPI', 'BrandSubmit', 'BrandActiveAPI', function ($scope, $rootScope, Material, toaster, ComponentActive, Enterprise, $q, NumberService, $location, $stateParams, Search, $modal, ComponentActiveAPI, BrandSubmit, BrandActiveAPI) {
+	app.register.controller('vendor_materialCtrl', ['$scope', '$rootScope', 'Material', 'toaster', 'ComponentActive', 'Enterprise', '$q', 'NumberService', '$location', '$stateParams', 'Search', '$modal', 'ComponentActiveAPI', 'BrandSubmit', 'BrandActiveAPI', 'DistributionRule', function ($scope, $rootScope, Material, toaster, ComponentActive, Enterprise, $q, NumberService, $location, $stateParams, Search, $modal, ComponentActiveAPI, BrandSubmit, BrandActiveAPI, DistributionRule) {
 		$rootScope.active = 'vendor_material';
 		document.title = '卖家产品库-优软商城';
 		$scope.tab = 'material';
@@ -494,6 +494,13 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
 		};
 
 		var loadData = function () {
+			var pathname = window.location.pathname;
+			if (pathname.substring(pathname.lastIndexOf('/') + 1) == 'vendor_erp') {
+				$scope.param.sorting = {
+					erpReserve: 'DESC'
+				};
+			}
+			console.log(window.location.pathname);
 			Material.getAll($scope.param, function (data) {
 				$scope.materialAll = data;
 				$scope.currenctMaterial = data.content;

+ 1 - 1
src/main/webapp/resources/view/vendor/forstore/erp/vendor_material_erp.html

@@ -485,7 +485,7 @@
 							<span ng-show="isBatch"><input type="checkbox" ng-checked="material.isChoosed"  ng-click="chooseOne(material)"  id="{{$index+1}}"/><label for="{{$index+1}}"></label><br/></span>
 							<span ng-show="!isBatch" ng-bind="(param.currentPage - 1) * 10 + $index + 1"></span>
 						</td>
-						<td>{{material.productDetail.reserve || 0}}</td>
+						<td>{{material.erpReserve || 0}}</td>
 						<td ng-bind="material.prodNum" title="{{material.prodNum}}"></td>
 						<td>
 							<span ng-if="material.kind" ng-bind="material.kind" title="{{material.kind}}"></span>