Example #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.MO.MO entity = (UFIDA.U9.MO.MO.MO)key.GetEntity();
            if (entity == null)
            {
                return;
            }
            else
            {
                try
                {
                    if (entity.SysState == UFSoft.UBF.PL.Engine.ObjectState.Inserted)//更新操作
                    {
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
        }
Example #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.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);
                    }
                }
            }
        }
Example #3
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
            }
        }
        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
            {
                if (po.SubType.Value.ToString() == "-1")//标准采购
                {
                    string productLine = "";
                    productLine = po.POLines[0].ItemInfo.ItemID.DescFlexField.PrivateDescSeg28;
                    for (int i = 0; i < po.POLines.Count; i++)
                    {
                        if (productLine == "02")                                                      //当存在功放料品
                        {
                            if (po.POLines[i].ItemInfo.ItemID.DescFlexField.PrivateDescSeg28 != "02") //存在非功放
                            {
                                throw new Exception("订单中同时存在功放和非功放料品,创建失败!");
                            }
                            productLine = "02";
                        }
                        else//存在非功放料品
                        {
                            if (po.POLines[i].ItemInfo.ItemID.DescFlexField.PrivateDescSeg28 == "02")
                            {
                                throw new Exception("订单中同时存在功放和非功放料品,创建失败!");
                            }
                            productLine = "99";
                        }
                    }
                    po.DescFlexField.PrivateDescSeg1 = productLine;
                }
            }
        }
        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);
                    }
                }
            }
        }
Example #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.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
            }
        }
Example #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
            }
        }
Example #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.InvDoc.TransferIn.TransferIn transferIn = (UFIDA.U9.InvDoc.TransferIn.TransferIn)key.GetEntity();
            UFIDA.U9.PM.Rcv.Receivement entity = (UFIDA.U9.PM.Rcv.Receivement)key.GetEntity();
            if (entity == null)
            {
                return;
            }
            else
            {
                try
                {
                    if (entity.SysState == UFSoft.UBF.PL.Engine.ObjectState.Inserted)//插入操作
                    {
                        //清空复制的OA流程扩展字段字段内容
                        entity.DescFlexField.PrivateDescSeg3 = "";
                        entity.DescFlexField.PrivateDescSeg4 = "";
                        entity.DescFlexField.PrivateDescSeg5 = "";
                        entity.DescFlexField.PrivateDescSeg6 = "";
                        entity.DescFlexField.PrivateDescSeg7 = "";
                        foreach (UFIDA.U9.PM.Rcv.RcvLine item in entity.RcvLines)
                        {
                            item.DescFlexSegments.PrivateDescSeg4 = "";
                            item.DescFlexSegments.PrivateDescSeg5 = "";
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
        }
Example #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.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);
                    }
                }
            }
        }
Example #10
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);
                    }
                }
            }
        }
