コード例 #1
0
        public void ProcessRequest(HttpContext context)
        {
            //判断客户端请求是否为post方法
            if (context.Request.HttpMethod.ToUpper() != "POST")
            {
                context.Response.Write("{\"errmsg\":\"请求方式不允许,请使用POST方式(DD0001)\",\"errcode\":1}");
                return;
            }

            try
            {
                string signUrl = ToolsClass.GetConfig("signUrl"); context.Response.ContentType = "text/plain";
                //数据库链接
                connectionString = ToolsClass.GetConfig("DataOnLine");
                //sqlServer
                da = new DbHelper.SqlHelper("SqlServer", connectionString);

                //获取请求json
                using (var reader = new StreamReader(context.Request.InputStream, Encoding.UTF8))
                {
                    CsJson = reader.ReadToEnd();
                }

                if (CsJson == "")
                {
                    context.Response.Write("{\"errmsg\":\"报文格式错误(DD0003)\",\"errcode\":1}");
                    return;
                }
                CsJson = Regex.Replace(CsJson, @"[\n\r]", "").Replace(@"\n", ",").Replace("'", "‘").Replace("\t", ":").Replace("\r", ",").Replace("\n", ",");
                //json转Hashtable
                Object    jgobj      = ToolsClass.DeserializeObject(CsJson);
                Hashtable returnhash = jgobj as Hashtable;
                if (returnhash == null)
                {
                    context.Response.Write("{\"errmsg\":\"报文格式错误(DD0003)\",\"errcode\":1}");
                    return;
                }

                string path  = context.Request.Path.Replace("Approval/GetBillName.ashx", "billname");
                string path1 = context.Request.Path.Replace("Approval/GetBillName.ashx", "getbillclassnode");
                //验证请求sign
                string sign  = ToolsClass.md5(signUrl + path + "Romens1/DingDing2" + path, 32);
                string sign1 = ToolsClass.md5(signUrl + path1 + "Romens1/DingDing2" + path1, 32);
                ToolsClass.TxtLog("生成的sign", "生成的" + sign + "传入的sign" + returnhash["Sign"].ToString() + "\r\n 后台字符串:" + signUrl + path + "Romens1/DingDing2" + path);
                if (sign != returnhash["Sign"].ToString() && sign1 != returnhash["Sign"].ToString())
                {
                    context.Response.Write("{\"errmsg\":\"认证信息Sign不存在或者不正确!\",\"errcode\":1}");
                    return;
                }

                if (returnhash.Contains("SearchAall"))
                {
                    SearchAall = returnhash["SearchAall"].ToString();
                    if (SearchAall == "")
                    {
                        context.Response.Write("{\"errmsg\":\"SearchAall不允许为空(DD2001)\",\"errcode\":1}");
                        return;
                    }
                }

                //#微应用ID:agentId #企业ID:corpId #应用的唯一标识:appKey #应用的密钥:appSecret
                AppWyy    = ToolsClass.GetConfig("AppWyy");
                ScList    = AppWyy.Split('$');
                agentId   = ScList[0].ToString();
                corpId    = ScList[1].ToString();
                appKey    = ScList[2].ToString();
                appSecret = ScList[3].ToString();
                isWrite   = ToolsClass.GetConfig("isWrite");
                ddUrl     = ToolsClass.GetConfig("ddUrl");

                if (isWrite == "1")
                {
                    ToolsClass.TxtLog("获取审批类型日志", "\r\n获取审批类型信息入参:" + CsJson.ToString() + "\r\n");
                }

                //获取access_token
                url    = "https://oapi.dingtalk.com/gettoken?appkey=" + appKey + "&appsecret=" + appSecret;
                FhJson = ToolsClass.ApiFun("GET", url, "");

                TokenClass tokenClass = new TokenClass();
                tokenClass   = (TokenClass)JsonConvert.DeserializeObject(FhJson, typeof(TokenClass));
                access_token = tokenClass.access_token;
                errcode      = tokenClass.errcode;
                if (errcode != 0)
                {
                    context.Response.Write("{\"errmsg\":\"获取ACCESS_TOKEN报错(DD0004)\",\"errcode\":1}");
                    return;
                }
                //获取流程类型
                if (SearchAall == "1")
                {
                    sql = "select BillClassid,BillName,BillLogoUrl,BillUrl,VisibleRange from BillClass";
                    obj = da.GetDataTable(sql);
                    dt  = obj as DataTable;
                    rJson.Append("{\"errmsg\":\"ok\",\"errcode\":0,\"count\":").Append(dt.Rows.Count).Append(",\"data\":[");
                    if (dt.Rows.Count > 0)
                    {
                        for (int x = 0; x < dt.Rows.Count; x++)
                        {
                            if (x > 0)
                            {
                                rJson.Append(",");
                            }
                            rJson.Append("{");
                            for (int y = 0; y < dt.Columns.Count; y++)
                            {
                                if (y > 0)
                                {
                                    rJson.Append(",");
                                }
                                rJson.Append("\"").Append(dt.Columns[y].ColumnName).Append("\":\"").Append(dt.Rows[x][dt.Columns[y].ColumnName].ToString()).Append("\"");
                            }
                            rJson.Append("}");
                        }
                    }
                    rJson.Append("]}");
                }

                //获取现在已保存的流程信息节点
                if (SearchAall == "2")
                {
                    ClassType = returnhash["ClassType"].ToString();
                    if (ClassType == "")
                    {
                        context.Response.Write("{\"errmsg\":\"ClassType不允许为空(DD2001)\",\"errcode\":1}");
                        return;
                    }
                    sql = "";
                    sql = $"select ClassRuCan from BillClass where BillClassid ='{ClassType}' ";
                    obj = da.GetValue(sql).ToString();
                    rJson.Append(obj);
                }
                context.Response.Write(rJson.Replace(" ", ""));
                if (isWrite == "1")
                {
                    ToolsClass.TxtLog("获取审批类型日志", "\r\n获取审批类型信息出参:" + rJson.ToString() + "\r\n");
                }
                return;
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"errmsg\":\"" + ex.Message + "\",\"errcode\":1}");
                return;
            }
        }
