工作站能效
							parent
							
								
									52603ba6e8
								
							
						
					
					
						commit
						b4d3f96e41
					
				| 
						 | 
				
			
			@ -18,6 +18,7 @@ import org.hibernate.Session;
 | 
			
		|||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
 | 
			
		||||
 | 
			
		||||
import com.dev.energy.server.service.pojo.DefaultBaseManager;
 | 
			
		||||
import com.dev.swms.server.model.base.ShiXiao;
 | 
			
		||||
import com.dev.swms.server.model.inventory.Task;
 | 
			
		||||
import com.dev.swms.server.model.receiving.LibraryTaskType.classification;
 | 
			
		||||
import com.dev.swms.server.model.shipping.NewWaveFlag;
 | 
			
		||||
| 
						 | 
				
			
			@ -35,13 +36,33 @@ public class DefaultNewWaveManager extends DefaultBaseManager implements
 | 
			
		|||
	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));
 | 
			
		||||
			ShiXiao lx_sx=commonDao.get(ShiXiao.class, NewWaveFlag.LKQ);
 | 
			
		||||
			ShiXiao hj_sx=commonDao.get(ShiXiao.class, NewWaveFlag.LKQ);
 | 
			
		||||
			ShiXiao lk_sx=commonDao.get(ShiXiao.class, NewWaveFlag.LKQ);
 | 
			
		||||
			//得到工作站剩余任务行数
 | 
			
		||||
			List<String> lx_codes=getGzzCodes(NewWaveFlag.LXQ);
 | 
			
		||||
			List<String> hj_codes=getGzzCodes(NewWaveFlag.HJQ);
 | 
			
		||||
			List<String> lk_codes=getGzzCodes(NewWaveFlag.LKQ);
 | 
			
		||||
			Map<String, Integer> maps=gzzCount();
 | 
			
		||||
			int lxCount=0;//工作站任务未处理任务数
 | 
			
		||||
			int hjCount=0;
 | 
			
		||||
			int lkCount=0;
 | 
			
		||||
			for(String code:lx_codes){
 | 
			
		||||
				lxCount+=maps.get(code);
 | 
			
		||||
			}
 | 
			
		||||
			for(String code:hj_codes){
 | 
			
		||||
				hjCount+=maps.get(code);
 | 
			
		||||
			}
 | 
			
		||||
			for(String code:lk_codes){
 | 
			
		||||
				lkCount+=maps.get(code);
 | 
			
		||||
			}
 | 
			
		||||
			allocateGZZ(waveDoc.getCode(),NewWaveFlag.LKQ, lx_codes,(int)lx_sx.getTaskD(),(int)lx_sx.getNumber(),lxCount,maps);
 | 
			
		||||
			allocateGZZ(waveDoc.getCode(),NewWaveFlag.HJQ, hj_codes,(int)hj_sx.getTaskD(),(int)hj_sx.getNumber(),hjCount,maps);
 | 
			
		||||
			allocateGZZ(waveDoc.getCode(),NewWaveFlag.LKQ, lk_codes,(int)lk_sx.getTaskD(),(int)lk_sx.getNumber(),lkCount,maps);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void allocateGZZ(String waveDocCode, List<Long> lx_gzz_ids,
 | 
			
		||||
			List<Long> hj_gzz_ids, List<Long> lk_gzz_ids) {
 | 
			
		||||
	public void allocateGZZ(String waveDocCode, Long zone_id,List<String> gzz_codes,int cfhs,int jhxl,int syhs,Map<String, Integer> gzz_maps) {
 | 
			
		||||
		Session session = ((HibernateDaoSupport) this.commonDao)
 | 
			
		||||
				.getSessionFactory().openSession();
 | 
			
		||||
		/* try { */
 | 
			
		||||
| 
						 | 
				
			
			@ -79,11 +100,13 @@ public class DefaultNewWaveManager extends DefaultBaseManager implements
 | 
			
		|||
				+ "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 ";
 | 
			
		||||
				+ "' and t.WAVE_DOC_ID is not null ";
 | 
			
		||||
		if(zone_id!=null){
 | 
			
		||||
			sql+=" and z.id="+zone_id;
 | 
			
		||||
		}
 | 
			
		||||
			// " t.PLAN_QUANTITY_MU-t.MOVED_QUANTITY_MU>0 and t.agv_status=0 "
 | 
			
		||||
			sql+= "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();
 | 
			
		||||
| 
						 | 
				
			
			@ -291,6 +314,18 @@ public class DefaultNewWaveManager extends DefaultBaseManager implements
 | 
			
		|||
			logger.info("--------------------------------------------------------------------------------------------------------------------------------------------------");
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
		int count_all=syhs+list_fenpei.size();//所有未处理的数据
 | 
			
		||||
		int gzz_nx_avg=count_all/gzz_codes.size();//得到工作站的平均能效,
 | 
			
		||||
		if(gzz_nx_avg<jhxl){//小于默认值则取默认
 | 
			
		||||
			gzz_nx_avg=jhxl;
 | 
			
		||||
		}
 | 
			
		||||
		//分配工作站,每个工作站剩余可分配订单数
 | 
			
		||||
		for(String code:gzz_codes){
 | 
			
		||||
			int gzz_nx=gzz_nx_avg-gzz_maps.get(code);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// 写入数据库
 | 
			
		||||
 | 
			
		||||
		/*
 | 
			
		||||
| 
						 | 
				
			
			@ -469,11 +504,61 @@ public class DefaultNewWaveManager extends DefaultBaseManager implements
 | 
			
		|||
		return v;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public List<Long> getGZZ(Long zone_id) {
 | 
			
		||||
	public List<Long> getGzzIds(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;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public List<String> getGzzCodes(Long zone_id) {
 | 
			
		||||
		String hql = "select code from LocationStorage l where l.type='拣货' and l.warehouseArea.id="
 | 
			
		||||
				+ zone_id;// +" and l.beAuto=1";
 | 
			
		||||
		List<String> codes = commonDao.findByQuery(hql);
 | 
			
		||||
		return codes;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public Map<String, Integer > gzzCount(){
 | 
			
		||||
		Session session = ((HibernateDaoSupport) this.commonDao).getSessionFactory().openSession();
 | 
			
		||||
		String sql ="select v.gzz,count(v.gzz) gzz_count from "
 | 
			
		||||
				+ " (SELECT MAX ( t.END_REGION ) AS gzz 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 ITEM_KEY ik ON ik.id= t.ITEM_KEY_ID "
 | 
			
		||||
				+ " LEFT JOIN ITEM item ON item.id= ik.ITEM_ID "
 | 
			
		||||
				+ " LEFT JOIN WAVE_DOC wd ON wd.id= t.WAVE_DOC_ID  "
 | 
			
		||||
				+ " WHERE 1 = 1  AND pt.BILL_TYPE_ID= 1094 and loc.ZONE_ID in (1763,1765,1766) "
 | 
			
		||||
				+ " AND  t.agv_Status in (1,2) "
 | 
			
		||||
				+ " AND t.WAVE_DOC_ID IS NOT NULL "
 | 
			
		||||
				+ " GROUP BY pt.code,t.BILLCODE,loc.id,loc.code,ik.PROP_C1,ik.PROP_C2,ik.PROP_C3,ik.PROP_D1,ik.PROP_D2,item.ISBOM ) v "
 | 
			
		||||
				+ " GROUP BY v.gzz";
 | 
			
		||||
		logger.info(sql);
 | 
			
		||||
		Query   query   =   session.createSQLQuery(sql); 
 | 
			
		||||
		List<Object[]> objs= (List<Object[]>)query.list();
 | 
			
		||||
		Map<String, Integer > gdCount = new HashMap<String, Integer>();
 | 
			
		||||
		for(int i=0;i<objs.size();i++){
 | 
			
		||||
			Object[] obj=objs.get(i);
 | 
			
		||||
			if(obj[0]==null||obj[0].toString().equals("")){
 | 
			
		||||
				break;
 | 
			
		||||
			}else{
 | 
			
		||||
				gdCount.put(obj[0].toString(), getValueInt(obj,1));
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		session.close();
 | 
			
		||||
		return gdCount;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
	public ShiXiao kqShiXiao(Long zone_id){
 | 
			
		||||
		String hql =" from ShiXiao sx where sx.warehouseArea.id="+zone_id;
 | 
			
		||||
		List<ShiXiao> list=commonDao.findByQuery(hql);
 | 
			
		||||
		if(list.size()>0){
 | 
			
		||||
			return  list.get(0);
 | 
			
		||||
		}
 | 
			
		||||
		return null;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue