Browse Source

更新物料的一键开启一键关闭的方法,同时录入企业表中,ERP传入物料时根据这个进行判断

git-svn-id: svn+ssh://10.10.101.21/source/platform/platform-b2b@9993 f3bf4e98-0cf0-11e4-a00c-a99a8b9d557d
hejq 8 years ago
parent
commit
e68d56fe6f

+ 4 - 0
src/main/java/com/uas/platform/b2b/controller/PurcProductController.java

@@ -10,6 +10,7 @@ import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Sort.Direction;
+import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.ui.ModelMap;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -58,6 +59,9 @@ public class PurcProductController {
 	@Autowired
 	private SearchService searchService;
 
+	@Autowired
+	private JdbcTemplate jdbcTemplate;
+
 	/**
 	 * 获取批量上传物料的模板
 	 * 

+ 20 - 8
src/main/java/com/uas/platform/b2b/erp/model/Prod.java

@@ -2,6 +2,7 @@ package com.uas.platform.b2b.erp.model;
 
 import java.util.Date;
 
+import com.uas.platform.b2b.model.Enterprise;
 import com.uas.platform.b2b.model.Product;
 import com.uas.platform.b2b.support.SystemSession;
 import com.uas.platform.core.model.Constant;
@@ -285,14 +286,25 @@ public class Prod {
 		} else {
 			product.setCmpCode(this.pr_spec);
 		}
-		if (this.pr_uuid != null) {
-			// 如果传过来的数据是有UUID,则把原来的信息赋值给标准信息上
-			product.setStandard(Constant.YES);
-			product.setPcmpcode(product.getCmpCode());
-			product.setPbrand(product.getBrand());
-			product.setKind(product.getTitle());
-		} else {
-			product.setStandard(Constant.NO);
+		// if (this.pr_uuid != null) {
+		// // 如果传过来的数据是有UUID,则把原来的信息赋值给标准信息上
+		// product.setStandard(Constant.YES);
+		// product.setPcmpcode(product.getCmpCode());
+		// product.setPbrand(product.getBrand());
+		// product.setKind(product.getTitle());
+		// } else {
+		// product.setStandard(Constant.NO);
+		// }
+		product.setStandard(Constant.NO);// 默认设置为非标准,到平台做匹配更新
+		Enterprise enter = SystemSession.getUser().getEnterprise();
+		// 默认开启关闭状态都是开启
+		product.setIsPurchase(Constant.YES);
+		product.setIsSale(Constant.YES);
+		if (enter.getProdpurc().equals(Constant.NO)) {
+			product.setIsPurchase(Constant.NO);
+		}
+		if (enter.getProdsale().equals(Constant.NO)) {
+			product.setIsSale(Constant.NO);
 		}
 		product.setIsPubsale(this.pr_ispubsale);
 		product.setIsPurchase(this.pr_ispurchase);

+ 0 - 4
src/main/java/com/uas/platform/b2b/erp/service/impl/ProdServiceImpl.java

@@ -12,7 +12,6 @@ import com.uas.platform.b2b.erp.model.Prod;
 import com.uas.platform.b2b.erp.service.ProdService;
 import com.uas.platform.b2b.model.Product;
 import com.uas.platform.b2b.support.SystemSession;
-import com.uas.platform.core.model.Constant;
 
 @Service
 public class ProdServiceImpl implements ProdService {
@@ -61,9 +60,6 @@ public class ProdServiceImpl implements ProdService {
 				Product product = prod.convert();
 				product.setId(prodResult.get(0).getId());
 				product.setCode(prodResult.get(0).getCode());
-				product.setIsPubsale(Constant.YES);
-				product.setIsSale(Constant.YES);
-				product.setSourceApp("ERP");
 				products.add(product);
 			}
 		}

+ 34 - 0
src/main/java/com/uas/platform/b2b/model/Enterprise.java

@@ -234,6 +234,24 @@ public class Enterprise implements Serializable {
 	@Column(name = "en_products")
 	private String enProducts;
 
+	/**
+	 * 记录产品的销售状态<br>
+	 * 1. 开启<br>
+	 * 0. 关闭
+	 */
+	@Column(name = "en_prodsale")
+	private Short prodsale;
+
+	/**
+	 * 记录物料的采购状态<br>
+	 * 1. 开启<br>
+	 * 0. 关闭
+	 * 
+	 * @return
+	 */
+	@Column(name = "en_prodpurc")
+	private Short prodpurc;
+
 	public String getEnManagement() {
 		return enManagement;
 	}
@@ -645,4 +663,20 @@ public class Enterprise implements Serializable {
 		this.enbank = enbank;
 	}
 
+	public Short getProdsale() {
+		return prodsale;
+	}
+
+	public void setProdsale(Short prodsale) {
+		this.prodsale = prodsale;
+	}
+
+	public Short getProdpurc() {
+		return prodpurc;
+	}
+
+	public void setProdpurc(Short prodpurc) {
+		this.prodpurc = prodpurc;
+	}
+
 }