コード例 #2
0
        private StringBuilder FhJson = new StringBuilder();//返回JSON

        public void ProcessRequest(HttpContext context)
        {
            //判断客户端请求是否为post方法
            if (context.Request.HttpMethod.ToUpper() != "POST")
            {
                context.Response.Write(JsonConvert.SerializeObject(new ApprovalOverViewModel {
                    errcode = "1", errmsg = "请求方式不允许,请使用POST方式", Detail = null
                }));
                return;
            }
            string signUrl = ToolsClass.GetConfig("signUrl"); context.Response.ContentType = "text/plain";

            //数据库链接
            connectionString = ToolsClass.GetConfig("DataOnLine");
            //sqlServer
            da = new DbHelper.SqlHelper("SqlServer", connectionString);

            isWrite = ToolsClass.GetConfig("isWrite");

            //获取请求json
            using (var reader = new StreamReader(context.Request.InputStream, Encoding.UTF8))
            {
                CsJson = reader.ReadToEnd();
            }

            CsJson = Regex.Replace(CsJson, @"[\n\r]", "").Replace(@"\n", ",").Replace("'", "‘").Replace("\t", ":").Replace("\r", ",").Replace("\n", ",");
            //json转Hashtable
            Object    jgobj      = ToolsClass.DeserializeObject(CsJson);
            Hashtable returnhash = jgobj as Hashtable;

            if (returnhash == null)
            {
                ToolsClass.TxtLog("查询审批信息日志", $"\r\n入参{ CsJson}\r\n");
                context.Response.Write(JsonConvert.SerializeObject(new ApprovalOverViewModel {
                    errcode = "1", errmsg = "报文格式错误(DD0003)", Detail = null
                }));
                return;
            }
            string path = context.Request.Path.Replace("Travel/SelApproval.ashx", "selapproval");
            //验证请求sign
            string sign = ToolsClass.md5(signUrl + path + "Romens1/DingDing2" + path, 32);

            ToolsClass.TxtLog("生成的sign", "生成的" + sign + "传入的sign" + returnhash["Sign"].ToString() + "\r\n 后台字符串:" + signUrl + path + "Romens1/DingDing2" + path);
            if (sign != returnhash["Sign"].ToString())
            {
                context.Response.Write(JsonConvert.SerializeObject(new ApprovalOverViewModel {
                    errcode = "1", errmsg = "认证信息Sign不存在或者不正确", Detail = null
                }));
                return;
            }

            WTypeId      = returnhash["WTypeId"].ToString();
            SpTypeId     = returnhash["SpTypeId"].ToString();
            selValue     = returnhash["Value"].ToString().Trim();
            DDOperatorId = returnhash["DDOperatorId"].ToString();
            if (isWrite == "1")
            {
                ToolsClass.TxtLog("查询审批信息日志", $"\r\n入参:{CsJson}\r\n");
            }

            #region 查询审批信息

            string result = string.Empty;
            try
            {
                sql = "select selectsql from  dataquerydefine where dataquerytype='20190605DD_SelApproval'";
                obj = da.GetValue(sql);
                if (obj == null)
                {
                    context.Response.Write(JsonConvert.SerializeObject(new ApprovalOverViewModel {
                        errcode = "0", errmsg = "数据源表中没有进行配置", Detail = null
                    }));
                    return;
                }
                sql = obj.ToString();

                #region 查询SQL语句

                //根据selValue判断是否去哪查询

                if (WTypeId == "1")//我审批的
                {
                    //待审批的
                    if (SpTypeId == "0")
                    {
                        sql = $"select Top 80 * from  (select a.BillNo BillNo,a.IsAccount, b.BillCount,b.FeeAmount,isnull(a.IsSp, 0) IsSp,C.employeename + '提交的雨诺差旅费审批' + (case when isnull(a.IsSp,0)= 1 then '[已同意]' when isnull(a.IsSp,0)= 2 then '[已驳回]' else '' end ) Title,12 FType, BillDate,a.Notes,a.DDOperatorId,a.SelAuditingGuid,a.CopyPerson,'' CustName,A.AuditingIdea ,a.IsInsteadApply,isnull(a.InsteadOperatorGuid,'') InsteadOperatorGuid,a.HangState from  ExpeTrav a left join(SELECT BILLNO, SUM(TOTALAMOUNT) FeeAmount, sum(TranCount)+sum(AccoCount) + sum(CityTrafCount) BillCount FROM EXPETRAVDETAIL GROUP BY BILLNO) b ON A.BILLNO = b.BILLNO left join FlowEmployee c on a.InsteadOperatorGuid = c.ddid union select a.BillNo BillNo, a.IsAccount,a.BillCount,a.FeeAmount,isnull(a.IsSp, 0) IsSp,B.employeename + '提交的雨诺' + (case when a.FeeType = '01' then '交通费' when a.FeeType = '02' then '通讯费' when a.FeeType = '03' then '车辆费' when a.FeeType = '04' then '房租费' when a.FeeType = '05' then '水费' when a.FeeType = '06' then '电费'  when a.FeeType = '07' then '其他费用' end)+'审批' + (case when isnull(a.IsSp,0)= 1 then '[已同意]' when isnull(a.IsSp,0)= 2 then '[已驳回]' else '' end ) Title,A.FeeType FType,  BillDate,a.Notes,a.DDOperatorId,a.SelAuditingGuid,a.CopyPersonID CopyPerson,'' CustName,A.AuditingIdea,a.IsInsteadApply,isnull(a.InsteadOperatorGuid,'') InsteadOperatorGuid,a.HangState from EXPEOTHER a left join FlowEmployee b on a.InsteadOperatorGuid = b.ddid union select a.BillNo BillNo,a.IsAccount, a.BillCount,a.FeeAmount,isnull(a.IsSp, 0) IsSp,B.employeename + '提交的雨诺招待费审批' + (case when isnull(a.IsSp,0)= 1 then '[已同意]' when isnull(a.IsSp,0)= 2 then '[已驳回]' else '' end ) Title,'00' FType, BillDate,a.Notes,a.DDOperatorId,a.SelAuditingGuid,a.CopyPersonID CopyPerson, c.CustName,A.AuditingIdea,a.IsInsteadApply,isnull(a.InsteadOperatorGuid,'') InsteadOperatorGuid,a.HangState from EXPEENTEMENT a left join FlowEmployee b on a.InsteadOperatorGuid = b.ddid left join Customer c on a.CustCode = c.CustCode) t where BillNo in (select BillNo from ApprovalComments where ApprovalID = (select distinct EmployeeCode from FlowEmployee where ddid = '{DDOperatorId}') and persontype = 2 and ApprovalStatus = '0' and BillNo<> '')  and (Title like '%{selValue}%' or BillNo like '%{selValue}%') and issp = '0' and isnull(HangState,'0')='0'   order by BillDate asc";
                    }

                    //已审批的
                    if (SpTypeId == "1")
                    {
                        sql = $"select Top 80 * from(select a.BillNo,0 IsAccount, 0 BillCount, 0 FeeAmount, isnull(a.IsAuditing, 0) IsSp, A.OperatorName + '提交的出差申请' + (case when isnull(a.IsAuditing, 0) = 1 then '[已同意]' when isnull(a.IsAuditing, 0) = 2 then '[已驳回]' else '' end ) Title,11 FType, BillDate,a.TravelReason Notes, a.DDOperatorId,a.SelAuditingGuid,a.CopyPerson,'' CustName,A.AuditingIdea,'' IsInsteadApply,'' InsteadOperatorGuid from TravelReq A union select a.BillNo BillNo,a.IsAccount, b.BillCount,b.FeeAmount,isnull(a.IsSp, 0) IsSp,C.employeename + '提交的雨诺差旅费审批' + (case when isnull(a.IsSp,0)= 1 then '[已同意]' when isnull(a.IsSp,0)= 2 then '[已驳回]' else '' end ) Title,12 FType, BillDate,a.Notes,a.DDOperatorId,a.SelAuditingGuid,a.CopyPerson,'' CustName,A.AuditingIdea,a.IsInsteadApply,isnull(a.InsteadOperatorGuid,'') InsteadOperatorGuid from  ExpeTrav a left join(SELECT BILLNO, SUM(TOTALAMOUNT) FeeAmount, sum(TranCount)+sum(AccoCount) + sum(CityTrafCount) BillCount FROM EXPETRAVDETAIL GROUP BY BILLNO) b ON A.BILLNO = b.BILLNO left join FlowEmployee c on a.InsteadOperatorGuid = c.ddid union select a.BillNo BillNo, a.IsAccount,a.BillCount,a.FeeAmount,isnull(a.IsSp, 0) IsSp,B.employeename + '提交的雨诺' + (case when a.FeeType = '01' then '交通费' when a.FeeType = '02' then '通讯费' when a.FeeType = '03' then '车辆费' when a.FeeType = '04' then '房租费' when a.FeeType = '05' then '水费' when a.FeeType = '06' then '电费' when a.FeeType = '07' then '其他费用' end)+'审批' + (case when isnull(a.IsSp,0)= 1 then '[已同意]' when isnull(a.IsSp,0)= 2 then '[已驳回]' else '' end ) Title,A.FeeType FType, BillDate,a.Notes,a.DDOperatorId,a.SelAuditingGuid,a.CopyPersonID CopyPerson,'' CustName,A.AuditingIdea,a.IsInsteadApply,isnull(a.InsteadOperatorGuid,'') InsteadOperatorGuid from EXPEOTHER a left join FlowEmployee b on a.InsteadOperatorGuid = b.ddid union select a.BillNo BillNo,a.IsAccount, a.BillCount,a.FeeAmount,isnull(a.IsSp, 0) IsSp,B.employeename + '提交的雨诺招待费审批' + (case when isnull(a.IsSp,0)= 1 then '[已同意]' when isnull(a.IsSp,0)= 2 then '[已驳回]' else '' end ) Title,'00' FType, BillDate,a.Notes,a.DDOperatorId,a.SelAuditingGuid,a.CopyPersonID CopyPerson, c.CustName,A.AuditingIdea,a.IsInsteadApply,isnull(a.InsteadOperatorGuid,'') InsteadOperatorGuid from EXPEENTEMENT a left join FlowEmployee b on a.InsteadOperatorGuid = b.ddid left join Customer c on a.CustCode = c.CustCode) t where    BillNo in (select BillNo from ApprovalComments where ApprovalID = (select distinct EmployeeCode from FlowEmployee where ddid = '{DDOperatorId}') and persontype = 2 and ApprovalStatus in (1, 2) and BillNo<> '')  and (Title like '%{selValue}%' or BillNo like '%{selValue}%') order by BillDate desc";
                    }

                    //取一条待审批的
                    if (SpTypeId == "2")
                    {
                        sql = $"select Top 1 * from (select a.BillNo BillNo,a.IsAccount,  b.BillCount,b.FeeAmount,isnull(a.IsSp, 0) IsSp,C.employeename + '提交的雨诺差旅费审批' + (case when isnull(a.IsSp,0)= 1 then '[已同意]' when isnull(a.IsSp,0)= 2 then '[已驳回]' else '' end ) Title,12 FType, BillDate,a.Notes,a.DDOperatorId,a.SelAuditingGuid,a.CopyPerson,'' CustName,A.AuditingIdea ,a.IsInsteadApply,isnull(a.InsteadOperatorGuid,'') InsteadOperatorGuid,a.HangState,a.HangDDIDs from  ExpeTrav a left join(SELECT BILLNO, SUM(TOTALAMOUNT) FeeAmount, sum(TranCount)+sum(AccoCount) + sum(CityTrafCount) BillCount FROM EXPETRAVDETAIL GROUP BY BILLNO) b ON A.BILLNO = b.BILLNO left join FlowEmployee c on a.InsteadOperatorGuid = c.ddid union select a.BillNo BillNo, a.IsAccount, a.BillCount,a.FeeAmount,isnull(a.IsSp, 0) IsSp,B.employeename + '提交的雨诺' + (case when a.FeeType = '01' then '交通费' when a.FeeType = '02' then '通讯费' when a.FeeType = '03' then '车辆费' when a.FeeType = '04' then '房租费' when a.FeeType = '05' then '水费' when a.FeeType = '06' then '电费' when a.FeeType = '07' then '其他费用' end)+'审批' + (case when isnull(a.IsSp,0)= 1 then '[已同意]' when isnull(a.IsSp,0)= 2 then '[已驳回]' else '' end ) Title,A.FeeType FType,  BillDate,a.Notes,a.DDOperatorId,a.SelAuditingGuid,a.CopyPersonID CopyPerson,'' CustName,A.AuditingIdea,a.IsInsteadApply,isnull(a.InsteadOperatorGuid,'') InsteadOperatorGuid,a.HangState,a.HangDDIDs from EXPEOTHER a left join FlowEmployee b on a.InsteadOperatorGuid = b.ddid union select a.BillNo BillNo,a.IsAccount,  a.BillCount,a.FeeAmount,isnull(a.IsSp, 0) IsSp,B.employeename + '提交的雨诺招待费审批' + (case when isnull(a.IsSp,0)= 1 then '[已同意]' when isnull(a.IsSp,0)= 2 then '[已驳回]' else '' end ) Title,'00' FType, BillDate,a.Notes,a.DDOperatorId,a.SelAuditingGuid,a.CopyPersonID CopyPerson, c.CustName,A.AuditingIdea,a.IsInsteadApply,isnull(a.InsteadOperatorGuid,'') InsteadOperatorGuid,a.HangState,a.HangDDIDs from EXPEENTEMENT a left join FlowEmployee b on a.InsteadOperatorGuid = b.ddid left join Customer c on a.CustCode = c.CustCode) t where BillNo in (select BillNo from ApprovalComments where ApprovalID = (select distinct EmployeeCode from FlowEmployee where ddid = '{DDOperatorId}') and persontype = 2 and ApprovalStatus = '0' and BillNo<> '')  and (Title like '%{selValue}%' or BillNo like '%{selValue}%') and issp = '0' and isnull(HangState,'0')='0' order by BillDate asc";
                    }
                    //出纳和集团领导查看已付款的
                    if (SpTypeId == "3")
                    {
                        //sql = $"select Top 80 * from(select a.BillNo,0 IsAccount, 0 BillCount, 0 FeeAmount, isnull(a.IsAuditing, 0) IsSp, A.OperatorName + '提交的出差申请' + (case when isnull(a.IsAuditing, 0) = 1 then '[已同意]' when isnull(a.IsAuditing, 0) = 2 then '[已驳回]' else '' end ) Title,11 FType, BillDate,a.TravelReason Notes, a.DDOperatorId,a.SelAuditingGuid,a.CopyPerson,'' CustName,A.AuditingIdea,'' IsInsteadApply,'' InsteadOperatorGuid from TravelReq A union select a.BillNo BillNo,a.IsAccount, b.BillCount,b.FeeAmount,isnull(a.IsSp, 0) IsSp,C.employeename + '提交的雨诺差旅费审批' + (case when isnull(a.IsSp,0)= 1 then '[已同意]' when isnull(a.IsSp,0)= 2 then '[已驳回]' else '' end ) Title,12 FType, BillDate,a.Notes,a.DDOperatorId,a.SelAuditingGuid,a.CopyPerson,'' CustName,A.AuditingIdea,a.IsInsteadApply,isnull(a.InsteadOperatorGuid,'') InsteadOperatorGuid from  ExpeTrav a left join(SELECT BILLNO, SUM(TOTALAMOUNT) FeeAmount, sum(TranCount)+sum(AccoCount) + sum(CityTrafCount) BillCount FROM EXPETRAVDETAIL GROUP BY BILLNO) b ON A.BILLNO = b.BILLNO left join FlowEmployee c on a.InsteadOperatorGuid = c.ddid union select a.BillNo BillNo, a.IsAccount,a.BillCount,a.FeeAmount,isnull(a.IsSp, 0) IsSp,B.employeename + '提交的雨诺' + (case when a.FeeType = '01' then '交通费' when a.FeeType = '02' then '通讯费' when a.FeeType = '03' then '车辆费' when a.FeeType = '04' then '房租费' when a.FeeType = '05' then '水费' when a.FeeType = '06' then '电费' when a.FeeType = '07' then '其他费用' end)+'审批' + (case when isnull(a.IsSp,0)= 1 then '[已同意]' when isnull(a.IsSp,0)= 2 then '[已驳回]' else '' end ) Title,A.FeeType FType, BillDate,a.Notes,a.DDOperatorId,a.SelAuditingGuid,a.CopyPersonID CopyPerson,'' CustName,A.AuditingIdea,a.IsInsteadApply,isnull(a.InsteadOperatorGuid,'') InsteadOperatorGuid from EXPEOTHER a left join FlowEmployee b on a.InsteadOperatorGuid = b.ddid union select a.BillNo BillNo,a.IsAccount, a.BillCount,a.FeeAmount,isnull(a.IsSp, 0) IsSp,B.employeename + '提交的雨诺招待费审批' + (case when isnull(a.IsSp,0)= 1 then '[已同意]' when isnull(a.IsSp,0)= 2 then '[已驳回]' else '' end ) Title,'00' FType, BillDate,a.Notes,a.DDOperatorId,a.SelAuditingGuid,a.CopyPersonID CopyPerson, c.CustName,A.AuditingIdea,a.IsInsteadApply,isnull(a.InsteadOperatorGuid,'') InsteadOperatorGuid from EXPEENTEMENT a left join FlowEmployee b on a.InsteadOperatorGuid = b.ddid left join Customer c on a.CustCode = c.CustCode) t where isAccount = '1'  and BillNo in (select BillNo from ApprovalComments where ApprovalID = (select distinct EmployeeCode from FlowEmployee where ddid = '{DDOperatorId}') and persontype = 2 and ApprovalStatus =1 and BillNo<> '')  and (Title like '%{selValue}%' or BillNo like '%{selValue}%') order by BillDate desc";
                        sql = $"select Top 80 * from(select a.BillNo,0 IsAccount, 0 BillCount, 0 FeeAmount, isnull(a.IsAuditing, 0) IsSp, A.OperatorName + '提交的出差申请' + (case when isnull(a.IsAuditing, 0) = 1 then '[已同意]' when isnull(a.IsAuditing, 0) = 2 then '[已驳回]' else '' end ) Title,11 FType, BillDate,a.TravelReason Notes, a.DDOperatorId,a.SelAuditingGuid,a.CopyPerson,'' CustName,A.AuditingIdea,'' IsInsteadApply,'' InsteadOperatorGuid from TravelReq A union select a.BillNo BillNo,a.IsAccount, b.BillCount,b.FeeAmount,isnull(a.IsSp, 0) IsSp,C.employeename + '提交的雨诺差旅费审批' + (case when isnull(a.IsSp,0)= 1 then '[已同意]' when isnull(a.IsSp,0)= 2 then '[已驳回]' else '' end ) Title,12 FType, BillDate,a.Notes,a.DDOperatorId,a.SelAuditingGuid,a.CopyPerson,'' CustName,A.AuditingIdea,a.IsInsteadApply,isnull(a.InsteadOperatorGuid,'') InsteadOperatorGuid from  ExpeTrav a left join(SELECT BILLNO, SUM(TOTALAMOUNT) FeeAmount, sum(TranCount)+sum(AccoCount) + sum(CityTrafCount) BillCount FROM EXPETRAVDETAIL GROUP BY BILLNO) b ON A.BILLNO = b.BILLNO left join FlowEmployee c on a.InsteadOperatorGuid = c.ddid union select a.BillNo BillNo, a.IsAccount,a.BillCount,a.FeeAmount,isnull(a.IsSp, 0) IsSp,B.employeename + '提交的雨诺' + (case when a.FeeType = '01' then '交通费' when a.FeeType = '02' then '通讯费' when a.FeeType = '03' then '车辆费' when a.FeeType = '04' then '房租费' when a.FeeType = '05' then '水费' when a.FeeType = '06' then '电费' when a.FeeType = '07' then '其他费用' end)+'审批' + (case when isnull(a.IsSp,0)= 1 then '[已同意]' when isnull(a.IsSp,0)= 2 then '[已驳回]' else '' end ) Title,A.FeeType FType, BillDate,a.Notes,a.DDOperatorId,a.SelAuditingGuid,a.CopyPersonID CopyPerson,'' CustName,A.AuditingIdea,a.IsInsteadApply,isnull(a.InsteadOperatorGuid,'') InsteadOperatorGuid from EXPEOTHER a left join FlowEmployee b on a.InsteadOperatorGuid = b.ddid union select a.BillNo BillNo,a.IsAccount, a.BillCount,a.FeeAmount,isnull(a.IsSp, 0) IsSp,B.employeename + '提交的雨诺招待费审批' + (case when isnull(a.IsSp,0)= 1 then '[已同意]' when isnull(a.IsSp,0)= 2 then '[已驳回]' else '' end ) Title,'00' FType, BillDate,a.Notes,a.DDOperatorId,a.SelAuditingGuid,a.CopyPersonID CopyPerson, c.CustName,A.AuditingIdea,a.IsInsteadApply,isnull(a.InsteadOperatorGuid,'') InsteadOperatorGuid from EXPEENTEMENT a left join FlowEmployee b on a.InsteadOperatorGuid = b.ddid left join Customer c on a.CustCode = c.CustCode) t where isAccount = '1'  and BillNo in (select BillNo from ApprovalComments where persontype = 2 and ApprovalStatus =1 and BillNo<> '')  and (Title like '%{selValue}%' or BillNo like '%{selValue}%') order by BillDate desc";
                    }

                    //查询待审批已挂起的
                    if (SpTypeId == "4")
                    {
                        sql = $"select Top 80 * from (select a.BillNo BillNo,a.IsAccount,  b.BillCount,b.FeeAmount,isnull(a.IsSp, 0) IsSp,C.employeename + '提交的雨诺差旅费审批' + (case when isnull(a.IsSp,0)= 1 then '[已同意]' when isnull(a.IsSp,0)= 2 then '[已驳回]' else '' end ) Title,12 FType, BillDate,a.Notes,a.DDOperatorId,a.SelAuditingGuid,a.CopyPerson,'' CustName,A.AuditingIdea ,a.IsInsteadApply,isnull(a.InsteadOperatorGuid,'') InsteadOperatorGuid,a.HangState,a.HangDDIDs from  ExpeTrav a left join(SELECT BILLNO, SUM(TOTALAMOUNT) FeeAmount, sum(TranCount)+sum(AccoCount) + sum(CityTrafCount) BillCount FROM EXPETRAVDETAIL GROUP BY BILLNO) b ON A.BILLNO = b.BILLNO left join FlowEmployee c on a.InsteadOperatorGuid = c.ddid union select a.BillNo BillNo, a.IsAccount, a.BillCount,a.FeeAmount,isnull(a.IsSp, 0) IsSp,B.employeename + '提交的雨诺' + (case when a.FeeType = '01' then '交通费' when a.FeeType = '02' then '通讯费' when a.FeeType = '03' then '车辆费' when a.FeeType = '04' then '房租费' when a.FeeType = '05' then '水费' when a.FeeType = '06' then '电费' when a.FeeType = '07' then '其他费用' end)+'审批' + (case when isnull(a.IsSp,0)= 1 then '[已同意]' when isnull(a.IsSp,0)= 2 then '[已驳回]' else '' end ) Title,A.FeeType FType,  BillDate,a.Notes,a.DDOperatorId,a.SelAuditingGuid,a.CopyPersonID CopyPerson,'' CustName,A.AuditingIdea,a.IsInsteadApply,isnull(a.InsteadOperatorGuid,'') InsteadOperatorGuid,a.HangState,a.HangDDIDs from EXPEOTHER a left join FlowEmployee b on a.InsteadOperatorGuid = b.ddid union select a.BillNo BillNo,a.IsAccount,  a.BillCount,a.FeeAmount,isnull(a.IsSp, 0) IsSp,B.employeename + '提交的雨诺招待费审批' + (case when isnull(a.IsSp,0)= 1 then '[已同意]' when isnull(a.IsSp,0)= 2 then '[已驳回]' else '' end ) Title,'00' FType, BillDate,a.Notes,a.DDOperatorId,a.SelAuditingGuid,a.CopyPersonID CopyPerson, c.CustName,A.AuditingIdea,a.IsInsteadApply,isnull(a.InsteadOperatorGuid,'') InsteadOperatorGuid,a.HangState,a.HangDDIDs from EXPEENTEMENT a left join FlowEmployee b on a.InsteadOperatorGuid = b.ddid left join Customer c on a.CustCode = c.CustCode) t where HangDDIDs like '%{DDOperatorId}%'  and (Title like '%{selValue}%' or BillNo like '%{selValue}%') and issp = '0' and isnull(HangState,'0')='1' order by BillDate asc";
                    }
                }
                if (WTypeId == "2")//我发起的
                {
                    sql = sql.Replace("BillNo in (select BillNo from ApprovalComments where persontype [审批类型] and BillNo <> '')", $"'{DDOperatorId}'   in(DDOperatorId,InsteadOperatorGuid)");
                    //sql = sql.Replace("BillNo in (select BillNo from ApprovalComments where ApprovalID =(select distinct EmployeeCode from Employee where ddid ='[钉钉ID]') and persontype [审批类型] and BillNo <> '')", $"'{DDOperatorId}'   in(DDOperatorId,InsteadOperatorGuid)");
                }
                //else if (WTypeId == "3")//抄送我的
                //{
                //    sql = sql.Replace("[审批类型]", "=3");
                //}
                else if (WTypeId == "3")//抄送我的
                {
                    context.Response.Write(JsonConvert.SerializeObject(new ApprovalOverViewModel {
                        errcode = "0", errmsg = "查询数据为空", Detail = null
                    }));
                    return;
                }

                if ((SpTypeId == "0" || SpTypeId == "2") && WTypeId != "1")//待审批
                {
                    sql = sql.Replace("[审批状态]", "in(0,3)");
                }
                else if (SpTypeId == "1" && WTypeId != "1")//已审批
                {
                    sql = sql.Replace("[审批状态]", "in(1,2)");
                }

                sql = sql.Replace("[查询条件]", selValue).Replace("[钉钉ID]", DDOperatorId);

                #endregion 查询SQL语句

                ToolsClass.TxtLog("查询审批信息日志", "\r\n查询语句" + sql + "\r\n");
                obj = da.GetDataTable(sql);
                dt  = obj as DataTable;
                string isdt = "0";
                ApprovalOverViewModel         approvalOverViewModel = new ApprovalOverViewModel();
                List <ApprovalOverViewDetail> Detail = new List <ApprovalOverViewDetail>();
                if (dt.Rows.Count > 0)
                {
                    approvalOverViewModel.errcode = "0";
                    approvalOverViewModel.errmsg  = "查询当前人的单据信息成功!";

                    for (int x = 0; x < dt.Rows.Count; x++)
                    {
                        isdt = dt.Rows[x]["IsInsteadApply"].ToString();

                        if (dt.Rows[x]["InsteadOperatorGuid"].ToString() == DDOperatorId && dt.Rows[x]["DDOperatorId"].ToString() != DDOperatorId)
                        {
                            //被别人代替报销的
                            isdt = "2";
                        }
                        sql = "";
                        sql = $"select distinct BillClassId from approvalcomments where billno ='{dt.Rows[x]["BillNo"].ToString()}'";
                        string ftype = dt.Rows[x]["FType"].ToString();
                        if (ftype.Length == 1)
                        {
                            ftype = "0" + ftype;
                        }
                        if (da.GetValue(sql) == null)
                        {
                            Detail.Add(new ApprovalOverViewDetail
                            {
                                IsSp                = dt.Rows[x]["IsSp"].ToString(),
                                AuditingIdea        = dt.Rows[x]["AuditingIdea"].ToString(),
                                BillCount           = dt.Rows[x]["BillCount"].ToString(),
                                BillDate            = dt.Rows[x]["BillDate"].ToString(),
                                BillNo              = dt.Rows[x]["BillNo"].ToString(),
                                CustName            = dt.Rows[x]["CustName"].ToString(),
                                FeeAmount           = dt.Rows[x]["FeeAmount"].ToString(),
                                FType               = ftype,
                                InsteadOperatorGuid = dt.Rows[x]["InsteadOperatorGuid"].ToString(),
                                IsAccount           = dt.Rows[x]["IsAccount"].ToString(),
                                IsInsteadApply      = isdt,
                                Notes               = dt.Rows[x]["Notes"].ToString(),
                                Title               = dt.Rows[x]["Title"].ToString()
                            });
                        }
                        else
                        {
                            Detail.Add(new ApprovalOverViewDetail
                            {
                                IsSp                = dt.Rows[x]["IsSp"].ToString(),
                                BillClassId         = da.GetValue(sql).ToString(),
                                AuditingIdea        = dt.Rows[x]["AuditingIdea"].ToString(),
                                BillCount           = dt.Rows[x]["BillCount"].ToString(),
                                BillDate            = dt.Rows[x]["BillDate"].ToString(),
                                BillNo              = dt.Rows[x]["BillNo"].ToString(),
                                CustName            = dt.Rows[x]["CustName"].ToString(),
                                FeeAmount           = dt.Rows[x]["FeeAmount"].ToString(),
                                FType               = ftype,
                                InsteadOperatorGuid = dt.Rows[x]["InsteadOperatorGuid"].ToString(),
                                IsAccount           = dt.Rows[x]["IsAccount"].ToString(),
                                IsInsteadApply      = isdt,
                                Notes               = dt.Rows[x]["Notes"].ToString(),
                                Title               = dt.Rows[x]["Title"].ToString()
                            });
                        }
                    }
                    approvalOverViewModel.Detail = Detail;
                }
                else
                {
                    context.Response.Write(JsonConvert.SerializeObject(new ApprovalOverViewModel {
                        errcode = "0", errmsg = "查询数据为空", Detail = null
                    }));
                    return;
                }
                result = JsonConvert.SerializeObject(approvalOverViewModel);
                if (isWrite == "1")
                {
                    ToolsClass.TxtLog("查询审批信息日志", $"\r\n返回:{result}\r\n");
                }
                context.Response.Write(result);
                return;
            }
            catch (Exception ex)
            {
                context.Response.Write(JsonConvert.SerializeObject(new ApprovalOverViewModel {
                    errcode = "1", errmsg = ex.Message, Detail = null
                }));
                return;
            }

            #endregion 查询审批信息
        }
