工作中心匹配
							parent
							
								
									2d754b1ef8
								
							
						
					
					
						commit
						c930e431ca
					
				| 
						 | 
				
			
			@ -93,7 +93,7 @@ public class DefaultNewWaveManager extends DefaultBaseManager implements
 | 
			
		|||
				// " and b.PLAN_QUANTITY_MU-b.MOVED_QUANTITY_MU>0 "+
 | 
			
		||||
				+ " for xml Path('')),1,1,'') as taskId,"
 | 
			
		||||
				+ "item.code as liaohao  ,"
 | 
			
		||||
				+ "max(z.id) as kuqu,"j
 | 
			
		||||
				+ "max(z.id) as kuqu,"
 | 
			
		||||
				+ "max(t.END_REGION) as gzz,"
 | 
			
		||||
				+ "sum(t.PLAN_QUANTITY_MU-t.MOVED_QUANTITY_MU) as jhsl,"
 | 
			
		||||
				+ "MAX(s2.LP) as rqh ,"
 | 
			
		||||
| 
						 | 
				
			
			@ -418,40 +418,61 @@ public class DefaultNewWaveManager extends DefaultBaseManager implements
 | 
			
		|||
			List<GongDanMingXi> list_show = twlFenZu.gdPaiXus; //当前头物料所有的工单组合,以及每个工单的物料明细
 | 
			
		||||
			int this_fenzuCount=twlFenZu.wl_count;						//当前分组总物料行数
 | 
			
		||||
			List<GongZuoZhan>listGzz= FaiXuGzz(gzzMap);			//工作站根据可分配数量进行排序
 | 
			
		||||
			int gzz_index=0;															//当前分配工作站的排序下标
 | 
			
		||||
			GongZuoZhan curr_gzz=listGzz.get(0);
 | 
			
		||||
			for (int index=0;index<list_show.size();index++) {
 | 
			
		||||
				GongDanMingXi gongDanMingXi=list_show.get(index);
 | 
			
		||||
				//当前工单的物料
 | 
			
		||||
			
 | 
			
		||||
			if(list_show.size()==1){
 | 
			
		||||
				GongDanMingXi gongDanMingXi=list_show.get(0);
 | 
			
		||||
				GongZuoZhan curr_gzz=PiPeiGongZuoZhanForGzzxAndRqh(listGzz,gongDanMingXi,cfhs);
 | 
			
		||||
				List<FenPei> list_wList=gongDanMingXi.list;
 | 
			
		||||
				int chao=(list_wList.size()+curr_gzz.notFinished+curr_gzz.renWuList.size())-curr_gzz.maxRenWu;
 | 
			
		||||
				logger.info(listGzz.size());
 | 
			
		||||
				if(chao<=cfhs||index==list_show.size()-1){
 | 
			
		||||
					logger.info("11=="+listGzz.get(gzz_index));
 | 
			
		||||
					//如果当前待分配+此工作站未完成+已分配任务数  小于最大任务数 //将当前任务分配到此工作站
 | 
			
		||||
					for (FenPei fenPei : list_wList) {
 | 
			
		||||
						curr_gzz.renWuList.add(fenPei);
 | 
			
		||||
					}
 | 
			
		||||
					if(index==list_show.size()-1){
 | 
			
		||||
						//最后一个工单
 | 
			
		||||
						gzzMap.put(curr_gzz.code, curr_gzz);
 | 
			
		||||
					}
 | 
			
		||||
				}else{
 | 
			
		||||
					logger.info("2=="+listGzz.get(gzz_index));
 | 
			
		||||
					gzzMap.put(curr_gzz.code, curr_gzz);
 | 
			
		||||
					//如果当前待分配+此工作站未完成+已分配任务数  大于最大任务数 //将当前任务分配到下个工作站
 | 
			
		||||
					gzz_index=gzz_index+1;
 | 
			
		||||
					curr_gzz=listGzz.get(gzz_index);
 | 
			
		||||
					for (FenPei fenPei : list_wList) {
 | 
			
		||||
						curr_gzz.renWuList.add(fenPei);
 | 
			
		||||
					}
 | 
			
		||||
					if(index==list_show.size()-1){
 | 
			
		||||
						//最后一个工单
 | 
			
		||||
						gzzMap.put(curr_gzz.code, curr_gzz);
 | 
			
		||||
					}
 | 
			
		||||
				for (FenPei fenPei : list_wList) {
 | 
			
		||||
					curr_gzz.renWuList.add(fenPei);
 | 
			
		||||
					curr_gzz.RongQIHaoMap.put(fenPei.rqh,"");
 | 
			
		||||
					curr_gzz.GongZuoZhongXinMap.put(fenPei.gzzx,"");
 | 
			
		||||
				}
 | 
			
		||||
				gzzMap.put(curr_gzz.code, curr_gzz);
 | 
			
		||||
				
 | 
			
		||||
			}else{
 | 
			
		||||
				//多个工单匹配进行
 | 
			
		||||
				int gzz_index=0;															//当前分配工作站的排序下标
 | 
			
		||||
				GongZuoZhan curr_gzz=listGzz.get(0);
 | 
			
		||||
				for (int index=0;index<list_show.size();index++) {
 | 
			
		||||
					GongDanMingXi gongDanMingXi=list_show.get(index);
 | 
			
		||||
					//当前工单的物料
 | 
			
		||||
					List<FenPei> list_wList=gongDanMingXi.list;
 | 
			
		||||
					int chao=(list_wList.size()+curr_gzz.notFinished+curr_gzz.renWuList.size())-curr_gzz.maxRenWu;
 | 
			
		||||
					logger.info(listGzz.size());
 | 
			
		||||
					if(chao<=cfhs||index==list_show.size()-1){
 | 
			
		||||
						logger.info("11=="+listGzz.get(gzz_index));
 | 
			
		||||
						//如果当前待分配+此工作站未完成+已分配任务数  小于最大任务数 //将当前任务分配到此工作站
 | 
			
		||||
						for (FenPei fenPei : list_wList) {
 | 
			
		||||
							curr_gzz.renWuList.add(fenPei);
 | 
			
		||||
							curr_gzz.RongQIHaoMap.put(fenPei.rqh,"");
 | 
			
		||||
							curr_gzz.GongZuoZhongXinMap.put(fenPei.gzzx,"");
 | 
			
		||||
						}
 | 
			
		||||
						if(index==list_show.size()-1){
 | 
			
		||||
							//最后一个工单
 | 
			
		||||
							gzzMap.put(curr_gzz.code, curr_gzz);
 | 
			
		||||
						}
 | 
			
		||||
					}else{
 | 
			
		||||
						logger.info("2=="+listGzz.get(gzz_index));
 | 
			
		||||
						gzzMap.put(curr_gzz.code, curr_gzz);
 | 
			
		||||
						//如果当前待分配+此工作站未完成+已分配任务数  大于最大任务数 //将当前任务分配到下个工作站
 | 
			
		||||
						gzz_index=gzz_index+1;
 | 
			
		||||
						curr_gzz=listGzz.get(gzz_index);
 | 
			
		||||
						for (FenPei fenPei : list_wList) {
 | 
			
		||||
							curr_gzz.renWuList.add(fenPei);
 | 
			
		||||
							curr_gzz.RongQIHaoMap.put(fenPei.rqh,"");
 | 
			
		||||
							curr_gzz.GongZuoZhongXinMap.put(fenPei.gzzx,"");
 | 
			
		||||
						}
 | 
			
		||||
						if(index==list_show.size()-1){
 | 
			
		||||
							//最后一个工单
 | 
			
		||||
							gzzMap.put(curr_gzz.code, curr_gzz);
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
						
 | 
			
		||||
				}
 | 
			
		||||
					
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			
 | 
			
		||||
		}
 | 
			
		||||
		int fenPeiCount=0;
 | 
			
		||||
		for (String  key : gzzMap.keySet()) {
 | 
			
		||||
| 
						 | 
				
			
			@ -471,7 +492,7 @@ public class DefaultNewWaveManager extends DefaultBaseManager implements
 | 
			
		|||
					}
 | 
			
		||||
					task.setBillCode(fenPei.gdh+"-"+lx+"-"+fenPei.chf_fz);
 | 
			
		||||
					task.setEndRegion(gongZuoZhan.code);
 | 
			
		||||
					task.setAgvStatus(1);//下发
 | 
			
		||||
					//task.setAgvStatus(1);//下发
 | 
			
		||||
					this.commonDao.store(task);
 | 
			
		||||
					logger.info("one:"+task.getBillCode()+"---"+task.getEndRegion()+"--two:-"+task.getOldGzz()+"---"+task.getOldZrw()+"--three:-"+fenPei.gdh+"-"+fenPei.chf_fz+"-----"+gongZuoZhan.code);
 | 
			
		||||
				}
 | 
			
		||||
| 
						 | 
				
			
			@ -490,6 +511,63 @@ public class DefaultNewWaveManager extends DefaultBaseManager implements
 | 
			
		|||
		session.close();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public GongZuoZhan PiPeiGongZuoZhanForGzzxAndRqh(List<GongZuoZhan>listGzz,GongDanMingXi gongDanMingXi,int cfhs){
 | 
			
		||||
			List<FenPei> list_wList=gongDanMingXi.list;
 | 
			
		||||
			GongZuoZhan check=listGzz.get(0);
 | 
			
		||||
			int max_rqh_count=0;
 | 
			
		||||
			int max_gzzx=0;
 | 
			
		||||
			for (GongZuoZhan gzz : listGzz) {
 | 
			
		||||
				int chao=(list_wList.size()+gzz.notFinished+gzz.renWuList.size())-gzz.maxRenWu;
 | 
			
		||||
				logger.info(listGzz.size());
 | 
			
		||||
				if(chao>cfhs){
 | 
			
		||||
					continue;
 | 
			
		||||
				}
 | 
			
		||||
				
 | 
			
		||||
				int rqh_count=0;
 | 
			
		||||
				int gzzx=0;
 | 
			
		||||
				for (FenPei fenPei : list_wList) {
 | 
			
		||||
					if(gzz.GongZuoZhongXinMap.containsKey(fenPei.gzzx)){
 | 
			
		||||
						gzzx=1;
 | 
			
		||||
					}
 | 
			
		||||
					if(gzz.RongQIHaoMap.containsKey(fenPei.rqh)){
 | 
			
		||||
						rqh_count=rqh_count+1;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				Boolean isPiPeiGzzx=true;
 | 
			
		||||
				if(isPiPeiGzzx){
 | 
			
		||||
					if(max_gzzx==0 && gzzx==0 && rqh_count>max_rqh_count){
 | 
			
		||||
						//如果工作中心未匹配过,且本次未匹配到工作中心  容器号 匹配 度大优先
 | 
			
		||||
						max_rqh_count=rqh_count;
 | 
			
		||||
						max_gzzx=gzzx;
 | 
			
		||||
						check=gzz;
 | 
			
		||||
					}else if(max_gzzx==0 && gzzx==1 ){
 | 
			
		||||
						//如果工作中心未匹配过,本次匹配到工作中心
 | 
			
		||||
						max_rqh_count=rqh_count;
 | 
			
		||||
						max_gzzx=gzzx;
 | 
			
		||||
						check=gzz;
 | 
			
		||||
						
 | 
			
		||||
					}else if(max_gzzx==1 &&gzzx==1 && rqh_count>max_rqh_count){
 | 
			
		||||
						//如果匹配过工作中心,且本次匹配到工作中心; 容器号匹配度大优先
 | 
			
		||||
						max_rqh_count=rqh_count;
 | 
			
		||||
						max_gzzx=gzzx;
 | 
			
		||||
						check=gzz;
 | 
			
		||||
						
 | 
			
		||||
					}
 | 
			
		||||
				}else{
 | 
			
		||||
					if(rqh_count>max_rqh_count){
 | 
			
		||||
						//如果工作中心未匹配过,且本次未匹配到工作中心  容器号 匹配 度大优先
 | 
			
		||||
						max_rqh_count=rqh_count;
 | 
			
		||||
						max_gzzx=gzzx;
 | 
			
		||||
						check=gzz;
 | 
			
		||||
					}
 | 
			
		||||
				}	
 | 
			
		||||
			}
 | 
			
		||||
			logger.info("------------------------匹配容器号和工作中心-----------------------------------------------");
 | 
			
		||||
			logger.info("容器号匹配次数:"+max_rqh_count+"		工作中心匹配次数:"+max_gzzx+"		工单号:"+gongDanMingXi.gdh+"		工作站:"+check.code);
 | 
			
		||||
			logger.info("------------------------匹配容器号和工作中心-----------------------------------------------");
 | 
			
		||||
			return check;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
	public List<GongZuoZhan> FaiXuGzz(Map<String, GongZuoZhan> gzzMap){
 | 
			
		||||
		List<GongZuoZhan> list =new ArrayList<DefaultNewWaveManager.GongZuoZhan>();
 | 
			
		||||
| 
						 | 
				
			
			@ -515,6 +593,9 @@ public class DefaultNewWaveManager extends DefaultBaseManager implements
 | 
			
		|||
		public int maxRenWu;
 | 
			
		||||
		public int notFinished =0;
 | 
			
		||||
		public List<FenPei> renWuList=new ArrayList<DefaultNewWaveManager.FenPei>();
 | 
			
		||||
		
 | 
			
		||||
		Map<String, String> GongZuoZhongXinMap = new HashMap<>();
 | 
			
		||||
		Map<String, String> RongQIHaoMap = new HashMap<>();
 | 
			
		||||
		@Override
 | 
			
		||||
		public int compareTo(GongZuoZhan other) {
 | 
			
		||||
			// TODO Auto-generated method stub
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue