233 lines
		
	
	
		
			5.8 KiB
		
	
	
	
		
			Java
		
	
	
		
		
			
		
	
	
			233 lines
		
	
	
		
			5.8 KiB
		
	
	
	
		
			Java
		
	
	
| 
								 | 
							
								package hhwms;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								import java.util.ArrayList;
							 | 
						|||
| 
								 | 
							
								import java.util.Arrays;
							 | 
						|||
| 
								 | 
							
								import java.util.Collection;
							 | 
						|||
| 
								 | 
							
								import java.util.Date;
							 | 
						|||
| 
								 | 
							
								import java.util.HashMap;
							 | 
						|||
| 
								 | 
							
								import java.util.Iterator;
							 | 
						|||
| 
								 | 
							
								import java.util.LinkedList;
							 | 
						|||
| 
								 | 
							
								import java.util.List;
							 | 
						|||
| 
								 | 
							
								import java.util.Map;
							 | 
						|||
| 
								 | 
							
								import java.util.stream.Collectors;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								import org.apache.commons.collections.CollectionUtils;
							 | 
						|||
| 
								 | 
							
								import org.apache.commons.lang.StringUtils;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								import net.sf.json.JSONArray;
							 | 
						|||
| 
								 | 
							
								import net.sf.json.JSONObject;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								public class test {
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
									public static void main(String[] args) {
							 | 
						|||
| 
								 | 
							
										String json="["
							 | 
						|||
| 
								 | 
							
											 	+ "{'entryId':'entry-board-201912300001','workOrder':'workOrder-board-201912300001','skuType':'board','skuId':'sku-board-0001','amount':'100','unit':'件','lineName':'line0001','sendTime':'2019-12-30 15:15:14'},"
							 | 
						|||
| 
								 | 
							
											 	+ "{'entryId':'entry-board-201912300002','workOrder':'workOrder-board-201912300001','skuType':'board','skuId':'sku-board-0001','amount':'100','unit':'件','lineName':'line0001','sendTime':'2019-12-30 15:15:14'}"
							 | 
						|||
| 
								 | 
							
											 	+ "]";
							 | 
						|||
| 
								 | 
							
										String json1="["
							 | 
						|||
| 
								 | 
							
												 + "{'orderId':'entry-board-201912300001','workOrder':'workOrder-board-201912300001','skuType':'board','skuId':'sku-board-0001','amount':'100','unit':'件','lineName':'line0001','sendTime':'2019-12-30 15:15:14'},"
							 | 
						|||
| 
								 | 
							
												 + "{'orderId':'entry-board-201912300003','workOrder':'workOrder-board-201912300001','skuType':'board','skuId':'sku-board-0001','amount':'100','unit':'件','lineName':'line0001','sendTime':'2019-12-30 15:15:14'}"
							 | 
						|||
| 
								 | 
							
												 + "]";
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
										//storeInbardown(json);
							 | 
						|||
| 
								 | 
							
										//storeInbardown(json1);
							 | 
						|||
| 
								 | 
							
										//returnInbardown();
							 | 
						|||
| 
								 | 
							
										/*String str="CP001221000011";
							 | 
						|||
| 
								 | 
							
										System.out.println(isNumeric(str));*/
							 | 
						|||
| 
								 | 
							
										//aa();
							 | 
						|||
| 
								 | 
							
										//bb();
							 | 
						|||
| 
								 | 
							
										cc();
							 | 
						|||
| 
								 | 
							
										//removeElement();
							 | 
						|||
| 
								 | 
							
										//dd();
							 | 
						|||
| 
								 | 
							
										 //zz();
							 | 
						|||
| 
								 | 
							
										/*List<String> list=new ArrayList<String>();
							 | 
						|||
| 
								 | 
							
										list.add("1001");
							 | 
						|||
| 
								 | 
							
										list.add("1002");*/
							 | 
						|||
| 
								 | 
							
										
							 | 
						|||
| 
								 | 
							
										/*if(!list.contains("2")){
							 | 
						|||
| 
								 | 
							
											System.out.println("hah");
							 | 
						|||
| 
								 | 
							
										}*/
							 | 
						|||
| 
								 | 
							
										
							 | 
						|||
| 
								 | 
							
									}
							 | 
						|||
| 
								 | 
							
									
							 | 
						|||
| 
								 | 
							
									public static void zz(){
							 | 
						|||
| 
								 | 
							
										String a="202, 201";
							 | 
						|||
| 
								 | 
							
										String b=a.replace(" ","");
							 | 
						|||
| 
								 | 
							
										System.out.println(b);
							 | 
						|||
| 
								 | 
							
										List<String> list=Arrays.asList(a.toString());
							 | 
						|||
| 
								 | 
							
										for(String id:list){
							 | 
						|||
| 
								 | 
							
											System.out.println(id);
							 | 
						|||
| 
								 | 
							
										}
							 | 
						|||
| 
								 | 
							
									}
							 | 
						|||
| 
								 | 
							
									
							 | 
						|||
| 
								 | 
							
									public static String aa(List<String> list){
							 | 
						|||
| 
								 | 
							
										String ids = list.stream().map(s -> "'" + s + "'").collect(Collectors.joining(","));
							 | 
						|||
| 
								 | 
							
										System.out.println(ids);
							 | 
						|||
| 
								 | 
							
									    return ids;
							 | 
						|||
| 
								 | 
							
									}
							 | 
						|||
| 
								 | 
							
									
							 | 
						|||
| 
								 | 
							
									public static void ee(){
							 | 
						|||
| 
								 | 
							
										String K5="11111";
							 | 
						|||
| 
								 | 
							
										String MMM="{'k1':'7313','k2':'7313','k3':'','k4':'T29','k5':'"+K5+"','k6':'','k7':'55b45151'}";
							 | 
						|||
| 
								 | 
							
										System.out.println(MMM);
							 | 
						|||
| 
								 | 
							
									}
							 | 
						|||
| 
								 | 
							
									public static void dd(){
							 | 
						|||
| 
								 | 
							
										String barcode="D202301127837";
							 | 
						|||
| 
								 | 
							
										String a=StringUtils.substringBefore(barcode, ",");
							 | 
						|||
| 
								 | 
							
										System.out.println(a);
							 | 
						|||
| 
								 | 
							
									}
							 | 
						|||
| 
								 | 
							
									
							 | 
						|||
| 
								 | 
							
									public static void cc(){
							 | 
						|||
| 
								 | 
							
										
							 | 
						|||
| 
								 | 
							
										List<String> xd=new ArrayList<String>();
							 | 
						|||
| 
								 | 
							
										List<String> bxd=new ArrayList<String>();
							 | 
						|||
| 
								 | 
							
										
							 | 
						|||
| 
								 | 
							
										List<String> new1=new ArrayList<String>();
							 | 
						|||
| 
								 | 
							
										new1.add("b2");
							 | 
						|||
| 
								 | 
							
										new1.add("b5");
							 | 
						|||
| 
								 | 
							
										List<String> old=new ArrayList<String>();
							 | 
						|||
| 
								 | 
							
										old.add("b4");
							 | 
						|||
| 
								 | 
							
										old.add("b2");
							 | 
						|||
| 
								 | 
							
										old.add("b3");
							 | 
						|||
| 
								 | 
							
										
							 | 
						|||
| 
								 | 
							
										List<String> notnew1=new ArrayList(new1);
							 | 
						|||
| 
								 | 
							
								        notnew1.removeAll(old);
							 | 
						|||
| 
								 | 
							
								        System.out.println("new1中不存在于_set中的:"+notnew1);
							 | 
						|||
| 
								 | 
							
								        
							 | 
						|||
| 
								 | 
							
								        List<String> notold1=new ArrayList(old);
							 | 
						|||
| 
								 | 
							
								        notold1.removeAll(new1);
							 | 
						|||
| 
								 | 
							
								        System.out.println("old中不存在于_set中的:"+notold1);
							 | 
						|||
| 
								 | 
							
								        
							 | 
						|||
| 
								 | 
							
								        
							 | 
						|||
| 
								 | 
							
								        for(String id:old){
							 | 
						|||
| 
								 | 
							
								        	if(new1.contains(id)){
							 | 
						|||
| 
								 | 
							
								        		xd.add(id);
							 | 
						|||
| 
								 | 
							
								        	}else{
							 | 
						|||
| 
								 | 
							
								        		bxd.add(id);
							 | 
						|||
| 
								 | 
							
								        	}
							 | 
						|||
| 
								 | 
							
								        	
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        
							 | 
						|||
| 
								 | 
							
								        
							 | 
						|||
| 
								 | 
							
								        for(String id:xd){
							 | 
						|||
| 
								 | 
							
								        	System.out.println("相等:"+id);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        String xlh = bxd.stream().map(s -> "'" + s + "'").collect(Collectors.joining(","));
							 | 
						|||
| 
								 | 
							
								        
							 | 
						|||
| 
								 | 
							
								        System.out.println("不相等:"+xlh);
							 | 
						|||
| 
								 | 
							
								        
							 | 
						|||
| 
								 | 
							
								      
							 | 
						|||
| 
								 | 
							
									
							 | 
						|||
| 
								 | 
							
									}
							 | 
						|||
| 
								 | 
							
									
							 | 
						|||
| 
								 | 
							
									public static void removeElement() {
							 | 
						|||
| 
								 | 
							
									    List<String> list = new ArrayList<String>();
							 | 
						|||
| 
								 | 
							
									    list.add("1");
							 | 
						|||
| 
								 | 
							
									    list.add("2");
							 | 
						|||
| 
								 | 
							
									    list.add("3");
							 | 
						|||
| 
								 | 
							
									    for (String item : list) {
							 | 
						|||
| 
								 | 
							
									        if (item=="1") {
							 | 
						|||
| 
								 | 
							
									            list.remove(item);
							 | 
						|||
| 
								 | 
							
									        }
							 | 
						|||
| 
								 | 
							
									    }
							 | 
						|||
| 
								 | 
							
									}
							 | 
						|||
| 
								 | 
							
									
							 | 
						|||
| 
								 | 
							
									public static void bb(){
							 | 
						|||
| 
								 | 
							
										Map<Integer,Integer> map=new HashMap<Integer, Integer>();
							 | 
						|||
| 
								 | 
							
										List<Long> ids=new ArrayList<Long>();
							 | 
						|||
| 
								 | 
							
										List<Integer> ids2=new ArrayList<Integer>();
							 | 
						|||
| 
								 | 
							
										ids.add(1L);
							 | 
						|||
| 
								 | 
							
										ids.add(2L);
							 | 
						|||
| 
								 | 
							
										ids.add(3L);
							 | 
						|||
| 
								 | 
							
										ids.add(4L);
							 | 
						|||
| 
								 | 
							
										ids.add(5L);
							 | 
						|||
| 
								 | 
							
										ids.add(6L);
							 | 
						|||
| 
								 | 
							
										int i=0;
							 | 
						|||
| 
								 | 
							
										for(Long id:ids){
							 | 
						|||
| 
								 | 
							
											if(id==1){
							 | 
						|||
| 
								 | 
							
												ids2.add(i++);
							 | 
						|||
| 
								 | 
							
											}
							 | 
						|||
| 
								 | 
							
											if(id==2){
							 | 
						|||
| 
								 | 
							
												ids2.add(i++);
							 | 
						|||
| 
								 | 
							
											}
							 | 
						|||
| 
								 | 
							
										}
							 | 
						|||
| 
								 | 
							
										if(ids2.size()>0){
							 | 
						|||
| 
								 | 
							
											map.put(1, ids2.size());
							 | 
						|||
| 
								 | 
							
										}else{
							 | 
						|||
| 
								 | 
							
											map.put(0,0);
							 | 
						|||
| 
								 | 
							
										}
							 | 
						|||
| 
								 | 
							
										System.out.println(map.size());
							 | 
						|||
| 
								 | 
							
										for(Map.Entry<Integer,Integer> entry:map.entrySet()){
							 | 
						|||
| 
								 | 
							
											System.out.println(entry.getKey());
							 | 
						|||
| 
								 | 
							
											System.out.println(entry.getValue());
							 | 
						|||
| 
								 | 
							
										}
							 | 
						|||
| 
								 | 
							
										
							 | 
						|||
| 
								 | 
							
									}
							 | 
						|||
| 
								 | 
							
									
							 | 
						|||
| 
								 | 
							
									
							 | 
						|||
| 
								 | 
							
									public static void aa(){
							 | 
						|||
| 
								 | 
							
										List<Long> Tasks=new ArrayList<Long>();
							 | 
						|||
| 
								 | 
							
										Tasks.add(111L);
							 | 
						|||
| 
								 | 
							
										Tasks.add(222L);
							 | 
						|||
| 
								 | 
							
										Tasks.add(333L);
							 | 
						|||
| 
								 | 
							
										Tasks.add(444L);
							 | 
						|||
| 
								 | 
							
										Tasks.add(555L);
							 | 
						|||
| 
								 | 
							
										Tasks.add(666L);
							 | 
						|||
| 
								 | 
							
										Tasks.add(777L);
							 | 
						|||
| 
								 | 
							
										
							 | 
						|||
| 
								 | 
							
										List<Long> lxq=new ArrayList<Long>();
							 | 
						|||
| 
								 | 
							
										lxq.add(1L);
							 | 
						|||
| 
								 | 
							
										lxq.add(2L);
							 | 
						|||
| 
								 | 
							
										int i=0;
							 | 
						|||
| 
								 | 
							
										int num=0;
							 | 
						|||
| 
								 | 
							
										for(Long id:Tasks){
							 | 
						|||
| 
								 | 
							
											long a=lxq.get(i);
							 | 
						|||
| 
								 | 
							
											System.out.println(a);
							 | 
						|||
| 
								 | 
							
											System.out.println(id);
							 | 
						|||
| 
								 | 
							
											num++;
							 | 
						|||
| 
								 | 
							
											if(num>=((int)Math.ceil(Tasks.size()/lxq.size()))){
							 | 
						|||
| 
								 | 
							
												num=0;
							 | 
						|||
| 
								 | 
							
												i=i+1;
							 | 
						|||
| 
								 | 
							
												if(i+1>lxq.size()){
							 | 
						|||
| 
								 | 
							
													i=0;
							 | 
						|||
| 
								 | 
							
												}
							 | 
						|||
| 
								 | 
							
												
							 | 
						|||
| 
								 | 
							
											}
							 | 
						|||
| 
								 | 
							
										}
							 | 
						|||
| 
								 | 
							
										
							 | 
						|||
| 
								 | 
							
									}
							 | 
						|||
| 
								 | 
							
									
							 | 
						|||
| 
								 | 
							
									public static void storeInbardown(String json) {
							 | 
						|||
| 
								 | 
							
										
							 | 
						|||
| 
								 | 
							
									}
							 | 
						|||
| 
								 | 
							
									
							 | 
						|||
| 
								 | 
							
									public static String  isNumeric(String str){
							 | 
						|||
| 
								 | 
							
										
							 | 
						|||
| 
								 | 
							
										if(str.substring(0, 1).equals("0")){
							 | 
						|||
| 
								 | 
							
											str=String.valueOf(Integer.parseInt(str));
							 | 
						|||
| 
								 | 
							
										}
							 | 
						|||
| 
								 | 
							
										return str;
							 | 
						|||
| 
								 | 
							
									}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
									
							 | 
						|||
| 
								 | 
							
									public static void returnInbardown() {
							 | 
						|||
| 
								 | 
							
										
							 | 
						|||
| 
								 | 
							
										JSONObject jsonObject = new JSONObject();
							 | 
						|||
| 
								 | 
							
										jsonObject.put("entryId", "entry-board-201912300001");
							 | 
						|||
| 
								 | 
							
										jsonObject.put("workOrder", "workOrder-board-201912300001");
							 | 
						|||
| 
								 | 
							
										jsonObject.put("skuType", "board");
							 | 
						|||
| 
								 | 
							
										jsonObject.put("skuId", "sku-board-0001");
							 | 
						|||
| 
								 | 
							
										jsonObject.put("amount", "100");
							 | 
						|||
| 
								 | 
							
										jsonObject.put("unit", "件");
							 | 
						|||
| 
								 | 
							
										jsonObject.put("lineName", "line0001");
							 | 
						|||
| 
								 | 
							
										jsonObject.put("stored", "100");
							 | 
						|||
| 
								 | 
							
										jsonObject.put("rejection", "0");
							 | 
						|||
| 
								 | 
							
										jsonObject.put("scrap", "0");
							 | 
						|||
| 
								 | 
							
										jsonObject.put("unqualified", "0");
							 | 
						|||
| 
								 | 
							
										jsonObject.put("sendTime", "2019-12-30 15:15:14");
							 | 
						|||
| 
								 | 
							
										jsonObject.put("finishTime", "2019-12-30 17:15:15");
							 | 
						|||
| 
								 | 
							
										System.out.println(jsonObject.toString());
							 | 
						|||
| 
								 | 
							
									}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								}
							 |