Example #11
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.MO.MO entity = (UFIDA.U9.MO.MO.MO)key.GetEntity();
            if (entity == null)
            {
                return;
            }
            else
            {
                try
                {
                    if (entity.SysState == UFSoft.UBF.PL.Engine.ObjectState.Updated)        //更新操作
                    {
                        if (!entity.OriginalData.Cancel.Canceled && entity.Cancel.Canceled) //作废操作:校验是否有发料信息
                        {
                            foreach (UFIDA.U9.MO.MO.MOPickList item in entity.MOPickLists)
                            {
                                if (item.IssuedQty > 0)
                                {
                                    throw new Exception("当前工单存在已发料的备料行,请退料后再作废!");
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
        }
Example #12
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.MOModify.MOModify entity = (UFIDA.U9.MO.MOModify.MOModify)key.GetEntity();
            if (entity == null)
            {
                return;
            }
            else
            {
                try
                {
                    if (entity.SysState == UFSoft.UBF.PL.Engine.ObjectState.Updated)//更新操作
                    {
                        //提交操作
                        if (entity.OriginalData.Status == MOModifyStatusEnum.Openend && entity.Status == MOModifyStatusEnum.Approving && entity.DocType.DescFlexField.PrivateDescSeg1 == "1")
                        {
                            //TODO:变更单提交到OA
                            Dictionary <string, object> dicResult = new Dictionary <string, object>();
                            //用户
                            User user = User.Finder.FindByID(Context.LoginUserID);
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
        }
Example #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
            }
        }
Example #14
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.MO.MO entity = (UFIDA.U9.MO.MO.MO)key.GetEntity();
            if (entity == null)
            {
                return;
            }
            else
            {
                try
                {
                    if (entity.SysState == UFSoft.UBF.PL.Engine.ObjectState.Updated)//更新操作
                    {
                        ILogger log = LoggerManager.GetLogger(typeof(CacheManager));
                        //提交操作
                        if (entity.OriginalData.DocState == MOStateEnum.Opened && entity.DocState == MOStateEnum.Approving && entity.DocType.DescFlexField.PrivateDescSeg1 == "1")
                        {
                            Dictionary <string, object> dicResult = new Dictionary <string, object>();
                            //获取工单相关信息
                            DataSet ds  = new DataSet();
                            string  sql = string.Format("select * from v_Cust_MOInfo where DocNo='{0}' and rn=1", entity.DocNo);
                            DataAccessor.RunSQL(DatabaseManager.GetCurrentConnection(), sql, null, out ds);
                            //表单信息
                            Dictionary <string, object> dicMain  = new Dictionary <string, object>();
                            Dictionary <string, object> dicValue = new Dictionary <string, object>();
                            User user = User.Finder.FindByID(Context.LoginUserID);//U9用户信息
                            #region OA信息
                            BaseInfo baseInfo;
                            if (entity.DescFlexField.PrivateDescSeg8 == "是")
                            {
                                baseInfo = Auctus.Common.Utils.GenerateOABaseInfo(user.Code, PubFunction.GetOAInfoByCode("06"), entity.ID.ToString(), 1, entity.DescFlexField.PrivateDescSeg7, 1, "生产订单审批-订单号:" + entity.DocNo);
                            }
                            else
                            {
                                baseInfo = Auctus.Common.Utils.GenerateOABaseInfo(user.Code, PubFunction.GetOAInfoByCode("06"), entity.ID.ToString(), 1, "", 1, "生产订单审批-订单号:" + entity.DocNo);
                                //设置OA上下文
                                if (!string.IsNullOrEmpty(entity.DescFlexField.PrivateDescSeg7))
                                {
                                    dicValue = new Dictionary <string, object>();
                                    dicValue.Add("value", entity.DescFlexField.PrivateDescSeg7);
                                    dicMain.Add("gllc", dicValue);
                                }
                            }

                            dicMain = Auctus.Common.Utils.GenerateOAUserInfo(dicMain, user.Code, DateTime.Now.ToString("yyyy-MM-dd"));

                            #endregion
                            #region 工单信息
                            //dicValue = new Dictionary<string, object>();
                            //dicValue.Add("value", entity.CreatedBy);
                            //dicMain.Add("CreateBy", dicValue);
                            dicValue = new Dictionary <string, object>();
                            dicValue.Add("value", entity.DocType.Code);
                            dicMain.Add("DocType", dicValue);
                            dicValue = new Dictionary <string, object>();
                            dicValue.Add("value", entity.DocNo);
                            dicMain.Add("DocNo", dicValue);
                            dicValue = new Dictionary <string, object>();
                            dicValue.Add("value", entity.Department.Name);
                            dicMain.Add("Dept", dicValue);
                            dicValue = new Dictionary <string, object>();
                            dicValue.Add("value", entity.ItemMaster.Code);
                            dicMain.Add("Code", dicValue);
                            dicValue = new Dictionary <string, object>();
                            dicValue.Add("value", entity.ItemMaster.Name);
                            dicMain.Add("Name", dicValue);
                            dicValue = new Dictionary <string, object>();
                            dicValue.Add("value", entity.ItemMaster.SPECS);
                            dicMain.Add("Specs", dicValue);
                            dicValue = new Dictionary <string, object>();
                            dicValue.Add("value", Convert.ToInt32(entity.ProductQty));
                            dicMain.Add("ProductQty", dicValue);
                            dicValue = new Dictionary <string, object>();
                            dicValue.Add("value", entity.StartDate.ToString("yyyy-MM-dd"));
                            dicMain.Add("StartDate", dicValue);
                            dicValue = new Dictionary <string, object>();
                            dicValue.Add("value", entity.CompleteDate.ToString("yyyy-MM-dd"));
                            dicMain.Add("CompleteDate", dicValue);
                            dicValue = new Dictionary <string, object>();
                            dicValue.Add("value", entity.SCVWh.Name);
                            dicMain.Add("Wh", dicValue);
                            dicValue = new Dictionary <string, object>();
                            dicValue.Add("value", entity.ID.ToString());
                            dicMain.Add("u9id", dicValue);
                            dicValue = new Dictionary <string, object>();
                            dicValue.Add("value", entity.Org.ID.ToString());
                            dicMain.Add("u9zz", dicValue);

                            if (ds.Tables.Count == 0)
                            {
                                throw new Exception("工单" + entity.DocNo + "信息在视图中找不到,请检查v_Cust_MOInfo视图!");
                            }
                            foreach (DataRow dr in ds.Tables[0].Rows)
                            {
                                dicValue = new Dictionary <string, object>();
                                dicValue.Add("value", dr["OriginalLineName"]);
                                dicMain.Add("Line", dicValue);
                                dicValue = new Dictionary <string, object>();
                                if (dr["SODocNo"] == DBNull.Value)
                                {
                                    dicMain.Add("DemandCode", null);
                                }
                                else
                                {
                                    dicValue.Add("value", dr["SODocNo"]);
                                    dicMain.Add("DemandCode", dicValue);
                                }

                                if (dr["SODeliveryDate"] == DBNull.Value)
                                {
                                    dicMain.Add("SODeliverDate", null);
                                }
                                else
                                {
                                    dicValue = new Dictionary <string, object>();
                                    if (string.IsNullOrEmpty(dr["SODeliveryDate"].ToString()))
                                    {
                                        dicMain.Add("SODeliverDate", null);
                                    }
                                    else
                                    {
                                        DateTime d = new DateTime();
                                        if (DateTime.TryParse(dr["SODeliveryDate"].ToString(), out d))
                                        {
                                            dicValue.Add("value", d.ToString("yyyy-MM-dd"));
                                            dicMain.Add("SODeliverDate", dicValue);
                                        }
                                        else
                                        {
                                            throw new Exception("销售交期:" + dr["SODeliveryDate"].ToString() + "不是正确的日期格式!");
                                        }
                                    }
                                }
                                dicValue = new Dictionary <string, object>();
                                if (dr["SODocNo"] == DBNull.Value)
                                {
                                    dicValue.Add("value", dr["SO"]);
                                    dicMain.Add("SODocNo", dicValue);
                                }
                                else
                                {
                                    dicValue.Add("value", dr["SODocNo"]);
                                    dicMain.Add("SODocNo", dicValue);
                                }
                                dicValue = new Dictionary <string, object>();
                                dicValue.Add("value", dr["MRPName"].ToString());
                                dicMain.Add("MRP", dicValue);
                            }
                            #endregion
                            dicResult.Add("base", baseInfo);
                            dicResult.Add("main", dicMain);
                            List <Dictionary <string, object> > li = new List <Dictionary <string, object> >();
                            li.Add(dicResult);
                            string json = "";
                            json = JsonHelper.GetJsonJS(li);
                            log.Error("工单JSON数据为:" + json);
                            PubFunction pubFun = new PubFunction();
                            //调用OA接口
                            string OAFlowID = pubFun.OAService(json);
                            //更新返回的流程ID
                            string UpSQL = "";
                            if (entity.DescFlexField.PrivateDescSeg8 == "是")
                            {
                                UpSQL = string.Format(@"UPDATE dbo.MO_MO SET DescFlexField_PrivateDescSeg7='{0}',DescFlexField_PrivateDescSeg8='' WHERE ID = {1}", OAFlowID, entity.ID.ToString());
                            }
                            else
                            {
                                UpSQL = string.Format(@"UPDATE dbo.MO_MO SET DescFlexField_PrivateDescSeg7='{0}' WHERE ID = {1}", OAFlowID, entity.ID.ToString());
                            }
                            DataAccessor.RunSQL(DatabaseManager.GetCurrentConnection(), UpSQL, null);
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
        }
Example #15
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.SM.Ship.Ship entity = (UFIDA.U9.SM.Ship.Ship)key.GetEntity();
            if (entity == null)
            {
                return;
            }
            else
            {
                try
                {
                    if (entity.SysState == UFSoft.UBF.PL.Engine.ObjectState.Updated)                                                                                                //更新操作
                    {
                        if (entity.OriginalData.Status == ShipStateEnum.Creates && entity.Status == ShipStateEnum.Approving && entity.DocType.DescFlexField.PrivateDescSeg1 == "1") //提交操作
                        {
                            ILogger log = LoggerManager.GetLogger(typeof(CacheManager));
                            //传送给OA的Json对象
                            Dictionary <string, object> dicResult = new Dictionary <string, object>();
                            //U9用户信息
                            User user = User.Finder.FindByID(Context.LoginUserID);
                            //表单信息
                            Dictionary <string, object>         dicMain  = new Dictionary <string, object>();
                            List <Dictionary <string, object> > liDt     = new List <Dictionary <string, object> >();
                            Dictionary <string, object>         dicValue = new Dictionary <string, object>();
                            #region OA信息
                            BaseInfo baseInfo;
                            if (entity.DescFlexField.PrivateDescSeg7 == "是")
                            {
                                baseInfo = Auctus.Common.Utils.GenerateOABaseInfo(user.Code, PubFunction.GetOAInfoByCode("12"), entity.ID.ToString(), 1, entity.DescFlexField.PrivateDescSeg8, 1, "出货单:" + entity.DocNo);
                            }
                            else
                            {
                                baseInfo = Auctus.Common.Utils.GenerateOABaseInfo(user.Code, PubFunction.GetOAInfoByCode("12"), entity.ID.ToString(), 1, "", 1, "出货单:" + entity.DocNo);
                                //设置OA上下文
                                if (!string.IsNullOrEmpty(entity.DescFlexField.PrivateDescSeg7))
                                {
                                    dicValue = new Dictionary <string, object>();
                                    dicValue.Add("value", entity.DescFlexField.PrivateDescSeg7);
                                    dicMain.Add("gllc", dicValue);
                                }
                            }

                            dicMain = Auctus.Common.Utils.GenerateOAUserInfo(dicMain, user.Code, DateTime.Now.ToString("yyyy-MM-dd"));

                            #endregion
                            #region 表单信息
                            dicValue.Add("value", entity.DocNo);
                            dicMain.Add("dh", dicValue);
                            dicValue = new Dictionary <string, object>();
                            dicValue.Add("value", entity.Org.ID);
                            dicMain.Add("u9zz", dicValue);
                            dicValue = new Dictionary <string, object>();
                            dicValue.Add("value", entity.DocType.Code);
                            dicMain.Add("djlx", dicValue);
                            dicValue = new Dictionary <string, object>();
                            dicValue.Add("value", entity.OrderBy.Name);
                            dicMain.Add("kh", dicValue);
                            dicValue = new Dictionary <string, object>();
                            dicValue.Add("value", entity.TC.Name);
                            dicMain.Add("bz", dicValue);
                            dicValue = new Dictionary <string, object>();
                            dicValue.Add("value", entity.DescFlexField.PubDescSeg3);
                            dicMain.Add("khddh", dicValue);
                            dicValue = new Dictionary <string, object>();
                            dicValue.Add("value", entity.IsPriceIncludeTax ? "1" : "0");
                            dicMain.Add("jghs", dicValue);
                            dicValue = new Dictionary <string, object>();
                            dicValue.Add("value", entity.DescFlexField.PrivateDescSeg1);
                            dicMain.Add("cph", dicValue);
                            dicValue = new Dictionary <string, object>();
                            dicValue.Add("value", entity.ShipConfirmDate.ToString("yyyy-MM-dd"));
                            dicMain.Add("chqrr", dicValue);
                            dicValue = new Dictionary <string, object>();
                            dicValue.Add("value", entity.DescFlexField.PrivateDescSeg2);
                            dicMain.Add("sj", dicValue);
                            dicValue = new Dictionary <string, object>();
                            dicValue.Add("value", entity.DescFlexField.PrivateDescSeg4);
                            dicMain.Add("xh", dicValue);
                            dicValue = new Dictionary <string, object>();
                            dicValue.Add("value", entity.DescFlexField.PrivateDescSeg3);
                            dicMain.Add("sjdh", dicValue);
                            dicValue = new Dictionary <string, object>();
                            dicValue.Add("value", entity.DescFlexField.PrivateDescSeg5);
                            dicMain.Add("kddh", dicValue);
                            dicValue = new Dictionary <string, object>();
                            dicValue.Add("value", entity.ID);
                            dicMain.Add("fpkid", dicValue);

                            foreach (ShipLine item in entity.ShipLines)
                            {
                                Dictionary <string, object> dicDt = new Dictionary <string, object>();

                                dicValue = new Dictionary <string, object>();
                                dicValue.Add("value", item.ID);
                                dicDt.Add("xid", dicValue);
                                dicValue = new Dictionary <string, object>();
                                dicValue.Add("value", item.DonationType.Value + 1);
                                dicDt.Add("mflx", dicValue);
                                dicValue = new Dictionary <string, object>();
                                dicValue.Add("value", item.DocLineNo);
                                dicDt.Add("xh", dicValue);
                                dicValue = new Dictionary <string, object>();
                                dicValue.Add("value", item.ItemInfo.ItemID.ID);
                                dicDt.Add("lpid", dicValue);
                                dicValue = new Dictionary <string, object>();
                                dicValue.Add("value", item.ItemInfo.ItemID.Code);
                                dicDt.Add("lh", dicValue);
                                dicValue = new Dictionary <string, object>();
                                dicValue.Add("value", item.ItemInfo.ItemID.Name);
                                dicDt.Add("pm", dicValue);
                                dicValue = new Dictionary <string, object>();
                                dicValue.Add("value", item.ItemInfo.ItemID.SPECS);
                                dicDt.Add("gg", dicValue);
                                dicValue = new Dictionary <string, object>();
                                dicValue.Add("value", Convert.ToInt32(item.QtyPriceAmount));
                                dicDt.Add("jhcsl", dicValue);
                                dicValue = new Dictionary <string, object>();
                                dicValue.Add("value", Convert.ToInt32(item.QtyPriceAmount));
                                dicDt.Add("sl", dicValue);
                                if (item.LotInfo != null)
                                {
                                    if (item.LotInfo.LotMaster != null)
                                    {
                                        dicValue = new Dictionary <string, object>();
                                        dicValue.Add("value", item.LotInfo.LotMaster.ID);
                                        dicDt.Add("phid", dicValue);
                                    }
                                    dicValue = new Dictionary <string, object>();
                                    dicValue.Add("value", item.LotInfo.LotCode);
                                    dicDt.Add("ph", dicValue);
                                }
                                dicValue = new Dictionary <string, object>();
                                dicValue.Add("value", item.DescFlexField.PubDescSeg3);
                                dicDt.Add("khddh", dicValue);
                                dicValue = new Dictionary <string, object>();
                                dicValue.Add("value", item.CustomerItemCode);
                                dicDt.Add("khlh", dicValue);
                                dicValue = new Dictionary <string, object>();
                                dicValue.Add("value", item.DescFlexField.PubDescSeg2);
                                dicDt.Add("khwlbm", dicValue);
                                dicValue = new Dictionary <string, object>();
                                dicValue.Add("value", item.FinallyPriceTC);
                                dicDt.Add("zzj", dicValue);
                                dicValue = new Dictionary <string, object>();
                                dicValue.Add("value", item.TotalMoneyTC);
                                dicDt.Add("je", dicValue);
                                dicValue = new Dictionary <string, object>();
                                dicValue.Add("value", item.TaxRate);
                                dicDt.Add("sli", dicValue);
                                dicValue = new Dictionary <string, object>();
                                dicValue.Add("value", item.SrcDocNo);
                                dicDt.Add("xsddh", dicValue);
                                if (item.WH != null)
                                {
                                    dicValue = new Dictionary <string, object>();
                                    dicValue.Add("value", item.WH.ID);
                                    dicDt.Add("whid", dicValue);
                                    dicValue = new Dictionary <string, object>();
                                    bool IsExistsLotID = false;
                                    if (item.LotInfo != null)
                                    {
                                        if (item.LotInfo.LotMaster != null)
                                        {
                                            IsExistsLotID = true;
                                        }
                                    }
                                    //构建存储地点、料品ID、批号组合的唯一索引
                                    string uid = item.WH.ID.ToString() + item.ItemInfo.ItemID.ID.ToString();
                                    if (IsExistsLotID)
                                    {
                                        uid += item.LotInfo.LotMaster.ID.ToString();
                                    }
                                    else
                                    {
                                        uid += "0";
                                    }

                                    dicValue.Add("value", uid);
                                    dicDt.Add("ccdd", dicValue);
                                }
                                liDt.Add(dicDt);
                            }
                            #endregion

                            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 = "";
                            json = JsonHelper.GetJsonJS(li);
                            log.Error("出货单JSON数据为:" + json);
                            PubFunction pubFun = new PubFunction();
                            //调用OA接口
                            string OAFlowID = pubFun.OAService(json);
                            //更新返回的流程ID
                            string UpSQL = "";
                            if (entity.DescFlexField.PrivateDescSeg7 == "是")
                            {
                                UpSQL = string.Format(@"UPDATE dbo.SM_Ship SET DescFlexField_PrivateDescSeg8='{0}',DescFlexField_PrivateDescSeg7='' WHERE ID = {1}", OAFlowID, entity.ID.ToString());
                            }
                            else
                            {
                                UpSQL = string.Format(@"UPDATE dbo.SM_Ship SET DescFlexField_PrivateDescSeg8='{0}' WHERE ID = {1}", OAFlowID, entity.ID.ToString());
                            }
                            DataAccessor.RunSQL(DatabaseManager.GetCurrentConnection(), UpSQL, null);
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
        }
Example #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);
                    }
                }
            }
        }
Example #17
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);
                    }
                }
            }
        }
Example #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.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 + "从核准中变成了开立");
                    }
                }
            }
        }
Example #19
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
            }
        }