Kaynağa Gözat

1、添加从维德系统获取数据的接口工程
2、修改导入数据和更新数据从接口中获取维德系统的数据

luocaiyang 2 yıl önce
ebeveyn
işleme
d246c78c25

+ 6 - 0
wispro.sp.api/Controllers/StaffController.cs

@@ -173,6 +173,12 @@ namespace wispro.sp.api.Controllers
                             foreach(var staff in temStaffs)
                             {
                                 if(retStaffs.FirstOrDefault(s=>s.Id == staff.Id) == null) {
+                                    staff.Customers = null;
+                                    staff.StaffGrade = null;
+                                    staff.ItemStaffs = null;
+                                    staff.Positions = null;
+                                    staff.ReviewerItems = null;
+                                    
                                     retStaffs.Add(staff);
                                 }
                             }

+ 85 - 61
wispro.sp.api/Job/ImportProjectInfoJob.cs

@@ -7,6 +7,9 @@ using System.Threading.Tasks;
 using wispro.sp.entity;
 using wispro.sp.utility;
 using System.Linq;
+using System.IO;
+using System.Net.Http;
+using System.Xml.Serialization;
 
 namespace wispro.sp.api.Job
 {
@@ -369,65 +372,86 @@ namespace wispro.sp.api.Job
         }
         private DataTable GetDataFromIPEasy()
 		{
-			DataTable dt = new DataTable();
-			string strSQL = @"SELECT  p_case_info.case_volume as 我方文号,
-	                        p_case_info.case_volume_customer as 客户文号,
-	                        p_case_info.case_name as 案件名称,
-	                        p_case_info.charge_date as 委案日期,
-	                        i_case_status.case_status_zh_cn as 案件状态,
-	                        i_case_type.case_type_zh_cn as 案件类型,
-	                        p_case_info.app_no as 申请号,
-	                        p_case_info.app_date as 申请日,
-	                        i_business_type.business_type_zh_cn as 业务类型,
-	                        STUFF((SELECT ',' + u.cn_name from c_customer_user as cu 
-		                        inner join s_user_info as u on u.user_id = cu.user_id where cu.customer_id = p_case_info.customer_id FOR XML PATH('') ),1,1,'') as 流程负责人,
-	                        c_customer.customer_name as 客户名称,
-	                        STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl
-		                        inner join s_user_info as u on u.user_id = pl.revise_user_id where pl.obj_id = p_case_info.case_id   FOR XML PATH('') ),1,1,'') as 案件核稿人,
-	                        STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
-		                        inner join s_user_info as u on u.user_id = pl.pic_id where pl.obj_id = p_case_info.case_id   FOR XML PATH('') ),1,1,'') as 案件处理人,
-	                        p_case_info.create_time as 开卷日期,
-	                        STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl 
-		                        inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id 
-		                        where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员,
-	                        i_country.country_zh_cn as '国家(地区)'  
-                        from p_case_info
-	                        inner join   p_case_advance_info  with(nolock)  on p_case_info.case_id=p_case_advance_info.case_id  
-	                        inner join   i_apply_type  with(nolock)  on i_apply_type.apply_type_id=p_case_info.apply_type_id  
-	                        inner join   i_case_type  with(nolock)  on i_case_type.case_type_id=p_case_info.case_type_id  
-	                        inner join   i_country  with(nolock)  on i_country.country_id=p_case_info.country_id  
-	                        inner join   i_case_status  with(nolock)  on i_case_status.case_status_id=p_case_info.case_status_id  
-	                        inner join   c_customer  with(nolock)  on c_customer.customer_id=p_case_info.customer_id  
-	                        inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id 
-	                        inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id 
-                        where p_case_info.is_enabled=1 and  p_case_info.case_volume like 'S%' and not p_case_info.case_volume like 'SCN%'
-						and i_case_status.case_status_zh_cn<>'已完成' and i_case_status.case_status_zh_cn<>'结案'
-						order by 我方文号";
-					
-
-
-			using (var conn = new SqlConnection(ConfigHelper.GetSectionValue("IPEasySetting:ConnectionStrings")))
-			{
-				try
-				{
-					conn.Open();
-					using (var cmd = conn.CreateCommand())
-					{
-						cmd.CommandText = strSQL;
-						cmd.CommandType = CommandType.Text;
-						
-						using (var reader = cmd.ExecuteReader())
-						{
-							dt.Load(reader);
-						}
-					}
-				}
-				catch (Exception ex)
-				{
-					throw ex;
-				}
-			}
-			return dt;
-		}
-	}
+            HttpClient http = new HttpClient();
+            var bytRespon = http.GetAsync($"{ConfigHelper.GetSectionValue("IPEasySetting:ipEeasyApi")}/api/ipEasy/getProjectDataFromIPEasy").Result;
+
+            if (bytRespon.IsSuccessStatusCode)
+            {
+                string result = bytRespon.Content.ReadAsStringAsync().Result.Replace("\"", string.Empty);
+                byte[] data = Convert.FromBase64String(result);
+                //byte[] data = bytRespon.Content.ReadAsByteArrayAsync().Result;//Here is the problem
+                XmlSerializer serializer = new XmlSerializer(typeof(System.Data.DataTable));
+                MemoryStream memory = new MemoryStream(data);
+                DataTable dt = (DataTable)serializer.Deserialize(memory);
+
+                return dt;
+            }
+            else
+            {
+                return null;
+            }
+
+            #region old Code
+            //         DataTable dt = new DataTable();
+            //string strSQL = @"SELECT  p_case_info.case_volume as 我方文号,
+            //                      p_case_info.case_volume_customer as 客户文号,
+            //                      p_case_info.case_name as 案件名称,
+            //                      p_case_info.charge_date as 委案日期,
+            //                      i_case_status.case_status_zh_cn as 案件状态,
+            //                      i_case_type.case_type_zh_cn as 案件类型,
+            //                      p_case_info.app_no as 申请号,
+            //                      p_case_info.app_date as 申请日,
+            //                      i_business_type.business_type_zh_cn as 业务类型,
+            //                      STUFF((SELECT ',' + u.cn_name from c_customer_user as cu 
+            //                       inner join s_user_info as u on u.user_id = cu.user_id where cu.customer_id = p_case_info.customer_id FOR XML PATH('') ),1,1,'') as 流程负责人,
+            //                      c_customer.customer_name as 客户名称,
+            //                      STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl
+            //                       inner join s_user_info as u on u.user_id = pl.revise_user_id where pl.obj_id = p_case_info.case_id   FOR XML PATH('') ),1,1,'') as 案件核稿人,
+            //                      STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
+            //                       inner join s_user_info as u on u.user_id = pl.pic_id where pl.obj_id = p_case_info.case_id   FOR XML PATH('') ),1,1,'') as 案件处理人,
+            //                      p_case_info.create_time as 开卷日期,
+            //                      STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl 
+            //                       inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id 
+            //                       where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员,
+            //                      i_country.country_zh_cn as '国家(地区)'  
+            //                     from p_case_info
+            //                      inner join   p_case_advance_info  with(nolock)  on p_case_info.case_id=p_case_advance_info.case_id  
+            //                      inner join   i_apply_type  with(nolock)  on i_apply_type.apply_type_id=p_case_info.apply_type_id  
+            //                      inner join   i_case_type  with(nolock)  on i_case_type.case_type_id=p_case_info.case_type_id  
+            //                      inner join   i_country  with(nolock)  on i_country.country_id=p_case_info.country_id  
+            //                      inner join   i_case_status  with(nolock)  on i_case_status.case_status_id=p_case_info.case_status_id  
+            //                      inner join   c_customer  with(nolock)  on c_customer.customer_id=p_case_info.customer_id  
+            //                      inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id 
+            //                      inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id 
+            //                     where p_case_info.is_enabled=1 and  p_case_info.case_volume like 'S%' and not p_case_info.case_volume like 'SCN%'
+            //			and i_case_status.case_status_zh_cn<>'已完成' and i_case_status.case_status_zh_cn<>'结案'
+            //			order by 我方文号";
+
+
+
+            //using (var conn = new SqlConnection(ConfigHelper.GetSectionValue("IPEasySetting:ConnectionStrings")))
+            //{
+            //	try
+            //	{
+            //		conn.Open();
+            //		using (var cmd = conn.CreateCommand())
+            //		{
+            //			cmd.CommandText = strSQL;
+            //			cmd.CommandType = CommandType.Text;
+
+            //			using (var reader = cmd.ExecuteReader())
+            //			{
+            //				dt.Load(reader);
+            //			}
+            //		}
+            //	}
+            //	catch (Exception ex)
+            //	{
+            //		throw ex;
+            //	}
+            //}
+            //return dt;
+            #endregion
+        }
+    }
 }

+ 352 - 325
wispro.sp.api/Job/ImportReportJob.cs

@@ -6,10 +6,14 @@ using System;
 using System.Collections.Generic;
 using System.Configuration;
 using System.Data;
+using System.IO;
 using System.Linq;
+using System.Net.Http;
 using System.Threading.Tasks;
+using System.Xml.Serialization;
 using wispro.sp.entity;
 using wispro.sp.utility;
+using static System.Net.WebRequestMethods;
 
 namespace wispro.sp.api.Job
 {
@@ -627,336 +631,359 @@ namespace wispro.sp.api.Job
 
         private DataTable GetDataFromIPEasy(string ReportName, bool isModifyDate)
         {
-            DataTable dt = new DataTable();
-            string strSQL = "";
-            switch (ReportName)
-            {
-                case "每月绩效统计--发客户超过一个月未完成案件":
-                    strSQL = @"SELECT  p_case_info.case_volume as 我方文号,
-		                i_apply_type.apply_type_zh_cn as 申请类型,
-		                i_business_type.business_type_zh_cn as 业务类型,
-		                i_ctrl_proc.ctrl_proc_zh_cn as 处理事项,
-		                (select case_status_zh_cn from i_case_status where case_status_id=p_proc_info.review_stage)  as 案件阶段,
-		                i_case_coefficient.case_coefficient_zh_cn as 案件系数,
-		                i_proc_coefficient.proc_coefficient_zh_cn as 处理事项系数,
-		                (select  proc_coefficient_zh_cn from p_proc_info pr 
-			                left join i_proc_coefficient pc on pc.proc_coefficient_id=pr.proc_coefficient_id 
-			                where case_id=p_case_info.case_id and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5' 
-				                and pr.seq=
-					                (select max(seq) from p_proc_info pr where case_id=p_case_info.case_id 
-						                and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'and seq<p_proc_info.seq)
-					                ) as 前一次OA处理事项系数,
-		                (STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
-			                inner join s_user_info as u on u.user_id = pl.pic_id 
-			                inner join  p_proc_info pr1 on pr1.proc_id=pl.obj_id 
-				                where case_id=p_case_info.case_id and 
-					                ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5' 
-					                and pr1.seq=(
-						                select max(seq) from p_proc_info pr2 where case_id=p_case_info.case_id 
-						                and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5' 
-						                and seq<p_proc_info.seq) FOR XML PATH('') ),1,1,'')) as 前一次OA处理人,
-		                STUFF((SELECT ',' + ur.rank_zh_cn from p_proc_pic_list as pl   
-			                inner join s_user_info as u on u.user_id = pl.pic_id 
-			                left join i_user_rank ur on ur.rank_id=u.rank_id 
-			                where pl.obj_id = p_proc_info.proc_id   FOR XML PATH('') ),1,1,'') as 处理人等级,
-		                STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl   
-			                inner join s_user_info as u on u.user_id = pl.pic_id 
-			                where pl.obj_id = p_proc_info.proc_id   FOR XML PATH('') ),1,1,'') as 处理人,
-		                STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl   
-			                inner join s_user_info as u on u.user_id = pl.revise_user_id 
-			                where pl.obj_id = p_proc_info.proc_id   FOR XML PATH('') ),1,1,'') as 核稿人,
-		                c_customer.customer_name as 客户名称,
-		                STUFF((SELECT ',' + a.applicant_name_cn from p_applicant_list as al 
-			                inner join i_applicant as a on a.applicant_id = al.applicant_id 
-			                where al.obj_id = p_case_info.case_id order by al.seq FOR XML PATH('') ),1,1,'') as 申请人,
-		                p_proc_info.finish_date as 处理事项完成日,
-		                p_proc_info.finish_doc_date as 定稿日,
-		                p_proc_info.back_date as 返稿日,
-		                i_case_type.case_type_zh_cn as 案件类型,
-		                i_case_status.case_status_zh_cn as 案件状态,
-		                p_proc_info.proc_note as 处理事项备注,
-		                (select proc_status_zh_cn from i_proc_status where proc_status_id=p_proc_info.proc_status_id) as 处理状态,
-		                p_case_info.case_name as 案件名称,
-		                p_case_info.charge_date as 委案日期,
-		                p_proc_info.cus_due_date as 客户期限,
-		                p_proc_info.int_due_date as 内部期限,
-		                p_proc_info.first_doc_date as 初稿日,
-		                p_case_info.remark as 案件备注,
-		                p_proc_info.translate_count as 翻译字数,
-		                STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl 
-			                inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id 
-			                where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员,
-		                i_country.country_zh_cn as '国家(地区)'  
-	                from p_case_info  
-		                inner join   p_case_advance_info  with(nolock)  on p_case_info.case_id=p_case_advance_info.case_id  
-		                inner join   i_apply_type  with(nolock)  on i_apply_type.apply_type_id=p_case_info.apply_type_id  
-		                inner join   i_case_type  with(nolock)  on i_case_type.case_type_id=p_case_info.case_type_id  
-		                inner join   i_country  with(nolock)  on i_country.country_id=p_case_info.country_id  
-		                inner join   i_case_status  with(nolock)  on i_case_status.case_status_id=p_case_info.case_status_id  
-		                inner join   c_customer  with(nolock)  on c_customer.customer_id=p_case_info.customer_id 
-		                left join i_case_coefficient on i_case_coefficient.case_coefficient_id=p_case_info.case_coefficient_id  
-		                inner join   p_proc_info  with(nolock)  on p_case_info.case_id=p_proc_info.case_id  
-		                inner join   i_ctrl_proc  with(nolock)  on p_proc_info.ctrl_proc_id=i_ctrl_proc.ctrl_proc_id 
-		                inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id 
-		                inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id 
-		                left join p_proc_pic_list with(nolock) on p_proc_pic_list.obj_id=p_proc_info.proc_id 
-		                left join s_user_info with(nolock) on s_user_info.user_id=p_proc_pic_list.pic_id 
-		                left join i_proc_coefficient on i_proc_coefficient.proc_coefficient_id=p_proc_info.proc_coefficient_id 
-	                where 
-		                p_case_info.is_enabled=1 and p_proc_info.is_enabled=1 and 
-		                s_user_info.dept_id not in ('60e09ee0-fcc7-446f-badc-af9973079fee','34d0e351-71dc-418f-9b6b-bcb67af62fed','599cbe0c-044e-4ffc-9411-96dd9019d8a6') and 
-		                p_proc_info.finish_date is null 
-		                and p_proc_info.back_date<DATEADD(MM,-1,DATEADD(MM, DATEDIFF(MM,0,getdate()), 0)) and  
-		                (p_case_info.case_type_id='31D1A147-2931-43B5-94AE-B72B1525BA8A'   ) AND  
-		                ( i_ctrl_proc.ctrl_proc_zh_cn='新申请'    
-			                or  i_ctrl_proc.ctrl_proc_zh_cn='Non'    
-			                or  i_ctrl_proc.ctrl_proc_zh_cn='无效宣告'    
-			                or  i_ctrl_proc.ctrl_proc_zh_cn='意见陈述'    
-			                or  i_ctrl_proc.ctrl_proc_zh_cn='专利挖掘与布局'    
-			                or  i_ctrl_proc.ctrl_proc_zh_cn='处理审查意见'    
-			                or  i_ctrl_proc.ctrl_proc_zh_cn='Final'    
-			                or  i_ctrl_proc.ctrl_proc_zh_cn='复审通知意见陈述'    
-			                or  i_ctrl_proc.ctrl_proc_zh_cn='申復'    
-			                or  i_ctrl_proc.ctrl_proc_zh_cn='RCE'    
-			                or  i_ctrl_proc.ctrl_proc_zh_cn='翻译'    
-			                or  i_ctrl_proc.ctrl_proc_zh_cn='提出异议复审'    
-			                or  i_ctrl_proc.ctrl_proc_zh_cn='Advisory'    
-			                or  i_ctrl_proc.ctrl_proc_zh_cn='复审'    
-			                or  i_ctrl_proc.ctrl_proc_zh_cn='请求复审'    
-			                or  i_ctrl_proc.ctrl_proc_zh_cn='提出报告'    
-			                or  i_ctrl_proc.ctrl_proc_zh_cn='提出公众意见'    
-			                or  i_ctrl_proc.ctrl_proc_zh_cn='诉讼'    
-			                or  i_ctrl_proc.ctrl_proc_zh_cn='提出异议'    
-			                or  i_ctrl_proc.ctrl_proc_zh_cn='补充理由和证据'    
-			                or  i_ctrl_proc.ctrl_proc_zh_cn='无效分析'    
-			                or  i_ctrl_proc.ctrl_proc_zh_cn='无效答辩'   
-		                )";
-                    break;
-                case "每月绩效统计--上个月递交完成案件":
-                    strSQL = @"SELECT  
-	                    p_case_info.case_volume as 我方文号,
-	                    i_apply_type.apply_type_zh_cn as 申请类型,
-	                    i_business_type.business_type_zh_cn as 业务类型,
-	                    i_ctrl_proc.ctrl_proc_zh_cn as 处理事项,
-	                    (select case_status_zh_cn from i_case_status where case_status_id=p_proc_info.review_stage)  as 案件阶段,
-	                    i_case_coefficient.case_coefficient_zh_cn as 案件系数,
-	                    i_proc_coefficient.proc_coefficient_zh_cn as 处理事项系数,
-	                    (select  
-		                    proc_coefficient_zh_cn from p_proc_info pr 
-		                    left join i_proc_coefficient pc on pc.proc_coefficient_id=pr.proc_coefficient_id 
-	                    where case_id=p_case_info.case_id 
-		                    and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5' 
-		                    and pr.seq=(select max(seq) from p_proc_info pr where case_id=p_case_info.case_id 
-		                    and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'and seq<p_proc_info.seq)
-	                    ) as 前一次OA处理事项系数,
-	                    (STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl   
-		                    inner join s_user_info as u on u.user_id = pl.pic_id 
-		                    inner join  p_proc_info pr1 on pr1.proc_id=pl.obj_id 
-	                    where case_id=p_case_info.case_id 
-		                    and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5' 
-		                    and pr1.seq=(select max(seq) from p_proc_info pr2 where case_id=p_case_info.case_id 
-		                    and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'and seq<p_proc_info.seq) FOR XML PATH('') ),1,1,'')
-	                    ) as 前一次OA处理人,
-	                    STUFF((SELECT ',' + ur.rank_zh_cn from p_proc_pic_list as pl   
-		                    inner join s_user_info as u on u.user_id = pl.pic_id 
-		                    left join i_user_rank ur on ur.rank_id=u.rank_id where pl.obj_id = p_proc_info.proc_id   FOR XML PATH('') ),1,1,'') as 处理人等级,
-	                    STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl   
-		                    inner join s_user_info as u on u.user_id = pl.pic_id 
-		                    where pl.obj_id = p_proc_info.proc_id   FOR XML PATH('') ),1,1,'') as 处理人,
-	                    STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl   
-		                    inner join s_user_info as u on u.user_id = pl.revise_user_id 
-		                    where pl.obj_id = p_case_info.case_id   FOR XML PATH('') ),1,1,'') as 案件核稿人,
-	                    c_customer.customer_name as 客户名称,
-	                    STUFF((SELECT ',' + a.applicant_name_cn from p_applicant_list as al 
-		                    inner join i_applicant as a on a.applicant_id = al.applicant_id 
-	                    where al.obj_id = p_case_info.case_id order by al.seq FOR XML PATH('') ),1,1,'') as 申请人,
-	                    p_proc_info.finish_date as 处理事项完成日,
-	                    p_proc_info.finish_doc_date as 定稿日,
-	                    p_proc_info.back_date as 返稿日,
-	                    i_case_type.case_type_zh_cn as 案件类型,
-	                    i_case_status.case_status_zh_cn as 案件状态,
-	                    p_proc_info.proc_note as 处理事项备注,
-	                    (select proc_status_zh_cn from i_proc_status where proc_status_id=p_proc_info.proc_status_id) as 处理状态,
-	                    p_case_info.case_name as 案件名称,
-	                    p_case_info.charge_date as 委案日期,
-	                    p_proc_info.cus_due_date as 客户期限,
-	                    p_proc_info.int_due_date as 内部期限,
-	                    p_proc_info.first_doc_date as 初稿日,
-	                    p_case_info.remark as 案件备注,
-	                    p_proc_info.translate_count as 翻译字数,
-	                    STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl 
-		                    inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id 
-	                    where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员,
-	                    i_country.country_zh_cn as '国家(地区)'  
-                    from p_case_info  
-	                    inner join   p_case_advance_info  with(nolock)  on p_case_info.case_id=p_case_advance_info.case_id  
-	                    inner join   i_apply_type  with(nolock)  on i_apply_type.apply_type_id=p_case_info.apply_type_id  
-	                    inner join   i_case_type  with(nolock)  on i_case_type.case_type_id=p_case_info.case_type_id  
-	                    inner join   i_country  with(nolock)  on i_country.country_id=p_case_info.country_id  
-	                    inner join   i_case_status  with(nolock)  on i_case_status.case_status_id=p_case_info.case_status_id  
-	                    inner join   c_customer  with(nolock)  on c_customer.customer_id=p_case_info.customer_id 
-	                    left join i_case_coefficient on i_case_coefficient.case_coefficient_id=p_case_info.case_coefficient_id  
-	                    inner join   p_proc_info  with(nolock)  on p_case_info.case_id=p_proc_info.case_id  
-	                    inner join   i_ctrl_proc  with(nolock)  on p_proc_info.ctrl_proc_id=i_ctrl_proc.ctrl_proc_id 
-	                    inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id 
-	                    inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id 
-	                    left join p_proc_pic_list with(nolock) on p_proc_pic_list.obj_id=p_proc_info.proc_id 
-	                    left join s_user_info with(nolock) on s_user_info.user_id=p_proc_pic_list.pic_id 
-	                    left join i_proc_coefficient on i_proc_coefficient.proc_coefficient_id=p_proc_info.proc_coefficient_id 
-                    where 
-	                    p_case_info.is_enabled=1 
-	                    and p_proc_info.is_enabled=1 
-	                    and s_user_info.dept_id not in ('60e09ee0-fcc7-446f-badc-af9973079fee','34d0e351-71dc-418f-9b6b-bcb67af62fed','599cbe0c-044e-4ffc-9411-96dd9019d8a6') 
-	                    and  (p_case_info.case_type_id='31D1A147-2931-43B5-94AE-B72B1525BA8A'   ) 
-	                    AND  ((p_proc_info.finish_date >= @beginTime  and p_proc_info.finish_date<@endTime)) ";
-                    break;
-                case "每月绩效统计--中国一次OA授权表":
-                    strSQL = @"select 	
-	                    p_case_info.case_volume as 我方文号, 
-	                    p_case_info.case_name as 案件名称,
-	                    p_case_info.app_no as 申请号,
-	                    c_customer.customer_name as 客户名称,
-	                    STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl   
-		                    inner join s_user_info as u on u.user_id = pl.pic_id 
-		                    where pl.obj_id = p_case_info.case_id   FOR XML PATH('') ),1,1,'') as 案件处理人,
-	                    STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl   
-		                    inner join s_user_info as u on u.user_id = pl.revise_user_id 
-		                    where pl.obj_id = p_case_info.case_id   FOR XML PATH('') ),1,1,'') as 案件核稿人,
-	                    p_file_list.post_date as 发文日期,
-	                    p_case_info.case_volume_customer as 客户文号,
-	                    p_case_info.app_date as 申请日,
-	                    i_country.country_zh_cn as '国家(地区)',
-	                    STUFF((SELECT ',' + a.applicant_name_cn from p_applicant_list as al 
-		                    inner join i_applicant as a on a.applicant_id = al.applicant_id 
-		                    where al.obj_id = p_case_info.case_id order by al.seq FOR XML PATH('') ),1,1,'') as 申请人,
-	                    p_file_list.upload_time as 上传日期,
-	                    i_file_desc.file_desc_zh_cn as 文件描述,
-	                    i_apply_type.apply_type_zh_cn as 申请类型,
-	                    STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl 
-		                    inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id 
-		                    where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员 
-                    from p_case_info 
-	                    inner join i_apply_type on p_case_info.apply_type_id=i_apply_type.apply_type_id 
-	                    inner join p_proc_info on p_case_info.case_id=p_proc_info.case_id 
-	                    inner join p_file_list on p_file_list.obj_id=p_proc_info.proc_id 
-	                    inner join i_file_desc on i_file_desc.file_desc_id=p_file_list.file_desc_id 
-	                    inner join c_customer on p_case_info.customer_id=c_customer.customer_id 
-	                    inner join i_country on i_country.country_id=p_case_info.country_id 
-                    where 
-	                    p_case_info.is_enabled=1 
-	                    and p_proc_info.is_enabled=1 and p_case_info.country_id='CN' 
-	                    and p_file_list.file_desc_id='09800D39-D585-49F3-B9DE-50AC689DE9AB' 
-	                    and p_file_list.file_name not like '%.zip' 
-	                    and (select count(*) from p_proc_info where case_id=p_case_info.case_id and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5')=1 
-	                    and  (p_case_info.case_type_id='31D1A147-2931-43B5-94AE-B72B1525BA8A'   ) 
-	                    AND  ((p_file_list.upload_time >= @beginTime  and p_file_list.upload_time<@endTime))";
-                    break;
-                case "每月绩效统计--专案进度跟踪~S卷":
-                    strSQL = @"SELECT  p_case_info.case_volume as 我方文号,
-                            p_case_info.case_name as 案件名称,
-                            i_case_type.case_type_zh_cn as 案件类型,
-                            i_business_type.business_type_zh_cn as 业务类型,
-                            i_country.country_zh_cn as '国家(地区)',
-                            c_customer.customer_name as 客户名称,
-                            s_dept_info.dept_full_name as 承办部门,
-                            i_case_status.case_status_zh_cn as 案件状态,
-                            i_ctrl_proc.ctrl_proc_zh_cn as 处理事项,
-                            p_proc_info.int_due_date as 内部期限,
-                            p_proc_info.cus_due_date as 客户期限,
-                            p_proc_info.legal_due_date as 官方期限,
-                            p_proc_info.finish_doc_date as 定稿日,
-                            STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
-                               inner join s_user_info as u on u.user_id = pl.pic_id where pl.obj_id = p_proc_info.proc_id
-                               FOR XML PATH('') ),1,1,'') as 处理人,
-                            p_case_info.charge_date as 委案日期,
-                            (select proc_status_zh_cn from i_proc_status where proc_status_id=p_proc_info.proc_status_id) as 处理状态,
-                            p_proc_info.first_doc_date as 初稿日,
-                            STUFF((SELECT ',' + u.cn_name from c_customer_user as cu
-                             inner join s_user_info as u on u.user_id = cu.user_id 
-                             where cu.customer_id = p_case_info.customer_id FOR XML PATH('') ),1,1,'') as 流程负责人,
-                            p_proc_info.finish_date as 处理事项完成日,
-                            STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl
-                             inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id 
-                             where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员
-                            from p_case_info
-                              inner join   p_case_advance_info  with(nolock)  on p_case_info.case_id=p_case_advance_info.case_id
-                              inner join   i_apply_type  with(nolock)  on i_apply_type.apply_type_id=p_case_info.apply_type_id
-                              inner join   i_case_type  with(nolock)  on i_case_type.case_type_id=p_case_info.case_type_id
-                              inner join   i_country  with(nolock)  on i_country.country_id=p_case_info.country_id
-                              inner join   i_case_status  with(nolock)  on i_case_status.case_status_id=p_case_info.case_status_id
-                              inner join   c_customer  with(nolock)  on c_customer.customer_id=p_case_info.customer_id
-                              inner join   p_proc_info  with(nolock)  on p_case_info.case_id=p_proc_info.case_id
-                              inner join   i_ctrl_proc  with(nolock)  on p_proc_info.ctrl_proc_id=i_ctrl_proc.ctrl_proc_id
-                              inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id
-                              inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id 
-                             where p_case_info.is_enabled=1 and p_proc_info.is_enabled=1  and  
-                             (isnull (p_proc_info.finish_date,'') ='') AND  (i_ctrl_proc.ctrl_proc_zh_cn='提出报告')";
-                    break;
-                case "每月绩效统计--专案开卷报表~S卷":
-                    strSQL = @"SELECT  p_case_info.case_volume as 我方文号,
-	                        p_case_info.case_volume_customer as 客户文号,
-	                        p_case_info.case_name as 案件名称,
-	                        p_case_info.charge_date as 委案日期,
-	                        i_case_status.case_status_zh_cn as 案件状态,
-	                        i_case_type.case_type_zh_cn as 案件类型,
-	                        p_case_info.app_no as 申请号,
-	                        p_case_info.app_date as 申请日,
-	                        i_business_type.business_type_zh_cn as 业务类型,
-	                        STUFF((SELECT ',' + u.cn_name from c_customer_user as cu 
-		                        inner join s_user_info as u on u.user_id = cu.user_id where cu.customer_id = p_case_info.customer_id FOR XML PATH('') ),1,1,'') as 流程负责人,
-	                        c_customer.customer_name as 客户名称,
-	                        STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl
-		                        inner join s_user_info as u on u.user_id = pl.revise_user_id where pl.obj_id = p_case_info.case_id   FOR XML PATH('') ),1,1,'') as 案件核稿人,
-	                        STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
-		                        inner join s_user_info as u on u.user_id = pl.pic_id where pl.obj_id = p_case_info.case_id   FOR XML PATH('') ),1,1,'') as 案件处理人,
-	                        p_case_info.create_time as 开卷日期,
-	                        STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl 
-		                        inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id 
-		                        where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员,
-	                        i_country.country_zh_cn as '国家(地区)'  
-                        from p_case_info
-	                        inner join   p_case_advance_info  with(nolock)  on p_case_info.case_id=p_case_advance_info.case_id  
-	                        inner join   i_apply_type  with(nolock)  on i_apply_type.apply_type_id=p_case_info.apply_type_id  
-	                        inner join   i_case_type  with(nolock)  on i_case_type.case_type_id=p_case_info.case_type_id  
-	                        inner join   i_country  with(nolock)  on i_country.country_id=p_case_info.country_id  
-	                        inner join   i_case_status  with(nolock)  on i_case_status.case_status_id=p_case_info.case_status_id  
-	                        inner join   c_customer  with(nolock)  on c_customer.customer_id=p_case_info.customer_id  
-	                        inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id 
-	                        inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id 
-                        where p_case_info.is_enabled=1 p_case_info.is_enabled=1 and  p_case_info.case_volume like 'S%' and not p_case_info.case_volume like 'SC%'
-						and i_case_status.case_status_zh_cn<>'已完成' and i_case_status.case_status_zh_cn<>'结案'";
-                    break;
-            }
+            HttpClient http = new HttpClient();
+            var bytRespon = http.GetAsync($"{ConfigHelper.GetSectionValue("IPEasySetting:ipEeasyApi")}/api/ipEasy/GetDataFromIPEasy?ReportName={ReportName}&isModifyDate={isModifyDate}").Result;
             
+            if (bytRespon.IsSuccessStatusCode)
+            {
+                string result = bytRespon.Content.ReadAsStringAsync().Result.Replace("\"", string.Empty);
+                byte[] data = Convert.FromBase64String(result);
+                //byte[] data = bytRespon.Content.ReadAsByteArrayAsync().Result;//Here is the problem
+                XmlSerializer serializer = new XmlSerializer(typeof(System.Data.DataTable));
+                MemoryStream memory = new MemoryStream(data);
+                DataTable dt = (DataTable)serializer.Deserialize(memory);
 
-            using (var conn = new SqlConnection(ConfigHelper.GetSectionValue("IPEasySetting:ConnectionStrings")))
+                return dt;
+            }
+            else
             {
+                return null;
+            }
 
-                try
-                {
-                    conn.Open();
-                    using (var cmd = conn.CreateCommand())
-                    {
-                        cmd.CommandText = strSQL;
-                        cmd.CommandType = CommandType.Text;
 
-                        if (isModifyDate)
-                        {
-                            cmd.Parameters.Add(new SqlParameter("beginTime", DateTime.Parse(DateTime.Now.AddMonths(-1).ToString("yyyy-MM") + "-01")));
-                            cmd.Parameters.Add(new SqlParameter("endTime", DateTime.Parse(DateTime.Now.ToString("yyyy-MM") + "-01")));
-                        }
-                        using (var reader = cmd.ExecuteReader())
-                        {
-                            dt.Load(reader);
-                        }
-                    }
-                }
-                catch (Exception ex)
-                {
-                    throw ex;
-                }
-            }
-            return dt;
+
+            #region old code 从维德数据库中直接读取
+            //      DataTable dt = new DataTable();
+            //      string strSQL = "";
+            //      switch (ReportName)
+            //      {
+            //          case "每月绩效统计--发客户超过一个月未完成案件":
+            //              strSQL = @"SELECT  p_case_info.case_volume as 我方文号,
+            //            i_apply_type.apply_type_zh_cn as 申请类型,
+            //            i_business_type.business_type_zh_cn as 业务类型,
+            //            i_ctrl_proc.ctrl_proc_zh_cn as 处理事项,
+            //            (select case_status_zh_cn from i_case_status where case_status_id=p_proc_info.review_stage)  as 案件阶段,
+            //            i_case_coefficient.case_coefficient_zh_cn as 案件系数,
+            //            i_proc_coefficient.proc_coefficient_zh_cn as 处理事项系数,
+            //            (select  proc_coefficient_zh_cn from p_proc_info pr 
+            //             left join i_proc_coefficient pc on pc.proc_coefficient_id=pr.proc_coefficient_id 
+            //             where case_id=p_case_info.case_id and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5' 
+            //              and pr.seq=
+            //               (select max(seq) from p_proc_info pr where case_id=p_case_info.case_id 
+            //                and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'and seq<p_proc_info.seq)
+            //               ) as 前一次OA处理事项系数,
+            //            (STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
+            //             inner join s_user_info as u on u.user_id = pl.pic_id 
+            //             inner join  p_proc_info pr1 on pr1.proc_id=pl.obj_id 
+            //              where case_id=p_case_info.case_id and 
+            //               ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5' 
+            //               and pr1.seq=(
+            //                select max(seq) from p_proc_info pr2 where case_id=p_case_info.case_id 
+            //                and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5' 
+            //                and seq<p_proc_info.seq) FOR XML PATH('') ),1,1,'')) as 前一次OA处理人,
+            //            STUFF((SELECT ',' + ur.rank_zh_cn from p_proc_pic_list as pl   
+            //             inner join s_user_info as u on u.user_id = pl.pic_id 
+            //             left join i_user_rank ur on ur.rank_id=u.rank_id 
+            //             where pl.obj_id = p_proc_info.proc_id   FOR XML PATH('') ),1,1,'') as 处理人等级,
+            //            STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl   
+            //             inner join s_user_info as u on u.user_id = pl.pic_id 
+            //             where pl.obj_id = p_proc_info.proc_id   FOR XML PATH('') ),1,1,'') as 处理人,
+            //            STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl   
+            //             inner join s_user_info as u on u.user_id = pl.revise_user_id 
+            //             where pl.obj_id = p_proc_info.proc_id   FOR XML PATH('') ),1,1,'') as 核稿人,
+            //            c_customer.customer_name as 客户名称,
+            //            STUFF((SELECT ',' + a.applicant_name_cn from p_applicant_list as al 
+            //             inner join i_applicant as a on a.applicant_id = al.applicant_id 
+            //             where al.obj_id = p_case_info.case_id order by al.seq FOR XML PATH('') ),1,1,'') as 申请人,
+            //            p_proc_info.finish_date as 处理事项完成日,
+            //            p_proc_info.finish_doc_date as 定稿日,
+            //            p_proc_info.back_date as 返稿日,
+            //            i_case_type.case_type_zh_cn as 案件类型,
+            //            i_case_status.case_status_zh_cn as 案件状态,
+            //            p_proc_info.proc_note as 处理事项备注,
+            //            (select proc_status_zh_cn from i_proc_status where proc_status_id=p_proc_info.proc_status_id) as 处理状态,
+            //            p_case_info.case_name as 案件名称,
+            //            p_case_info.charge_date as 委案日期,
+            //            p_proc_info.cus_due_date as 客户期限,
+            //            p_proc_info.int_due_date as 内部期限,
+            //            p_proc_info.first_doc_date as 初稿日,
+            //            p_case_info.remark as 案件备注,
+            //            p_proc_info.translate_count as 翻译字数,
+            //            STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl 
+            //             inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id 
+            //             where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员,
+            //            i_country.country_zh_cn as '国家(地区)'  
+            //           from p_case_info  
+            //            inner join   p_case_advance_info  with(nolock)  on p_case_info.case_id=p_case_advance_info.case_id  
+            //            inner join   i_apply_type  with(nolock)  on i_apply_type.apply_type_id=p_case_info.apply_type_id  
+            //            inner join   i_case_type  with(nolock)  on i_case_type.case_type_id=p_case_info.case_type_id  
+            //            inner join   i_country  with(nolock)  on i_country.country_id=p_case_info.country_id  
+            //            inner join   i_case_status  with(nolock)  on i_case_status.case_status_id=p_case_info.case_status_id  
+            //            inner join   c_customer  with(nolock)  on c_customer.customer_id=p_case_info.customer_id 
+            //            left join i_case_coefficient on i_case_coefficient.case_coefficient_id=p_case_info.case_coefficient_id  
+            //            inner join   p_proc_info  with(nolock)  on p_case_info.case_id=p_proc_info.case_id  
+            //            inner join   i_ctrl_proc  with(nolock)  on p_proc_info.ctrl_proc_id=i_ctrl_proc.ctrl_proc_id 
+            //            inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id 
+            //            inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id 
+            //            left join p_proc_pic_list with(nolock) on p_proc_pic_list.obj_id=p_proc_info.proc_id 
+            //            left join s_user_info with(nolock) on s_user_info.user_id=p_proc_pic_list.pic_id 
+            //            left join i_proc_coefficient on i_proc_coefficient.proc_coefficient_id=p_proc_info.proc_coefficient_id 
+            //           where 
+            //            p_case_info.is_enabled=1 and p_proc_info.is_enabled=1 and 
+            //            s_user_info.dept_id not in ('60e09ee0-fcc7-446f-badc-af9973079fee','34d0e351-71dc-418f-9b6b-bcb67af62fed','599cbe0c-044e-4ffc-9411-96dd9019d8a6') and 
+            //            p_proc_info.finish_date is null 
+            //            and p_proc_info.back_date<DATEADD(MM,-1,DATEADD(MM, DATEDIFF(MM,0,getdate()), 0)) and  
+            //            (p_case_info.case_type_id='31D1A147-2931-43B5-94AE-B72B1525BA8A'   ) AND  
+            //            ( i_ctrl_proc.ctrl_proc_zh_cn='新申请'    
+            //             or  i_ctrl_proc.ctrl_proc_zh_cn='Non'    
+            //             or  i_ctrl_proc.ctrl_proc_zh_cn='无效宣告'    
+            //             or  i_ctrl_proc.ctrl_proc_zh_cn='意见陈述'    
+            //             or  i_ctrl_proc.ctrl_proc_zh_cn='专利挖掘与布局'    
+            //             or  i_ctrl_proc.ctrl_proc_zh_cn='处理审查意见'    
+            //             or  i_ctrl_proc.ctrl_proc_zh_cn='Final'    
+            //             or  i_ctrl_proc.ctrl_proc_zh_cn='复审通知意见陈述'    
+            //             or  i_ctrl_proc.ctrl_proc_zh_cn='申復'    
+            //             or  i_ctrl_proc.ctrl_proc_zh_cn='RCE'    
+            //             or  i_ctrl_proc.ctrl_proc_zh_cn='翻译'    
+            //             or  i_ctrl_proc.ctrl_proc_zh_cn='提出异议复审'    
+            //             or  i_ctrl_proc.ctrl_proc_zh_cn='Advisory'    
+            //             or  i_ctrl_proc.ctrl_proc_zh_cn='复审'    
+            //             or  i_ctrl_proc.ctrl_proc_zh_cn='请求复审'    
+            //             or  i_ctrl_proc.ctrl_proc_zh_cn='提出报告'    
+            //             or  i_ctrl_proc.ctrl_proc_zh_cn='提出公众意见'    
+            //             or  i_ctrl_proc.ctrl_proc_zh_cn='诉讼'    
+            //             or  i_ctrl_proc.ctrl_proc_zh_cn='提出异议'    
+            //             or  i_ctrl_proc.ctrl_proc_zh_cn='补充理由和证据'    
+            //             or  i_ctrl_proc.ctrl_proc_zh_cn='无效分析'    
+            //             or  i_ctrl_proc.ctrl_proc_zh_cn='无效答辩'   
+            //            )";
+            //              break;
+            //          case "每月绩效统计--上个月递交完成案件":
+            //              strSQL = @"SELECT  
+            //               p_case_info.case_volume as 我方文号,
+            //               i_apply_type.apply_type_zh_cn as 申请类型,
+            //               i_business_type.business_type_zh_cn as 业务类型,
+            //               i_ctrl_proc.ctrl_proc_zh_cn as 处理事项,
+            //               (select case_status_zh_cn from i_case_status where case_status_id=p_proc_info.review_stage)  as 案件阶段,
+            //               i_case_coefficient.case_coefficient_zh_cn as 案件系数,
+            //               i_proc_coefficient.proc_coefficient_zh_cn as 处理事项系数,
+            //               (select  
+            //                proc_coefficient_zh_cn from p_proc_info pr 
+            //                left join i_proc_coefficient pc on pc.proc_coefficient_id=pr.proc_coefficient_id 
+            //               where case_id=p_case_info.case_id 
+            //                and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5' 
+            //                and pr.seq=(select max(seq) from p_proc_info pr where case_id=p_case_info.case_id 
+            //                and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'and seq<p_proc_info.seq)
+            //               ) as 前一次OA处理事项系数,
+            //               (STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl   
+            //                inner join s_user_info as u on u.user_id = pl.pic_id 
+            //                inner join  p_proc_info pr1 on pr1.proc_id=pl.obj_id 
+            //               where case_id=p_case_info.case_id 
+            //                and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5' 
+            //                and pr1.seq=(select max(seq) from p_proc_info pr2 where case_id=p_case_info.case_id 
+            //                and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'and seq<p_proc_info.seq) FOR XML PATH('') ),1,1,'')
+            //               ) as 前一次OA处理人,
+            //               STUFF((SELECT ',' + ur.rank_zh_cn from p_proc_pic_list as pl   
+            //                inner join s_user_info as u on u.user_id = pl.pic_id 
+            //                left join i_user_rank ur on ur.rank_id=u.rank_id where pl.obj_id = p_proc_info.proc_id   FOR XML PATH('') ),1,1,'') as 处理人等级,
+            //               STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl   
+            //                inner join s_user_info as u on u.user_id = pl.pic_id 
+            //                where pl.obj_id = p_proc_info.proc_id   FOR XML PATH('') ),1,1,'') as 处理人,
+            //               STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl   
+            //                inner join s_user_info as u on u.user_id = pl.revise_user_id 
+            //                where pl.obj_id = p_case_info.case_id   FOR XML PATH('') ),1,1,'') as 案件核稿人,
+            //               c_customer.customer_name as 客户名称,
+            //               STUFF((SELECT ',' + a.applicant_name_cn from p_applicant_list as al 
+            //                inner join i_applicant as a on a.applicant_id = al.applicant_id 
+            //               where al.obj_id = p_case_info.case_id order by al.seq FOR XML PATH('') ),1,1,'') as 申请人,
+            //               p_proc_info.finish_date as 处理事项完成日,
+            //               p_proc_info.finish_doc_date as 定稿日,
+            //               p_proc_info.back_date as 返稿日,
+            //               i_case_type.case_type_zh_cn as 案件类型,
+            //               i_case_status.case_status_zh_cn as 案件状态,
+            //               p_proc_info.proc_note as 处理事项备注,
+            //               (select proc_status_zh_cn from i_proc_status where proc_status_id=p_proc_info.proc_status_id) as 处理状态,
+            //               p_case_info.case_name as 案件名称,
+            //               p_case_info.charge_date as 委案日期,
+            //               p_proc_info.cus_due_date as 客户期限,
+            //               p_proc_info.int_due_date as 内部期限,
+            //               p_proc_info.first_doc_date as 初稿日,
+            //               p_case_info.remark as 案件备注,
+            //               p_proc_info.translate_count as 翻译字数,
+            //               STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl 
+            //                inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id 
+            //               where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员,
+            //               i_country.country_zh_cn as '国家(地区)'  
+            //              from p_case_info  
+            //               inner join   p_case_advance_info  with(nolock)  on p_case_info.case_id=p_case_advance_info.case_id  
+            //               inner join   i_apply_type  with(nolock)  on i_apply_type.apply_type_id=p_case_info.apply_type_id  
+            //               inner join   i_case_type  with(nolock)  on i_case_type.case_type_id=p_case_info.case_type_id  
+            //               inner join   i_country  with(nolock)  on i_country.country_id=p_case_info.country_id  
+            //               inner join   i_case_status  with(nolock)  on i_case_status.case_status_id=p_case_info.case_status_id  
+            //               inner join   c_customer  with(nolock)  on c_customer.customer_id=p_case_info.customer_id 
+            //               left join i_case_coefficient on i_case_coefficient.case_coefficient_id=p_case_info.case_coefficient_id  
+            //               inner join   p_proc_info  with(nolock)  on p_case_info.case_id=p_proc_info.case_id  
+            //               inner join   i_ctrl_proc  with(nolock)  on p_proc_info.ctrl_proc_id=i_ctrl_proc.ctrl_proc_id 
+            //               inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id 
+            //               inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id 
+            //               left join p_proc_pic_list with(nolock) on p_proc_pic_list.obj_id=p_proc_info.proc_id 
+            //               left join s_user_info with(nolock) on s_user_info.user_id=p_proc_pic_list.pic_id 
+            //               left join i_proc_coefficient on i_proc_coefficient.proc_coefficient_id=p_proc_info.proc_coefficient_id 
+            //              where 
+            //               p_case_info.is_enabled=1 
+            //               and p_proc_info.is_enabled=1 
+            //               and s_user_info.dept_id not in ('60e09ee0-fcc7-446f-badc-af9973079fee','34d0e351-71dc-418f-9b6b-bcb67af62fed','599cbe0c-044e-4ffc-9411-96dd9019d8a6') 
+            //               and  (p_case_info.case_type_id='31D1A147-2931-43B5-94AE-B72B1525BA8A'   ) 
+            //               AND  ((p_proc_info.finish_date >= @beginTime  and p_proc_info.finish_date<@endTime)) ";
+            //              break;
+            //          case "每月绩效统计--中国一次OA授权表":
+            //              strSQL = @"select 	
+            //               p_case_info.case_volume as 我方文号, 
+            //               p_case_info.case_name as 案件名称,
+            //               p_case_info.app_no as 申请号,
+            //               c_customer.customer_name as 客户名称,
+            //               STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl   
+            //                inner join s_user_info as u on u.user_id = pl.pic_id 
+            //                where pl.obj_id = p_case_info.case_id   FOR XML PATH('') ),1,1,'') as 案件处理人,
+            //               STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl   
+            //                inner join s_user_info as u on u.user_id = pl.revise_user_id 
+            //                where pl.obj_id = p_case_info.case_id   FOR XML PATH('') ),1,1,'') as 案件核稿人,
+            //               p_file_list.post_date as 发文日期,
+            //               p_case_info.case_volume_customer as 客户文号,
+            //               p_case_info.app_date as 申请日,
+            //               i_country.country_zh_cn as '国家(地区)',
+            //               STUFF((SELECT ',' + a.applicant_name_cn from p_applicant_list as al 
+            //                inner join i_applicant as a on a.applicant_id = al.applicant_id 
+            //                where al.obj_id = p_case_info.case_id order by al.seq FOR XML PATH('') ),1,1,'') as 申请人,
+            //               p_file_list.upload_time as 上传日期,
+            //               i_file_desc.file_desc_zh_cn as 文件描述,
+            //               i_apply_type.apply_type_zh_cn as 申请类型,
+            //               STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl 
+            //                inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id 
+            //                where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员 
+            //              from p_case_info 
+            //               inner join i_apply_type on p_case_info.apply_type_id=i_apply_type.apply_type_id 
+            //               inner join p_proc_info on p_case_info.case_id=p_proc_info.case_id 
+            //               inner join p_file_list on p_file_list.obj_id=p_proc_info.proc_id 
+            //               inner join i_file_desc on i_file_desc.file_desc_id=p_file_list.file_desc_id 
+            //               inner join c_customer on p_case_info.customer_id=c_customer.customer_id 
+            //               inner join i_country on i_country.country_id=p_case_info.country_id 
+            //              where 
+            //               p_case_info.is_enabled=1 
+            //               and p_proc_info.is_enabled=1 and p_case_info.country_id='CN' 
+            //               and p_file_list.file_desc_id='09800D39-D585-49F3-B9DE-50AC689DE9AB' 
+            //               and p_file_list.file_name not like '%.zip' 
+            //               and (select count(*) from p_proc_info where case_id=p_case_info.case_id and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5')=1 
+            //               and  (p_case_info.case_type_id='31D1A147-2931-43B5-94AE-B72B1525BA8A'   ) 
+            //               AND  ((p_file_list.upload_time >= @beginTime  and p_file_list.upload_time<@endTime))";
+            //              break;
+            //          case "每月绩效统计--专案进度跟踪~S卷":
+            //              strSQL = @"SELECT  p_case_info.case_volume as 我方文号,
+            //                      p_case_info.case_name as 案件名称,
+            //                      i_case_type.case_type_zh_cn as 案件类型,
+            //                      i_business_type.business_type_zh_cn as 业务类型,
+            //                      i_country.country_zh_cn as '国家(地区)',
+            //                      c_customer.customer_name as 客户名称,
+            //                      s_dept_info.dept_full_name as 承办部门,
+            //                      i_case_status.case_status_zh_cn as 案件状态,
+            //                      i_ctrl_proc.ctrl_proc_zh_cn as 处理事项,
+            //                      p_proc_info.int_due_date as 内部期限,
+            //                      p_proc_info.cus_due_date as 客户期限,
+            //                      p_proc_info.legal_due_date as 官方期限,
+            //                      p_proc_info.finish_doc_date as 定稿日,
+            //                      STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
+            //                         inner join s_user_info as u on u.user_id = pl.pic_id where pl.obj_id = p_proc_info.proc_id
+            //                         FOR XML PATH('') ),1,1,'') as 处理人,
+            //                      p_case_info.charge_date as 委案日期,
+            //                      (select proc_status_zh_cn from i_proc_status where proc_status_id=p_proc_info.proc_status_id) as 处理状态,
+            //                      p_proc_info.first_doc_date as 初稿日,
+            //                      STUFF((SELECT ',' + u.cn_name from c_customer_user as cu
+            //                       inner join s_user_info as u on u.user_id = cu.user_id 
+            //                       where cu.customer_id = p_case_info.customer_id FOR XML PATH('') ),1,1,'') as 流程负责人,
+            //                      p_proc_info.finish_date as 处理事项完成日,
+            //                      STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl
+            //                       inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id 
+            //                       where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员
+            //                      from p_case_info
+            //                        inner join   p_case_advance_info  with(nolock)  on p_case_info.case_id=p_case_advance_info.case_id
+            //                        inner join   i_apply_type  with(nolock)  on i_apply_type.apply_type_id=p_case_info.apply_type_id
+            //                        inner join   i_case_type  with(nolock)  on i_case_type.case_type_id=p_case_info.case_type_id
+            //                        inner join   i_country  with(nolock)  on i_country.country_id=p_case_info.country_id
+            //                        inner join   i_case_status  with(nolock)  on i_case_status.case_status_id=p_case_info.case_status_id
+            //                        inner join   c_customer  with(nolock)  on c_customer.customer_id=p_case_info.customer_id
+            //                        inner join   p_proc_info  with(nolock)  on p_case_info.case_id=p_proc_info.case_id
+            //                        inner join   i_ctrl_proc  with(nolock)  on p_proc_info.ctrl_proc_id=i_ctrl_proc.ctrl_proc_id
+            //                        inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id
+            //                        inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id 
+            //                       where p_case_info.is_enabled=1 and p_proc_info.is_enabled=1  and  
+            //                       (isnull (p_proc_info.finish_date,'') ='') AND  (i_ctrl_proc.ctrl_proc_zh_cn='提出报告')";
+            //              break;
+            //          case "每月绩效统计--专案开卷报表~S卷":
+            //              strSQL = @"SELECT  p_case_info.case_volume as 我方文号,
+            //                   p_case_info.case_volume_customer as 客户文号,
+            //                   p_case_info.case_name as 案件名称,
+            //                   p_case_info.charge_date as 委案日期,
+            //                   i_case_status.case_status_zh_cn as 案件状态,
+            //                   i_case_type.case_type_zh_cn as 案件类型,
+            //                   p_case_info.app_no as 申请号,
+            //                   p_case_info.app_date as 申请日,
+            //                   i_business_type.business_type_zh_cn as 业务类型,
+            //                   STUFF((SELECT ',' + u.cn_name from c_customer_user as cu 
+            //                    inner join s_user_info as u on u.user_id = cu.user_id where cu.customer_id = p_case_info.customer_id FOR XML PATH('') ),1,1,'') as 流程负责人,
+            //                   c_customer.customer_name as 客户名称,
+            //                   STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl
+            //                    inner join s_user_info as u on u.user_id = pl.revise_user_id where pl.obj_id = p_case_info.case_id   FOR XML PATH('') ),1,1,'') as 案件核稿人,
+            //                   STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
+            //                    inner join s_user_info as u on u.user_id = pl.pic_id where pl.obj_id = p_case_info.case_id   FOR XML PATH('') ),1,1,'') as 案件处理人,
+            //                   p_case_info.create_time as 开卷日期,
+            //                   STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl 
+            //                    inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id 
+            //                    where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员,
+            //                   i_country.country_zh_cn as '国家(地区)'  
+            //                  from p_case_info
+            //                   inner join   p_case_advance_info  with(nolock)  on p_case_info.case_id=p_case_advance_info.case_id  
+            //                   inner join   i_apply_type  with(nolock)  on i_apply_type.apply_type_id=p_case_info.apply_type_id  
+            //                   inner join   i_case_type  with(nolock)  on i_case_type.case_type_id=p_case_info.case_type_id  
+            //                   inner join   i_country  with(nolock)  on i_country.country_id=p_case_info.country_id  
+            //                   inner join   i_case_status  with(nolock)  on i_case_status.case_status_id=p_case_info.case_status_id  
+            //                   inner join   c_customer  with(nolock)  on c_customer.customer_id=p_case_info.customer_id  
+            //                   inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id 
+            //                   inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id 
+            //                  where p_case_info.is_enabled=1 p_case_info.is_enabled=1 and  p_case_info.case_volume like 'S%' and not p_case_info.case_volume like 'SC%'
+            //and i_case_status.case_status_zh_cn<>'已完成' and i_case_status.case_status_zh_cn<>'结案'";
+            //              break;
+            //      }
+
+
+            //      using (var conn = new SqlConnection(ConfigHelper.GetSectionValue("IPEasySetting:ConnectionStrings")))
+            //      {
+
+            //          try
+            //          {
+            //              conn.Open();
+            //              using (var cmd = conn.CreateCommand())
+            //              {
+            //                  cmd.CommandText = strSQL;
+            //                  cmd.CommandType = CommandType.Text;
+
+            //                  if (isModifyDate)
+            //                  {
+            //                      cmd.Parameters.Add(new SqlParameter("beginTime", DateTime.Parse(DateTime.Now.AddMonths(-1).ToString("yyyy-MM") + "-01")));
+            //                      cmd.Parameters.Add(new SqlParameter("endTime", DateTime.Parse(DateTime.Now.ToString("yyyy-MM") + "-01")));
+            //                  }
+            //                  using (var reader = cmd.ExecuteReader())
+            //                  {
+            //                      dt.Load(reader);
+            //                  }
+            //              }
+            //          }
+            //          catch (Exception ex)
+            //          {
+            //              throw ex;
+            //          }
+            //      }
+            //      return dt;
+            #endregion
         }
     }
 }

