Ejemplo n.º 1
0
        //public JsonResult GetOrderNumber()
        //{
        //    rtn_data rtn = new rtn_data();
        //    try
        //    {
        //        AllocationOrder.AllocationOrderRule rule = allocationOrder.UserRule(this.UserValidator.UserID);
        //        if (rule != null)
        //        {
        //            //条件
        //            string condtions = "";

        //            #region 渠道类型
        //            if (rule.ChannelType == "内网")
        //            {
        //                condtions += " and app.createdbyparentid ='28a0ba01-4f58-4097-96cb-77c2b09e8253'";
        //            }
        //            else if (rule.ChannelType == "外网")
        //            {
        //                condtions += " and app.createdbyparentid ='9b8eb0fb-31c2-4577-bea7-9e453812f863'";
        //            }
        //            #endregion

        //            #region 资产类型
        //            if (!string.IsNullOrEmpty(rule.AssetCondition))
        //            {
        //                condtions += " and vehicle.condition='" + rule.AssetCondition + "'";
        //            }
        //            #endregion

        //            #region 审核额度
        //            condtions += " and contract.amount_financed>=" + rule.LoanAmountFrom;
        //            condtions += " and contract.amount_financed<=" + rule.LoanAmountTo;
        //            #endregion

        //            #region SQL
        //            string sql = allocationOrder.GetQueryTaskSql(condtions);
        //            #endregion

        //            int filterNumber = AppUtility.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteDataTable(sql).Rows.Count;

        //            int totalNumber = allocationOrder.GetTaskTotalNumber();

        //            rtn.code = 1;
        //            rtn.data = "满足[" + filterNumber + "]/总[" + totalNumber + "]";
        //        }
        //        else
        //        {
        //            rtn.code = -1;
        //            rtn.message = "无分单规则";
        //        }
        //        return Json(rtn);
        //    }
        //    catch (Exception ex)
        //    {
        //        rtn.code = -1;
        //        rtn.message = "查询异常";
        //        return Json(rtn);
        //    }
        //}

        public JsonResult TransferUserByRG(string worlitemids, string replaceuserid)
        {
            string[] workItems = worlitemids.Split(';');
            // 转移工作项
            int successCount = 0;

            if (workItems != null)
            {
                foreach (string itemId in workItems)
                {
                    if (string.IsNullOrEmpty(itemId))
                    {
                        continue;
                    }
                    var item = this.Engine.WorkItemManager.GetWorkItem(itemId);
                    if (item.DisplayName == "东正风控评估")
                    {
                        var context = this.Engine.InstanceManager.GetInstanceContext(item.InstanceId);

                        //流程数据
                        string sql = "select app.application_number,det.amount_financed,app.allocation_available from i_application{0} app left join i_contract_detail{0} det on app.objectid = det.parentobjectid where app.objectid = '{1}'";
                        sql = string.Format(sql, context.BizObjectSchemaCode.ToLower().Replace("application", ""), context.BizObjectId);
                        DataTable dt = AppUtility.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteDataTable(sql);

                        //允许分单
                        if (dt.Rows[0]["allocation_available"] + string.Empty == "1")
                        {
                            //获取当前规则
                            AllocationOrder.AllocationOrderRule rule = allocationOrder.UserRule(replaceuserid);
                            if (rule != null)
                            {
                                allocationOrder.AddLog(LogFileName, DateTime.Now.ToString("yyyy-MM-dd"), string.Format("任务[{0}]分配给{1}[{2}]-->人工分单", itemId, rule.UserName, rule.UserCode));

                                //现有订单数量
                                int num = allocationOrder.GetProposalOrderNumber(replaceuserid);

                                //插入到分单历史表中;
                                allocationOrder.SaveToOrderHis(rule, item.InstanceId, item.ObjectID, dt.Rows[0]["application_number"] + string.Empty, dt.Rows[0]["amount_financed"] + string.Empty, context.OrgUnit, num);
                                //分单;
                                allocationOrder.SendOrder(rule, context.BizObjectSchemaCode, context.BizObjectId, item.Participant, item.ObjectID, dt.Rows[0]["amount_financed"] + string.Empty);
                            }
                        }
                    }
                    else
                    {
                        long result1 = this.Engine.WorkItemManager.Transfer(itemId, replaceuserid);
                        if (result1 == ErrorCode.SUCCESS)
                        {
                            this.Engine.LogWriter.Write(string.Format("TransferUserTransferUserByRG itemId:{0},replaceuserid:{1},by:{2}", itemId, replaceuserid, this.UserValidator.UserName + "[" + this.UserValidator.UserCode + "]"));
                            successCount++;
                        }
                    }
                }
            }

            OThinker.H3.Controllers.ActionResult result = new OThinker.H3.Controllers.ActionResult(true, "TransferUser.TransferSucess");//TODO  信息提示
            return(Json(result));
        }
    public JsonResult GetBondCount()
    {
        string UserID = this.UserValidator.UserID;

        return(this.ExecuteFunctionRun(() =>
        {
            OThinker.H3.Controllers.ActionResult result = new OThinker.H3.Controllers.ActionResult(true);
            Dictionary <string, int> Extend = new Dictionary <string, int>();
            string sql1 = @"select count(distinct Distributorcode) counts
from I_Bond";
            string sql2 = @"select count(distinct DEALER_CODE)count from IN_WFS.V_DEALER_INFO v";

            var count = this.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteScalar(sql1);
            int num1 = Convert.ToInt32(count);
            int num2 = ExecuteCountSql("Wholesale", sql2);

            //= @"select count(1) counts from I_Bond where BondState='终审中'";
            string sql3 = @"SELECT count(1)
 from i_bond A
JOIN (select Max(b.Modifiedtime)  OperationTime
             ,b.distributorcode
        from i_bond  b  
        group by b.distributorcode
      ) B ON A.Distributorcode = B.Distributorcode and B.OperationTime = A.Modifiedtime
join Ot_Instancecontext c on c.bizobjectid = A.OBJECTID 
                      join (select a.objectid workItemcode ,a.instanceid,a.starttime
                               from (select a.objectid instanceid,b.starttime,b.objectid
                               from Ot_Instancecontext a
                               join Ot_Workitem b on a.objectid = b.instanceid
                               where a.workflowcode = 'Bond' and a.state = '2' and b.PARTICIPANT = '{0}'
                               union 
                               select a.objectid instanceid,b.starttime,b.objectid
                               from Ot_Instancecontext a
                               join Ot_Workitemfinished b on a.objectid = b.instanceid
                               where a.workflowcode = 'Bond' and a.state = '4' and b.PARTICIPANT = '{0}') a
                               join ( 
                               select Max(starttime)receivetime,objectid
                               from (
                               select a.objectid,b.starttime
                               from Ot_Instancecontext a
                               join Ot_Workitem b on a.objectid = b.instanceid
                               where a.workflowcode = 'Bond' and a.state = '2' and b.PARTICIPANT = '{0}'
                               union 
                               select a.objectid,b.starttime
                               from Ot_Instancecontext a
                               join Ot_Workitemfinished b on a.objectid = b.instanceid
                               where a.workflowcode = 'Bond' and a.state = '4' and b.PARTICIPANT = '{0}')
                               group by objectid) b on a.instanceid = b.objectid and b.receivetime = a.starttime
                               
                               ) d on d.instanceid = c.objectid
WHERE 1=1 AND FinalState in('创建待审核','修改待审核')";

            var count3 = this.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteScalar(string.Format(sql3, UserID));

            int total1 = num2 - num1;
            int total2 = Convert.ToInt32(count3);


            Extend["BondCount"] = total1;
            Extend["BondFinalCount"] = total2;
            result.Extend = Extend;
            return Json(result, JsonRequestBehavior.AllowGet);
        }));
    }
    public System.Web.Mvc.JsonResult UpdateBondApproval(string param)
    {
        WorkItemServer Ws = new WorkItemServer();

        string[] paramS = param.Split(',');
        // DataTable dt = QueryBondApproval(paramS);

        //  List<BondViewModel> paramList = this.Getgriddata(dt);//this.GetgriddataEdit(dtWorkitem, param);

        // List<BondViewModel> paramList = param;
        //System.Web.Script.Serialization.JavaScriptSerializer json = new System.Web.Script.Serialization.JavaScriptSerializer();
        //json.MaxJsonLength = int.MaxValue;
        //paramList = json.Deserialize<List<BondViewModel>>(param);


        return(this.ExecuteFunctionRun(() =>
        {
            OThinker.H3.Controllers.ActionResult result = new OThinker.H3.Controllers.ActionResult(true);
            var code = this.UserValidator.UserID;
            foreach (string item in paramS)
            {
                string[] str = item.Split(';');
                if (string.IsNullOrEmpty(str[0]) || str[0] == "null")
                {
                    continue;
                }
                List <DataItemParam> paramValues = new List <DataItemParam>();
                //paramValues.Add(new DataItemParam()
                //{
                //    ItemName = "Distributorcode",
                //    ItemValue = item.Distributorcode
                //});
                //paramValues.Add(new DataItemParam()
                //{
                //    ItemName = "Distributorname",
                //    ItemValue = item.Distributorname
                //});
                paramValues.Add(new DataItemParam()
                {
                    ItemName = "BondProportion",
                    ItemValue = str[0]
                });
                paramValues.Add(new DataItemParam()
                {
                    ItemName = "OperationTime",
                    ItemValue = DateTime.Now.ToLongDateString()
                });
                paramValues.Add(new DataItemParam()
                {
                    ItemName = "FinalState",
                    ItemValue = "已生效"
                });

                paramValues.Add(new DataItemParam()
                {
                    ItemName = "BondState",
                    ItemValue = "已生效"
                });


                Ws.ForwardWorkItem(paramValues, code, "Bond", str[2], str[3]);
                string sql = @"update I_Bond
set BondState = '已失效',FinalState = '已失效'
where objectid !='{0}' and Distributorcode ='{1}'";

                sql = string.Format(sql, str[4], str[5]);

                OThinker.H3.Controllers.AppUtility.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteNonQuery(sql);
            }

            return Json(result, "text/html", JsonRequestBehavior.AllowGet);
        }, string.Empty));
    }
    public System.Web.Mvc.JsonResult UpdateBondFinalEdit(string page)
    {
        WorkItemServer Ws = new WorkItemServer();

        string[] WorkItems = page.Split(',');
        //string[] WorkItems = param;

        return(this.ExecuteFunctionRun(() =>
        {
            OThinker.H3.Controllers.ActionResult result = new OThinker.H3.Controllers.ActionResult(true);
            var code = this.UserValidator.UserCode;
            foreach (string item in WorkItems)
            {
                if (string.IsNullOrEmpty(item))
                {
                    continue;
                }

                string[] pv = item.Split(';');
                if (string.IsNullOrEmpty(pv[2].Trim()) || pv[2].Trim() == "null")
                {
                    continue;
                }
                string sql = @"update I_Bond
set BondState = '已失效',FinalState = '已失效'
where objectid ='{0}' and Distributorcode ='{1}'";

                sql = string.Format(sql, pv[3].Trim(), pv[0].Trim());

                OThinker.H3.Controllers.AppUtility.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteNonQuery(sql);

                string H3IDSql = string.Format(@"select objectid from Ot_User where APPELLATION = '{0}'  and STATE =1 ", pv[0].Trim());

                var H3ID = OThinker.H3.Controllers.AppUtility.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteScalar(H3IDSql);

                if (H3ID == null || H3ID.ToString() == "")
                {
                    sql = "select objectid from Ot_User where APPELLATION = '" + pv[0].Trim() + "'";
                    H3ID = this.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteScalar(sql);
                }

                List <DataItemParam> paramValues = new List <DataItemParam>();
                paramValues.Add(new DataItemParam()
                {
                    ItemName = "Distributorcode",
                    ItemValue = pv[0].Trim()
                });
                paramValues.Add(new DataItemParam()
                {
                    ItemName = "Distributorname",
                    ItemValue = pv[1].Trim()
                });
                paramValues.Add(new DataItemParam()
                {
                    ItemName = "BondProportion",
                    ItemValue = Convert.ToDecimal(pv[2].Trim())
                });
                paramValues.Add(new DataItemParam()
                {
                    ItemName = "OperationTime",
                    ItemValue = DateTime.Now.ToLongDateString()
                });
                paramValues.Add(new DataItemParam()
                {
                    ItemName = "BondState",
                    ItemValue = "已生效"
                });
                paramValues.Add(new DataItemParam()
                {
                    ItemName = "FinalState",
                    ItemValue = "已生效"
                });
                paramValues.Add(new DataItemParam()
                {
                    ItemName = "ISYN",
                    ItemValue = "是"
                });
                paramValues.Add(new DataItemParam()
                {
                    ItemName = "JXSH3ID",
                    ItemValue = H3ID
                });

                Ws.startWorkflow("Bond", code, true, paramValues);
            }

            return Json(result, "text/html", JsonRequestBehavior.AllowGet);
        }, string.Empty));
    }
    public System.Web.Mvc.JsonResult UpdateBondEdit(string param)
    {
        WorkItemServer Ws = new WorkItemServer();

        string[] WorkItems = param.Split(',');



        return(this.ExecuteFunctionRun(() =>
        {
            OThinker.H3.Controllers.ActionResult result = new OThinker.H3.Controllers.ActionResult(true);
            var code = this.UserValidator.UserCode;
            foreach (string item in WorkItems)
            {
                string[] pv = item.Split(';');
                if (string.IsNullOrEmpty(pv[2].Trim()) || pv[2].Trim() == "null")
                {
                    continue;
                }
                List <DataItemParam> paramValues = new List <DataItemParam>();
                paramValues.Add(new DataItemParam()
                {
                    ItemName = "Distributorcode",
                    ItemValue = pv[0].Trim()
                });
                paramValues.Add(new DataItemParam()
                {
                    ItemName = "Distributorname",
                    ItemValue = pv[1].Trim()
                });
                paramValues.Add(new DataItemParam()
                {
                    ItemName = "BondProportion",
                    ItemValue = Convert.ToDecimal(pv[2].Trim())
                });
                paramValues.Add(new DataItemParam()
                {
                    ItemName = "OperationTime",
                    ItemValue = DateTime.Now.ToLongDateString()
                });

                string sql = "select objectid from Ot_User where APPELLATION = '" + pv[0].Trim() + "' and STATE =1 ";
                var JXSH3ID = this.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteScalar(sql);
                if (JXSH3ID == null || JXSH3ID.ToString() == "")
                {
                    sql = "select objectid from Ot_User where APPELLATION = '" + pv[0].Trim() + "'";
                    JXSH3ID = this.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteScalar(sql);
                }
                paramValues.Add(new DataItemParam()
                {
                    ItemName = "JXSH3ID",
                    ItemValue = JXSH3ID
                });


                if (pv[3].Trim() == "待创建" || pv[3].Trim() == "已生效")
                {
                    paramValues.Add(new DataItemParam()
                    {
                        ItemName = "BondState",
                        ItemValue = "终审中"
                    });
                    if (pv[3].Trim() == "待创建")
                    {
                        paramValues.Add(new DataItemParam()
                        {
                            ItemName = "FinalState",
                            ItemValue = "创建待审核"
                        });
                    }
                    if (pv[3].Trim() == "已生效")
                    {
                        paramValues.Add(new DataItemParam()
                        {
                            ItemName = "FinalState",
                            ItemValue = "修改待审核"
                        });
                    }
                    Ws.startWorkflow("Bond", code, true, paramValues);
                }
            }

            return Json(result, "text/html", JsonRequestBehavior.AllowGet);
        }, string.Empty));
    }