diff --git a/src/main/java/com/dev/swms/server/service/shipping/NewWaveDocManager.java b/src/main/java/com/dev/swms/server/service/shipping/NewWaveDocManager.java index 4869bd1..4ebff02 100644 --- a/src/main/java/com/dev/swms/server/service/shipping/NewWaveDocManager.java +++ b/src/main/java/com/dev/swms/server/service/shipping/NewWaveDocManager.java @@ -20,4 +20,10 @@ public interface NewWaveDocManager extends BaseManager { @Transactional void hotWaveDoc(Date date1,Date date2 ,Integer lxqQty,Integer longtiem,Integer hjqQty,Integer lkqQty,boolean ddq,String pickCode ,boolean ddq1,boolean ddq2,boolean ddq3,boolean ddq4,boolean ddq5,boolean ddq6,boolean ddq7,boolean ddq8,boolean ddq9,Integer taskqty,boolean beUrgent); + + //自动创波,ddq1=3#不良品区,ddq2=3#焊接件区,ddq3=3#货架区,ddq4=3#料箱区,ddq5=7#3楼普通库, + //ddq6=7#4楼普通库,ddq7=7#地堆区,ddq8=#堆垛库,ddq9=8#化学品区 + @Transactional + void cssjHotWaveDoc(Date date1,Date date2 ,Integer lxqQty,Integer longtiem,Integer hjqQty,Integer lkqQty,boolean ddq,String pickCode + ,boolean ddq1,boolean ddq2,boolean ddq3,boolean ddq4,boolean ddq5,boolean ddq6,boolean ddq7,boolean ddq8,boolean ddq9,Integer taskqty,boolean beUrgent); } diff --git a/src/main/java/com/dev/swms/server/service/shipping/pojo/DefaultNewWaveDocManager.java b/src/main/java/com/dev/swms/server/service/shipping/pojo/DefaultNewWaveDocManager.java index 058e6cb..f8d04fd 100644 --- a/src/main/java/com/dev/swms/server/service/shipping/pojo/DefaultNewWaveDocManager.java +++ b/src/main/java/com/dev/swms/server/service/shipping/pojo/DefaultNewWaveDocManager.java @@ -14,11 +14,15 @@ import org.springframework.transaction.annotation.Transactional; import com.dev.energy.server.exception.BusinessException; import com.dev.energy.server.model.EntityFactory; import com.dev.energy.server.service.pojo.DefaultBaseManager; +import com.dev.energy.server.web.security.UserHolder; +import com.dev.swms.server.model.base.BillTypeConfig; import com.dev.swms.server.model.base.Item; import com.dev.swms.server.model.base.ShiXiao; +import com.dev.swms.server.model.inventory.Configuration; import com.dev.swms.server.model.inventory.Inventory; import com.dev.swms.server.model.inventory.Task; import com.dev.swms.server.model.inventory.TaskType; +import com.dev.swms.server.model.shipping.PickTicket; import com.dev.swms.server.model.shipping.PickTicketDetail; import com.dev.swms.server.model.shipping.WaveDoc; import com.dev.swms.server.model.shipping.WaveDocSort; @@ -30,6 +34,7 @@ import com.dev.swms.server.service.picking.allocate.NewAutoAllocator; import com.dev.swms.server.service.sequence.BussinessCodeManager; import com.dev.swms.server.service.shipping.NewWaveDocManager; import com.dev.swms.server.service.shipping.PickTicketManager; +import com.dev.swms.server.utils.DateUtil; import com.dev.swms.server.utils.TimeNumberUtils; @@ -361,6 +366,415 @@ public class DefaultNewWaveDocManager extends DefaultBaseManager implements hotWave=true; } } + public List cssjBeUrgentTaks(Date date1,Date date2 ,Integer longtiem,Integer lxqQty,Integer hjqQty,Integer lkqQty,boolean ddq,String pickCode + ,boolean ddq1,boolean ddq2,boolean ddq3,boolean ddq4,boolean ddq5,boolean ddq6,boolean ddq7,boolean ddq8,boolean ddq9,Integer taskQty, + boolean beUrgent,String noLoc) { + List taskids=new ArrayList(); + List lxtaskids=new ArrayList();//料箱区任务 + List hjtaskids=new ArrayList();//货架区任务 + List lktaskids=new ArrayList();//立库区任务 + //料箱区 + long lxqsx=0; + List lxqTasks=new ArrayList(); + if(lxqQty!=null&&lxqQty>0){ + ShiXiao loc=this.load(ShiXiao.class, 2L);//料箱区 + lxqsx=(long)loc.getNumber()*lxqQty*longtiem; + } + //货架区 + long hjqsx=0; + List hjqTasks=new ArrayList(); + if(hjqQty>0){ + ShiXiao loc=this.load(ShiXiao.class, 3L);//货架区 + hjqsx=(long)loc.getNumber()*hjqQty*longtiem;//货架区总数 + } + //立库区 + long lkqsx=0; + List lkqTasks=new ArrayList(); + if(lkqQty>0){ + ShiXiao loc=this.load(ShiXiao.class, 4L);//立库区 + lkqsx=(long)loc.getNumber()*lkqQty*longtiem; + } + long number=lxqsx+hjqsx+lkqsx;//总行数 + + String hql2="select ptd.id from PickTicketDetail ptd where ptd.pickTicket.equatedQuantity in('U','X','H') "; + hql2+= " and ptd.orderQuantity>=ptd.allocatedQuantity " + + " and ptd.pickTicket.billType.name='工单出库' " + + " and ptd.pickedQuantity=0 and ptd.shippedQuantity=0 " + + " and (ptd.strBill6 is null or ptd.strBill6='' ) " + + " and ptd.newLotInfo.propC2 not in('SL55') " + + " and (ptd.waveDoc.id is null ) " + + " and ptd.pickTicket.status ='OPEN' " + + " order by ptd.SOI desc,ptd.pickTicket.orderDate, ptd.pickTicket.code,ptd.item.code "; + List pdisd= commonDao.findByQuery(hql2); + boolean bd=true;//是否满足波次行数 + Long ptsid=null;//最后一个明细id + for(Long pid:pdisd) { + List pids=new ArrayList(); + ptsid=pid; + pids.add(pid); + cssjAllocatePickticketDetail(pids,taskQty,ddq, ddq1, ddq2, ddq3, ddq4, ddq5, ddq6, ddq7, ddq8, ddq9,noLoc);//明细分配 + List objs=commonDao.findByQuery("select t.id,t.srcLoc.zone.id from Task t where t.movedQuantityMU=0 and t.pickTicketDetail.id="+pid); + //查询统计总任务数、料箱区任务数、货架区任务、堆垛库任务 + if(objs.size()>0) { + for(Object obj:objs) { + Object [] str=(Object [])obj; + String tid=str[0].toString(); + String zoneName=str[1].toString(); + if(zoneName.equals("1763")) { + lxtaskids.add(Long.parseLong(tid)); + }else if(zoneName.equals("1765")){ + hjtaskids.add(Long.parseLong(tid)); + }else if(zoneName.equals("1766")){ + lktaskids.add(Long.parseLong(tid)); + } + taskids.add(Long.parseLong(tid)); + } + } + + if(lxqsx>0&&lxqsx<=lxtaskids.size()) { + bd=false; + break; + }else if(hjqsx>0&&hjqsx<=hjtaskids.size()){ + bd=false; + break; + }else if(lkqsx>0&&lkqsx<=lktaskids.size()){ + bd=false; + break; + } + } + //将最后一个工单明细全部分配完成 + if(ptsid!=null) { + PickTicketDetail ptdd= commonDao.load(PickTicketDetail.class, ptsid); + if(ptdd!=null) { + List picklists= commonDao.findByQuery("select p.id from PickTicketDetail p where p.pickTicket.id="+ptdd.getPickTicket().getId() + +" and p.orderQuantity>0 and p.allocatedQuantity=0 order by p.item.code "); + if(picklists.size()>0) { + autoAllocator.allocatePickticketDetail(picklists,taskQty,ddq, ddq1, ddq2, ddq3, ddq4, ddq5, ddq6, ddq7, ddq8, ddq9,noLoc);//明细分配 + List objs1=commonDao.findByQuery("select t.id from Task t where t.movedQuantityMU=0 " + + " and t.planQuantity>0 and t.pickTicketDetail.pickTicket.id="+ptdd.getPickTicket().getId()+" "); + + // + if(objs1.size()>0) { + for(Long tids:objs1) { + if(!taskids.contains(tids)) { + taskids.add(tids); + } + } + } + } + } + } + + return taskids; + + } + + @Override + public void cssjHotWaveDoc(Date date1,Date date2 ,Integer longtiem,Integer lxqQty,Integer hjqQty,Integer lkqQty,boolean ddq,String pickCode + ,boolean ddq1,boolean ddq2,boolean ddq3,boolean ddq4,boolean ddq5,boolean ddq6,boolean ddq7,boolean ddq8,boolean ddq9,Integer taskQty,boolean beUrgent) { + SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd"); + Date date=new Date(); + logger.info(date); +// 1000*60*20,小于20分钟。 + /*if(!hotWave&&date.getTime()-hotWaveDate.getTime()<1200000) { + throw new BusinessException("其它人正在创建波次,请稍后"); + }*/ + List waveDocSortList = commonDao.findByQuery("select wds from WaveDocSort wds where wds.disabled=0 order by wds.sort asc"); + /*波次排序规则*/ + String sqlSort=""; + for (WaveDocSort waveDocSort : waveDocSortList) { + if (sqlSort.length()>1) { + sqlSort=sqlSort+","; + }else { + sqlSort=" order by"; +// + " order by ptd.SOI desc,ptd.pickTicket.orderDate, ptd.pickTicket.code ,ptd.item.code " + + } + sqlSort=sqlSort+" ptd."+waveDocSort.getColume()+" "; + } + hotWave=false; + List PickTicketDetailIds=null; + List taskids=new ArrayList(); + List lxtaskids=new ArrayList();//料区任务 + List hjtaskids=new ArrayList();//货架区任务 + List lktaskids=new ArrayList();//立箱库区任务 + //库存料号id + String hqlinv1="select i.itemKey.item.id from Inventory i where i.location.type='存货' " + + " and i.status='已入库' and i.quantity-i.queuedQuantity>0 and i.counPlan is null " + + " "; + String hqlmave=" ";//不入波的LOC + List hqllist=commonDao.findByQuery("select pl.code from PlantLocation pl where pl.disabled=0 and pl.beWave=0"); + if(hqllist.size()>0) { + hqlmave=""; + for(String sh:hqllist) { + hqlmave=hqlmave+"'"+sh+"',"; + } + if(hqlmave.length()>4) + hqlmave=hqlmave.substring(0, hqlmave.length()-1); + } +// String hqlmaveloc=" ";//优先入波的LOC +// List hqllist1=commonDao.findByQuery("select pl.code from PlantLocation pl where pl.disabled=0 and pl.bePriorityWave=1"); +// if(hqllist1.size()>0) { +// hqlmaveloc=""; +// for(String sh:hqllist1) { +// hqlmaveloc=hqlmaveloc+"'"+sh+"',"; +// } +// if(hqlmaveloc.length()>4) +// hqlmaveloc=hqlmaveloc.substring(0, hqlmaveloc.length()-1); +// } + if(beUrgent) { + //加急单 + taskids=cssjBeUrgentTaks(date1, date2, longtiem, lxqQty, hjqQty, lkqQty, ddq, pickCode, ddq1, ddq2, ddq3, ddq4, ddq5, ddq6, ddq7, ddq8, ddq9, taskQty, beUrgent,hqlmave); + }else { + //根据工单号生成任务 + if(pickCode!=null&&pickCode.length()>0){ + String[] strings=pickCode.split("\n"); + String code=""; + for(int i=0;i1) { + code=code.substring(0, code.length()-1); + } + String hql="select ptd.id from PickTicketDetail ptd where 1=1 and ptd.pickTicket.billType.name='工单出库' and " + + " ptd.orderQuantity>=ptd.allocatedQuantity and ptd.pickedQuantity=0 and ptd.shippedQuantity=0 " + + " and ptd.pickTicket.status ='OPEN' and ptd.newLotInfo.propC2 not in("+hqlmave+") " + + " and (ptd.strBill6 is null or ptd.strBill6='' ) "; //and pt.allocatedQuantity=pt.pickedQuantity + if(code.length()>0) { + hql+=" and ptd.pickTicket.code in("+code+")"; + } + hql+=" order by ptd.pickTicket.orderDate, ptd.pickTicket.code,ptd.item.code "; + PickTicketDetailIds = commonDao.findByQuery(hql); + + }else{ + //未分配完成的订单明细 + String sql2=" select ptd.id from PickTicketDetail ptd " + + " where 1=1 and ptd.newLotInfo.propC2 not in("+hqlmave+") " + + " and ptd.pickTicket.billType.name='工单出库' "; + if(date1==null){ + sql2+=" and CONVERT(varchar(100),ptd.pickTicket.orderDate, 23)<='"+sdf.format(date2)+"' "; + }else{ + sql2+= " and CONVERT(varchar(100),ptd.pickTicket.orderDate, 23)>='"+sdf.format(date1)+"' "; + sql2+= " and CONVERT(varchar(100),ptd.pickTicket.orderDate, 23)<='"+sdf.format(date2)+"' "; + } + sql2+= " and ptd.orderQuantity>=ptd.allocatedQuantity " + + " and ptd.pickedQuantity=0 and ptd.shippedQuantity=0 " + + " and (ptd.strBill6 is null or ptd.strBill6='' ) " + + " and (ptd.waveDoc.id is null ) " + + " and ptd.pickTicket.status ='OPEN' " //,'PICKUP','CHECK' + + " and ptd.item.id in("+hqlinv1+") " + + sqlSort +// + " order by ptd.SOI desc,ptd.pickTicket.orderDate, ptd.pickTicket.code ,ptd.item.code " + ; + PickTicketDetailIds = commonDao.findByQuery(sql2); + } + + if(PickTicketDetailIds.size()>0){ + //根据条件查询任务行数 + //料箱区 + long lxqsx=0; + List lxqTasks=new ArrayList(); + if(lxqQty!=null&&lxqQty>0){ + ShiXiao loc=this.load(ShiXiao.class, 2L);//料箱区 + lxqsx=(long)loc.getNumber()*lxqQty*longtiem; + } + //货架区 + long hjqsx=0; + List hjqTasks=new ArrayList(); + if(hjqQty>0){ + ShiXiao loc=this.load(ShiXiao.class, 3L);//货架区 + hjqsx=(long)loc.getNumber()*hjqQty*longtiem;//货架区总数 + } + //立库区 + long lkqsx=0; + List lkqTasks=new ArrayList(); + if(lkqQty>0){ + ShiXiao loc=this.load(ShiXiao.class, 4L);//立库区 + lkqsx=(long)loc.getNumber()*lkqQty*longtiem; + } + long number=lxqsx+hjqsx+lkqsx; + int jyq=0;//平均数 + + if(lxqsx>0&&lxqQty>0) { + jyq=(int)lxqsx/lxqQty; + } + if(jyq==0&&hjqQty>0) { + jyq=(int)hjqsx/hjqQty; + } + jyq=taskQty; +// logger.info("3---"+new Date()); + if(number>0){ + //查询加急单号,需要优先分配 + + String hql2="select ptd.id from PickTicketDetail ptd where ptd.SOI is not null and ptd.SOI <>'' "; + hql2+= " and ptd.orderQuantity>=ptd.allocatedQuantity " + + " and ptd.pickTicket.billType.name='工单出库' " + + " and ptd.pickedQuantity=0 and ptd.shippedQuantity=0 " + + " and (ptd.strBill6 is null or ptd.strBill6='' ) " + + " and (ptd.waveDoc.id is null ) " + + " and ptd.newLotInfo.propC2 not in("+hqlmave+")" + + " and ptd.pickTicket.status ='OPEN' " + + " and ptd.item.id in("+hqlinv1+") " + + sqlSort +// + " order by ptd.SOI desc,ptd.pickTicket.orderDate, ptd.pickTicket.code,ptd.item.code " + ; + List pdisd= commonDao.findByQuery(hql2); + boolean bd=true;//是否满足波次行数 +// logger.info("4---"+new Date()); + for(Long pid:pdisd) { + List pids=new ArrayList(); + pids.add(pid); + autoAllocator.allocatePickticketDetail(pids,jyq,ddq, ddq1, ddq2, ddq3, ddq4, ddq5, ddq6, ddq7, ddq8, ddq9,hqlmave);//明细分配 +// logger.info("5---"+new Date()); + + List objs=commonDao.findByQuery("select t.id,t.srcLoc.zone.id from Task t where t.movedQuantityMU=0 and t.pickTicketDetail.id="+pid); + //查询统计总任务数、料箱区任务数、货架区任务、堆垛库任务 +// logger.info("6---"+new Date()); + if(objs.size()>0) { + for(Object obj:objs) { + Object [] str=(Object [])obj; + String tid=str[0].toString(); + String zoneName=str[1].toString(); + if(zoneName.equals("1763")) { + lxtaskids.add(Long.parseLong(tid)); + }else if(zoneName.equals("1765")){ + hjtaskids.add(Long.parseLong(tid)); + }else if(zoneName.equals("1766")){ + lktaskids.add(Long.parseLong(tid)); + } + taskids.add(Long.parseLong(tid)); + } + } +// logger.info("7---"+new Date()); + if(lxqsx>0&&lxqsx<=lxtaskids.size()) { + bd=false; + break; + }else if(hjqsx>0&&hjqsx<=hjtaskids.size()){ + bd=false; + break; + }else if(lkqsx>0&&lkqsx<=lktaskids.size()){ + bd=false; + break; + } + } + if(bd) { + Long ptsid=null;//最后一个明细id + + for(Long pid:PickTicketDetailIds) { +// logger.info("8---"+new Date()); + List pids=new ArrayList(); + ptsid=pid; + pids.add(pid); + autoAllocator.allocatePickticketDetail(pids,jyq,ddq, ddq1, ddq2, ddq3, ddq4, ddq5, ddq6, ddq7, ddq8, ddq9,hqlmave);//明细分配 + List objs=commonDao.findByQuery("select t.id,t.srcLoc.zone.id from Task t where t.movedQuantityMU=0 and t.pickTicketDetail.id="+pid); + //查询统计总任务数、料箱区任务数、货架区任务、堆垛库任务 +// logger.info("9---"+new Date()); + if(objs.size()>0) { + for(Object obj:objs) { + Object [] str=(Object [])obj; + String tid=str[0].toString(); + String zoneName=str[1].toString(); + if(zoneName.equals("1763")) { + lxtaskids.add(Long.parseLong(tid)); + }else if(zoneName.equals("1765")){ + hjtaskids.add(Long.parseLong(tid)); + }else if(zoneName.equals("1766")){ + lktaskids.add(Long.parseLong(tid)); + } + taskids.add(Long.parseLong(tid)); + } + } +// logger.info("10---"+new Date()); + if(lxqsx>0&&lxqsx<=lxtaskids.size()) { + bd=false; + break; + }else if(hjqsx>0&&hjqsx<=hjtaskids.size()){ + bd=false; + break; + }else if(lkqsx>0&&lkqsx<=lktaskids.size()){ + bd=false; + break; + } + } + //将最后一个工单明细全部分配完成 + if(ptsid!=null) { + PickTicketDetail ptdd= commonDao.load(PickTicketDetail.class, ptsid); + if(ptdd!=null) { + List picklists= commonDao.findByQuery("select p.id from PickTicketDetail p where p.pickTicket.id="+ptdd.getPickTicket().getId() + +" and p.orderQuantity>0 and p.allocatedQuantity=0 and p.newLotInfo.propC2 not in("+hqlmave+") order by p.item.code "); + if(picklists.size()>0) { + autoAllocator.allocatePickticketDetail(picklists,jyq,ddq, ddq1, ddq2, ddq3, ddq4, ddq5, ddq6, ddq7, ddq8, ddq9,hqlmave);//明细分配 + + List objs=commonDao.findByQuery("select t.id from Task t where t.movedQuantityMU=0 " + + " and t.planQuantity>0 and t.pickTicketDetail.pickTicket.id="+ptdd.getPickTicket().getId()+" "); +// taskids.addAll(ts); + if(objs.size()>0) { + for(Long tids:objs) { + if(!taskids.contains(tids)) { + taskids.add(tids); + } + } + } + } + } + } + } + + }else { + cssjAllocatePickticketDetail(PickTicketDetailIds,jyq,ddq, ddq1, ddq2, ddq3, ddq4, ddq5, ddq6, ddq7, ddq8, ddq9,hqlmave);//明细分配 + + if(PickTicketDetailIds.size()>0) { + String robotJobId=StringUtils.strip(PickTicketDetailIds.toString(),"[]"); + String sql1=" select " + + " t.id from Task t " + + " where 1=1 "; + + sql1+= " and t.planQuantity>t.movedQuantityMU " + + " and t.pickTicketDetail.id in ("+robotJobId+") " + + " and t.waveDoc.id is null " + + " order by t.id "; + taskids= commonDao.findByQuery(sql1); + + } + } + + } + } + List ids =new ArrayList(); + List Tasks =null; +// logger.info("18---"+new Date()); + //指定出库单创建波次 + if(pickCode!=null&&pickCode.length()>0){ + String sql=""; + if(PickTicketDetailIds.size()==0) { + throw new BusinessException(pickCode+"无可以拣货明细!"); + } + String robotJobId=StringUtils.strip(PickTicketDetailIds.toString(),"[]"); + sql+="select t.id from Task t " + + " where 1=1 " + + " and t.pickTicketDetail.id in ("+robotJobId+") " + + " and t.planQuantity>t.movedQuantityMU " + + " and t.waveDoc.id is null " + + " order by t.id "; + Tasks = commonDao.findByQuery(sql); + }else{ + Tasks=taskids; + } + + if(Tasks.size()>0){ + pickTicketManager.addTaskToWaveDocDetail(Tasks, date1, date2, longtiem, lxqQty, hjqQty, lkqQty, ddq9, pickCode, taskQty,1); + } + + try { + hotWave=true; + hotWaveDate=sdf.parse("2023-02-02"); + } catch (ParseException e) { + hotWave=true; + } + } public List beUrgentTaks(Date date1,Date date2 ,Integer longtiem,Integer lxqQty,Integer hjqQty,Integer lkqQty,boolean ddq,String pickCode ,boolean ddq1,boolean ddq2,boolean ddq3,boolean ddq4,boolean ddq5,boolean ddq6,boolean ddq7,boolean ddq8,boolean ddq9,Integer taskQty, boolean beUrgent,String noLoc) { @@ -460,7 +874,313 @@ public class DefaultNewWaveDocManager extends DefaultBaseManager implements } } - return taskids; + return taskids; } + /** 当前输送线库存*/ + private List invIds=new ArrayList(); + public List cssjAllocatePickticketDetail(List ids,int qty,boolean ddq,boolean ddq1,boolean ddq2,boolean ddq3, + boolean ddq4,boolean ddq5,boolean ddq6,boolean ddq7,boolean ddq8,boolean ddq9,String noLoc) { + if (invIds.size()==0) { + invIds=inventoryManager.selectSSXInventory(); + } + String msg=""; + List tasks=new ArrayList(); + for (int i = 0; i < ids.size(); i++) { + Long id=Long.valueOf(ids.get(i)+""); + + PickTicketDetail ptd= commonDao.load(PickTicketDetail.class, id); + if(ptd.getOrderQuantity()- ptd.getAllocatedQuantity()<=0) { + continue; + } + Date date=new Date(); + if(ptd.getStrBill6()==null||ptd.getStrBill6().length()<=0){ + PickTicket pt=ptd.getPickTicket(); + //分配库存 + String hql1=" from Inventory i where i.itemKey.item.id=:id and i.location.type='存货'" + + "and i.status='已入库' and i.quantity-i.queuedQuantity>0 and i.counPlan is null " + + " "; + //不能入波的LOC + if(noLoc!=null&&!noLoc.equals("")) { + hql1+=" and i.itemKey.lotInfo.propC2 not in("+noLoc+")"; + } + //自动创波,ddq1=3#不良品区,ddq2=3#焊接件区,ddq3=3#货架区,ddq4=3#料箱区,ddq5=7#3楼普通库, + //ddq6=7#4楼普通库,ddq7=7#地堆区,ddq8=7#堆垛库,ddq9=8#化学品区 + String kqno=""; + if(!ddq1) { + kqno+="1798,"; + } + if(!ddq2) { + kqno+="1773,"; + } + if(!ddq3) { + kqno+="1765,"; + } + if(!ddq4) { + kqno+="1763,"; + } + if(!ddq5) { + kqno+="1768,"; + } + if(!ddq6) { + kqno+="1783,"; + } + if(!ddq7) { + kqno+="1808,"; + } + if(!ddq8) { + kqno+="1766,"; + } + if(!ddq9) { + kqno+="1799,"; + } + if(kqno.length()>0) { + kqno=kqno.substring(0, kqno.length()-1); + hql1+=" and i.location.zone.id not in("+kqno+") "; + } + if(ddq&&ptd.getPickTicket().getOrderDate().getTime()>=date.getTime()) { + hql1+=" and i.location.zone.id not in(1808) "; + } + + if(ptd.getNewLotInfo()!=null) { + if(ptd.getNewLotInfo().getPropC1()!=null&&!ptd.getNewLotInfo().getPropC1().equals("")) { + hql1+=" and i.itemKey.lotInfo.propC1='"+ptd.getNewLotInfo().getPropC1()+"'"; + } + +// if(ptd.getNewLotInfo().getPropC2()!=null&&!ptd.getNewLotInfo().getPropC2().equals("")) { +// hql1+=" and i.itemKey.lotInfo.propC2='"+ptd.getNewLotInfo().getPropC2()+"'"; +// }else { +// +// } + if(ptd.getNewLotInfo().getPropC3()!=null&&!ptd.getNewLotInfo().getPropC3().equals("")) { + hql1+=" and i.itemKey.lotInfo.propC3='"+ptd.getNewLotInfo().getPropC3()+"'"; + }else { + if(ptd.getStrExtend2()!=null&&(ptd.getStrExtend2().equals("TRUE")||ptd.getStrExtend2().equals("true"))) { + hql1+=" and i.itemKey.lotInfo.propC3='K' "; + } + } + if(ptd.getNewLotInfo().getPropC4()!=null&&!ptd.getNewLotInfo().getPropC4().equals("")) { + hql1+=" and i.itemKey.lotInfo.propC4='"+ptd.getNewLotInfo().getPropC4()+"'"; + } + if(ptd.getNewLotInfo().getPropC4()!=null&&!ptd.getNewLotInfo().getPropC4().equals("")) { + hql1+=" and i.itemKey.lotInfo.propC4='"+ptd.getNewLotInfo().getPropC4()+"'"; + } + if(ptd.getNewLotInfo().getPropC5()!=null&&!ptd.getNewLotInfo().getPropC5().equals("")) { + hql1+=" and i.itemKey.lotInfo.propC5='"+ptd.getNewLotInfo().getPropC5()+"'"; + } + if(ptd.getNewLotInfo().getPropC6()!=null&&!ptd.getNewLotInfo().getPropC6().equals("")) { + hql1+=" and i.itemKey.lotInfo.propC6='"+ptd.getNewLotInfo().getPropC6()+"'"; + } + if(ptd.getNewLotInfo().getPropC7()!=null&&!ptd.getNewLotInfo().getPropC7().equals("")) { + hql1+=" and i.itemKey.lotInfo.propC7='"+ptd.getNewLotInfo().getPropC7()+"'"; + } + if(ptd.getNewLotInfo().getPropC8()!=null&&!ptd.getNewLotInfo().getPropC8().equals("")) { + hql1+=" and i.itemKey.lotInfo.propC8='"+ptd.getNewLotInfo().getPropC8()+"'"; + } + if(ptd.getNewLotInfo().getPropC9()!=null&&!ptd.getNewLotInfo().getPropC9().equals("")) { + hql1+=" and i.itemKey.lotInfo.propC9='"+ptd.getNewLotInfo().getPropC9()+"'"; + } + }else { + + } + StringBuffer sqlBuffer=new StringBuffer(); + sqlBuffer.append(" order by "); + if (invIds.size()>0) { + StringBuilder sb = new StringBuilder(); + for (int k = 0; k < invIds.size(); k++) { + sb.append(invIds.get(k)); + if (k < invIds.size() - 1) { + sb.append(","); + } + } + if (sb.length()>0) { + sqlBuffer.append(" CASE " + +" WHEN i.id IN (" + + sb.toString() + +") THEN 1 " + +" ELSE 0 " + +" END, "); + } + } + sqlBuffer.append(" i.itemKey.lotInfo.propD2,i.itemKey.lotInfo.propC3,i.itemKey.lotInfo.propC1,i.statuss desc,i.storageDate,i.quantity,i.id"); + String hql2=sqlBuffer.toString(); + //排序 + String lcs = new String(); + if(pt.getBillType()!=null&&pt.getBillType().getName().indexOf("工单")>=0 + &&ptd.getStrBill12()!=null&&(!ptd.getStrBill12().equals("881")&& + !ptd.getStrBill12().equals("981"))) { + String hqlmaveloc=" ";//优先入波的LOC + List hqllist1=commonDao.findByQuery("select pl.code from PlantLocation pl where pl.disabled=0 and pl.bePriorityWave=1"); + if(hqllist1.size()>0) { + hqlmaveloc=" CASE i.itemKey.lotInfo.propC2 "; + for(String sh:hqllist1) { + hqlmaveloc=hqlmaveloc+" WHEN '"+sh+"' THEN 1 "; + lcs=lcs+"'"+sh + "',"; + } + hqlmaveloc=hqlmaveloc+" ELSE 99 " + + " END ASC " ; + lcs=lcs.substring(0, lcs.length()-1); + + hql2=" order by i.itemKey.lotInfo.propD2,i.itemKey.lotInfo.propC3,i.itemKey.lotInfo.propC1,"+hqlmaveloc+",i.statuss desc,i.storageDate,i.quantity"; + } + } + + if(pt.getBillType()!=null&&pt.getBillType().getName().indexOf("其它")>=0) { + List cs=commonDao.findByQuery(" from Configuration c where c.configuration1='"+ + ptd.getNewLotInfo().getPropC2()+"' or c.configuration2='"+ptd.getNewLotInfo().getPropC2()+"' " ); + if(cs.size()>0) { + Configuration c=cs.get(0); + StringBuffer sb = new StringBuffer(); + if(c.getConfiguration1().length()>0) { + sb.append("'"+c.getConfiguration1() + "', "); + sb.append("'"+c.getConfiguration2() + "' "); + hql1+=" and i.itemKey.lotInfo.propC2 in("+sb.toString()+")"; + } + }else { + hql1+=" and i.itemKey.lotInfo.propC2='"+ptd.getNewLotInfo().getPropC2()+"'"; + } + }else if(pt.getBillType()!=null&&pt.getBillType().getName().indexOf("工单")>=0) { + + if(ptd.getNewLotInfo()!=null&&ptd.getNewLotInfo().getPropC2()!=null + &&(!ptd.getNewLotInfo().getPropC2().equals("SL12")&&!ptd.getNewLotInfo().getPropC2().equals("")&& + !ptd.getNewLotInfo().getPropC2().equals("SL02") + &&!ptd.getNewLotInfo().getPropC2().equals("SL34"))) { + + hql1+=" and i.itemKey.lotInfo.propC2='"+ptd.getNewLotInfo().getPropC2()+"'"; + + }else { + String bsql=" from BillTypeConfig b where b.billType.id="+pt.getBillType().getId(); + if(ptd.getNewLotInfo().getPropC9()!=null&&!ptd.getNewLotInfo().getPropC9().equals("")) { + bsql+=" and b.plantCode='"+ptd.getNewLotInfo().getPropC9()+"'"; + } + List bts=commonDao.findByQuery(bsql); + if(bts.size()>0) { + StringBuffer sb = new StringBuffer(); + for(int y1=0;y1<=bts.size()-1;y1++){ + BillTypeConfig bt=bts.get(y1); + if(y10) { + sb.append(","+lcs); + } + hql1+=" and i.itemKey.lotInfo.propC2 in("+sb.toString()+") "; + }else { + if(ptd.getNewLotInfo()!=null&&ptd.getNewLotInfo().getPropC2()!=null&&ptd.getNewLotInfo().getPropC2().length()>0) { + hql1+=" and i.itemKey.lotInfo.propC2='"+ptd.getNewLotInfo().getPropC2()+"'"; + } + } + } + }else { + if(ptd.getNewLotInfo()!=null&&ptd.getNewLotInfo().getPropC2()!=null&&ptd.getNewLotInfo().getPropC2().length()>0) { + hql1+=" and i.itemKey.lotInfo.propC2='"+ptd.getNewLotInfo().getPropC2()+"'"; + } + } + //指定序列号 +// if(ptd.getApplyDoc()!=null&&!ptd.getApplyDoc().equals("")) { +// hql1+=" and i.barCode='"+ptd.getApplyDoc()+"'"; +// } + //有限期 + if(ptd.getItem().getIsBOM()) { + hql1+=" and CONVERT(varchar(100), i.itemKey.lotInfo.propD2, 23)>='"+DateUtil.formatDateYMDToStr(new Date())+"'"; + } + + List Inventorys = commonDao.findByQuery("select inv from Inventory inv where inv.id = 78789" ); + + if (Inventorys.size() > 0) { + double allocatedQuantity = 0; + double unQty = ptd.getOrderQuantity()- ptd.getAllocatedQuantity();//未分配数量 + double allocateQty=0; + for (Inventory inventory : Inventorys) { + inventory.setQuantity(ptd.getOrderQuantity()); + inventory.setQueuedQuantity(0); + int j = 0; + if (unQty == 0) { + break; + } + allocateQty = inventory.getQuantity()- inventory.getQueuedQuantity();//可分配数量 + if (allocateQty == 0) { + continue; + } + if (unQty < allocateQty) { + allocateQty = unQty; + } + j++; + inventory.setQueuedQuantity(inventory.getQueuedQuantity()+ allocateQty); + inventory.setVersion(inventory.getVersion()); + commonDao.store(inventory); + allocatedQuantity += allocateQty; + unQty -= allocateQty; + ptd.setAllocatedQuantity(ptd.getAllocatedQuantity()+ allocateQty); + commonDao.store(ptd); + + Task task = EntityFactory.getEntity(Task.class); + task.setPickTicketDetail(ptd); + Item item=commonDao.load(Item.class, ptd.getItem().getId()); + /*task.setBillCode(getSubWorkOrer(ptd.getPickTicket().getCode(),inventory.getLocation().getZone(),item)); + //单个子任务数量 + if(qty>0) { + List tas=commonDao.findByQuery("select t.hs from PickTicketTaskView t where t.pickTicket.id="+ptd.getPickTicket().getId() + +" and t.billcode='"+task.getBillCode()+"' "); + if(tas.size()>0) { + //单个子任务数量 + if(tas.get(0)>=qty) { + task.setBillCode(bussinessCodeManager.getCodeForYmd(ptd.getPickTicket().getCode()+"-", 2)); + } + } + }*/ + if (inventory.getLocation().getStock()!=null) { + task.setStrBill7(inventory.getLocation().getStock().getLP()); + } + task.setBillCode(pt.getRelatedBill2()); + String tItemCode=item.getCode().substring(0, 9); + String ptCode = ptd.getPickTicket().getCode(); + char lastChar = ptCode.charAt(ptCode.length() - 1); + if (Character.isUpperCase(lastChar)) { + //System.out.println("最后一位是大写字母"); + task.setStrBill8(tItemCode+lastChar); + } + task.setCode(TimeNumberUtils.getTaskCode()); + task.setType(TaskType.MV_PICKTICKET); + task.setItemKey(inventory.getItemKey()); + task.setStorageDate(inventory.getStorageDate()); + task.setSrcLoc(inventory.getLocation()); + task.setSOI(inventory.getSOI()); + task.setPlanQuantity(allocateQty); + task.setPlanQuantityMU(allocateQty); + task.setInventoryStatus(inventory.getStatus()); + task.setCreateTime(new Date()); + task.setWarehouseArea(inventory.getWarehouseArea()); + task.setBarCode(inventory.getBarCode()); + task.setSrcLP(inventory.getLocation().getStock()); + if(UserHolder.getUser()!=null) { + task.setOperator(UserHolder.getUser().getName()); + task.setStrBill3(UserHolder.getUser().getName()); + } + commonDao.store(task); + tasks.add(task); + } + if(unQty>0) { + msg=msg+ptd.getItem().getCode()+",库存不足! "; + } + + //修改为下发的回传状态 +// List pdids=new ArrayList(); +// pdids.add(ptd.getId()); +// interfaceReqManager.wmsSapZhuantaihuichuang(pdids, 0,"",1);//状态回传 + }else { + msg=msg+ptd.getItem().getCode()+",无匹配库存! "; + } +// shuaxinPick(pt);//刷新订单 + + }else{ + throw new BusinessException("任务状态错误!"); + } + } + invIds =new ArrayList(); + return tasks; + } } diff --git a/src/webapp/WEB-INF/classes/config/origen/shipping/editNewbkcbPage.xml b/src/webapp/WEB-INF/classes/config/origen/shipping/editNewbkcbPage.xml index 2297d7d..5597b04 100644 --- a/src/webapp/WEB-INF/classes/config/origen/shipping/editNewbkcbPage.xml +++ b/src/webapp/WEB-INF/classes/config/origen/shipping/editNewbkcbPage.xml @@ -57,6 +57,40 @@ editEnabled="true" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/webapp/WEB-INF/classes/config/origen/shipping/maintainNewWaveDocPage.xml b/src/webapp/WEB-INF/classes/config/origen/shipping/maintainNewWaveDocPage.xml index 4f90c63..47ee575 100644 --- a/src/webapp/WEB-INF/classes/config/origen/shipping/maintainNewWaveDocPage.xml +++ b/src/webapp/WEB-INF/classes/config/origen/shipping/maintainNewWaveDocPage.xml @@ -78,7 +78,7 @@ -