+ 201 - 160
wispro.sp.api/Job/UpdateJXDataFromIPEasyJob.cs

@@ -8,6 +8,9 @@ using System.Diagnostics;
 using System.Dynamic;
 using System.IO;
 using System.Linq;
+using System.Net.Http;
+using System.Net.Http.Json;
+using System.Text.Json;
 using System.Threading;
 using System.Threading.Tasks;
 using wispro.sp.entity;
@@ -20,170 +23,208 @@ namespace wispro.sp.api.Job
        
         public dynamic  GetItemFromIPEasyDB(PerformanceItem Item, spDbContext spDb)
         {
-            dynamic retItem = new ExpandoObject();
-
-            var dt = new DataTable();
-            using (var conn = new SqlConnection(ConfigHelper.GetSectionValue("IPEasySetting:ConnectionStrings")))
-            {
-                
-                try
-                {
-                    conn.Open();
-
-                    string strSql = @"SELECT distinct  p_case_info.case_volume as case_volume,
-		            i_apply_type.apply_type_zh_cn as apply_type_zh_cn,
-		            i_business_type.business_type_zh_cn as business_type_zh_cn,
-		            i_ctrl_proc.ctrl_proc_zh_cn as ctrl_proc_zh_cn,
-		            (select case_status_zh_cn from i_case_status where case_status_id=p_proc_info.review_stage)  as review_stage,
-		            i_case_coefficient.case_coefficient_zh_cn as case_coefficient,
-		            i_proc_coefficient.proc_coefficient_zh_cn as proc_coefficient,
-		            (select  proc_coefficient_zh_cn from p_proc_info pr 
-			            left join i_proc_coefficient pc on pc.proc_coefficient_id=pr.proc_coefficient_id 
-			            where case_id=p_case_info.case_id and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5' 
-				            and pr.seq=
-					            (select max(seq) from p_proc_info pr where case_id=p_case_info.case_id 
-						            and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'and seq<p_proc_info.seq)
-					            ) as oa_proc_coefficient,
-		            (STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
-			            inner join s_user_info as u on u.user_id = pl.pic_id 
-			            inner join  p_proc_info pr1 on pr1.proc_id=pl.obj_id 
-				            where case_id=p_case_info.case_id and 
-					            ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5' 
-					            and pr1.seq=(
-						            select max(seq) from p_proc_info pr2 where case_id=p_case_info.case_id 
-						            and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5' 
-						            and seq<p_proc_info.seq) FOR XML PATH('') ),1,1,'')) 
-		            as oa_pic_list,
-		            STUFF((SELECT ',' + ur.rank_zh_cn from p_proc_pic_list as pl   
-			            inner join s_user_info as u on u.user_id = pl.pic_id 
-			            left join i_user_rank ur on ur.rank_id=u.rank_id 
-			            where pl.obj_id = p_proc_info.proc_id   FOR XML PATH('') ),1,1,'') as user_rank,
-		            STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl   
-			            inner join s_user_info as u on u.user_id = pl.pic_id 
-			            where pl.obj_id = p_proc_info.proc_id   FOR XML PATH('') ),1,1,'') as pic,
-		            STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl   
-			            inner join s_user_info as u on u.user_id = pl.revise_user_id 
-			            where pl.obj_id = p_proc_info.proc_id   FOR XML PATH('') ),1,1,'') as reviser,
-		            c_customer.customer_name as customer_name,
-		            STUFF((SELECT ',' + a.applicant_name_cn from p_applicant_list as al 
-			            inner join i_applicant as a on a.applicant_id = al.applicant_id 
-			            where al.obj_id = p_case_info.case_id order by al.seq FOR XML PATH('') ),1,1,'') as applicants,
-		            p_proc_info.finish_date as finish_date,
-		            p_proc_info.finish_doc_date as finish_doc_date,
-		            p_proc_info.back_date as back_date,
-		            i_case_type.case_type_zh_cn as case_type_zh_cn,
-		            i_case_status.case_status_zh_cn as case_status_zh_cn,
-		            p_proc_info.proc_note as proc_note,
-		            (select proc_status_zh_cn from i_proc_status where proc_status_id=p_proc_info.proc_status_id) as proc_status_zh_cn,
-		            p_case_info.case_name as case_name,
-		            p_case_info.charge_date as charge_date,
-		            p_proc_info.cus_due_date as cus_due_date,
-		            p_proc_info.int_due_date as int_due_date,
-		            p_proc_info.first_doc_date as first_doc_date,
-		            p_case_info.remark as case_remark,
-		            p_proc_info.translate_count as translate_count,
-		            STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl 
-			            inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id 
-			            where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as sales,
-		            i_country.country_zh_cn as country_zh_cn  
-	            from p_case_info  
-		            inner join   p_case_advance_info  with(nolock)  on p_case_info.case_id=p_case_advance_info.case_id  
-		            inner join   i_apply_type  with(nolock)  on i_apply_type.apply_type_id=p_case_info.apply_type_id  
-		            inner join   i_case_type  with(nolock)  on i_case_type.case_type_id=p_case_info.case_type_id  
-		            inner join   i_country  with(nolock)  on i_country.country_id=p_case_info.country_id  
-		            inner join   i_case_status  with(nolock)  on i_case_status.case_status_id=p_case_info.case_status_id  
-		            inner join   c_customer  with(nolock)  on c_customer.customer_id=p_case_info.customer_id 
-		            left join i_case_coefficient on i_case_coefficient.case_coefficient_id=p_case_info.case_coefficient_id  
-		            inner join   p_proc_info  with(nolock)  on p_case_info.case_id=p_proc_info.case_id  
-		            inner join   i_ctrl_proc  with(nolock)  on p_proc_info.ctrl_proc_id=i_ctrl_proc.ctrl_proc_id 
-		            inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id 
-		            left join p_proc_pic_list with(nolock) on p_proc_pic_list.obj_id=p_proc_info.proc_id 
-		            left join s_user_info with(nolock) on s_user_info.user_id=p_proc_pic_list.pic_id 
-		            left join i_proc_coefficient on i_proc_coefficient.proc_coefficient_id=p_proc_info.proc_coefficient_id 
-	            where 
-		            p_case_info.is_enabled=1 and 
-		            p_proc_info.is_enabled=1 and 
-		            s_user_info.dept_id not in ('60e09ee0-fcc7-446f-badc-af9973079fee','34d0e351-71dc-418f-9b6b-bcb67af62fed','599cbe0c-044e-4ffc-9411-96dd9019d8a6') and 
-		            (p_case_info.case_type_id='31D1A147-2931-43B5-94AE-B72B1525BA8A') AND  
-		            i_ctrl_proc.ctrl_proc_zh_cn=@DoItem and 
-		            p_case_info.case_volume =@CaseNo";
-
-                    //if (!string.IsNullOrEmpty(Item.CaseStage))
-                    //{
-                    //    strSql = $"select * from  ({strSql}) as t where review_stage=@CaseStage";
-                    //}
-
-
-                    using (var cmd = conn.CreateCommand())
-                    {
-                        cmd.CommandText = strSql;
-                        cmd.CommandType = CommandType.Text;
-                        cmd.Parameters.Add(new SqlParameter("DoItem", Item.DoItem.Trim()));
-                        cmd.Parameters.Add(new SqlParameter("CaseNo", Item.CaseNo.Trim()));
-                        //if (!string.IsNullOrEmpty(Item.CaseStage))
-                        //{
-                        //    cmd.Parameters.Add(new SqlParameter("CaseStage", Item.CaseStage));
-                        //}
-
-                        using (var reader = cmd.ExecuteReader())
-                        {
-                            dt.Load(reader);
-
-
-
-                            if (dt.Rows.Count > 1)
-                            {
-                                bool bRet = false;
-                                foreach (DataRow row in dt.Rows)
-                                {
-                                    retItem.FinishedDate = row["finish_date"].ToString();
-                                    DateTime temDate = DateTime.Now;
-                                    DateTime.TryParse(retItem.FinishedDate,out temDate);
-                                    if ((Item.FinishedDate.HasValue && Item.FinishedDate.Value == temDate) ||
-                                        (!string.IsNullOrEmpty(Item.CaseStage) && Item.CaseStage == row["review_stage"].ToString()))
-                                    {
-                                        GetItemData(retItem, row);
+            HttpClient http = new HttpClient();
 
-                                        bRet = true;
-                                        break;
-                                    }
-                                    
-                                }
+            //http.GetFromJsonAsync($"{ConfigHelper.GetSectionValue("IPEasySetting:ipEeasyApi")}/api/ipEasy/GetItemFromIPEasyDB?CaseNo={Item.CaseNo}&DoItem={Item.DoItem}").Wait();
+            var response =  http.GetFromJsonAsync<Object>($"{ConfigHelper.GetSectionValue("IPEasySetting:ipEeasyApi")}/api/ipEasy/GetItemFromIPEasyDB?CaseNo={Item.CaseNo}&DoItem={Item.DoItem}").Result;
 
-                                if (!bRet)
-                                {
-                                    DataRow row = dt.Rows[0];
-                                    GetItemData(retItem, row);
-
-                                }
-                            }
-                            else
-                            {
-                                if (dt.Rows.Count > 0)
-                                {
-                                    DataRow row = dt.Rows[0];
-                                    GetItemData(retItem, row);
-
-                                }
-
-                            }
+            
+            dynamic retItem = new ExpandoObject();
 
-
-                        }
-                    }
-                }
-                catch (Exception ex)
-                {
-                    // error handling
-                    throw;
-                }
-                finally
-                {
-                    conn.Close();
-                }
-            }
+            JsonElement json = ((System.Text.Json.JsonElement)response);
+            retItem.CaseNo = json.GetProperty("CaseNo").GetString();
+            retItem.ApplicationType = json.GetProperty("ApplicationType").GetString();
+            retItem.BusinessType = json.GetProperty("BusinessType").GetString();
+            retItem.DoItem = json.GetProperty("DoItem").GetString();
+            retItem.CaseStage = json.GetProperty("CaseStage").GetString();
+            retItem.CaseCoefficient = json.GetProperty("CaseCoefficient").GetString();
+            retItem.DoItemCoefficient = json.GetProperty("DoItemCoefficient").GetString();
+            retItem.DoPersons = json.GetProperty("DoPersons").GetString();
+            retItem.Reviewer = json.GetProperty("Reviewer").GetString();
+            retItem.CustomerName = json.GetProperty("CustomerName").GetString();
+            retItem.FinishedDate = json.GetProperty("FinishedDate").GetString();
+            retItem.WordCount = json.GetProperty("WordCount").GetString();
+            retItem.ReturnDate = json.GetProperty("ReturnDate").GetString();
+            retItem.CaseType = json.GetProperty("CaseType").GetString();
+            retItem.CaseState = json.GetProperty("CaseState").GetString();
+            retItem.DoItemMemo = json.GetProperty("DoItemMemo").GetString();
+            retItem.DoItemState = json.GetProperty("DoItemState").GetString();
+            retItem.CaseName = json.GetProperty("CaseName").GetString();
+            retItem.EntrustingDate = json.GetProperty("EntrustingDate").GetString();
+            retItem.CustomerLimitDate = json.GetProperty("CustomerLimitDate").GetString();
+            retItem.InternalDate = json.GetProperty("InternalDate").GetString();
+            retItem.FirstDraftDate = json.GetProperty("FirstDraftDate").GetString();
+            retItem.CaseMemo = json.GetProperty("CaseMemo").GetString();
+            retItem.FinalizationDate = json.GetProperty("FinalizationDate").GetString();
 
             return retItem;