コード例 #3
0
ファイル: ProcessInfo.ashx.cs プロジェクト: WangBank/DDWebApi
        public void ProcessRequest(HttpContext context)
        {
            //判断客户端请求是否为post方法
            if (context.Request.HttpMethod.ToUpper() != "POST")
            {
                context.Response.Write(JsonConvert.SerializeObject(new CommonModel {
                    errcode = "1", errmsg = "请求方式不允许,请使用POST方式"
                }));
                return;
            }
            try
            {
                string signUrl = ToolsClass.GetConfig("signUrl");
                context.Response.ContentType = "text/plain";
                //数据库链接
                connectionString = ToolsClass.GetConfig("DataOnLine");
                string MedConfig180AuditingInfo = ToolsClass.GetConfig("MedConfig180AuditingInfo");
                //sqlServer
                da = new DbHelper.SqlHelper("SqlServer", connectionString);
                //获取请求json
                using (var reader = new StreamReader(context.Request.InputStream, Encoding.UTF8))
                {
                    CsJson = reader.ReadToEnd();
                }

                if (CsJson == "")
                {
                    context.Response.Write(JsonConvert.SerializeObject(new CommonModel {
                        errcode = "1", errmsg = "报文格式错误"
                    }));
                    return;
                }
                CsJson = Regex.Replace(CsJson, @"[\n\r]", "").Replace(@"\n", ",").Replace("'", "‘").Replace("\t", ":").Replace("\r", ",").Replace("\n", ",");
                ToolsClass.TxtLog("获取审批流程信息日志", "\r\n入参:" + CsJson + "\r\n");
                //json转Hashtable
                object    jgobj      = ToolsClass.DeserializeObject(CsJson);
                Hashtable returnhash = jgobj as Hashtable;
                if (returnhash == null)
                {
                    context.Response.Write(JsonConvert.SerializeObject(new CommonModel {
                        errcode = "1", errmsg = "报文格式错误"
                    }));
                    return;
                }

                string path = context.Request.Path.Replace("Approval/ProcessInfo.ashx", "getprocessbegin");
                //验证请求sign
                string sign = ToolsClass.md5(signUrl + path + "Romens1/DingDing2" + path, 32);
                ToolsClass.TxtLog("生成的sign", "生成的" + sign + "传入的sign" + returnhash["Sign"].ToString() + "\r\n 后台字符串:" + signUrl + path + "Romens1/DingDing2" + path);
                if (sign != returnhash["Sign"].ToString())
                {
                    context.Response.Write(JsonConvert.SerializeObject(new CommonModel {
                        errcode = "1", errmsg = "Sign不正确"
                    }));
                    return;
                }
                string MedConfig180 = string.Empty;
                selType        = returnhash["TypeId"].ToString();
                DDOperatorId   = returnhash["DDOperatorId"].ToString();
                DDOperatorName = returnhash["DDOperatorName"].ToString();
                if (returnhash.ContainsKey("MedConfig180"))
                {
                    MedConfig180 = returnhash["MedConfig180"].ToString();
                }
                //#微应用ID:agentId #企业ID:corpId #应用的唯一标识:appKey #应用的密钥:appSecret
                AppWyy    = ToolsClass.GetConfig("AppWyy");
                ScList    = AppWyy.Split('$');
                agentId   = ScList[0].ToString();
                corpId    = ScList[1].ToString();
                appKey    = ScList[2].ToString();
                appSecret = ScList[3].ToString();
                isWrite   = ToolsClass.GetConfig("isWrite");
                ddUrl     = ToolsClass.GetConfig("ddUrl");

                #region 获取access_token

                url    = "https://oapi.dingtalk.com/gettoken?appkey=" + appKey + "&appsecret=" + appSecret;
                fjsons = ToolsClass.ApiFun("GET", url, "");

                TokenClass tokenClass = new TokenClass();
                tokenClass   = (TokenClass)JsonConvert.DeserializeObject(fjsons, typeof(TokenClass));
                access_token = tokenClass.access_token;
                int errcode = tokenClass.errcode;
                if (errcode != 0)
                {
                    context.Response.Write("{\"errmsg\":\"" + tokenClass.errmsg + "\",\"errcode\":1}");
                    return;
                }

                #endregion 获取access_token

                #region 获取用户详情

                url    = "https://oapi.dingtalk.com/user/get?access_token=" + access_token + "&userid=" + DDOperatorId;
                fjsons = ToolsClass.ApiFun("GET", url, "");

                GetUserXq userXqClass = new GetUserXq();
                userXqClass = (GetUserXq)JsonConvert.DeserializeObject(fjsons, typeof(GetUserXq));
                errcode     = userXqClass.errcode;
                if (errcode != 0)
                {
                    context.Response.Write(JsonConvert.SerializeObject(new CommonModel {
                        errcode = "1", errmsg = userXqClass.errmsg
                    }));
                    return;
                }

                #endregion 获取用户详情
                List <RUPNodeinfo> NodeInfo      = new List <RUPNodeinfo>();
                string             returnProcess = "";
                //取用户信息,进入功能时获取审批流程信息
                if (selType == "psin")
                {
                    //如果是高级领导发起审批
                    if (da.GetDataTable($"select * from flowemployee where orgcode ='00' and isleader='1' and ddid='{DDOperatorId}' and disable ='0'").Rows.Count != 0)
                    {
                        DataTable roleWithEmp = da.GetDataTable("select distinct Type,PersonId,PersonName  from RoleWithEmp where status = '1'");
                        if (roleWithEmp.Rows.Count == 0)
                        {
                            context.Response.Write(JsonConvert.SerializeObject(new CommonModel {
                                errcode = "1", errmsg = "未配置高级领导审批流程,请联系相关人员进行RoleWithEmp中数据配置!"
                            }));
                            return;
                        }
                        DataRow[] dataRows1, dataRows2 = null;
                        //为1 的是集团财务
                        dataRows1 = roleWithEmp.Select("Type ='1'");
                        List <RUPNodeinfodetail>
                        NodeInfoDetailsCW     = new List <RUPNodeinfodetail>(),
                            NodeInfoDetailsCN = new List <RUPNodeinfodetail>();
                        List <RUPPerson>
                        Personscaiwu  = new List <RUPPerson>(),
                            Personscn = new List <RUPPerson>();

                        for (int ri = 0; ri < dataRows1.Length; ri++)
                        {
                            Personscaiwu.Add(new RUPPerson {
                                AType      = "集团财务",
                                PersonId   = dataRows1[ri]["PersonId"].SqlDataBankToString(),
                                PersonName = dataRows1[ri]["PersonName"].SqlDataBankToString()
                            });
                        }
                        NodeInfoDetailsCW.Add(new RUPNodeinfodetail {
                            GroupType = "集团财务",
                            IsAndOr   = "1",
                            IsLeader  = "0",
                            Persons   = Personscaiwu
                        });
                        NodeInfo.Add(new RUPNodeinfo {
                            NodeInfoDetails = NodeInfoDetailsCW, NodeInfoType = "2"
                        });
                        //为2的是出纳
                        dataRows2 = roleWithEmp.Select("Type ='2'");
                        for (int ci = 0; ci < dataRows2.Length; ci++)
                        {
                            Personscn.Add(new RUPPerson {
                                AType      = "出纳",
                                PersonId   = dataRows2[ci]["PersonId"].SqlDataBankToString(),
                                PersonName = dataRows2[ci]["PersonName"].SqlDataBankToString()
                            });
                        }
                        NodeInfoDetailsCN.Add(new RUPNodeinfodetail
                        {
                            GroupType = "出纳",
                            IsAndOr   = "1",
                            IsLeader  = "0",
                            Persons   = Personscn
                        });

                        NodeInfo.Add(new RUPNodeinfo {
                            NodeInfoDetails = NodeInfoDetailsCN, NodeInfoType = "2"
                        });
                        returnProcess = JsonConvert.SerializeObject(new ReturnUserProcess {
                            NodeInfo = NodeInfo,
                            errcode  = "0",
                            errmsg   = ""
                        });
                        if (isWrite == "1")
                        {
                            ToolsClass.TxtLog("获取审批流程信息日志", "\r\n返回高级领导审批流程:" + returnProcess + "\r\n");
                        }
                        context.Response.Write(returnProcess);
                        return;
                    }

                    if (MedConfig180 == "1")
                    {
                        List <RUPNodeinfodetail> NodeInfoDetailsYB = new List <RUPNodeinfodetail>();
                        List <RUPPerson>         PersonsYB         = new List <RUPPerson>();

                        NodeInfo.Clear();
                        PersonsYB.Add(new RUPPerson {
                            AType      = "指定人",
                            PersonId   = MedConfig180AuditingInfo.Split(',')[0],
                            PersonName = MedConfig180AuditingInfo.Split(',')[1]
                        });
                        NodeInfoDetailsYB.Add(new RUPNodeinfodetail
                        {
                            GroupType = "指定人",
                            IsAndOr   = "1",
                            IsLeader  = "0",
                            Persons   = PersonsYB
                        });
                        NodeInfo.Add(new RUPNodeinfo
                        {
                            NodeInfoDetails = NodeInfoDetailsYB,
                            NodeInfoType    = "2"
                        });
                        returnProcess = JsonConvert.SerializeObject(new ReturnUserProcess
                        {
                            NodeInfo = NodeInfo,
                            errcode  = "0",
                            errmsg   = ""
                        });
                        context.Response.Write(returnProcess);
                        return;
                    }

                    string BillClassId = returnhash["BillClassId"].ToString();
                    string billName    = returnhash["BillName"].ToString();
                    string deptCode    = returnhash["DeptCode"].ToString();
                    sql = $"select nodeid,BilliClassid,BillClassName,NodeNumber,CharacterTypes,ApprovalType,persons,IsAndOr,IsEnd from ApprovalNode where BilliClassid = '{BillClassId}' order by NodeNumber";
                    //找到相对应的流程信息
                    DataTable processdt = da.GetDataTable(sql);
                    DataTable deptdt;
                    DataTable roledt;

                    NodeInfo.Clear();

                    //嗯 开始组json,如果你看到这段代码,劝你别轻举妄动,仔细观察再改,容易出事,修改之前切记切记,三思而后行
                    List <RUPPerson>
                    PersonsRy,
                        PersonsJs,
                        PersonsCs,
                        PersonsBm1 = new List <RUPPerson>(),
                        PersonsBm2 = new List <RUPPerson>(),
                        PersonsBm3 = new List <RUPPerson>(),
                        PersonsBm4 = new List <RUPPerson>(),
                        PersonsBm5 = new List <RUPPerson>();

                    List <RUPNodeinfodetail>
                    NodeInfoDetailsRy,
                        NodeInfoDetailsCs,
                        NodeInfoDetailsJs,
                        NodeInfoDetailsBm1 = new List <RUPNodeinfodetail>(),
                        NodeInfoDetailsBm2 = new List <RUPNodeinfodetail>(),
                        NodeInfoDetailsBm3 = new List <RUPNodeinfodetail>(),
                        NodeInfoDetailsBm4 = new List <RUPNodeinfodetail>(),
                        NodeInfoDetailsBm5 = new List <RUPNodeinfodetail>();

                    PSPPerson pSPPerson = new PSPPerson();
                    string    deptid, deptname;
                    //是否是主管
                    PSPApprovalType pSPApprovalType = new PSPApprovalType();
                    for (int i = 0; i < processdt.Rows.Count; i++)
                    {
                        PSPPerson[] Persons = (PSPPerson[])JsonConvert.DeserializeObject(processdt.Rows[i]["Persons"].SqlDataBankToString(), typeof(PSPPerson[]));
                        if (processdt.Rows[i]["CharacterTypes"].SqlDataBankToString() == "2")
                        {
                            pSPApprovalType = null;
                            pSPApprovalType = (PSPApprovalType)JsonConvert.DeserializeObject(processdt.Rows[i]["ApprovalType"].SqlDataBankToString(), typeof(PSPApprovalType));

                            //按照人员审批
                            if (pSPApprovalType.Type == "1")
                            {
                                PersonsRy         = new List <RUPPerson>();
                                NodeInfoDetailsRy = new List <RUPNodeinfodetail>();
                                for (int k = 0; k < Persons.Length; k++)
                                {
                                    PersonsRy.Add(new RUPPerson
                                    {
                                        AType      = "指定人",
                                        PersonId   = Persons[k].PersonId,
                                        PersonName = Persons[k].PersonName
                                    });
                                }
                                NodeInfoDetailsRy.Add(new RUPNodeinfodetail
                                {
                                    GroupType = "指定人",
                                    IsAndOr   = processdt.Rows[i]["IsAndOr"].SqlDataBankToString(),
                                    IsLeader  = "0",
                                    Persons   = PersonsRy
                                });
                                NodeInfo.Add(new RUPNodeinfo
                                {
                                    NodeInfoDetails = NodeInfoDetailsRy,
                                    NodeInfoType    = "2"
                                });
                            }
                            //按照部门审批
                            if (pSPApprovalType.Type == "2")
                            {
                                //查询当前的人的级别以及部门编号 取isleader最大的为准
                                sql = $"select a.IsLeader IsLeader, b.guid orgcode from FlowEmployee a join Organization b on a.orgcode = b. guid where a.EmployeeCode = '{userXqClass.jobnumber}' and a.orgcode ='{deptCode}' and a.disable ='0' order by a.IsLeader desc";

                                DataTable loinfo = da.GetDataTable(sql);
                                if (loinfo.Rows.Count == 0)
                                {
                                    context.Response.Write(JsonConvert.SerializeObject(new CommonModel {
                                        errcode = "1", errmsg = "未配置审批流程,请联系相关人员进行FlowEmployee表配置!"
                                    }));
                                    return;
                                }
                                string leaderlevel = loinfo.Rows[0]["IsLeader"].SqlDataBankToString();
                                string orgcode     = loinfo.Rows[0]["orgcode"].SqlDataBankToString();
                                //直接主管 一级主管
                                if (pSPApprovalType.Level == "1")
                                {
                                    //判断他是否是主管
                                    if (int.Parse(leaderlevel) > 0)
                                    {
                                        sql = null;
                                        sql = $"select  EmployeeCode, EmployeeName from FlowEmployee where orgcode= (select case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid = '{orgcode}') and disable ='0' and IsLeader ='1' ";
                                    }
                                    else
                                    {
                                        sql = null;
                                        // sql = $"select  EmployeeCode, EmployeeName from FlowEmployee where orgcode= (select guid from Organization where guid = '{orgcode}') and disable ='0' and  IsLeader ='{int.Parse(leaderlevel) + 1}'";

                                        sql = $"select  EmployeeCode, EmployeeName from FlowEmployee where orgcode= (select guid from Organization where guid = '{orgcode}') and disable ='0' and  IsLeader ='1'";
                                    }
                                    deptdt = da.GetDataTable(sql);
                                    if (deptdt.Rows.Count != 0)
                                    {
                                        for (int k = 0; k < deptdt.Rows.Count; k++)
                                        {
                                            deptid   = deptdt.Rows[k]["EmployeeCode"].SqlDataBankToString();
                                            deptname = deptdt.Rows[k]["EmployeeName"].SqlDataBankToString();
                                            PersonsBm1.Add(new RUPPerson
                                            {
                                                AType      = "直接主管",
                                                PersonId   = deptid,
                                                PersonName = deptname
                                            });
                                        }
                                        NodeInfoDetailsBm1.Add(new RUPNodeinfodetail
                                        {
                                            GroupType = "直接主管",
                                            IsAndOr   = processdt.Rows[i]["IsAndOr"].SqlDataBankToString(),
                                            IsLeader  = "1",
                                            Persons   = PersonsBm1
                                        });
                                        NodeInfo.Add(new RUPNodeinfo
                                        {
                                            NodeInfoDetails = NodeInfoDetailsBm1,
                                            NodeInfoType    = "2"
                                        });
                                    }
                                }
                                //二级主管
                                if (pSPApprovalType.Level == "2")
                                {
                                    //判断他是否是主管
                                    if (int.Parse(leaderlevel) > 0)
                                    {
                                        //二级主管
                                        sql = null;
                                        //sql = $"select  EmployeeCode, EmployeeName from FlowEmployee where orgcode= (select case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid = '{orgcode}')) and disable ='0' and IsLeader ='{int.Parse(leaderlevel) + 2}'";
                                        sql = $"select  EmployeeCode, EmployeeName from FlowEmployee where orgcode= (select case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid = '{orgcode}')) and disable ='0' and IsLeader ='1'";
                                    }
                                    else
                                    //当前人不是主管
                                    {
                                        sql = null;
                                        //sql = $"select  EmployeeCode, EmployeeName from FlowEmployee where orgcode= (select case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select guid from Organization where guid = '{orgcode}')) and disable ='0' and IsLeader ='{int.Parse(leaderlevel) + 2}'";
                                        sql = $"select  EmployeeCode, EmployeeName from FlowEmployee where orgcode= (select case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select guid from Organization where guid = '{orgcode}')) and disable ='0' and IsLeader ='1'";
                                    }
                                    deptdt = da.GetDataTable(sql);
                                    if (deptdt.Rows.Count != 0)
                                    {
                                        for (int k = 0; k < deptdt.Rows.Count; k++)
                                        {
                                            deptid   = deptdt.Rows[k]["EmployeeCode"].SqlDataBankToString();
                                            deptname = deptdt.Rows[k]["EmployeeName"].SqlDataBankToString();
                                            PersonsBm2.Add(new RUPPerson
                                            {
                                                AType      = "二级主管",
                                                PersonId   = deptid,
                                                PersonName = deptname
                                            });
                                        }
                                        NodeInfoDetailsBm2.Add(new RUPNodeinfodetail
                                        {
                                            GroupType = "二级主管",
                                            IsAndOr   = processdt.Rows[i]["IsAndOr"].SqlDataBankToString(),
                                            IsLeader  = "1",
                                            Persons   = PersonsBm2
                                        });
                                        NodeInfo.Add(new RUPNodeinfo
                                        {
                                            NodeInfoDetails = NodeInfoDetailsBm2,
                                            NodeInfoType    = "2"
                                        });
                                    }
                                }
                                //三级主管
                                if (pSPApprovalType.Level == "3")
                                {
                                    //判断他是否是主管
                                    if (int.Parse(leaderlevel) > 0)
                                    {
                                        sql = null;
                                        //三级主管
                                        //sql = $"select  EmployeeCode, EmployeeName from FlowEmployee where orgcode = (select  case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid = '{orgcode}'))) and disable ='0'  and IsLeader ='{int.Parse(leaderlevel) + 3}'";
                                        sql = $"select  EmployeeCode, EmployeeName from FlowEmployee where orgcode = (select  case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid = '{orgcode}'))) and disable ='0'  and IsLeader ='1";
                                    }
                                    else
                                    {
                                        sql = null;
                                        //sql = $"select  EmployeeCode, EmployeeName from FlowEmployee where orgcode = (select  case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select guid from Organization where guid = '{orgcode}'))) and disable ='0'  and IsLeader ='{int.Parse(leaderlevel) + 3}'";
                                        sql = $"select  EmployeeCode, EmployeeName from FlowEmployee where orgcode = (select  case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select guid from Organization where guid = '{orgcode}'))) and disable ='0'  and IsLeader ='1";
                                    }
                                    deptdt = da.GetDataTable(sql);
                                    if (deptdt.Rows.Count != 0)
                                    {
                                        for (int k = 0; k < deptdt.Rows.Count; k++)
                                        {
                                            deptid   = deptdt.Rows[k]["EmployeeCode"].SqlDataBankToString();
                                            deptname = deptdt.Rows[k]["EmployeeName"].SqlDataBankToString();
                                            PersonsBm3.Add(new RUPPerson
                                            {
                                                AType      = "三级主管",
                                                PersonId   = deptid,
                                                PersonName = deptname
                                            });
                                        }
                                        NodeInfoDetailsBm3.Add(new RUPNodeinfodetail
                                        {
                                            GroupType = "三级主管",
                                            IsAndOr   = processdt.Rows[i]["IsAndOr"].SqlDataBankToString(),
                                            IsLeader  = "1",
                                            Persons   = PersonsBm3
                                        });
                                        NodeInfo.Add(new RUPNodeinfo
                                        {
                                            NodeInfoDetails = NodeInfoDetailsBm3,
                                            NodeInfoType    = "2"
                                        });
                                    }
                                }
                                //四级主管
                                if (pSPApprovalType.Level == "4")
                                {
                                    //判断他是否是主管
                                    if (int.Parse(leaderlevel) > 0)
                                    {
                                        sql = null;
                                        //四级主管
                                        //sql = $"select  EmployeeCode, EmployeeName from FlowEmployee where orgcode =(select  case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid = (select  case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid = '{orgcode}')))) and disable ='0'  and IsLeader ='{int.Parse(leaderlevel) + 4}'";
                                        sql = $"select  EmployeeCode, EmployeeName from FlowEmployee where orgcode =(select  case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid = (select  case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid = '{orgcode}')))) and disable ='0'  and IsLeader ='1'";
                                    }
                                    else
                                    {
                                        sql = null;
                                        //员工的四级主管
                                        //sql = $"select  EmployeeCode, EmployeeName from FlowEmployee where orgcode =(select  case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid = (select  case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select guid from Organization where guid = '{orgcode}')))) and disable ='0' and IsLeader ='{int.Parse(leaderlevel) + 4}'";
                                        sql = $"select  EmployeeCode, EmployeeName from FlowEmployee where orgcode =(select  case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid = (select  case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select guid from Organization where guid = '{orgcode}')))) and disable ='0' and IsLeader ='1'";
                                    }
                                    deptdt = da.GetDataTable(sql);
                                    if (deptdt.Rows.Count != 0)
                                    {
                                        for (int k = 0; k < deptdt.Rows.Count; k++)
                                        {
                                            deptid   = deptdt.Rows[k]["EmployeeCode"].SqlDataBankToString();
                                            deptname = deptdt.Rows[k]["EmployeeName"].SqlDataBankToString();
                                            PersonsBm4.Add(new RUPPerson
                                            {
                                                AType      = "四级主管",
                                                PersonId   = deptid,
                                                PersonName = deptname
                                            });
                                        }
                                        NodeInfoDetailsBm4.Add(new RUPNodeinfodetail
                                        {
                                            GroupType = "四级主管",
                                            IsAndOr   = processdt.Rows[i]["IsAndOr"].SqlDataBankToString(),
                                            IsLeader  = "1",
                                            Persons   = PersonsBm4
                                        });
                                        NodeInfo.Add(new RUPNodeinfo
                                        {
                                            NodeInfoDetails = NodeInfoDetailsBm4,
                                            NodeInfoType    = "2"
                                        });
                                    }
                                }
                                //五级主管
                                if (pSPApprovalType.Level == "5")
                                {
                                    //判断他是否是主管
                                    if (int.Parse(leaderlevel) > 0)
                                    {
                                        sql = null;
                                        //五级主管
                                        //sql = $"select  EmployeeCode, EmployeeName from FlowEmployee where orgcode =(select  case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid =(select  case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid = (select  case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid = '{orgcode}'))))) and disable ='0'  and IsLeader ='{int.Parse(leaderlevel) + 5}'";
                                        sql = $"select  EmployeeCode, EmployeeName from FlowEmployee where orgcode =(select  case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid =(select  case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid = (select  case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid = '{orgcode}'))))) and disable ='0'  and IsLeader ='1'";
                                    }
                                    else
                                    {
                                        sql = null;
                                        //员工的五级主管
                                        // sql = $"select  EmployeeCode, EmployeeName from FlowEmployee where orgcode =(select  case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid =(select  case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid = (select  case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select guid from Organization where guid = '{orgcode}'))))) and disable ='0' and IsLeader ='{int.Parse(leaderlevel) + 5}'";
                                        sql = $"select  EmployeeCode, EmployeeName from FlowEmployee where orgcode =(select  case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid =(select  case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid = (select  case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select case when isnull(Guid,'')='00' then '' else ParentGuid end ParentGuid from Organization where guid= (select guid from Organization where guid = '{orgcode}'))))) and disable ='0' and IsLeader ='1'";
                                    }
                                    deptdt = da.GetDataTable(sql);
                                    if (deptdt.Rows.Count != 0)
                                    {
                                        for (int k = 0; k < deptdt.Rows.Count; k++)
                                        {
                                            deptid   = deptdt.Rows[k]["EmployeeCode"].SqlDataBankToString();
                                            deptname = deptdt.Rows[k]["EmployeeName"].SqlDataBankToString();
                                            PersonsBm5.Add(new RUPPerson
                                            {
                                                AType      = "五级主管",
                                                PersonId   = deptid,
                                                PersonName = deptname
                                            });
                                        }
                                        NodeInfoDetailsBm5.Add(new RUPNodeinfodetail
                                        {
                                            GroupType = "五级主管",
                                            IsAndOr   = processdt.Rows[i]["IsAndOr"].SqlDataBankToString(),
                                            IsLeader  = "1",
                                            Persons   = PersonsBm5
                                        });
                                        NodeInfo.Add(new RUPNodeinfo
                                        {
                                            NodeInfoDetails = NodeInfoDetailsBm5,
                                            NodeInfoType    = "2"
                                        });
                                    }
                                }
                            }
                            //按角色审批 type 为3 level 为角色id
                            if (pSPApprovalType.Type == "3")
                            {
                                #region

                                //当前操作人的部门deptCode
                                //当前环节的角色组名称是pSPApprovalType.Level
                                sql = "";
                                sql = $"select distinct a.EmployeeCode EmployeeCode, a.EmployeeName EmployeeName,b.RoleName RoleName,c.roleid from FlowEmployee a join EmpsRoleId c on a.EmployeeCode = c.EmployeeCode join role b on b.roleid = c.roleid  where  c.RoleId in (select RoleId from RoleWithOrg where orgcode='{deptCode}' and status ='1') and c.Roleid in (select Roleid from Role where RoleGroupId = '{pSPApprovalType.Level}' and status ='1') and a.disable ='0' and c.status ='1' and b.status='1'";
                                ToolsClass.TxtLog("获取审批流程信息", "\r\n查询相应角色sql:" + sql + "\r\n");
                                roledt = da.GetDataTable(sql);
                                if (roledt.Rows.Count != 0)
                                {
                                    NodeInfoDetailsJs = new List <RUPNodeinfodetail>();
                                    PersonsJs         = new List <RUPPerson>();
                                    for (int k = 0; k < roledt.Rows.Count; k++)
                                    {
                                        deptid   = roledt.Rows[k]["EmployeeCode"].SqlDataBankToString();
                                        deptname = roledt.Rows[k]["EmployeeName"].SqlDataBankToString();
                                        PersonsJs.Add(new RUPPerson
                                        {
                                            AType      = roledt.Rows[k]["RoleName"].SqlDataBankToString(),
                                            PersonId   = deptid,
                                            PersonName = deptname
                                        });
                                    }
                                    NodeInfoDetailsJs.Add(new RUPNodeinfodetail
                                    {
                                        GroupType = da.GetValue($"select RoleGroupName from RoleGroup where RoleGroupId ='{pSPApprovalType.Level}'").SqlDataBankToString(),
                                        IsAndOr   = processdt.Rows[i]["IsAndOr"].SqlDataBankToString(),
                                        IsLeader  = "0",
                                        Persons   = PersonsJs
                                    });
                                    NodeInfo.Add(new RUPNodeinfo
                                    {
                                        NodeInfoDetails = NodeInfoDetailsJs,
                                        NodeInfoType    = "2"
                                    });
                                }
                                #endregion
                            }
                        }
                        //抄送环节
                        if (processdt.Rows[i]["CharacterTypes"].SqlDataBankToString() == "3")
                        {
                            NodeInfoDetailsCs = new List <RUPNodeinfodetail>();
                            PersonsCs         = new List <RUPPerson>();
                            for (int k = 0; k < Persons.Length; k++)
                            {
                                PersonsCs.Add(new RUPPerson
                                {
                                    AType      = "抄送人",
                                    PersonId   = Persons[k].PersonId,
                                    PersonName = Persons[k].PersonName
                                });
                            }
                            NodeInfoDetailsCs.Add(new RUPNodeinfodetail
                            {
                                GroupType = "抄送人",
                                IsAndOr   = "",
                                IsLeader  = "0",
                                Persons   = PersonsCs
                            });
                            NodeInfo.Add(new RUPNodeinfo
                            {
                                NodeInfoDetails = NodeInfoDetailsCs,
                                NodeInfoType    = "3"
                            });
                        }
                    }
                    returnProcess = JsonConvert.SerializeObject(new ReturnUserProcess
                    {
                        NodeInfo = NodeInfo,
                        errcode  = "0",
                        errmsg   = ""
                    });
                    ToolsClass.TxtLog("获取审批流程信息日志", "\r\n返回当前操作人审批流程:" + returnProcess + "\r\n");
                    context.Response.Write(returnProcess);
                    return;
                }

                //获取用户当前的部门
                else if (selType == "deptin")
                {
                    sql = $"select a.IsLeader IsLeader, b.guid orgcode,b.Name orgName,b.ParentGuid from FlowEmployee a join Organization b on a.orgcode = b. guid where a.EmployeeCode = '{userXqClass.jobnumber}' and a.disable = '0'";
                    DataTable           loinfo = da.GetDataTable(sql);
                    string              orgcode, orgName, ParentGuid;
                    List <Organization> DeptInfo = new List <Organization>();
                    for (int i = 0; i < loinfo.Rows.Count; i++)
                    {
                        orgcode    = loinfo.Rows[i]["orgcode"].SqlDataBankToString();
                        orgName    = loinfo.Rows[i]["orgName"].SqlDataBankToString();
                        ParentGuid = loinfo.Rows[i]["ParentGuid"].SqlDataBankToString();
                        DeptInfo.Add(new Organization
                        {
                            OrgCode    = orgcode,
                            OrgName    = orgName,
                            ParentGuid = ParentGuid
                        });
                    }
                    string result = JsonConvert.SerializeObject(new ReturnUserOrg {
                        DeptInfo = DeptInfo,
                        errcode  = "0",
                        errmsg   = "ok"
                    });
                    ToolsClass.TxtLog("获取用户当前的部门", $"执行的sql:{ sql }\r\n,返回的数据:\r\n{result}");
                    context.Response.Write(result);
                    return;
                }
            }
            catch (Exception ex)
            {
                context.Response.Write(JsonConvert.SerializeObject(new CommonModel {
                    errcode = "1", errmsg = ex.Message
                }));
                return;
            }
        }
コード例 #4
0
        public void ProcessRequest(HttpContext context)
        {
            //判断客户端请求是否为post方法
            if (context.Request.HttpMethod.ToUpper() != "POST")
            {
                context.Response.Write("{\"errmsg\":\"请求方式不允许,请使用POST方式(A0001)\",\"errcode\":1}");
                return;
            }

            try
            {
                string ymadk = System.Configuration.ConfigurationManager.AppSettings["ymadk"].ToString() + "/";
                //数据库链接
                connectionString = ToolsClass.GetConfig("DataOnLine");
                da = new BankDbHelper.SqlHelper("SqlServer", connectionString);
                //获取请求json
                using (var reader = new StreamReader(context.Request.InputStream, Encoding.UTF8))
                {
                    CsJson = reader.ReadToEnd();
                }

                if (CsJson == "")
                {
                    context.Response.Write("{\"errmsg\":\"报文格式错误(A0002)\",\"errcode\":1}");
                    return;
                }

                //ToolsClass.TxtLog("医保","1");

                //json转Hashtable
                Object    jgobj      = ToolsClass.DeserializeObject(CsJson);
                Hashtable returnhash = jgobj as Hashtable;
                if (returnhash == null)
                {
                    context.Response.Write("{\"errmsg\":\"报文格式错误(A0002)\",\"errcode\":1}");
                    return;
                }
                //ToolsClass.TxtLog("医保", "2");
                if (returnhash.Contains("BillNo"))
                {
                    BillNo = returnhash["BillNo"].ToString();
                    if (BillNo == "")
                    {
                        context.Response.Write("{\"errmsg\":\"BillNo(单据编号)不允许为空!\",\"errcode\":1}");
                        return;
                    }
                }
                else
                {
                    if (BillNo == "")
                    {
                        context.Response.Write("{\"errmsg\":\"BillNo(单据编号)不允许为空!\",\"errcode\":1}");
                        return;
                    }
                }
                //ToolsClass.TxtLog("医保", "3");
                sbSQL.Clear();
                sbSQL.AppendLine("Select A.BillNo,Convert(varchar(10),A.BillDate,126) as BillDate,A.BillTime,A.CusCode,A.CusName,A.MedType,A.ProductType,");
                sbSQL.AppendLine("A.IsAuditing,C.Name as AuditingName,A.AuditingDate,D.Name as OperatorName,isnull(YXQFlag,'') as YXQFlag,Convert(varchar(10),isnull(YXQ,'1900-01-01'),126) as YXQ,isnull(IsWrite,0) as IsWrite");
                sbSQL.AppendLine("From MedConfig A ");
                sbSQL.AppendLine("Left Join Operators C on A.AuditingGuid=C.Guid");
                sbSQL.AppendLine("Left Join Operators D On A.OperatorGuid=D.Guid");
                sbSQL.AppendLine("Where Isnull(A.IsAuditing,0)=1 and A.BillNo='" + BillNo + "' and isnull(A.MedType,' ')<>' ' and isnull(A.CusCode,' ')<>' ' and IsNull(A.CusName,' ')<>' '");
                SelectSQL = sbSQL.ToString();

                //ToolsClass.TxtLog("医保", "4");
                obj = da.GetDataTable(SelectSQL);
                if (obj == null)
                {
                    FhJson = "{\"errmsg\":\"授权单据不存在(A0002)\",\"errcode\":1}";
                    context.Response.Write(FhJson);
                    return;
                }
                dt = obj as DataTable;
                if (dt.Rows.Count == 0)
                {
                    FhJson = "{\"errmsg\":\"本笔单据未审核,不允许生成文件(A0003)\",\"errcode\":1}";
                    context.Response.Write(FhJson);
                    return;
                }
                //ToolsClass.TxtLog("医保", "5");

                EntCode = dt.Rows[0]["CusCode"].ToString();
                EntName = dt.Rows[0]["CusName"].ToString();
                MedCode = dt.Rows[0]["MedType"].ToString();
                YXQFlag = dt.Rows[0]["YXQFlag"].ToString();
                //ToolsClass.TxtLog("医保", "6");

                sbSQL.Clear();
                sbSQL.AppendLine("select CustCode CusCode,CustName CusName,MedType , Convert(varchar(10),isnull(YXQ,'1900-01-01'),126) YXQ ,YXQFlag");
                sbSQL.AppendLine("from MedEncryption ");
                sbSQL.AppendLine("where CustCode='" + EntCode + "' order by CustCode");
                SelectSQL = sbSQL.ToString();
                //ToolsClass.TxtLog("医保", "7");
                obj = da.GetDataTable(SelectSQL);
                if (obj == null)
                {
                    FhJson = "{\"errmsg\":\"授权单据不存在(A0002)\",\"errcode\":1}";
                    context.Response.Write(FhJson);
                    return;
                }
                //ToolsClass.TxtLog("医保", "8");
                dt.Clear();
                dt = obj as DataTable;
                if (dt.Rows.Count == 0)
                {
                    FhJson = "{\"errmsg\":\"本笔单据未审核,不允许生成文件(A0004)\",\"errcode\":1}";
                    context.Response.Write(FhJson);
                    return;
                }
                //ToolsClass.TxtLog("医保", "9:CustCode:" + EntCode+",sql:"+ SelectSQL);
                EntCode = dt.Rows[0]["CusCode"].ToString();
                EntName = dt.Rows[0]["CusName"].ToString();
                MedCode = dt.Rows[0]["MedType"].ToString();
                YXQFlag = dt.Rows[0]["YXQFlag"].ToString();
                //ToolsClass.TxtLog("医保", "10");
                if (YXQFlag.Equals("False", StringComparison.InvariantCultureIgnoreCase) ||
                    YXQFlag.Equals("0", StringComparison.InvariantCultureIgnoreCase))
                {
                    YXQFlag = "0";
                }
                else if (YXQFlag.Equals("true", StringComparison.InvariantCultureIgnoreCase) ||
                         YXQFlag.Equals("1", StringComparison.InvariantCultureIgnoreCase))
                {
                    YXQFlag = "1";
                }

                YXQ = dt.Rows[0]["YXQ"].ToString();

                if (this.WriteRomensEnt(MedCode, EntCode, EntName, YXQFlag, YXQ) == false)
                {
                    context.Response.Write(FhJson);
                    return;
                }

                //更新IsWrite标志
                string UpdateSQL = "Update MedConfig Set IsWrite=1,FileUrl='" + FileName + "' Where BillNo='" + BillNo + "'";
                obj = da.ExecSql(UpdateSQL);

                if (obj == null)
                {
                    FhJson = "{\"errmsg\":\"更新已写加密标志出错!\",\"errcode\":1}";
                    context.Response.Write(FhJson);
                    return;
                }
                FhJson = "{\"fileurl\":\"" + ssssname + "\",\"errmsg\":\"写入文件成功!\",\"errcode\":0}";

                context.Response.Write(FhJson);
                return;
            }
            catch (Exception)
            {
                context.Response.Write("{\"errmsg\":\"参数BillNo不允许为空!\",\"errcode\":1}");
                return;
            }
        }
