/** * 订购入库 接收 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; }
/** * 订购入库列表查询 * * @param orderNo * @return List 查询结果 */ public List orderInList(String orderNo) { List<String[]> orderInfoList = new ArrayList<String[]>(); try { // 查询订购中的某订单零件PO信息 String strHql = "from PoForm as po where po.orderNo= :orderNo and po.orderStatus='B'"; ArrayList<QueryParameter> paramList = new ArrayList<QueryParameter>(); QueryParameter param = new QueryParameter(); param.setName("orderNo"); param.setValue(orderNo); param.setHbType(Hibernate.STRING); paramList.add(param); List<PoForm> orderList = this.getDao().parameterQuery(strHql, paramList); for (int i = 0; orderList != null && i < orderList.size(); i++) { PoForm pf = orderList.get(i); String[] temp = new String[13]; temp[0] = pf.getPoNo().toString(); temp[1] = pf.getStuffNo(); temp[2] = pf.getModelCode(); temp[3] = pf.getSaleNo(); temp[4] = pf.getCustomerName(); temp[5] = pf.getDeliveryTime(); temp[6] = pf.getShippingAddress(); temp[7] = pf.getOrderNum().toString(); temp[8] = Operate.toFix(pf.getPerQuote(), 2); temp[9] = pf.getCreateDate().toLocaleString(); temp[10] = Operate.toFix( pf.getPerQuote() * CommonSearch.getInstance().getExchangeRate(pf.getSaleNo()), 2); temp[11] = pf.getTransportMode(); temp[12] = pf.getSkuCode(); orderInfoList.add(temp); } } catch (Exception e) { e.printStackTrace(); } return orderInfoList; }