+
+            #region old code 直接从数据库中获取数据
+            //dynamic retItem = new ExpandoObject();
+
+            //var dt = new DataTable();
+            //using (var conn = new SqlConnection(ConfigHelper.GetSectionValue("IPEasySetting:ConnectionStrings")))
+            //{
+
+            //    try
+            //    {
+            //        conn.Open();
+
+            //        string strSql = @"SELECT distinct  p_case_info.case_volume as case_volume,
+            //  i_apply_type.apply_type_zh_cn as apply_type_zh_cn,
+            //  i_business_type.business_type_zh_cn as business_type_zh_cn,
+            //  i_ctrl_proc.ctrl_proc_zh_cn as ctrl_proc_zh_cn,
+            //  (select case_status_zh_cn from i_case_status where case_status_id=p_proc_info.review_stage)  as review_stage,
+            //  i_case_coefficient.case_coefficient_zh_cn as case_coefficient,
+            //  i_proc_coefficient.proc_coefficient_zh_cn as proc_coefficient,
+            //  (select  proc_coefficient_zh_cn from p_proc_info pr 
+            //   left join i_proc_coefficient pc on pc.proc_coefficient_id=pr.proc_coefficient_id 
+            //   where case_id=p_case_info.case_id and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5' 
+            //    and pr.seq=
+            //     (select max(seq) from p_proc_info pr where case_id=p_case_info.case_id 
+            //      and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'and seq<p_proc_info.seq)
+            //     ) as oa_proc_coefficient,
+            //  (STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
+            //   inner join s_user_info as u on u.user_id = pl.pic_id 
+            //   inner join  p_proc_info pr1 on pr1.proc_id=pl.obj_id 
+            //    where case_id=p_case_info.case_id and 
+            //     ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5' 
+            //     and pr1.seq=(
+            //      select max(seq) from p_proc_info pr2 where case_id=p_case_info.case_id 
+            //      and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5' 
+            //      and seq<p_proc_info.seq) FOR XML PATH('') ),1,1,'')) 
+            //  as oa_pic_list,
+            //  STUFF((SELECT ',' + ur.rank_zh_cn from p_proc_pic_list as pl   
+            //   inner join s_user_info as u on u.user_id = pl.pic_id 
+            //   left join i_user_rank ur on ur.rank_id=u.rank_id 
+            //   where pl.obj_id = p_proc_info.proc_id   FOR XML PATH('') ),1,1,'') as user_rank,
+            //  STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl   
+            //   inner join s_user_info as u on u.user_id = pl.pic_id 
+            //   where pl.obj_id = p_proc_info.proc_id   FOR XML PATH('') ),1,1,'') as pic,
+            //  STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl   
+            //   inner join s_user_info as u on u.user_id = pl.revise_user_id 
+            //   where pl.obj_id = p_proc_info.proc_id   FOR XML PATH('') ),1,1,'') as reviser,
+            //  c_customer.customer_name as customer_name,
+            //  STUFF((SELECT ',' + a.applicant_name_cn from p_applicant_list as al 
+            //   inner join i_applicant as a on a.applicant_id = al.applicant_id 
+            //   where al.obj_id = p_case_info.case_id order by al.seq FOR XML PATH('') ),1,1,'') as applicants,
+            //  p_proc_info.finish_date as finish_date,
+            //  p_proc_info.finish_doc_date as finish_doc_date,
+            //  p_proc_info.back_date as back_date,
+            //  i_case_type.case_type_zh_cn as case_type_zh_cn,
+            //  i_case_status.case_status_zh_cn as case_status_zh_cn,
+            //  p_proc_info.proc_note as proc_note,
+            //  (select proc_status_zh_cn from i_proc_status where proc_status_id=p_proc_info.proc_status_id) as proc_status_zh_cn,
+            //  p_case_info.case_name as case_name,
+            //  p_case_info.charge_date as charge_date,
+            //  p_proc_info.cus_due_date as cus_due_date,
+            //  p_proc_info.int_due_date as int_due_date,
+            //  p_proc_info.first_doc_date as first_doc_date,
+            //  p_case_info.remark as case_remark,
+            //  p_proc_info.translate_count as translate_count,
+            //  STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl 
+            //   inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id 
+            //   where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as sales,
+            //  i_country.country_zh_cn as country_zh_cn  
+            // from p_case_info  
+            //  inner join   p_case_advance_info  with(nolock)  on p_case_info.case_id=p_case_advance_info.case_id  
+            //  inner join   i_apply_type  with(nolock)  on i_apply_type.apply_type_id=p_case_info.apply_type_id  
+            //  inner join   i_case_type  with(nolock)  on i_case_type.case_type_id=p_case_info.case_type_id  
+            //  inner join   i_country  with(nolock)  on i_country.country_id=p_case_info.country_id  
+            //  inner join   i_case_status  with(nolock)  on i_case_status.case_status_id=p_case_info.case_status_id  
+            //  inner join   c_customer  with(nolock)  on c_customer.customer_id=p_case_info.customer_id 
+            //  left join i_case_coefficient on i_case_coefficient.case_coefficient_id=p_case_info.case_coefficient_id  
+            //  inner join   p_proc_info  with(nolock)  on p_case_info.case_id=p_proc_info.case_id  
+            //  inner join   i_ctrl_proc  with(nolock)  on p_proc_info.ctrl_proc_id=i_ctrl_proc.ctrl_proc_id 
+            //  inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id 
+            //  left join p_proc_pic_list with(nolock) on p_proc_pic_list.obj_id=p_proc_info.proc_id 
+            //  left join s_user_info with(nolock) on s_user_info.user_id=p_proc_pic_list.pic_id 
+            //  left join i_proc_coefficient on i_proc_coefficient.proc_coefficient_id=p_proc_info.proc_coefficient_id 
+            // where 
+            //  p_case_info.is_enabled=1 and 
+            //  p_proc_info.is_enabled=1 and 
+            //  s_user_info.dept_id not in ('60e09ee0-fcc7-446f-badc-af9973079fee','34d0e351-71dc-418f-9b6b-bcb67af62fed','599cbe0c-044e-4ffc-9411-96dd9019d8a6') and 
+            //  (p_case_info.case_type_id='31D1A147-2931-43B5-94AE-B72B1525BA8A') AND  
+            //  i_ctrl_proc.ctrl_proc_zh_cn=@DoItem and 
+            //  p_case_info.case_volume =@CaseNo";
+
+            //        //if (!string.IsNullOrEmpty(Item.CaseStage))
+            //        //{
+            //        //    strSql = $"select * from  ({strSql}) as t where review_stage=@CaseStage";
+            //        //}
+
+
+            //        using (var cmd = conn.CreateCommand())
+            //        {
+            //            cmd.CommandText = strSql;
+            //            cmd.CommandType = CommandType.Text;
+            //            cmd.Parameters.Add(new SqlParameter("DoItem", Item.DoItem.Trim()));
+            //            cmd.Parameters.Add(new SqlParameter("CaseNo", Item.CaseNo.Trim()));
+            //            //if (!string.IsNullOrEmpty(Item.CaseStage))
+            //            //{
+            //            //    cmd.Parameters.Add(new SqlParameter("CaseStage", Item.CaseStage));
+            //            //}
+
+            //            using (var reader = cmd.ExecuteReader())
+            //            {
+            //                dt.Load(reader);
+
+
+
+            //                if (dt.Rows.Count > 1)
+            //                {
+            //                    bool bRet = false;
+            //                    foreach (DataRow row in dt.Rows)
+            //                    {
+            //                        retItem.FinishedDate = row["finish_date"].ToString();
+            //                        DateTime temDate = DateTime.Now;
+            //                        DateTime.TryParse(retItem.FinishedDate,out temDate);
+            //                        if ((Item.FinishedDate.HasValue && Item.FinishedDate.Value == temDate) ||
+            //                            (!string.IsNullOrEmpty(Item.CaseStage) && Item.CaseStage == row["review_stage"].ToString()))
+            //                        {
+            //                            GetItemData(retItem, row);
+
+            //                            bRet = true;
+            //                            break;
+            //                        }
+
+            //                    }
+
+            //                    if (!bRet)
+            //                    {
+            //                        DataRow row = dt.Rows[0];
+            //                        GetItemData(retItem, row);
+
+            //                    }
+            //                }
+            //                else
+            //                {
+            //                    if (dt.Rows.Count > 0)
+            //                    {
+            //                        DataRow row = dt.Rows[0];
+            //                        GetItemData(retItem, row);
+
+            //                    }
+
+            //                }
+
+
+            //            }
+            //        }
+            //    }
+            //    catch (Exception ex)
+            //    {
+            //        // error handling
+            //        throw;
+            //    }
+            //    finally
+            //    {
+            //        conn.Close();
+            //    }
+            //}
+
+            //return retItem;
+            #endregion
         }
 
         private static void GetItemData(dynamic retItem, DataRow row)
