Exemplo n.º 1
0
        public void Notify(params object[] args)
        {
            if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent))
            {
                return;
            }

            //将入口参数列表中第一个参数,转成EntityEvent,并取EntityKey存入key
            UFSoft.UBF.Business.BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;
            //key的有效性判断
            if (key == null)
            {
                return;
            }
            //转成所需实体,同时判断有效性
            //UFIDA.U9.InvDoc.TransferIn.TransferIn transferIn = (UFIDA.U9.InvDoc.TransferIn.TransferIn)key.GetEntity();
            UFIDA.U9.MO.Complete.CompleteRpt entity = (UFIDA.U9.MO.Complete.CompleteRpt)key.GetEntity();
            if (entity == null)
            {
                return;
            }
            else
            {
                if (entity.Org.Code == "300")
                {
                    try
                    {
                        string        DocNo       = entity.DocNo;
                        string        result      = "";
                        string        content     = HttpMethod.PostMethod("http://192.168.30.8:9090/MXQHService/common.asmx/DoBefore", GenPara("ExecPlan", "CompleteRpt", "GetQty", "{WorkOrder:'" + entity.MO.DocNo + "'}"));
                        MesReturnData r           = Newtonsoft.Json.JsonConvert.DeserializeObject <MesReturnData>(content);
                        int           CompleteQty = 0;
                        if (r.data.Count == 0)
                        {
                            CompleteQty = 0;
                        }
                        else
                        {
                            CompleteQty = r.data[0].CompleteQty;
                        }
                        DataParamList dp = new DataParamList();
                        dp.Add(DataParamFactory.Create("DocNo", entity.MO.DocNo, ParameterDirection.Input, DbType.String, 50));
                        dp.Add(DataParamFactory.Create("CompleteQty", CompleteQty, ParameterDirection.Input, DbType.Int32, 64));
                        dp.Add(DataParamFactory.CreateOutput("Result", DbType.String));
                        DataAccessor.RunSP("sp_Auctus_BE_MOCompleteQtyAI", dp);
                        result = dp["Result"].Value.ToString();
                        if (result != "1")
                        {
                            throw new Exception(result);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void Notify(params object[] args)
        {
            if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent))
            {
                return;
            }

            //将入口参数列表中第一个参数,转成EntityEvent,并取EntityKey存入key
            UFSoft.UBF.Business.BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;
            //key的有效性判断
            if (key == null)
            {
                return;
            }
            //转成所需实体,同时判断有效性
            UFIDA.U9.InvDoc.MiscRcv.MiscRcvTrans miscRcv = (UFIDA.U9.InvDoc.MiscRcv.MiscRcvTrans)key.GetEntity();

            if (miscRcv == null)
            {
                return;
            }
            else
            {
                if (miscRcv.Org.Code == "300")
                {
                    try
                    {
                        //不允许“制损报废入库”弃审
                        if (miscRcv.MiscRcvDocType.Name.Trim() == "制损报废入库")
                        {
                            //单据从已核准状态到开立(弃审操作)
                            if (miscRcv.OriginalData.Status == INVDocStatus.Approved && miscRcv.Status == INVDocStatus.Open)
                            {
                                //存储过程控制取消退料操作是否开启
                                DataParamList dpL = new DataParamList();
                                dpL.Add(DataParamFactory.Create("Type", "MiscRcvBtnUnDoApprove", ParameterDirection.Input, DbType.String, 50));//禁用杂收单弃审功能
                                dpL.Add(DataParamFactory.CreateOutput("IsOpen", DbType.String));
                                DataAccessor.RunSP("sp_Auctus_BEPlugin_Control", dpL);
                                string isOpen = dpL["IsOpen"].Value.ToString();
                                if (isOpen == "1")
                                {
                                    throw new Exception("此单据为" + miscRcv.MiscRcvTransLs[0].DescFlexSegments.PrivateDescSeg29 + "自动生成单据,不允许弃审!");
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }//end if
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 开发测试版
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnTest_Click(object sender, EventArgs e)
        {
            DataParamList dp = new DataParamList();

            dp.Add(DataParamFactory.CreateOutput("Result", DbType.String));
            DataAccessor.RunSP("sp_Auctus_UI_CreatePOModifyQty", dp);
            string result = dp["Result"].Value.ToString();

            if (result != "1")
            {
                throw new Exception(result);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 创建MPS变交期的委外采购变更单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnWPOModify_Click(object sender, EventArgs e)
        {
            string        userName = Context.LoginUser;
            DataParamList dp       = new DataParamList();

            dp.Add(DataParamFactory.CreateInput("UserName", userName, DbType.String));
            dp.Add(DataParamFactory.CreateOutput("Result", DbType.String));
            DataAccessor.RunSP("sp_Auctus_UI_CreateWPOModify", dp);
            string result = dp["Result"].Value.ToString();

            if (result != "1")
            {
                throw new Exception(result);
            }
        }
Exemplo n.º 5
0
        public void Notify(params object[] args)
        {
            if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent))
            {
                return;
            }

            //将入口参数列表中第一个参数,转成EntityEvent,并取EntityKey存入key
            UFSoft.UBF.Business.BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;
            //key的有效性判断
            if (key == null)
            {
                return;
            }
            //转成所需实体,同时判断有效性
            UFIDA.U9.PM.POChange.POModify poModify = (UFIDA.U9.PM.POChange.POModify)key.GetEntity();

            if (poModify == null)
            {
                return;
            }
            else
            {
                //验证标准采购或委外采购采购数量>需求数量,且采购数量-需求数量<最小交货量(最小叫货量不为0)
                if (poModify.Org.Code == "300")
                {
                    try
                    {
                        if (poModify.Status == UFIDA.U9.PM.POChange.POChangeListStatusEnum.Approved)
                        {
                            DataParamList dp = new DataParamList();
                            dp.Add(DataParamFactory.Create("DocNo", poModify.DocNo, ParameterDirection.Input, DbType.String, 50));
                            dp.Add(DataParamFactory.CreateOutput("Result", DbType.String));
                            DataAccessor.RunSP("sp_Auctus_BE_POModifyAU", dp);
                            string result = dp["Result"].Value.ToString();
                            if (result != "1")
                            {
                                throw new Exception(result);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }//end if
            }
        }
Exemplo n.º 6
0
        public void Notify(params object[] args)
        {
            if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent))
            {
                return;
            }

            //将入口参数列表中第一个参数,转成EntityEvent,并取EntityKey存入key
            UFSoft.UBF.Business.BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;
            //key的有效性判断
            if (key == null)
            {
                return;
            }
            //转成所需实体,同时判断有效性
            UFIDA.U9.InvDoc.TransferIn.TransferIn transferIn = (UFIDA.U9.InvDoc.TransferIn.TransferIn)key.GetEntity();
            if (transferIn == null)
            {
                return;
            }
            else
            {
                if (transferIn.Org.Code == "300")
                {
                    try
                    {
                        if (transferIn.DocType.Name == "委外加工发料" || transferIn.DocType.Name == "委外加工退料")
                        {
                            string        DocNo  = transferIn.DocNo;
                            string        result = "";
                            DataParamList dp     = new DataParamList();
                            dp.Add(DataParamFactory.Create("DocNo", transferIn.DocNo, ParameterDirection.Input, DbType.String, 50));
                            dp.Add(DataParamFactory.CreateOutput("Result", DbType.String));
                            DataAccessor.RunSP("sp_Auctus_LockTransferIn", dp);
                            result = dp["Result"].Value.ToString();
                            if (result != "1")
                            {
                                throw new Exception(result);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
Exemplo n.º 7
0
        public void Notify(params object[] args)
        {
            if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent))
            {
                return;
            }

            //将入口参数列表中第一个参数,转成EntityEvent,并取EntityKey存入key
            UFSoft.UBF.Business.BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;
            //key的有效性判断
            if (key == null)
            {
                return;
            }
            //转成所需实体,同时判断有效性
            UFIDA.U9.PM.PO.POLine poLine = (UFIDA.U9.PM.PO.POLine)key.GetEntity();

            if (poLine == null)
            {
                return;
            }
            else
            {
                UFIDA.U9.PM.PO.PurchaseOrder po = poLine.PurchaseOrder;
                //委外订单短缺关闭时,若财务未核销(备料单行核销数量<>已发料数量),则不允许关闭
                if (po.Org.Code == "300" && po.SubType.Value.ToString() != "-1" && poLine.Status == PODOCStatusEnum.ClosedShort)
                {
                    try
                    {
                        DataParamList dp = new DataParamList();
                        dp.Add(DataParamFactory.Create("DocNo", po.DocNo, ParameterDirection.Input, DbType.String, 50));
                        dp.Add(DataParamFactory.CreateOutput("Result", DbType.String));
                        DataAccessor.RunSP("sp_Auctus_BE_PurchaseOrderAU", dp);
                        string result = dp["Result"].Value.ToString();
                        if (result != "1")
                        {
                            throw new Exception(result);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }//end if
            }
        }
Exemplo n.º 8
0
        public void Notify(params object[] args)
        {
            if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent))
            {
                return;
            }

            //将入口参数列表中第一个参数,转成EntityEvent,并取EntityKey存入key
            UFSoft.UBF.Business.BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;
            //key的有效性判断
            if (key == null)
            {
                return;
            }
            //转成所需实体,同时判断有效性
            UFIDA.U9.MO.Issue.IssueDoc issueDoc = (UFIDA.U9.MO.Issue.IssueDoc)key.GetEntity();
            if (issueDoc == null)
            {
                return;
            }
            else
            {
                if (issueDoc.Org.Code == "300")
                {
                    try
                    {
                        DataParamList dp = new DataParamList();
                        dp.Add(DataParamFactory.Create("DocNo", issueDoc.DocNo, ParameterDirection.Input, DbType.String, 50));
                        dp.Add(DataParamFactory.Create("BeforeConfirmDate", "", ParameterDirection.Input, DbType.String, 50));
                        dp.Add(DataParamFactory.Create("ConfirmDate", "", ParameterDirection.Input, DbType.String, 50));
                        dp.Add(DataParamFactory.CreateOutput("Result", DbType.String));
                        DataAccessor.RunSP("sp_Auctus_BE_MoIssueDoc", dp);
                        string result = dp["Result"].Value.ToString();
                        if (result != "1")
                        {
                            throw new Exception(result);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
Exemplo n.º 9
0
        public void Notify(params object[] args)
        {
            if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent))
            {
                return;
            }

            //将入口参数列表中第一个参数,转成EntityEvent,并取EntityKey存入key
            UFSoft.UBF.Business.BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;
            //key的有效性判断
            if (key == null)
            {
                return;
            }
            //转成所需实体,同时判断有效性
            UFIDA.U9.SM.SO.SO so = (UFIDA.U9.SM.SO.SO)key.GetEntity();

            if (so == null)
            {
                return;
            }
            else
            {
                if (so.Org.Code == "300" && so.DescFlexField.PrivateDescSeg1.Contains("PO"))
                {
                    try
                    {
                        DataParamList dp = new DataParamList();
                        dp.Add(DataParamFactory.Create("SODocNo", so.DocNo, ParameterDirection.Input, DbType.String, 50));
                        dp.Add(DataParamFactory.Create("PoDocNo", so.DescFlexField.PrivateDescSeg1, ParameterDirection.Input, DbType.String, 50));
                        dp.Add(DataParamFactory.CreateOutput("Result", DbType.String));
                        DataAccessor.RunSP("sp_Auctus_BE_SOAI", dp);
                        string result = dp["Result"].Value.ToString();
                        if (result != "0")
                        {
                            throw new Exception(result);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
        internal List <long> LoadFlowNos(string sequenceBy, int count, long UserDefineNumber, KeyFlexFieldStru fieldStru)
        {
            List <long> list   = new List <long>();
            string      spName = "Base_KFFLoadFlowNew";
            long        iD     = fieldStru.ID;

            if (!FlexFieldFlow.Finder.IsExists("KeyFlexFieldStru=@KeyFlexFieldStru and Code=@SequenceBy", new OqlParam[] { new OqlParam(fieldStru.ID), new OqlParam(sequenceBy) }))
            {
                iD = KeyGenerator.NewValue();
            }
            DataParamList dataParams = new DataParamList();

            dataParams.Add(DataParamFactory.CreateInput("SN", iD, DbType.Int64));
            dataParams.Add(DataParamFactory.CreateInput("Struc", fieldStru.ID, DbType.Int64));
            dataParams.Add(DataParamFactory.CreateInput("SequenceBy", sequenceBy, DbType.String));
            dataParams.Add(DataParamFactory.CreateInput("Count", count, DbType.Int32));
            dataParams.Add(DataParamFactory.CreateOutput("ErrorInfo", DbType.String));
            dataParams.Add(DataParamFactory.CreateInput("UserFlow", UserDefineNumber, DbType.Int64));
            return(LoadFlowBySP(spName, dataParams, fieldStru, sequenceBy, count));
        }
Exemplo n.º 11
0
 public override void AfterDo(object bp, ref object result)
 {
     UFIDA.U9.MO.MO.StartMO moBP = bp as UFIDA.U9.MO.MO.StartMO;
     //UFIDA.U9.MO.MO.MO mo=UFIDA.U9.MO.MO.MO.Finder.FindAll()
     for (int i = 0; i < moBP.StartInfoDTOs.Count; i++)
     {
         try
         {
             int mesOnlineQty = 0;//MES投入数量
             if (moBP.StartInfoDTOs[i].BusinessDirection.Value == 1)
             {
                 string        content = HttpMethod.PostMethod("http://192.168.30.8:9090/MXQHService/common.asmx/DoBefore", GenPara("ExecPlan", "CompleteRpt", "GetQty", "{WorkOrder:'" + moBP.StartInfoDTOs[i].MOKey.GetEntity().DocNo + "'}"));
                 MesReturnData r       = Newtonsoft.Json.JsonConvert.DeserializeObject <MesReturnData>(content);
                 if (r.data.Count == 0)
                 {
                     mesOnlineQty = 0;
                 }
                 else
                 {
                     mesOnlineQty = r.data[0].OnLineQty;
                 }
             }
             DataParamList dp = new DataParamList();
             dp.Add(DataParamFactory.Create("LoginUser", UFIDA.U9.Base.Context.LoginUser, ParameterDirection.Input, DbType.String, 50));
             dp.Add(DataParamFactory.Create("MOID", moBP.StartInfoDTOs[i].MOKey.ID, ParameterDirection.Input, DbType.String, 50));
             dp.Add(DataParamFactory.Create("Status", moBP.StartInfoDTOs[i].BusinessDirection.Value, ParameterDirection.Input, DbType.Int32, 32));
             dp.Add(DataParamFactory.Create("MesCompleteQty", mesOnlineQty, ParameterDirection.Input, DbType.Int32, 32));
             dp.Add(DataParamFactory.CreateOutput("Result", DbType.String));
             DataAccessor.RunSP("sp_Auctus_BP_MOStartInfoAD", dp);
             string output = dp["Result"].Value.ToString();
             if (output != "1")
             {
                 throw new Exception(output);
             }
         }
         catch (Exception ex)
         {
             throw new Exception(ex.Message);
         }
     }
 }
        public virtual void ProcessColumn
        (
            ColumnInfo column,
            IDbCommand insertCommand,
            DataParamFactory parameterFactory
        )
        {
            InsertSections insert = GetTableInsert(column.Table);

            insert.ColumnNames.Add(column.Name);
            insert.ParametersValueNames.Add("@" + column.Name);     //TODO: add a parameter name to the column class
            //insert.ParametersValueNames.Add ( column.Values[0] ) ;


            System.Data.IDbDataParameter param;

            object value = DBNull.Value;

            if (null != column.Values && column.Values.Count != 0)
            {
                //TODO: multivalue must be stored in their own table where each value is a row
                //in order to support proper query
                value = column.Values[0];

                if (null == value)
                {
                    value = DBNull.Value;
                }
            }

            param = parameterFactory("@" + column.Name, value);

            Parameters.Add(param);

            if (null != insertCommand)
            {
                insertCommand.Parameters.Add(param);
            }
        }
Exemplo n.º 13
0
        public void Notify(params object[] args)
        {
            if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent))
            {
                return;
            }

            //将入口参数列表中第一个参数,转成EntityEvent,并取EntityKey存入key
            UFSoft.UBF.Business.BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;
            //key的有效性判断
            if (key == null)
            {
                return;
            }
            //转成所需实体,同时判断有效性
            UFIDA.U9.PM.Rcv.Receivement receivement = (UFIDA.U9.PM.Rcv.Receivement)key.GetEntity();

            if (receivement == null)
            {
                return;
            }
            else
            {
                if (receivement.Org.Code == "300" && receivement.Status == UFIDA.U9.PM.Rcv.RcvStatusEnum.Opened && receivement.RcvDocType.DescFlexField.PrivateDescSeg1 != "1")
                {
                    try
                    {
                        DataParamList dp = new DataParamList();
                        dp.Add(DataParamFactory.Create("DocNo", receivement.DocNo, ParameterDirection.Input, DbType.String, 50));
                        DataAccessor.RunSP("sp_Auctus_BE_Receivement", dp);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }//end if
            }
        }
        /// <summary>获取当前记账期间.</summary>
        /// <returns></returns>
        public static long GetSOBAccountingPeriod()
        {
            string sql = @"SELECT A1.ID FROM dbo.Base_SOBAccountingPeriod A1
JOIN Base_SetofBooks A2 ON A1.SetofBooks=A2.ID
WHERE
A2.Org=@Org AND
A1.Year=@Year AND A1.Code=@Code";

            var parasUpdate = new DataParamList
            {
                DataParamFactory.CreateInput("Org", UFIDA.U9.Base.Context.LoginOrg.ID, System.Data.DbType.Int64),
                DataParamFactory.CreateInput("Year", DateTime.Now.Year, System.Data.DbType.Int16),
                DataParamFactory.CreateInput("Code", DateTime.Now.ToString("MM"), System.Data.DbType.String)
            };

            DataAccessor.RunSQL(DatabaseManager.GetCurrentConnection(), sql, parasUpdate, out DataSet ds);
            if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0)
            {
                return(Convert.ToInt64(ds.Tables[0].Rows[0][0]));
            }

            return(-1);
        }
Exemplo n.º 15
0
        /// <summary>
        ///     查询服务信息
        /// </summary>
        /// <param name="bpsvTypeQuery"></param>
        /// <returns></returns>
        public ReturnMessage <List <BPSVType> > QueryBPSVType(BPSVTypeQuery bpsvTypeQuery)
        {
            if (bpsvTypeQuery == null)
            {
                throw new ArgumentException("bpsvTypeQuery is null");
            }
            if (string.IsNullOrWhiteSpace(bpsvTypeQuery.QueryStr))
            {
                throw new ArgumentException("bpsvTypeQuery.QueryStr is empty");
            }
            string[]      arrQueryStr = bpsvTypeQuery.QueryStr.Split(' ');
            StringBuilder sb          = new StringBuilder();

            sb.Append(@"SELECT B.DisplayName,
                       A.FullName,
                       C.AssemblyName,
                       C.Kind
                FROM UBF_MD_Class AS A
                    LEFT JOIN UBF_MD_Class_Trl AS B
                        ON A.Local_ID = B.Local_ID
                    LEFT JOIN UBF_MD_Component AS C
                        ON A.MD_Component_ID = C.ID
                    LEFT JOIN UBF_MD_Component_Trl AS D
                        ON C.Local_ID = D.Local_ID
                WHERE (
                          C.Kind = 'SV'
                          OR C.Kind = 'BP'
                      )
                      AND (");
            StringBuilder fullNameSb    = new StringBuilder();
            StringBuilder displayNameSb = new StringBuilder();

            fullNameSb.Append("(");
            displayNameSb.Append("(");
            bool          isFirst    = true;
            DataParamList dataParams = new DataParamList();

            for (int i = 0; i < arrQueryStr.Length; i++)
            {
                string str       = arrQueryStr[i];
                string paramName = "param" + i;
                if (string.IsNullOrWhiteSpace(str))
                {
                    continue;
                }
                if (!isFirst)
                {
                    fullNameSb.Append(" AND ");
                    displayNameSb.Append(" AND ");
                }
                fullNameSb.AppendFormat("A.FullName LIKE @{0}", paramName);
                displayNameSb.AppendFormat("B.DisplayName LIKE @{0}", paramName);
                dataParams.Add(DataParamFactory.CreateInput(paramName, string.Format("%{0}%", str), DbType.String));
                isFirst = false;
            }
            fullNameSb.Append(")");
            displayNameSb.Append(")");
            sb.Append(fullNameSb + " OR " + displayNameSb);
            sb.Append(")");
            DataSet dataSet;

            DataAccessor.RunSQL(DatabaseManager.GetCurrentConnection(), sb.ToString(), dataParams, out dataSet);
            List <BPSVType> list = new List <BPSVType>();

            if (dataSet != null && dataSet.Tables.Count > 0 && dataSet.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow row in dataSet.Tables[0].Rows)
                {
                    BPSVType bpsv = new BPSVType();
                    bpsv.DisplayName  = AsString(row, "DisplayName");
                    bpsv.FullName     = AsString(row, "FullName");
                    bpsv.AssemblyName = AsString(row, "AssemblyName");
                    bpsv.Kind         = AsString(row, "Kind");
                    list.Add(bpsv);
                }
            }
            ReturnMessage <List <BPSVType> > ret = new ReturnMessage <List <BPSVType> >();

            ret.Result    = list;
            ret.IsSuccess = true;
            return(ret);
        }
Exemplo n.º 16
0
        /// <summary>
        /// 1、“制损退料单”、“返工制损退料单”退料确认后参照生产退料单信息同步创建并审核杂发单、杂收单
        /// 2、控制同一需求分类号下,领料单领料数量不超过供应数量(按严格匹配的料号)(领料控制逻辑看存储过程)
        /// </summary>
        /// <param name="args"></param>
        public void Notify(params object[] args)
        {
            if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent))
            {
                return;
            }

            //将入口参数列表中第一个参数,转成EntityEvent,并取EntityKey存入key
            UFSoft.UBF.Business.BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;
            //key的有效性判断
            if (key == null)
            {
                return;
            }
            //转成所需实体,同时判断有效性
            UFIDA.U9.MO.Issue.IssueDoc issueDoc = (UFIDA.U9.MO.Issue.IssueDoc)key.GetEntity();

            if (issueDoc == null)
            {
                return;
            }
            else
            {
                if (issueDoc.Org.Code == "300")
                {
                    try
                    {
                        #region“制损退料单”、“返工制损退料单”退料确认后参照生产退料单信息同步创建并审核杂发单、杂收单

                        if (issueDoc.IssueDocType.Name.Trim() == "制损退料单" || issueDoc.IssueDocType.Name.Trim() == "返工制损退料单")
                        {
                            //单据从关闭状态到已核准状态,说明是取消退料操作
                            if (issueDoc.DocState == IssueTXNStateEnum.Approved && issueDoc.OriginalData.DocState == IssueTXNStateEnum.Closed)
                            {
                                //存储过程控制取消退料操作是否开启
                                DataParamList dpL = new DataParamList();
                                dpL.Add(DataParamFactory.Create("Type", "BtnRecedeReverse", ParameterDirection.Input, DbType.String, 50));//禁用取消退料功能
                                dpL.Add(DataParamFactory.CreateOutput("IsOpen", DbType.String));
                                DataAccessor.RunSP("sp_Auctus_BEPlugin_Control", dpL);
                                string isOpen = dpL["IsOpen"].Value.ToString();
                                if (isOpen == "1")//打开控制
                                {
                                    UFIDA.U9.InvDoc.MiscShip.MiscShipmentL miscShipLine = UFIDA.U9.InvDoc.MiscShip.MiscShipmentL.Finder.Find("DescFlexSegments.PrivateDescSeg29='" + issueDoc.DocNo + "'");
                                    bool   flag    = false;
                                    string delDocs = "";
                                    if (miscShipLine != null)
                                    {
                                        flag     = true;
                                        delDocs += miscShipLine.MiscShip.DocNo;
                                    }
                                    UFIDA.U9.InvDoc.MiscRcv.MiscRcvTransL rcvTransLine = UFIDA.U9.InvDoc.MiscRcv.MiscRcvTransL.Finder.Find("DescFlexSegments.PrivateDescSeg29='" + issueDoc.DocNo + "'");
                                    if (rcvTransLine != null)
                                    {
                                        flag     = true;
                                        delDocs += rcvTransLine.MiscRcvTrans.DocNo;
                                    }
                                    if (flag)
                                    {
                                        throw new Exception("此单已生成杂收、杂发单,不能取消。如果需要取消需删除杂发、杂收单:" + delDocs);
                                    }
                                }
                            }
                            //单据从已核准状态到关闭状态,说明是退料确认操作
                            if (issueDoc.DocState == IssueTXNStateEnum.Closed && issueDoc.OriginalData.DocState == IssueTXNStateEnum.Approved)
                            {
                                //创建杂发单
                                #region 创建杂发杂收单
                                UFIDA.U9.ISV.MiscShipISV.Proxy.CommonCreateMiscShipProxy shipSv = new UFIDA.U9.ISV.MiscShipISV.Proxy.CommonCreateMiscShipProxy();
                                shipSv.MiscShipmentDTOList = new List <UFIDA.U9.ISV.MiscShipISV.IC_MiscShipmentDTOData>();//杂发SV参数
                                #region 杂发单数据
                                IC_MiscShipmentDTOData shipheadDto = new IC_MiscShipmentDTOData();
                                shipheadDto.BenefitOrg      = Context.LoginOrg.ID;
                                shipheadDto.BusinessDate    = DateTime.Now;
                                shipheadDto.MiscShipDocType = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData();
                                UFIDA.U9.InvDoc.MiscShip.MiscShipDocType shipDocType = UFIDA.U9.InvDoc.MiscShip.MiscShipDocType.Finder.Find("Code='MS30129' and Org=" + Context.LoginOrg.ID.ToString());//杂发单类型
                                shipheadDto.MiscShipDocType.ID   = shipDocType.ID;
                                shipheadDto.MiscShipDocType.Code = shipDocType.Code;
                                shipheadDto.MiscShipDocType.Name = shipDocType.Name;
                                shipheadDto.Org              = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData();
                                shipheadDto.Org.ID           = Context.LoginOrg.ID;
                                shipheadDto.Org.Code         = Context.LoginOrg.Code;
                                shipheadDto.Org.Name         = Context.LoginOrg.Name;
                                shipheadDto.SOBAccountPeriod = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData();
                                UFIDA.U9.Base.SOB.SOBAccountingPeriod sobPeriod = UFIDA.U9.Base.SOB.SOBAccountingPeriod.GetSOBAccountingPeriod(UFIDA.U9.Base.SOB.SetofBooks.Finder.Find("org='" + Context.LoginOrg.ID.ToString() + "'"), DateTime.Now);
                                shipheadDto.SOBAccountPeriod.ID   = sobPeriod.ID;
                                shipheadDto.SOBAccountPeriod.Code = sobPeriod.Code;
                                shipheadDto.SOBAccountPeriod.Name = sobPeriod.DisplayName;
                                #region 杂发行数据
                                UFIDA.U9.MO.Issue.IssueDocLine.EntityList lines = issueDoc.IssueDocLines;//退料行数据
                                shipheadDto.MiscShipLs = new List <IC_MiscShipmentLDTOData>();
                                for (int i = 0; i < lines.Count; i++)
                                {
                                    UFIDA.U9.MO.Issue.IssueDocLine line        = lines[i];
                                    IC_MiscShipmentLDTOData        shipLineDto = new IC_MiscShipmentLDTOData();
                                    //扩展字段中记录杂发单的来源退料单号、行号
                                    shipLineDto.DescFlexSegments = new UFIDA.U9.Base.FlexField.DescFlexField.DescFlexSegmentsData();
                                    shipLineDto.DescFlexSegments.PrivateDescSeg2  = line.MO.DocNo;
                                    shipLineDto.DescFlexSegments.PrivateDescSeg29 = issueDoc.DocNo;
                                    shipLineDto.DescFlexSegments.PrivateDescSeg30 = line.LineNum.ToString();
                                    shipLineDto.ItemInfo          = new UFIDA.U9.CBO.SCM.Item.ItemInfoData();
                                    shipLineDto.ItemInfo.ItemID   = line.Item.ID;
                                    shipLineDto.ItemInfo.ItemCode = line.Item.Code;
                                    shipLineDto.ItemInfo.ItemName = line.Item.Name;
                                    shipLineDto.StoreUOMQty       = line.IssuedQty;                                             //库存数量
                                    shipLineDto.CostUOMQty        = line.IssuedQty;                                             //成本数量
                                    shipLineDto.StoreUOM          = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData(); //库存单位
                                    shipLineDto.StoreUOM.ID       = line.StoreBaseUOM.ID;
                                    shipLineDto.StoreUOM.Code     = line.StoreBaseUOM.Code;
                                    shipLineDto.StoreUOM.Name     = line.StoreBaseUOM.Name;
                                    shipLineDto.Wh        = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData();//存储地点
                                    shipLineDto.Wh.ID     = line.Wh.ID;
                                    shipLineDto.Wh.Code   = line.Wh.Code;
                                    shipLineDto.Wh.Name   = line.Wh.Name;
                                    shipLineDto.StoreType = line.StorageType.Value;//存储类型
                                    if (issueDoc.HandleDept != null)
                                    {
                                        shipLineDto.BenefitDept      = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData();//受益部门
                                        shipLineDto.BenefitDept.ID   = issueDoc.HandleDept.ID;
                                        shipLineDto.BenefitDept.Code = issueDoc.HandleDept.Code;
                                        shipLineDto.BenefitDept.Name = issueDoc.HandleDept.Name;
                                    }
                                    shipLineDto.BenefitPsn = new CommonArchiveDataDTOData();
                                    if (issueDoc.HandlePerson != null)
                                    {
                                        shipLineDto.BenefitPsn.ID   = issueDoc.HandlePerson.ID;
                                        shipLineDto.BenefitPsn.Code = issueDoc.HandlePerson.Code;
                                        shipLineDto.BenefitPsn.Name = issueDoc.HandlePerson.Name;
                                    }
                                    if (!string.IsNullOrEmpty(lines[i].LotNo))
                                    {
                                        shipLineDto.LotInfo         = new UFIDA.U9.CBO.SCM.PropertyTypes.LotInfoData();
                                        shipLineDto.LotInfo.LotCode = lines[i].LotNo;
                                        //shipLineDto.LotInfo.LotMaster = new UFIDA.U9.Base.PropertyTypes.BizEntityKeyData();
                                        //shipLineDto.LotInfo.LotMaster=lines[i].LotMaster
                                    }
                                    shipLineDto.OwnerOrg      = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData();//货主组织
                                    shipLineDto.OwnerOrg.ID   = Context.LoginOrg.ID;
                                    shipLineDto.OwnerOrg.Code = Context.LoginOrg.Code;
                                    shipLineDto.OwnerOrg.Name = Context.LoginOrg.Name;
                                    shipheadDto.MiscShipLs.Add(shipLineDto);
                                }
                                #endregion

                                #endregion
                                shipSv.MiscShipmentDTOList.Add(shipheadDto);
                                shipSv.TargetOrgCode = Context.LoginOrg.Code;
                                shipSv.TargetOrgName = Context.LoginOrg.Name;
                                List <CommonArchiveDataDTOData> liShipReturn = new List <CommonArchiveDataDTOData>();
                                liShipReturn = shipSv.Do();

                                #endregion
                                //提交杂发单
                                #region CommonCommitMiscShipSV
                                UFIDA.U9.ISV.MiscShipISV.Proxy.CommonCommitMiscShipSVProxy shipCommitSV = new UFIDA.U9.ISV.MiscShipISV.Proxy.CommonCommitMiscShipSVProxy();
                                shipCommitSV.MiscShipmentKeyList = new List <CommonArchiveDataDTOData>();
                                shipCommitSV.MiscShipmentKeyList = liShipReturn;
                                shipCommitSV.Do();
                                #endregion

                                //审核杂发单
                                #region CommonApproveMiscShipSV
                                UFIDA.U9.ISV.MiscShipISV.Proxy.CommonApproveMiscShipSVProxy shipApproveSV = new UFIDA.U9.ISV.MiscShipISV.Proxy.CommonApproveMiscShipSVProxy();
                                shipApproveSV.MiscShipmentKeyList = new List <CommonArchiveDataDTOData>();
                                shipApproveSV.MiscShipmentKeyList = liShipReturn;
                                shipApproveSV.Do();
                                #endregion

                                //创建杂收单,把上面创建的杂发单杂收了
                                #region 创建杂收单
                                UFIDA.U9.ISV.MiscRcvISV.Proxy.CommonCreateMiscRcvProxy rcvSV = new UFIDA.U9.ISV.MiscRcvISV.Proxy.CommonCreateMiscRcvProxy();
                                //杂收SV参数
                                rcvSV.TargetOrgCode  = Context.LoginOrg.Code;
                                rcvSV.TargetOrgName  = Context.LoginOrg.Name;
                                rcvSV.MiscRcvDTOList = new List <UFIDA.U9.ISV.MiscRcvISV.IC_MiscRcvDTOData>();
                                IC_MiscRcvDTOData rcvHeadDto = new IC_MiscRcvDTOData();//杂收单头
                                //dto.DocNo = "MR30190417999";
                                rcvHeadDto.MiscRcvDocType = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData();
                                UFIDA.U9.InvDoc.MiscRcv.MiscRcvDocType rcvDocType = UFIDA.U9.InvDoc.MiscRcv.MiscRcvDocType.Finder.Find("Code='MR30116' and Org= " + Context.LoginOrg.ID);
                                rcvHeadDto.MiscRcvDocType.ID     = rcvDocType.ID;
                                rcvHeadDto.MiscRcvDocType.Code   = rcvDocType.Code;
                                rcvHeadDto.MiscRcvDocType.Name   = rcvDocType.Name;
                                rcvHeadDto.BusinessDate          = DateTime.Now;                                               //业务日期
                                rcvHeadDto.SOBAccountPeriod      = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData(); //账期
                                rcvHeadDto.SOBAccountPeriod.ID   = sobPeriod.ID;
                                rcvHeadDto.SOBAccountPeriod.Code = sobPeriod.Code;
                                rcvHeadDto.SOBAccountPeriod.Name = sobPeriod.DisplayName;
                                rcvHeadDto.Org        = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData();
                                rcvHeadDto.Org.ID     = Context.LoginOrg.ID;;
                                rcvHeadDto.Org.Code   = Context.LoginOrg.Code;
                                rcvHeadDto.Org.Name   = Context.LoginOrg.Name;
                                rcvHeadDto.BenefitOrg = Context.LoginOrg.ID;//受益组织

                                #region 杂收行
                                rcvHeadDto.MiscRcvTransLs = new List <IC_MiscRcvTransLsDTOData>();
                                UFIDA.U9.CBO.SCM.Warehouse.Warehouse wh = UFIDA.U9.CBO.SCM.Warehouse.Warehouse.Finder.Find("Code='106' and Org=" + Context.LoginOrg.ID.ToString());
                                for (int i = 0; i < lines.Count; i++)
                                {
                                    UFIDA.U9.MO.Issue.IssueDocLine line       = lines[i];
                                    IC_MiscRcvTransLsDTOData       rcvLineDto = new IC_MiscRcvTransLsDTOData();
                                    //扩展字段中记录杂发单的来源退料单号、行号
                                    rcvLineDto.DescFlexSegments = new UFIDA.U9.Base.FlexField.DescFlexField.DescFlexSegmentsData();
                                    rcvLineDto.DescFlexSegments.PrivateDescSeg2  = line.MO.DocNo;
                                    rcvLineDto.DescFlexSegments.PrivateDescSeg29 = issueDoc.DocNo;
                                    rcvLineDto.DescFlexSegments.PrivateDescSeg30 = line.LineNum.ToString();
                                    rcvLineDto.ItemInfo          = new UFIDA.U9.CBO.SCM.Item.ItemInfoData();
                                    rcvLineDto.ItemInfo.ItemID   = line.Item.ID;
                                    rcvLineDto.ItemInfo.ItemCode = line.Item.Code;
                                    rcvLineDto.ItemInfo.ItemName = line.Item.Name;
                                    rcvLineDto.Wh               = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData();
                                    rcvLineDto.Wh.ID            = wh.ID;
                                    rcvLineDto.Wh.Code          = wh.Code;
                                    rcvLineDto.Wh.Name          = wh.Name;
                                    rcvLineDto.BenefitDept      = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData();
                                    rcvLineDto.BenefitDept.ID   = issueDoc.HandleDept.ID;
                                    rcvLineDto.BenefitDept.Code = issueDoc.HandleDept.Code;
                                    rcvLineDto.BenefitDept.Name = issueDoc.HandleDept.Name;
                                    rcvLineDto.StoreUOMQty      = line.IssuedQty;
                                    rcvLineDto.CostUOMQty       = line.IssuedQty;
                                    rcvLineDto.CostUOM          = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData();
                                    rcvLineDto.CostUOM.ID       = line.StoreBaseUOM.ID;
                                    rcvLineDto.CostUOM.Code     = line.StoreBaseUOM.Code;
                                    rcvLineDto.CostUOM.Name     = line.StoreBaseUOM.Name;
                                    rcvLineDto.StoreUOM         = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData();
                                    rcvLineDto.StoreUOM.ID      = line.StoreBaseUOM.ID;
                                    rcvLineDto.StoreUOM.Code    = line.StoreBaseUOM.Code;
                                    rcvLineDto.StoreUOM.Name    = line.StoreBaseUOM.Name;
                                    rcvLineDto.IsZeroCost       = true;
                                    //rcvLineDto.StoreUOM.ID = 1001708030115592;
                                    //rcvLineDto.StoreUOM.Code = "SL01";
                                    //rcvLineDto.StoreUOM.Name = "PCS";
                                    rcvLineDto.OwnerOrg      = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData();
                                    rcvLineDto.OwnerOrg.ID   = Context.LoginOrg.ID;
                                    rcvLineDto.OwnerOrg.Code = Context.LoginOrg.Code;
                                    rcvLineDto.OwnerOrg.Name = Context.LoginOrg.Name;
                                    if (!string.IsNullOrEmpty(lines[i].LotNo))
                                    {
                                        rcvLineDto.LotInfo         = new UFIDA.U9.CBO.SCM.PropertyTypes.LotInfoData();
                                        rcvLineDto.LotInfo.LotCode = lines[i].LotNo;
                                    }
                                    rcvHeadDto.MiscRcvTransLs.Add(rcvLineDto);
                                }
                                #endregion
                                rcvSV.MiscRcvDTOList.Add(rcvHeadDto);
                                List <CommonArchiveDataDTOData> liRcvReturn = new List <CommonArchiveDataDTOData>();
                                liRcvReturn = rcvSV.Do();//执行创建杂收单服务

                                #region 提交杂收单服务
                                UFIDA.U9.ISV.MiscRcvISV.Proxy.CommonCommitMiscRcvProxy rcvCommitSV = new UFIDA.U9.ISV.MiscRcvISV.Proxy.CommonCommitMiscRcvProxy();
                                rcvCommitSV.TargetOrgCode = Context.LoginOrg.Code;
                                rcvCommitSV.TargetOrgName = Context.LoginOrg.Name;
                                rcvCommitSV.MiscRcvKeys   = new List <CommonArchiveDataDTOData>();
                                rcvCommitSV.MiscRcvKeys   = liRcvReturn;
                                rcvCommitSV.Do();
                                #endregion

                                #region 审核杂收单
                                UFIDA.U9.ISV.MiscRcvISV.Proxy.CommonApproveMiscRcvProxy rcvApproveSV = new UFIDA.U9.ISV.MiscRcvISV.Proxy.CommonApproveMiscRcvProxy();
                                rcvApproveSV.TargetOrgCode = Context.LoginOrg.Code;
                                rcvApproveSV.MiscRcvKeys   = new List <CommonArchiveDataDTOData>();
                                rcvApproveSV.MiscRcvKeys   = liRcvReturn;
                                rcvApproveSV.Do();
                                #endregion

                                #endregion
                            }
                        }
                        #endregion

                        #region  领料控制
                        //根据更新前后时间判断订单是否已审核,若beforeConfirmDate=confirmDate表示订单已审核
                        string beforeConfirmDate = "";
                        string confirmDate       = "";
                        if (issueDoc.OriginalData.IssueItemOn != DateTime.MinValue)
                        {
                            beforeConfirmDate = issueDoc.OriginalData.IssueItemOn.ToString();
                        }
                        if (issueDoc.IssueItemOn != DateTime.MinValue)
                        {
                            confirmDate = issueDoc.IssueItemOn.ToString();
                        }
                        DataParamList dp = new DataParamList();
                        dp.Add(DataParamFactory.Create("DocNo", issueDoc.DocNo, ParameterDirection.Input, DbType.String, 50));
                        dp.Add(DataParamFactory.Create("BeforeConfirmDate", beforeConfirmDate, ParameterDirection.Input, DbType.String, 50));
                        dp.Add(DataParamFactory.Create("ConfirmDate", confirmDate, ParameterDirection.Input, DbType.String, 50));
                        dp.Add(DataParamFactory.CreateOutput("Result", DbType.String));
                        DataAccessor.RunSP("sp_auctus_BE_MoIssueDoc", dp);
                        string result = dp["Result"].Value.ToString();
                        if (result != "1")
                        {
                            throw new Exception(result);
                        }
                        #endregion

                        #region 提交流程到OA
                        if (issueDoc.DocType.DescFlexField.PrivateDescSeg1 == "1" && issueDoc.DocState == IssueTXNStateEnum.Approving && issueDoc.OriginalData.DocState == IssueTXNStateEnum.Opened)
                        {
                            PubFunction pubFun = new PubFunction();
                            User        user   = User.Finder.FindByID(Context.LoginUserID);//U9用户信息
                            Dictionary <string, object>         dicResult = new Dictionary <string, object>();
                            Dictionary <string, object>         dicMain   = GenerateMainInfo(issueDoc, user.Code);
                            List <Dictionary <string, object> > liDt      = GenerateDtInfo(issueDoc);
                            BaseInfo baseInfo;
                            string   workflowid = "";
                            if (issueDoc.IssueType == IssueTypeEnum.Issue)//发料
                            {
                                workflowid = PubFunction.GetOAInfoByCode("08");
                            }
                            else if (issueDoc.IssueType == IssueTypeEnum.Withdrawal)//退料
                            {
                                workflowid = PubFunction.GetOAInfoByCode("09");
                            }

                            string requestName = "";
                            if (issueDoc.IssueType == IssueTypeEnum.Issue)
                            {
                                requestName = "生产领料单:" + issueDoc.DocNo;
                            }
                            else if (issueDoc.IssueType == IssueTypeEnum.Withdrawal)
                            {
                                requestName = "生产退料单:" + issueDoc.DocNo;
                            }
                            if (issueDoc.DescFlexField.PrivateDescSeg6 == "是")//提交流程或弃审后重新提交流程
                            {
                                baseInfo = Utils.GenerateOABaseInfo(user.Code, workflowid, issueDoc.ID.ToString(), 1, issueDoc.DescFlexField.PrivateDescSeg5, 1, requestName);
                            }
                            else//驳回后重新提交
                            {
                                baseInfo = Utils.GenerateOABaseInfo(user.Code, workflowid, issueDoc.ID.ToString(), 1, "", 1, requestName);
                            }
                            dicResult.Add("base", baseInfo);
                            dicResult.Add("main", dicMain);
                            dicResult.Add("dt1", liDt);
                            List <Dictionary <string, object> > li = new List <Dictionary <string, object> >();
                            li.Add(dicResult);
                            string json = JsonHelper.GetJsonJS(li);
                            Utils.LogError("生产领料JSON");
                            Utils.LogError(json);
                            string OAFlowID = pubFun.OAService(json);
                            //更新扩展字段:OA流程ID和是否驳回
                            string sql = string.Format("update mo_IssueDoc set DescFlexField_PrivateDescSeg6='否',DescFlexField_PrivateDescSeg5='{0}' where ID={1}", OAFlowID, issueDoc.ID);
                            DataAccessor.RunSQL(DatabaseManager.GetCurrentConnection(), sql, null);//更新sql
                        }
                        #endregion
                    }

                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
Exemplo n.º 17
0
 /// <summary>
 /// 试算2功能 region之外的代码都是copy的U9反编译的代码
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void TryCalc_Extend(object sender, UIActionEventArgs e)
 {
     #region Add by liufei
     string ids = "";//拼接请购行ID字符串
     #endregion
     PRToPOUIModelAction prToPO = ((PRToPOUIModelAction)this.iPart.Action);
     prToPO.ClearErrorMessage();
     //this.OnBtnTryCalcClick_DefaultImpl(sender, e);
     IList <IUIRecord> selectRecordFromCache = UIRuntimeHelper.Instance.GetSelectRecordFromCache(prToPO.CurrentModel.PR_PRLineList);
     if (selectRecordFromCache == null || selectRecordFromCache.Count == 0)
     {
         throw new Exception(PRToPOUIModelRes.NoSelectedRecord);
     }
     //this.CurrentModel.TryCalcView.Records.Clear();
     prToPO.CurrentModel.TryCalcView.Records.Clear();
     string text = "";
     GetSupplierQuotaSVProxy getSupplierQuotaSVProxy = new GetSupplierQuotaSVProxy();
     getSupplierQuotaSVProxy.QuotaReqList = new List <QuotaReqDTOData>();
     int num = 1;
     Dictionary <long, int> dictionary = new Dictionary <long, int>();
     using (IEnumerator <IUIRecord> enumerator = selectRecordFromCache.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             PR_PRLineListRecord pR_PRLineListRecord = (PR_PRLineListRecord)enumerator.Current;
             #region Add by liufei
             ids += pR_PRLineListRecord.ID.ToString() + ",";
             #endregion
             if (!(pR_PRLineListRecord.ToPOQtyTU * pR_PRLineListRecord.TUToTBURate + pR_PRLineListRecord.ToPOQtyTBU <= 0m))
             {
                 if (!pR_PRLineListRecord.ItemInfo_ItemID_PurchaseInfo_IsNeedInquire || !(pR_PRLineListRecord.ItemInfo_ItemID_PurchaseInfo_InquireRule == InquireRuleEnum.EveryTime.Value))
                 {
                     if ((!(pR_PRLineListRecord.ItemInfo_ItemID_PurchaseInfo_PurchaseQuotaMode == 6) && pR_PRLineListRecord.BizType != BusinessTypeEnum.PM050.Value) || !pR_PRLineListRecord.SuggestedSupplier_Supplier.HasValue || !pR_PRLineListRecord.SuggestedSupplier_Supplier.HasValue || pR_PRLineListRecord.SuggestedSupplier_Supplier.Value <= 0L)
                     {
                         //QuotaReqDTOData item = this.CreateQuotaReqDTOData(pR_PRLineListRecord, num);
                         QuotaReqDTOData item = prToPO.CreateQuotaReqDTOData(pR_PRLineListRecord, num);
                         getSupplierQuotaSVProxy.QuotaReqList.Add(item);
                         dictionary.Add(pR_PRLineListRecord.ID, num);
                         num++;
                     }
                 }
             }
         }
     }
     List <QuotaDTOData> list = getSupplierQuotaSVProxy.Do();
     #region Add by liufei
     DataParamList dp = new DataParamList();
     ids = ids.Substring(0, ids.Length - 1);
     dp.Add(DataParamFactory.Create("PRIDS", ids, ParameterDirection.Input, DbType.String, 8000));
     dp.Add(DataParamFactory.CreateOutput("Result", DbType.String));
     DataSet ds = new DataSet();
     DataAccessor.RunSP("sp_Auctus_UI_GetSupplySource", dp, out ds);
     //按固定比例分配的料品是否存无厂商价目表、无供应商-料品交叉数据(即无MPQ)
     string result = dp["Result"].Value.ToString();
     if (result != "0")
     {
         throw new Exception(PRToPOUIModelRes.DataError + result);
     }
     #endregion
     Dictionary <int, List <QuotaDTOData> > dictionary2 = new Dictionary <int, List <QuotaDTOData> >();
     foreach (QuotaDTOData current in list)
     {
         if (dictionary2.ContainsKey(current.Index_1))
         {
             dictionary2[current.Index_1].Add(current);
         }
         else
         {
             List <QuotaDTOData> list2 = new List <QuotaDTOData>();
             list2.Add(current);
             dictionary2.Add(current.Index_1, list2);
         }
     }
     using (IEnumerator <IUIRecord> enumerator = selectRecordFromCache.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             PR_PRLineListRecord pR_PRLineListRecord = (PR_PRLineListRecord)enumerator.Current;
             if (!(pR_PRLineListRecord.ToPOQtyTU * pR_PRLineListRecord.TUToTBURate + pR_PRLineListRecord.ToPOQtyTBU <= 0m))
             {
                 if (!pR_PRLineListRecord.ItemInfo_ItemID_PurchaseInfo_IsNeedInquire || !(pR_PRLineListRecord.ItemInfo_ItemID_PurchaseInfo_InquireRule == InquireRuleEnum.EveryTime.Value))
                 {
                     if (text == "")
                     {
                         text = pR_PRLineListRecord.ID.ToString();
                     }
                     else
                     {
                         text = text + "," + pR_PRLineListRecord.ID.ToString();
                     }
                     if ((pR_PRLineListRecord.ItemInfo_ItemID_PurchaseInfo_PurchaseQuotaMode == 6 || pR_PRLineListRecord.BizType == BusinessTypeEnum.PM050.Value) && pR_PRLineListRecord.SuggestedSupplier_Supplier.HasValue && pR_PRLineListRecord.SuggestedSupplier_Supplier.HasValue && pR_PRLineListRecord.SuggestedSupplier_Supplier.Value > 0L)
                     {
                         //TryCalcViewRecord tryCalcViewRecord = this.CurrentModel.TryCalcView.AddNewUIRecord();
                         TryCalcViewRecord tryCalcViewRecord = prToPO.CurrentModel.TryCalcView.AddNewUIRecord();
                         tryCalcViewRecord.RFQStatus            = pR_PRLineListRecord.RFQStatus;
                         tryCalcViewRecord.RFQ_SrcDocNo         = pR_PRLineListRecord.RFQInfo_SrcDocNo;
                         tryCalcViewRecord.Currency             = pR_PRLineListRecord.PR_AC;
                         tryCalcViewRecord.LineEntityID         = new long?(pR_PRLineListRecord.ID);
                         tryCalcViewRecord.ItemCode             = pR_PRLineListRecord.ItemInfo_ItemCode;
                         tryCalcViewRecord.ItemID               = pR_PRLineListRecord.ItemInfo_ItemID;
                         tryCalcViewRecord.ItemName             = pR_PRLineListRecord.ItemInfo_ItemName;
                         tryCalcViewRecord.ItemIsDual           = new bool?(pR_PRLineListRecord.ItemInfo_ItemID_IsDualQuantity);
                         tryCalcViewRecord.PRDocLineNo          = new long?((long)pR_PRLineListRecord.DocLineNo);
                         tryCalcViewRecord.RequiredDeliveryDate = pR_PRLineListRecord.RequiredDeliveryDate;
                         tryCalcViewRecord.Supplier             = pR_PRLineListRecord.SuggestedSupplier_Supplier;
                         tryCalcViewRecord.Supplier_Code        = pR_PRLineListRecord.SuggestedSupplier_Code;
                         tryCalcViewRecord.Supplier_Name        = pR_PRLineListRecord.SuggestedSupplier_Name;
                         tryCalcViewRecord.SPECS      = pR_PRLineListRecord.ItemInfo_ItemID_SPECS;
                         tryCalcViewRecord.DemandCode = pR_PRLineListRecord.DemandCode;
                         if (pR_PRLineListRecord.BizType == BusinessTypeEnum.PM050.Value)
                         {
                             tryCalcViewRecord.ToPOQtyTBU                    = 0m;
                             tryCalcViewRecord.TradeBaseUom                  = new long?(0L);
                             tryCalcViewRecord.TradeBaseUom_Code             = "";
                             tryCalcViewRecord.TradeBaseUom_Name             = "";
                             tryCalcViewRecord.TradeBaseUOM_Round_Precision  = 0;
                             tryCalcViewRecord.TradeBaseUOM_Round_RoundType  = 0;
                             tryCalcViewRecord.TradeBaseUOM_Round_RoundValue = new int?(0);
                         }
                         else
                         {
                             tryCalcViewRecord.ToPOQtyTBU                    = pR_PRLineListRecord.ToPOQtyTBU;
                             tryCalcViewRecord.TradeBaseUom                  = pR_PRLineListRecord.TradeBaseUOM;
                             tryCalcViewRecord.TradeBaseUom_Code             = pR_PRLineListRecord.TradeBaseUOM_Code;
                             tryCalcViewRecord.TradeBaseUom_Name             = pR_PRLineListRecord.TradeBaseUOM_Name;
                             tryCalcViewRecord.TradeBaseUOM_Round_Precision  = pR_PRLineListRecord.TradeBaseUOM_Round_Precision;
                             tryCalcViewRecord.TradeBaseUOM_Round_RoundType  = pR_PRLineListRecord.TradeBaseUOM_Round_RoundType;
                             tryCalcViewRecord.TradeBaseUOM_Round_RoundValue = pR_PRLineListRecord.TradeBaseUOM_Round_RoundValue;
                         }
                         tryCalcViewRecord.ToPOQtyTU                 = pR_PRLineListRecord.ToPOQtyTU;
                         tryCalcViewRecord.TradeUom                  = pR_PRLineListRecord.TradeUOM;
                         tryCalcViewRecord.TradeUom_Code             = pR_PRLineListRecord.TradeUOM_Code;
                         tryCalcViewRecord.TradeUom_Name             = pR_PRLineListRecord.TradeUOM_Name;
                         tryCalcViewRecord.TradeUOM_Round_Precision  = pR_PRLineListRecord.TradeUOM_Round_Precision;
                         tryCalcViewRecord.TradeUOM_Round_RoundType  = pR_PRLineListRecord.TradeUOM_Round_RoundType;
                         tryCalcViewRecord.TradeUOM_Round_RoundValue = pR_PRLineListRecord.TradeUOM_Round_RoundValue;
                         tryCalcViewRecord.BizType = pR_PRLineListRecord.BizType;
                         if (pR_PRLineListRecord.ItemInfo_ItemID_ItemFormAttribute == 16)
                         {
                             tryCalcViewRecord.IsMisc = new bool?(true);
                         }
                         else
                         {
                             tryCalcViewRecord.IsMisc = new bool?(false);
                         }
                     }
                     else
                     {
                         try
                         {
                             if (dictionary.ContainsKey(pR_PRLineListRecord.ID) && dictionary2.ContainsKey(dictionary[pR_PRLineListRecord.ID]))
                             {
                                 List <QuotaDTOData> list2 = dictionary2[dictionary[pR_PRLineListRecord.ID]];
                                 #region ADD By liufei
                                 //固定比例分配模式的请购单
                                 if (pR_PRLineListRecord.ItemInfo_ItemID_PurchaseInfo_PurchaseQuotaMode == 4)//固定比例分配模式
                                 {
                                     DataRow[] dr = ds.Tables[0].Select("PRLineID=" + pR_PRLineListRecord.ID);
                                     if (dr.Length > 0)
                                     {
                                         foreach (DataRow item in dr)
                                         {
                                             if (Convert.ToDecimal(item["ActualReq"]) == 0)
                                             {
                                                 list2.Remove(list2.Where(m => m.Supplier == Convert.ToInt64(item["Supplier"]) && m.SupplySource == Convert.ToInt64(item["SupplySource"])).Select(m => m).First());
                                             }
                                             else
                                             {
                                                 for (int i = 0; i < list2.Count; i++)
                                                 {
                                                     if (item["Supplier"].ToString() == list2[i].Supplier.ToString() && item["SupplySource"].ToString() == list2[i].SupplySource.ToString())
                                                     {
                                                         list2[i].PurNum.Amount1 = Convert.ToDecimal(item["ActualReq"]);
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                                 #endregion
                                 foreach (QuotaDTOData current2 in list2)
                                 {
                                     if (current2.PurNum.Amount1 == 0m && current2.PurNum.Amount2 == 0m)
                                     {
                                         throw new Exception(PRToPOUIModelRes.SupQtyZeroCannotGenPO);
                                     }
                                     //TryCalcViewRecord tryCalcViewRecord = this.CurrentModel.TryCalcView.AddNewUIRecord();
                                     TryCalcViewRecord tryCalcViewRecord = prToPO.CurrentModel.TryCalcView.AddNewUIRecord();
                                     tryCalcViewRecord.RFQStatus                 = pR_PRLineListRecord.RFQStatus;
                                     tryCalcViewRecord.RFQ_SrcDocNo              = pR_PRLineListRecord.RFQInfo_SrcDocNo;
                                     tryCalcViewRecord.Currency                  = pR_PRLineListRecord.PR_AC;
                                     tryCalcViewRecord.ItemID                    = pR_PRLineListRecord.ItemInfo_ItemID;
                                     tryCalcViewRecord.ItemCode                  = pR_PRLineListRecord.ItemInfo_ItemCode;
                                     tryCalcViewRecord.ItemName                  = pR_PRLineListRecord.ItemInfo_ItemName;
                                     tryCalcViewRecord.ItemIsDual                = new bool?(pR_PRLineListRecord.ItemInfo_ItemID_IsDualQuantity);
                                     tryCalcViewRecord.PRDocLineNo               = new long?((long)pR_PRLineListRecord.DocLineNo);
                                     tryCalcViewRecord.RequiredDeliveryDate      = pR_PRLineListRecord.RequiredDeliveryDate;
                                     tryCalcViewRecord.TradeUom                  = pR_PRLineListRecord.TradeUOM;
                                     tryCalcViewRecord.TradeUom_Code             = pR_PRLineListRecord.TradeUOM_Code;
                                     tryCalcViewRecord.TradeUom_Name             = pR_PRLineListRecord.TradeUOM_Name;
                                     tryCalcViewRecord.LineEntityID              = new long?(pR_PRLineListRecord.ID);
                                     tryCalcViewRecord.TradeUOM_Round_Precision  = pR_PRLineListRecord.TradeUOM_Round_Precision;
                                     tryCalcViewRecord.TradeUOM_Round_RoundType  = pR_PRLineListRecord.TradeUOM_Round_RoundType;
                                     tryCalcViewRecord.TradeUOM_Round_RoundValue = pR_PRLineListRecord.TradeUOM_Round_RoundValue;
                                     tryCalcViewRecord.SPECS      = pR_PRLineListRecord.ItemInfo_ItemID_SPECS;
                                     tryCalcViewRecord.DemandCode = pR_PRLineListRecord.DemandCode;
                                     if (pR_PRLineListRecord.BizType == BusinessTypeEnum.PM050.Value)
                                     {
                                         tryCalcViewRecord.ToPOQtyTBU                    = 0m;
                                         tryCalcViewRecord.TradeBaseUom                  = new long?(0L);
                                         tryCalcViewRecord.TradeBaseUom_Code             = "";
                                         tryCalcViewRecord.TradeBaseUom_Name             = "";
                                         tryCalcViewRecord.TradeBaseUOM_Round_Precision  = 0;
                                         tryCalcViewRecord.TradeBaseUOM_Round_RoundType  = 0;
                                         tryCalcViewRecord.TradeBaseUOM_Round_RoundValue = new int?(0);
                                         if (pR_PRLineListRecord.ItemInfo_ItemID_IsDualQuantity)
                                         {
                                             tryCalcViewRecord.ToPOQtyTU = current2.PurNum.Amount1;
                                         }
                                         else
                                         {
                                             tryCalcViewRecord.ToPOQtyTU = current2.PurNum.Amount1;
                                         }
                                     }
                                     else
                                     {
                                         tryCalcViewRecord.TradeBaseUom                  = pR_PRLineListRecord.TradeBaseUOM;
                                         tryCalcViewRecord.TradeBaseUom_Code             = pR_PRLineListRecord.TradeBaseUOM_Code;
                                         tryCalcViewRecord.TradeBaseUom_Name             = pR_PRLineListRecord.TradeBaseUOM_Name;
                                         tryCalcViewRecord.TradeBaseUOM_Round_Precision  = pR_PRLineListRecord.TradeBaseUOM_Round_Precision;
                                         tryCalcViewRecord.TradeBaseUOM_Round_RoundType  = pR_PRLineListRecord.TradeBaseUOM_Round_RoundType;
                                         tryCalcViewRecord.TradeBaseUOM_Round_RoundValue = pR_PRLineListRecord.TradeBaseUOM_Round_RoundValue;
                                         if (pR_PRLineListRecord.ItemInfo_ItemID_IsDualQuantity)
                                         {
                                             tryCalcViewRecord.ToPOQtyTBU = current2.PurNum.Amount2;
                                             tryCalcViewRecord.ToPOQtyTU  = current2.PurNum.Amount1;
                                         }
                                         else
                                         {
                                             tryCalcViewRecord.ToPOQtyTBU = 0m;
                                             tryCalcViewRecord.ToPOQtyTU  = current2.PurNum.Amount1;
                                         }
                                     }
                                     tryCalcViewRecord.BizType       = pR_PRLineListRecord.BizType;
                                     tryCalcViewRecord.Supplier      = new long?(current2.Supplier);
                                     tryCalcViewRecord.Supplier_Code = current2.SupplierCode;
                                     tryCalcViewRecord.Supplier_Name = current2.SupplierName;
                                 }
                             }
                             else
                             {
                                 //TryCalcViewRecord tryCalcViewRecord = this.CurrentModel.TryCalcView.AddNewUIRecord();
                                 TryCalcViewRecord tryCalcViewRecord = prToPO.CurrentModel.TryCalcView.AddNewUIRecord();
                                 tryCalcViewRecord.RFQStatus            = pR_PRLineListRecord.RFQStatus;
                                 tryCalcViewRecord.RFQ_SrcDocNo         = pR_PRLineListRecord.RFQInfo_SrcDocNo;
                                 tryCalcViewRecord.Currency             = pR_PRLineListRecord.PR_AC;
                                 tryCalcViewRecord.LineEntityID         = new long?(pR_PRLineListRecord.ID);
                                 tryCalcViewRecord.ItemCode             = pR_PRLineListRecord.ItemInfo_ItemCode;
                                 tryCalcViewRecord.ItemID               = pR_PRLineListRecord.ItemInfo_ItemID;
                                 tryCalcViewRecord.ItemName             = pR_PRLineListRecord.ItemInfo_ItemName;
                                 tryCalcViewRecord.ItemIsDual           = new bool?(pR_PRLineListRecord.ItemInfo_ItemID_IsDualQuantity);
                                 tryCalcViewRecord.PRDocLineNo          = new long?((long)pR_PRLineListRecord.DocLineNo);
                                 tryCalcViewRecord.RequiredDeliveryDate = pR_PRLineListRecord.RequiredDeliveryDate;
                                 tryCalcViewRecord.SPECS      = pR_PRLineListRecord.ItemInfo_ItemID_SPECS;
                                 tryCalcViewRecord.DemandCode = pR_PRLineListRecord.DemandCode;
                                 if (pR_PRLineListRecord.BizType == BusinessTypeEnum.PM050.Value)
                                 {
                                     tryCalcViewRecord.ToPOQtyTBU                    = 0m;
                                     tryCalcViewRecord.TradeBaseUom                  = new long?(0L);
                                     tryCalcViewRecord.TradeBaseUom_Code             = "";
                                     tryCalcViewRecord.TradeBaseUom_Name             = "";
                                     tryCalcViewRecord.TradeBaseUOM_Round_Precision  = 0;
                                     tryCalcViewRecord.TradeBaseUOM_Round_RoundType  = 0;
                                     tryCalcViewRecord.TradeBaseUOM_Round_RoundValue = new int?(0);
                                 }
                                 else
                                 {
                                     tryCalcViewRecord.TradeBaseUom                  = pR_PRLineListRecord.TradeBaseUOM;
                                     tryCalcViewRecord.TradeBaseUom_Code             = pR_PRLineListRecord.TradeBaseUOM_Code;
                                     tryCalcViewRecord.TradeBaseUom_Name             = pR_PRLineListRecord.TradeBaseUOM_Name;
                                     tryCalcViewRecord.TradeBaseUOM_Round_Precision  = pR_PRLineListRecord.TradeBaseUOM_Round_Precision;
                                     tryCalcViewRecord.TradeBaseUOM_Round_RoundType  = pR_PRLineListRecord.TradeBaseUOM_Round_RoundType;
                                     tryCalcViewRecord.TradeBaseUOM_Round_RoundValue = pR_PRLineListRecord.TradeBaseUOM_Round_RoundValue;
                                     tryCalcViewRecord.ToPOQtyTBU = pR_PRLineListRecord.ToPOQtyTBU;
                                 }
                                 tryCalcViewRecord.ToPOQtyTU                 = pR_PRLineListRecord.ToPOQtyTU;
                                 tryCalcViewRecord.TradeUom                  = pR_PRLineListRecord.TradeUOM;
                                 tryCalcViewRecord.TradeUom_Code             = pR_PRLineListRecord.TradeUOM_Code;
                                 tryCalcViewRecord.TradeUom_Name             = pR_PRLineListRecord.TradeUOM_Name;
                                 tryCalcViewRecord.TradeUOM_Round_Precision  = pR_PRLineListRecord.TradeUOM_Round_Precision;
                                 tryCalcViewRecord.TradeUOM_Round_RoundType  = pR_PRLineListRecord.TradeUOM_Round_RoundType;
                                 tryCalcViewRecord.TradeUOM_Round_RoundValue = pR_PRLineListRecord.TradeUOM_Round_RoundValue;
                                 tryCalcViewRecord.BizType = pR_PRLineListRecord.BizType;
                                 if (pR_PRLineListRecord.ItemInfo_ItemID_ItemFormAttribute == 16)
                                 {
                                     tryCalcViewRecord.IsMisc = new bool?(true);
                                 }
                                 else
                                 {
                                     tryCalcViewRecord.IsMisc = new bool?(false);
                                 }
                                 //this.SetErrorMsg(tryCalcViewRecord, "Supplier", string.Concat(new string[]
                                 prToPO.SetErrorMsg(tryCalcViewRecord, "Supplier", string.Concat(new string[]
                                 {
                                     PRToPOUIModelRes.LineNum1,
                                     tryCalcViewRecord.PRDocLineNo.GetValueOrDefault().ToString(),
                                     PRToPOUIModelRes.LineNum2,
                                     PRToPOUIModelRes.ItemCode,
                                     tryCalcViewRecord.ItemCode,
                                     PRToPOUIModelRes.SupplierBeNull
                                 }));
                             }
                         }
                         catch (Exception ex)
                         {
                             throw ex;
                         }
                     }
                 }
             }
         }
     }
     string partId = "b7345fdb-dab2-4b1a-b380-af6e4d2b285c";
     //string parentTaskId = base.CurrentPart.TaskId.ToString();
     string parentTaskId = prToPO.CurrentPart.TaskId.ToString();
     string width        = "810";
     string height       = "465";
     //base.CurrentState["PRToPO_SelectedPrLineIDs"] = text;
     prToPO.CurrentState["PRToPO_SelectedPrLineIDs"] = text;
     //base.CurrentPart.ShowModalDialog(partId, PRToPOUIModelRes.TryCalc, width, height, parentTaskId, null, false, true);
     prToPO.CurrentPart.ShowModalDialog(partId, PRToPOUIModelRes.TryCalc, width, height, parentTaskId, null, false, true);
 }
Exemplo n.º 18
0
        public void Notify(params object[] args)
        {
            if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent))
            {
                return;
            }

            //将入口参数列表中第一个参数,转成EntityEvent,并取EntityKey存入key
            UFSoft.UBF.Business.BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;
            //key的有效性判断
            if (key == null)
            {
                return;
            }
            //转成所需实体,同时判断有效性
            UFIDA.U9.PM.PO.PurchaseOrder po = (UFIDA.U9.PM.PO.PurchaseOrder)key.GetEntity();

            if (po == null)
            {
                return;
            }
            else
            {
                //锁WMO转WPO功能
                if (po.Org.Code == "300")//po.SubType委外订单
                {
                    try
                    {
                        DataParamList dp = new DataParamList();
                        dp.Add(DataParamFactory.Create("DocNo", po.DocNo, ParameterDirection.Input, DbType.String, 50));
                        dp.Add(DataParamFactory.CreateOutput("Result", DbType.String));
                        DataAccessor.RunSP("sp_Auctus_BE_PurchaseOrderAI", dp);
                        string result = dp["Result"].Value.ToString();
                        if (result != "0")
                        {
                            throw new Exception(result);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
                ////锁WMO转WPO功能
                //if (po.Org.Code == "300" && po.SubType.Value.ToString() != "-1")//po.SubType委外订单
                //{
                //    try
                //    {
                //        DataParamList dp = new DataParamList();
                //        dp.Add(DataParamFactory.Create("DocNo", po.DocNo, ParameterDirection.Input, DbType.String, 50));
                //        dp.Add(DataParamFactory.CreateOutput("Result", DbType.String));
                //        DataAccessor.RunSP("sp_Auctus_BE_PurchaseOrderAI", dp);
                //        string result = dp["Result"].Value.ToString();
                //        if (result != "0")
                //        {
                //            throw new Exception(result);
                //        }
                //    }
                //    catch (Exception ex)
                //    {
                //        throw new Exception(ex.Message);
                //    }
                //}
                //end if
                ////锁WMO转WPO功能
                //if (po.Org.Code == "300")//po.SubType委外订单
                //{
                //    try
                //    {
                //        DataParamList dp = new DataParamList();
                //        dp.Add(DataParamFactory.Create("DocNo", po.DocNo, ParameterDirection.Input, DbType.String, 50));
                //        dp.Add(DataParamFactory.CreateOutput("Result", DbType.String));
                //        DataAccessor.RunSP("sp_Auctus_BE_PurchaseOrderAI", dp);
                //        string result = dp["Result"].Value.ToString();
                //        if (result != "1")
                //        {
                //            throw new Exception(result);
                //        }
                //    }
                //    catch (Exception ex)
                //    {
                //        throw new Exception(ex.Message);
                //    }
                //}//end if
            }
        }
Exemplo n.º 19
0
 /// <summary>
 /// 试算2功能 region之外的代码都是copy的U9反编译的代码
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void TryCalc_Extend(object sender, UIActionEventArgs e)
 {
     #region Add by liufei
     string ids = "";//拼接请购行ID字符串
     #endregion
     ListPRToPOUIModelAction listPRToPO = ((ListPRToPOUIModelAction)this.iPart.Action);
     listPRToPO.ClearErrorMessage();
     listPRToPO.CalAmountAndSetRFQForCalcBtn();
     IList <IUIRecord> selectRecordFromCache = UIRuntimeHelper.Instance.GetSelectRecordFromCache(listPRToPO.CurrentModel.PRLine);
     if (selectRecordFromCache == null || selectRecordFromCache.Count == 0)
     {
         throw new Exception(UFIDA.U9.SCM.PM.PRToPOUIModel.PRToPOUIModelRes.NoSelectedRecord);
     }
     listPRToPO.CurrentModel.TryCalcView.Records.Clear();
     string text = "";
     GetSupplierQuotaSVProxy getSupplierQuotaSVProxy = new GetSupplierQuotaSVProxy();
     getSupplierQuotaSVProxy.QuotaReqList = new List <QuotaReqDTOData>();
     int num = 1;
     Dictionary <long, int> dictionary = new Dictionary <long, int>();
     using (IEnumerator <IUIRecord> enumerator = selectRecordFromCache.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             PRLineRecord pRLineRecord = (PRLineRecord)enumerator.Current;
             #region Add by liufei
             ids += pRLineRecord.ID.ToString() + ",";
             #endregion
             if (!(pRLineRecord.ToPOQtyTU * pRLineRecord.TUToTBURate + pRLineRecord.ToPOQtyTBU <= 0m))
             {
                 if (!pRLineRecord.ItemInfo_ItemID_PurchaseInfo_IsNeedInquire || !(pRLineRecord.ItemInfo_ItemID_PurchaseInfo_InquireRule == InquireRuleEnum.EveryTime.Value))
                 {
                     if ((!(pRLineRecord.ItemInfo_ItemID_PurchaseInfo_PurchaseQuotaMode == 6) && pRLineRecord.BizType != BusinessTypeEnum.PM050.Value) || !pRLineRecord.SuggestedSupplier_Supplier.HasValue || !pRLineRecord.SuggestedSupplier_Supplier.HasValue || pRLineRecord.SuggestedSupplier_Supplier.Value <= 0L)
                     {
                         QuotaReqDTOData quotaReqDTOData = new QuotaReqDTOData();
                         quotaReqDTOData.Item = new ItemInfoData();
                         if (pRLineRecord.BizType == BusinessTypeEnum.PM050.Value)
                         {
                             quotaReqDTOData.Item.ItemCode = pRLineRecord.ProcessItem_ItemCode;
                             quotaReqDTOData.Item.ItemID   = pRLineRecord.ProcessItem_ItemID.Value;
                             quotaReqDTOData.Item.ItemName = pRLineRecord.ProcessItem_ItemName;
                             if (pRLineRecord.ProcessItem_ItemOpt1.HasValue && pRLineRecord.ProcessItem_ItemOpt1.HasValue)
                             {
                                 quotaReqDTOData.Item.ItemOpt1 = pRLineRecord.ProcessItem_ItemOpt1.Value;
                             }
                             if (pRLineRecord.ProcessItem_ItemOpt2.HasValue && pRLineRecord.ProcessItem_ItemOpt2.HasValue)
                             {
                                 quotaReqDTOData.Item.ItemOpt2 = pRLineRecord.ProcessItem_ItemOpt2.Value;
                             }
                             if (pRLineRecord.ProcessItem_ItemOpt3.HasValue && pRLineRecord.ProcessItem_ItemOpt3.HasValue)
                             {
                                 quotaReqDTOData.Item.ItemOpt3 = pRLineRecord.ProcessItem_ItemOpt3.Value;
                             }
                             if (pRLineRecord.ProcessItem_ItemOpt4.HasValue && pRLineRecord.ProcessItem_ItemOpt4.HasValue)
                             {
                                 quotaReqDTOData.Item.ItemOpt4 = pRLineRecord.ProcessItem_ItemOpt4.Value;
                             }
                             if (pRLineRecord.ProcessItem_ItemOpt5.HasValue && pRLineRecord.ProcessItem_ItemOpt5.HasValue)
                             {
                                 quotaReqDTOData.Item.ItemOpt5 = pRLineRecord.ProcessItem_ItemOpt5.Value;
                             }
                             if (pRLineRecord.ProcessItem_ItemOpt6.HasValue && pRLineRecord.ProcessItem_ItemOpt6.HasValue)
                             {
                                 quotaReqDTOData.Item.ItemOpt6 = pRLineRecord.ProcessItem_ItemOpt6.Value;
                             }
                             if (pRLineRecord.ProcessItem_ItemOpt7.HasValue && pRLineRecord.ProcessItem_ItemOpt7.HasValue)
                             {
                                 quotaReqDTOData.Item.ItemOpt7 = pRLineRecord.ProcessItem_ItemOpt7.Value;
                             }
                             if (pRLineRecord.ProcessItem_ItemOpt8.HasValue && pRLineRecord.ProcessItem_ItemOpt8.HasValue)
                             {
                                 quotaReqDTOData.Item.ItemOpt8 = pRLineRecord.ProcessItem_ItemOpt8.Value;
                             }
                             if (pRLineRecord.ProcessItem_ItemOpt9.HasValue && pRLineRecord.ProcessItem_ItemOpt9.HasValue)
                             {
                                 quotaReqDTOData.Item.ItemOpt9 = pRLineRecord.ProcessItem_ItemOpt9.Value;
                             }
                             if (pRLineRecord.ProcessItem_ItemOpt10.HasValue && pRLineRecord.ProcessItem_ItemOpt10.HasValue)
                             {
                                 quotaReqDTOData.Item.ItemOpt10 = pRLineRecord.ProcessItem_ItemOpt10.Value;
                             }
                             if (pRLineRecord.ProcessItem_ItemPotency.HasValue && pRLineRecord.ProcessItem_ItemPotency.HasValue)
                             {
                                 quotaReqDTOData.Item.ItemPotency = pRLineRecord.ProcessItem_ItemPotency.Value;
                             }
                             if (pRLineRecord.ProcessItem_ItemGrade.HasValue && pRLineRecord.ProcessItem_ItemGrade.HasValue)
                             {
                                 quotaReqDTOData.Item.ItemGrade = pRLineRecord.ProcessItem_ItemGrade.Value;
                             }
                             if (pRLineRecord.ProcessItem_ItemVersion != null)
                             {
                                 quotaReqDTOData.Item.ItemVersion = pRLineRecord.ProcessItem_ItemVersion;
                             }
                         }
                         else
                         {
                             quotaReqDTOData.Item.ItemCode = pRLineRecord.ItemInfo_ItemCode;
                             quotaReqDTOData.Item.ItemID   = pRLineRecord.ItemInfo_ItemID.Value;
                             quotaReqDTOData.Item.ItemName = pRLineRecord.ItemInfo_ItemName;
                             if (pRLineRecord.ItemInfo_ItemOpt1.HasValue && pRLineRecord.ItemInfo_ItemOpt1.HasValue)
                             {
                                 quotaReqDTOData.Item.ItemOpt1 = pRLineRecord.ItemInfo_ItemOpt1.Value;
                             }
                             if (pRLineRecord.ItemInfo_ItemOpt2.HasValue && pRLineRecord.ItemInfo_ItemOpt2.HasValue)
                             {
                                 quotaReqDTOData.Item.ItemOpt2 = pRLineRecord.ItemInfo_ItemOpt2.Value;
                             }
                             if (pRLineRecord.ItemInfo_ItemOpt3.HasValue && pRLineRecord.ItemInfo_ItemOpt3.HasValue)
                             {
                                 quotaReqDTOData.Item.ItemOpt3 = pRLineRecord.ItemInfo_ItemOpt3.Value;
                             }
                             if (pRLineRecord.ItemInfo_ItemOpt4.HasValue && pRLineRecord.ItemInfo_ItemOpt4.HasValue)
                             {
                                 quotaReqDTOData.Item.ItemOpt4 = pRLineRecord.ItemInfo_ItemOpt4.Value;
                             }
                             if (pRLineRecord.ItemInfo_ItemOpt5.HasValue && pRLineRecord.ItemInfo_ItemOpt5.HasValue)
                             {
                                 quotaReqDTOData.Item.ItemOpt5 = pRLineRecord.ItemInfo_ItemOpt5.Value;
                             }
                             if (pRLineRecord.ItemInfo_ItemOpt6.HasValue && pRLineRecord.ItemInfo_ItemOpt6.HasValue)
                             {
                                 quotaReqDTOData.Item.ItemOpt6 = pRLineRecord.ItemInfo_ItemOpt6.Value;
                             }
                             if (pRLineRecord.ItemInfo_ItemOpt7.HasValue && pRLineRecord.ItemInfo_ItemOpt7.HasValue)
                             {
                                 quotaReqDTOData.Item.ItemOpt7 = pRLineRecord.ItemInfo_ItemOpt7.Value;
                             }
                             if (pRLineRecord.ItemInfo_ItemOpt8.HasValue && pRLineRecord.ItemInfo_ItemOpt8.HasValue)
                             {
                                 quotaReqDTOData.Item.ItemOpt8 = pRLineRecord.ItemInfo_ItemOpt8.Value;
                             }
                             if (pRLineRecord.ItemInfo_ItemOpt9.HasValue && pRLineRecord.ItemInfo_ItemOpt9.HasValue)
                             {
                                 quotaReqDTOData.Item.ItemOpt9 = pRLineRecord.ItemInfo_ItemOpt9.Value;
                             }
                             if (pRLineRecord.ItemInfo_ItemOpt10.HasValue && pRLineRecord.ItemInfo_ItemOpt10.HasValue)
                             {
                                 quotaReqDTOData.Item.ItemOpt10 = pRLineRecord.ItemInfo_ItemOpt10.Value;
                             }
                             if (pRLineRecord.ItemInfo_ItemPotency.HasValue && pRLineRecord.ItemInfo_ItemPotency.HasValue)
                             {
                                 quotaReqDTOData.Item.ItemPotency = pRLineRecord.ItemInfo_ItemPotency.Value;
                             }
                             if (pRLineRecord.ItemInfo_ItemGrade.HasValue && pRLineRecord.ItemInfo_ItemGrade.HasValue)
                             {
                                 quotaReqDTOData.Item.ItemGrade = pRLineRecord.ItemInfo_ItemGrade.Value;
                             }
                             if (pRLineRecord.ItemInfo_ItemVersion != null)
                             {
                                 quotaReqDTOData.Item.ItemVersion = pRLineRecord.ItemInfo_ItemVersion;
                             }
                         }
                         quotaReqDTOData.PurType           = 3;
                         quotaReqDTOData.ReqAmount         = new DoubleQuantityData();
                         quotaReqDTOData.ReqAmount.Amount1 = pRLineRecord.ToPOQtyTU;
                         quotaReqDTOData.ReqAmount.UOM1    = new UOMInfoDTOData();
                         if (pRLineRecord.BizType == BusinessTypeEnum.PM050.Value)
                         {
                             quotaReqDTOData.ReqAmount.UOM1.UOMMain    = pRLineRecord.PM050Uom.Value;
                             quotaReqDTOData.ReqAmount.UOM1.UOMSub     = pRLineRecord.PM050BaseUom.Value;
                             quotaReqDTOData.UsageQuantityType         = Convert.ToInt32(pRLineRecord.ChargeBasis);
                             quotaReqDTOData.ItemEntityKey             = pRLineRecord.ProcessItem_ItemID.GetValueOrDefault();
                             quotaReqDTOData.PerProcessQty             = pRLineRecord.RatioPerProduct.GetValueOrDefault();
                             quotaReqDTOData.OperationQty              = new DoubleQuantityData();
                             quotaReqDTOData.OperationQty.UOM1         = new UOMInfoDTOData();
                             quotaReqDTOData.OperationQty.UOM2         = new UOMInfoDTOData();
                             quotaReqDTOData.OperationQty.Amount1      = pRLineRecord.PM050ForTOPOQtyTU.GetValueOrDefault();
                             quotaReqDTOData.OperationQty.Amount2      = pRLineRecord.PM050ForTOPOQtyTBU.GetValueOrDefault();
                             quotaReqDTOData.OperationQty.UOM1.UOMMain = pRLineRecord.PM050Uom.GetValueOrDefault();
                             quotaReqDTOData.OperationQty.UOM1.UOMSub  = pRLineRecord.PM050BaseUom.GetValueOrDefault();
                             quotaReqDTOData.OperationQty.UOM1.Rate    = pRLineRecord.TUToTBURate.GetValueOrDefault();
                             quotaReqDTOData.OperationQty.UOM2.UOMMain = pRLineRecord.PM050BaseUom.GetValueOrDefault();
                             quotaReqDTOData.OperationQty.UOM2.UOMSub  = pRLineRecord.PM050BaseUom.GetValueOrDefault();
                             quotaReqDTOData.OperationQty.UOM2.Rate    = 1m;
                         }
                         else
                         {
                             quotaReqDTOData.ReqAmount.UOM1.UOMMain = pRLineRecord.TradeUOM.Value;
                             quotaReqDTOData.ReqAmount.UOM1.UOMSub  = pRLineRecord.TradeBaseUOM.Value;
                         }
                         quotaReqDTOData.ReqAmount.Amount2   = pRLineRecord.ToPOQtyTBU;
                         quotaReqDTOData.ReqAmount.UOM1.Rate = pRLineRecord.TUToTBURate.Value;
                         quotaReqDTOData.ReqTime             = pRLineRecord.RequiredDeliveryDate.Value;
                         if (pRLineRecord.SrcDocType.HasValue && pRLineRecord.SrcDocType.GetValueOrDefault(-1) == 1)
                         {
                             quotaReqDTOData.VMIType = 0;
                         }
                         else
                         {
                             quotaReqDTOData.VMIType = 2;
                         }
                         if (pRLineRecord.ItemInfo_ItemID_ItemFormAttribute == 0)
                         {
                             if (pRLineRecord.SelectedResult_EntityID.HasValue)
                             {
                                 quotaReqDTOData.BOMID = pRLineRecord.SelectedResult_EntityID.GetValueOrDefault(-1L);
                             }
                         }
                         else if (pRLineRecord.BomID.HasValue)
                         {
                             quotaReqDTOData.BOMID = pRLineRecord.BomID.GetValueOrDefault(-1L);
                         }
                         if (pRLineRecord.Mfc.HasValue && pRLineRecord.Mfc.GetValueOrDefault(-1L) > 0L)
                         {
                             quotaReqDTOData.Mfc = pRLineRecord.Mfc.Value;
                         }
                         quotaReqDTOData.Index_1 = num;
                         if (pRLineRecord.SuggestedSupplier_Supplier.HasValue && pRLineRecord.SuggestedSupplier_Supplier.HasValue && pRLineRecord.SuggestedSupplier_Supplier.Value > 0L)
                         {
                             quotaReqDTOData.Supplier = pRLineRecord.SuggestedSupplier_Supplier.Value;
                         }
                         getSupplierQuotaSVProxy.QuotaReqList.Add(quotaReqDTOData);
                         dictionary.Add(pRLineRecord.ID, num);
                         num++;
                     }
                 }
             }
         }
     }
     List <QuotaDTOData> list = getSupplierQuotaSVProxy.Do();
     #region Add by liufei
     DataParamList dp = new DataParamList();
     ids = ids.Substring(0, ids.Length - 1);
     dp.Add(DataParamFactory.Create("PRIDS", ids, ParameterDirection.Input, DbType.String, 50000));
     dp.Add(DataParamFactory.CreateOutput("Result", DbType.String));
     DataSet ds = new DataSet();
     DataAccessor.RunSP("sp_Auctus_UI_GetSupplySource", dp, out ds);
     //按固定比例分配的料品是否存无厂商价目表、无供应商-料品交叉数据(即无MPQ)
     string result = dp["Result"].Value.ToString();
     if (result != "0")
     {
         throw new Exception(UFIDA.U9.SCM.PM.PRToPOUIModel.PRToPOUIModelRes.DataError + result);
     }
     #endregion
     Dictionary <int, List <QuotaDTOData> > dictionary2 = new Dictionary <int, List <QuotaDTOData> >();
     foreach (QuotaDTOData current in list)
     {
         if (dictionary2.ContainsKey(current.Index_1))
         {
             dictionary2[current.Index_1].Add(current);
         }
         else
         {
             List <QuotaDTOData> list2 = new List <QuotaDTOData>();
             list2.Add(current);
             dictionary2.Add(current.Index_1, list2);
         }
     }
     using (IEnumerator <IUIRecord> enumerator = selectRecordFromCache.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             PRLineRecord pRLineRecord = (PRLineRecord)enumerator.Current;
             if (!(pRLineRecord.ToPOQtyTU * pRLineRecord.TUToTBURate + pRLineRecord.ToPOQtyTBU <= 0m))
             {
                 if (!pRLineRecord.ItemInfo_ItemID_PurchaseInfo_IsNeedInquire || !(pRLineRecord.ItemInfo_ItemID_PurchaseInfo_InquireRule == InquireRuleEnum.EveryTime.Value))
                 {
                     if (text == "")
                     {
                         text = pRLineRecord.ID.ToString();
                     }
                     else
                     {
                         text = text + "," + pRLineRecord.ID.ToString();
                     }
                     if ((pRLineRecord.ItemInfo_ItemID_PurchaseInfo_PurchaseQuotaMode == 6 || pRLineRecord.BizType == BusinessTypeEnum.PM050.Value) && pRLineRecord.SuggestedSupplier_Supplier.HasValue && pRLineRecord.SuggestedSupplier_Supplier.HasValue && pRLineRecord.SuggestedSupplier_Supplier.Value > 0L)
                     {
                         TryCalcViewRecord tryCalcViewRecord = listPRToPO.CurrentModel.TryCalcView.AddNewUIRecord();
                         tryCalcViewRecord.RFQStatus            = pRLineRecord.RFQStatus;
                         tryCalcViewRecord.RFQ_SrcDocNo         = pRLineRecord.RFQInfo_SrcDocNo;
                         tryCalcViewRecord.Currency             = pRLineRecord.PR_AC;
                         tryCalcViewRecord.PRDocNo              = pRLineRecord.PR_DocNo;
                         tryCalcViewRecord.LineEntityID         = new long?(pRLineRecord.ID);
                         tryCalcViewRecord.ItemCode             = pRLineRecord.ItemInfo_ItemCode;
                         tryCalcViewRecord.ItemID               = pRLineRecord.ItemInfo_ItemID;
                         tryCalcViewRecord.ItemName             = pRLineRecord.ItemInfo_ItemName;
                         tryCalcViewRecord.ItemIsDual           = new bool?(pRLineRecord.ItemInfo_ItemID_IsDualQuantity);
                         tryCalcViewRecord.PRDocLineNo          = new long?((long)pRLineRecord.DocLineNo);
                         tryCalcViewRecord.RequiredDeliveryDate = pRLineRecord.RequiredDeliveryDate;
                         tryCalcViewRecord.Supplier             = pRLineRecord.SuggestedSupplier_Supplier;
                         tryCalcViewRecord.Supplier_Code        = pRLineRecord.SuggestedSupplier_Code;
                         tryCalcViewRecord.Supplier_Name        = pRLineRecord.SuggestedSupplier_Name;
                         tryCalcViewRecord.DemandCode           = pRLineRecord.DemandCode;
                         tryCalcViewRecord.SPECS = pRLineRecord.ItemInfo_ItemID_SPECS;
                         if (pRLineRecord.BizType == BusinessTypeEnum.PM050.Value)
                         {
                             tryCalcViewRecord.ToPOQtyTBU                    = 0m;
                             tryCalcViewRecord.TradeBaseUom                  = new long?(0L);
                             tryCalcViewRecord.TradeBaseUom_Code             = "";
                             tryCalcViewRecord.TradeBaseUom_Name             = "";
                             tryCalcViewRecord.TradeBaseUOM_Round_Precision  = new int?(0);
                             tryCalcViewRecord.TradeBaseUOM_Round_RoundType  = new int?(0);
                             tryCalcViewRecord.TradeBaseUOM_Round_RoundValue = new int?(0);
                         }
                         else
                         {
                             tryCalcViewRecord.ToPOQtyTBU                    = pRLineRecord.ToPOQtyTBU;
                             tryCalcViewRecord.TradeBaseUom                  = pRLineRecord.TradeBaseUOM;
                             tryCalcViewRecord.TradeBaseUom_Code             = pRLineRecord.TradeBaseUOM_Code;
                             tryCalcViewRecord.TradeBaseUom_Name             = pRLineRecord.TradeBaseUOM_Name;
                             tryCalcViewRecord.TradeBaseUOM_Round_Precision  = new int?(pRLineRecord.TradeBaseUOM_Round_Precision);
                             tryCalcViewRecord.TradeBaseUOM_Round_RoundType  = new int?(pRLineRecord.TradeBaseUOM_Round_RoundType);
                             tryCalcViewRecord.TradeBaseUOM_Round_RoundValue = pRLineRecord.TradeBaseUOM_Round_RoundValue;
                         }
                         tryCalcViewRecord.ToPOQtyTU                 = pRLineRecord.ToPOQtyTU;
                         tryCalcViewRecord.TradeUom                  = pRLineRecord.TradeUOM;
                         tryCalcViewRecord.TradeUom_Code             = pRLineRecord.TradeUOM_Code;
                         tryCalcViewRecord.TradeUom_Name             = pRLineRecord.TradeUOM_Name;
                         tryCalcViewRecord.TradeUOM_Round_Precision  = new int?(pRLineRecord.TradeUOM_Round_Precision);
                         tryCalcViewRecord.TradeUOM_Round_RoundType  = new int?(pRLineRecord.TradeUOM_Round_RoundType);
                         tryCalcViewRecord.TradeUOM_Round_RoundValue = pRLineRecord.TradeUOM_Round_RoundValue;
                         tryCalcViewRecord.BizType = pRLineRecord.BizType;
                         if (pRLineRecord.ItemInfo_ItemID_ItemFormAttribute == 16)
                         {
                             tryCalcViewRecord.IsMisc = new bool?(true);
                         }
                         else
                         {
                             tryCalcViewRecord.IsMisc = new bool?(false);
                         }
                     }
                     else
                     {
                         try
                         {
                             if (dictionary.ContainsKey(pRLineRecord.ID) && dictionary2.ContainsKey(dictionary[pRLineRecord.ID]))
                             {
                                 List <QuotaDTOData> list2 = dictionary2[dictionary[pRLineRecord.ID]];
                                 #region ADD By liufei
                                 //固定比例分配模式的请购单
                                 if (pRLineRecord.ItemInfo_ItemID_PurchaseInfo_PurchaseQuotaMode == 4)//固定比例分配模式
                                 {
                                     DataRow[] dr = ds.Tables[0].Select("PRLineID=" + pRLineRecord.ID);
                                     if (dr.Length > 0)
                                     {
                                         foreach (DataRow item in dr)
                                         {
                                             if (Convert.ToDecimal(item["ActualReq"]) == 0)
                                             {
                                                 list2.Remove(list2.Where(m => m.Supplier == Convert.ToInt64(item["Supplier"]) && m.SupplySource == Convert.ToInt64(item["SupplySource"])).Select(m => m).First());
                                             }
                                             else
                                             {
                                                 for (int i = 0; i < list2.Count; i++)
                                                 {
                                                     if (item["Supplier"].ToString() == list2[i].Supplier.ToString() && item["SupplySource"].ToString() == list2[i].SupplySource.ToString())
                                                     {
                                                         list2[i].PurNum.Amount1 = Convert.ToDecimal(item["ActualReq"]);
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                                 #endregion
                                 foreach (QuotaDTOData current2 in list2)
                                 {
                                     if (current2.PurNum.Amount1 == 0m && current2.PurNum.Amount2 == 0m)
                                     {
                                         throw new Exception(UFIDA.U9.SCM.PM.PRToPOUIModel.PRToPOUIModelRes.SupQtyZeroCannotGenPO);
                                     }
                                     TryCalcViewRecord tryCalcViewRecord = listPRToPO.CurrentModel.TryCalcView.AddNewUIRecord();
                                     tryCalcViewRecord.RFQStatus                 = pRLineRecord.RFQStatus;
                                     tryCalcViewRecord.RFQ_SrcDocNo              = pRLineRecord.RFQInfo_SrcDocNo;
                                     tryCalcViewRecord.Currency                  = pRLineRecord.PR_AC;
                                     tryCalcViewRecord.PRDocNo                   = pRLineRecord.PR_DocNo;
                                     tryCalcViewRecord.ItemID                    = pRLineRecord.ItemInfo_ItemID;
                                     tryCalcViewRecord.ItemCode                  = pRLineRecord.ItemInfo_ItemCode;
                                     tryCalcViewRecord.ItemName                  = pRLineRecord.ItemInfo_ItemName;
                                     tryCalcViewRecord.ItemIsDual                = new bool?(pRLineRecord.ItemInfo_ItemID_IsDualQuantity);
                                     tryCalcViewRecord.PRDocLineNo               = new long?((long)pRLineRecord.DocLineNo);
                                     tryCalcViewRecord.RequiredDeliveryDate      = pRLineRecord.RequiredDeliveryDate;
                                     tryCalcViewRecord.TradeUom                  = pRLineRecord.TradeUOM;
                                     tryCalcViewRecord.TradeUom_Code             = pRLineRecord.TradeUOM_Code;
                                     tryCalcViewRecord.TradeUom_Name             = pRLineRecord.TradeUOM_Name;
                                     tryCalcViewRecord.LineEntityID              = new long?(pRLineRecord.ID);
                                     tryCalcViewRecord.TradeUOM_Round_Precision  = new int?(pRLineRecord.TradeUOM_Round_Precision);
                                     tryCalcViewRecord.TradeUOM_Round_RoundType  = new int?(pRLineRecord.TradeUOM_Round_RoundType);
                                     tryCalcViewRecord.TradeUOM_Round_RoundValue = pRLineRecord.TradeUOM_Round_RoundValue;
                                     tryCalcViewRecord.DemandCode                = pRLineRecord.DemandCode;
                                     tryCalcViewRecord.SPECS = pRLineRecord.ItemInfo_ItemID_SPECS;
                                     if (pRLineRecord.BizType == BusinessTypeEnum.PM050.Value)
                                     {
                                         tryCalcViewRecord.ToPOQtyTBU                    = 0m;
                                         tryCalcViewRecord.TradeBaseUom                  = new long?(0L);
                                         tryCalcViewRecord.TradeBaseUom_Code             = "";
                                         tryCalcViewRecord.TradeBaseUom_Name             = "";
                                         tryCalcViewRecord.TradeBaseUOM_Round_Precision  = new int?(0);
                                         tryCalcViewRecord.TradeBaseUOM_Round_RoundType  = new int?(0);
                                         tryCalcViewRecord.TradeBaseUOM_Round_RoundValue = new int?(0);
                                         if (pRLineRecord.ItemInfo_ItemID_IsDualQuantity)
                                         {
                                             tryCalcViewRecord.ToPOQtyTU = current2.PurNum.Amount1;
                                         }
                                         else
                                         {
                                             tryCalcViewRecord.ToPOQtyTU = current2.PurNum.Amount1;
                                         }
                                     }
                                     else
                                     {
                                         tryCalcViewRecord.TradeBaseUom                  = pRLineRecord.TradeBaseUOM;
                                         tryCalcViewRecord.TradeBaseUom_Code             = pRLineRecord.TradeBaseUOM_Code;
                                         tryCalcViewRecord.TradeBaseUom_Name             = pRLineRecord.TradeBaseUOM_Name;
                                         tryCalcViewRecord.TradeBaseUOM_Round_Precision  = new int?(pRLineRecord.TradeBaseUOM_Round_Precision);
                                         tryCalcViewRecord.TradeBaseUOM_Round_RoundType  = new int?(pRLineRecord.TradeBaseUOM_Round_RoundType);
                                         tryCalcViewRecord.TradeBaseUOM_Round_RoundValue = pRLineRecord.TradeBaseUOM_Round_RoundValue;
                                         if (pRLineRecord.ItemInfo_ItemID_IsDualQuantity)
                                         {
                                             tryCalcViewRecord.ToPOQtyTBU = current2.PurNum.Amount2;
                                             tryCalcViewRecord.ToPOQtyTU  = current2.PurNum.Amount1;
                                         }
                                         else
                                         {
                                             tryCalcViewRecord.ToPOQtyTBU = 0m;
                                             tryCalcViewRecord.ToPOQtyTU  = current2.PurNum.Amount1;
                                         }
                                     }
                                     tryCalcViewRecord.BizType       = pRLineRecord.BizType;
                                     tryCalcViewRecord.Supplier      = new long?(current2.Supplier);
                                     tryCalcViewRecord.Supplier_Code = current2.SupplierCode;
                                     tryCalcViewRecord.Supplier_Name = current2.SupplierName;
                                 }
                             }
                             else
                             {
                                 TryCalcViewRecord tryCalcViewRecord = listPRToPO.CurrentModel.TryCalcView.AddNewUIRecord();
                                 tryCalcViewRecord.RFQStatus            = pRLineRecord.RFQStatus;
                                 tryCalcViewRecord.RFQ_SrcDocNo         = pRLineRecord.RFQInfo_SrcDocNo;
                                 tryCalcViewRecord.Currency             = pRLineRecord.PR_AC;
                                 tryCalcViewRecord.PRDocNo              = pRLineRecord.PR_DocNo;
                                 tryCalcViewRecord.LineEntityID         = new long?(pRLineRecord.ID);
                                 tryCalcViewRecord.ItemCode             = pRLineRecord.ItemInfo_ItemCode;
                                 tryCalcViewRecord.ItemID               = pRLineRecord.ItemInfo_ItemID;
                                 tryCalcViewRecord.ItemName             = pRLineRecord.ItemInfo_ItemName;
                                 tryCalcViewRecord.ItemIsDual           = new bool?(pRLineRecord.ItemInfo_ItemID_IsDualQuantity);
                                 tryCalcViewRecord.PRDocLineNo          = new long?((long)pRLineRecord.DocLineNo);
                                 tryCalcViewRecord.RequiredDeliveryDate = pRLineRecord.RequiredDeliveryDate;
                                 tryCalcViewRecord.DemandCode           = pRLineRecord.DemandCode;
                                 tryCalcViewRecord.SPECS = pRLineRecord.ItemInfo_ItemID_SPECS;
                                 if (pRLineRecord.BizType == BusinessTypeEnum.PM050.Value)
                                 {
                                     tryCalcViewRecord.ToPOQtyTBU                    = 0m;
                                     tryCalcViewRecord.TradeBaseUom                  = new long?(0L);
                                     tryCalcViewRecord.TradeBaseUom_Code             = "";
                                     tryCalcViewRecord.TradeBaseUom_Name             = "";
                                     tryCalcViewRecord.TradeBaseUOM_Round_Precision  = new int?(0);
                                     tryCalcViewRecord.TradeBaseUOM_Round_RoundType  = new int?(0);
                                     tryCalcViewRecord.TradeBaseUOM_Round_RoundValue = new int?(0);
                                 }
                                 else
                                 {
                                     tryCalcViewRecord.TradeBaseUom                  = pRLineRecord.TradeBaseUOM;
                                     tryCalcViewRecord.TradeBaseUom_Code             = pRLineRecord.TradeBaseUOM_Code;
                                     tryCalcViewRecord.TradeBaseUom_Name             = pRLineRecord.TradeBaseUOM_Name;
                                     tryCalcViewRecord.TradeBaseUOM_Round_Precision  = new int?(pRLineRecord.TradeBaseUOM_Round_Precision);
                                     tryCalcViewRecord.TradeBaseUOM_Round_RoundType  = new int?(pRLineRecord.TradeBaseUOM_Round_RoundType);
                                     tryCalcViewRecord.TradeBaseUOM_Round_RoundValue = pRLineRecord.TradeBaseUOM_Round_RoundValue;
                                     tryCalcViewRecord.ToPOQtyTBU = pRLineRecord.ToPOQtyTBU;
                                 }
                                 tryCalcViewRecord.ToPOQtyTU                 = pRLineRecord.ToPOQtyTU;
                                 tryCalcViewRecord.TradeUom                  = pRLineRecord.TradeUOM;
                                 tryCalcViewRecord.TradeUom_Code             = pRLineRecord.TradeUOM_Code;
                                 tryCalcViewRecord.TradeUom_Name             = pRLineRecord.TradeUOM_Name;
                                 tryCalcViewRecord.TradeUOM_Round_Precision  = new int?(pRLineRecord.TradeUOM_Round_Precision);
                                 tryCalcViewRecord.TradeUOM_Round_RoundType  = new int?(pRLineRecord.TradeUOM_Round_RoundType);
                                 tryCalcViewRecord.TradeUOM_Round_RoundValue = pRLineRecord.TradeUOM_Round_RoundValue;
                                 tryCalcViewRecord.BizType = pRLineRecord.BizType;
                                 if (pRLineRecord.ItemInfo_ItemID_ItemFormAttribute == 16)
                                 {
                                     tryCalcViewRecord.IsMisc = new bool?(true);
                                 }
                                 else
                                 {
                                     tryCalcViewRecord.IsMisc = new bool?(false);
                                 }
                                 listPRToPO.SetErrorMsg(tryCalcViewRecord, "Supplier", string.Concat(new string[]
                                 {
                                     UFIDA.U9.SCM.PM.PRToPOUIModel.PRToPOUIModelRes.LineNum1,
                                     tryCalcViewRecord.PRDocLineNo.GetValueOrDefault().ToString(),
                                     UFIDA.U9.SCM.PM.PRToPOUIModel.PRToPOUIModelRes.LineNum2,
                                     UFIDA.U9.SCM.PM.PRToPOUIModel.PRToPOUIModelRes.ItemCode,
                                     tryCalcViewRecord.ItemCode,
                                     UFIDA.U9.SCM.PM.PRToPOUIModel.PRToPOUIModelRes.SupplierBeNull
                                 }));
                             }
                         }
                         catch (Exception ex)
                         {
                             throw ex;
                         }
                     }
                 }
             }
         }
     }
     string partId       = "6b00deb4-fdb4-4a1d-9848-398735643139";
     string parentTaskId = listPRToPO.CurrentPart.TaskId.ToString();
     string width        = "810";
     string height       = "465";
     listPRToPO.CurrentState["PRToPO_SelectedPrLineIDs"] = text;
     listPRToPO.CurrentPart.ShowModalDialog(partId, UFIDA.U9.SCM.PM.PRToPOUIModel.PRToPOUIModelRes.TryCalc, width, height, parentTaskId, null, false, true);
 }
Exemplo n.º 20
0
        public void Notify(params object[] args)
        {
            if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent))
            {
                return;
            }

            //将入口参数列表中第一个参数,转成EntityEvent,并取EntityKey存入key
            UFSoft.UBF.Business.BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;
            //key的有效性判断
            if (key == null)
            {
                return;
            }
            //转成所需实体,同时判断有效性
            //UFIDA.U9.InvDoc.TransferIn.TransferIn transferIn = (UFIDA.U9.InvDoc.TransferIn.TransferIn)key.GetEntity();
            UFIDA.U9.MO.Complete.CompleteRpt entity = (UFIDA.U9.MO.Complete.CompleteRpt)key.GetEntity();
            if (entity == null)
            {
                return;
            }
            else
            {
                if (entity.Org.Code == "300")
                {
                    try
                    {
                        //校验mes是否完工足够的数量
                        string        DocNo       = entity.DocNo;
                        string        result      = "";
                        string        content     = HttpMethod.PostMethod("http://192.168.30.8:9090/MXQHService/common.asmx/DoBefore", GenPara("ExecPlan", "CompleteRpt", "GetQty", "{WorkOrder:'" + entity.MO.DocNo + "'}"));
                        MesReturnData r           = Newtonsoft.Json.JsonConvert.DeserializeObject <MesReturnData>(content);
                        int           CompleteQty = 0;
                        if (r.data.Count == 0)
                        {
                            CompleteQty = 0;
                        }
                        else
                        {
                            CompleteQty = r.data[0].CompleteQty;
                        }
                        DataParamList dp = new DataParamList();
                        dp.Add(DataParamFactory.Create("DocNo", entity.MO.DocNo, ParameterDirection.Input, DbType.String, 50));
                        dp.Add(DataParamFactory.Create("CompleteQty", CompleteQty, ParameterDirection.Input, DbType.Int32, 64));
                        dp.Add(DataParamFactory.CreateOutput("Result", DbType.String));
                        DataAccessor.RunSP("sp_Auctus_BE_MOCompleteQtyAU", dp);
                        result = dp["Result"].Value.ToString();
                        if (result != "1")
                        {
                            throw new Exception(result);
                        }

                        //流程触发到OA
                        if (entity.DocState == UFIDA.U9.MO.Enums.CompleteRptStateEnum.Approving && entity.OriginalData.DocState == UFIDA.U9.MO.Enums.CompleteRptStateEnum.Opened && entity.DocType.DescFlexField.PrivateDescSeg1 == "1")
                        {
                            Dictionary <string, object> dicResult = new Dictionary <string, object>();
                            Dictionary <string, object> dicMain   = new Dictionary <string, object>();
                            User user = User.Finder.FindByID(Context.LoginUserID);//U9用户信息
                            #region OA信息
                            BaseInfo baseInfo;
                            if (entity.DescFlexField.PrivateDescSeg3 == "是")//驳回后提交
                            {
                                baseInfo = Auctus.Common.Utils.GenerateOABaseInfo(user.Code, PubFunction.GetOAInfoByCode("10"), entity.ID.ToString(), 1, entity.DescFlexField.PrivateDescSeg2, 1, "完工报告:" + entity.DocNo);
                            }
                            else//非驳回提交
                            {
                                baseInfo = Auctus.Common.Utils.GenerateOABaseInfo(user.Code, PubFunction.GetOAInfoByCode("10"), entity.ID.ToString(), 1, "", 1, "完工报告:" + entity.DocNo);
                            }
                            #endregion
                            dicMain = GenerateMainInfo(entity, user.Code);
                            dicResult.Add("base", baseInfo);
                            dicResult.Add("main", dicMain);
                            List <Dictionary <string, object> > li = new List <Dictionary <string, object> >();
                            li.Add(dicResult);
                            string json = JsonHelper.GetJsonJS(li);
                            Utils.LogError("完工报告JSON");
                            Utils.LogError(json);
                            PubFunction pubFun   = new PubFunction();
                            string      OAFlowID = pubFun.OAService(json);
                            //更新扩展字段:OA流程ID和是否驳回
                            string sql = string.Format("update MO_CompleteRpt set DescFlexField_PrivateDescSeg3='否',DescFlexField_PrivateDescSeg2='{0}' where ID={1}", OAFlowID, entity.ID);
                            DataAccessor.RunSQL(DatabaseManager.GetCurrentConnection(), sql, null);//更新sql
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
Exemplo n.º 21
0
        public void Notify(params object[] args)
        {
            if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent))
            {
                return;
            }

            //将入口参数列表中第一个参数,转成EntityEvent,并取EntityKey存入key
            UFSoft.UBF.Business.BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;
            //key的有效性判断
            if (key == null)
            {
                return;
            }
            //转成所需实体,同时判断有效性
            UFIDA.U9.InvDoc.MiscShip.MiscShipment miscShip = (UFIDA.U9.InvDoc.MiscShip.MiscShipment)key.GetEntity();

            if (miscShip == null)
            {
                return;
            }
            else
            {
                if (miscShip.SysState == UFSoft.UBF.PL.Engine.ObjectState.Updated)
                {
                    ILogger log = LoggerManager.GetLogger(typeof(CacheManager));
                    //单据从开立状态->审核中(提交审核操作),调用OA接口,创建审批流
                    if (miscShip.OriginalData.Status == INVDocStatus.Open && miscShip.Status == INVDocStatus.Approving && miscShip.DocType.DescFlexField.PrivateDescSeg1 == "1")
                    {
                        //查询OA的流程ID
                        string  sql = string.Format(@"SELECT DescFlexField_PrivateDescSeg4 AS IsOAtoU9
                        FROM dbo.InvDoc_MiscShip WHERE ID={0}", miscShip.ID);
                        DataSet ds  = new DataSet();
                        DataAccessor.RunSQL(DatabaseManager.GetCurrentConnection(), sql, null, out ds);
                        string IsOAtoU9 = "";
                        foreach (DataRow row in ds.Tables[0].Rows)
                        {
                            IsOAtoU9 = row["IsOAtoU9"].ToString();
                        }
                        if (IsOAtoU9 == "1")//OA触发到U9的杂发单,不触发U9到OA
                        {
                            return;
                        }

                        List <MishShipDoc> list     = new List <MishShipDoc>(); //杂发单集合
                        MishShipDoc        doc      = new MishShipDoc();        //杂发单数据
                        BaseInfo           baseInfo = new BaseInfo();           //OA上下文数据

                        ValueTrans vt   = new ValueTrans();
                        User       user = User.Finder.FindByID(Context.LoginUserID);
                        vt.value     = user.Code;
                        vt.transrule = "getUseridByWorkcode";
                        #region   文基础信息
                        baseInfo.creator = vt;
                        baseInfo.fpkid   = miscShip.ID.ToString();//单据ID
                        //baseInfo.isnextflow = 0;
                        //baseInfo.requestid = "1025";
                        //baseInfo.requestlevel = 1;
                        baseInfo.isnextflow = 1;

                        baseInfo.requestname = "杂发单审批-订单号:" + miscShip.DocNo;     //审批流标题
                        baseInfo.workflowid  = PubFunction.GetMiscShipWorkFlow(); //固定值,取数逻辑看文档
                        //baseInfo.workflowid = "1025";//固定值,取数逻辑看文档
                        #endregion

                        doc.@base = baseInfo;
                        #region 表头信息
                        //表头信息
                        MishShipHeadDto main = new MishShipHeadDto();

                        Value v = new Value();
                        if (miscShip.DescFlexField.PrivateDescSeg3 != "")
                        {
                            //OA弃审后,U9重新提交流程,应该走更细OA流程接口
                            //if (miscShip.DescFlexField.PrivateDescSeg4 == "1")
                            //{
                            v.value   = miscShip.DescFlexField.PrivateDescSeg3;
                            main.gllc = v;
                            //main.requestid = miscShip.DescFlexField.PrivateDescSeg3; //requestid不为空,则为更新流程接口
                            //string sql = string.Format(@"UPDATE dbo.InvDoc_MiscShip SET DescFlexField_PrivateDescSeg4='0' WHERE ID = {0}", miscShip.ID);
                            //DataAccessor.RunSQL(DatabaseManager.GetCurrentConnection(), sql, null);
                            //}
                        }
                        //申请人
                        vt           = new ValueTrans();
                        vt.value     = user.Code;
                        vt.transrule = "getUseridByWorkcode";
                        main.sqr     = vt;
                        //申请人工号
                        vt           = new ValueTrans();
                        vt.value     = user.Code;
                        vt.transrule = "getWorkcodeByU9code";
                        main.sqrgh   = vt;
                        //申请人部门
                        vt           = new ValueTrans();
                        vt.value     = user.Code;
                        vt.transrule = "getDeptidByWorkcode";
                        main.ssbm    = vt;
                        //申请人岗位
                        vt           = new ValueTrans();
                        vt.value     = user.Code;
                        vt.transrule = "getJobidByWorkcode";
                        main.sqrgw   = vt;
                        //申请人分部
                        vt           = new ValueTrans();
                        vt.value     = user.Code;
                        vt.transrule = "getSubcomidByWorkcode";
                        main.ssgs    = vt;
                        //申请日期
                        v         = new Value();
                        v.value   = DateTime.Now.ToString("yyyy-MM-dd");
                        main.sqrq = v;
                        //流程编号lcbh
                        //单据类型
                        v         = new Value();
                        v.value   = miscShip.DocType.Code;
                        main.djlx = v;
                        //单号
                        v       = new Value();
                        v.value = miscShip.DocNo;
                        main.dh = v;
                        //存储地点
                        if (miscShip.MiscShipLs[0].Wh != null)
                        {
                            v         = new Value();
                            v.value   = miscShip.MiscShipLs[0].Wh.Name;
                            main.ccdd = v;
                        }
                        //受益存储地点
                        if (miscShip.MiscShipLs[0].BenefitWh != null)
                        {
                            v.value     = miscShip.MiscShipLs[0].BenefitWh.Name;
                            main.syccdd = v;
                        }
                        //受益人
                        if (miscShip.BenefitPsn != null)
                        {
                            v        = new Value();
                            v.value  = miscShip.BenefitPsn.Name;
                            main.syr = v;
                        }

                        //受益部门
                        if (miscShip.MiscShipLs[0].BenefitDept != null)
                        {
                            v         = new Value();
                            v.value   = miscShip.MiscShipLs[0].BenefitDept.Name;
                            main.sybm = v;
                        }

                        //记账时间jzsj
                        v         = new Value();
                        v.value   = miscShip.MiscShipAccountPeriods[0].SOBAccountPeriod.DisplayName;
                        main.jzsj = v;
                        //供应商gys
                        if (miscShip.MiscShipLs[0].SupplierInfo != null)
                        {
                            v        = new Value();
                            v.value  = miscShip.MiscShipLs[0].SupplierInfo.Name;
                            main.gys = v;
                        }
                        //客户kh
                        if (miscShip.MiscShipLs[0].CustomerInfo != null)
                        {
                            v       = new Value();
                            v.value = miscShip.MiscShipLs[0].CustomerInfo.Name;
                            main.kh = v;
                        }

                        //库管员
                        if (miscShip.WhMan != null)
                        {
                            v       = new Value();
                            v.value = miscShip.WhMan.Name;
                            //vt.transrule = "";
                            main.kgy = v;
                        }

                        //高新项目gxxm
                        v         = new Value();
                        v.value   = miscShip.DescFlexField.PrivateDescSeg1;
                        main.gxxm = v;
                        //研发项目yfxm
                        v         = new Value();
                        v.value   = miscShip.DescFlexField.PrivateDescSeg2;
                        main.yfxm = v;
                        //U9组织
                        v       = new Value();
                        v.value = miscShip.Org.ID.ToString();
                        //vt.transrule = "getUseridByWorkcode";
                        main.u9zz1 = v;
                        //关联流程gllc
                        #endregion

                        doc.main = main;

                        #region 行信息
                        //行信息
                        List <MishShipLineDto> lines = new List <MishShipLineDto>();
                        foreach (MiscShipmentL item in miscShip.MiscShipLs)
                        {
                            MishShipLineDto l = new MishShipLineDto();
                            //料号
                            v       = new Value();
                            v.value = item.ItemInfo.ItemCode;
                            l.lh    = v;
                            //品名
                            v       = new Value();
                            v.value = item.ItemInfo.ItemName;
                            l.pm    = v;
                            //存储地点
                            v       = new Value();
                            v.value = item.Wh.Name;
                            l.ccdd  = v;
                            //杂发量
                            v       = new Value();
                            v.value = item.CostUOMQty.ToString("0.00");
                            l.zfl   = v;
                            //成本cb
                            v       = new Value();
                            v.value = item.CostMny.ToString("f4");
                            l.cb    = v;
                            //批号ph
                            if (item.LotInfo != null)
                            {
                                v       = new Value();
                                v.value = item.LotInfo.LotCode;
                                l.ph    = v;
                            }
                            //生产订单号scddh
                            v       = new Value();
                            v.value = item.MoDocNo;
                            l.scddh = v;
                            //生产相关scxg
                            v = new Value();
                            if (item.IsMFG)
                            {
                                v.value = "1";
                            }
                            else
                            {
                                v.value = "0";
                            }
                            l.scxg = v;
                            //零成本
                            v = new Value();
                            if (item.IsZeroCost)
                            {
                                v.value = "1";
                            }
                            else
                            {
                                v.value = "0";
                            }
                            l.lcb = v;
                            //受益人
                            if (item.BenefitPsn != null)
                            {
                                v       = new Value();
                                v.value = item.BenefitPsn.Name;
                                //vt.transrule = "getUseridByWorkcode";
                                l.syr = v;
                            }
                            //受益部门
                            if (item.BenefitDept != null)
                            {
                                v       = new Value();
                                v.value = item.BenefitDept.Name;
                                //vt.transrule = "getDeptidByWorkcode";
                                l.sybm = v;
                            }
                            //供应商gys
                            if (item.SupplierInfo != null)
                            {
                                v       = new Value();
                                v.value = item.SupplierInfo.Name;
                                l.gys   = v;
                            }
                            //备注
                            v       = new Value();
                            v.value = item.Memo;
                            l.bz    = v;
                            lines.Add(l);
                        }
                        #endregion
                        doc.dt1 = new List <MishShipLineDto>();
                        doc.dt1 = lines;

                        //添加
                        list.Add(doc);
                        string json = "";
                        json = JsonHelper.GetJson <List <MishShipDoc> >(list);
                        log.Error("杂发单JSON数据为:" + json);
                        PubFunction pubFun = new PubFunction();
                        //调用OA接口
                        string OAFlowID = pubFun.OAService(json);
                        //更新返回的流程ID
                        string UpSQL = string.Format(@"UPDATE dbo.InvDoc_MiscShip SET DescFlexField_PrivateDescSeg3='{0}' WHERE ID = {1}", OAFlowID, miscShip.ID.ToString());
                        DataAccessor.RunSQL(DatabaseManager.GetCurrentConnection(), UpSQL, null);
                        log.Error("结束调用OA审批接口");
                    }
                    //单据从已核准状态到开立(弃审操作)
                    if (miscShip.OriginalData.Status == INVDocStatus.Approved && miscShip.Status == INVDocStatus.Open)
                    {
                        log.Error(miscShip.DocNo + "弃审了");
                        //if (miscShip.DocType.DescFlexField.PrivateDescSeg1 == "1")//继承OA流程的单据类型
                        //{
                        //    string UpSQL = string.Format(@"UPDATE dbo.InvDoc_MiscShip SET DescFlexField_PrivateDescSeg4='1' WHERE ID = {0}", miscShip.ID);
                        //    DataAccessor.RunSQL(DatabaseManager.GetCurrentConnection(), UpSQL, null);
                        //}
                        bool IsNeedCreateOA = true;
                        try
                        {
                            //300组织不允许“生产制损领料”弃审
                            if (miscShip.Org.Code == "300" && miscShip.MiscShipDocType.Name.Trim() == "生产制损领料")
                            {
                                //存储过程控制取消退料操作是否开启
                                DataParamList dpL = new DataParamList();
                                dpL.Add(DataParamFactory.Create("Type", "MiscShipBtnUnDoApprove", ParameterDirection.Input, DbType.String, 50));//禁用杂收单弃审功能
                                dpL.Add(DataParamFactory.CreateOutput("IsOpen", DbType.String));
                                DataAccessor.RunSP("sp_Auctus_BEPlugin_Control", dpL);
                                string isOpen = dpL["IsOpen"].Value.ToString();
                                if (isOpen == "1")
                                {
                                    DataParamList dp = new DataParamList();
                                    dp.Add(DataParamFactory.Create("DocNo", miscShip.DocNo, ParameterDirection.Input, DbType.String, 50));//禁用杂收单弃审功能
                                    dp.Add(DataParamFactory.CreateOutput("Result", DbType.String));
                                    DataAccessor.RunSP("sp_Auctus_BE_MiscShip", dp);
                                    string result = dp["Result"].Value.ToString();
                                    if (result != "1")//存在下游杂收单
                                    {
                                        IsNeedCreateOA = false;
                                        throw new Exception(result);
                                    }
                                    else
                                    {
                                        IsNeedCreateOA = true;
                                    }
                                }
                            }

                            if (IsNeedCreateOA)//需要发起OA弃审,调用删除OA流程接口
                            {
                                //TODO:调用OA弃审接口
                            }
                        }
                        catch (Exception ex)
                        {
                            throw new Exception(ex.Message);
                        }
                    }//end if
                    else if (miscShip.OriginalData.Status == INVDocStatus.Approving && miscShip.Status == INVDocStatus.Open)
                    {
                        log.Error(miscShip.DocNo + "从核准中变成了开立");
                    }
                }
            }
        }