Compare commits

..

3 Commits

Author SHA1 Message Date
暴炳林 3eff067888 no message 2024-12-27 10:17:39 +08:00
暴炳林 dfef3aecbc Merge remote-tracking branch 'origin/main' 2024-12-27 10:13:23 +08:00
暴炳林 f8c5b31045 no message 2024-12-27 10:13:13 +08:00
10 changed files with 516 additions and 4019 deletions

View File

@ -1,210 +0,0 @@
package com.dev.swms.server.service.picking.allocate;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.springframework.transaction.annotation.Transactional;
import com.dev.swms.server.model.abstractEntity.AbstractMoveDoc;
import com.dev.swms.server.model.abstractEntity.AbstractMoveDocDetail;
import com.dev.swms.server.model.base.BillType;
import com.dev.swms.server.model.base.Item;
import com.dev.swms.server.model.base.LotInfo;
import com.dev.swms.server.model.base.Structure;
import com.dev.swms.server.model.base.PackageUnit;
import com.dev.swms.server.model.inventory.AgvTask;
import com.dev.swms.server.model.inventory.ProcessDocBOMDetail;
import com.dev.swms.server.model.inventory.Task;
import com.dev.swms.server.model.rules.PickItemRule;
import com.dev.swms.server.model.shipping.PickTicket;
import com.dev.swms.server.model.shipping.PickTicketDetail;
import com.dev.energy.server.service.BaseManager;
/**
* @author dev
*/
@Transactional(readOnly = true)
public interface AutoAllocator1 extends BaseManager {
/**
*
* @param pickTicketDetails
*/
@Transactional
String preAllocate(List<Long> pickTicketId);
@Transactional(readOnly = false)
String preAllocatePO(List<Long> pickTicketId);
@Transactional(readOnly = false)
String preAllocateDate(Date beginDate,Date endDate);
/**
*
* @param pickTicketDetails
*/
@Transactional
void preAllocate(Collection<PickTicketDetail> pickTicketDetails);
/**
*
* @param pickTicketDetails
*/
@Transactional
void unPreAllocate(Collection<PickTicketDetail> pickTicketDetails);
/**
*
* @param detail
* @param quantity
*/
@Transactional
void unPreAllocate(PickTicketDetail detail, Double quantity);
/**
*
* @param company
* @param billType
* @param itemPickType
* @param item
* @param packageUnit
* @param lotInfo
* @param quantity
* @param abcType
* @return
*/
List<PickItemRule> getPickItemRules(Structure company,BillType billType,String itemPickType,
Item item,PackageUnit packageUnit,LotInfo lotInfo,double quantity,String abcType);
/**
*
* @param moveDoc
* @return
*/
@Transactional
void unallocate(AbstractMoveDoc moveDoc);
@Transactional
void unallocate(AbstractMoveDoc moveDoc,List<PickTicketDetail> details);
/**
*
* @param bomDetail
* @param quantity
*/
@Transactional
void preAllocate(ProcessDocBOMDetail bomDetail, Double quantity);
/**
*
* @param bomDetail
* @param quantity
*/
@Transactional
void unPreAllocate(ProcessDocBOMDetail bomDetail, Double quantity);
/**
*
* @param pickTicketDetail
* @param inventories
*/
@Transactional
void manualAllocate(AbstractMoveDocDetail moveDocDetail, Map inventories);
/**
* ()
* @param ids
* @param type
*/
@Transactional
String allocate(Long pickTicketId, Long waveDocId, Long moveDocId, Collection<AbstractMoveDocDetail> details);
/**
* ()
* @param ids
* @param type
*/
@Transactional
String allocateDetail(AbstractMoveDocDetail detail);
//波次分配
@Transactional
void allocateWaveDoc(List<Long> WaveDocIds);
//波次分配
@Transactional
void allocatePlanAll(List<Long> WaveDocIds);
//波次分配
@Transactional
void newallocateWaveDoc(List<Long> WaveDocIds);
//订单明细分配
//自动创波,ddq1=3#不良品区,ddq2=3#焊接件区,ddq3=3#货架区,ddq4=3#料箱区,ddq5=7#3楼普通库,
//ddq6=7#4楼普通库,ddq7=7#地堆区,ddq8=#堆垛库,ddq9=8#化学品区
@Transactional
List<Task> allocatePickticketDetail(List<Long> 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);
//按明细分配
@Transactional
void allocatePickticketDetail(List<Long> ids);
//取消分配
@Transactional
void cancelallocate(List<Long> WaveDocIds);
@Transactional
void cancelallocateTaskAgv(List<Long> WaveDocIds);
@Transactional
void cancelPickticket(List<Long> pickIds);
@Transactional
void cancelPickticketDetail(List<Long> pickIds);
//按task取消分配
@Transactional
void cancelTask(List<Long> pickIds);
@Transactional
void shuaxinPick(PickTicket pt);
//料箱出库回传
@Transactional
void returnAGV(List<Long> robotJobIds,String containerCode);
@Transactional
void returnAGV(String code,Boolean takeAwayFlag,List<String> robotJobIds);
//人工呼叫AGV
@Transactional
void artificialAGV(List<Long> ids);
@Transactional
void initializationLabel(long waveDocId);
@Transactional
void callAGV(long waveDocId);
@Transactional
void allautoWaveDetail(List<Long> ids);
@Transactional
String allocatePickticket(PickTicket pt);
//自动下发创波任务
void initiandcallAGV(long waveDocId,List<Long> lxq,List<Long> hjq,List<Long> lkq);
//杂单下发AGV任务
@Transactional
void issueAGV0();
//生成AGV任务平均分配到工作站
@Transactional
void issuedAgvTask(List<Long> ids);
//刷新波次
void shuaXinWaveDoc(long waveDocId);
@Transactional
void taskIssuedAgv(List<Long> ids);
//加急单生成出库任务
@Transactional
void addPickTicketTask(Long asnid,Long userId);
}

View File

@ -0,0 +1,37 @@
package com.dev.swms.server.service.picking.allocate;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.springframework.transaction.annotation.Transactional;
import com.dev.swms.server.model.abstractEntity.AbstractMoveDoc;
import com.dev.swms.server.model.abstractEntity.AbstractMoveDocDetail;
import com.dev.swms.server.model.base.BillType;
import com.dev.swms.server.model.base.Item;
import com.dev.swms.server.model.base.LotInfo;
import com.dev.swms.server.model.base.Structure;
import com.dev.swms.server.model.base.PackageUnit;
import com.dev.swms.server.model.inventory.AgvTask;
import com.dev.swms.server.model.inventory.ProcessDocBOMDetail;
import com.dev.swms.server.model.inventory.Task;
import com.dev.swms.server.model.rules.PickItemRule;
import com.dev.swms.server.model.shipping.PickTicket;
import com.dev.swms.server.model.shipping.PickTicketDetail;
import com.dev.energy.server.service.BaseManager;
/**
* @author dev
*/
@Transactional(readOnly = true)
public interface NewAutoAllocator extends BaseManager {
//订单明细分配
//自动创波,ddq1=3#不良品区,ddq2=3#焊接件区,ddq3=3#货架区,ddq4=3#料箱区,ddq5=7#3楼普通库,
//ddq6=7#4楼普通库,ddq7=7#地堆区,ddq8=#堆垛库,ddq9=8#化学品区
@Transactional
List<Task> allocatePickticketDetail(List<Long> 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);
}

View File