@@ -452,7 +493,7 @@ namespace wispro.sp.api.Job
             StreamWriter sw = File.AppendText("c:\\temp\\log.txt");
             sw.WriteLine($"{strMessage}");
             sw.Flush();
-            sw.Close();
+        sw.Close();
             sw.Dispose();
         }
     }

+ 1 - 0
wispro.sp.api/appsettings.json

@@ -26,6 +26,7 @@
     "Issuer": "http://localhost:39476"
   },
   "IPEasySetting": {
+    "ipEeasyApi": "http://localhost:22468",
     "ConnectionStrings": "Data Source=(local);Initial Catalog=IPEasy;User ID=sa;Password=Lqftiu807005",
     "DownloadFileSavePath": "c:\\temp",
     "isHeadless": "true",

+ 283 - 4
wispro.sp.ipeasyApi/Controllers/ipEasyController.cs

@@ -3,6 +3,11 @@ using Microsoft.AspNetCore.Mvc;
 using Microsoft.Data.SqlClient;
 using System;
 using System.Data;
+using System.Dynamic;
+using System.IO;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.Xml.Serialization;
+using wispro.sp.entity;
 using wispro.sp.utility;
 
 namespace wispro.sp.ipeasyApi.Controllers
@@ -17,8 +22,7 @@ namespace wispro.sp.ipeasyApi.Controllers
 		/// <param name="ReportName">报告名称</param>
 		/// <param name="isModifyDate">是否从上月1日开始取上月的整月数据</param>
 		/// <returns></returns>
-		[HttpGet,HttpPost]
-        public DataTable GetDataFromIPEasy(string ReportName, bool isModifyDate)
+        public byte[] GetDataFromIPEasy(string ReportName, bool isModifyDate)
         {
             DataTable dt = new DataTable();
             string strSQL = "";
@@ -321,7 +325,6 @@ namespace wispro.sp.ipeasyApi.Controllers
                     break;
             }
 
-
             using (var conn = new SqlConnection(ConfigHelper.GetSectionValue("IPEasySetting:ConnectionStrings")))
             {
 
@@ -350,7 +353,283 @@ namespace wispro.sp.ipeasyApi.Controllers
                 }
             }
 
