/// <summary> /// 更新调拨单单身 /// </summary> /// <param name="decimalPlace">金额小数位数</param> /// <param name="carryMode">金额取位模式</param> private void UpdateTransactionDocD(int decimalPlace, int carryMode) { #region 查询 QueryNode groupNode = GroupNode(false); //子查询的节点 _queryNode = OOQL.Select(OOQL.CreateProperty("TRANSACTION_DOC_D.TRANSACTION_DOC_D_ID", "TRANSACTION_DOC_D_ID"), OOQL.CreateProperty("TEMP_SCAN_DETAIL.picking_qty", "BUSINESS_QTY"), Formulas.IsNull(OOQL.CreateProperty("UNIT.UNIT_ID"), OOQL.CreateConstants(Maths.GuidDefaultValue()), "UNIT_ID"), Formulas.IsNull(OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_ID"), OOQL.CreateConstants(Maths.GuidDefaultValue()), "WAREHOUSE_ID"), Formulas.IsNull(OOQL.CreateProperty("BIN.BIN_ID"), OOQL.CreateConstants(Maths.GuidDefaultValue()), "BIN_ID"), Formulas.IsNull(OOQL.CreateProperty("ITEM_LOT.ITEM_LOT_ID"), OOQL.CreateConstants(Maths.GuidDefaultValue()), "ITEM_LOT_ID"), Formulas.Ext("UNIT_CONVERT", "SECOND_QTY", new object[] { OOQL.CreateProperty("ITEM.ITEM_ID"), Formulas.IsNull(OOQL.CreateProperty("UNIT.UNIT_ID"), OOQL.CreateConstants(Maths.GuidDefaultValue())), OOQL.CreateProperty("TEMP_SCAN_DETAIL.picking_qty"), OOQL.CreateProperty("ITEM.SECOND_UNIT_ID"), OOQL.CreateConstants(0) }), //领料第二数量 Formulas.Ext("UNIT_CONVERT", "INVENTORY_QTY", new object[] { OOQL.CreateProperty("ITEM.ITEM_ID"), Formulas.IsNull(OOQL.CreateProperty("UNIT.UNIT_ID"), OOQL.CreateConstants(Maths.GuidDefaultValue())), OOQL.CreateProperty("TEMP_SCAN_DETAIL.picking_qty"), OOQL.CreateProperty("ITEM.STOCK_UNIT_ID"), OOQL.CreateConstants(0) }), //领料库存数量 Formulas.Case(null, OOQL.CreateConstants("COST_DOMAIN"), OOQL.CreateCaseArray( OOQL.CreateCaseItem( ((OOQL.CreateProperty("PARA_COMPANY.INVENTORY_VALUATION_LEVEL") == OOQL.CreateConstants(1)) ), OOQL.CreateConstants("COMPANY"))), "COST_DOMAIN_ID_RTK"), //成本域 Formulas.Case(null, OOQL.CreateConstants(Maths.GuidDefaultValue()), OOQL.CreateCaseArray( OOQL.CreateCaseItem( ((OOQL.CreateProperty("PARA_COMPANY.INVENTORY_VALUATION_LEVEL") == OOQL.CreateConstants(1))), OOQL.CreateProperty("PLANT.COMPANY_ID")), OOQL.CreateCaseItem( ((OOQL.CreateProperty("PARA_COMPANY.INVENTORY_VALUATION_LEVEL") == OOQL.CreateConstants(2))), OOQL.CreateProperty("PLANT.COST_DOMAIN_ID")), OOQL.CreateCaseItem( ((OOQL.CreateProperty("PARA_COMPANY.INVENTORY_VALUATION_LEVEL") == OOQL.CreateConstants(3))), OOQL.CreateProperty("WAREHOUSE.COST_DOMAIN_ID"))), "COST_DOMAIN_ID_ROid"), //成本域类型 OOQL.CreateProperty("ITEM.ITEM_SN_MANAGEMENT", "ITEM_SN_MANAGEMENT"), Formulas.Case(null, OOQL.CreateConstants("1"), OOQL.CreateCaseArray( OOQL.CreateCaseItem( ((OOQL.CreateProperty("ITEM.ITEM_SN_MANAGEMENT") == OOQL.CreateConstants(0, GeneralDBType.Boolean)) | (Formulas.Ext("UNIT_CONVERT", new object[] { OOQL.CreateProperty("ITEM.ITEM_ID"), Formulas.IsNull(OOQL.CreateProperty("UNIT.UNIT_ID"), OOQL.CreateConstants(Maths.GuidDefaultValue())), OOQL.CreateProperty("TEMP_SCAN_DETAIL.picking_qty"), OOQL.CreateProperty("ITEM.STOCK_UNIT_ID"), OOQL.CreateConstants(0) }) == OOQL.CreateConstants(0)) ), OOQL.CreateConstants("0")), OOQL.CreateCaseItem( ((OOQL.CreateProperty("ITEM.ITEM_SN_MANAGEMENT") == OOQL.CreateConstants(1, GeneralDBType.Boolean)) & (OOQL.CreateProperty("TRANSACTION_DOC_D.SN_COLLECTED_QTY") != OOQL.CreateConstants(0, GeneralDBType.Decimal)) & (Formulas.Abs(Formulas.Ext("UNIT_CONVERT", new object[] { OOQL.CreateProperty("ITEM.ITEM_ID"), Formulas.IsNull(OOQL.CreateProperty("UNIT.UNIT_ID"), OOQL.CreateConstants(Maths.GuidDefaultValue())), OOQL.CreateProperty("TEMP_SCAN_DETAIL.picking_qty"), OOQL.CreateProperty("ITEM.STOCK_UNIT_ID"), OOQL.CreateConstants(0) })) == OOQL.CreateProperty("TRANSACTION_DOC_D.SN_COLLECTED_QTY")) ), OOQL.CreateConstants("2"))), "SN_COLLECTED_STATUS"), //序列号检核码 Formulas.Case(null, Formulas.Round(OOQL.CreateProperty("TRANSACTION_DOC_D.UNIT_COST") * Formulas.Ext("UNIT_CONVERT", new object[] { OOQL.CreateProperty("ITEM.ITEM_ID"), Formulas.IsNull(OOQL.CreateProperty("UNIT.UNIT_ID"), OOQL.CreateConstants(Maths.GuidDefaultValue())), OOQL.CreateProperty("TEMP_SCAN_DETAIL.picking_qty"), OOQL.CreateProperty("ITEM.STOCK_UNIT_ID"), OOQL.CreateConstants(0) }), decimalPlace, 1, ""), OOQL.CreateCaseArray( OOQL.CreateCaseItem(((OOQL.CreateConstants(carryMode) == OOQL.CreateConstants(1)) ), Formulas.Round( OOQL.CreateProperty("TRANSACTION_DOC_D.UNIT_COST") * Formulas.Ext("UNIT_CONVERT", new object[] { OOQL.CreateProperty("ITEM.ITEM_ID"), Formulas.IsNull(OOQL.CreateProperty("UNIT.UNIT_ID"), OOQL.CreateConstants(Maths.GuidDefaultValue())), OOQL.CreateProperty("TEMP_SCAN_DETAIL.picking_qty"), OOQL.CreateProperty("ITEM.STOCK_UNIT_ID"), OOQL.CreateConstants(0) }), decimalPlace))), "COST_AMT") //成本金额 ) //.From(_TEMP_SCAN_DETAIL.Name, "TEMP_SCAN_DETAIL") .From(groupNode, "TEMP_SCAN_DETAIL") .InnerJoin("TRANSACTION_DOC", "TRANSACTION_DOC") .On(OOQL.CreateProperty("TRANSACTION_DOC.DOC_NO") == OOQL.CreateProperty("TEMP_SCAN_DETAIL.doc_no")) .InnerJoin("TRANSACTION_DOC.TRANSACTION_DOC_D", "TRANSACTION_DOC_D") .On((OOQL.CreateProperty("TRANSACTION_DOC_D.TRANSACTION_DOC_ID") == OOQL.CreateProperty("TRANSACTION_DOC.TRANSACTION_DOC_ID")) & (OOQL.CreateProperty("TRANSACTION_DOC_D.SequenceNumber") == OOQL.CreateProperty("TEMP_SCAN_DETAIL.seq"))) .InnerJoin("ITEM", "ITEM") .On((OOQL.CreateProperty("ITEM.ITEM_ID") == OOQL.CreateProperty("TRANSACTION_DOC_D.ITEM_ID")) & (OOQL.CreateProperty("ITEM.ITEM_CODE") == OOQL.CreateProperty("TEMP_SCAN_DETAIL.item_no"))) .InnerJoin("PLANT", "PLANT") .On(OOQL.CreateProperty("PLANT.PLANT_CODE") == OOQL.CreateProperty("TEMP_SCAN_DETAIL.site_no")) .InnerJoin("PARA_COMPANY", "PARA_COMPANY") .On(OOQL.CreateProperty("PARA_COMPANY.Owner_Org.ROid") == OOQL.CreateProperty("PLANT.COMPANY_ID")) .LeftJoin("ITEM.ITEM_FEATURE", "ITEM_FEATURE") .On((OOQL.CreateProperty("ITEM_FEATURE.ITEM_FEATURE_ID") == OOQL.CreateProperty("TRANSACTION_DOC_D.ITEM_FEATURE_ID")) & (Formulas.IsNull(OOQL.CreateProperty("ITEM_FEATURE.ITEM_FEATURE_CODE"), OOQL.CreateConstants(string.Empty)) == OOQL.CreateProperty("TEMP_SCAN_DETAIL.item_feature_no"))) .LeftJoin("ITEM_LOT", "ITEM_LOT") .On((OOQL.CreateProperty("ITEM_LOT.LOT_CODE") == OOQL.CreateProperty("TEMP_SCAN_DETAIL.lot_no")) & (OOQL.CreateProperty("ITEM_LOT.ITEM_ID") == OOQL.CreateProperty("ITEM.ITEM_ID")) & (OOQL.CreateProperty("ITEM_LOT.ITEM_FEATURE_ID") == Formulas.IsNull(OOQL.CreateProperty("ITEM_FEATURE.ITEM_FEATURE_ID"), OOQL.CreateConstants(Maths.GuidDefaultValue())))) .LeftJoin("UNIT", "UNIT") .On(OOQL.CreateProperty("UNIT.UNIT_CODE") == OOQL.CreateProperty("TEMP_SCAN_DETAIL.picking_unit_no")) .LeftJoin("WAREHOUSE", "WAREHOUSE") .On((OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_CODE") == OOQL.CreateProperty("TEMP_SCAN_DETAIL.warehouse_no")) & (OOQL.CreateProperty("WAREHOUSE.Owner_Org.ROid") == OOQL.CreateProperty("PLANT.PLANT_ID"))) .LeftJoin("WAREHOUSE.BIN", "BIN") .On((OOQL.CreateProperty("BIN.BIN_CODE") == OOQL.CreateProperty("TEMP_SCAN_DETAIL.storage_spaces_no")) & (OOQL.CreateProperty("BIN.WAREHOUSE_ID") == OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_ID"))); #endregion #region 执行修改 QueryNode updateNode = OOQL.Update("TRANSACTION_DOC.TRANSACTION_DOC_D") .Set(new SetItem[] { new SetItem(OOQL.CreateProperty("BUSINESS_QTY"), OOQL.CreateProperty("SelectNode.BUSINESS_QTY")), new SetItem(OOQL.CreateProperty("BUSINESS_UNIT_ID"), OOQL.CreateProperty("SelectNode.UNIT_ID")), new SetItem(OOQL.CreateProperty("SECOND_QTY"), OOQL.CreateProperty("SelectNode.SECOND_QTY")), new SetItem(OOQL.CreateProperty("INVENTORY_QTY"), OOQL.CreateProperty("SelectNode.INVENTORY_QTY")), new SetItem(OOQL.CreateProperty("WAREHOUSE_ID"), OOQL.CreateProperty("SelectNode.WAREHOUSE_ID")), new SetItem(OOQL.CreateProperty("BIN_ID"), OOQL.CreateProperty("SelectNode.BIN_ID")), new SetItem(OOQL.CreateProperty("ITEM_LOT_ID"), OOQL.CreateProperty("SelectNode.ITEM_LOT_ID")), new SetItem(OOQL.CreateProperty("COST_DOMAIN_ID.RTK"), OOQL.CreateProperty("SelectNode.COST_DOMAIN_ID_RTK")), new SetItem(OOQL.CreateProperty("COST_DOMAIN_ID.ROid"), OOQL.CreateProperty("SelectNode.COST_DOMAIN_ID_ROid")), new SetItem(OOQL.CreateProperty("SN_COLLECTED_STATUS"), OOQL.CreateProperty("SelectNode.SN_COLLECTED_STATUS")), new SetItem(OOQL.CreateProperty("COST_AMT"), OOQL.CreateProperty("SelectNode.COST_AMT")) }) .From(_queryNode, "SelectNode") .Where(OOQL.CreateProperty("TRANSACTION_DOC.TRANSACTION_DOC_D.TRANSACTION_DOC_D_ID") == OOQL.CreateProperty("SelectNode.TRANSACTION_DOC_D_ID")); #endregion _querySrv.ExecuteNoQueryWithManageProperties(updateNode); }