+ 4 - 0
src/main/java/com/uas/platform/b2b/service/impl/BaseInfoServiceImpl.java

@@ -897,9 +897,13 @@ public class BaseInfoServiceImpl implements BaseInfoService {
 	public void switchPorduct(String status) {
 		String switchtype = "sale";
 		Integer switchstatus = 0;
+		Enterprise enter = SystemSession.getUser().getEnterprise();
+		enter.setProdsale(Constant.NO);
 		if (status.equals("on")) {
 			switchstatus = 1;
+			enter.setProdsale(Constant.YES);
 		}
+		enterpriseDao.save(enter);
 		productDao.switchProductByEnuuAndTypeAndStatus(SystemSession.getUser().getEnterprise().getUu(), switchtype,
 				switchstatus);
 	}

+ 9 - 0
src/main/java/com/uas/platform/b2b/service/impl/PurcProductServiceImpl.java

@@ -14,7 +14,9 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.ui.ModelMap;
 
+import com.uas.platform.b2b.dao.EnterpriseDao;
 import com.uas.platform.b2b.dao.ProductDao;
+import com.uas.platform.b2b.model.Enterprise;
 import com.uas.platform.b2b.model.Product;
 import com.uas.platform.b2b.service.PurcProductService;
 import com.uas.platform.b2b.support.SystemSession;
@@ -26,6 +28,9 @@ public class PurcProductServiceImpl implements PurcProductService {
 	@Autowired
 	private ProductDao productDao;
 
+	@Autowired
+	private EnterpriseDao enterpriseDao;
+
 	/**
 	 * 批量导入物料资料
 	 */
@@ -288,9 +293,13 @@ public class PurcProductServiceImpl implements PurcProductService {
 	public void switchPorduct(String status) {
 		String switchtype = "purc";
 		Integer switchstatus = 0;
+		Enterprise enter = SystemSession.getUser().getEnterprise();
+		enter.setProdpurc(Constant.NO);
 		if (status.equals("on")) {
 			switchstatus = 1;
+			enter.setProdpurc(Constant.YES);
 		}
+		enterpriseDao.save(enter);
 		productDao.switchProductByEnuuAndTypeAndStatus(SystemSession.getUser().getEnterprise().getUu(), switchtype,
 				switchstatus);
 	}

+ 31 - 2
src/main/webapp/resources/js/index/app.js

@@ -10320,8 +10320,16 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 	/**
 	 * 物料资料
 	 */
-	app.controller('ProductListCtrl', ['$scope', 'GetProductInfo', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', '$rootScope', '$modal', 'Products', 'GetProductInfoNewest', function($scope, GetProductInfo, ngTableParams, $filter, BaseService, toaster, $timeout, $rootScope, $modal, Products, GetProductInfoNewest) {
+	app.controller('ProductListCtrl', ['$scope', 'GetProductInfo', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', '$rootScope', '$modal', 'Products', 'GetProductInfoNewest', 'AccountEnterprise', function($scope, GetProductInfo, ngTableParams, $filter, BaseService, toaster, $timeout, $rootScope, $modal, Products, GetProductInfoNewest, AccountEnterprise) {
 		BaseService.scrollBackToTop();
+		var loadAccount = function() {
+			AccountEnterprise.get({}, function(data){
+				$scope.loading = false;
+				$scope.enterprise = data;
+				$scope.saleStatus = $scope.enterprise.prodsale;
+			});
+		}
+		loadAccount();
 		$scope.active = 'all';
 		$scope.agreedText = '全部';
 		$scope.dateZoneText = '一个月内';
@@ -10419,10 +10427,16 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 
 		// 一键开启关闭
 		$scope.toggle = function(status) {
+			if($scope.saleStatus = 0) {
+				$scope.saleStatus = 1;
+			} else {
+				$scope.saleStatus = 0;
+			}
 			$scope.loading = true;
 			GetProductInfo.toggle({status: status}, {}, function(data) {
 				$scope.loading = false;
 				toaster.pop('success', '提示', '操作成功');
+				loadAccount();
 				$scope.tableParams.reload();
 			}, function(response) {
 				$scope.loading = false;
@@ -17589,8 +17603,17 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 	/**
 	 * 采购物料资料
 	 */
-	app.controller('PurcProductCtrl', ['$scope', 'PurcProduct', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', 'Products', '$modal', 'GetProductInfo', '$rootScope', 'PurcProductNewest', function($scope, PurcProduct, ngTableParams, $filter, BaseService, toaster, $timeout, Products, $modal, GetProductInfo, $rootScope, PurcProductNewest) {
+	app.controller('PurcProductCtrl', ['$scope', 'PurcProduct', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', 'Products', '$modal', 'GetProductInfo', '$rootScope', 'PurcProductNewest', 'AccountEnterprise', function($scope, PurcProduct, ngTableParams, $filter, BaseService, toaster, $timeout, Products, $modal, GetProductInfo, $rootScope, PurcProductNewest, AccountEnterprise) {
 		BaseService.scrollBackToTop();
+		
+		var loadAccount = function () {
+			AccountEnterprise.get({}, function(data){
+				$scope.loading = false;
+				$scope.enterprise = data;
+				$scope.purcStatus = $scope.enterprise.prodpurc;
+			});
+		}
+		loadAccount();
 		$scope.active = 'all';
 		$scope.agreedText = '全部';
 		$scope.dateZoneText = '一个月内';
@@ -17681,10 +17704,16 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 		
 		// 一键开启关闭
 		$scope.toggle = function(status) {
+			if($scope.purcStatus = 0) {
+				$scope.purcStatus = 1;
+			} else {
+				$scope.purcStatus = 0;
+			}
 			$scope.loading = true;
 			Products.toggle({status: status}, {}, function(data) {
 				$scope.loading = false;
 				toaster.pop('success', '提示', '操作成功');
+				loadAccount();
 				$scope.tableParams.reload();
 			}, function(response) {
 				$scope.loading = false;

+ 2 - 2
src/main/webapp/resources/tpl/index/baseInfo/prodList.html

@@ -192,8 +192,8 @@
             <a href="product/baseInfo/xls?_state={{active}}&keyword={{keywordXls}}" target="_self" class="text-simple" title="导出Excel表格">导出</a>
             <a ui-sref="sale.newProdInfo">新增</a>
             <a ui-sref="sale.uploadByBatch" title="批量导入">批量导入</a>
-            <a ng-click="toggle('off')">一键关闭</a>
-            <a ng-click="toggle('on')">一键开启</a>
+            <a ng-click="toggle('off')" ng-if="saleStatus != 0">一键关闭</a>
+            <a ng-click="toggle('on')" ng-if="saleStatus == 0">一键开启</a>
            <!-- <a ng-click="matchall()">一键匹配</a>-->
         </div>
     </div>

+ 2 - 2
src/main/webapp/resources/tpl/index/purc/prodList.html

@@ -173,8 +173,8 @@
             <a href="product/baseInfo/xls?keyword={{keywordXls}}" target="_self" class="text-simple" title="导出Excel表格">导出</a>
             <a ui-sref="purc.newProduct">新增</a>
             <a ui-sref="purc.uploadProduct" title="批量导入">批量导入</a>
-            <a ng-click="toggle('off')">一键关闭</a>
-            <a ng-click="toggle('on')">一键开启</a>
+            <a ng-click="toggle('off');" ng-if="purcStatus != 0">一键关闭</a>
+            <a ng-click="toggle('on')" ng-if="purcStatus == 0">一键开启</a>
             <!--<a ng-click="matchall()">一键匹配</a>-->
         </div>
     </div>