-            return dt;
+            dt.TableName = $"{ReportName}";
+            MemoryStream memory = new MemoryStream();
+            XmlSerializer serializer = new XmlSerializer(typeof(System.Data.DataTable));
+            System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(memory);
+            serializer.Serialize(writer, dt);
+            byte[] temp = memory.ToArray();
+            
+			return temp;
         }
+
+		/// <summary>
+		/// 从维德系统中获取专案数据
+		/// </summary>
+		/// <returns></returns>
+		public byte[] getProjectDataFromIPEasy()
+		{
+            DataTable dt = new DataTable();
+            string strSQL = @"SELECT  p_case_info.case_volume as 我方文号,
+	                        p_case_info.case_volume_customer as 客户文号,
+	                        p_case_info.case_name as 案件名称,
+	                        p_case_info.charge_date as 委案日期,
+	                        i_case_status.case_status_zh_cn as 案件状态,
+	                        i_case_type.case_type_zh_cn as 案件类型,
+	                        p_case_info.app_no as 申请号,
+	                        p_case_info.app_date as 申请日,
+	                        i_business_type.business_type_zh_cn as 业务类型,
+	                        STUFF((SELECT ',' + u.cn_name from c_customer_user as cu 
+		                        inner join s_user_info as u on u.user_id = cu.user_id where cu.customer_id = p_case_info.customer_id FOR XML PATH('') ),1,1,'') as 流程负责人,
+	                        c_customer.customer_name as 客户名称,
+	                        STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl
+		                        inner join s_user_info as u on u.user_id = pl.revise_user_id where pl.obj_id = p_case_info.case_id   FOR XML PATH('') ),1,1,'') as 案件核稿人,
+	                        STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
+		                        inner join s_user_info as u on u.user_id = pl.pic_id where pl.obj_id = p_case_info.case_id   FOR XML PATH('') ),1,1,'') as 案件处理人,
+	                        p_case_info.create_time as 开卷日期,
+	                        STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl 
+		                        inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id 
+		                        where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员,
+	                        i_country.country_zh_cn as '国家(地区)'  
+                        from p_case_info
+	                        inner join   p_case_advance_info  with(nolock)  on p_case_info.case_id=p_case_advance_info.case_id  
+	                        inner join   i_apply_type  with(nolock)  on i_apply_type.apply_type_id=p_case_info.apply_type_id  
+	                        inner join   i_case_type  with(nolock)  on i_case_type.case_type_id=p_case_info.case_type_id  
+	                        inner join   i_country  with(nolock)  on i_country.country_id=p_case_info.country_id  
+	                        inner join   i_case_status  with(nolock)  on i_case_status.case_status_id=p_case_info.case_status_id  
+	                        inner join   c_customer  with(nolock)  on c_customer.customer_id=p_case_info.customer_id  
+	                        inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id 
+	                        inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id 
+                        where p_case_info.is_enabled=1 and  p_case_info.case_volume like 'S%' and not p_case_info.case_volume like 'SCN%'
+						and i_case_status.case_status_zh_cn<>'已完成' and i_case_status.case_status_zh_cn<>'结案'
+						order by 我方文号";
+
+            using (var conn = new SqlConnection(ConfigHelper.GetSectionValue("IPEasySetting:ConnectionStrings")))
+            {
+                try
+                {
+                    conn.Open();
+                    using (var cmd = conn.CreateCommand())
+                    {
+                        cmd.CommandText = strSQL;
+                        cmd.CommandType = CommandType.Text;
+
+                        using (var reader = cmd.ExecuteReader())
+                        {
+                            dt.Load(reader);
+                        }
+                    }
+                }
+                catch (Exception ex)
+                {
+                    throw ex;
+                }
+            }
+            dt.TableName = $"专案数据";
+            MemoryStream memory = new MemoryStream();
+            XmlSerializer serializer = new XmlSerializer(typeof(System.Data.DataTable));
+            System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(memory);
+            serializer.Serialize(writer, dt);
+            byte[] temp = memory.ToArray();
+
+            return temp;
+        }
+
+        /// <summary>
+		/// 从维德系统中获取案件信息
+		/// </summary>
+		/// <param name="CaseNo">案件号</param>
+		/// <param name="DoItem">处理事项</param>
+		/// <param name="CaseStage">案件阶段,默认为空</param>
+		/// <returns>返回案件记录,如果数据库中有多条记录,返回完成日最后的那条记录</returns>
+		[HttpGet, HttpPost]
+        public ExpandoObject GetItemFromIPEasyDB(string CaseNo,string DoItem,string CaseStage=null)
+        {
+            dynamic retItem = new ExpandoObject();
+
+            var dt = new DataTable();
+            using (var conn = new SqlConnection(ConfigHelper.GetSectionValue("IPEasySetting:ConnectionStrings")))
+            {
+
+                try
+                {
+                    conn.Open();
+
+                    string strSql = @"SELECT distinct  p_case_info.case_volume as case_volume,
+		            i_apply_type.apply_type_zh_cn as apply_type_zh_cn,
+		            i_business_type.business_type_zh_cn as business_type_zh_cn,
+		            i_ctrl_proc.ctrl_proc_zh_cn as ctrl_proc_zh_cn,
+		            (select case_status_zh_cn from i_case_status where case_status_id=p_proc_info.review_stage)  as review_stage,
+		            i_case_coefficient.case_coefficient_zh_cn as case_coefficient,
+		            i_proc_coefficient.proc_coefficient_zh_cn as proc_coefficient,
+		            (select  proc_coefficient_zh_cn from p_proc_info pr 
+			            left join i_proc_coefficient pc on pc.proc_coefficient_id=pr.proc_coefficient_id 
+			            where case_id=p_case_info.case_id and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5' 
+				            and pr.seq=
+					            (select max(seq) from p_proc_info pr where case_id=p_case_info.case_id 
+						            and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'and seq<p_proc_info.seq)
+					            ) as oa_proc_coefficient,
+		            (STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
+			            inner join s_user_info as u on u.user_id = pl.pic_id 
+			            inner join  p_proc_info pr1 on pr1.proc_id=pl.obj_id 
+				            where case_id=p_case_info.case_id and 
+					            ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5' 
+					            and pr1.seq=(
+						            select max(seq) from p_proc_info pr2 where case_id=p_case_info.case_id 
+						            and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5' 
+						            and seq<p_proc_info.seq) FOR XML PATH('') ),1,1,'')) 
+		            as oa_pic_list,
+		            STUFF((SELECT ',' + ur.rank_zh_cn from p_proc_pic_list as pl   
+			            inner join s_user_info as u on u.user_id = pl.pic_id 
+			            left join i_user_rank ur on ur.rank_id=u.rank_id 
+			            where pl.obj_id = p_proc_info.proc_id   FOR XML PATH('') ),1,1,'') as user_rank,
+		            STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl   
+			            inner join s_user_info as u on u.user_id = pl.pic_id 
+			            where pl.obj_id = p_proc_info.proc_id   FOR XML PATH('') ),1,1,'') as pic,
+		            STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl   
+			            inner join s_user_info as u on u.user_id = pl.revise_user_id 
+			            where pl.obj_id = p_proc_info.proc_id   FOR XML PATH('') ),1,1,'') as reviser,
+		            c_customer.customer_name as customer_name,
+		            STUFF((SELECT ',' + a.applicant_name_cn from p_applicant_list as al 
+			            inner join i_applicant as a on a.applicant_id = al.applicant_id 
+			            where al.obj_id = p_case_info.case_id order by al.seq FOR XML PATH('') ),1,1,'') as applicants,
+		            p_proc_info.finish_date as finish_date,
+		            p_proc_info.finish_doc_date as finish_doc_date,
+		            p_proc_info.back_date as back_date,
+		            i_case_type.case_type_zh_cn as case_type_zh_cn,
+		            i_case_status.case_status_zh_cn as case_status_zh_cn,
+		            p_proc_info.proc_note as proc_note,
+		            (select proc_status_zh_cn from i_proc_status where proc_status_id=p_proc_info.proc_status_id) as proc_status_zh_cn,
+		            p_case_info.case_name as case_name,
+		            p_case_info.charge_date as charge_date,
+		            p_proc_info.cus_due_date as cus_due_date,
+		            p_proc_info.int_due_date as int_due_date,
+		            p_proc_info.first_doc_date as first_doc_date,
+		            p_case_info.remark as case_remark,
+		            p_proc_info.translate_count as translate_count,
+		            STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl 
+			            inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id 
+			            where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as sales,
+		            i_country.country_zh_cn as country_zh_cn  
+	            from p_case_info  
+		            inner join   p_case_advance_info  with(nolock)  on p_case_info.case_id=p_case_advance_info.case_id  
+		            inner join   i_apply_type  with(nolock)  on i_apply_type.apply_type_id=p_case_info.apply_type_id  
+		            inner join   i_case_type  with(nolock)  on i_case_type.case_type_id=p_case_info.case_type_id  
+		            inner join   i_country  with(nolock)  on i_country.country_id=p_case_info.country_id  
+		            inner join   i_case_status  with(nolock)  on i_case_status.case_status_id=p_case_info.case_status_id  
+		            inner join   c_customer  with(nolock)  on c_customer.customer_id=p_case_info.customer_id 
+		            left join i_case_coefficient on i_case_coefficient.case_coefficient_id=p_case_info.case_coefficient_id  
+		            inner join   p_proc_info  with(nolock)  on p_case_info.case_id=p_proc_info.case_id  
+		            inner join   i_ctrl_proc  with(nolock)  on p_proc_info.ctrl_proc_id=i_ctrl_proc.ctrl_proc_id 
+		            inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id 
+		            left join p_proc_pic_list with(nolock) on p_proc_pic_list.obj_id=p_proc_info.proc_id 
+		            left join s_user_info with(nolock) on s_user_info.user_id=p_proc_pic_list.pic_id 
+		            left join i_proc_coefficient on i_proc_coefficient.proc_coefficient_id=p_proc_info.proc_coefficient_id 
+	            where 
+		            p_case_info.is_enabled=1 and 
+		            p_proc_info.is_enabled=1 and 
+		            s_user_info.dept_id not in ('60e09ee0-fcc7-446f-badc-af9973079fee','34d0e351-71dc-418f-9b6b-bcb67af62fed','599cbe0c-044e-4ffc-9411-96dd9019d8a6') and 
+		            (p_case_info.case_type_id='31D1A147-2931-43B5-94AE-B72B1525BA8A') AND  
+		            i_ctrl_proc.ctrl_proc_zh_cn=@DoItem and 
+		            p_case_info.case_volume =@CaseNo";
+
+                    using (var cmd = conn.CreateCommand())
+                    {
+                        cmd.CommandText = strSql;
+                        cmd.CommandType = CommandType.Text;
+                        cmd.Parameters.Add(new SqlParameter("DoItem", DoItem.Trim()));
+                        cmd.Parameters.Add(new SqlParameter("CaseNo", CaseNo.Trim()));
+                        
+                        using (var reader = cmd.ExecuteReader())
+                        {
+                            dt.Load(reader);
+
+
+
+                            if (dt.Rows.Count > 1)
+                            {
+                                bool bRet = false;
+								DateTime preFinishedDate = DateTime.MinValue;
+                                foreach (DataRow row in dt.Rows)
+                                {
+                                    
+                                    DateTime temDate = DateTime.Now;
+                                    DateTime.TryParse(row["finish_date"].ToString(), out temDate);
+                                    if ((preFinishedDate < temDate) &&
+                                        (!string.IsNullOrEmpty(CaseStage) && CaseStage == row["review_stage"].ToString()))
+                                    {
+										preFinishedDate = temDate;
+                                        GetItemData(retItem, row);
+
+                                        bRet = true;
+                                        //break;
+                                    }
+
+                                }
+
+                                if (!bRet)
+                                {
+                                    DataRow row = dt.Rows[0];
+                                    GetItemData(retItem, row);
+
+                                }
+                            }
+                            else
+                            {
+                                if (dt.Rows.Count > 0)
+                                {
+                                    DataRow row = dt.Rows[0];
+                                    GetItemData(retItem, row);
+
+                                }
+
+                            }
+
+
+                        }
+                    }
+                }
+                catch (Exception ex)
+                {
+                    // error handling
+                    throw;
+                }
+                finally
+                {
+                    conn.Close();
+                }
+            }
+
+            return retItem as ExpandoObject;
+        }
+
+        private static void GetItemData(dynamic retItem, DataRow row)
+        {
+            retItem.CaseNo = row["case_volume"].ToString();
+            retItem.ApplicationType = row["apply_type_zh_cn"].ToString();
+            retItem.BusinessType = row["business_type_zh_cn"].ToString();
+            retItem.DoItem = row["ctrl_proc_zh_cn"].ToString(); ;
+            retItem.CaseStage = row["review_stage"].ToString();
+            retItem.CaseCoefficient = row["case_coefficient"].ToString();
+            retItem.DoItemCoefficient = row["proc_coefficient"].ToString();
+            retItem.DoPersons = row["pic"].ToString();
+            retItem.Reviewer = row["reviser"].ToString();
+            retItem.CustomerName = row["customer_name"].ToString();
+            retItem.FinishedDate = row["finish_date"].ToString();
+            retItem.WordCount = row["translate_count"].ToString();
+            retItem.ReturnDate = row["back_date"].ToString();
+            retItem.CaseType = row["case_type_zh_cn"].ToString();
+            retItem.CaseState = row["case_status_zh_cn"].ToString();
+            retItem.DoItemMemo = row["proc_status_zh_cn"].ToString();
+            retItem.DoItemState = row["proc_note"].ToString();
+            retItem.CaseName = row["case_name"].ToString();
+            retItem.EntrustingDate = row["charge_date"].ToString();
+            retItem.CustomerLimitDate = row["cus_due_date"].ToString();
+            retItem.InternalDate = row["int_due_date"].ToString();
+            retItem.FirstDraftDate = row["first_doc_date"].ToString();
+            retItem.CaseMemo = row["case_remark"].ToString();
+            retItem.FinalizationDate = row["finish_doc_date"].ToString();
+        }
+
     }
 }

