public void Delete(AscmWmsStockTransMain ascmWmsStockTransMain)
 {
     try
     {
         YnDaoHelper.GetInstance().nHibernateHelper.Delete<AscmWmsStockTransMain>(ascmWmsStockTransMain);
     }
     catch (Exception ex)
     {
         YnBaseClass2.Helper.LogHelper.GetLog().Error("删除失败(Delete AscmWmsStockTransMain)", ex);
         throw ex;
     }
 }
Exemplo n.º 2
0
        public void DoStockTrans(AscmWmsStockTransMain ascmWmsStockTransMain, List<AscmWmsStockTransDetail> listWmsStockTransDetail, string userId, AscmMesInteractiveLog ascmMesInteractiveLog)
        {
            try
            {
                OracleParameter[] stockTransParams = GetStockTransParams(ascmWmsStockTransMain, listWmsStockTransDetail, userId);
                ISession session = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession();
                OracleCommand command = (OracleCommand)session.Connection.CreateCommand();
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "cux_mes_ascm_interface_pkg.ascm_do_stock_trans";
                Array.ForEach<OracleParameter>(stockTransParams, P => command.Parameters.Add(P));
                command.ExecuteNonQuery();

                ascmMesInteractiveLog.returnCode = stockTransParams[stockTransParams.Length - 2].Value.ToString();
                ascmMesInteractiveLog.returnMessage = stockTransParams[stockTransParams.Length - 1].Value.ToString();

                if (ascmWmsStockTransMain != null)
                {
                    ascmWmsStockTransMain.returnCode = ascmMesInteractiveLog.returnCode;
                    ascmWmsStockTransMain.returnMessage = ascmMesInteractiveLog.returnMessage;
                    ascmWmsStockTransMain.uploadTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public void Update(AscmWmsStockTransMain ascmWmsStockTransMain)
 {
     try
     {
         using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction())
         {
             try
             {
                 YnDaoHelper.GetInstance().nHibernateHelper.Update<AscmWmsStockTransMain>(ascmWmsStockTransMain);
                 tx.Commit();//正确执行提交
             }
             catch (Exception ex)
             {
                 tx.Rollback();//回滚
                 YnBaseClass2.Helper.LogHelper.GetLog().Error("修改失败(Update AscmWmsStockTransMain)", ex);
                 throw ex;
             }
         }
     }
     catch (Exception ex)
     {
         YnBaseClass2.Helper.LogHelper.GetLog().Error("修改失败(Save AscmWmsStockTransMain)", ex);
         throw ex;
     }
 }
Exemplo n.º 4
0
        public OracleParameter[] GetStockTransParams(AscmWmsStockTransMain ascmWmsStockTransMain, List<AscmWmsStockTransDetail> listWmsStockTransDetail, string userId)
        {
            //备注
            string memo = "";
            if (!string.IsNullOrEmpty(ascmWmsStockTransMain.memo))
                memo = ascmWmsStockTransMain.memo;
            //注意MES存储过程中要求字符串数组长度一致,并且一一对应
            string[] itemIds = listWmsStockTransDetail.Select(P => P.materialId.ToString()).ToArray();
            string[] labelIds = new string[itemIds.Length];
            string[] fromInvCodes = new string[itemIds.Length];
            string[] fromLocIds = new string[itemIds.Length];
            string[] toInvCodes = new string[itemIds.Length];
            string[] toLocIds = new string[itemIds.Length];
            string[] quantities = listWmsStockTransDetail.Select(P => P.quantity.ToString()).ToArray();
            string[] descriptions = new string[itemIds.Length];
            string[] references = listWmsStockTransDetail.Select(P => P.reference.ToString()).ToArray();
            string[] moBatchNos = new string[itemIds.Length];
            string[] vendorIds = new string[itemIds.Length];
            string[] accountStatuss = new string[itemIds.Length];
            string[] deliveryNos = new string[itemIds.Length];
            //为数组元素指定默认值
            for (int i = 0; i < itemIds.Length; i++)
            {
                labelIds[i] = "";
                fromInvCodes[i] = ascmWmsStockTransMain.fromWarehouseId;
                fromLocIds[i] = "";
                toInvCodes[i] = ascmWmsStockTransMain.toWarehouseId;
                toLocIds[i] = "";
                descriptions[i] = "";
                moBatchNos[i] = "";
                vendorIds[i] = "";
                accountStatuss[i] = "lm_deliveried";
                deliveryNos[i] = "";
            }

            return new OracleParameter[] {
                //库存组织
                new OracleParameter{
                    ParameterName = "i_org_id",
                    OracleDbType = OracleDbType.Int32,
                    Value = orgId,
                    Direction = ParameterDirection.Input
                },
                //MES闭环单号
                new OracleParameter{
                    ParameterName = "i_invtrano",
                    OracleDbType = OracleDbType.Varchar2,
                    Size = 80,
                    Value = ascmWmsStockTransMain.docNumber,
                    Direction = ParameterDirection.Input
                },
                //手工单号
                new OracleParameter{
                    ParameterName = "i_manuno",
                    OracleDbType = OracleDbType.Varchar2,
                    Size = 80,
                    Value = ascmWmsStockTransMain.manualDocNumber,
                    Direction = ParameterDirection.Input
                },
                //MES事务类型
                new OracleParameter{
                    ParameterName = "i_cbxtype",
                    OracleDbType = OracleDbType.Varchar2,
                    Size = 80,
                    Value = ascmWmsStockTransMain.transType,
                    Direction = ParameterDirection.Input
                },
                //接收人
                new OracleParameter{
                    ParameterName = "i_recemp",
                    OracleDbType = OracleDbType.Varchar2,
                    Size = 80,
                    Value = ascmWmsStockTransMain.createUser,
                    Direction = ParameterDirection.Input
                },
                //自动报检
                new OracleParameter{
                    ParameterName = "i_autosendcheck",
                    OracleDbType = OracleDbType.Varchar2,
                    Size = 80,
                    Value = "FALSE",
                    Direction = ParameterDirection.Input
                },
                //退货原因,ERP事务原因id
                new OracleParameter{
                    ParameterName = "i_resion_id",
                    OracleDbType = OracleDbType.Varchar2,
                    Size = 80,
                    Value = ascmWmsStockTransMain.reasonId,
                    Direction = ParameterDirection.Input
                },
                //标签号(字符串数组)
                new OracleParameter{
                    ParameterName = "i_labelid",
                    OracleDbType = OracleDbType.Varchar2,
                    Value = labelIds,
                    Direction = ParameterDirection.Input,
                    CollectionType = OracleCollectionType.PLSQLAssociativeArray
                },
                //物料编码(字符串数组)
                new OracleParameter{
                    ParameterName = "i_itemid",
                    OracleDbType = OracleDbType.Varchar2,
                    Value = itemIds,
                    Direction = ParameterDirection.Input,
                    CollectionType = OracleCollectionType.PLSQLAssociativeArray
                },
                //来源仓库(字符串数组),不可为空
                new OracleParameter{
                    ParameterName = "i_frominvcode",
                    OracleDbType = OracleDbType.Varchar2,
                    Value = fromInvCodes,
                    Direction = ParameterDirection.Input,
                    CollectionType = OracleCollectionType.PLSQLAssociativeArray
                },
                //来源货位(字符串数组)
                new OracleParameter{
                    ParameterName = "i_fromlocid",
                    OracleDbType = OracleDbType.Varchar2,
                    Value = fromLocIds,
                    Direction = ParameterDirection.Input,
                    CollectionType = OracleCollectionType.PLSQLAssociativeArray
                },
                //目标仓库(字符串数组),不可为空
                new OracleParameter{
                    ParameterName = "i_toinvcode",
                    OracleDbType = OracleDbType.Varchar2,
                    Value = toInvCodes,
                    Direction = ParameterDirection.Input,
                    CollectionType = OracleCollectionType.PLSQLAssociativeArray
                },
                //目标货位(字符串数组)
                new OracleParameter{
                    ParameterName = "i_tolocid",
                    OracleDbType = OracleDbType.Varchar2,
                    Value = toLocIds,
                    Direction = ParameterDirection.Input,
                    CollectionType = OracleCollectionType.PLSQLAssociativeArray
                },
                //数量(字符串数组)
                new OracleParameter{
                    ParameterName = "i_quantity",
                    OracleDbType = OracleDbType.Varchar2,
                    Value = quantities,
                    Direction = ParameterDirection.Input,
                    CollectionType = OracleCollectionType.PLSQLAssociativeArray
                },
                //备注(字符串数组)
                new OracleParameter{
                    ParameterName = "i_description",
                    OracleDbType = OracleDbType.Varchar2,
                    Value = descriptions,
                    Direction = ParameterDirection.Input,
                    CollectionType = OracleCollectionType.PLSQLAssociativeArray
                },
                //参考(字符串数组)
                new OracleParameter{
                    ParameterName = "i_reference",
                    OracleDbType = OracleDbType.Varchar2,
                    Value = references,
                    Direction = ParameterDirection.Input,
                    CollectionType = OracleCollectionType.PLSQLAssociativeArray
                },
                //生产批次(字符串数组)
                new OracleParameter{
                    ParameterName = "i_mobatchno",
                    OracleDbType = OracleDbType.Varchar2,
                    Value = moBatchNos,
                    Direction = ParameterDirection.Input,
                    CollectionType = OracleCollectionType.PLSQLAssociativeArray
                },
                //供应商ID(字符串数组)
                new OracleParameter{
                    ParameterName = "i_vendorid",
                    OracleDbType = OracleDbType.Varchar2,
                    Value = vendorIds,
                    Direction = ParameterDirection.Input,
                    CollectionType = OracleCollectionType.PLSQLAssociativeArray
                },
                //账务状态(字符串数组)
                new OracleParameter{
                    ParameterName = "i_accountstatus",
                    OracleDbType = OracleDbType.Varchar2,
                    Value = accountStatuss,
                    Direction = ParameterDirection.Input,
                    CollectionType = OracleCollectionType.PLSQLAssociativeArray
                },
                //送货单号(字符串数组)
                new OracleParameter{
                    ParameterName = "i_deliveryno",
                    OracleDbType = OracleDbType.Varchar2,
                    Value = deliveryNos,
                    Direction = ParameterDirection.Input,
                    CollectionType = OracleCollectionType.PLSQLAssociativeArray
                },
                //用户名称
                new OracleParameter{
                    ParameterName = "i_user_code",
                    OracleDbType = OracleDbType.Varchar2,
                    Size = 80,
                    Value = userId,
                    Direction = ParameterDirection.Input
                },
                //返回参(值为0时表示成功)
                new OracleParameter{
                    ParameterName = "o_ret_code",
                    OracleDbType = OracleDbType.Varchar2,
                    Size = 4000,
                    Direction = ParameterDirection.Output
                },
                //返回参(错误信息)
                new OracleParameter{
                    ParameterName = "o_ret_msg",
                    OracleDbType = OracleDbType.Varchar2,
                    Size = 4000,
                    Direction = ParameterDirection.Output
                }
            };
        }