参考文章:http://wenku.baidu.com/view/09e4ad3231126edb6f1a10e9.html
package com.kingdee.eas.scm.im.inv.app; import com.kingdee.bos.BOSException; import com.kingdee.bos.Context; import com.kingdee.bos.ctrl.common.util.StringUtil; import com.kingdee.bos.dao.IObjectPK; import com.kingdee.bos.dao.ormapping.ObjectUuidPK; import com.kingdee.bos.metadata.IMetaDataLoader; import com.kingdee.bos.metadata.MetaDataLoaderFactory; import com.kingdee.bos.metadata.entity.EntityObjectInfo; import com.kingdee.bos.metadata.entity.EntityViewInfo; import com.kingdee.bos.metadata.entity.FilterInfo; import com.kingdee.bos.metadata.entity.FilterItemCollection; import com.kingdee.bos.metadata.entity.FilterItemInfo; import com.kingdee.bos.metadata.query.util.CompareType; import com.kingdee.bos.util.BOSUuid; import com.kingdee.eas.base.codingrule.CodingRuleManagerFactory; import com.kingdee.eas.base.codingrule.ICodingRuleManager; import com.kingdee.eas.base.param.IParamControl; import com.kingdee.eas.base.param.ParamControlFactory; import com.kingdee.eas.base.permission.UserInfo; import com.kingdee.eas.basedata.assistant.CurrencyFactory; import com.kingdee.eas.basedata.assistant.CurrencyInfo; import com.kingdee.eas.basedata.assistant.ICurrency; import com.kingdee.eas.basedata.assistant.IMeasureUnit; import com.kingdee.eas.basedata.assistant.MeasureUnitCollection; import com.kingdee.eas.basedata.assistant.MeasureUnitFactory; import com.kingdee.eas.basedata.assistant.MeasureUnitInfo; import com.kingdee.eas.basedata.master.cssp.CustomerCollection; import com.kingdee.eas.basedata.master.cssp.CustomerFactory; import com.kingdee.eas.basedata.master.cssp.CustomerInfo; import com.kingdee.eas.basedata.master.cssp.ICustomer; import com.kingdee.eas.basedata.master.cssp.ISupplier; import com.kingdee.eas.basedata.master.cssp.SupplierCollection; import com.kingdee.eas.basedata.master.cssp.SupplierFactory; import com.kingdee.eas.basedata.master.cssp.SupplierInfo; import com.kingdee.eas.basedata.master.material.AccountType; import com.kingdee.eas.basedata.master.material.AsstAttrTypeInfo; import com.kingdee.eas.basedata.master.material.AsstAttrValueCollection; import com.kingdee.eas.basedata.master.material.AsstAttrValueFactory; import com.kingdee.eas.basedata.master.material.AsstAttrValueInfo; import com.kingdee.eas.basedata.master.material.IAsstAttrValue; import com.kingdee.eas.basedata.master.material.IMaterial; import com.kingdee.eas.basedata.master.material.IMultiMeasureUnit; import com.kingdee.eas.basedata.master.material.MaterialCollection; import com.kingdee.eas.basedata.master.material.MaterialCompanyInfoInfo; import com.kingdee.eas.basedata.master.material.MaterialFactory; import com.kingdee.eas.basedata.master.material.MaterialInfo; import com.kingdee.eas.basedata.master.material.MaterialInventoryInfo; import com.kingdee.eas.basedata.master.material.MultiMeasureUnitFactory; import com.kingdee.eas.basedata.master.material.MultiMeasureUnitInfo; import com.kingdee.eas.basedata.master.material.TimeUnitEnum; import com.kingdee.eas.basedata.org.CompanyOrgUnitInfo; import com.kingdee.eas.basedata.org.IOrgUnitRelation; import com.kingdee.eas.basedata.org.IStorageOrgUnit; import com.kingdee.eas.basedata.org.OrgType; import com.kingdee.eas.basedata.org.OrgUnitCollection; import com.kingdee.eas.basedata.org.OrgUnitInfo; import com.kingdee.eas.basedata.org.OrgUnitRelationFactory; import com.kingdee.eas.basedata.org.StorageOrgUnitCollection; import com.kingdee.eas.basedata.org.StorageOrgUnitFactory; import com.kingdee.eas.basedata.org.StorageOrgUnitInfo; import com.kingdee.eas.basedata.scm.common.BillTypeInfo; import com.kingdee.eas.basedata.scm.common.ITransactionType; import com.kingdee.eas.basedata.scm.common.TransactionTypeFactory; import com.kingdee.eas.basedata.scm.common.TransactionTypeInfo; import com.kingdee.eas.basedata.scm.im.inv.ILocation; import com.kingdee.eas.basedata.scm.im.inv.ISOAccreditWH; import com.kingdee.eas.basedata.scm.im.inv.IStoreState; import com.kingdee.eas.basedata.scm.im.inv.IStoreType; import com.kingdee.eas.basedata.scm.im.inv.IWarehouse; import com.kingdee.eas.basedata.scm.im.inv.LocationCollection; import com.kingdee.eas.basedata.scm.im.inv.LocationFactory; import com.kingdee.eas.basedata.scm.im.inv.LocationInfo; import com.kingdee.eas.basedata.scm.im.inv.SOAccreditWHFactory; import com.kingdee.eas.basedata.scm.im.inv.StoreFlagEnum; import com.kingdee.eas.basedata.scm.im.inv.StoreStateCollection; import com.kingdee.eas.basedata.scm.im.inv.StoreStateFactory; import com.kingdee.eas.basedata.scm.im.inv.StoreStateInfo; import com.kingdee.eas.basedata.scm.im.inv.StoreTypeCollection; import com.kingdee.eas.basedata.scm.im.inv.StoreTypeFactory; import com.kingdee.eas.basedata.scm.im.inv.StoreTypeInfo; import com.kingdee.eas.basedata.scm.im.inv.WHStateEnum; import com.kingdee.eas.basedata.scm.im.inv.WarehouseCollection; import com.kingdee.eas.basedata.scm.im.inv.WarehouseFactory; import com.kingdee.eas.basedata.scm.im.inv.WarehouseInfo; import com.kingdee.eas.common.EASBizException; import com.kingdee.eas.framework.CoreBaseInfo; import com.kingdee.eas.framework.CoreBillBaseInfo; import com.kingdee.eas.framework.ICoreBase; import com.kingdee.eas.scm.common.BillBaseStatusEnum; import com.kingdee.eas.scm.common.SCMBillException; import com.kingdee.eas.scm.common.app.SCMGroupServerUtils; import com.kingdee.eas.scm.common.app.SCMServerUtils; import com.kingdee.eas.scm.common.util.SCMUtils; import com.kingdee.eas.scm.im.inv.IInventoryInitBill; import com.kingdee.eas.scm.im.inv.InventoryInitBillCollection; import com.kingdee.eas.scm.im.inv.InventoryInitBillFactory; import com.kingdee.eas.scm.im.inv.InventoryInitBillInfo; import com.kingdee.eas.scm.im.inv.InventoryInitEntryCollection; import com.kingdee.eas.scm.im.inv.InventoryInitEntryInfo; import com.kingdee.eas.scm.sm.pur.util.DataImportUtils; import com.kingdee.eas.tools.datatask.AbstractDataTransmission; import com.kingdee.eas.tools.datatask.core.TaskExternalException; import com.kingdee.eas.tools.datatask.runtime.DataToken; import com.kingdee.eas.util.app.ContextUtil; import com.kingdee.jdbc.rowset.IRowSet; import java.math.BigDecimal; import java.sql.Timestamp; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Hashtable; import java.util.LinkedHashSet; public class InvInitBillDataImport extends AbstractDataTransmission { private static final String[] DECIMAL_ENTRY_PROPERTY = { "qty", "costPrice", "amount", "diffAmount", "yearReceiptQty", "yearReceiptAmount", "yearReceiptCostDiff", "yearIssueQty", "yearIssueAmount", "yearIssueCostDiff", "assistQty", "yearReceiptAssistQty", "yearIssueAssistQty" }; private static final String[] QTY_PROPERTY = { "qty", "yearReceiptQty", "yearIssueQty" }; private static final String[] ASSISTQTY_PROPERTY = { "assistQty", "yearReceiptAssistQty", "yearIssueAssistQty" }; private static final String[] PRICE_PROPERTY = { "costPrice" }; private static final String[] AMOUNT_PROPERTY = { "amount", "diffAmount", "yearReceiptAmount", "yearIssueAmount", "yearReceiptCostDiff", "yearIssueCostDiff" }; private boolean isArUpdateInventory = false; private static final String[] DATE_BILL_PROPERTY = { "bizDate", "mfg", "exp" }; private static final String[] DATE_ENTRY_PROPERTY = { "mfg", "exp" }; private static final int WAREHOUSE = 0; private static final int CUSTOMER = 1; private static final int SUPPLIER = 2; private static final int ASSISTPROPERTY = 3; private static final int ASSISTUNIT = 4; private static String resource = "com.kingdee.eas.scm.im.inv.WarehsManageResource"; private static String RESOURCE = "com.kingdee.eas.scm.im.inv.InvInitBillResource"; CompanyOrgUnitInfo cou = null; StorageOrgUnitInfo sou = null; InventoryInitBillInfo invInit = null; private static final BigDecimal ZERO = new BigDecimal("0.00"); private static String getResource(Context ctx, String strKey) { if ((strKey == null) || (strKey.trim().length() == 0)) { return null; } return SCMUtils.getResource(resource, strKey, ctx); } private static String getMyResource(Context ctx, String strKey) { if (StringUtil.isEmptyString(strKey)) { return null; } return SCMUtils.getResource(RESOURCE, strKey, ctx); } protected ICoreBase getController(Context ctx) throws TaskExternalException { try { return InventoryInitBillFactory.getLocalInstance(ctx); } catch (BOSException e) { } throw new TaskExternalException("", e); } private InventoryInitBillInfo transmitHead(Hashtable lineData, Context ctx) throws TaskExternalException { this.invInit = new InventoryInitBillInfo(); boolean noNumber = false; boolean userCodingRuleManager = false; Object number = ((DataToken)lineData.get("number")).data; if ((number != null) && (number.toString().trim().length() > 0)) { this.invInit.setNumber(number.toString().trim()); String existId = getIdFromNumber(number.toString().trim(), ctx); if ((!isSltImportUpdate()) && (!StringUtil.isEmptyString(existId))) { throw new TaskExternalException(number.toString().trim() + getResource(ctx, "EXISTS")); } if ((isSltImportUpdate()) && (!StringUtil.isEmptyString(existId))) { InventoryInitBillInfo existInfo = null; try { existInfo = ((IInventoryInitBill)getController(ctx)).getInventoryInitBillInfo(new ObjectUuidPK(existId)); } catch (Exception e) { throw new TaskExternalException("", e); } if (BillBaseStatusEnum.AUDITED.equals(existInfo.getBaseStatus())) { throw new TaskExternalException(number.toString().trim() + getMyResource(ctx, "import_bill_audited")); } } if (StringUtil.isEmptyString(existId)) { userCodingRuleManager = true; noNumber = true; } } else { noNumber = true; } DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); for (int i = 0; i < DATE_BILL_PROPERTY.length; i++) { Object date = ((DataToken)lineData.get(DATE_BILL_PROPERTY[i])).data; if ((date != null) && (date.toString().length() > 0)) { try { date = df.parse(date.toString()); } catch (ParseException e) { e.printStackTrace(); throw new TaskExternalException(getDateString(i, ctx) + getResource(ctx, "InvalidDateFormat") + date.toString()); } if ((date != null) && ((date instanceof Date))) this.invInit.setDate(DATE_BILL_PROPERTY[i], (Date)date); } else { if (!DATE_BILL_PROPERTY[i].equals("bizDate")) { continue; } throw new TaskExternalException(getDateString(i, ctx) + getResource(ctx, "InvalidDateFormat") + date.toString()); } } try { Object souData = ((DataToken)lineData.get("storageOrgUnit")).data; if ((souData != null) && (souData.toString().trim().length() > 0)) { IStorageOrgUnit isou = StorageOrgUnitFactory.getLocalInstance(ctx); StorageOrgUnitCollection collection = isou.getStorageOrgUnitCollection(getFilter(souData.toString().trim())); if ((collection != null) && (collection.size() > 0)) { this.sou = collection.get(0); if (!this.sou.isIsBizUnit()) { throw new TaskExternalException(getResource(ctx, "StorageOrgUnitIsNotBizUnit")); } this.invInit.setStorageOrgUnit(this.sou); } else { throw new TaskExternalException(souData.toString().trim() + " " + getResource(ctx, "StorageOrgUnitNotExists")); } } else { throw new TaskExternalException(getResource(ctx, "StorageOrgUnitNotNull")); } } catch (BOSException e) { throw new TaskExternalException(e.getMessage(), e.getCause()); } try { if (noNumber) { boolean isUsedParam = DataImportUtils.getImportParam(ctx); if (isUsedParam) { String souID = this.sou.getId().toString().trim(); ICodingRuleManager iCodingRuleManager = CodingRuleManagerFactory.getLocalInstance(ctx); if (iCodingRuleManager.isExist(this.invInit, souID)) { this.invInit.setNumber(iCodingRuleManager.getNumber(this.invInit, souID, "")); } else if (!userCodingRuleManager) { IMetaDataLoader imeataLoader = MetaDataLoaderFactory.getLocalMetaDataLoader(ctx); EntityObjectInfo entityObjectInfo = imeataLoader.getEntity(this.sou.getBOSType()); String[] materialNames = new String[1]; materialNames[0] = entityObjectInfo.getAlias(); throw new SCMBillException(SCMBillException.NOCORDRULE, materialNames); } } else if (!userCodingRuleManager) { SCMUtils.getResource("com.kingdee.eas.scm.im.inv.app.OtherBillDataImportResource", "UnUseDataImportParam", ctx); } } } catch (Exception e) { throw new TaskExternalException(e.getMessage(), e.getCause()); } try { this.invInit.setCU(ContextUtil.getCurrentCtrlUnit(ctx)); IOrgUnitRelation iUnitRel = OrgUnitRelationFactory.getLocalInstance(ctx); OrgUnitCollection orgCol = iUnitRel.getToUnit(this.sou.getId().toString(), 4, 1); if (orgCol.get(0) != null) { this.cou = ((CompanyOrgUnitInfo)orgCol.get(0)); this.invInit.setCompanyOrgUnit(this.cou); } else { throw new TaskExternalException(getResource(ctx, "NoCompanyOrgUnit")); } UserInfo userInfo = ContextUtil.getCurrentUserInfo(ctx); this.invInit.setCreator(userInfo); Date d = new Date(); this.invInit.setCreateTime(new Timestamp(d.getTime())); this.invInit.setBaseStatus(BillBaseStatusEnum.TEMPORARILYSAVED); ITransactionType itt = TransactionTypeFactory.getLocalInstance(ctx); TransactionTypeInfo tti = itt.getTransactionTypeInfo(new ObjectUuidPK(BOSUuid.read("0a7c476c-0106-1000-e000-0261c0a812e6B008DCA7"))); this.invInit.setTransactionType(tti); BillTypeInfo bii = new BillTypeInfo(); bii.setId(BOSUuid.read("528d806a-0106-1000-e000-0194c0a812e6463ED552")); bii.setNumber("100"); this.invInit.setBillType(bii); String isUpdateByARBILL = ParamControlFactory.getLocalInstance(ctx).getParamValue(new ObjectUuidPK(this.cou.getId()), "CONSIGNSALES"); if (isUpdateByARBILL != null) this.isArUpdateInventory = isUpdateByARBILL.trim().equals("true"); } catch (Exception e) { throw new TaskExternalException(e.getMessage(), e.getCause()); } return this.invInit; } private InventoryInitEntryInfo transmitEntry(Hashtable hsData, Context ctx) throws TaskExternalException { if (hsData == null) { return null; } InventoryInitEntryInfo entryInfo = new InventoryInitEntryInfo(); MaterialInfo materialInfo = new MaterialInfo(); MeasureUnitInfo mui = new MeasureUnitInfo(); MaterialCompanyInfoInfo materialCompanyInfo = null; MaterialInventoryInfo materialInventory = null; StoreTypeInfo storeTypeInfo = new StoreTypeInfo(); this.cou = this.invInit.getCompanyOrgUnit(); this.sou = this.invInit.getStorageOrgUnit(); StringBuffer errorString = new StringBuffer(); DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); for (int i = 0; i < DATE_ENTRY_PROPERTY.length; i++) { Object o = ((DataToken)hsData.get(DATE_ENTRY_PROPERTY[i])).data; if ((o == null) || (o.toString().length() <= 0)) continue; try { o = df.parse(o.toString()); } catch (ParseException pex) { pex.printStackTrace(); throw new TaskExternalException(getDateString(i + 1, ctx) + getResource(ctx, "InvalidDateFormat") + o.toString()); } if ((o != null) && ((o instanceof Date))) { Date value = (Date)o; if (value != null) { entryInfo.setDate(DATE_ENTRY_PROPERTY[i], value); } } } for (int i = 0; i < DECIMAL_ENTRY_PROPERTY.length; i++) { try { Object o = ((DataToken)hsData.get(DECIMAL_ENTRY_PROPERTY[i])).data; if ((o != null) && (o.toString().trim().length() > 0)) { BigDecimal value = new BigDecimal(o.toString()); if (value != null) { if (("costPrice".equals(DECIMAL_ENTRY_PROPERTY[i])) && (value.compareTo(ZERO) < 0)) { throw new TaskExternalException(DECIMAL_ENTRY_PROPERTY[i] + getMyResource(ctx, "import_price_must_positive")); } entryInfo.setBigDecimal(DECIMAL_ENTRY_PROPERTY[i], value); } } else { entryInfo.setBigDecimal(DECIMAL_ENTRY_PROPERTY[i], ZERO); } } catch (NumberFormatException nex) { nex.printStackTrace(); throw new TaskExternalException(DECIMAL_ENTRY_PROPERTY[i] + getResource(ctx, "FormatMustBeNumber")); } } try { String number = null; Object data = ((DataToken)hsData.get("material")).data; if ((data != null) && (data.toString().length() > 0)) { number = data.toString(); if ((number != null) && (number.trim().length() > 0)) { IMaterial imaterial = MaterialFactory.getLocalInstance(ctx); MaterialCollection collection = imaterial.getMaterialCollection(getFilter(number)); if ((collection != null) && (collection.size() > 0)) { MaterialInfo info = collection.get(0); if (info != null) { entryInfo.setMaterial(info); materialInfo = info; materialInventory = imaterial.getInventoryInfo(materialInfo.getId().toString(), this.sou.getId().toString()); if (materialInventory == null) { throw new TaskExternalException(materialInfo.getNumber() + " " + this.sou.getNumber() + " " + getResource(ctx, "NO_INVENTORY_PROPERTY")); } materialCompanyInfo = imaterial.getCompanyInfo(materialInfo.getId().toString(), this.cou.getId().toString()); if (materialCompanyInfo == null) { throw new TaskExternalException(materialInfo.getNumber() + " " + this.cou.getNumber() + " " + getResource(ctx, "NO_COMPANY_PROPERTY")); } if (materialCompanyInfo.getAccountType() == null) { throw new TaskExternalException(materialInfo.getNumber() + getResource(ctx, "NotAccountType")); } entryInfo.setAccountType(materialCompanyInfo.getAccountType()); } else { throw new TaskExternalException(data.toString() + " " + getResource(ctx, "MaterialNotExists")); } } else { throw new TaskExternalException(data.toString() + " " + getResource(ctx, "MaterialNotExists")); } } } else { throw new TaskExternalException(getResource(ctx, "MaterialNotExists")); } data = ((DataToken)hsData.get("storeType")).data; if (data != null) { number = data.toString(); if (number != null) { IStoreType ist = StoreTypeFactory.getLocalInstance(ctx); StoreTypeCollection collection = ist.getStoreTypeCollection(getFilter(number)); if ((collection != null) && (collection.size() > 0)) { StoreTypeInfo info = collection.get(0); if (info != null) { entryInfo.setStoreType(info); storeTypeInfo = info; } else { throw new TaskExternalException(data.toString() + " " + getResource(ctx, "StoreTypeNotExists")); } } else { throw new TaskExternalException(data.toString() + " " + getResource(ctx, "StoreTypeNotExists")); } } } else { throw new TaskExternalException(getResource(ctx, "StoreTypeNotExists")); } data = ((DataToken)hsData.get("lot")).data; checkLotInfo(ctx, materialInfo, data, this.sou, entryInfo); if ((data == null) || (data.toString() == null) || (data.toString().trim().length() == 0)) entryInfo.setLot(null); else { entryInfo.setLot(data.toString().trim()); } if (materialInventory.isIsPeriodValid()) { Date mfg = entryInfo.getMfg(); Date exp = entryInfo.getExp(); if (mfg != null) { TimeUnitEnum periodValidUnit = materialInventory.getPeriodValidUnit(); int unit = 3; if (periodValidUnit != null) { unit = periodValidUnit.getValue(); } int periodValid = materialInventory.getPeriodValid(); Date exp2 = getEXP(mfg, unit, periodValid); entryInfo.setExp(exp2); } } data = ((DataToken)hsData.get("assistProperty")).data; checkMaterialInfo(ctx, materialInfo, data, 3); if (data != null) { number = data.toString(); if ((number != null) && (number.trim().length() > 0)) { IAsstAttrValue iasstAttrValue = AsstAttrValueFactory.getLocalInstance(ctx); AsstAttrValueCollection collection = iasstAttrValue.getAsstAttrValueCollection("where number='" + number + "'"); if ((collection != null) && (collection.size() > 0)) { AsstAttrValueInfo info = collection.get(0); if (info != null) entryInfo.setAssistProperty(info); } else { throw new TaskExternalException(number + getResource(ctx, "AsstAttrValueExists")); } } } data = ((DataToken)hsData.get("customer")).data; if (data != null) { number = data.toString(); if ((number != null) && (number.trim().length() > 0)) { ICustomer ic = CustomerFactory.getLocalInstance(ctx); CustomerCollection collection = ic.getCustomerCollection(getFilter(number)); if ((collection != null) && (collection.size() > 0)) { CustomerInfo info = collection.get(0); if (info != null) { entryInfo.setCustomer(info); } else { throw new TaskExternalException(data.toString() + " " + getResource(ctx, "CustomerNotExists")); } } else { throw new TaskExternalException(data.toString() + " " + getResource(ctx, "CustomerNotExists")); } } } checkStoreTypeEtc(ctx, storeTypeInfo, data, 1); data = ((DataToken)hsData.get("supplier")).data; if (data != null) { number = data.toString(); if ((number != null) && (number.trim().length() > 0)) { ISupplier is = SupplierFactory.getLocalInstance(ctx); SupplierCollection collection = is.getSupplierCollection(getFilter(number)); if ((collection != null) && (collection.size() > 0)) { SupplierInfo info = collection.get(0); if (info != null) { entryInfo.setSupplier(info); } else { throw new TaskExternalException(data.toString() + " " + getResource(ctx, "SupplierNotExists")); } } else { throw new TaskExternalException(data.toString() + " " + getResource(ctx, "SupplierNotExists")); } } } checkStoreTypeEtc(ctx, storeTypeInfo, data, 2); data = ((DataToken)hsData.get("storeStatus")).data; if (data != null) { number = data.toString(); if (number != null) { IStoreState iss = StoreStateFactory.getLocalInstance(ctx); StoreStateCollection collection = iss.getStoreStateCollection(getFilter(number)); if ((collection != null) && (collection.size() > 0)) { StoreStateInfo info = collection.get(0); if (info != null) { entryInfo.setStoreStatus(info); } else { throw new TaskExternalException(data.toString() + " " + getResource(ctx, "StoreStatusNotExists")); } } else { throw new TaskExternalException(data.toString() + " " + getResource(ctx, "StoreStatusNotExists")); } } } else { throw new TaskExternalException(getResource(ctx, "StoreStatusNotExists")); } WarehouseInfo warehouseInfo = new WarehouseInfo(); data = ((DataToken)hsData.get("warehouse")).data; if ((data != null) && (data.toString() != null) && (data.toString().length() > 0)) { number = data.toString(); if (number != null) { IWarehouse iw = WarehouseFactory.getLocalInstance(ctx); WarehouseCollection collection = iw.getWarehouseCollection(getFilter(number)); if ((collection != null) && (collection.size() > 0)) { WarehouseInfo info = collection.get(0); if (info != null) { if (!info.getWhState().equals(WHStateEnum.ACTIVE)) { throw new TaskExternalException(info.getNumber() + " " + getResource(ctx, "WarehouseNotActive")); } checkWarehouse(ctx, info, this.sou); entryInfo.setWarehouse(info); warehouseInfo = info; } else { throw new TaskExternalException(data.toString() + " " + getResource(ctx, "WarehouseNotExists")); } } else { throw new TaskExternalException(data.toString() + " " + getResource(ctx, "WarehouseNotExists")); } } } else if (isWarehouseLotNecessary(storeTypeInfo)) { throw new TaskExternalException(getResource(ctx, "WarehouseNotExists")); } checkStoreTypeEtc(ctx, storeTypeInfo, data, 0); data = ((DataToken)hsData.get("location")).data; if ((warehouseInfo.isHasLocation()) && ((data == null) || (data.toString().length() <= 0))) { throw new TaskExternalException(warehouseInfo.getNumber() + " " + getResource(ctx, "LocationMustNotBeNull")); } if ((!warehouseInfo.isHasLocation()) && (data != null) && (data.toString().length() > 0)) { String warehsNumber = warehouseInfo.getNumber(); if ((warehsNumber == null) || (warehsNumber.trim().length() == 0)) { warehsNumber = ""; } throw new TaskExternalException(warehsNumber + " " + getResource(ctx, "LocationMustBeNull")); } if (data != null) { number = data.toString(); if ((number != null) && (number.trim().length() > 0)) { ILocation il = LocationFactory.getLocalInstance(ctx); EntityViewInfo viewInfo = new EntityViewInfo(); FilterInfo filter = new FilterInfo(); filter.getFilterItems().add(new FilterItemInfo("number", number, CompareType.EQUALS)); filter.getFilterItems().add(new FilterItemInfo("Warehouse.id", warehouseInfo.getId().toString(), CompareType.EQUALS)); viewInfo.setFilter(filter); LocationCollection collection = il.getLocationCollection(viewInfo); if ((collection != null) && (collection.size() > 0)) { LocationInfo info = collection.get(0); if (info != null) { if (!info.getState().equals(WHStateEnum.ACTIVE)) { throw new TaskExternalException(info.getNumber() + " " + getResource(ctx, "LocationNotActive")); } if (!warehouseInfo.getId().toString().equals(info.getWarehouse().getId().toString())) { throw new TaskExternalException(info.getNumber() + " " + getMyResource(ctx, "import_location_not_match_warehouse") + " " + warehouseInfo.getNumber()); } entryInfo.setLocation(info); } else { throw new TaskExternalException(data.toString() + " " + getResource(ctx, "LocationNotExists")); } } else { throw new TaskExternalException(data.toString() + " " + getResource(ctx, "LocationNotExists")); } } } data = ((DataToken)hsData.get("unit")).data; if (data != null) { number = data.toString(); if (number != null) { IMeasureUnit imu = MeasureUnitFactory.getLocalInstance(ctx); MeasureUnitCollection collection = imu.getMeasureUnitCollection(getFilter(number)); if ((collection != null) && (collection.size() > 0)) { MeasureUnitInfo info = collection.get(0); checkUnit(ctx, materialInfo, info); if (info != null) { entryInfo.setUnit(info); mui = info; } else { throw new TaskExternalException(data.toString() + " " + getResource(ctx, "UnitNotExists")); } } else { throw new TaskExternalException(data.toString() + " " + getResource(ctx, "UnitNotExists")); } } } else { throw new TaskExternalException(getResource(ctx, "UnitNotExists")); } if (entryInfo.getUnit() != null) { MultiMeasureUnitInfo mmu = MultiMeasureUnitFactory.getLocalInstance(ctx).getMultiUnit(materialInfo.getId().toString(), entryInfo.getUnit().getId().toString()); if (mmu != null) { int qtyPrecision = mmu.getQtyPrecision(); for (int i = 0; i < QTY_PROPERTY.length; i++) { if (entryInfo.getBigDecimal(QTY_PROPERTY[i]) != null) { entryInfo.setBigDecimal(QTY_PROPERTY[i], entryInfo.getBigDecimal(QTY_PROPERTY[i]).setScale(qtyPrecision, 4)); } } } } data = ((DataToken)hsData.get("assistUnit")).data; checkMaterialInfo(ctx, materialInfo, data, 4); if (data != null) { number = data.toString(); if ((number != null) && (number.trim().length() > 0)) { IMeasureUnit imu = MeasureUnitFactory.getLocalInstance(ctx); MeasureUnitCollection collection = imu.getMeasureUnitCollection(getFilter(number)); if ((collection != null) && (collection.size() > 0)) { MeasureUnitInfo info = collection.get(0); if (info != null) { checkAssistUnit(ctx, materialInfo, info); entryInfo.setAssistUnit(info); } else { throw new TaskExternalException(data.toString() + " " + getResource(ctx, "AssistUnitNotExists")); } } else { throw new TaskExternalException(data.toString() + " " + getResource(ctx, "AssistUnitNotExists")); } } } if (entryInfo.getAssistUnit() != null) { MultiMeasureUnitInfo assistMmu = MultiMeasureUnitFactory.getLocalInstance(ctx).getMultiUnit(materialInfo.getId().toString(), entryInfo.getAssistUnit().getId().toString()); if (assistMmu != null) { int assistQtyPrecision = assistMmu.getQtyPrecision(); for (int i = 0; i < ASSISTQTY_PROPERTY.length; i++) { if (entryInfo.getBigDecimal(ASSISTQTY_PROPERTY[i]) != null) { entryInfo.setBigDecimal(ASSISTQTY_PROPERTY[i], entryInfo.getBigDecimal(ASSISTQTY_PROPERTY[i]).setScale(assistQtyPrecision, 4)); } } if ((entryInfo.getAssistQty() == null) || (entryInfo.getAssistQty().compareTo(ZERO) == 0)) { BigDecimal qty = entryInfo.getQty(); BigDecimal assisqtyQty = InvAppUtils.getMultiUnitQty(ctx, mui, entryInfo.getAssistUnit(), materialInfo, qty); entryInfo.setAssistQty(assisqtyQty); } } } } catch (Exception e) { throw new TaskExternalException(e.getMessage(), e.getCause()); } try { IMeasureUnit imu = MeasureUnitFactory.getLocalInstance(ctx); IObjectPK pk = new ObjectUuidPK(materialInfo.getBaseUnit().getId()); MeasureUnitInfo baseUnit = imu.getMeasureUnitInfo(pk); entryInfo.setBaseUnit(baseUnit); BigDecimal price = entryInfo.getCostPrice(); BigDecimal amount = entryInfo.getAmount(); BigDecimal yearRecAmount = entryInfo.getYearReceiptAmount(); BigDecimal yearIssAmount = entryInfo.getYearIssueAmount(); BigDecimal qty = entryInfo.getQty(); BigDecimal baseQty = InvAppUtils.getBaseUnitQty(ctx, mui, baseUnit, materialInfo, qty); entryInfo.setBaseQty(baseQty); ICurrency ic = CurrencyFactory.getLocalInstance(ctx); CurrencyInfo ci = ic.getCurrencyInfo(new ObjectUuidPK(this.cou.getBaseCurrency().getId())); if (amount != null) { amount = amount.setScale(ci.getPrecision(), 4); } if (yearRecAmount != null) { yearRecAmount = yearRecAmount.setScale(ci.getPrecision(), 4); } if (yearIssAmount != null) { yearIssAmount = yearIssAmount.setScale(ci.getPrecision(), 4); } if (materialCompanyInfo != null) { AccountType accountType = materialCompanyInfo.getAccountType(); if (accountType.equals(AccountType.STANDARDCOST)) { BigDecimal standardCost = materialCompanyInfo.getStandardCost(); BigDecimal unitPrice = InvAppUtils.getUnitPrice(ctx, materialInfo, standardCost, baseUnit, mui); if (unitPrice.compareTo(price) != 0) { errorString.append(materialInfo.getNumber()).append(" ").append(getResource(ctx, "PRICE_NOT_EQUAL_STANDARDCOST")).append(unitPrice).append(" ").append(price); throw new TaskExternalException(errorString.toString()); } BigDecimal aAmount = qty.multiply(price); aAmount = aAmount.setScale(ci.getPrecision(), 4); if (aAmount.compareTo(amount) != 0) { errorString = new StringBuffer(); errorString.append(materialInfo.getNumber()).append(" ").append(getResource(ctx, "AmountIsError")).append(qty).append("×").append(price).append("=").append(aAmount).append(" != ").append(amount); throw new TaskExternalException(errorString.toString()); } } else if ((qty != null) && (qty.compareTo(ZERO) != 0)) { BigDecimal aPrice = amount.divide(qty, materialInfo.getPricePrecision(), 4); if (aPrice.compareTo(price) != 0) { errorString = new StringBuffer(); errorString.append(materialInfo.getNumber()).append(" ").append(getResource(ctx, "PriceIsError")).append(amount).append("/").append(qty).append("=").append(aPrice).append(" != ").append(price); } } } entryInfo.setPrice(price); BigDecimal recQty = entryInfo.getYearReceiptQty(); BigDecimal baseRecQty = InvAppUtils.getBaseUnitQty(ctx, mui, baseUnit, materialInfo, recQty); entryInfo.setYearReceiptQty(baseRecQty); BigDecimal isuQty = entryInfo.getYearIssueQty(); BigDecimal baseIsuQty = InvAppUtils.getBaseUnitQty(ctx, mui, baseUnit, materialInfo, isuQty); entryInfo.setYearIssueQty(baseIsuQty); if ((materialCompanyInfo != null) && (materialCompanyInfo.getAccountType().equals(AccountType.STANDARDCOST))) { if ((recQty != null) && (yearRecAmount != null) && (recQty.multiply(price).setScale(ci.getPrecision(), 4).compareTo(yearRecAmount) != 0)) { throw new TaskExternalException(materialInfo.getNumber() + " " + getResource(ctx, "YearRecAmountIsError")); } if ((isuQty != null) && (yearIssAmount != null) && (isuQty.multiply(price).setScale(ci.getPrecision(), 4).compareTo(yearIssAmount) != 0)) { throw new TaskExternalException(materialInfo.getNumber() + " " + getResource(ctx, "YearIssueAmountIsError")); } } if ((materialCompanyInfo != null) && (!AccountType.STANDARDCOST.equals(materialCompanyInfo.getAccountType()))) { entryInfo.setDiffAmount(ZERO); entryInfo.setYearReceiptCostDiff(ZERO); entryInfo.setYearIssueCostDiff(ZERO); } if (!storeTypeInfo.isIsForwardAmt()) { entryInfo.setAmount(ZERO); entryInfo.setDiffAmount(ZERO); entryInfo.setYearIssueAmount(ZERO); entryInfo.setYearIssueCostDiff(ZERO); entryInfo.setYearReceiptAmount(ZERO); entryInfo.setYearReceiptCostDiff(ZERO); } } catch (Exception e) { throw new TaskExternalException(e.getMessage(), e.getCause()); } if (errorString.length() > 0) { throw new TaskExternalException(errorString.toString()); } return entryInfo; } public static Date getEXP(Date curDate, int unit, int unitValue) { if (curDate != null) { Calendar calendar = Calendar.getInstance(); calendar.setTime(curDate); int field = 5; switch (unit) { case 1: field = 1; break; case 2: field = 2; break; case 3: field = 5; break; default: field = 5; } calendar.add(field, unitValue); return calendar.getTime(); } return null; } public CoreBaseInfo transmit(Hashtable hsData, Context ctx) throws TaskExternalException { this.invInit = null; int keyCursor = 0; for (int i = 0; i < hsData.size(); i++) { Hashtable lineData = (Hashtable)hsData.get(new Integer(i)); if (keyCursor == 0) { this.invInit = transmitHead(lineData, ctx); if (this.invInit == null) { return null; } } InventoryInitEntryInfo entry = transmitEntry(lineData, ctx); int seq = this.invInit.getEntry().size() + 1; entry.setSeq(seq); entry.setParent(this.invInit); entry.setStorageOrgUnit(this.sou); entry.setCompanyOrgUnit(this.cou); this.invInit.getEntry().add(entry); keyCursor++; } return this.invInit; } private void checkWarehouse(Context ctx, WarehouseInfo warehouseInfo, StorageOrgUnitInfo sou) throws TaskExternalException, BOSException, EASBizException { ISOAccreditWH iso = SOAccreditWHFactory.getLocalInstance(ctx); FilterInfo fi = new FilterInfo(); fi.getFilterItems().add(new FilterItemInfo("WAREHOUSE", warehouseInfo.getId().toString(), CompareType.EQUALS)); fi.getFilterItems().add(new FilterItemInfo("STORAGEORG", sou.getId().toString(), CompareType.EQUALS)); if (!iso.exists(fi)) { throw new TaskExternalException(warehouseInfo.getNumber() + "," + sou.getNumber() + " " + getResource(ctx, "RelationNotExists")); } if (iso.isStarted(sou, warehouseInfo)) { throw new TaskExternalException(warehouseInfo.getNumber() + "," + sou.getNumber() + " " + getResource(ctx, "AlreadyClosed")); } } private void checkLotInfo(Context ctx, MaterialInfo materialInfo, Object data, StorageOrgUnitInfo sou, InventoryInitEntryInfo entryInfo) throws TaskExternalException, BOSException, EASBizException { IMaterial iMaterial = MaterialFactory.getLocalInstance(ctx); MaterialInventoryInfo materialInventoryInfo = iMaterial.getInventoryInfo(materialInfo.getId().toString(), sou.getId().toString()); boolean isPeriodValid = materialInventoryInfo.isIsPeriodValid(); boolean isLotNumber = materialInventoryInfo.isIsLotNumber(); Date exp = entryInfo.getExp(); Date mfg = entryInfo.getMfg(); if ((!isLotNumber) && (data != null) && (data.toString().length() > 0)) { throw new TaskExternalException(materialInfo.getNumber() + getResource(ctx, "NotLotManager")); }if ((isLotNumber) && ((data == null) || (data.toString().length() <= 0)) && (isWarehouseLotNecessary(entryInfo.getStoreType()))) { throw new TaskExternalException(materialInfo.getNumber() + getResource(ctx, "LotManager")); }if ((isLotNumber) && (data != null) && (data.toString().length() > 0) && (!isWarehouseLotNecessary(entryInfo.getStoreType()))) { throw new TaskExternalException(materialInfo.getNumber() + getResource(ctx, "ArUpdateInventoryLotNotNull")); }if ((!isPeriodValid) && (mfg != null) && (mfg.toString().length() > 0)) { throw new TaskExternalException(materialInfo.getNumber() + getResource(ctx, "NotPVManagerMFGNull")); }if ((isPeriodValid) && ((mfg == null) || (mfg.toString().length() <= 0))) { throw new TaskExternalException(materialInfo.getNumber() + getResource(ctx, "NotPVManagerMFGNotNull")); }if ((!isPeriodValid) && (exp != null) && (exp.toString().length() > 0)) { throw new TaskExternalException(materialInfo.getNumber() + getResource(ctx, "NotPVManagerEXPNull")); }if ((isPeriodValid) && ((exp == null) || (exp.toString().length() <= 0))) { throw new TaskExternalException(materialInfo.getNumber() + getResource(ctx, "NotPVManagerEXPNotNull")); } if (isPeriodValid) { if (entryInfo.getExp().before(entryInfo.getMfg())) throw new TaskExternalException(materialInfo.getNumber() + getResource(ctx, "EXPMustBeforeEXP")); } } private void checkUnit(Context ctx, MaterialInfo materialInfo, MeasureUnitInfo mui) throws TaskExternalException, BOSException, EASBizException { IMultiMeasureUnit immu = MultiMeasureUnitFactory.getLocalInstance(ctx); MultiMeasureUnitInfo mmui = immu.getMultiUnit(materialInfo.getId().toString(), mui.getId().toString()); if (mmui == null) { throw new TaskExternalException(materialInfo.getNumber() + getResource(ctx, "UnitNotExists")); } } private void checkMaterialInfo(Context ctx, MaterialInfo materialInfo, Object data, int type) throws TaskExternalException, BOSException { if (type == 3) { AsstAttrTypeInfo asstAttrTypeInfo = materialInfo.getAssistAttr(); if ((asstAttrTypeInfo == null) && (data != null) && (data.toString().length() > 0)) { throw new TaskExternalException(materialInfo.getNumber() + getResource(ctx, "NotSetAssistProperty")); }if ((asstAttrTypeInfo != null) && ((data == null) || (data.toString().length() <= 0))) { throw new TaskExternalException(materialInfo.getNumber() + getResource(ctx, "SetAssistProperty")); } } else if (type == 4) { MeasureUnitInfo assistUnit = materialInfo.getAssistUnit(); if ((assistUnit == null) && (data != null) && (data.toString().length() > 0)) { throw new TaskExternalException(materialInfo.getNumber() + getResource(ctx, "NotSetAssistUnit")); }if ((assistUnit != null) && ((data == null) || (data.toString().length() <= 0))) { throw new TaskExternalException(materialInfo.getNumber() + getResource(ctx, "SetAssistUnit")); } } } private void checkStoreTypeEtc(Context ctx, StoreTypeInfo storeTypeInfo, Object data, int type) throws TaskExternalException { StoreFlagEnum storeFlag = storeTypeInfo.getStoreFlag(); if (type == 0) { if (isWarehouseLotNecessary(storeTypeInfo)) { if ((data == null) || (data.toString().length() == 0)) { throw new TaskExternalException(storeTypeInfo.getNumber() + getResource(ctx, "WarehouseCanNotNull")); } } else if ((data != null) && (data.toString().length() > 0)) { throw new TaskExternalException(storeTypeInfo.getNumber() + getResource(ctx, "ArUpdateInventoryWarehouseNotNull")); } } else if (type == 1) { if ((StoreFlagEnum.TOCUSTOMER.equals(storeFlag)) || (StoreFlagEnum.CUSTOMER.equals(storeFlag))) { if ((data == null) || (data.toString().length() == 0)) { throw new TaskExternalException(storeTypeInfo.getNumber() + getResource(ctx, "StoreTypeAboutCustomerNeedCustomer")); } } else if ((data != null) && (data.toString().length() > 0)) { throw new TaskExternalException(storeTypeInfo.getNumber() + getResource(ctx, "StoreTypeNotAboutCustomerNeedNotCustomer")); } } else if (type == 2) { if ((StoreFlagEnum.TOSUPPLIER.equals(storeFlag)) || (StoreFlagEnum.SUPPLIER.equals(storeFlag))) { if ((data == null) || (data.toString().length() == 0)) { throw new TaskExternalException(storeTypeInfo.getNumber() + getResource(ctx, "StoreTypeAboutSupplierNeedSupplier")); } } else if ((data != null) && (data.toString().length() > 0)) { throw new TaskExternalException(storeTypeInfo.getNumber() + getResource(ctx, "StoreTypeNotAboutSupplierNeedNotSupplier")); } } } private void checkAssistUnit(Context ctx, MaterialInfo mi, MeasureUnitInfo mui) throws TaskExternalException { MeasureUnitInfo amui = mi.getAssistUnit(); if (!amui.getId().equals(mui.getId())) { throw new TaskExternalException(mi.getName() + getResource(ctx, "AssistQtyIsError")); } } private EntityViewInfo getFilter(String number) { EntityViewInfo viewInfo = new EntityViewInfo(); FilterInfo filter = new FilterInfo(); filter.getFilterItems().add(new FilterItemInfo("number", number, CompareType.EQUALS)); viewInfo.setFilter(filter); return viewInfo; } public void submit(CoreBaseInfo coreBaseInfo, Context ctx) throws TaskExternalException { if ((coreBaseInfo == null) || (!(coreBaseInfo instanceof CoreBillBaseInfo))) { return; } try { InventoryInitBillInfo bill = (InventoryInitBillInfo)coreBaseInfo; String id = getIdFromNumber(bill.getNumber(), ctx); IObjectPK userPK = ctx.getCaller(); IObjectPK orgPK = new ObjectUuidPK(bill.getStorageOrgUnit().getId()); if (StringUtil.isEmptyString(id)) { SCMServerUtils.checkFunctionPermission(ctx, userPK, orgPK, "inventoryinit_new"); getController(ctx).addnew(coreBaseInfo); } else { SCMServerUtils.checkFunctionPermission(ctx, userPK, orgPK, "inventoryinit_update"); coreBaseInfo.setId(BOSUuid.read(id)); getController(ctx).update(new ObjectUuidPK(id), coreBaseInfo); } } catch (Exception ex) { throw new TaskExternalException(ex.getMessage(), ex.getCause()); } } private String getIdFromNumber(String number, Context ctx) throws TaskExternalException { try { collection = InventoryInitBillFactory.getLocalInstance(ctx).getInventoryInitBillCollection("where number ='" + number + "'"); } catch (BOSException e) { InventoryInitBillCollection collection; throw new TaskExternalException(e.getMessage(), e.getCause()); } InventoryInitBillCollection collection; if ((collection != null) && (collection.size() > 0)) { return collection.get(0).getId().toString(); } return null; } public int getSubmitType() { return 1; } public boolean isSameBlock(Hashtable firstData, Hashtable currentData) { if ((firstData == null) || (currentData == null)) { return false; } DataToken firstNumber = (DataToken)firstData.get(getMainField()); DataToken currentNumber = (DataToken)currentData.get(getMainField()); return (firstNumber != null) && ((currentNumber.data == null) || (currentNumber.data.toString().length() == 0) || (firstNumber.data.equals(currentNumber.data))); } public String getMainField() { return "number"; } private String getDateString(int i, Context ctx) { String returnString = null; if (0 == i) { returnString = getResource(ctx, "InventoryBizDate"); } if (1 == i) { returnString = getResource(ctx, "InventoryMFG"); } if (2 == i) { returnString = getResource(ctx, "InventoryEXP"); } return returnString; } public Hashtable exportTransmit(IRowSet rs, Context ctx) throws TaskExternalException { Hashtable result = new Hashtable(); try { result.put("number", DataImportUtils.transformValue(rs.getString("number"))); result.put("storageOrgUnit", DataImportUtils.transformValue(rs.getString("storageOrgUnit.number"))); result.put("storageOrgUnitName", DataImportUtils.transformValue(rs.getString("storageOrgUnit.name"))); result.put("bizDate", DataImportUtils.transformValue(rs.getString("bizDate"))); result.put("material", DataImportUtils.transformValue(rs.getString("material.number"))); result.put("materialName", DataImportUtils.transformValue(rs.getString("material.name"))); result.put("assistProperty", DataImportUtils.transformValue(rs.getString("assistProperty.number"))); result.put("assistPropertyName", DataImportUtils.transformValue(rs.getString("assistProperty.name"))); result.put("unit", DataImportUtils.transformValue(rs.getString("unit.number"))); result.put("unitName", DataImportUtils.transformValue(rs.getString("unit.name"))); result.put("lot", DataImportUtils.transformValue(rs.getString("entry.lot"))); result.put("mfg", DataImportUtils.transformValue(rs.getString("entry.mfg"))); result.put("exp", DataImportUtils.transformValue(rs.getString("entry.exp"))); result.put("qty", DataImportUtils.transformValue(rs.getString("entry.qty"))); result.put("assistUnit", DataImportUtils.transformValue(rs.getString("assistantUnit.number"))); result.put("assistUnitName", DataImportUtils.transformValue(rs.getString("assistantUnit.name"))); if (("".equalsIgnoreCase(DataImportUtils.transformValue(rs.getString("assistantUnit.number")).toString())) || (DataImportUtils.transformValue(rs.getString("assistantUnit.number")).toString().length() < 1)) { result.put("assistQty", DataImportUtils.transformValue(null)); } else result.put("assistQty", DataImportUtils.transformValue(rs.getString("entry.assistQty"))); result.put("costPrice", DataImportUtils.transformValue(rs.getString("entry.costPrice"))); result.put("amount", DataImportUtils.transformValue(rs.getString("entry.amount"))); result.put("warehouse", DataImportUtils.transformValue(rs.getString("warehouse.number"))); result.put("warehouseName", DataImportUtils.transformValue(rs.getString("warehouse.name"))); result.put("location", DataImportUtils.transformValue(rs.getString("location.number"))); result.put("locationName", DataImportUtils.transformValue(rs.getString("location.name"))); result.put("storeType", DataImportUtils.transformValue(rs.getString("storeType.number"))); result.put("storeTypeName", DataImportUtils.transformValue(rs.getString("storeType.name"))); result.put("storeStatus", DataImportUtils.transformValue(rs.getString("storeStatus.number"))); result.put("storeStatusName", DataImportUtils.transformValue(rs.getString("storeStatus.name"))); result.put("customer", DataImportUtils.transformValue(rs.getString("customer.number"))); result.put("customerName", DataImportUtils.transformValue(rs.getString("customer.name"))); result.put("supplier", DataImportUtils.transformValue(rs.getString("supplier.number"))); result.put("supplierName", DataImportUtils.transformValue(rs.getString("supplier.name"))); result.put("diffAmount", DataImportUtils.transformValue(rs.getString("entry.diffAmount"))); result.put("yearReceiptQty", DataImportUtils.transformValue(SCMServerUtils.toPlainString(rs.getBigDecimal("entry.yearReceiptQty")))); result.put("yearReceiptAmount", DataImportUtils.transformValue(rs.getString("entry.yearReceiptAmount"))); result.put("yearIssueQty", DataImportUtils.transformValue(SCMServerUtils.toPlainString(rs.getBigDecimal("entry.yearIssueQty")))); result.put("yearIssueAmount", DataImportUtils.transformValue(rs.getString("entry.yearIssueAmount"))); result.put("yearReceiptAssistQty", DataImportUtils.transformValue(SCMServerUtils.toPlainString(rs.getBigDecimal("entry.yearReceiptAssistQty")))); result.put("yearIssueAssistQty", DataImportUtils.transformValue(SCMServerUtils.toPlainString(rs.getBigDecimal("entry.yearIssueAssistQty")))); result.put("yearReceiptCostDiff", DataImportUtils.transformValue(rs.getString("entry.yearReceiptCostDiff"))); result.put("yearIssueCostDiff", DataImportUtils.transformValue(rs.getString("entry.yearIssueCostDiff"))); } catch (Exception e) { throw new TaskExternalException(e.getMessage(), e); } return result; } public FilterInfo getExportFilterForQuery(Context ctx) { FilterInfo filterInfo = new FilterInfo(); OrgUnitCollection collection = null; try { collection = SCMGroupServerUtils.getAuthOrgByPermItem(ctx, OrgType.Storage, "inventoryinit_export"); } catch (EASBizException e) { e.printStackTrace(); } catch (BOSException e) { e.printStackTrace(); } if ((collection != null) && (collection.size() > 0)) { LinkedHashSet keys = new LinkedHashSet(); for (int i = 0; i < collection.size(); i++) { keys.add(collection.get(i).getId().toString()); } filterInfo.getFilterItems().add(new FilterItemInfo("storageOrgUnit.id", keys, CompareType.INCLUDE)); } FilterInfo oldFilterInfo = (FilterInfo)getContextParameter("filter"); if (oldFilterInfo == null) { oldFilterInfo = new FilterInfo(); } try { if (filterInfo != null) oldFilterInfo.mergeFilter(filterInfo, "and"); } catch (BOSException e) { e.printStackTrace(); } return oldFilterInfo; } public String getExportQueryInfo(Context ctx) { return "com.kingdee.eas.scm.im.inv.InventoryInitExportQuery"; } private boolean isWarehouseLotNecessary(StoreTypeInfo storeTypeInfo) { if ((storeTypeInfo != null) && ("181875d5-0105-1000-e000-011ac0a812fd97D461A6".equals(storeTypeInfo.getId().toString()))) { return !this.isArUpdateInventory; } return true; } }
-------------------------------------------------------------------------
/**
* 导入开户银行
* @author ganjh
*
*/
public class BankBillDataImport extends AbstractDataTransmission {
@Override
protected ICoreBase getController(Context arg0)
throws TaskExternalException {
try {
return BankFactory.getLocalInstance(arg0);
} catch (BOSException e) {
}
throw new TaskExternalException("导入出错,BankFactory.getLocalInstance(arg0) is null。");
}
public CoreBaseInfo transmit(Hashtable arg0, Context arg1)
throws TaskExternalException {
BankInfo info = new BankInfo();
Object data = ((DataToken)arg0.get("FNumber")).data;
if(data!=null){
info.setNumber(data.toString().trim());
}else{
throw new TaskExternalException("开户银行不能为空");
}
data = ((DataToken)arg0.get("FName")).data;
if(data!=null){
info.setName(data.toString().trim());
}else{
throw new TaskExternalException("内容不能为空");
}
data = ((DataToken)arg0.get("FFormat")).data;
if(data!=null){
info.setFormat(data.toString().trim());
}
data = ((DataToken)arg0.get("FCode")).data;
if(data!=null){
info.setCode(data.toString().trim());
}
return info;
}
}