+ 2 - 2
wispro.sp.ipeasyApi/Properties/launchSettings.json

@@ -12,7 +12,7 @@
     "IIS Express": {
       "commandName": "IISExpress",
       "launchBrowser": true,
-      "launchUrl": "api/GetDataFromIPEasy",
+      "launchUrl": "swagger",
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       }
@@ -21,7 +21,7 @@
       "commandName": "Project",
       "dotnetRunMessages": "true",
       "launchBrowser": true,
-      "launchUrl": "api/GetDataFromIPEasy",
+      "launchUrl": "swagger",
       "applicationUrl": "http://localhost:5000",
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"

+ 12 - 0
wispro.sp.ipeasyApi/Startup.cs

@@ -25,6 +25,16 @@ namespace wispro.sp.ipeasyApi
         // This method gets called by the runtime. Use this method to add services to the container.
         public void ConfigureServices(IServiceCollection services)
         {
+            services.AddCors(options =>
+            {
+                options.AddPolicy("any",
+                builder =>
+                {
+                    builder.AllowAnyOrigin()
+                           .AllowAnyMethod()
+                           .AllowAnyHeader();
+                });
+            });
 
             services.AddControllers();
             services.AddSwaggerGen(c =>
@@ -45,6 +55,8 @@ namespace wispro.sp.ipeasyApi
 
             app.UseRouting();
 
+            app.UseCors("any");
+
             app.UseAuthorization();
 
             app.UseEndpoints(endpoints =>

+ 2 - 0
wispro.sp.ipeasyApi/wispro.sp.ipeasyApi.csproj

@@ -10,7 +10,9 @@
   </ItemGroup>
 
   <ItemGroup>
+    <ProjectReference Include="..\wispro.sp.share\wispro.sp.share.csproj" />
     <ProjectReference Include="..\wispro.sp.utility\wispro.sp.utility.csproj" />
+    <ProjectReference Include="..\wospro.sp.entity\wispro.sp.entity.csproj" />
   </ItemGroup>
 
 </Project>

+ 66 - 1
wispro.sp.winClient/Form1.cs

@@ -1,4 +1,5 @@
-using DynamicExpresso;
+using AntDesign;
+using DynamicExpresso;
 using Microsoft.International.Converters.PinYinConverter;
 using System;
 using System.Collections.Generic;
@@ -13,10 +14,12 @@ using System.IO;
 using System.Linq;
 using System.Net.Http;
 using System.Net.Http.Json;
+using System.Runtime.Serialization.Formatters.Binary;
 using System.Text;
 using System.Text.Json;
 using System.Threading.Tasks;
 using System.Windows.Forms;
+using System.Xml.Serialization;
 using wispro.sp.entity;
 using wispro.sp.entity.workflowDefine;
 using wispro.sp.share;
@@ -1034,6 +1037,8 @@ namespace wispro.sp.winClient
             }
         }
 
+
+
         private async Task StatisticsLevelCount(int year, int month)
         {
             HttpClient http = CreateHttp();
@@ -1350,8 +1355,68 @@ namespace wispro.sp.winClient
 
         }
 
+        private async Task<dynamic> GetPerformanceItemFromIPEasy()
+        {
+            HttpClient http = new HttpClient();
+
+            var response = http.GetFromJsonAsync<Object>($"http://localhost:22468/api/ipEasy/GetItemFromIPEasyDB?CaseNo=PADE1510724&DoItem=处理审查意见").Result;
+            
+            dynamic retItem = new ExpandoObject();
+
+            JsonElement json = ((System.Text.Json.JsonElement)response);
+            retItem.CaseNo = json.GetProperty("CaseNo").GetString();
+            retItem.ApplicationType = json.GetProperty("ApplicationType").GetString();
+            retItem.BusinessType = json.GetProperty("BusinessType").GetString();
+            retItem.DoItem = json.GetProperty("DoItem").GetString();
+            retItem.CaseStage = json.GetProperty("CaseStage").GetString();
+            retItem.CaseCoefficient = json.GetProperty("CaseCoefficient").GetString();
+            retItem.DoItemCoefficient = json.GetProperty("DoItemCoefficient").GetString();
+            retItem.DoPersons = json.GetProperty("DoPersons").GetString();
+            retItem.Reviewer = json.GetProperty("Reviewer").GetString();
+            retItem.CustomerName = json.GetProperty("CustomerName").GetString();
+            retItem.FinishedDate = json.GetProperty("FinishedDate").GetString();
+            retItem.WordCount = json.GetProperty("WordCount").GetString();
+            retItem.ReturnDate = json.GetProperty("ReturnDate").GetString();
+            retItem.CaseType = json.GetProperty("CaseType").GetString();
+            retItem.CaseState = json.GetProperty("CaseState").GetString();
+            retItem.DoItemMemo = json.GetProperty("DoItemMemo").GetString();
+            retItem.DoItemState = json.GetProperty("DoItemState").GetString();
+            retItem.CaseName = json.GetProperty("CaseName").GetString();
+            retItem.EntrustingDate = json.GetProperty("EntrustingDate").GetString();
+            retItem.CustomerLimitDate = json.GetProperty("CustomerLimitDate").GetString();
+            retItem.InternalDate = json.GetProperty("InternalDate").GetString();
+            retItem.FirstDraftDate = json.GetProperty("FirstDraftDate").GetString();
+            retItem.CaseMemo = json.GetProperty("CaseMemo").GetString();
+            retItem.FinalizationDate = json.GetProperty("FinalizationDate").GetString();
+
+
+
+            var bytRespon =http.GetAsync($"http://localhost:22468/api/ipEasy/GetDataFromIPEasy?ReportName=每月绩效统计--发客户超过一个月未完成案件&isModifyDate=true").Result;
+            //byte[] data = await http.GetByteArrayAsync($"http://localhost:22468/api/ipEasy/GetDataFromIPEasy?ReportName=每月绩效统计--发客户超过一个月未完成案件&isModifyDate=true");
+
+            if (bytRespon.IsSuccessStatusCode)
+            {
+                string result = bytRespon.Content.ReadAsStringAsync().Result.Replace("\"", string.Empty);
+                byte[] data = Convert.FromBase64String(result);
+                //byte[] data = bytRespon.Content.ReadAsByteArrayAsync().Result;//Here is the problem
+                XmlSerializer serializer = new XmlSerializer(typeof(System.Data.DataTable));
+                MemoryStream memory = new MemoryStream(data);
+                DataTable dt = (DataTable)serializer.Deserialize(memory);
+            }
+
+            
+
+            return response;
+        }
         private async void button4_Click_1(object sender, EventArgs e)
         {
+            dynamic ret = await GetPerformanceItemFromIPEasy();
+            //if (ret != null)
+            {
+                //System.Diagnostics.Debug.WriteLine(ret.ToString());
+            }
+            return;
+
             if (Token == null)
             {
                 await Login();