/** * 库存调整入库确认 插入库存信息表(TD_STOCK_INFO)信息, 插入出入库流水表(td_stock_flow)一条出库记录 * * @param sif - 入库信息; * @return 是否成功标志 */ public int stockAdjustIn(StockFlowForm sff) throws Exception { int tag = -1; StockInfoForm sif = flowToInfo(sff); StockOutBo sob = StockOutBo.getInstance(); sff.setRestNum(sob.getRestStock(sif.getStuffNo(), sff.getSkuNum(), "I")); ArrayList al = new ArrayList(); al.add(sif); al.add(sff); if (this.getBatchDao().insertBatch(al)) { tag = 1; // 把原先0数量的该零件删除 // sob.inMerge(sff.getStuffNo()); } return tag; }
public StockFlowForm infoToFlow(StockInfoForm sif) throws Exception { StockFlowForm sff = new StockFlowForm(); sff.setFlowId(sif.getFlowNo()); sff.setSkuCode(sif.getSkuCode()); sff.setShortCode(sif.getShortCode()); sff.setStandard(sif.getStandard()); sff.setStuffNo(sif.getStuffNo()); sff.setSkuUnit(sif.getSkuUnit()); sff.setSkuNum(sif.getSkuNum()); sff.setPerCost(sif.getPerCost()); sff.setSkuType(sif.getSkuType()); sff.setRemark(sif.getRemark()); sff.setCreateBy(sif.getCreateBy()); sff.setCreateDate(new Date()); sff.setTransportMode(sif.getTransportMode()); sff.setOrderDollar(sif.getOrderDollar()); sff.setFreightTW(sif.getFreightTW()); return sff; }
/** * 订购入库 接收 1.先将实际收到零件全部入库(临时库存X),插入StockInfoForm和StockFlowForm,各recevie条。 2.修改PO状态,以及拆分PO * 分析PO数量和到货recevie数量: a. PO<=recevie : 将对应PO直接修改状态(已到货/已分配待领取); b. PO>recevie : * 拆分PO,原来记录的num改为PO-recevie,状态不变; 新增recevie条,并修改状态(已到货/已分配待领取); 3.调用分配逻辑 a. * 将销售零件进行状态修改或拆分,再判断销售单状态是否需要修改; b. 将销售零件的detailId赋值给库存requestId,保留该库存零件(已分配待领取) ; c. * 若入库有剩余,将剩余零件再分配给其他需要该零件的单子; * * @param para 收货信息 * @param saleNo 销售单号 * @param userId 操作人 * @return tag */ public synchronized int orderInReceive( String[][] para, String saleNo, Long userId, String transportMode) throws Exception { int tag = -1; ArrayList poList = new ArrayList(); ArrayList<StockInfoForm> stockList = new ArrayList<StockInfoForm>(); PartPoBo ppb = PartPoBo.getInstance(); PartInfoBo pib = PartInfoBo.getInstance(); // SaleInfoBo sib=SaleInfoBo.getInstance(); StockOutBo sob = StockOutBo.getInstance(); String inStuffNo = ""; for (int i = 0; i < para[0].length; i++) { PoForm pf = ppb.findById(new Long(para[0][i])); PartInfoForm pi = pib.find(pf.getStuffNo()); // 零件料号非法 if (pi == null) { throw new IllegalPoException(pf.getStuffNo()); } int intPoNum = pf.getOrderNum(); int intReceiveNum = Integer.parseInt(para[1][i]); if (intReceiveNum > 0) { // 插入库存信息表 StockInfoForm sif = new StockInfoForm(); sif.setCreateBy(userId); sif.setStuffNo(pf.getStuffNo()); sif.setSkuCode(pf.getSkuCode()); sif.setShortCode(pi.getShortCode()); sif.setStandard(pi.getStandard()); sif.setSkuUnit(pf.getSkuUnit()); sif.setSkuNum(intReceiveNum); sif.setPerCost( calculatePerCost(new Float(para[2][i]), new Float(para[4][i]), new Float(para[6][i]))); sif.setOrderDollar(new Float(para[3][i])); sif.setFreightTW(new Float(para[4][i])); sif.setInvoiceNo(para[5][i]); sif.setBinCode(para[7][i]); sif.setSkuType("A"); // 默认 sif.setStockStatus("X"); // 临时状态,等待到货分配时修改 sif.setRequestId(pf.getRequestId()); // 申请零件时的saleDetailId,到货分配时调用 sif.setSkuType("S"); sif.setCreateBy(userId); sif.setCreateDate(new Date()); sif.setFlowNo(FormNumberBuilder.getStockFlowId()); // 流水号fk sif.setTransportMode(transportMode); stockList.add(sif); inStuffNo += "," + sif.getStuffNo(); // 插入出入库流水表 StockFlowForm sff = this.infoToFlow(sif); sff.setSkuNum(intReceiveNum); sff.setRestNum(sob.getRestStock(sif.getStuffNo(), intReceiveNum, "I")); sff.setCustomerName(pf.getCustomerName()); sff.setFlowType("I"); sff.setFlowItem("D"); // 订购入库 sff.setFeeType(pf.getOrderType()); sff.setRequestId(pf.getPoNo()); sff.setFormNo(pf.getSaleNo()); sff.setOrderDollar(sif.getOrderDollar()); sff.setFreightTW(sif.getFreightTW()); sff.setInvoiceNo(sif.getInvoiceNo()); sff.setTransportMode(sif.getTransportMode()); sff.setBinCode(sif.getBinCode()); poList.add(sff); if (intPoNum <= intReceiveNum) { // a. PO<=recevie pf.setOrderStatus("C"); // 已到货 pf.setUpdateBy(userId); pf.setUpdateDate(new Date()); poList.add(pf); } else { // b. PO>recevie // 原来记录的num改为PO-recevie,仍然等待PO pf.setOrderNum(intPoNum - intReceiveNum); pf.setUpdateBy(userId); pf.setUpdateDate(new Date()); poList.add(pf); // 拆分出recevie条,状态已到货 PoForm newPo = new PoForm(); BeanUtils.copyProperties(newPo, pf); newPo.setPoNo(null); newPo.setOrderNum(intReceiveNum); newPo.setOrderStatus("C"); // 已到货 newPo.setCreateBy(userId); newPo.setCreateDate(new Date()); poList.add(newPo); } } } if (poList.size() > 0 && this.getBatchDao().saveOrUpdateBatch(poList)) { if (this.getBatchDao().insertBatch(stockList)) { tag = new ReceiveAllocateBo().allocate(stockList); // sob.inMerge(inStuffNo.substring(1).replace(",", "','")); } } return tag; }