コード例 #5
0
        public void ProcessRequest(HttpContext context)
        {
            //判断客户端请求是否为post方法
            if (context.Request.HttpMethod.ToUpper() != "POST")
            {
                context.Response.Write("{\"errmsg\":\"请求方式不允许,请使用POST方式(DD0001)\",\"errcode\":1}");
                return;
            }
            string ymadk = System.Configuration.ConfigurationManager.AppSettings["ymadk"].ToString() + "/";

            //数据库链接
            connectionString = ToolsClass.GetConfig("DataOnLine");

            da = new DbHelper.SqlHelper("SqlServer", connectionString);
            string signUrl = ToolsClass.GetConfig("signUrl"); context.Response.ContentType = "text/plain";

            //获取请求json
            using (var reader = new StreamReader(context.Request.InputStream, Encoding.UTF8))
            {
                CsJson = reader.ReadToEnd();
            }

            Object    jgobj      = ToolsClass.DeserializeObject(CsJson);
            Hashtable returnhash = jgobj as Hashtable;

            if (CsJson == "")
            {
                context.Response.Write("{\"errmsg\":\"报文格式错误(DD0003)\",\"errcode\":1}");
                return;
            }

            CsJson = Regex.Replace(CsJson, @"[\n\r]", "").Replace(@"\n", ",").Replace("'", "‘").Replace("\t", ":").Replace("\r", ",").Replace("\n", ",");

            ToolsClass.TxtLog("审批信息修改日志", context.Request.Path.ToLower() + "\r\n修改后的数据:" + CsJson + "\r\n");

            string path1 = context.Request.Path.Replace("Approval/ChangeSQDetails.ashx", "changeclfbxdetails");
            string path2 = context.Request.Path.Replace("Approval/ChangeSQDetails.ashx", "changeqitadetails");
            string path3 = context.Request.Path.Replace("Approval/ChangeSQDetails.ashx", "changezddetails");
            string path4 = context.Request.Path.Replace("Approval/ChangeSQDetails.ashx", "changeqtfydetails");
            //验证请求sign
            string sign1 = ToolsClass.md5(signUrl + path1 + "Romens1/DingDing2" + path1, 32);
            string sign2 = ToolsClass.md5(signUrl + path2 + "Romens1/DingDing2" + path2, 32);
            string sign3 = ToolsClass.md5(signUrl + path3 + "Romens1/DingDing2" + path3, 32);
            string sign4 = ToolsClass.md5(signUrl + path4 + "Romens1/DingDing2" + path4, 32);

            ToolsClass.TxtLog("生成的sign", "生成的" + "sign:" + sign1 + ";" + sign2 + ";" + sign3 + ";" + sign4 + ";" + "传入的sign" + returnhash["Sign"].ToString() + "\r\n");

            if (sign1 != returnhash["Sign"].ToString() && sign2 != returnhash["Sign"].ToString() && sign3 != returnhash["Sign"].ToString() && sign4 != returnhash["Sign"].ToString())
            {
                context.Response.Write("{\"errmsg\":\"认证信息Sign不存在或者不正确!\",\"errcode\":1}");
                return;
            }
            try
            {
                if (returnhash["BillNo"].ToString().Contains("CL"))
                {
                    //前端传入数据
                    changeCLFBXSQRC = new ChangeCLFBXSQRC();
                    changeCLFBXSQRC = (ChangeCLFBXSQRC)JsonConvert.DeserializeObject(CsJson, typeof(ChangeCLFBXSQRC));

                    isclf = 1;
                }
                else if (returnhash["BillNo"].ToString().Contains("TXF") || returnhash["BillNo"].ToString().Contains("JTF"))
                {
                    //前端传入数据
                    changeQTSQRC = new ChangeQTSQRC();
                    changeQTSQRC = (ChangeQTSQRC)JsonConvert.DeserializeObject(CsJson, typeof(ChangeQTSQRC));

                    isclf = 2;
                }
                else if (returnhash["BillNo"].ToString().Contains("ZDF"))
                {
                    //前端传入数据
                    changeZDSQRC = new ChangeZDSQRC();
                    changeZDSQRC = (ChangeZDSQRC)JsonConvert.DeserializeObject(CsJson, typeof(ChangeZDSQRC));

                    isclf = 3;
                }
                else if (returnhash["BillNo"].ToString().Contains("QTFY"))
                {
                    //前端传入数据
                    changeQTFYSQRC = new ChangeQTFYSQRC();
                    changeQTFYSQRC = (ChangeQTFYSQRC)JsonConvert.DeserializeObject(CsJson, typeof(ChangeQTFYSQRC));

                    isclf = 4;
                }
                string updatedetail    = "";
                string updateCCnum     = "";
                string insertLogMain   = "";
                string insertLogDetail = "";

                if (isclf == 1)
                {
                    updateCCnum = $"update ExpeTrav set CCNum = CCNum -1 where billno = '{changeCLFBXSQRC.BillNo}'";
                    string guid = Guid.NewGuid().ToString();
                    //修改可修改次数减一
                    //保存修改的日志内容
                    insertLogMain   = $"insert into BILLCHANGELOG(GUID,BILLTYPE,BILLNAME,DDID,SPPName,BILLNO,ChangeReason)  values('{guid}','{changeCLFBXSQRC.BillType}','差旅费报销','{changeCLFBXSQRC.SPPDDid}','{changeCLFBXSQRC.SPPName}','{changeCLFBXSQRC.BillNo}','{changeCLFBXSQRC.ChangeReason}')";
                    insertLogDetail = $"INSERT INTO ExpeTravDetailLOG(BillNo, Detailno, CustCode, DepaDate, RetuDate , DepaCity, DestCity, TranMode, TranCount, TranAmount, AlloDay,AlloPric,AlloAmount, AccoCount, AccoAmount , CityTrafCount , CityTraAmont , TotalAmount, GUID , OtherFee , GasAmount , HSRAmount , OffDay , TaxAmount , TripNo, DepaCity1, DestCity1, MAINGUID) SELECT BillNo, Detailno, CustCode, DepaDate, RetuDate , DepaCity, DestCity, TranMode, TranCount, TranAmount, AlloDay,AlloPric,AlloAmount, AccoCount, AccoAmount , CityTrafCount , CityTraAmont , TotalAmount, GUID , OtherFee , GasAmount , HSRAmount , OffDay , TaxAmount , TripNo, DepaCity1, DestCity1, '{guid}' FROM ExpeTravDetail  where  BillNo='{changeCLFBXSQRC.BillNo}'";

                    sqlList.Clear();
                    sqlList.Add(updateCCnum);
                    sqlList.Add(insertLogMain);
                    sqlList.Add(insertLogDetail);
                    da.ExecSql(sqlList);
                    sqlList.Clear();

                    #region 修改差旅费

                    //,isnull(B.TripNo,0) TripNo,convert(varchar(20),B.DepaDate,120) DepaDate,convert(varchar(20),B.RetuDate,120) RetuDate,B.DepaCity,B.DestCity,B.CustCode,e.CustName,B.DetailNo,B.AlloDay,B.OffDay,AlloPric, AlloAmount,OtherFee,B.TranMode,B.TranCount,TranAmount,GasAmount,HsrAmount,B.AccoCount,AccoAmount,B.CityTrafCount,CityTraAmont,TotalAmount
                    for (int i = 0; i < changeCLFBXSQRC.ExpeTravDetail.Length; i++)
                    {
                        double ta = 0.00;
                        ta           = double.Parse(changeCLFBXSQRC.ExpeTravDetail[i].TranAmount) + double.Parse(changeCLFBXSQRC.ExpeTravDetail[i].AlloAmount) + double.Parse(changeCLFBXSQRC.ExpeTravDetail[i].OtherFee);
                        updatedetail = $"update ExpeTravDetail set TranCount ='{changeCLFBXSQRC.ExpeTravDetail[i].TranCount}',TranAmount='{changeCLFBXSQRC.ExpeTravDetail[i].TranAmount}',AlloDay='{changeCLFBXSQRC.ExpeTravDetail[i].AlloDay}',AlloPric='{changeCLFBXSQRC.ExpeTravDetail[i].AlloPric}',AlloAmount='{changeCLFBXSQRC.ExpeTravDetail[i].AlloAmount}',AccoCount='{changeCLFBXSQRC.ExpeTravDetail[i].AccoCount}',AccoAmount='{changeCLFBXSQRC.ExpeTravDetail[i].AccoAmount}',CityTrafCount='{changeCLFBXSQRC.ExpeTravDetail[i].CityTrafCount}',CityTraAmont='{changeCLFBXSQRC.ExpeTravDetail[i].CityTraAmont}',TotalAmount='{ta}',OtherFee='{changeCLFBXSQRC.ExpeTravDetail[i].OtherFee}',DepaDate='{changeCLFBXSQRC.ExpeTravDetail[i].DepaDate}',RetuDate='{changeCLFBXSQRC.ExpeTravDetail[i].RetuDate}',DepaCity='{changeCLFBXSQRC.ExpeTravDetail[i].DepaCity}',DestCity='{changeCLFBXSQRC.ExpeTravDetail[i].DestCity}',GasAmount='{changeCLFBXSQRC.ExpeTravDetail[i].GasAmount}',HSRAmount='{changeCLFBXSQRC.ExpeTravDetail[i].HsrAmount}',TranMode='{changeCLFBXSQRC.ExpeTravDetail[i].TranMode}',OffDay='{changeCLFBXSQRC.ExpeTravDetail[i].OffDay}'  where BillNo = '{changeCLFBXSQRC.BillNo}' and Detailno = '{changeCLFBXSQRC.ExpeTravDetail[i].DetailNo}' and TripNo='{changeCLFBXSQRC.ExpeTravDetail[i].TripNo}'";
                        sqlTou.Clear();
                        sqlTou.Append(updatedetail);
                        sqlList.Add(sqlTou.ToString());
                        ToolsClass.TxtLog("审批信息修改日志", "\r\n执行的sql语句:" + updatedetail + "\r\n");
                    }

                    string ss = da.ExecSql(sqlList);
                    da.ExecSql($"update ExpeTravDetail");
                    ToolsClass.TxtLog("审批信息修改日志", "\r\n执行的sql语句返回:" + ss + "\r\n");
                    if (ss == null)
                    {
                        context.Response.Write("{\"errmsg\":\"更新流程失败\",\"errcode\":1}");
                        return;
                    }

                    ToolsClass.TxtLog("审批信息修改日志", $"\r\n 修改单据明细:{updatedetail} \r\n  修改可修改次数:{updateCCnum}  \r\n    保存日志主表:{insertLogMain} \r\n   保存日志明细:{insertLogDetail}");

                    #endregion 修改差旅费
                }
                else if (isclf == 2)
                {
                    //修改可修改次数减一
                    updateCCnum = $"update ExpeOther set CCNum = CCNum -1 where billno = '{changeQTSQRC.BillNo}'";
                    string guid = Guid.NewGuid().ToString();

                    //保存修改的日志内容
                    insertLogMain   = $"insert into BILLCHANGELOG(GUID,BILLTYPE,BILLNAME,DDID,SPPName,BILLNO,ChangeReason)  values('{guid}','{changeQTSQRC.BillType}','交通费、通讯费报销','{changeQTSQRC.SPPDDid}','{changeQTSQRC.SPPName}','{changeQTSQRC.BillNo}','{changeQTSQRC.ChangeReason}')";
                    insertLogDetail = $"INSERT INTO ExpeOtherLOG(BillNo,BillDate,FeeType ,ApplPers,BearOrga,BillCount,FeeAmount,Notes ,OperatorGuid,IsAuditing ,AuditingGUID ,AuditingDate,IsAccount ,AccountGUID ,AccountDate,REALDATE,ISREFER,REFERGUID,REFERDATE ,NoCountFee ,DDOperatorId,DDAuditingId ,AppendixUrl ,PictureUrl ,SelAuditingGuid ,SelAuditingName,CopypersonID ,CopyPersonName ,IsSp ,AuditingIdea,ProcessNodeInfo,Urls,DeptCode ,DeptName ,CCNum,MAINGUID) SELECT BillNo,BillDate,FeeType ,ApplPers,BearOrga,BillCount,FeeAmount,Notes ,OperatorGuid,IsAuditing ,AuditingGUID ,AuditingDate,IsAccount ,AccountGUID ,AccountDate,REALDATE,ISREFER,REFERGUID,REFERDATE ,NoCountFee ,DDOperatorId,DDAuditingId ,AppendixUrl ,PictureUrl ,SelAuditingGuid ,SelAuditingName,CopypersonID ,CopyPersonName ,IsSp ,AuditingIdea,ProcessNodeInfo,Urls,DeptCode ,DeptName ,CCNum, '{guid}' FROM ExpeOther  where  BillNo='{changeQTSQRC.BillNo}'";

                    sqlList.Clear();
                    sqlList.Add(updateCCnum);
                    sqlList.Add(insertLogMain);
                    sqlList.Add(insertLogDetail);
                    da.ExecSql(sqlList);

                    updatedetail = $"update ExpeOther set BillCount='{changeQTSQRC.BillCount}',FeeAmount='{changeQTSQRC.FeeAmount}'  where BillNo = '{changeQTSQRC.BillNo}'";

                    if (da.ExecSql(updatedetail) == null)
                    {
                        context.Response.Write("{\"errmsg\":\"更新流程失败\",\"errcode\":1}");
                        return;
                    }

                    ToolsClass.TxtLog("审批信息修改日志", $"\r\n 修改单据明细:{updatedetail} \r\n  修改可修改次数:{updateCCnum}  \r\n    保存日志主表:{insertLogMain} \r\n   保存日志明细:{insertLogDetail}");
                }
                else if (isclf == 3)
                {
                    //修改可修改次数减一
                    updateCCnum = $"update ExpeEnteMent set CCNum = CCNum -1 where billno = '{changeZDSQRC.BillNo}'";
                    string guid = Guid.NewGuid().ToString();

                    //保存修改的日志内容
                    insertLogMain   = $"insert into BILLCHANGELOG(GUID,BILLTYPE,BILLNAME,DDID,SPPName,BILLNO,ChangeReason)  values('{guid}','{changeZDSQRC.BillType}','招待费报销','{changeZDSQRC.SPPDDid}','{changeZDSQRC.SPPName}','{changeZDSQRC.BillNo}','{changeZDSQRC.ChangeReason}')";
                    insertLogDetail = $"INSERT INTO ExpeEnteMentLOG( BillNo,BillDate,ApplPers,BearOrga ,CustCode ,BillCount,FeeAmount ,Notes ,OperatorGuid,IsAuditing ,AuditingGUID,AuditingDate ,IsAccount ,AccountGUID,AccountDate,REALDATE ,ISREFER ,REFERGUID ,REFERDATE ,NoCountFee,DDOperatorId,DDAuditingId,AppendixUrl,PictureUrl,SelAuditingGuid ,SelAuditingName ,CopypersonID ,CopyPersonName,IsSp ,AuditingIdea ,ProcessNodeInfo,Urls,DeptCode,DeptName ,CCNum,MAINGUID) SELECT BillNo,BillDate,ApplPers,BearOrga ,CustCode ,BillCount,FeeAmount ,Notes ,OperatorGuid,IsAuditing ,AuditingGUID,AuditingDate ,IsAccount ,AccountGUID,AccountDate,REALDATE ,ISREFER ,REFERGUID ,REFERDATE ,NoCountFee,DDOperatorId,DDAuditingId,AppendixUrl,PictureUrl,SelAuditingGuid ,SelAuditingName ,CopypersonID ,CopyPersonName,IsSp ,AuditingIdea ,ProcessNodeInfo,Urls,DeptCode,DeptName ,CCNum, '{guid}' FROM ExpeEnteMent  where  BillNo='{changeZDSQRC.BillNo}'";

                    sqlList.Clear();
                    sqlList.Add(updateCCnum);
                    sqlList.Add(insertLogMain);
                    sqlList.Add(insertLogDetail);
                    da.ExecSql(sqlList);

                    updatedetail = $"update ExpeEnteMent set BillCount='{changeZDSQRC.BillCount}',FeeAmount='{changeZDSQRC.FeeAmount}'  where BillNo = '{changeZDSQRC.BillNo}'";

                    if (da.ExecSql(updatedetail) == null)
                    {
                        context.Response.Write("{\"errmsg\":\"更新流程失败\",\"errcode\":1}");
                        return;
                    }

                    ToolsClass.TxtLog("审批信息修改日志", $"\r\n 修改单据明细:{updatedetail} \r\n  修改可修改次数:{updateCCnum}  \r\n    保存日志主表:{insertLogMain} \r\n   保存日志明细:{insertLogDetail}");
                }
                else if (isclf == 4)
                {
                    //修改可修改次数减一
                    updateCCnum = $"update ExpeOther set CCNum = CCNum -1 where billno = '{changeQTFYSQRC.BillNo}'";
                    string guid = Guid.NewGuid().ToString();

                    //保存修改的日志内容
                    insertLogMain   = $"insert into BILLCHANGELOG(GUID,BILLTYPE,BILLNAME,DDID,SPPName,BILLNO,ChangeReason)  values('{guid}','{changeQTFYSQRC.BillType}','其他费用报销','{changeQTFYSQRC.SPPDDid}','{changeQTFYSQRC.SPPName}','{changeQTFYSQRC.BillNo}','{changeQTFYSQRC.ChangeReason}')";
                    insertLogDetail = $"INSERT INTO ExpeOtherLOG(BillNo,BillDate,FeeType ,ApplPers,BearOrga,BillCount,FeeAmount,Notes ,OperatorGuid,IsAuditing ,AuditingGUID ,AuditingDate,IsAccount ,AccountGUID ,AccountDate,REALDATE,ISREFER,REFERGUID,REFERDATE ,NoCountFee ,DDOperatorId,DDAuditingId ,AppendixUrl ,PictureUrl ,SelAuditingGuid ,SelAuditingName,CopypersonID ,CopyPersonName ,IsSp ,AuditingIdea,ProcessNodeInfo,Urls,DeptCode ,DeptName ,CCNum,MAINGUID) SELECT BillNo,BillDate,FeeType ,ApplPers,BearOrga,BillCount,FeeAmount,Notes ,OperatorGuid,IsAuditing ,AuditingGUID ,AuditingDate,IsAccount ,AccountGUID ,AccountDate,REALDATE,ISREFER,REFERGUID,REFERDATE ,NoCountFee ,DDOperatorId,DDAuditingId ,AppendixUrl ,PictureUrl ,SelAuditingGuid ,SelAuditingName,CopypersonID ,CopyPersonName ,IsSp ,AuditingIdea,ProcessNodeInfo,Urls,DeptCode ,DeptName ,CCNum, '{guid}' FROM ExpeOther  where  BillNo='{changeQTFYSQRC.BillNo}'";

                    sqlList.Clear();
                    sqlList.Add(updateCCnum);
                    sqlList.Add(insertLogMain);
                    sqlList.Add(insertLogDetail);
                    ToolsClass.TxtLog("审批信息修改日志", $"\r\n 修改可修改次数:{updateCCnum}  \r\n    保存日志主表:{insertLogMain} \r\n   保存日志明细:{insertLogDetail}");
                    da.ExecSql(sqlList);

                    sqlList.Clear();
                    for (int i = 0; i < changeQTFYSQRC.OtherCostSQModels.Count; i++)
                    {
                        updatedetail = $"insert into ExpeOtherDetailLOG(BillNo,MAINGUID,BillCount,BillAmount,FeeTypeDetail) values('{changeQTFYSQRC.BillNo}','{guid}','{changeQTFYSQRC.OtherCostSQModels[i].Count}','{changeQTFYSQRC.OtherCostSQModels[i].Amount}','{changeQTFYSQRC.OtherCostSQModels[i].FType}')";
                        sqlList.Add(updatedetail);
                        ToolsClass.TxtLog("审批信息修改日志", "\r\n执行的sql语句:" + updatedetail + "\r\n");
                    }
                    da.ExecSql(sqlList);
                    sqlList.Clear();
                    updatedetail = $"update ExpeOther set BillCount='{changeQTFYSQRC.BillCount}',FeeAmount='{changeQTFYSQRC.FeeAmount}'  where BillNo = '{changeQTFYSQRC.BillNo}'";
                    da.ExecSql(updatedetail);
                    ToolsClass.TxtLog("审批信息修改日志", "\r\n执行的sql语句:" + updatedetail + "\r\n");
                    for (int i = 0; i < changeQTFYSQRC.OtherCostSQModels.Count; i++)
                    {
                        updatedetail = string.Empty;
                        updatedetail = $"update ExpeOtherDetail set BillCount ='{changeQTFYSQRC.OtherCostSQModels[i].Count}',BillAmount='{changeQTFYSQRC.OtherCostSQModels[i].Amount}'  where BillNo = '{changeQTFYSQRC.BillNo}' and FeeTypeDetail = '{changeQTFYSQRC.OtherCostSQModels[i].FType}'";
                        sqlTou.Clear();
                        sqlTou.Append(updatedetail);
                        sqlList.Add(sqlTou.ToString());
                        ToolsClass.TxtLog("审批信息修改日志", "\r\n执行的sql语句:" + updatedetail + "\r\n");
                    }
                    da.ExecSql(sqlList);
                    if (da.ExecSql(updatedetail) == null)
                    {
                        context.Response.Write("{\"errmsg\":\"更新流程失败\",\"errcode\":1}");
                        return;
                    }
                }
                context.Response.Write("{\"errmsg\":\"ok\",\"errcode\":0}");
                return;
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"errmsg\":\"" + ex.Message + "\",\"errcode\":1}");
                context.Response.End();
            }
        }
コード例 #6
0
        public void ProcessRequest(HttpContext context)
        {
            //判断客户端请求是否为post方法
            if (context.Request.HttpMethod.ToUpper() != "POST")
            {
                context.Response.Write("{\"errmsg\":\"请求方式不允许,请使用POST方式(DD0001)\",\"errcode\":1}");
                return;
            }
            string ymadk = System.Configuration.ConfigurationManager.AppSettings["ymadk"].ToString() + "/";

            //数据库链接
            connectionString = ToolsClass.GetConfig("DataOnLine");

            SqlHelper = new BankDbHelper.SqlHelper("SqlServer", connectionString);
            string signUrl   = ToolsClass.GetConfig("signUrl"); context.Response.ContentType = "text/plain";
            string tableName = ToolsClass.GetConfig("tableName");

            //获取请求json
            using (var reader = new StreamReader(context.Request.InputStream, Encoding.UTF8))
            {
                CsJson = reader.ReadToEnd();
            }

            Object jgobj = ToolsClass.DeserializeObject(CsJson);

            CsJson = Regex.Replace(CsJson, @"[\n\r]", "").Replace(@"\n", ",").Replace("'", "‘").Replace("\t", ":").Replace("\r", ",").Replace("\n", ",");

            ToolsClass.TxtLog("差旅费明细修改日志", "\r\n入参:" + CsJson + "\r\n");
            CDChange cDChange = new CDChange();

            cDChange = (CDChange)JsonConvert.DeserializeObject(CsJson, typeof(CDChange));
            string path = context.Request.Path.Replace("Common/CLFBXDetailChange.ashx", "clfbxdetailchange");
            //验证请求sign
            string sign = ToolsClass.md5(signUrl + path + "Romens1/DingDing2" + path, 32);

            ToolsClass.TxtLog("生成的sign", "生成的" + sign + "传入的sign" + cDChange.Sign + "\r\n 后台字符串:" + signUrl + path + "Romens1/DingDing2" + path);
            if (sign != cDChange.Sign)
            {
                context.Response.Write("{\"errmsg\":\"认证信息Sign不存在或者不正确!\",\"errcode\":1}");
                return;
            }
            try
            {
                List <SqlHelperParameter> sqlHelperParameters = new List <SqlHelperParameter>();
                string    selectAllErrorDetail = $"select * from {tableName} where billno = '{cDChange.BillNo}' order by detailno";
                DataTable AllErrorDetaildt     = SqlHelper.GetDataTable(selectAllErrorDetail);
                int       detailno             = int.Parse(AllErrorDetaildt.Rows[AllErrorDetaildt.Rows.Count - 1]["DetailNo"].ToString()) + 1;
                for (int i = 0; i < AllErrorDetaildt.Rows.Count; i++)
                {
                    if (AllErrorDetaildt.Rows[i]["TranMode"].ToString() == "自驾")
                    {
                        SqlHelper.ExecSql($"update {tableName} set TranAmount = GasAmount + HSRAmount,GasAmount=0,HSRAmount=0 where guid = '{AllErrorDetaildt.Rows[i]["guid"].ToString()}'");
                    }

                    //拆除住宿费
                    if (AllErrorDetaildt.Rows[i]["AccoCount"].ToString() != "0")
                    {
                        //判断当前交通方式
                        if (AllErrorDetaildt.Rows[i]["TranMode"].ToString() == "住宿")
                        {
                            SqlHelper.ExecSql($"update {tableName} set TranCount = AccoCount,TranAmount =AccoAmount,AccoCount='0',AccoAmount='0' where guid = '{AllErrorDetaildt.Rows[i]["guid"].ToString()}'");
                        }
                        else
                        {
                            sqlHelperParameters.Clear();
                            string guid = Guid.NewGuid().ToString();
                            //新增住宿费单子
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@TripNo", Value = AllErrorDetaildt.Rows[i]["TripNo"].ToString(), Size = AllErrorDetaildt.Rows[i]["TripNo"].ToString().Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@BillNo", Value = AllErrorDetaildt.Rows[i]["BillNo"].ToString(), Size = AllErrorDetaildt.Rows[i]["BillNo"].ToString().Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@Guid", Value = guid, Size = guid.Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@DepaDate", Value = AllErrorDetaildt.Rows[i]["DepaDate"].ToString(), Size = AllErrorDetaildt.Rows[i]["DepaDate"].ToString().Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@RetuDate", Value = AllErrorDetaildt.Rows[i]["RetuDate"].ToString(), Size = AllErrorDetaildt.Rows[i]["RetuDate"].ToString().Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@DepaCity", Value = AllErrorDetaildt.Rows[i]["DepaCity"].ToString(), Size = AllErrorDetaildt.Rows[i]["DepaCity"].ToString().Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@DestCity", Value = AllErrorDetaildt.Rows[i]["DestCity"].ToString(), Size = AllErrorDetaildt.Rows[i]["DestCity"].ToString().Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@DepaCity1", Value = AllErrorDetaildt.Rows[i]["DepaCity1"].ToString(), Size = AllErrorDetaildt.Rows[i]["DepaCity1"].ToString().Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@DestCity1", Value = AllErrorDetaildt.Rows[i]["DestCity1"].ToString(), Size = AllErrorDetaildt.Rows[i]["DestCity1"].ToString().Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@CustCode", Value = AllErrorDetaildt.Rows[i]["CustCode"].ToString(), Size = AllErrorDetaildt.Rows[i]["CustCode"].ToString().Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@DetailNo", Value = detailno, Size = detailno.ToString().Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@AlloDay", Value = "0", Size = "0".Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@OffDay", Value = AllErrorDetaildt.Rows[i]["OffDay"].ToString(), Size = AllErrorDetaildt.Rows[i]["OffDay"].ToString().Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@AlloPric", Value = "0", Size = "0".Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@AlloAmount", Value = "0", Size = "0".Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@OtherFee", Value = "0", Size = "0".Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@TranMode", Value = "住宿", Size = "住宿".Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@TranCount", Value = AllErrorDetaildt.Rows[i]["AccoCount"].ToString(), Size = AllErrorDetaildt.Rows[i]["AccoCount"].ToString().Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@TranAmount", Value = AllErrorDetaildt.Rows[i]["AccoAmount"].ToString(), Size = AllErrorDetaildt.Rows[i]["AccoAmount"].ToString().Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@TotalAmount", Value = AllErrorDetaildt.Rows[i]["AccoAmount"].ToString(), Size = AllErrorDetaildt.Rows[i]["AccoAmount"].ToString().Length
                            });
                            var result = SqlHelper.ExecSql($"insert into {tableName}(TripNo, BillNo, Guid, DepaDate, RetuDate, DepaCity, DestCity, DepaCity1, DestCity1, CustCode, DetailNo, AlloDay, OffDay, AlloPric, AlloAmount, OtherFee, TranMode, TranCount, TranAmount, GasAmount, HsrAmount, AccoCount, AccoAmount, CityTrafCount, CityTraAmont, TotalAmount,TaxAmount) values(@TripNo, @BillNo, @Guid, @DepaDate, @RetuDate, @DepaCity, @DestCity, @DepaCity1, @DestCity1, @CustCode, @DetailNo, @AlloDay, @OffDay, @AlloPric, @AlloAmount, @OtherFee, @TranMode, @TranCount, @TranAmount, '0','0', '0','0', '0', '0', @TotalAmount,'0')", sqlHelperParameters);
                            if (!string.IsNullOrEmpty(result))
                            {
                                detailno = detailno + 1;
                                SqlHelper.ExecSql($"update {tableName} set TotalAmount = TotalAmount-AccoAmount,AccoCount='0',AccoAmount='0' where guid = '{AllErrorDetaildt.Rows[i]["guid"].ToString()}'");
                            }
                        }
                    }
                    //拆除交通费
                    if (AllErrorDetaildt.Rows[i]["CityTrafCount"].ToString() != "0")
                    {
                        //判断当前交通方式
                        if (AllErrorDetaildt.Rows[i]["TranMode"].ToString() == "市内交通")
                        {
                            SqlHelper.ExecSql($"update {tableName} set TranCount = CityTrafCount,TranAmount =CityTraAmont,CityTrafCount='0',CityTraAmont='0'  where guid = '{AllErrorDetaildt.Rows[i]["guid"].ToString()}'");
                        }
                        else
                        { //新增市内交通单子
                            string guid = Guid.NewGuid().ToString();
                            sqlHelperParameters.Clear();
                            //新增住宿费单子
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@TripNo", Value = AllErrorDetaildt.Rows[i]["TripNo"].ToString(), Size = AllErrorDetaildt.Rows[i]["TripNo"].ToString().Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@BillNo", Value = AllErrorDetaildt.Rows[i]["BillNo"].ToString(), Size = AllErrorDetaildt.Rows[i]["BillNo"].ToString().Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@Guid", Value = guid, Size = guid.Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@DepaDate", Value = AllErrorDetaildt.Rows[i]["DepaDate"].ToString(), Size = AllErrorDetaildt.Rows[i]["DepaDate"].ToString().Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@RetuDate", Value = AllErrorDetaildt.Rows[i]["RetuDate"].ToString(), Size = AllErrorDetaildt.Rows[i]["RetuDate"].ToString().Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@DepaCity", Value = AllErrorDetaildt.Rows[i]["DepaCity"].ToString(), Size = AllErrorDetaildt.Rows[i]["DepaCity"].ToString().Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@DestCity", Value = AllErrorDetaildt.Rows[i]["DestCity"].ToString(), Size = AllErrorDetaildt.Rows[i]["DestCity"].ToString().Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@DepaCity1", Value = AllErrorDetaildt.Rows[i]["DepaCity1"].ToString(), Size = AllErrorDetaildt.Rows[i]["DepaCity1"].ToString().Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@DestCity1", Value = AllErrorDetaildt.Rows[i]["DestCity1"].ToString(), Size = AllErrorDetaildt.Rows[i]["DestCity1"].ToString().Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@CustCode", Value = AllErrorDetaildt.Rows[i]["CustCode"].ToString(), Size = AllErrorDetaildt.Rows[i]["CustCode"].ToString().Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@DetailNo", Value = detailno, Size = detailno.ToString().Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@AlloDay", Value = "0", Size = "0".Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@OffDay", Value = AllErrorDetaildt.Rows[i]["OffDay"].ToString(), Size = AllErrorDetaildt.Rows[i]["OffDay"].ToString().Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@AlloPric", Value = "0", Size = "0".Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@AlloAmount", Value = "0", Size = "0".Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@OtherFee", Value = "0", Size = "0".Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@TranMode", Value = "市内交通", Size = "市内交通".Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@TranCount", Value = AllErrorDetaildt.Rows[i]["CityTrafCount"].ToString(), Size = AllErrorDetaildt.Rows[i]["CityTrafCount"].ToString().Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@TranAmount", Value = AllErrorDetaildt.Rows[i]["CityTraAmont"].ToString(), Size = AllErrorDetaildt.Rows[i]["CityTraAmont"].ToString().Length
                            });
                            sqlHelperParameters.Add(new SqlHelperParameter {
                                Name = "@TotalAmount", Value = AllErrorDetaildt.Rows[i]["CityTraAmont"].ToString(), Size = AllErrorDetaildt.Rows[i]["CityTraAmont"].ToString().Length
                            });
                            var result = SqlHelper.ExecSql($"insert into {tableName}(TripNo, BillNo, Guid, DepaDate, RetuDate, DepaCity, DestCity, DepaCity1, DestCity1, CustCode, DetailNo, AlloDay, OffDay, AlloPric, AlloAmount, OtherFee, TranMode, TranCount, TranAmount, GasAmount, HsrAmount, AccoCount, AccoAmount, CityTrafCount, CityTraAmont, TotalAmount,TaxAmount) values(@TripNo, @BillNo, @Guid, @DepaDate, @RetuDate, @DepaCity, @DestCity, @DepaCity1, @DestCity1, @CustCode, @DetailNo, @AlloDay, @OffDay, @AlloPric, @AlloAmount, @OtherFee, @TranMode, @TranCount, @TranAmount, '0','0', '0','0', '0', '0', @TotalAmount,'0')", sqlHelperParameters);
                            if (!string.IsNullOrEmpty(result))
                            {
                                detailno = detailno + 1;
                                SqlHelper.ExecSql($"update {tableName} set TotalAmount = TotalAmount-CityTraAmont,CityTrafCount='0',CityTraAmont='0' where guid = '{AllErrorDetaildt.Rows[i]["guid"].ToString()}'");
                            }
                        }
                    }
                }
                context.Response.Write("{\"errmsg\":\"ok\",\"errcode\":0}");
                return;
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"errmsg\":\"" + ex.Message + "\",\"errcode\":1}");
                context.Response.End();
            }
        }