@ -0,0 +1,459 @@
package com.dev.swms.server.service.picking.allocate;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.beanutils.BeanComparator;
import org.apache.commons.collections.comparators.ComparatorChain;
import org.apache.commons.collections.comparators.ReverseComparator;
import org.apache.commons.lang.StringUtils;
import com.dev.swms.server.model.abstractEntity.AbstractMoveDoc;
import com.dev.swms.server.model.abstractEntity.AbstractMoveDocDetail;
import com.dev.swms.server.model.base.BillType;
import com.dev.swms.server.model.base.BillTypeConfig;
import com.dev.swms.server.model.base.CompanyCode;
import com.dev.swms.server.model.base.Item;
import com.dev.swms.server.model.base.ItemKey;
import com.dev.swms.server.model.base.Location;
import com.dev.swms.server.model.base.LocationStorage;
import com.dev.swms.server.model.base.LotInfo;
import com.dev.swms.server.model.base.NewLotInfo;
import com.dev.swms.server.model.base.Structure;
import com.dev.swms.server.model.base.PackageUnit;
import com.dev.swms.server.model.base.ShiXiao;
import com.dev.swms.server.model.base.TurnOverMode;
import com.dev.swms.server.model.base.Warehouse;
import com.dev.swms.server.model.base.WarehouseArea;
import com.dev.swms.server.model.base.WarehouseAreaStatus;
import com.dev.swms.server.model.base.Worker;
import com.dev.swms.server.model.delivery.UrgentOrder;
import com.dev.swms.server.model.inventory.AgvTask;
import com.dev.swms.server.model.inventory.Configuration;
import com.dev.swms.server.model.inventory.Inventory;
import com.dev.swms.server.model.inventory.InventoryLogType;
import com.dev.swms.server.model.inventory.ItemKeyInventory;
import com.dev.swms.server.model.inventory.ProcessDoc;
import com.dev.swms.server.model.inventory.ProcessDocBOMDetail;
import com.dev.swms.server.model.inventory.Stock;
import com.dev.swms.server.model.inventory.Task;
import com.dev.swms.server.model.inventory.TaskType;
import com.dev.swms.server.model.receiving.ASN;
import com.dev.swms.server.model.receiving.ASNDetail;
import com.dev.swms.server.model.receiving.InterWMStask;
import com.dev.swms.server.model.receiving.MoveDoc;
import com.dev.swms.server.model.receiving.MoveDocDetail;
import com.dev.swms.server.model.receiving.MoveDocStatus;
import com.dev.swms.server.model.receiving.ReceivedRecord;
import com.dev.swms.server.model.receiving.STATUS;
import com.dev.swms.server.model.rules.ItemStorageRule;
import com.dev.swms.server.model.rules.PickItemRule;
import com.dev.swms.server.model.rules.PickMethod;
import com.dev.swms.server.model.rules.SortRule;
import com.dev.swms.server.model.shipping.LotQuantity;
import com.dev.swms.server.model.shipping.PickTicket;
import com.dev.swms.server.model.shipping.PickTicketDetail;
import com.dev.swms.server.model.shipping.PickTicketStatus;
import com.dev.swms.server.model.shipping.PreAllocate;
import com.dev.swms.server.model.shipping.SeedWall;
import com.dev.swms.server.model.shipping.WaveDoc;
import com.dev.swms.server.model.shipping.WaveDocDetail;
import com.dev.swms.server.model.shipping.WaveDocStatus;
import com.dev.swms.server.service.GlobalParamUtils;
import com.dev.swms.server.service.base.AgvTaskManager;
import com.dev.swms.server.service.base.ItemManager;
import com.dev.swms.server.service.interfaceLog.ApiURL;
import com.dev.swms.server.service.interfaceLog.InterfaceManager;
import com.dev.swms.server.service.interfaceLog.InterfaceReqManager;
import com.dev.swms.server.service.interfaceLog.JdbcManager;
import com.dev.swms.server.service.interfaceLog.WcsCSDCode;
import com.dev.swms.server.service.inventory.InventoryManager;
import com.dev.swms.server.service.receiving.PutawayAllocator;
import com.dev.swms.server.service.sequence.BussinessCodeManager;
import com.dev.swms.server.utils.DateUtil;
import com.dev.swms.server.utils.DoubleUtils;
import com.dev.swms.server.utils.NewLotInfoParser;
import com.dev.swms.server.utils.TimeNumberUtils;
import com.dev.swms.server.web.filter.WarehouseHolder;
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.util.LocalizedMessage;
import com.dev.energy.server.web.security.UserHolder;
import org.apache.log4j.Logger;
/**
* @author dev
*
*/
public class NewDefaultAutoAllocator extends DefaultBaseManager implements NewAutoAllocator {
protected final ItemManager itemManager;
protected final InventoryManager inventoryManager;
protected final BussinessCodeManager bussinessCodeManager;
protected final PutawayAllocator putawayAllocator;
private Long warehouseId;
protected final InterfaceManager interfaceManager;
protected final JdbcManager jdbcManager;
protected final AgvTaskManager agvTaskManager;
protected final InterfaceReqManager interfaceReqManager;
private static Logger logger = Logger.getLogger(DefaultAutoAllocator.class);
public NewDefaultAutoAllocator(ItemManager manager,InventoryManager manager1,
BussinessCodeManager manager2, PutawayAllocator allocator,InterfaceManager interfaceManager2,JdbcManager jdbcManager2,AgvTaskManager agvTaskManager,
InterfaceReqManager interfaceReqManager) {
itemManager = manager;
inventoryManager = manager1;
bussinessCodeManager = manager2;
putawayAllocator = allocator;
interfaceManager=interfaceManager2;
jdbcManager=jdbcManager2;
this.agvTaskManager=agvTaskManager;
this.interfaceReqManager=interfaceReqManager;
}
/** 当前输送线库存*/
private List<Long> invIds=new ArrayList<Long>();
@Override
public List<Task> allocatePickticketDetail(List<Long> 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<Task> tasks=new ArrayList<Task>();
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(",");
}
}
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<String> 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<Configuration> 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<BillTypeConfig> 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(y1<bts.size()-1){
sb.append("'"+bt.getCode() + "', ");
}else {
sb.append("'"+bt.getCode()+"' ");
}
}
if(lcs!=null&&lcs.length()>0) {
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<Inventory> Inventorys = commonDao.findByQuery(
hql1+hql2,new String[] { "id" },new Object[] { ptd.getItem().getId() });
if (Inventorys.size() > 0) {
double allocatedQuantity = 0;
double unQty = ptd.getOrderQuantity()- ptd.getAllocatedQuantity();//未分配数量
double allocateQty=0;
for (Inventory inventory : Inventorys) {
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<Integer> 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());
}
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<Long> pdids=new ArrayList<Long>();
// pdids.add(ptd.getId());
// interfaceReqManager.wmsSapZhuantaihuichuang(pdids, 0,"",1);//状态回传
}else {
msg=msg+ptd.getItem().getCode()+",无匹配库存! ";
}
// shuaxinPick(pt);//刷新订单
}else{
throw new BusinessException("任务状态错误!");
}
}
invIds =new ArrayList<Long>();
return tasks;
}
public String getSubWorkOrer(String picktickCode,WarehouseArea warehouseArea,Item item){
String code="";
if(warehouseArea.getId()==1765) {
if(item.getGoodType()!=null&&item.getGoodType().equals("大件")) {
Long count= (Long) commonDao.findByQuery(" select max(t.id) from Task t where t.billCode like '"+picktickCode+"-%' and t.srcLoc.zone.id="+warehouseArea.getId()+
" and t.planQuantity>t.movedQuantityMU and t.itemKey.item.goodType='大件' ").get(0);
if(count!=null&&count.longValue()>0){
Task t=this.load(Task.class,count);
code=t.getBillCode();
}else{
code=bussinessCodeManager.getCodeForYmd(picktickCode+"-", 2);
}
}else {
Long count= (Long) commonDao.findByQuery(" select max(t.id) from Task t where t.billCode like '"+picktickCode+"-%' and t.srcLoc.zone.id="+warehouseArea.getId()+
" and t.planQuantity>t.movedQuantityMU and t.itemKey.item.goodType<>'大件' ").get(0);
if(count!=null&&count.longValue()>0){
Task t=this.load(Task.class,count);
code=t.getBillCode();
}else{
code=bussinessCodeManager.getCodeForYmd(picktickCode+"-", 2);
}
}
}else {
Long count= (Long) commonDao.findByQuery(" select max(t.id) from Task t where t.billCode like '"+picktickCode+"-%' and t.srcLoc.zone.id="+warehouseArea.getId()+
" and t.planQuantity>t.movedQuantityMU ").get(0);
if(count!=null&&count.longValue()>0){
Task t=this.load(Task.class,count);
code=t.getBillCode();
}else{
code=bussinessCodeManager.getCodeForYmd(picktickCode+"-", 2);
}
}
return code;
}
}

