Exemplo 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 GetOrder()
        {
            rtn_data rtn = new rtn_data();

            AllocationOrder.AllocationOrderRule rule = allocationOrder.UserRule(this.UserValidator.UserID);
            if (rule != null)
            {
                //现有订单数量
                int num = allocationOrder.GetProposalOrderNumber(this.UserValidator.UserID);
                allocationOrder.AddLog(LogFileName, DateTime.Now.ToString("yyyy-MM-dd"), this.UserValidator.UserName + "[" + this.UserValidator.UserCode + "]" + "现有订单数量:" + num);
                if (num < rule.LimitNumber)
                {
                    //条件
                    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

                    DataTable dt = AppUtility.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteDataTable(sql);
                    if (dt.Rows.Count > 0)
                    {
                        DataRow row = dt.Rows[0];
                        allocationOrder.AddLog(LogFileName, DateTime.Now.ToString("yyyy-MM-dd"), string.Format("任务[{0}]分配给{1}[{2}]", row["objectid"], rule.UserName, rule.UserCode));
                        //插入到分单历史表中;
                        allocationOrder.SaveToOrderHis(rule, row["instanceid"] + string.Empty, row["objectid"] + string.Empty, row["application_number"] + string.Empty, row["amount_financed"] + string.Empty, row["createdbyparentid"] + string.Empty, num);
                        //分单;
                        rtn = allocationOrder.SendOrder(rule, row["bizobjectschemacode"] + string.Empty, row["bizobjectid"] + string.Empty, row["participant"] + string.Empty, row["objectid"] + string.Empty, row["amount_financed"] + string.Empty);
                    }
                    else
                    {
                        rtn.code    = -1;
                        rtn.message = "暂时没有可分配的申请,请稍后再试";
                    }
                }
                else
                {
                    rtn.code    = -1;
                    rtn.message = string.Format("主动获单数量上限为{0},当前为{1}", rule.LimitNumber, num);
                }
            }
            else
            {
                rtn.code    = -1;
                rtn.message = "您没有配置分单规则,请联系管理员添加";
            }
            return(Json(rtn));
        }