no message
							parent
							
								
									6d9461548b
								
							
						
					
					
						commit
						52603ba6e8
					
				| 
						 | 
				
			
			@ -27,254 +27,292 @@ import com.dev.swms.server.utils.interfaceUtil;
 | 
			
		|||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
public class DefaultNewWaveManager extends DefaultBaseManager implements NewWaveManager{
 | 
			
		||||
	private static Logger logger = Logger.getLogger(DefaultNewWaveManager.class); 
 | 
			
		||||
public class DefaultNewWaveManager extends DefaultBaseManager implements
 | 
			
		||||
		NewWaveManager {
 | 
			
		||||
	private static Logger logger = Logger
 | 
			
		||||
			.getLogger(DefaultNewWaveManager.class);
 | 
			
		||||
 | 
			
		||||
	public  void allocateGZZ(List<Long> ids){
 | 
			
		||||
		for(Long id:ids){
 | 
			
		||||
			WaveDoc waveDoc=commonDao.get(WaveDoc.class, id);
 | 
			
		||||
			allocateGZZ(waveDoc.getCode(),getGZZ(NewWaveFlag.LXQ),getGZZ(NewWaveFlag.HJQ),getGZZ(NewWaveFlag.LKQ));
 | 
			
		||||
	public void allocateGZZ(List<Long> ids) {
 | 
			
		||||
		for (Long id : ids) {
 | 
			
		||||
			WaveDoc waveDoc = commonDao.get(WaveDoc.class, id);
 | 
			
		||||
			allocateGZZ(waveDoc.getCode(), getGZZ(NewWaveFlag.LXQ),
 | 
			
		||||
					getGZZ(NewWaveFlag.HJQ), getGZZ(NewWaveFlag.LKQ));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	public  void allocateGZZ(String waveDocCode,List<Long> lx_gzz_ids,List<Long> hj_gzz_ids,List<Long> lk_gzz_ids){
 | 
			
		||||
		Session session = ((HibernateDaoSupport) this.commonDao).getSessionFactory().openSession();
 | 
			
		||||
 | 
			
		||||
	public void allocateGZZ(String waveDocCode, List<Long> lx_gzz_ids,
 | 
			
		||||
			List<Long> hj_gzz_ids, List<Long> lk_gzz_ids) {
 | 
			
		||||
		Session session = ((HibernateDaoSupport) this.commonDao)
 | 
			
		||||
				.getSessionFactory().openSession();
 | 
			
		||||
		/* try { */
 | 
			
		||||
			String sql ="select STUFF((select ','+CONVERT(nvarchar(10),b.id) "
 | 
			
		||||
						+"from task b "
 | 
			
		||||
						+"left join PICK_TICKET_DETAIL ptd1 on ptd1.id=b.PICK_TICKET_DETAIL_ID   "
 | 
			
		||||
						+"left join PICK_TICKET pt1 on pt1.id=ptd1.PICK_TICKET_ID "
 | 
			
		||||
						+"left join LOCATION loc2 on loc2.id=b.SRC_LOC_ID "
 | 
			
		||||
						+"left join ITEM_KEY ik2 on ik2.id=b.ITEM_KEY_ID "
 | 
			
		||||
						+"left join item item2 on item2.id=ik2.ITEM_ID "
 | 
			
		||||
						+"where 1=1 and b.BILLCODE=t.BILLCODE and pt1.BILL_TYPE_ID=1094  and loc2.id=loc.id  and item2.id=item.id "
 | 
			
		||||
						//" and b.PLAN_QUANTITY_MU-b.MOVED_QUANTITY_MU>0 "+
 | 
			
		||||
						+" for xml Path('')),1,1,'') as taskId,"
 | 
			
		||||
		String sql = "select STUFF((select ','+CONVERT(nvarchar(10),b.id) "
 | 
			
		||||
				+ "from task b "
 | 
			
		||||
				+ "left join PICK_TICKET_DETAIL ptd1 on ptd1.id=b.PICK_TICKET_DETAIL_ID   "
 | 
			
		||||
				+ "left join PICK_TICKET pt1 on pt1.id=ptd1.PICK_TICKET_ID "
 | 
			
		||||
				+ "left join LOCATION loc2 on loc2.id=b.SRC_LOC_ID "
 | 
			
		||||
				+ "left join ITEM_KEY ik2 on ik2.id=b.ITEM_KEY_ID "
 | 
			
		||||
				+ "left join item item2 on item2.id=ik2.ITEM_ID "
 | 
			
		||||
				+ "where 1=1 and b.BILLCODE=t.BILLCODE and pt1.BILL_TYPE_ID=1094  and loc2.id=loc.id  and item2.id=item.id "
 | 
			
		||||
				// " 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,"
 | 
			
		||||
				+ "max(t.END_REGION) as gzz,"
 | 
			
		||||
						+"sum(t.PLAN_QUANTITY_MU-t.MOVED_QUANTITY_MU) as jhsl,"
 | 
			
		||||
				+ "sum(t.PLAN_QUANTITY_MU-t.MOVED_QUANTITY_MU) as jhsl,"
 | 
			
		||||
				+ "MAX(s2.LP) as rqh ,"
 | 
			
		||||
				+ "t.BILLCODE as zrwh,"
 | 
			
		||||
				+ "MAX(pt.code) as gdh,"
 | 
			
		||||
				+ "MAX(pt.LOGISTICS_COMPANY) as gzzx,"
 | 
			
		||||
				+ "loc.code as kwh,"
 | 
			
		||||
				+ "max(t.agv_Status) as rwzt,"
 | 
			
		||||
						+"max(item.GOOD_TYPE) as wllx,"
 | 
			
		||||
				+ "max(item.GOOD_TYPE) as wllx,"
 | 
			
		||||
				+ "max(t.strBill8) as twl "
 | 
			
		||||
						+"from task t   "
 | 
			
		||||
						+"left join PICK_TICKET_DETAIL ptd on ptd.id=t.PICK_TICKET_DETAIL_ID   "
 | 
			
		||||
						+"left join PICK_TICKET pt on pt.id=ptd.PICK_TICKET_ID "   
 | 
			
		||||
						+"left join LOCATION loc on loc.id=t.SRC_LOC_ID   "
 | 
			
		||||
						+"left join ZONE z on z.id=loc.ZONE_ID   "
 | 
			
		||||
						+"left join ITEM_KEY ik on ik.id=t.ITEM_KEY_ID  " 
 | 
			
		||||
						+"left join ITEM item on item.id=ik.ITEM_ID "
 | 
			
		||||
						+"left join STOCK s2 on s2.id=t.SRC_LP   "
 | 
			
		||||
						+"left join STOCK s1 on s1.id=loc.stock "
 | 
			
		||||
						+"left join WAVE_DOC wd on wd.id=t.WAVE_DOC_ID  "
 | 
			
		||||
						+"where 1=1 and pt.BILL_TYPE_ID=1094 and wd.code='"+waveDocCode+"' and t.WAVE_DOC_ID is not null "
 | 
			
		||||
						//+ " t.PLAN_QUANTITY_MU-t.MOVED_QUANTITY_MU>0 and t.agv_status=0 "
 | 
			
		||||
						+"group by pt.code,t.BILLCODE,item.id,item.code,item.BE_MARK_WEIGHT,loc.id,loc.code,ik.PROP_C1,ik.PROP_C2,ik.PROP_C3,ik.PROP_D1,ik.PROP_D2,item.ISBOM "
 | 
			
		||||
						+"order by min(t.skips ),max(loc.code) asc, item.id,pt.code,t.BILLCODE ";
 | 
			
		||||
				+ "from task t   "
 | 
			
		||||
				+ "left join PICK_TICKET_DETAIL ptd on ptd.id=t.PICK_TICKET_DETAIL_ID   "
 | 
			
		||||
				+ "left join PICK_TICKET pt on pt.id=ptd.PICK_TICKET_ID "
 | 
			
		||||
				+ "left join LOCATION loc on loc.id=t.SRC_LOC_ID   "
 | 
			
		||||
				+ "left join ZONE z on z.id=loc.ZONE_ID   "
 | 
			
		||||
				+ "left join ITEM_KEY ik on ik.id=t.ITEM_KEY_ID  "
 | 
			
		||||
				+ "left join ITEM item on item.id=ik.ITEM_ID "
 | 
			
		||||
				+ "left join STOCK s2 on s2.id=t.SRC_LP   "
 | 
			
		||||
				+ "left join STOCK s1 on s1.id=loc.stock "
 | 
			
		||||
				+ "left join WAVE_DOC wd on wd.id=t.WAVE_DOC_ID  "
 | 
			
		||||
				+ "where 1=1 and pt.BILL_TYPE_ID=1094 and wd.code='"
 | 
			
		||||
				+ waveDocCode
 | 
			
		||||
				+ "' and t.WAVE_DOC_ID is not null "
 | 
			
		||||
				// +
 | 
			
		||||
				// " t.PLAN_QUANTITY_MU-t.MOVED_QUANTITY_MU>0 and t.agv_status=0 "
 | 
			
		||||
				+ "group by pt.code,t.BILLCODE,item.id,item.code,item.BE_MARK_WEIGHT,loc.id,loc.code,ik.PROP_C1,ik.PROP_C2,ik.PROP_C3,ik.PROP_D1,ik.PROP_D2,item.ISBOM "
 | 
			
		||||
				+ "order by min(t.skips ),max(loc.code) asc, item.id,pt.code,t.BILLCODE ";
 | 
			
		||||
		logger.info(sql);
 | 
			
		||||
		Query query = session.createSQLQuery(sql);
 | 
			
		||||
			List<Object[]> list= (List<Object[]>)query.list();
 | 
			
		||||
			int dataSize=list.size();
 | 
			
		||||
		List<Object[]> list = (List<Object[]>) query.list();
 | 
			
		||||
		int dataSize = list.size();
 | 
			
		||||
 | 
			
		||||
			List<FenPei> list_fenpei= new ArrayList<FenPei>();
 | 
			
		||||
			List<FenPei> list_fenpei_wgzz= new ArrayList<FenPei>();//无需分配工作站数据
 | 
			
		||||
			for(int i=0;i<list.size();i++){
 | 
			
		||||
				FenPei bean=new FenPei();
 | 
			
		||||
				bean.tsakId=getValueString(list.get(i),0);
 | 
			
		||||
				bean.liaohao=getValueString(list.get(i),1);
 | 
			
		||||
				bean.kuqu=getValueLong(list.get(i),2);
 | 
			
		||||
				bean.gzz=getValueString(list.get(i),3);
 | 
			
		||||
				bean.jhsl=getValueFloat(list.get(i),4);
 | 
			
		||||
				bean.rqh=getValueString(list.get(i),5);
 | 
			
		||||
				bean.zrwh=getValueString(list.get(i),6);
 | 
			
		||||
				bean.gdh=getValueString(list.get(i),7);
 | 
			
		||||
				bean.gzzx=getValueString(list.get(i),8);
 | 
			
		||||
				bean.kwh=getValueString(list.get(i),9);
 | 
			
		||||
				bean.rwzt=getValueInt(list.get(i),10);
 | 
			
		||||
				bean.wllx=getValueString(list.get(i),11);
 | 
			
		||||
				bean.twl=getValueString(list.get(i),12);
 | 
			
		||||
				if(bean.kuqu.equals(NewWaveFlag.LXQ)||bean.kuqu.equals(NewWaveFlag.HJQ)||bean.kuqu.equals(NewWaveFlag.LKQ)){
 | 
			
		||||
		List<FenPei> list_fenpei = new ArrayList<FenPei>();
 | 
			
		||||
		List<FenPei> list_fenpei_wgzz = new ArrayList<FenPei>();// 无需分配工作站数据
 | 
			
		||||
		for (int i = 0; i < list.size(); i++) {
 | 
			
		||||
			FenPei bean = new FenPei();
 | 
			
		||||
			bean.tsakId = getValueString(list.get(i), 0);
 | 
			
		||||
			bean.liaohao = getValueString(list.get(i), 1);
 | 
			
		||||
			bean.kuqu = getValueLong(list.get(i), 2);
 | 
			
		||||
			bean.gzz = getValueString(list.get(i), 3);
 | 
			
		||||
			bean.jhsl = getValueFloat(list.get(i), 4);
 | 
			
		||||
			bean.rqh = getValueString(list.get(i), 5);
 | 
			
		||||
			bean.zrwh = getValueString(list.get(i), 6);
 | 
			
		||||
			bean.gdh = getValueString(list.get(i), 7);
 | 
			
		||||
			bean.gzzx = getValueString(list.get(i), 8);
 | 
			
		||||
			bean.kwh = getValueString(list.get(i), 9);
 | 
			
		||||
			bean.rwzt = getValueInt(list.get(i), 10);
 | 
			
		||||
			String wllx_str = getValueString(list.get(i), 11);
 | 
			
		||||
			if ("大件".equals(wllx_str)) {
 | 
			
		||||
				wllx_str = "big";
 | 
			
		||||
			} else {
 | 
			
		||||
				wllx_str = "small";
 | 
			
		||||
			}
 | 
			
		||||
			bean.wllx = wllx_str;
 | 
			
		||||
 | 
			
		||||
			bean.twl = getValueString(list.get(i), 12);
 | 
			
		||||
			if (bean.kuqu.equals(NewWaveFlag.LXQ)
 | 
			
		||||
					|| bean.kuqu.equals(NewWaveFlag.HJQ)
 | 
			
		||||
					|| bean.kuqu.equals(NewWaveFlag.LKQ)) {
 | 
			
		||||
				list_fenpei.add(bean);
 | 
			
		||||
				}else{
 | 
			
		||||
			} else {
 | 
			
		||||
				list_fenpei_wgzz.add(bean);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
				logger.info(bean.gdh+"---"+bean.twl);
 | 
			
		||||
			// logger.info(bean.gdh+"---"+bean.twl);
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
			//1个工单对应一个头物料拆分号。
 | 
			
		||||
			//工单号  ;				容器号  ;			料号   			物料类型  				;	库区  ;				工作中心 			//头物料 							拆分号        工单总行数      
 | 
			
		||||
			//1100382814B			X8001315			A0101					A						3#料箱区			kanban				512-00004567-F04B			1					5
 | 
			
		||||
			//1100382814B			X8001315			A0102					A						3#料箱区			kanban				512-00004567-F04B			1					5
 | 
			
		||||
			//1100382814B			X8001315			A0101					A						3#料箱区			kanban				512-00004567-F04B			1					5
 | 
			
		||||
			//1100382814B			X8001315			A0102					A						3#料箱区			kanban				512-00004567-F04B			1					5
 | 
			
		||||
			//1100382814B			X8001315			A0101					A						3#料箱区			kanban				512-00004567-F04B			1					5
 | 
			
		||||
			//1100382814A			X8001315			A0102					A						3#料箱区			kanban				512-00004567-F04A
 | 
			
		||||
			//1100382814A			X8001315			A0101					A						3#料箱区			kanban				512-00004567-F04A
 | 
			
		||||
			//1100382814A			X8001315			A0102					A						3#料箱区			kanban				512-00004567-F04A
 | 
			
		||||
			//1100382814A			X8001315			A0101					A						3#料箱区			kanban				512-00004567-F04A
 | 
			
		||||
			//1100382814A			X8001315			A0102					A						3#料箱区			kanban				512-00004567-F04A
 | 
			
		||||
		// 1个工单对应一个头物料拆分号。
 | 
			
		||||
		// 工单号 ; 容器号 ; 料号 物料类型 ; 库区 ; 工作中心 //头物料 拆分号 工单总行数
 | 
			
		||||
		// 1100382814B X8001315 A0101 A 3#料箱区 kanban 512-00004567-F04B 1 5
 | 
			
		||||
		// 1100382814B X8001315 A0102 A 3#料箱区 kanban 512-00004567-F04B 1 5
 | 
			
		||||
		// 1100382814B X8001315 A0101 A 3#料箱区 kanban 512-00004567-F04B 1 5
 | 
			
		||||
		// 1100382814B X8001315 A0102 A 3#料箱区 kanban 512-00004567-F04B 1 5
 | 
			
		||||
		// 1100382814B X8001315 A0101 A 3#料箱区 kanban 512-00004567-F04B 1 5
 | 
			
		||||
		// 1100382814A X8001315 A0102 A 3#料箱区 kanban 512-00004567-F04A
 | 
			
		||||
		// 1100382814A X8001315 A0101 A 3#料箱区 kanban 512-00004567-F04A
 | 
			
		||||
		// 1100382814A X8001315 A0102 A 3#料箱区 kanban 512-00004567-F04A
 | 
			
		||||
		// 1100382814A X8001315 A0101 A 3#料箱区 kanban 512-00004567-F04A
 | 
			
		||||
		// 1100382814A X8001315 A0102 A 3#料箱区 kanban 512-00004567-F04A
 | 
			
		||||
 | 
			
		||||
			//计算同一工单总行数。
 | 
			
		||||
			  Map<String, List<FenPei> > gdCount = new HashMap<>(); 
 | 
			
		||||
		// 计算同一工单总行数。
 | 
			
		||||
		Map<String, List<FenPei>> gdCount = new HashMap<>();
 | 
			
		||||
 | 
			
		||||
		for (FenPei fenPei : list_fenpei) {
 | 
			
		||||
				 if(((java.util.Map) gdCount).containsKey(fenPei.gdh)){
 | 
			
		||||
					 	List<FenPei> list_count=gdCount.get(fenPei.gdh);
 | 
			
		||||
			String key_gd_wl = fenPei.gdh + fenPei.wllx;
 | 
			
		||||
			if (((java.util.Map) gdCount).containsKey(key_gd_wl)) {
 | 
			
		||||
				List<FenPei> list_count = gdCount.get(key_gd_wl);
 | 
			
		||||
				list_count.add(fenPei);
 | 
			
		||||
					 	gdCount.put(fenPei.gdh, list_count);
 | 
			
		||||
				 }else{
 | 
			
		||||
						List<FenPei> list_count= new ArrayList<FenPei>();
 | 
			
		||||
				gdCount.put(key_gd_wl, list_count);
 | 
			
		||||
			} else {
 | 
			
		||||
				List<FenPei> list_count = new ArrayList<FenPei>();
 | 
			
		||||
				list_count.add(fenPei);
 | 
			
		||||
						 gdCount.put(fenPei.gdh, list_count);
 | 
			
		||||
				gdCount.put(key_gd_wl, list_count);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
			 int sumCout=0;
 | 
			
		||||
			 //记录每个工单 的数目
 | 
			
		||||
		int sumCout = 0;
 | 
			
		||||
		// 记录每个工单 的数目
 | 
			
		||||
 | 
			
		||||
			 List<GdPaiXu> gd_paixuList =new ArrayList<GdPaiXu>();
 | 
			
		||||
		List<GdPaiXu> gd_paixuList = new ArrayList<GdPaiXu>();
 | 
			
		||||
		for (String key : gdCount.keySet()) {
 | 
			
		||||
					logger.info("gdh:	"+key+"	count:"+gdCount.get(key).size());
 | 
			
		||||
					sumCout=sumCout+gdCount.get(key).size();
 | 
			
		||||
					List<FenPei> list_ll1=gdCount.get(key);
 | 
			
		||||
			// logger.info("gdh:	"+key+"	count:"+gdCount.get(key).size());
 | 
			
		||||
			sumCout = sumCout + gdCount.get(key).size();
 | 
			
		||||
			List<FenPei> list_ll1 = gdCount.get(key);
 | 
			
		||||
			Collections.sort(list_ll1);
 | 
			
		||||
					GdPaiXu gdPaiXu=new GdPaiXu(key, list_ll1);
 | 
			
		||||
			GdPaiXu gdPaiXu = new GdPaiXu(key, list_ll1);
 | 
			
		||||
			gd_paixuList.add(gdPaiXu);
 | 
			
		||||
		}
 | 
			
		||||
		Collections.sort(gd_paixuList);
 | 
			
		||||
			logger.info("sumCout"+sumCout+"___dataSize:"+dataSize);
 | 
			
		||||
		logger.info("sumCout" + sumCout + "___dataSize:" + dataSize);
 | 
			
		||||
 | 
			
		||||
			//先根据头物料分组   如果头物料相同 且工单总行数 差异小于4的工单分到一个组里面  (尽量分配到同一工作站)
 | 
			
		||||
		// 先根据头物料分组 如果头物料相同 且工单总行数 差异小于4的工单分到一个组里面 (尽量分配到同一工作站)
 | 
			
		||||
 | 
			
		||||
		Map<String, List<GdPaiXu>> touwuliao_map = new HashMap<>();
 | 
			
		||||
 | 
			
		||||
		for (GdPaiXu gdPaiXu : gd_paixuList) {
 | 
			
		||||
 | 
			
		||||
				 //获取当前头物料
 | 
			
		||||
				 String twl=gdPaiXu.twl;
 | 
			
		||||
				 String gdh=gdPaiXu.gdh;
 | 
			
		||||
				 //获取当前工单的数量
 | 
			
		||||
				 int currCount=gdPaiXu.hangshu;
 | 
			
		||||
				 logger.info("---gdh:"+gdh+"		currCount:"+currCount);
 | 
			
		||||
				 //在touwuliao_map中进行匹配
 | 
			
		||||
				 boolean isFind=false;
 | 
			
		||||
			// 获取当前头物料
 | 
			
		||||
			String twl = gdPaiXu.twl;
 | 
			
		||||
			String gdh = gdPaiXu.gdh;
 | 
			
		||||
			// 获取当前工单的数量
 | 
			
		||||
			int currCount = gdPaiXu.hangshu;
 | 
			
		||||
			// logger.info("---gdh:"+gdh+"		currCount:"+currCount);
 | 
			
		||||
			// 在touwuliao_map中进行匹配
 | 
			
		||||
			boolean isFind = false;
 | 
			
		||||
			for (String twlKey : touwuliao_map.keySet()) {
 | 
			
		||||
					 String twl_in=touwuliao_map.get(twlKey).get(0).twl;
 | 
			
		||||
					 String gdh_in=touwuliao_map.get(twlKey).get(0).gdh;
 | 
			
		||||
					 int currCount_in=touwuliao_map.get(twlKey).get(0).hangshu;
 | 
			
		||||
					 if(twl_in.equals(twl)&&Math.abs(currCount-currCount_in)<=4){
 | 
			
		||||
						 //在分配好的数据中找到了相同的头物料 且 数量差小于4
 | 
			
		||||
						 List<GdPaiXu> old=touwuliao_map.get(twlKey);
 | 
			
		||||
				String twl_in = touwuliao_map.get(twlKey).get(0).twl;
 | 
			
		||||
				String gdh_in = touwuliao_map.get(twlKey).get(0).gdh;
 | 
			
		||||
				int currCount_in = touwuliao_map.get(twlKey).get(0).hangshu;
 | 
			
		||||
				if (twl_in.equals(twl)
 | 
			
		||||
						&& Math.abs(currCount - currCount_in) <= 4) {
 | 
			
		||||
					// 在分配好的数据中找到了相同的头物料 且 数量差小于4
 | 
			
		||||
					List<GdPaiXu> old = touwuliao_map.get(twlKey);
 | 
			
		||||
					old.add(gdPaiXu);
 | 
			
		||||
					touwuliao_map.put(twlKey, old);
 | 
			
		||||
						 isFind=true;
 | 
			
		||||
						 break ;
 | 
			
		||||
					isFind = true;
 | 
			
		||||
					break;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
				 if(!isFind){
 | 
			
		||||
					 //未匹配到数据,自己单独一组
 | 
			
		||||
					 List<GdPaiXu> llist=new ArrayList<GdPaiXu>();
 | 
			
		||||
			if (!isFind) {
 | 
			
		||||
				// 未匹配到数据,自己单独一组
 | 
			
		||||
				List<GdPaiXu> llist = new ArrayList<GdPaiXu>();
 | 
			
		||||
				llist.add(gdPaiXu);
 | 
			
		||||
					 touwuliao_map.put(twl+"_"+gdh,llist);
 | 
			
		||||
				touwuliao_map.put(twl + "_" + gdh, llist);
 | 
			
		||||
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
				 
 | 
			
		||||
		}
 | 
			
		||||
		logger.info("-----------------------------------------------------------------------");
 | 
			
		||||
		logger.info("-----------------------------------------------------------------------");
 | 
			
		||||
		logger.info("---------------------------打印计算结果--------------------------------------------");
 | 
			
		||||
			 int twl_count=0;
 | 
			
		||||
		int twl_count = 0;
 | 
			
		||||
		for (String twlKey : touwuliao_map.keySet()) {
 | 
			
		||||
				 List<GdPaiXu> list_show=touwuliao_map.get(twlKey);
 | 
			
		||||
			List<GdPaiXu> list_show = touwuliao_map.get(twlKey);
 | 
			
		||||
			for (GdPaiXu fenPei2 : list_show) {
 | 
			
		||||
						logger.info("twl"+fenPei2.twl+"		GDH:"+fenPei2.gdh+"		twlKey:"+twlKey+"		GDHCount:"+fenPei2.hangshu);
 | 
			
		||||
				logger.info("twl" + fenPei2.twl + "		GDH:" + fenPei2.gdh+ "		twlKey:" + twlKey + "		GDHCount:"+ fenPei2.hangshu);
 | 
			
		||||
				twl_count++;
 | 
			
		||||
						StringBuffer rqm =new StringBuffer();
 | 
			
		||||
				StringBuffer rqm = new StringBuffer();
 | 
			
		||||
				for (FenPei fff : fenPei2.list) {
 | 
			
		||||
							rqm.append(fff.rqh+",");
 | 
			
		||||
					rqm.append(fff.rqh + ",");
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
			}
 | 
			
		||||
			logger.info("-----------------------------------------------------------------------");
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
			logger.info("twl_count"+twl_count+"___dataSize:"+dataSize);
 | 
			
		||||
		logger.info("twl_count" + twl_count + "___dataSize:" + dataSize);
 | 
			
		||||
 | 
			
		||||
			//计算没个容器号出现得次数(在每个头物料得分组里面)
 | 
			
		||||
		// 计算没个容器号出现得次数(在每个头物料得分组里面)
 | 
			
		||||
 | 
			
		||||
		logger.info("-------------------------------------------------------------------------------打印工单容器号----------------------------------------------------------------------------------------------------------------------------");
 | 
			
		||||
 | 
			
		||||
		for (String twlKey : touwuliao_map.keySet()) {
 | 
			
		||||
				 List<GdPaiXu> list_show=touwuliao_map.get(twlKey);
 | 
			
		||||
			List<GdPaiXu> list_show = touwuliao_map.get(twlKey);
 | 
			
		||||
 | 
			
		||||
				  Map<String, Integer > rq_showTime = new HashMap<>(); 
 | 
			
		||||
			Map<String, Integer> rq_showTime = new HashMap<>();
 | 
			
		||||
 | 
			
		||||
			for (GdPaiXu fenPei2 : list_show) {
 | 
			
		||||
				Set<String> set_rqh = new HashSet<>();
 | 
			
		||||
						StringBuffer rqm_str =new StringBuffer();
 | 
			
		||||
				StringBuffer rqm_str = new StringBuffer();
 | 
			
		||||
				for (FenPei fff : fenPei2.list) {
 | 
			
		||||
							//通过set记录容器号
 | 
			
		||||
					// 通过set记录容器号
 | 
			
		||||
					set_rqh.add(fff.rqh);
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
						for(String rqh : set_rqh){
 | 
			
		||||
							if(rq_showTime.containsKey(rqh)){
 | 
			
		||||
								int stt=rq_showTime.get(rqh);
 | 
			
		||||
								rq_showTime.put(rqh, stt+1);
 | 
			
		||||
								rqm_str.append(rqh+"    __"+stt+"("+rq_showTime.get(rqh)+")"+",");
 | 
			
		||||
							}else{
 | 
			
		||||
				for (String rqh : set_rqh) {
 | 
			
		||||
					if (rq_showTime.containsKey(rqh)) {
 | 
			
		||||
						int stt = rq_showTime.get(rqh);
 | 
			
		||||
						rq_showTime.put(rqh, stt + 1);
 | 
			
		||||
						rqm_str.append(rqh + "    __" + stt + "("+ rq_showTime.get(rqh) + ")" + ",");
 | 
			
		||||
					} else {
 | 
			
		||||
						rq_showTime.put(rqh, 1);
 | 
			
		||||
								rqm_str.append(rqh+"    __"+0+"("+rq_showTime.get(rqh)+")"+",");
 | 
			
		||||
						rqm_str.append(rqh + "    __" + 0 + "("+ rq_showTime.get(rqh) + ")" + ",");
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
						for(String key:rq_showTime.keySet()){
 | 
			
		||||
			}
 | 
			
		||||
			// 给touwuliao_map的 中 按照容器出现次数进行排序
 | 
			
		||||
			List<GdPaiXu> list_show_new = new ArrayList<>();
 | 
			
		||||
			for (GdPaiXu fenPei2 : list_show) {
 | 
			
		||||
				List<FenPei> list_new = new ArrayList<>();
 | 
			
		||||
				for (FenPei f1 : fenPei2.list) {
 | 
			
		||||
					f1.show_time = rq_showTime.get(f1.rqh);
 | 
			
		||||
					f1.paixu_type = 1;
 | 
			
		||||
					list_new.add(f1);
 | 
			
		||||
				}
 | 
			
		||||
				Collections.sort(list_new);
 | 
			
		||||
				fenPei2.list = list_new;
 | 
			
		||||
				list_show_new.add(fenPei2);
 | 
			
		||||
			}
 | 
			
		||||
			touwuliao_map.put(twlKey, list_show_new);
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
						logger.info("-----------"+rqm_str.toString());
 | 
			
		||||
				 	}
 | 
			
		||||
				 	logger.info("----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------");
 | 
			
		||||
				 
 | 
			
		||||
			 }
 | 
			
		||||
		logger.info("-----------------------------------------------------------------------");
 | 
			
		||||
		logger.info("-----------------------------------------------------------------------");
 | 
			
		||||
		logger.info("---------------------------打印计算结果-------------------------------------------");
 | 
			
		||||
 | 
			
		||||
		// 计算拆分号 (为了15个为一组的工单) 拆分号等于 工单总行数 /15(可配置) 根据容器号。物料
 | 
			
		||||
 | 
			
		||||
		for (String twlKey : touwuliao_map.keySet()) {
 | 
			
		||||
			List<GdPaiXu> list_show = touwuliao_map.get(twlKey);
 | 
			
		||||
			for (GdPaiXu fenPei2 : list_show) {
 | 
			
		||||
				logger.info("twl" + fenPei2.twl + "		GDH:" + fenPei2.gdh+ "		twlKey:" + twlKey + "		GDHCount:"+ fenPei2.hangshu);
 | 
			
		||||
				twl_count++;
 | 
			
		||||
				StringBuffer rqm = new StringBuffer();
 | 
			
		||||
				for (FenPei fff : fenPei2.list) {
 | 
			
		||||
					rqm.append(fff.rqh + "("+fff.show_time+")		");
 | 
			
		||||
				}
 | 
			
		||||
				logger.info(rqm.toString());
 | 
			
		||||
			}
 | 
			
		||||
			logger.info("--------------------------------------------------------------------------------------------------------------------------------------------------");
 | 
			
		||||
			logger.info("--------------------------------------------------------------------------------------------------------------------------------------------------");
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
		// 写入数据库
 | 
			
		||||
 | 
			
		||||
			
 | 
			
		||||
			
 | 
			
		||||
			//写入数据库
 | 
			
		||||
 | 
			
		||||
			
 | 
			
		||||
	/*	}catch (Exception e) {
 | 
			
		||||
			logger.info(e.toString());
 | 
			
		||||
			session.close();
 | 
			
		||||
		}finally {
 | 
			
		||||
			session.close();
 | 
			
		||||
		}*/
 | 
			
		||||
		/*
 | 
			
		||||
		 * }catch (Exception e) { logger.info(e.toString()); session.close();
 | 
			
		||||
		 * }finally { session.close(); }
 | 
			
		||||
		 */
 | 
			
		||||
		session.close();
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	public void writeToDb(	List<FenPei> list_fenpei){
 | 
			
		||||
		for(FenPei fp:list_fenpei ){
 | 
			
		||||
			String[] ids=fp.tsakId.split(",");
 | 
			
		||||
			for(int i=0;i<=ids.length;i++){
 | 
			
		||||
				Task task=this.commonDao.get(Task.class, Long.parseLong(ids[i]));
 | 
			
		||||
				//保留原有信息字段做对比分析
 | 
			
		||||
				if(task.getOldGzz()==null){
 | 
			
		||||
	public void writeToDb(List<FenPei> list_fenpei) {
 | 
			
		||||
		for (FenPei fp : list_fenpei) {
 | 
			
		||||
			String[] ids = fp.tsakId.split(",");
 | 
			
		||||
			for (int i = 0; i <= ids.length; i++) {
 | 
			
		||||
				Task task = this.commonDao.get(Task.class,
 | 
			
		||||
						Long.parseLong(ids[i]));
 | 
			
		||||
				// 保留原有信息字段做对比分析
 | 
			
		||||
				if (task.getOldGzz() == null) {
 | 
			
		||||
					task.setOldGzz(task.getEndRegion());
 | 
			
		||||
					task.setOldZrw(task.getBillCode());
 | 
			
		||||
				}
 | 
			
		||||
				//对分析后的数据进行赋值
 | 
			
		||||
				// 对分析后的数据进行赋值
 | 
			
		||||
				task.setEndRegion(null);
 | 
			
		||||
				task.setBillCode(null);
 | 
			
		||||
				this.commonDao.store(task);
 | 
			
		||||
| 
						 | 
				
			
			@ -282,18 +320,17 @@ public class DefaultNewWaveManager extends DefaultBaseManager implements NewWave
 | 
			
		|||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	class GdPaiXu implements Comparable<GdPaiXu> {
 | 
			
		||||
		public String gdh; //工单号
 | 
			
		||||
		public int hangshu;//工单行数
 | 
			
		||||
		public String twl;//头物料
 | 
			
		||||
		public String gdh; // 工单号
 | 
			
		||||
		public int hangshu;// 工单行数
 | 
			
		||||
		public String twl;// 头物料
 | 
			
		||||
		public List<FenPei> list;
 | 
			
		||||
 | 
			
		||||
		public GdPaiXu(String gdh,List<FenPei> list ){
 | 
			
		||||
			this.gdh=gdh;
 | 
			
		||||
			this.hangshu=list.size();
 | 
			
		||||
			this.twl=list.get(0).twl;
 | 
			
		||||
			this.list=list;
 | 
			
		||||
		public GdPaiXu(String gdh, List<FenPei> list) {
 | 
			
		||||
			this.gdh = gdh;
 | 
			
		||||
			this.hangshu = list.size();
 | 
			
		||||
			this.twl = list.get(0).twl;
 | 
			
		||||
			this.list = list;
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -336,8 +373,6 @@ public class DefaultNewWaveManager extends DefaultBaseManager implements NewWave
 | 
			
		|||
		 */
 | 
			
		||||
		public String gdh;
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
		/**
 | 
			
		||||
		 * 工作中心
 | 
			
		||||
		 */
 | 
			
		||||
| 
						 | 
				
			
			@ -364,84 +399,81 @@ public class DefaultNewWaveManager extends DefaultBaseManager implements NewWave
 | 
			
		|||
		 */
 | 
			
		||||
		public String chf;
 | 
			
		||||
 | 
			
		||||
		public int paixu_type=0;
 | 
			
		||||
		public int paixu_type = 0;
 | 
			
		||||
 | 
			
		||||
		public  int show_time=0;
 | 
			
		||||
		public int show_time = 0;
 | 
			
		||||
 | 
			
		||||
		@Override
 | 
			
		||||
		public int compareTo(FenPei old) {
 | 
			
		||||
			// TODO Auto-generated method stub
 | 
			
		||||
 | 
			
		||||
			if(paixu_type==0){
 | 
			
		||||
				try{
 | 
			
		||||
			if (paixu_type == 0) {
 | 
			
		||||
				try {
 | 
			
		||||
					return this.rqh.compareTo(old.rqh);
 | 
			
		||||
				}catch(Exception e){
 | 
			
		||||
				} catch (Exception e) {
 | 
			
		||||
					return 0;
 | 
			
		||||
				}
 | 
			
		||||
			}else{
 | 
			
		||||
				try{
 | 
			
		||||
				     return this.show_time-old.show_time;
 | 
			
		||||
				}catch(Exception e){
 | 
			
		||||
			} else {
 | 
			
		||||
				try {
 | 
			
		||||
					return old.show_time - this.show_time;
 | 
			
		||||
				} catch (Exception e) {
 | 
			
		||||
					return 0;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public int  getValueInt(Object[] obj,int i){
 | 
			
		||||
		int str=-1;
 | 
			
		||||
		try{
 | 
			
		||||
			str=Integer.parseInt(obj[i].toString());
 | 
			
		||||
		}catch(Exception e){
 | 
			
		||||
			logger.info(i+""+e.toString());
 | 
			
		||||
			str=-1;
 | 
			
		||||
	public int getValueInt(Object[] obj, int i) {
 | 
			
		||||
		int str = -1;
 | 
			
		||||
		try {
 | 
			
		||||
			str = Integer.parseInt(obj[i].toString());
 | 
			
		||||
		} catch (Exception e) {
 | 
			
		||||
			logger.info(i + "" + e.toString());
 | 
			
		||||
			str = -1;
 | 
			
		||||
		}
 | 
			
		||||
		return str;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public String  getValueString(Object[] obj,int i){
 | 
			
		||||
		String str="";
 | 
			
		||||
		try{
 | 
			
		||||
			str=(String)obj[i];
 | 
			
		||||
		}catch(Exception e){
 | 
			
		||||
			logger.info(i+""+e.toString());
 | 
			
		||||
			str="";
 | 
			
		||||
	public String getValueString(Object[] obj, int i) {
 | 
			
		||||
		String str = "";
 | 
			
		||||
		try {
 | 
			
		||||
			str = (String) obj[i];
 | 
			
		||||
		} catch (Exception e) {
 | 
			
		||||
			logger.info(i + "" + e.toString());
 | 
			
		||||
			str = "";
 | 
			
		||||
		}
 | 
			
		||||
		return str;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public Long  getValueLong(Object[] obj,int i){
 | 
			
		||||
		Long str=0l;
 | 
			
		||||
		try{
 | 
			
		||||
			str=Long.parseLong(obj[i].toString());
 | 
			
		||||
		}catch(Exception e){
 | 
			
		||||
			logger.info(i+""+e.toString());
 | 
			
		||||
			str=0l;
 | 
			
		||||
	public Long getValueLong(Object[] obj, int i) {
 | 
			
		||||
		Long str = 0l;
 | 
			
		||||
		try {
 | 
			
		||||
			str = Long.parseLong(obj[i].toString());
 | 
			
		||||
		} catch (Exception e) {
 | 
			
		||||
			logger.info(i + "" + e.toString());
 | 
			
		||||
			str = 0l;
 | 
			
		||||
		}
 | 
			
		||||
		return str;
 | 
			
		||||
	}
 | 
			
		||||
	public float  getValueFloat(Object[] obj ,int i){
 | 
			
		||||
		float v=0.0f;
 | 
			
		||||
		try{
 | 
			
		||||
			v=Float.parseFloat(obj[i].toString());
 | 
			
		||||
		}catch(Exception e){
 | 
			
		||||
			v=0;
 | 
			
		||||
			logger.info(i+""+e.toString());
 | 
			
		||||
 | 
			
		||||
	public float getValueFloat(Object[] obj, int i) {
 | 
			
		||||
		float v = 0.0f;
 | 
			
		||||
		try {
 | 
			
		||||
			v = Float.parseFloat(obj[i].toString());
 | 
			
		||||
		} catch (Exception e) {
 | 
			
		||||
			v = 0;
 | 
			
		||||
			logger.info(i + "" + e.toString());
 | 
			
		||||
		}
 | 
			
		||||
		return v;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	public List<Long> getGZZ(Long zone_id){
 | 
			
		||||
		String hql="select id from LocationStorage l where l.type='拣货' and l.warehouseArea.id="+zone_id;//+" and l.beAuto=1";
 | 
			
		||||
		List<Long> ids=commonDao.findByQuery(hql);
 | 
			
		||||
	public List<Long> getGZZ(Long zone_id) {
 | 
			
		||||
		String hql = "select id from LocationStorage l where l.type='拣货' and l.warehouseArea.id="
 | 
			
		||||
				+ zone_id;// +" and l.beAuto=1";
 | 
			
		||||
		List<Long> ids = commonDao.findByQuery(hql);
 | 
			
		||||
		return ids;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue