Browse Source

Merge branch 'feature-wangyc-erpReserve-1219' into dev-mysql

wangyc 8 years ago
parent
commit
ecd0c167a2

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

@@ -57,12 +57,16 @@ public class ProductDetailERPServiceImpl implements ProductDetailERPService {
     @Override
     @Override
     public boolean uploadProductDetailERP(List<ProductDetailERP> productDetailERPList) {
     public boolean uploadProductDetailERP(List<ProductDetailERP> productDetailERPList) {
         List<ProductDetail> productDetails = new ArrayList<ProductDetail>();
         List<ProductDetail> productDetails = new ArrayList<ProductDetail>();
+        List<Product> productList = new ArrayList<Product>();
         Long enuu = SystemSession.getUser().getEnterprise().getUu();
         Long enuu = SystemSession.getUser().getEnterprise().getUu();
         for (ProductDetailERP productDetailERP : productDetailERPList) {
         for (ProductDetailERP productDetailERP : productDetailERPList) {
             ProductDetail productDetail = ModelConverter.convert(productDetailERP);
             ProductDetail productDetail = ModelConverter.convert(productDetailERP);
 
 
             List<Product> products = productDao.getProductByEnUUAndProdNum(enuu, productDetail.getCode());
             List<Product> products = productDao.getProductByEnUUAndProdNum(enuu, productDetail.getCode());
             if (!CollectionUtils.isEmpty(products)) {
             if (!CollectionUtils.isEmpty(products)) {
+                products.get(0).setErpReserve(productDetailERP.getReserve());
+                productList.add(products.get(0));
+
                 productDetail.setProductId(products.get(0).getId());
                 productDetail.setProductId(products.get(0).getId());
             }
             }
             // 如果已存在物料交易信息删除之前那一条,保存新的物料交易信息
             // 如果已存在物料交易信息删除之前那一条,保存新的物料交易信息
@@ -72,6 +76,8 @@ public class ProductDetailERPServiceImpl implements ProductDetailERPService {
             }
             }
             productDetails.add(productDetail);
             productDetails.add(productDetail);
         }
         }
+
+        productDao.save(productList);
         productDetailDao.save(productDetails);
         productDetailDao.save(productDetails);
         logger.log("物料交易详情", "初始化交易详情,企业:" + SystemSession.getUser().getEnterprise().getEnName() + ",数量:" + productDetails.size());
         logger.log("物料交易详情", "初始化交易详情,企业:" + SystemSession.getUser().getEnterprise().getEnName() + ",数量:" + productDetails.size());
         return true;
         return true;
@@ -85,16 +91,16 @@ public class ProductDetailERPServiceImpl implements ProductDetailERPService {
 
 
     @Override
     @Override
     public void updateReserve(List<ProductDetailERP> productDetailERPList) {
     public void updateReserve(List<ProductDetailERP> productDetailERPList) {
-        List<ProductDetail> productDetails = new ArrayList<ProductDetail>();
+        List<Product> productList = new ArrayList<Product>();
         Long enuu = SystemSession.getUser().getEnterprise().getUu();
         Long enuu = SystemSession.getUser().getEnterprise().getUu();
         for (ProductDetailERP productDetailERP : productDetailERPList) {
         for (ProductDetailERP productDetailERP : productDetailERPList) {
             List<Product> products = productDao.getProductByEnUUAndProdNum(enuu, productDetailERP.getCode());// 获取对应商城物料信息
             List<Product> products = productDao.getProductByEnUUAndProdNum(enuu, productDetailERP.getCode());// 获取对应商城物料信息
             if (!CollectionUtils.isEmpty(products)) {
             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) {// 如果为标准器件,更新在售商品信息
                 if (products.get(0).getCmpUuId() != null) {// 如果为标准器件,更新在售商品信息
                     Double b2cReserve = goodsDao.getSumReserveByEnUUAndUuidAndStatus(enuu, products.get(0).getCmpUuId(), Status.AVAILABLE.value());
                     Double b2cReserve = goodsDao.getSumReserveByEnUUAndUuidAndStatus(enuu, products.get(0).getCmpUuId(), Status.AVAILABLE.value());
@@ -117,8 +123,13 @@ public class ProductDetailERPServiceImpl implements ProductDetailERPService {
                                     good.setReserve(BigDecimal.valueOf(good.getReserve()).subtract(subtractDecimal).doubleValue());
                                     good.setReserve(BigDecimal.valueOf(good.getReserve()).subtract(subtractDecimal).doubleValue());
                                     good.setSelfSale(sysConf.getStoreid().equals(good.getStoreid())? IntegerConstant.B2C_SALE.toString() : IntegerConstant.SELF_SALE.toString());// 设置自营寄售
                                     good.setSelfSale(sysConf.getStoreid().equals(good.getStoreid())? IntegerConstant.B2C_SALE.toString() : IntegerConstant.SELF_SALE.toString());// 设置自营寄售
                                     loggerInfo.info(SystemSession.getUser().getEnterprise().getEnName() + "更新库存: " + products.get(0).getProdNum() + ",self is" + good.getSelfSale());
                                     loggerInfo.info(SystemSession.getUser().getEnterprise().getEnName() + "更新库存: " + products.get(0).getProdNum() + ",self is" + good.getSelfSale());
-                                    goodsService.updateGoods(nowGood, good);
-                                    goodsService.updateComponentTradeInfos(nowGood.getUuid());
+                                    // 如果调整后的库存小于最小起订量直接下架
+                                    if (good.getReserve() < good.getMinBuyQty()) {
+                                        goodsService.offShelfGoodsByProvider(good.getBatchCode());
+                                    } else {
+                                        goodsService.updateGoods(nowGood, good);
+                                        goodsService.updateComponentTradeInfos(nowGood.getUuid());
+                                    }
                                     break;
                                     break;
                                 }
                                 }
 
 
@@ -131,13 +142,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.setPackaging(productDetailERP.getPackaging());
 		productDetail.setPrice(productDetailERP.getPrice());
 		productDetail.setPrice(productDetailERP.getPrice());
 		productDetail.setProduceDate(productDetailERP.getProduceDate());
 		productDetail.setProduceDate(productDetailERP.getProduceDate());
-		productDetail.setReserve(productDetailERP.getReserve());
+		// 暂时将ERP空闲库存放置在product中
+//		productDetail.setReserve(productDetailERP.getReserve());
 		productDetail.setCode(productDetailERP.getCode());
 		productDetail.setCode(productDetailERP.getCode());
 		productDetail.setBreakUp(productDetailERP.getBreakUp());
 		productDetail.setBreakUp(productDetailERP.getBreakUp());
 		return productDetail;
 		return productDetail;

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

@@ -73,6 +73,12 @@ public class Product {
 	@Column(name = "pr_stock")
 	@Column(name = "pr_stock")
 	private Double stock;
 	private Double stock;
 
 
+	/**
+	 * ERP空闲库存
+	 */
+	@Column(name = "pr_reserve")
+	private Double erpReserve;
+
 	/**
 	/**
 	 * 价格
 	 * 价格
 	 */
 	 */
@@ -355,6 +361,14 @@ public class Product {
 		return this;
 		return this;
 	}
 	}
 
 
+	public Double getErpReserve() {
+		return erpReserve;
+	}
+
+	public void setErpReserve(Double erpReserve) {
+		this.erpReserve = erpReserve;
+	}
+
 	public Double getPrice() {
 	public Double getPrice() {
 		return price;
 		return price;
 	}
 	}

+ 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());
 		ProductDetail productDetail = productDetailDao.findByProductId(product.getId());
 		if (productDetail == null) {
 		if (productDetail == null) {
 			productDetail = new ProductDetail();
 			productDetail = new ProductDetail();
-		} else if (productDetail.getReserve() != null) {
+		} else if (product.getErpReserve() != null) {
 			ProductDetail newProductDetail = productService.findByProductId(product.getId());
 			ProductDetail newProductDetail = productService.findByProductId(product.getId());
-			if (productDetail.getReserve() < goods.getReserve() + newProductDetail.getB2cReserve()) {
+			if (product.getErpReserve() < goods.getReserve() + newProductDetail.getB2cReserve()) {
 				throw new IllegalOperatorException("本次上架数量和已上架数量之和不可超过ERP空闲库存数量");
 				throw new IllegalOperatorException("本次上架数量和已上架数量之和不可超过ERP空闲库存数量");
 			}
 			}
 		}
 		}

+ 14 - 0
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_materialCtrl.js

@@ -18,6 +18,20 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
             type : "standard"
             type : "standard"
         };
         };
 
 
+        $scope.sortByERP = 'none';
+        $scope.sortByERPReserve = function () {
+			if ($scope.sortByERP == 'none') {
+				$scope.sortByERP = 'DESC'
+			} else if ($scope.sortByERP == 'DESC') {
+				$scope.sortByERP = 'ASC'
+			} else {
+				$scope.sortByERP = 'none'
+			}
+			$scope.param.sorting = $scope.sortByERP == 'none' ? {id : 'DESC'} : {'erpReserve': $scope.sortByERP};
+			// $scope.sortByERP = type == $scope.sortByERP ? 'none' : type;
+			loadData();
+		}
+
 		if ($location.$$path.endsWith('vendor_material_unstandard_erp')) {
 		if ($location.$$path.endsWith('vendor_material_unstandard_erp')) {
 			$scope.tab = 'unstandard_material';
 			$scope.tab = 'unstandard_material';
 			// $scope.standard_tab = 'unstandard';
 			// $scope.standard_tab = 'unstandard';

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

@@ -96,6 +96,9 @@
 		font-size: 14px;
 		font-size: 14px;
 		vertical-align: middle !important;
 		vertical-align: middle !important;
 	}
 	}
+	.public-tab.table tr th >div i.active {
+		color: #5078cb;
+	}
 	.public-tab.table>tbody+tbody{
 	.public-tab.table>tbody+tbody{
 		border-top: none;
 		border-top: none;
 	}
 	}
@@ -426,6 +429,13 @@
 	.com_tab ul li.active a {
 	.com_tab ul li.active a {
 		color: #1687ff;
 		color: #1687ff;
 	}
 	}
+	.pro_management .table tr th .erp-reserve {
+		cursor: pointer;
+	}
+	.pro_management .table tr th .erp-reserve .sort-area,
+	.pro_management .table tr th .erp-reserve .sort-area:hover{
+		color: inherit !important;
+	}
 </style>
 </style>
 <div class="user_right fr">
 <div class="user_right fr">
 	<!--货品管理-->
 	<!--货品管理-->
@@ -465,7 +475,15 @@
 					<thead>
 					<thead>
 					<tr>
 					<tr>
 						<th width="80">序号</th>
 						<th width="80">序号</th>
-						<th width="80">ERP空闲库存</th>
+						<th width="80">
+							<div class="erp-reserve"  ng-click="sortByERPReserve()">
+								ERP空闲库存
+								<a class="sort-area" href="javascript:void(0)">
+									<i class=" fa fa-long-arrow-up" ng-class="{'active': sortByERP == 'ASC'}"></i>
+									<i class=" fa fa-long-arrow-down" ng-class="{'active': sortByERP == 'DESC'}"></i>
+								</a>
+							</div>
+						</th>
 						<th width="160">产品编号</th>
 						<th width="160">产品编号</th>
 						<th width="180">产品名称(类目)</th>
 						<th width="180">产品名称(类目)</th>
 						<th width="130">品牌</th>
 						<th width="130">品牌</th>
@@ -485,7 +503,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"><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>
 							<span ng-show="!isBatch" ng-bind="(param.currentPage - 1) * 10 + $index + 1"></span>
 						</td>
 						</td>
-						<td>{{material.productDetail.reserve || 0}}</td>
+						<td>{{material.erpReserve || 0}}</td>
 						<td ng-bind="material.prodNum" title="{{material.prodNum}}"></td>
 						<td ng-bind="material.prodNum" title="{{material.prodNum}}"></td>
 						<td>
 						<td>
 							<span ng-if="material.kind" ng-bind="material.kind" title="{{material.kind}}"></span>
 							<span ng-if="material.kind" ng-bind="material.kind" title="{{material.kind}}"></span>