View File

@ -14,7 +14,7 @@ import com.dev.swms.server.model.shipping.Prewave;
import com.dev.swms.server.model.shipping.WaveDoc; import com.dev.swms.server.model.shipping.WaveDoc;
import com.dev.energy.server.service.BaseManager; import com.dev.energy.server.service.BaseManager;
public interface WaveDocManager1 extends BaseManager { public interface NewWaveDocManager extends BaseManager {
//自动创波,ddq1=3#不良品区,ddq2=3#焊接件区,ddq3=3#货架区,ddq4=3#料箱区,ddq5=7#3楼普通库, //自动创波,ddq1=3#不良品区,ddq2=3#焊接件区,ddq3=3#货架区,ddq4=3#料箱区,ddq5=7#3楼普通库,
//ddq6=7#4楼普通库,ddq7=7#地堆区,ddq8=#堆垛库,ddq9=8#化学品区 //ddq6=7#4楼普通库,ddq7=7#地堆区,ddq8=#堆垛库,ddq9=8#化学品区
@Transactional @Transactional

View File

@ -25,26 +25,26 @@ import com.dev.swms.server.service.base.ItemManager;
import com.dev.swms.server.service.interfaceLog.JdbcManager; import com.dev.swms.server.service.interfaceLog.JdbcManager;
import com.dev.swms.server.service.inventory.InventoryManager; import com.dev.swms.server.service.inventory.InventoryManager;
import com.dev.swms.server.service.picking.allocate.AutoAllocator; import com.dev.swms.server.service.picking.allocate.AutoAllocator;
import com.dev.swms.server.service.picking.allocate.AutoAllocator1; import com.dev.swms.server.service.picking.allocate.NewAutoAllocator;
import com.dev.swms.server.service.sequence.BussinessCodeManager; 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.service.shipping.PickTicketManager;
import com.dev.swms.server.service.shipping.WaveDocManager1;
import com.dev.swms.server.utils.TimeNumberUtils; import com.dev.swms.server.utils.TimeNumberUtils;
public class DefaultWaveDocManager1 extends DefaultBaseManager implements public class NewDefaultWaveDocManager extends DefaultBaseManager implements
WaveDocManager1 { NewWaveDocManager {
private static Logger logger = Logger.getLogger(DefaultWaveDocManager.class); private static Logger logger = Logger.getLogger(DefaultWaveDocManager.class);
private final PickTicketManager pickTicketManager; private final PickTicketManager pickTicketManager;
protected final AutoAllocator1 autoAllocator; protected final NewAutoAllocator autoAllocator;
protected final InventoryManager inventoryManager; protected final InventoryManager inventoryManager;
protected final ItemManager itemManager; protected final ItemManager itemManager;
protected final BussinessCodeManager bussinessCodeManager; protected final BussinessCodeManager bussinessCodeManager;
protected final JdbcManager jdbcManager; protected final JdbcManager jdbcManager;
protected static Date hotWaveDate=new Date();//波次创建,判断不能同时新建 protected static Date hotWaveDate=new Date();//波次创建,判断不能同时新建
protected static boolean hotWave=true;//波次创建,判断不能同时新建 protected static boolean hotWave=true;//波次创建,判断不能同时新建
public DefaultWaveDocManager1(PickTicketManager pickTicketManager, AutoAllocator1 autoAllocator, public NewDefaultWaveDocManager(PickTicketManager pickTicketManager, NewAutoAllocator autoAllocator,
InventoryManager inventoryManager, ItemManager itemManager,BussinessCodeManager bussinessCodeManager,JdbcManager jdbcManager) { InventoryManager inventoryManager, ItemManager itemManager,BussinessCodeManager bussinessCodeManager,JdbcManager jdbcManager) {
this.pickTicketManager = pickTicketManager; this.pickTicketManager = pickTicketManager;
this.autoAllocator = autoAllocator; this.autoAllocator = autoAllocator;

View File

@ -581,16 +581,16 @@
</bean> </bean>
</property> </property>
</bean> </bean>
<bean id="waveDocManager1" parent="abstractTransactionProxy"> <bean id="newWaveDocManager" parent="abstractTransactionProxy">
<property name="target"> <property name="target">
<bean <bean
class="com.dev.swms.server.service.shipping.pojo.DefaultWaveDocManager1" class="com.dev.swms.server.service.shipping.pojo.NewDefaultWaveDocManager"
parent="baseManager"> parent="baseManager">
<constructor-arg index="0"> <constructor-arg index="0">
<ref local="pickTicketManager" /> <ref local="pickTicketManager" />
</constructor-arg> </constructor-arg>
<constructor-arg index="1"> <constructor-arg index="1">
<ref local="autoAllocator1" /> <ref local="newAutoAllocator" />
</constructor-arg> </constructor-arg>
<constructor-arg index="2"> <constructor-arg index="2">
<ref local="inventoryManager" /> <ref local="inventoryManager" />
@ -756,10 +756,10 @@
</bean> </bean>
</property> </property>
</bean> </bean>
<bean id="autoAllocator1" parent="abstractTransactionProxy"> <bean id="newAutoAllocator" parent="abstractTransactionProxy">
<property name="target"> <property name="target">
<bean <bean
class="com.dev.swms.server.service.picking.allocate.DefaultAutoAllocator1" class="com.dev.swms.server.service.picking.allocate.NewDefaultAutoAllocator"
parent="baseManager"> parent="baseManager">
<constructor-arg index="0"> <constructor-arg index="0">
<ref local="itemManager" /> <ref local="itemManager" />

View File

@ -137,10 +137,10 @@
<!-- <menuItem title="预分配统计" pageId="maintainViewOnePage"/> --> <!-- <menuItem title="预分配统计" pageId="maintainViewOnePage"/> -->
<!-- </menuItem> --> <!-- </menuItem> -->
<menuItem title="波次(新)" dir="configPool"> <menuItem title="波次(新)" dir="configPool">
<menuItem title="波次配置" pageId="maintainWaveDocFigPage"/> <!-- <menuItem title="波次配置" pageId="maintainWaveDocFigPage"/>
<menuItem title="创波排序组合" pageId="maintainTaskSortPage"/> <menuItem title="创波排序组合" pageId="maintainTaskSortPage"/> -->
<menuItem title="排序规则创波" pageId="maintainWaveDocSortPage"/> <menuItem title="波次排序规则" pageId="maintainWaveDocSortPage"/>
<menuItem title="波次" pageId="maintainWaveDocPage1"/> <menuItem title="波次" pageId="newMaintainWaveDocPage"/>
</menuItem> </menuItem>
<menuItem title="波次" pageId="maintainWaveDocPage"/> <menuItem title="波次" pageId="maintainWaveDocPage"/>
<menuItem title="插单" pageId="maintainPickTicketInsertPage"/> <menuItem title="插单" pageId="maintainPickTicketInsertPage"/>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<pages> <pages>
<editPage id="editbkcbPage1" title="创建波次" onClose="refreshParent" width="600" height="360"> <editPage id="newEditbkcbPage" title="创建波次" onClose="refreshParent" width="600" height="360">
<inputUIs> <inputUIs>
<date id="date1" title="开始日期" row="1" col="1" span="1" readOnly="false" required="false" reserve="false" forceOverride="true" inVisible="false" showTime="false" manualEditable="true" defaultCurrentDate="false"/> <date id="date1" title="开始日期" row="1" col="1" span="1" readOnly="false" required="false" reserve="false" forceOverride="true" inVisible="false" showTime="false" manualEditable="true" defaultCurrentDate="false"/>
<textArea id="pickCode" title="工单选择" row="1" col="2" span="4" readOnly="false" required="false" reserve="false" forceOverride="true" inVisible="false" rows="5" cols="30" /> <textArea id="pickCode" title="工单选择" row="1" col="2" span="4" readOnly="false" required="false" reserve="false" forceOverride="true" inVisible="false" rows="5" cols="30" />
@ -48,7 +48,7 @@
<mapping id="beUrgent" className="boolean" /> <mapping id="beUrgent" className="boolean" />
</mappings> </mappings>
<actions> <actions>
<action managerName="waveDocManager1" methodName="hotWaveDoc" <action managerName="newWaveDocManager" methodName="hotWaveDoc"
parameter="date1,date2,longtiem,lxqQty,hjqQty,lkqQty,ddq,pickCode,ddq1,ddq2,ddq3,ddq4,ddq5,ddq6,ddq7,ddq8,ddq9,taskQty,beUrgent" /> parameter="date1,date2,longtiem,lxqQty,hjqQty,lkqQty,ddq,pickCode,ddq1,ddq2,ddq3,ddq4,ddq5,ddq6,ddq7,ddq8,ddq9,taskQty,beUrgent" />
</actions> </actions>
<forwards> <forwards>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<pages> <pages>
<maintainPage id="maintainWaveDocPage1" title="波次管理" autoQuery="false"> <maintainPage id="newMaintainWaveDocPage" title="波次管理" autoQuery="false">
<search> <search>
<inputUIs> <inputUIs>
<text id="waveDoc.code" title="waveDoc.code" row="1" col="1" <text id="waveDoc.code" title="waveDoc.code" row="1" col="1"
@ -74,7 +74,7 @@
<column id="waveDoc.updateTime2" title="完成时间" visible="true" horizonAlign="center" verticalAlign="middle" format="dateTiemFormatter"/> <column id="waveDoc.updateTime2" title="完成时间" visible="true" horizonAlign="center" verticalAlign="middle" format="dateTiemFormatter"/>
</columns> </columns>
<buttons> <buttons>
<popup id="bkcb" title="创建波次" enableType="none" invisible="false" containId="false" pageId="editbkcbPage1" /> <popup id="bkcb" title="创建波次" enableType="none" invisible="false" containId="false" pageId="newEditbkcbPage" />
<popup id="issuedAgvTask" title="下发工作站任务" enableType="single" invisible="false" <popup id="issuedAgvTask" title="下发工作站任务" enableType="single" invisible="false"
containId="true" pageId="modifyIssuedAgvTaskPage1" /> containId="true" pageId="modifyIssuedAgvTaskPage1" />
<commit id="allocate21" title="下发AGV" <commit id="allocate21" title="下发AGV"