Browse Source

多选匹配功能

hulh 8 years ago
parent
commit
4b572012ff

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

@@ -2,6 +2,7 @@ package com.uas.platform.b2c.prod.commodity.controller;
 
 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.view.JxlsExcelView;
 import com.uas.platform.b2c.core.constant.SplitChar;
 import com.uas.platform.b2c.core.support.view.JxlsExcelView;
@@ -239,6 +240,18 @@ public class ProductController {
 		return productService.matchNonStandardProduct();
 	}
 
+	/**
+	 * 匹配选中的列表
+	 * @param idList
+	 * @return
+	 */
+	@RequestMapping(value = "/match/selected", method = RequestMethod.POST)
+	public ResultMap matchSelected(@RequestBody List<Long> idList) {
+		Long enuu = SystemSession.getUser().getEnterprise() != null ? SystemSession.getUser().getEnterprise().getUu() : null;
+		logger.info("选中的产品进行匹配" + enuu);
+		return productService.matchSelected(idList);
+	}
+
 	/**
 	 * 保存匹配的信息,非标上架版本
 	 * @param json

+ 88 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/model/MatchModel.java

@@ -0,0 +1,88 @@
+package com.uas.platform.b2c.prod.commodity.model;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+/**
+ * 记录勾选匹配的id
+ * @author hulh
+ */
+@Entity
+@Table(name = "product$match")
+public class MatchModel {
+
+    /**
+     * 主键
+     */
+    @Id
+    @GeneratedValue
+    @Column(name = "id")
+    private Long id;
+
+    /**
+     * 批次号,唯一标识
+     */
+    @Column(name = "ma_batch")
+    private String batch;
+
+    /**
+     * uu
+     */
+    @Column(name = "ma_useruu")
+    private Long useruu;
+
+    /**
+     * 企业enuu
+     */
+    @Column(name = "ma_enuu")
+    private Long enuu;
+
+    /**
+     * 对应的产品id
+     */
+    @Column(name = "ma_product_id")
+    private Long productId;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getBatch() {
+        return batch;
+    }
+
+    public void setBatch(String batch) {
+        this.batch = batch;
+    }
+
+    public Long getUseruu() {
+        return useruu;
+    }
+
+    public void setUseruu(Long useruu) {
+        this.useruu = useruu;
+    }
+
+    public Long getEnuu() {
+        return enuu;
+    }
+
+    public void setEnuu(Long enuu) {
+        this.enuu = enuu;
+    }
+
+    public Long getProductId() {
+        return productId;
+    }
+
+    public void setProductId(Long productId) {
+        this.productId = productId;
+    }
+}

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

