| 
					
				 | 
			
			
				@@ -1,5 +1,7 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.iamberry.rst.controllers.order; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.alibaba.fastjson.JSONArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.iamberry.redis.RedisUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.iamberry.rst.controllers.sys.SysController; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.iamberry.rst.core.address.District; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.iamberry.rst.core.cm.SalesOrder; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -30,10 +32,7 @@ import com.iamberry.rst.faces.product.ProductService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.iamberry.rst.faces.sms.MessageService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.iamberry.rst.faces.sms.SmsService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.iamberry.rst.faces.sys.SysService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.iamberry.rst.utils.AdminUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.iamberry.rst.utils.ExcelUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.iamberry.rst.utils.GenerateKeyUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.iamberry.rst.utils.OrderNoUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.iamberry.rst.utils.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.iamberry.wechat.tools.DateTimeUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.iamberry.wechat.tools.ObjectExcelView; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.iamberry.wechat.tools.ResponseJson; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -935,6 +934,14 @@ public class AdminOrderController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                         @RequestParam("productUrl") String filePath, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                         HttpServletRequest request) throws IOException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         ResponseJson json = new ResponseJson(200, "SUCCESS", 200); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Product product = new Product(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Product> productList = productService.listProductAndColorAndfittings(product); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ProductColor color = new ProductColor(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        color.setColorProductId(productList.get(0).getProductId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<ProductColor> productColorList = productService.listProduceColor(color); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        json.addResponseKeyValue("productColorList", productColorList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        json.addResponseKeyValue("productList", productList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         json.addResponseKeyValue("values", ExcelUtil.readCell(request.getServletContext().getRealPath(filePath), productName)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         json.addResponseKeyValue("colors", orderService.listProductColor()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return json; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2531,4 +2538,126 @@ public class AdminOrderController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         responseJson.addResponseKeyValue("order", order); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return responseJson; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 保存产品分词信息到redis 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param request 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @ResponseBody 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @RequestMapping("/addProductRedis") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public ResponseJson addProductRedis(HttpServletRequest request) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ResponseJson responseJson = new ResponseJson(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Product product = new Product(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Product> productList = productService.listProductAndColorAndfittings(product); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        HashMap<String,Set<String>> map = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for(Product pro : productList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for(ProductColor color : pro.getColorList()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                StringBuffer str = new StringBuffer(pro.getProductName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(pro.getProductType() == 6){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    str.append(" watero "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else if(pro.getProductType() == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    str.append(" 上朵soodo "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else if(pro.getProductType() == 9) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    str.append(" YULIA优尼雅 "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    str.append(" Aiberle爱贝源 "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(color.getColorAbbreviation() == null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    str.append(color.getColorName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    str.append(color.getColorName()+color.getColorAbbreviation()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(color.getColorlabel() != null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    str.append(color.getColorlabel()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                System.out.println(color.getColorId()+"----"+str); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Set<String> setString = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    setString = AnalyzerUtil.productsplitWord(str.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                map.put(color.getColorId().toString(),setString); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        RedisUtils.put("order_productList",map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return responseJson; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 根据excel文档产品名匹配产品颜色id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param request 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @ResponseBody 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @RequestMapping("/getColorIdByExcelName") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public ResponseJson getColorIdByExcelName(HttpServletRequest request,String excelProductName) throws IOException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ResponseJson responseJson = new ResponseJson(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(excelProductName == null || excelProductName.equals("")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            responseJson.setResultCode(500); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            responseJson.setReturnCode(500); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return responseJson; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /*excelProductName = new String(excelProductName.getBytes("ISO-8859-1"),"UTF-8");*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /*excelProductName = "watero滤芯T1";*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /*excelProductName = "上朵lips牙刷幻影黑";*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /*excelProductName = "WB-2水机珍珠白";*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /*excelProductName = "银离子水箱";*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /*excelProductName = "规格:滤芯组(T1/T2*2+T3/T4*1);";*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /*excelProductName = "水龙头净水器";*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /*excelProductName = "果蔬机STY02";*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /*excelProductName = "Watero净水机滤芯 T2";*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        HashMap<String,JSONArray> map = RedisUtils.get("order_productList",HashMap.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Set<String>  nameList = AnalyzerUtil.productsplitWord(excelProductName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String,Integer> productNums = new TreeMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for(String name : nameList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for(String key : map.keySet()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(productNums.get(key) == null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    productNums.put(key,0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Integer num2 = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                JSONArray jsonArray = map.get(key); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               /* Set<String> set = new HashSet<>();*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for(int i=0;i<jsonArray.size();i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                   String s1 =  name.toUpperCase(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                   String s2 =  jsonArray.getString(i).toUpperCase(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if(s1.equals(s2)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        num2+=2;//增加2 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if(s1.indexOf(s2) > 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            num2++;//增加1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if(s2.indexOf(s1) > 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            num2++;//增加1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(num2 > 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    productNums.put(key,productNums.get(key) + num2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Iterator iter = productNums.entrySet().iterator(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        TreeMap<Integer,String> productColors = new TreeMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        while(iter.hasNext()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Map.Entry entry = (Map.Entry)iter.next(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            productColors.put((Integer) entry.getValue(), (String) entry.getKey()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(productColors.size() > 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Integer colorId = Integer.valueOf(productColors.lastEntry().getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ProductColor productColor = productService.getProduceColor(colorId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            responseJson.addResponseKeyValue("colorId",productColor.getColorId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            responseJson.addResponseKeyValue("productId",productColor.getColorProductId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            responseJson.addResponseKeyValue("colorBar",productColor.getColorBar()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            responseJson.setReturnCode(200); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return responseJson; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |