之前的解释是:
出现这个问题,一般是由于事务类型设置不正确,检查事务类型的详细,特别是关于库存的即可解决。
这几天重新调试,发现是跟分录的一些属性有关。 特别是entry.setBaseUnit(material.getBaseUnit());和entry.setStorageOrgUnit(info.getStorageOrgUnit());
之前之所以以为事务类型问,是因为代码里面,会根据事务类型,带出来一些属性,进行计算。今天提取了对应的代码。。copy到一个工具类进行调试。
private CoreBaseInfo createEntryInfoOfOtherIssue_BJ(ImportParamInfo param, Map<String, Object> middleRS, CoreBaseInfo model) throws Exception{ OtherIssueBillInfo info = (OtherIssueBillInfo)model; StoreTypeInfo storeTypeInfo = info.getTransactionType().getStoreTypePre(); StoreStateInfo storeStateInfo = info.getTransactionType().getStoreStatePre(); OtherIssueBillEntryInfo entry = new OtherIssueBillEntryInfo(); info.getEntry().add(entry); entry.setParent(info); BigDecimal bdQty = BigDecimal.valueOf((Double)middleRS.get("FQTY")); entry.setSeq(((Double)middleRS.get("FSEQ")).intValue()); entry.setStorageOrgUnit(info.getStorageOrgUnit()); /* * 设置中间表传递过来的字段 */ MaterialInfo material = (MaterialInfo) SyncUtil.getObjectFromInitMap(param, middleRS, "FMATERIALID", true, ImportParamInfo.Init_Map_Material); if (material == null) { return null; } entry.setMaterial(material); entry.setUnit(material.getBaseUnit()); entry.setBaseUnit(material.getBaseUnit()); //entry.setMfg(item);//生产日期 //entry.setExp(item);//到期日期 //entry.setWarehouse(item);//仓库 //数量 entry.setQty(bdQty); entry.setBaseQty(bdQty); //批次 entry.setLot((String)middleRS.get("FLOT")); IObjectPK ipk = new ObjectUuidPK("j/kAAAALJqW76fiu"); WarehouseInfo warehouseInfo = WarehouseFactory.getLocalInstance(param.context).getWarehouseInfo(ipk); entry.setWarehouse(warehouseInfo); entry.setStoreType(storeTypeInfo); entry.setStoreStatus(storeStateInfo); entry.setRemark((String)middleRS.get("FREMARK")); return entry; }导入的分录这样设置就可以了。。。
另外,InvBillBaseControllerBean的updateSerialNumInventory代码,可提取到工具类进行测试。
public static void updateSerialNumInventory(Context ctx, InvBillBaseInfo billInfo) throws EASBizException, BOSException { if ((billInfo.getTransactionType() == null) || (billInfo.getTransactionType().getId() == null)) { return; } TransactionTypeInfo tti = billInfo.getTransactionType(); if (tti.getRIType() == null) { // } boolean isSaleBack = false; if (tti.getRIType().getValue() == 30) { isSaleBack = true; } boolean isSale = false; SerialNumberStatusEnum snstatus = InvServerUtils.getSnStatusByTranType(ctx, tti); if (snstatus == SerialNumberStatusEnum.NULL) { return; } if (snstatus == SerialNumberStatusEnum.OUTTHENIN) { isSale = false; } if (snstatus == SerialNumberStatusEnum.SALE) { isSale = true; } if (snstatus == SerialNumberStatusEnum.INWAREHOUSE) { isSale = false; } if (billInfo.isIsReversed()) { isSale = !isSale; } IObjectCollection iObjectCollection = (IObjectCollection)billInfo.get("entry"); int entrySize = iObjectCollection.size(); InvBillBaseEntryInfo ibb = null; MaterialSerialNumberInfo snInfo = null; MaterialInfo material = null; String[] materialIds = new String[entrySize]; String[] storageOrgIds = new String[entrySize]; String[] seqUnitIDS = new String[entrySize]; Set materialidSet = new HashSet(entrySize); String storageOrgId = billInfo.getStorageOrgUnit().getId().toString(); for (int i = 0; i < entrySize; i++) { ibb = (InvBillBaseEntryInfo)iObjectCollection.getObject(i); materialIds[i] = ibb.getMaterial().getId().toString(); storageOrgIds[i] = ibb.getStorageOrgUnit().getId().toString(); materialidSet.add(ibb.getMaterial().getId().toString()); } SelectorItemCollection sicCol = new SelectorItemCollection(); sicCol.add("isSequenceNo"); sicCol.add("material.id"); sicCol.add("orgUnit.id"); Map mapMaterialInventorys = DataLoaderHelper.loadMaterialInventorys(ctx, storageOrgId, materialidSet, sicCol); SelectorItemCollection siCol = new SelectorItemCollection(); siCol.add(new SelectorItemInfo("id")); siCol.add(new SelectorItemInfo("number")); siCol.add(new SelectorItemInfo("name")); siCol.add(new SelectorItemInfo("seqUnit.id")); siCol.add(new SelectorItemInfo("seqUnit.number")); siCol.add(new SelectorItemInfo("seqUnit.name")); Map mapMaterialSeq = DataLoaderHelper.loadMaterial(ctx, materialIds, siCol); boolean isNeedSele = false; MeasureUnitInfo seqUnit = null; HashMap map = new HashMap(); for (int i = 0; i < entrySize; i++) { /*if ((mapMaterialSeq != null) && (materialIds[i] != null) && (mapMaterialSeq.get(materialIds[i]) != null) && ((mapMaterialSeq.get(materialIds[i]) MaterialInfo))) { seqUnit = ((MaterialInfo)mapMaterialSeq.get(materialIds[i])).getSeqUnit(); }*/ if (seqUnit != null) { isNeedSele = true; seqUnitIDS[i] = seqUnit.getId().toString(); } else { seqUnitIDS[i] = ""; } } if (isNeedSele) { map = SCMServerUtils.getMultiMeasureUnits(ctx, materialIds, seqUnitIDS); } MaterialSerialNumberInfo[] serialNumberInfos = new MaterialSerialNumberInfo[entrySize]; for (int i = 0; i < entrySize; i++) { ibb = (InvBillBaseEntryInfo)iObjectCollection.getObject(i); MaterialInventoryInfo mii = (MaterialInventoryInfo)mapMaterialInventorys.get(ibb.getMaterial().getId().toString() + ibb.getStorageOrgUnit().getId().toString()); if ((mii != null) && (mii.isIsSequenceNo())) { if (ibb != null) { snInfo = new MaterialSerialNumberInfo(); snInfo.setBillID(billInfo.getId().toString()); snInfo.setBillEntryID(ibb.getId().toString()); snInfo.setIsReversed(billInfo.isIsReversed()); snInfo.setSoureBillID(ibb.getSourceBillId()); snInfo.setSoureBillEntryID(ibb.getSourceBillEntryId()); snInfo.setBillEntrySeq(ibb.getSeq()); if (isSale) { snInfo.setSnStatus(SerialNumberStatusEnum.SALE); } else { snInfo.setSnStatus(SerialNumberStatusEnum.INWAREHOUSE); } snInfo.setBillType(billInfo.getBillType()); snInfo.setBillNumber(billInfo.getNumber()); snInfo.setBillEntrySeq(ibb.getSeq()); snInfo.setStorageOrgUnit(ibb.getStorageOrgUnit()); snInfo.setMaterial(ibb.getMaterial()); material = ibb.getMaterial(); MeasureUnitInfo sNUnitInfo = material.getSeqUnit(); if (sNUnitInfo == null) { sNUnitInfo = ((MaterialInfo)mapMaterialSeq.get(material.getId().toString())).getSeqUnit(); if (sNUnitInfo == null) { return; } } BigDecimal baseQty = ibb.getBaseQty(); BigDecimal sNqty = baseQty; if (!ibb.getBaseUnit().getId().toString().equals(sNUnitInfo.getId().toString())) { BigDecimal coefficient = SCMConstant.BIGDECIMAL_ONE; MultiMeasureUnitInfo mulUnit = null; mulUnit = (MultiMeasureUnitInfo)map.get(material.getId().toString() + sNUnitInfo.getId().toString()); if (mulUnit != null) { coefficient = mulUnit.getBaseConvsRate(); int precision = mulUnit.getQtyPrecision(); if (coefficient != null) { sNqty = baseQty.divide(coefficient, precision, 4); } } } snInfo.setSnUnit(sNUnitInfo); snInfo.setSnQty(sNqty); snInfo.put("isSaleBack", Boolean.valueOf(isSaleBack)); serialNumberInfos[i] = snInfo; } } } //checkBillDuplicateSerialNumber(ctx, billInfo); IMaterialSerialNumber imsn = MaterialSerialNumberFactory.getLocalInstance(ctx); imsn.checkSerialNumber(serialNumberInfos); imsn.updateSerialInventory(billInfo); }