@@ -133,6 +133,13 @@ public interface ProductService {
      */
     ResultMap matchNonStandardProduct();
 
+    /**
+     *
+     * @param idList
+     * @return
+     */
+    ResultMap matchSelected(List<Long> idList);
+
     /**
      * 保存匹配信息
      * @param json

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

@@ -3,6 +3,7 @@ package com.uas.platform.b2c.prod.commodity.service.impl;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.uas.platform.b2c.advertise.ad.service.RecommendProductService;
+import com.uas.platform.b2c.common.account.model.Enterprise;
 import com.uas.platform.b2c.common.account.service.EnterpriseService;
 import com.uas.platform.b2c.core.config.SysConf;
 import com.uas.platform.b2c.core.constant.IntegerConstant;
@@ -18,6 +19,7 @@ import com.uas.platform.b2c.prod.commodity.service.ProductService;
 import com.uas.platform.b2c.prod.commodity.type.ProductConstant;
 import com.uas.platform.b2c.prod.product.brand.dao.BrandDao;
 import com.uas.platform.b2c.prod.product.brand.modal.Brand;
+import com.uas.platform.b2c.prod.product.common.service.impl.CreateNumberServiceImpl;
 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;
@@ -155,6 +157,9 @@ public class ProductServiceImpl implements ProductService {
     @Autowired
     private GoodsService goodsService;
 
+    @Autowired
+    private CreateNumberServiceImpl createNumberService;
+
     private ConcurrentHashMap<String, Field> sortFields = new ConcurrentHashMap<String, Field>();
 
     @Override
@@ -599,15 +604,7 @@ public class ProductServiceImpl implements ProductService {
         return "success";
     }
 
-    /**
-     * 一键匹配非标产品,并带出该型号匹配的器件信息
-     * @return
-     */
-    @Override
-    public ResultMap matchNonStandardProduct(){
-        Map<String, Object> map = new HashMap<>();
-        final Long uu = SystemSession.getUser().getUserUU();
-        final Long enUU = SystemSession.getUser().getEnterprise().getUu();
+    private ResultMap validateProductStatus(Long enUU) {
         ProductStoreStatus status = productStoreStatusDao.findByEnuu(enUU);
         if (status != null) {
             // 有人正在操作这张单据,不能进行操作
@@ -631,6 +628,23 @@ public class ProductServiceImpl implements ProductService {
             storeStatus.setStatus(Status.RUNNING.value());
             status = productStoreStatusDao.save(storeStatus);
         }
+        return ResultMap.success(status);
+    }
+
+    /**
+     * 一键匹配非标产品,并带出该型号匹配的器件信息
+     * @return
+     */
+    @Override
+    public ResultMap matchNonStandardProduct(){
+        Map<String, Object> map = new HashMap<>();
+        final Long uu = SystemSession.getUser().getUserUU();
+        final Long enUU = SystemSession.getUser().getEnterprise().getUu();
+        ResultMap statusResult = validateProductStatus(enUU);
+        if (statusResult.getCode() != CodeType.OK.code()) {
+            return statusResult;
+        }
+        ProductStoreStatus status = (ProductStoreStatus) statusResult.getData();
 
         int total = productDao.getCountByEnuuAndStatusAndEnabled(enUU, ShortConstant.NO_SHORT, IntegerConstant.YES_SHORT);
         int success = 0;
@@ -684,6 +698,39 @@ public class ProductServiceImpl implements ProductService {
         return product;
     }
 
+    @Override
+    public ResultMap matchSelected(List<Long> idList) {
+        Enterprise enterprise = SystemSession.getUser().getEnterprise();
+        Long enUU = enterprise != null ? enterprise.getUu() : null;
+        if (enUU == null) {
+            return new ResultMap(CodeType.NO_INFO, "企业或EnUU信息丢失");
+        }
+        ResultMap statusResult = validateProductStatus(enUU);
+        if (statusResult.getCode() != CodeType.OK.code()) {
+            return statusResult;
+        }
+        ProductStoreStatus status = (ProductStoreStatus) statusResult.getData();
+        String batch = createNumberService.getTimeNumber("product$match", 8);
+        // 保存要匹配的id数据
+
+        return null;
+    }
+
+
+    private void createMatchModel(List<Long> idList, String batch) {
+        Long uu = SystemSession.getUser().getUserUU();
+        Long enUU = SystemSession.getUser().getEnterprise() != null ? SystemSession.getUser().getEnterprise().getUu() : null;
+        List<MatchModel> resultList = new ArrayList<>(idList.size());
+        for (Long id : idList) {
+            MatchModel matchModel = new MatchModel();
+            matchModel.setBatch(batch);
+            matchModel.setProductId(id);
+            matchModel.setUseruu(uu);
+            matchModel.setEnuu(enUU);
+            resultList.add(matchModel);
+        }
+    }
+
     /**
      * 保存匹配的信息
      * @param json

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

@@ -766,18 +766,6 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
 			}, function (error) {
 				toaster.pop("error", "匹配操作失败!")
 			});
-
-			// Material.matchAll({}, function (data) {
-			// 	if (data.updateCount > 0) {
-			// 		toaster.pop('success', '匹配完成, 本次匹配成功 ' + data.updateCount +' 个,可前往“标准产品”中 , 编辑上架。');
-			// 	}
-			// 	else {
-			// 		toaster.pop('success', '匹配完成, 暂无匹配成功产品,可前往“品牌申请/器件申请”中 , 提出申请。');
-			// 	}
-			// 	loadDataReload();
-			// }, function (response) {
-			// 	toaster.pop('info', response.data);
-			// });
 		};
 
 		function downloadByJs(url, keyword, type) {

+ 14 - 12
src/main/webapp/resources/view/vendor/forstore/vendor_material.html

@@ -1521,15 +1521,14 @@
 				</div>
 				<div class="check fr">
 					<a ng-show="!isBatch && standard_tab == 'unstandard'" ng-click="matchAll()"><span ng-show="!isBatch && standard_tab == 'unstandard'">一键匹配</span></a>
-					<a ng-show="!isBatch" ng-click="enterBatch()"><span ng-show="!isBatch">批量操作</span></a>
+					<!--<a ng-show="!isBatch" ng-click="enterBatch()"><span ng-show="!isBatch">批量操作</span></a>-->
 					<span class="check-btn" ng-show="isBatch">
 						<label class="check-active">
 							<input type="checkbox"  ng-click="chooseAll()" ng-checked="isChoosedAll" id="AllChoose"/>
 							<label for="AllChoose"></label>
 							<span>全选</span>
 						</label>
-						<a
-								ng-click="deleteBatch()" name="delete-material">删除</a>
+						<a ng-click="deleteBatch()" name="delete-material">删除</a>
 						<a ng-click="exitBatch()">取消</a>
 					</span>
 				</div>
@@ -1540,12 +1539,13 @@
 				<table class="public-tab table">
 					<thead>
 					<tr>
+						<th width="80">全选</th>
 						<th width="80">序号</th>
 						<th width="180">产品名称(类目)</th>
 						<th width="200">产品型号</th>
 						<th width="150">品牌</th>
 						<th width="100">单位</th>
-						<th width="80">封装</th>
+						<!--<th width="80">封装</th>-->
 						<th width="180">操作</th>
 					</tr>
 					</thead>
@@ -1566,9 +1566,11 @@
 					<!--<tr ng-class="{ 'active': material.selected }" class="gre-bg">-->
 					<tr ng-class="{ 'active': material.selected, 'gre-bg' : material.exPandOper}">
 						<td class="check-input">
-							<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.page - 1) * 10 + $index + 1"></span>
+							<span><input type="checkbox" ng-checked="material.isChoosed"  ng-click="chooseOne(material)"  id="{{$index+1}}"/><label for="{{$index+1}}"></label><br/></span>
+						</td>
+						<td>
+							<!--<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.page - 1) * 10 + $index + 1"></span>
 						</td>
 						<td>
 							<span ng-if="material.kind" ng-bind="material.kind" title="{{material.kind}}"></span>
@@ -1583,9 +1585,9 @@
 							<div class="ellipsis-div" ng-if="!material.pbranden" ng-bind="material.pbrand" title="{{material.pbrand}}"></div>
 						</td>
 						<td ng-bind="material.unit || 'PCS'" title="{{material.unit  || 'PCS'}}"></td>
-						<td>
-							<span ng-bind="material.encapsulation || '-'" title="{{material.encapsulation || '-'}}"></span>
-						</td>
+						<!--<td>-->
+							<!--<span ng-bind="material.encapsulation || '-'" title="{{material.encapsulation || '-'}}"></span>-->
+						<!--</td>-->
 						<td class="edit">
 							<span name="delete-material" ng-show="!isBatch && !material.exPandOper && !material.addGoodsOper" ng-click="deleteMaterial(material)"><span>删除</span></span>
 							<span ng-show="!isBatch && !material.exPandOper && !material.addGoodsOper" ng-click="showShelfArea(material)"><span>添加产品</span></span>
@@ -2034,7 +2036,7 @@
 							<th width="120">产品名称(类目)</th>
 							<th width="120">品牌</th>
 							<th width="100">型号</th>
-							<th width="100">封装</th>
+							<!--<th width="100">封装</th>-->
 							<th width="80"></th>
 						</tr>
 						</thead>
@@ -2056,7 +2058,7 @@
                                 </select>
 							</td>
 							<td title="{{product.pcmpcode}}" ng-bind="product.pcmpcode || '-'">Lhhjhj-3</td>
-							<td title="{{product.encapsulation}}" ng-bind="product.encapsulation  || '-'">BGA</td>
+							<!--<td title="{{product.encapsulation}}" ng-bind="product.encapsulation  || '-'">BGA</td>-->
 							<td class="confirm"><span ng-if="product.matchresults.length != 0 && product.canMatch" ng-click="updateNStandardOne(product)">确认</span></td>
 						</tr>
 						</tbody>