ipEasyController.cs 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. using Microsoft.AspNetCore.Http;
  2. using Microsoft.AspNetCore.Mvc;
  3. using Microsoft.Data.SqlClient;
  4. using System;
  5. using System.Data;
  6. using System.Dynamic;
  7. using System.IO;
  8. using System.Runtime.Serialization.Formatters.Binary;
  9. using System.Xml.Serialization;
  10. using wispro.sp.entity;
  11. using wispro.sp.utility;
  12. namespace wispro.sp.ipeasyApi.Controllers
  13. {
  14. [Route("api/[controller]/[action]")]
  15. [ApiController]
  16. public class ipEasyController : ControllerBase
  17. {
  18. /// <summary>
  19. /// 从维德系统中获取报表数据
  20. /// </summary>
  21. /// <param name="ReportName">报告名称</param>
  22. /// <param name="isModifyDate">是否从上月1日开始取上月的整月数据</param>
  23. /// <returns></returns>
  24. public byte[] GetDataFromIPEasy(string ReportName, bool isModifyDate)
  25. {
  26. DataTable dt = new DataTable();
  27. string strSQL = "";
  28. switch (ReportName)
  29. {
  30. case "每月绩效统计--发客户超过一个月未完成案件":
  31. strSQL = @"SELECT p_case_info.case_volume as 我方文号,
  32. i_apply_type.apply_type_zh_cn as 申请类型,
  33. i_business_type.business_type_zh_cn as 业务类型,
  34. i_ctrl_proc.ctrl_proc_zh_cn as 处理事项,
  35. (select case_status_zh_cn from i_case_status where case_status_id=p_proc_info.review_stage) as 案件阶段,
  36. i_case_coefficient.case_coefficient_zh_cn as 案件系数,
  37. i_proc_coefficient.proc_coefficient_zh_cn as 处理事项系数,
  38. (select proc_coefficient_zh_cn from p_proc_info pr
  39. left join i_proc_coefficient pc on pc.proc_coefficient_id=pr.proc_coefficient_id
  40. where case_id=p_case_info.case_id and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'
  41. and pr.seq=
  42. (select max(seq) from p_proc_info pr where case_id=p_case_info.case_id
  43. and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'and seq<p_proc_info.seq)
  44. ) as 前一次OA处理事项系数,
  45. (STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
  46. inner join s_user_info as u on u.user_id = pl.pic_id
  47. inner join p_proc_info pr1 on pr1.proc_id=pl.obj_id
  48. where case_id=p_case_info.case_id and
  49. ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'
  50. and pr1.seq=(
  51. select max(seq) from p_proc_info pr2 where case_id=p_case_info.case_id
  52. and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'
  53. and seq<p_proc_info.seq) FOR XML PATH('') ),1,1,'')) as 前一次OA处理人,
  54. STUFF((SELECT ',' + ur.rank_zh_cn from p_proc_pic_list as pl
  55. inner join s_user_info as u on u.user_id = pl.pic_id
  56. left join i_user_rank ur on ur.rank_id=u.rank_id
  57. where pl.obj_id = p_proc_info.proc_id FOR XML PATH('') ),1,1,'') as 处理人等级,
  58. STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
  59. inner join s_user_info as u on u.user_id = pl.pic_id
  60. where pl.obj_id = p_proc_info.proc_id FOR XML PATH('') ),1,1,'') as 处理人,
  61. STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl
  62. inner join s_user_info as u on u.user_id = pl.revise_user_id
  63. where pl.obj_id = p_proc_info.proc_id FOR XML PATH('') ),1,1,'') as 核稿人,
  64. c_customer.customer_name as 客户名称,
  65. STUFF((SELECT ',' + a.applicant_name_cn from p_applicant_list as al
  66. inner join i_applicant as a on a.applicant_id = al.applicant_id
  67. where al.obj_id = p_case_info.case_id order by al.seq FOR XML PATH('') ),1,1,'') as 申请人,
  68. p_proc_info.finish_date as 处理事项完成日,
  69. p_proc_info.finish_doc_date as 定稿日,
  70. p_proc_info.back_date as 返稿日,
  71. i_case_type.case_type_zh_cn as 案件类型,
  72. i_case_status.case_status_zh_cn as 案件状态,
  73. p_proc_info.proc_note as 处理事项备注,
  74. (select proc_status_zh_cn from i_proc_status where proc_status_id=p_proc_info.proc_status_id) as 处理状态,
  75. p_case_info.case_name as 案件名称,
  76. p_case_info.charge_date as 委案日期,
  77. p_proc_info.cus_due_date as 客户期限,
  78. p_proc_info.int_due_date as 内部期限,
  79. p_proc_info.first_doc_date as 初稿日,
  80. p_case_info.remark as 案件备注,
  81. p_proc_info.translate_count as 翻译字数,
  82. STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl
  83. inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id
  84. where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员,
  85. i_country.country_zh_cn as '国家(地区)'
  86. from p_case_info
  87. inner join p_case_advance_info with(nolock) on p_case_info.case_id=p_case_advance_info.case_id
  88. inner join i_apply_type with(nolock) on i_apply_type.apply_type_id=p_case_info.apply_type_id
  89. inner join i_case_type with(nolock) on i_case_type.case_type_id=p_case_info.case_type_id
  90. inner join i_country with(nolock) on i_country.country_id=p_case_info.country_id
  91. inner join i_case_status with(nolock) on i_case_status.case_status_id=p_case_info.case_status_id
  92. inner join c_customer with(nolock) on c_customer.customer_id=p_case_info.customer_id
  93. left join i_case_coefficient on i_case_coefficient.case_coefficient_id=p_case_info.case_coefficient_id
  94. inner join p_proc_info with(nolock) on p_case_info.case_id=p_proc_info.case_id
  95. inner join i_ctrl_proc with(nolock) on p_proc_info.ctrl_proc_id=i_ctrl_proc.ctrl_proc_id
  96. inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id
  97. inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id
  98. left join p_proc_pic_list with(nolock) on p_proc_pic_list.obj_id=p_proc_info.proc_id
  99. left join s_user_info with(nolock) on s_user_info.user_id=p_proc_pic_list.pic_id
  100. left join i_proc_coefficient on i_proc_coefficient.proc_coefficient_id=p_proc_info.proc_coefficient_id
  101. where
  102. p_case_info.is_enabled=1 and p_proc_info.is_enabled=1 and
  103. s_user_info.dept_id not in ('60e09ee0-fcc7-446f-badc-af9973079fee','34d0e351-71dc-418f-9b6b-bcb67af62fed','599cbe0c-044e-4ffc-9411-96dd9019d8a6') and
  104. p_proc_info.finish_date is null
  105. and p_proc_info.back_date<DATEADD(MM,-1,DATEADD(MM, DATEDIFF(MM,0,getdate()), 0)) and
  106. (p_case_info.case_type_id='31D1A147-2931-43B5-94AE-B72B1525BA8A' ) AND
  107. ( i_ctrl_proc.ctrl_proc_zh_cn='新申请'
  108. or i_ctrl_proc.ctrl_proc_zh_cn='Non'
  109. or i_ctrl_proc.ctrl_proc_zh_cn='无效宣告'
  110. or i_ctrl_proc.ctrl_proc_zh_cn='意见陈述'
  111. or i_ctrl_proc.ctrl_proc_zh_cn='专利挖掘与布局'
  112. or i_ctrl_proc.ctrl_proc_zh_cn='处理审查意见'
  113. or i_ctrl_proc.ctrl_proc_zh_cn='Final'
  114. or i_ctrl_proc.ctrl_proc_zh_cn='复审通知意见陈述'
  115. or i_ctrl_proc.ctrl_proc_zh_cn='申復'
  116. or i_ctrl_proc.ctrl_proc_zh_cn='RCE'
  117. or i_ctrl_proc.ctrl_proc_zh_cn='翻译'
  118. or i_ctrl_proc.ctrl_proc_zh_cn='提出异议复审'
  119. or i_ctrl_proc.ctrl_proc_zh_cn='Advisory'
  120. or i_ctrl_proc.ctrl_proc_zh_cn='复审'
  121. or i_ctrl_proc.ctrl_proc_zh_cn='请求复审'
  122. or i_ctrl_proc.ctrl_proc_zh_cn='提出报告'
  123. or i_ctrl_proc.ctrl_proc_zh_cn='提出公众意见'
  124. or i_ctrl_proc.ctrl_proc_zh_cn='诉讼'
  125. or i_ctrl_proc.ctrl_proc_zh_cn='提出异议'
  126. or i_ctrl_proc.ctrl_proc_zh_cn='补充理由和证据'
  127. or i_ctrl_proc.ctrl_proc_zh_cn='无效分析'
  128. or i_ctrl_proc.ctrl_proc_zh_cn='无效答辩'
  129. )";
  130. break;
  131. case "每月绩效统计--上个月递交完成案件":
  132. strSQL = @"SELECT
  133. p_case_info.case_volume as 我方文号,
  134. i_apply_type.apply_type_zh_cn as 申请类型,
  135. i_business_type.business_type_zh_cn as 业务类型,
  136. i_ctrl_proc.ctrl_proc_zh_cn as 处理事项,
  137. (select case_status_zh_cn from i_case_status where case_status_id=p_proc_info.review_stage) as 案件阶段,
  138. i_case_coefficient.case_coefficient_zh_cn as 案件系数,
  139. i_proc_coefficient.proc_coefficient_zh_cn as 处理事项系数,
  140. (select
  141. proc_coefficient_zh_cn from p_proc_info pr
  142. left join i_proc_coefficient pc on pc.proc_coefficient_id=pr.proc_coefficient_id
  143. where case_id=p_case_info.case_id
  144. and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'
  145. and pr.seq=(select max(seq) from p_proc_info pr where case_id=p_case_info.case_id
  146. and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'and seq<p_proc_info.seq)
  147. ) as 前一次OA处理事项系数,
  148. (STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
  149. inner join s_user_info as u on u.user_id = pl.pic_id
  150. inner join p_proc_info pr1 on pr1.proc_id=pl.obj_id
  151. where case_id=p_case_info.case_id
  152. and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'
  153. and pr1.seq=(select max(seq) from p_proc_info pr2 where case_id=p_case_info.case_id
  154. and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'and seq<p_proc_info.seq) FOR XML PATH('') ),1,1,'')
  155. ) as 前一次OA处理人,
  156. STUFF((SELECT ',' + ur.rank_zh_cn from p_proc_pic_list as pl
  157. inner join s_user_info as u on u.user_id = pl.pic_id
  158. 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 处理人等级,
  159. STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
  160. inner join s_user_info as u on u.user_id = pl.pic_id
  161. where pl.obj_id = p_proc_info.proc_id FOR XML PATH('') ),1,1,'') as 处理人,
  162. STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl
  163. inner join s_user_info as u on u.user_id = pl.revise_user_id
  164. where pl.obj_id = p_case_info.case_id FOR XML PATH('') ),1,1,'') as 案件核稿人,
  165. c_customer.customer_name as 客户名称,
  166. STUFF((SELECT ',' + a.applicant_name_cn from p_applicant_list as al
  167. inner join i_applicant as a on a.applicant_id = al.applicant_id
  168. where al.obj_id = p_case_info.case_id order by al.seq FOR XML PATH('') ),1,1,'') as 申请人,
  169. p_proc_info.finish_date as 处理事项完成日,
  170. p_proc_info.finish_doc_date as 定稿日,
  171. p_proc_info.back_date as 返稿日,
  172. i_case_type.case_type_zh_cn as 案件类型,
  173. i_case_status.case_status_zh_cn as 案件状态,
  174. p_proc_info.proc_note as 处理事项备注,
  175. (select proc_status_zh_cn from i_proc_status where proc_status_id=p_proc_info.proc_status_id) as 处理状态,
  176. p_case_info.case_name as 案件名称,
  177. p_case_info.charge_date as 委案日期,
  178. p_proc_info.cus_due_date as 客户期限,
  179. p_proc_info.int_due_date as 内部期限,
  180. p_proc_info.first_doc_date as 初稿日,
  181. p_case_info.remark as 案件备注,
  182. p_proc_info.translate_count as 翻译字数,
  183. STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl
  184. inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id
  185. where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员,
  186. i_country.country_zh_cn as '国家(地区)'
  187. from p_case_info
  188. inner join p_case_advance_info with(nolock) on p_case_info.case_id=p_case_advance_info.case_id
  189. inner join i_apply_type with(nolock) on i_apply_type.apply_type_id=p_case_info.apply_type_id
  190. inner join i_case_type with(nolock) on i_case_type.case_type_id=p_case_info.case_type_id
  191. inner join i_country with(nolock) on i_country.country_id=p_case_info.country_id
  192. inner join i_case_status with(nolock) on i_case_status.case_status_id=p_case_info.case_status_id
  193. inner join c_customer with(nolock) on c_customer.customer_id=p_case_info.customer_id
  194. left join i_case_coefficient on i_case_coefficient.case_coefficient_id=p_case_info.case_coefficient_id
  195. inner join p_proc_info with(nolock) on p_case_info.case_id=p_proc_info.case_id
  196. inner join i_ctrl_proc with(nolock) on p_proc_info.ctrl_proc_id=i_ctrl_proc.ctrl_proc_id
  197. inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id
  198. inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id
  199. left join p_proc_pic_list with(nolock) on p_proc_pic_list.obj_id=p_proc_info.proc_id
  200. left join s_user_info with(nolock) on s_user_info.user_id=p_proc_pic_list.pic_id
  201. left join i_proc_coefficient on i_proc_coefficient.proc_coefficient_id=p_proc_info.proc_coefficient_id
  202. where
  203. p_case_info.is_enabled=1
  204. and p_proc_info.is_enabled=1
  205. and s_user_info.dept_id not in ('60e09ee0-fcc7-446f-badc-af9973079fee','34d0e351-71dc-418f-9b6b-bcb67af62fed','599cbe0c-044e-4ffc-9411-96dd9019d8a6')
  206. and (p_case_info.case_type_id='31D1A147-2931-43B5-94AE-B72B1525BA8A' )
  207. AND ((p_proc_info.finish_date >= @beginTime and p_proc_info.finish_date<@endTime)) ";
  208. break;
  209. case "每月绩效统计--中国一次OA授权表":
  210. strSQL = @"select
  211. p_case_info.case_volume as 我方文号,
  212. p_case_info.case_name as 案件名称,
  213. p_case_info.app_no as 申请号,
  214. c_customer.customer_name as 客户名称,
  215. STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
  216. inner join s_user_info as u on u.user_id = pl.pic_id
  217. where pl.obj_id = p_case_info.case_id FOR XML PATH('') ),1,1,'') as 案件处理人,
  218. STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl
  219. inner join s_user_info as u on u.user_id = pl.revise_user_id
  220. where pl.obj_id = p_case_info.case_id FOR XML PATH('') ),1,1,'') as 案件核稿人,
  221. p_file_list.post_date as 发文日期,
  222. p_case_info.case_volume_customer as 客户文号,
  223. p_case_info.app_date as 申请日,
  224. i_country.country_zh_cn as '国家(地区)',
  225. STUFF((SELECT ',' + a.applicant_name_cn from p_applicant_list as al
  226. inner join i_applicant as a on a.applicant_id = al.applicant_id
  227. where al.obj_id = p_case_info.case_id order by al.seq FOR XML PATH('') ),1,1,'') as 申请人,
  228. p_file_list.upload_time as 上传日期,
  229. i_file_desc.file_desc_zh_cn as 文件描述,
  230. i_apply_type.apply_type_zh_cn as 申请类型,
  231. STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl
  232. inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id
  233. where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员
  234. from p_case_info
  235. inner join i_apply_type on p_case_info.apply_type_id=i_apply_type.apply_type_id
  236. inner join p_proc_info on p_case_info.case_id=p_proc_info.case_id
  237. inner join p_file_list on p_file_list.obj_id=p_proc_info.proc_id
  238. inner join i_file_desc on i_file_desc.file_desc_id=p_file_list.file_desc_id
  239. inner join c_customer on p_case_info.customer_id=c_customer.customer_id
  240. inner join i_country on i_country.country_id=p_case_info.country_id
  241. where
  242. p_case_info.is_enabled=1
  243. and p_proc_info.is_enabled=1 and p_case_info.country_id='CN'
  244. and p_file_list.file_desc_id='09800D39-D585-49F3-B9DE-50AC689DE9AB'
  245. and p_file_list.file_name not like '%.zip'
  246. 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
  247. and (p_case_info.case_type_id='31D1A147-2931-43B5-94AE-B72B1525BA8A' )
  248. AND ((p_file_list.upload_time >= @beginTime and p_file_list.upload_time<@endTime))";
  249. break;
  250. case "每月绩效统计--专案进度跟踪~S卷":
  251. strSQL = @"SELECT p_case_info.case_volume as 我方文号,
  252. p_case_info.case_name as 案件名称,
  253. i_case_type.case_type_zh_cn as 案件类型,
  254. i_business_type.business_type_zh_cn as 业务类型,
  255. i_country.country_zh_cn as '国家(地区)',
  256. c_customer.customer_name as 客户名称,
  257. s_dept_info.dept_full_name as 承办部门,
  258. i_case_status.case_status_zh_cn as 案件状态,
  259. i_ctrl_proc.ctrl_proc_zh_cn as 处理事项,
  260. p_proc_info.int_due_date as 内部期限,
  261. p_proc_info.cus_due_date as 客户期限,
  262. p_proc_info.legal_due_date as 官方期限,
  263. p_proc_info.finish_doc_date as 定稿日,
  264. STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
  265. inner join s_user_info as u on u.user_id = pl.pic_id where pl.obj_id = p_proc_info.proc_id
  266. FOR XML PATH('') ),1,1,'') as 处理人,
  267. p_case_info.charge_date as 委案日期,
  268. (select proc_status_zh_cn from i_proc_status where proc_status_id=p_proc_info.proc_status_id) as 处理状态,
  269. p_proc_info.first_doc_date as 初稿日,
  270. STUFF((SELECT ',' + u.cn_name from c_customer_user as cu
  271. inner join s_user_info as u on u.user_id = cu.user_id
  272. where cu.customer_id = p_case_info.customer_id FOR XML PATH('') ),1,1,'') as 流程负责人,
  273. p_proc_info.finish_date as 处理事项完成日,
  274. STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl
  275. inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id
  276. where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员
  277. from p_case_info
  278. inner join p_case_advance_info with(nolock) on p_case_info.case_id=p_case_advance_info.case_id
  279. inner join i_apply_type with(nolock) on i_apply_type.apply_type_id=p_case_info.apply_type_id
  280. inner join i_case_type with(nolock) on i_case_type.case_type_id=p_case_info.case_type_id
  281. inner join i_country with(nolock) on i_country.country_id=p_case_info.country_id
  282. inner join i_case_status with(nolock) on i_case_status.case_status_id=p_case_info.case_status_id
  283. inner join c_customer with(nolock) on c_customer.customer_id=p_case_info.customer_id
  284. inner join p_proc_info with(nolock) on p_case_info.case_id=p_proc_info.case_id
  285. inner join i_ctrl_proc with(nolock) on p_proc_info.ctrl_proc_id=i_ctrl_proc.ctrl_proc_id
  286. inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id
  287. inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id
  288. where p_case_info.is_enabled=1 and p_proc_info.is_enabled=1 and
  289. (isnull (p_proc_info.finish_date,'') ='') AND (i_ctrl_proc.ctrl_proc_zh_cn='提出报告')";
  290. break;
  291. case "每月绩效统计--专案开卷报表~S卷":
  292. strSQL = @"SELECT p_case_info.case_volume as 我方文号,
  293. p_case_info.case_volume_customer as 客户文号,
  294. p_case_info.case_name as 案件名称,
  295. p_case_info.charge_date as 委案日期,
  296. i_case_status.case_status_zh_cn as 案件状态,
  297. i_case_type.case_type_zh_cn as 案件类型,
  298. p_case_info.app_no as 申请号,
  299. p_case_info.app_date as 申请日,
  300. i_business_type.business_type_zh_cn as 业务类型,
  301. STUFF((SELECT ',' + u.cn_name from c_customer_user as cu
  302. 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 流程负责人,
  303. c_customer.customer_name as 客户名称,
  304. STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl
  305. 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 案件核稿人,
  306. STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
  307. 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 案件处理人,
  308. p_case_info.create_time as 开卷日期,
  309. STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl
  310. inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id
  311. where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员,
  312. i_country.country_zh_cn as '国家(地区)'
  313. from p_case_info
  314. inner join p_case_advance_info with(nolock) on p_case_info.case_id=p_case_advance_info.case_id
  315. inner join i_apply_type with(nolock) on i_apply_type.apply_type_id=p_case_info.apply_type_id
  316. inner join i_case_type with(nolock) on i_case_type.case_type_id=p_case_info.case_type_id
  317. inner join i_country with(nolock) on i_country.country_id=p_case_info.country_id
  318. inner join i_case_status with(nolock) on i_case_status.case_status_id=p_case_info.case_status_id
  319. inner join c_customer with(nolock) on c_customer.customer_id=p_case_info.customer_id
  320. inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id
  321. inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id
  322. 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%'
  323. and i_case_status.case_status_zh_cn<>'已完成' and i_case_status.case_status_zh_cn<>'结案'";
  324. break;
  325. }
  326. using (var conn = new SqlConnection(ConfigHelper.GetSectionValue("IPEasySetting:ConnectionStrings")))
  327. {
  328. try
  329. {
  330. conn.Open();
  331. using (var cmd = conn.CreateCommand())
  332. {
  333. cmd.CommandText = strSQL;
  334. cmd.CommandType = CommandType.Text;
  335. if (isModifyDate)
  336. {
  337. cmd.Parameters.Add(new SqlParameter("beginTime", DateTime.Parse(DateTime.Now.AddMonths(-1).ToString("yyyy-MM") + "-01")));
  338. cmd.Parameters.Add(new SqlParameter("endTime", DateTime.Parse(DateTime.Now.ToString("yyyy-MM") + "-01")));
  339. }
  340. using (var reader = cmd.ExecuteReader())
  341. {
  342. dt.Load(reader);
  343. }
  344. cmd.Dispose();
  345. }
  346. conn.Close();
  347. conn.Dispose();
  348. }
  349. catch (Exception ex)
  350. {
  351. throw ex;
  352. }
  353. }
  354. dt.TableName = $"{ReportName}";
  355. MemoryStream memory = new MemoryStream();
  356. XmlSerializer serializer = new XmlSerializer(typeof(System.Data.DataTable));
  357. System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(memory);
  358. serializer.Serialize(writer, dt);
  359. byte[] temp = memory.ToArray();
  360. return temp;
  361. }
  362. /// <summary>
  363. /// 从维德系统中获取专案数据
  364. /// </summary>
  365. /// <returns></returns>
  366. public byte[] getProjectDataFromIPEasy()
  367. {
  368. DataTable dt = new DataTable();
  369. string strSQL = @"SELECT p_case_info.case_volume as 我方文号,
  370. p_case_info.case_volume_customer as 客户文号,
  371. p_case_info.case_name as 案件名称,
  372. p_case_info.charge_date as 委案日期,
  373. i_case_status.case_status_zh_cn as 案件状态,
  374. i_case_type.case_type_zh_cn as 案件类型,
  375. p_case_info.app_no as 申请号,
  376. p_case_info.app_date as 申请日,
  377. i_business_type.business_type_zh_cn as 业务类型,
  378. STUFF((SELECT ',' + u.cn_name from c_customer_user as cu
  379. 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 流程负责人,
  380. c_customer.customer_name as 客户名称,
  381. STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl
  382. 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 案件核稿人,
  383. STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
  384. 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 案件处理人,
  385. p_case_info.create_time as 开卷日期,
  386. STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl
  387. inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id
  388. where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员,
  389. i_country.country_zh_cn as '国家(地区)'
  390. from p_case_info
  391. inner join p_case_advance_info with(nolock) on p_case_info.case_id=p_case_advance_info.case_id
  392. inner join i_apply_type with(nolock) on i_apply_type.apply_type_id=p_case_info.apply_type_id
  393. inner join i_case_type with(nolock) on i_case_type.case_type_id=p_case_info.case_type_id
  394. inner join i_country with(nolock) on i_country.country_id=p_case_info.country_id
  395. inner join i_case_status with(nolock) on i_case_status.case_status_id=p_case_info.case_status_id
  396. inner join c_customer with(nolock) on c_customer.customer_id=p_case_info.customer_id
  397. inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id
  398. inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id
  399. where p_case_info.is_enabled=1 and p_case_info.case_volume like 'S%' and not p_case_info.case_volume like 'SCN%'
  400. and i_case_status.case_status_zh_cn<>'已完成' and i_case_status.case_status_zh_cn<>'结案'
  401. order by 我方文号";
  402. using (var conn = new SqlConnection(ConfigHelper.GetSectionValue("IPEasySetting:ConnectionStrings")))
  403. {
  404. try
  405. {
  406. conn.Open();
  407. using (var cmd = conn.CreateCommand())
  408. {
  409. cmd.CommandText = strSQL;
  410. cmd.CommandType = CommandType.Text;
  411. using (var reader = cmd.ExecuteReader())
  412. {
  413. dt.Load(reader);
  414. }
  415. cmd.Dispose();
  416. }
  417. conn.Close();
  418. conn.Dispose();
  419. }
  420. catch (Exception ex)
  421. {
  422. throw ex;
  423. }
  424. }
  425. dt.TableName = $"专案数据";
  426. MemoryStream memory = new MemoryStream();
  427. XmlSerializer serializer = new XmlSerializer(typeof(System.Data.DataTable));
  428. System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(memory);
  429. serializer.Serialize(writer, dt);
  430. byte[] temp = memory.ToArray();
  431. return temp;
  432. }
  433. /// <summary>
  434. /// 从维德系统中获取案件信息
  435. /// </summary>
  436. /// <param name="CaseNo">案件号</param>
  437. /// <param name="DoItem">处理事项</param>
  438. /// <param name="CaseStage">案件阶段,默认为空</param>
  439. /// <returns>返回案件记录,如果数据库中有多条记录,返回完成日最后的那条记录</returns>
  440. [HttpGet, HttpPost]
  441. public ExpandoObject GetItemFromIPEasyDB(string CaseNo,string DoItem,string CaseStage=null)
  442. {
  443. dynamic retItem = new ExpandoObject();
  444. var dt = new DataTable();
  445. using (var conn = new SqlConnection(ConfigHelper.GetSectionValue("IPEasySetting:ConnectionStrings")))
  446. {
  447. try
  448. {
  449. conn.Open();
  450. string strSql = @"SELECT distinct p_case_info.case_volume as case_volume,
  451. i_apply_type.apply_type_zh_cn as apply_type_zh_cn,
  452. i_business_type.business_type_zh_cn as business_type_zh_cn,
  453. i_ctrl_proc.ctrl_proc_zh_cn as ctrl_proc_zh_cn,
  454. (select case_status_zh_cn from i_case_status where case_status_id=p_proc_info.review_stage) as review_stage,
  455. i_case_coefficient.case_coefficient_zh_cn as case_coefficient,
  456. i_proc_coefficient.proc_coefficient_zh_cn as proc_coefficient,
  457. (select proc_coefficient_zh_cn from p_proc_info pr
  458. left join i_proc_coefficient pc on pc.proc_coefficient_id=pr.proc_coefficient_id
  459. where case_id=p_case_info.case_id and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'
  460. and pr.seq=
  461. (select max(seq) from p_proc_info pr where case_id=p_case_info.case_id
  462. and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'and seq<p_proc_info.seq)
  463. ) as oa_proc_coefficient,
  464. (STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
  465. inner join s_user_info as u on u.user_id = pl.pic_id
  466. inner join p_proc_info pr1 on pr1.proc_id=pl.obj_id
  467. where case_id=p_case_info.case_id and
  468. ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'
  469. and pr1.seq=(
  470. select max(seq) from p_proc_info pr2 where case_id=p_case_info.case_id
  471. and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'
  472. and seq<p_proc_info.seq) FOR XML PATH('') ),1,1,''))
  473. as oa_pic_list,
  474. STUFF((SELECT ',' + ur.rank_zh_cn from p_proc_pic_list as pl
  475. inner join s_user_info as u on u.user_id = pl.pic_id
  476. left join i_user_rank ur on ur.rank_id=u.rank_id
  477. where pl.obj_id = p_proc_info.proc_id FOR XML PATH('') ),1,1,'') as user_rank,
  478. STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
  479. inner join s_user_info as u on u.user_id = pl.pic_id
  480. where pl.obj_id = p_proc_info.proc_id FOR XML PATH('') ),1,1,'') as pic,
  481. STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl
  482. inner join s_user_info as u on u.user_id = pl.revise_user_id
  483. where pl.obj_id = p_proc_info.proc_id FOR XML PATH('') ),1,1,'') as reviser,
  484. c_customer.customer_name as customer_name,
  485. STUFF((SELECT ',' + a.applicant_name_cn from p_applicant_list as al
  486. inner join i_applicant as a on a.applicant_id = al.applicant_id
  487. where al.obj_id = p_case_info.case_id order by al.seq FOR XML PATH('') ),1,1,'') as applicants,
  488. p_proc_info.finish_date as finish_date,
  489. p_proc_info.finish_doc_date as finish_doc_date,
  490. p_proc_info.back_date as back_date,
  491. i_case_type.case_type_zh_cn as case_type_zh_cn,
  492. i_case_status.case_status_zh_cn as case_status_zh_cn,
  493. p_proc_info.proc_note as proc_note,
  494. (select proc_status_zh_cn from i_proc_status where proc_status_id=p_proc_info.proc_status_id) as proc_status_zh_cn,
  495. p_case_info.case_name as case_name,
  496. p_case_info.charge_date as charge_date,
  497. p_proc_info.cus_due_date as cus_due_date,
  498. p_proc_info.int_due_date as int_due_date,
  499. p_proc_info.first_doc_date as first_doc_date,
  500. p_case_info.remark as case_remark,
  501. p_proc_info.translate_count as translate_count,
  502. STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl
  503. inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id
  504. 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,
  505. i_country.country_zh_cn as country_zh_cn
  506. from p_case_info
  507. inner join p_case_advance_info with(nolock) on p_case_info.case_id=p_case_advance_info.case_id
  508. inner join i_apply_type with(nolock) on i_apply_type.apply_type_id=p_case_info.apply_type_id
  509. inner join i_case_type with(nolock) on i_case_type.case_type_id=p_case_info.case_type_id
  510. inner join i_country with(nolock) on i_country.country_id=p_case_info.country_id
  511. inner join i_case_status with(nolock) on i_case_status.case_status_id=p_case_info.case_status_id
  512. inner join c_customer with(nolock) on c_customer.customer_id=p_case_info.customer_id
  513. left join i_case_coefficient on i_case_coefficient.case_coefficient_id=p_case_info.case_coefficient_id
  514. inner join p_proc_info with(nolock) on p_case_info.case_id=p_proc_info.case_id
  515. inner join i_ctrl_proc with(nolock) on p_proc_info.ctrl_proc_id=i_ctrl_proc.ctrl_proc_id
  516. inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id
  517. left join p_proc_pic_list with(nolock) on p_proc_pic_list.obj_id=p_proc_info.proc_id
  518. left join s_user_info with(nolock) on s_user_info.user_id=p_proc_pic_list.pic_id
  519. left join i_proc_coefficient on i_proc_coefficient.proc_coefficient_id=p_proc_info.proc_coefficient_id
  520. where
  521. p_case_info.is_enabled=1 and
  522. p_proc_info.is_enabled=1 and
  523. s_user_info.dept_id not in ('60e09ee0-fcc7-446f-badc-af9973079fee','34d0e351-71dc-418f-9b6b-bcb67af62fed','599cbe0c-044e-4ffc-9411-96dd9019d8a6') and
  524. (p_case_info.case_type_id='31D1A147-2931-43B5-94AE-B72B1525BA8A') AND
  525. i_ctrl_proc.ctrl_proc_zh_cn=@DoItem and
  526. p_case_info.case_volume =@CaseNo";
  527. using (var cmd = conn.CreateCommand())
  528. {
  529. cmd.CommandText = strSql;
  530. cmd.CommandType = CommandType.Text;
  531. cmd.Parameters.Add(new SqlParameter("DoItem", DoItem.Trim()));
  532. cmd.Parameters.Add(new SqlParameter("CaseNo", CaseNo.Trim()));
  533. using (var reader = cmd.ExecuteReader())
  534. {
  535. dt.Load(reader);
  536. if (dt.Rows.Count > 1)
  537. {
  538. bool bRet = false;
  539. DateTime preFinishedDate = DateTime.MinValue;
  540. foreach (DataRow row in dt.Rows)
  541. {
  542. DateTime temDate = DateTime.Now;
  543. DateTime.TryParse(row["finish_date"].ToString(), out temDate);
  544. if ((preFinishedDate < temDate) &&
  545. (!string.IsNullOrEmpty(CaseStage) && CaseStage == row["review_stage"].ToString()))
  546. {
  547. preFinishedDate = temDate;
  548. GetItemData(retItem, row);
  549. bRet = true;
  550. //break;
  551. }
  552. }
  553. if (!bRet)
  554. {
  555. DataRow row = dt.Rows[0];
  556. GetItemData(retItem, row);
  557. }
  558. }
  559. else
  560. {
  561. if (dt.Rows.Count > 0)
  562. {
  563. DataRow row = dt.Rows[0];
  564. GetItemData(retItem, row);
  565. }
  566. }
  567. }
  568. cmd.Dispose();
  569. }
  570. conn.Close();
  571. conn.Dispose();
  572. }
  573. catch (Exception ex)
  574. {
  575. // error handling
  576. throw;
  577. }
  578. finally
  579. {
  580. conn.Close();
  581. }
  582. }
  583. return retItem as ExpandoObject;
  584. }
  585. private static void GetItemData(dynamic retItem, DataRow row)
  586. {
  587. retItem.CaseNo = row["case_volume"].ToString();
  588. retItem.ApplicationType = row["apply_type_zh_cn"].ToString();
  589. retItem.BusinessType = row["business_type_zh_cn"].ToString();
  590. retItem.DoItem = row["ctrl_proc_zh_cn"].ToString(); ;
  591. retItem.CaseStage = row["review_stage"].ToString();
  592. retItem.CaseCoefficient = row["case_coefficient"].ToString();
  593. retItem.DoItemCoefficient = row["proc_coefficient"].ToString();
  594. retItem.DoPersons = row["pic"].ToString();
  595. retItem.Reviewer = row["reviser"].ToString();
  596. retItem.CustomerName = row["customer_name"].ToString();
  597. retItem.FinishedDate = row["finish_date"].ToString();
  598. retItem.WordCount = row["translate_count"].ToString();
  599. retItem.ReturnDate = row["back_date"].ToString();
  600. retItem.CaseType = row["case_type_zh_cn"].ToString();
  601. retItem.CaseState = row["case_status_zh_cn"].ToString();
  602. retItem.DoItemState = row["proc_status_zh_cn"].ToString();
  603. retItem.DoItemMemo = row["proc_note"].ToString();
  604. retItem.CaseName = row["case_name"].ToString();
  605. retItem.EntrustingDate = row["charge_date"].ToString();
  606. retItem.CustomerLimitDate = row["cus_due_date"].ToString();
  607. retItem.InternalDate = row["int_due_date"].ToString();
  608. retItem.FirstDraftDate = row["first_doc_date"].ToString();
  609. retItem.CaseMemo = row["case_remark"].ToString();
  610. retItem.FinalizationDate = row["finish_doc_date"].ToString();
  611. retItem.WorkflowUser = row["sales"].ToString();
  612. retItem.Country = row["country_zh_cn"].ToString();
  613. }
  614. }
  615. }