ImportReportJob.cs 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961
  1. using DynamicExpresso;
  2. using Microsoft.Data.SqlClient;
  3. using Microsoft.Extensions.DependencyInjection;
  4. using Quartz;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Configuration;
  8. using System.Data;
  9. using System.Linq;
  10. using System.Threading.Tasks;
  11. using wispro.sp.entity;
  12. using wispro.sp.utility;
  13. namespace wispro.sp.api.Job
  14. {
  15. public class ImportReportJob : Quartz.IJob
  16. {
  17. /// <summary>
  18. /// 不需要计算绩效的处理事项
  19. /// </summary>
  20. private string[] InValidDoItem = new string[]
  21. {
  22. "案件异常-催缴年费",
  23. "案件异常-视为放弃取得专利权",
  24. "办理登记手续",
  25. "办理登记手续-确认客户是否委托",
  26. "代理所变更",
  27. "绘图",
  28. "技术确认",
  29. "缴年费",
  30. "请求保密审查",
  31. "请求费减",
  32. "请求实审",
  33. "取得申请号",
  34. "取得证书",
  35. "取得专利权评价报告",
  36. "确认官方审查状况",
  37. "询问放弃或复审",
  38. "知识点总结",
  39. "专利权人发明人申请人信息变更",
  40. "专利挖掘与布局",
  41. "我方文号前缀带J",
  42. "开卷",
  43. "请求提前公开",
  44. "取得国际检索报告",
  45. "委外检索",
  46. "中止程序",
  47. "终止",
  48. "案件异常-视为撤回",
  49. "进入国家阶段提醒",
  50. "请求恢复权利",
  51. "请求优先权",
  52. "取得【无效宣告请求审查决定】",
  53. "撤回",
  54. "请求退款",
  55. "确认是否委托申请与类型",
  56. "专利交易",
  57. "专利权评价报告",
  58. "专利权人发明人申请人信息变更+代理所变更"
  59. };
  60. spDbContext spDb = new spDbContext();
  61. public Task Execute(IJobExecutionContext context)
  62. {
  63. CalMonth calMonth = new CalMonth()
  64. {
  65. Year = DateTime.Now.AddMonths(-1).Year,
  66. Month = DateTime.Now.AddMonths(-1).Month,
  67. Status = 0
  68. };
  69. var temCalMonth = spDb.CalMonths.Where<CalMonth>(x => x.Year == calMonth.Year && x.Month == calMonth.Month).FirstOrDefault();
  70. if (temCalMonth != null)
  71. {
  72. var iCount = spDb.PerformanceItems.Where<PerformanceItem>(p => p.CalMonthId == temCalMonth.Id).Count<PerformanceItem>();
  73. if (iCount > 0)
  74. {
  75. return Task.CompletedTask;
  76. }
  77. calMonth = temCalMonth;
  78. }
  79. else
  80. {
  81. spDb.CalMonths.Add(calMonth);
  82. spDb.SaveChanges();
  83. }
  84. //每月绩效统计--发客户超过一个月未完成案件
  85. DownloadReport_SQL("每月绩效统计--发客户超过一个月未完成案件", calMonth, false);
  86. //DownloadReport( "每月绩效统计--发客户超过一个月未完成案件", calMonth,false);
  87. //每月绩效统计--上个月递交完成案件
  88. DownloadReport_SQL("每月绩效统计--上个月递交完成案件", calMonth, true);
  89. //DownloadReport("每月绩效统计--上个月递交完成案件", calMonth, true);
  90. //每月绩效统计--中国一次OA授权表
  91. DownloadReport_SQL("每月绩效统计--中国一次OA授权表", calMonth, true, true);
  92. //DownloadReport("每月绩效统计--中国一次OA授权表", calMonth, true,true);
  93. return Task.CompletedTask;
  94. }
  95. private void DownloadReport_SQL(string ReportName, CalMonth calMonth, bool isModifyDate, bool isFirstOA = false)
  96. {
  97. try
  98. {
  99. DataTable data = GetDataFromIPEasy(ReportName,isModifyDate);
  100. InputPerformanctItem(calMonth, isFirstOA, data);
  101. }
  102. catch
  103. {
  104. }
  105. }
  106. private Task InputPerformanceItem(string strExcelFile, bool isColumnName, bool ignorHideRows = false, int ColumnNameRow = 0, CalMonth calMonth = null, bool isFirstOAFile = false)
  107. {
  108. DataTable dt = NPOIExcel.ExcelToDataTable(strExcelFile, isColumnName, ignorHideRows, ColumnNameRow);
  109. return InputPerformanctItem(calMonth, isFirstOAFile, dt);
  110. }
  111. private Task InputPerformanctItem(CalMonth calMonth, bool isFirstOAFile, DataTable dt)
  112. {
  113. #region 删除重复行
  114. DataTable temdt = new DataTable();
  115. foreach (DataColumn col in dt.Columns)
  116. {
  117. DataColumn temCol = new DataColumn();
  118. temCol.ColumnName = col.ColumnName;
  119. temCol.DataType = col.DataType;
  120. temCol.Caption = col.Caption;
  121. temdt.Columns.Add(temCol);
  122. }
  123. new ExcelHelper().MerageDataTable(temdt, dt);
  124. #endregion
  125. List<BasePointRule> rules = spDb.BasePointRules.ToList<BasePointRule>();
  126. int iRow = 0;
  127. foreach (DataRow row in temdt.Rows)
  128. {
  129. string strDebug = $"{++iRow}\t{row["我方文号"]}";
  130. PerformanceItem item = null;
  131. if (isFirstOAFile)
  132. {
  133. item = Row2Item_1(row, calMonth);
  134. }
  135. else
  136. {
  137. item = Row2Item(row, calMonth);
  138. }
  139. if (item != null)
  140. {
  141. if (!InValidDoItem.Contains(item.DoItem) && !isDBNotFinishedDate(item))
  142. {
  143. //foreach(var temObj in item.ItemStaffs)
  144. //{
  145. // temObj.DoPerson.Name = temObj.DoPerson.Name.Replace("-君龙", "");
  146. //}
  147. SavePerformanceItem(item, rules);
  148. strDebug = $"{strDebug}\t保存成功";
  149. }
  150. else
  151. {
  152. strDebug = $"{strDebug}\t无效处理事项";
  153. }
  154. }
  155. else
  156. {
  157. strDebug = $"{strDebug}\t转换Item为Null";
  158. }
  159. System.Diagnostics.Debug.WriteLine(strDebug);
  160. }
  161. return Task.CompletedTask;
  162. }
  163. private bool isDBNotFinishedDate(PerformanceItem item)
  164. {
  165. return (item.DoItem == "处理审查意见" && item.FinishedDate == null);
  166. }
  167. private Task SavePerformanceItem(PerformanceItem item,List<BasePointRule> rules)
  168. {
  169. try
  170. {
  171. Utility.Utility.CalBasePoint(item, rules);
  172. var ret= new Controllers.PerformanceItemController(spDb,new Services.FileTaskCacheService()).New(item);
  173. if (ret.Success == false)
  174. {
  175. System.Diagnostics.Debug.WriteLine(ret.ErrorMessage);
  176. }
  177. }
  178. catch (Exception ex)
  179. {
  180. System.Diagnostics.Debug.WriteLine(ex.Message);
  181. }
  182. return Task.CompletedTask;
  183. }
  184. private PerformanceItem Row2Item_1(DataRow row, CalMonth calMonth)
  185. {
  186. PerformanceItem item = new PerformanceItem();
  187. item.ApplicationType = row["申请类型"].ToString().Trim();
  188. if (item.ApplicationType != "发明")
  189. {
  190. return null;
  191. }
  192. item.CaseNo = row["我方文号"].ToString().Trim();
  193. if (item.CaseNo.StartsWith("S"))
  194. {
  195. return null;
  196. }
  197. if (calMonth != null)
  198. {
  199. item.CalMonth = calMonth;
  200. }
  201. else
  202. {
  203. if (row.Table.Columns.Contains("绩效核算月份"))
  204. {
  205. string strjxyf = row["绩效核算月份"].ToString().Trim();
  206. string[] temYFs = strjxyf.Split(new char[] { '.' });
  207. item.CalMonth = new CalMonth();
  208. item.CalMonth.Year = int.Parse(temYFs[0]);
  209. item.CalMonth.Month = int.Parse(temYFs[1]);
  210. item.CalMonth.Status = 4;
  211. }
  212. else
  213. {
  214. item.CalMonth = new CalMonth();
  215. item.Status = 0;
  216. item.CalMonth.Year = DateTime.Now.AddMonths(-1).Year;
  217. item.CalMonth.Month = DateTime.Now.AddMonths(-1).Month;
  218. }
  219. }
  220. item.ApplicationType = row["申请类型"].ToString().Trim();
  221. item.BusinessType = "普通新申请"; // row["业务类型"].ToString().Trim();
  222. item.AgentFeedbackMemo = "发明一次OA授权"; //row["备注(填表注意事项)"].ToString().Trim();
  223. item.DoItem = "发明一次OA授权"; //row["处理事项"].ToString().Trim();
  224. string strHandler = "";
  225. if (row.Table.Columns.Contains("处理人"))
  226. {
  227. strHandler = row["处理人"].ToString().Trim();
  228. }
  229. else
  230. {
  231. if (row.Table.Columns.Contains("案件处理人"))
  232. {
  233. strHandler = row["案件处理人"].ToString().Trim();
  234. }
  235. }
  236. string[] temHandlers = strHandler.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  237. item.ItemStaffs = new List<ItemStaff>();
  238. foreach (string name in temHandlers)
  239. {
  240. ItemStaff itemStaff = new ItemStaff();
  241. string temName = name.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  242. if (!name.Contains("君龙"))
  243. {
  244. temName = name.Trim();
  245. }
  246. int? iTem = GetStaff(temName);
  247. if ((iTem != null))
  248. {
  249. //itemStaff.Item = item;
  250. itemStaff.DoPersonId = iTem.Value;
  251. item.ItemStaffs.Add(itemStaff);
  252. }
  253. else
  254. {
  255. itemStaff.DoPerson = new Staff()
  256. {
  257. Name = temName,
  258. Account = temName,
  259. Password = "12345678",
  260. IsCalPerformsnce = false,
  261. Status = "试用期",
  262. StaffGradeId = 4
  263. };
  264. item.ItemStaffs.Add(itemStaff);
  265. }
  266. }
  267. if (item.ItemStaffs.Count == 0)
  268. {
  269. System.Diagnostics.Debug.WriteLine($"没有处理人: {item.CaseNo}\t{item.DoItem}");
  270. }
  271. if (row.Table.Columns.Contains("核稿人"))
  272. {
  273. item.ReviewerId = GetStaff(row["核稿人"].ToString().Trim());
  274. }
  275. else
  276. {
  277. if (row.Table.Columns.Contains("案件核稿人"))
  278. {
  279. item.ReviewerId = GetStaff(row["案件核稿人"].ToString().Trim());
  280. }
  281. }
  282. if (row.Table.Columns.Contains("业务人员"))
  283. {
  284. if (!string.IsNullOrEmpty(row["业务人员"].ToString().Trim()))
  285. {
  286. string name = row["业务人员"].ToString();
  287. string temName = row["业务人员"].ToString().Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  288. if (!name.Contains("君龙"))
  289. {
  290. temName = name.Trim();
  291. }
  292. item.WorkflowUserId = GetStaff(temName);
  293. }
  294. }
  295. item.Customer = new Customer() { Name = row["客户名称"].ToString().Trim() };
  296. item.ApplicationName = row["申请人"].ToString().Trim();
  297. item.CaseName = row["案件名称"].ToString().Trim();
  298. if (row.Table.Columns.Contains("国家(地区)"))
  299. {
  300. item.Country = row["国家(地区)"].ToString().Trim();
  301. }
  302. //案件备注
  303. item.CaseMemo = $"发文日期:{row["发文日期"].ToString().Trim()}\r\n客户文号:{row["客户文号"].ToString().Trim()}\r\n上传日期:{row["上传日期"].ToString().Trim()}\r\n文件描述:{row["文件描述"].ToString().Trim()}";
  304. if (row.Table.Columns.Contains("翻译字数"))
  305. {
  306. //item.ReviewerId = GetStaff(row["案件核稿人"].ToString().Trim());
  307. var strWordCount = row["翻译字数"].ToString().Trim();
  308. if (string.IsNullOrEmpty(strWordCount))
  309. {
  310. try
  311. {
  312. item.WordCount = int.Parse(strWordCount);
  313. }
  314. catch { }
  315. }
  316. }
  317. return item;
  318. }
  319. private PerformanceItem Row2Item(DataRow row, CalMonth calMonth)
  320. {
  321. PerformanceItem item = new PerformanceItem();
  322. item.CaseNo = row["我方文号"].ToString().Trim();
  323. if (item.CaseNo.StartsWith("S"))
  324. {
  325. return null;
  326. }
  327. if (calMonth != null)
  328. {
  329. item.CalMonth = calMonth;
  330. }
  331. else
  332. {
  333. if (row.Table.Columns.Contains("绩效核算月份"))
  334. {
  335. string strjxyf = row["绩效核算月份"].ToString().Trim();
  336. string[] temYFs = strjxyf.Split(new char[] { '.' });
  337. item.CalMonth = new CalMonth();
  338. item.CalMonth.Year = int.Parse(temYFs[0]);
  339. item.CalMonth.Month = int.Parse(temYFs[1]);
  340. item.CalMonth.Status = 4;
  341. }
  342. else
  343. {
  344. item.CalMonth = new CalMonth();
  345. item.Status = 0;
  346. item.CalMonth.Year = DateTime.Now.AddMonths(-1).Year;
  347. item.CalMonth.Month = DateTime.Now.AddMonths(-1).Month;
  348. }
  349. }
  350. item.ApplicationType = row["申请类型"].ToString().Trim();
  351. item.BusinessType = row["业务类型"].ToString().Trim();
  352. if (row.Table.Columns.Contains("国家(地区)"))
  353. {
  354. item.Country = row["国家(地区)"].ToString().Trim();
  355. }
  356. if (row.Table.Columns.Contains("备注(填表注意事项)"))
  357. item.AgentFeedbackMemo = row["备注(填表注意事项)"].ToString().Trim();
  358. item.DoItem = row["处理事项"].ToString().Trim();
  359. item.CaseStage = row["案件阶段"].ToString().Trim();
  360. item.CaseCoefficient = row["案件系数"].ToString().Trim();
  361. item.DoItemCoefficient = row["处理事项系数"].ToString().Trim();
  362. item.PreOastaffId = GetStaff(row["前一次OA处理人"].ToString().Trim());
  363. string strHandler = "";
  364. if (row.Table.Columns.Contains("处理人"))
  365. {
  366. strHandler = row["处理人"].ToString().Trim();
  367. }
  368. else
  369. {
  370. if (row.Table.Columns.Contains("案件处理人"))
  371. {
  372. strHandler = row["案件处理人"].ToString().Trim();
  373. }
  374. }
  375. string[] temHandlers = strHandler.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  376. item.ItemStaffs = new List<ItemStaff>();
  377. foreach (string name in temHandlers)
  378. {
  379. ItemStaff itemStaff = new ItemStaff();
  380. string temName = name.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  381. if (!name.Contains("君龙"))
  382. {
  383. temName = name.Trim();
  384. }
  385. int? iTem = GetStaff(temName);
  386. if ((iTem != null))
  387. {
  388. //itemStaff.Item = item;
  389. itemStaff.DoPersonId = iTem.Value;
  390. item.ItemStaffs.Add(itemStaff);
  391. }
  392. else
  393. {
  394. itemStaff.DoPerson = new Staff()
  395. {
  396. Name = temName,
  397. Account = temName,
  398. Password = "12345678",
  399. IsCalPerformsnce = false,
  400. Status = "试用期",
  401. StaffGradeId = 4
  402. };
  403. item.ItemStaffs.Add(itemStaff);
  404. }
  405. }
  406. if (item.ItemStaffs.Count == 0)
  407. {
  408. System.Diagnostics.Debug.WriteLine($"没有处理人: {item.CaseNo}\t{item.DoItem}");
  409. }
  410. if (row.Table.Columns.Contains("核稿人"))
  411. {
  412. if (!string.IsNullOrEmpty(row["核稿人"].ToString().Trim()))
  413. {
  414. string name = row["核稿人"].ToString();
  415. string temName = name.Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  416. if (!name.Contains("君龙"))
  417. {
  418. temName = name.Trim();
  419. }
  420. item.ReviewerId = GetStaff(temName);
  421. }
  422. }
  423. else
  424. {
  425. if (row.Table.Columns.Contains("案件核稿人"))
  426. {
  427. if (!string.IsNullOrEmpty(row["案件核稿人"].ToString().Trim()))
  428. {
  429. string name = row["案件核稿人"].ToString();
  430. string temName = row["案件核稿人"].ToString().Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  431. if (!name.Contains("君龙"))
  432. {
  433. temName = name.Trim();
  434. }
  435. item.ReviewerId = GetStaff(temName);
  436. }
  437. }
  438. }
  439. if (row.Table.Columns.Contains("业务人员"))
  440. {
  441. if (!string.IsNullOrEmpty(row["业务人员"].ToString().Trim()))
  442. {
  443. string name = row["业务人员"].ToString();
  444. string temName = row["业务人员"].ToString().Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  445. if (!name.Contains("君龙"))
  446. {
  447. temName = name.Trim();
  448. }
  449. item.WorkflowUserId = GetStaff(temName);
  450. }
  451. }
  452. item.Customer = new Customer() { Name = row["客户名称"].ToString().Trim() };
  453. item.ApplicationName = row["申请人"].ToString().Trim();
  454. DateTime temDate = new DateTime();
  455. if (DateTime.TryParse(row["处理事项完成日"].ToString().Trim(), out temDate))
  456. {
  457. item.FinishedDate = temDate;
  458. }
  459. //定稿日
  460. if (DateTime.TryParse(row["定稿日"].ToString().Trim(), out temDate))
  461. {
  462. item.FinalizationDate = temDate;
  463. }
  464. //返稿日
  465. if (DateTime.TryParse(row["返稿日"].ToString().Trim(), out temDate))
  466. {
  467. item.ReturnDate = temDate;
  468. }
  469. //案件类型
  470. item.CaseType = row["案件类型"].ToString().Trim();
  471. //案件状态
  472. item.CaseState = row["案件状态"].ToString().Trim();
  473. //处理事项备注
  474. item.DoItemMemo = row["处理事项备注"].ToString().Trim();
  475. //处理状态
  476. item.DoItemState = row["处理状态"].ToString().Trim();
  477. //案件名称
  478. item.CaseName = row["案件名称"].ToString().Trim();
  479. //委案日期
  480. if (DateTime.TryParse(row["委案日期"].ToString().Trim(), out temDate))
  481. {
  482. item.EntrustingDate = temDate;
  483. }
  484. //客户期限
  485. if (DateTime.TryParse(row["客户期限"].ToString().Trim(), out temDate))
  486. {
  487. item.CustomerLimitDate = temDate;
  488. }
  489. //内部期限
  490. if (DateTime.TryParse(row["内部期限"].ToString().Trim(), out temDate))
  491. {
  492. item.InternalDate = temDate;
  493. }
  494. //初稿日
  495. if (DateTime.TryParse(row["初稿日"].ToString().Trim(), out temDate))
  496. {
  497. item.FirstDraftDate = temDate;
  498. }
  499. //备注(发文严重超期是否属客观原因,若为否,请填写原因)
  500. if (row.Table.Columns.Contains("备注(发文严重超期是否属客观原因,若为否,请填写原因)"))
  501. {
  502. item.OverDueMemo = row["备注(发文严重超期是否属客观原因,若为否,请填写原因)"].ToString().Trim();
  503. }
  504. //案件备注
  505. item.CaseMemo = row["案件备注"].ToString().Trim();
  506. if (row.Table.Columns.Contains("翻译字数"))
  507. {
  508. //item.ReviewerId = GetStaff(row["案件核稿人"].ToString().Trim());
  509. var strWordCount = row["翻译字数"].ToString().Trim();
  510. if (string.IsNullOrEmpty(strWordCount))
  511. {
  512. try
  513. {
  514. item.WordCount = int.Parse(strWordCount);
  515. }
  516. catch { }
  517. }
  518. }
  519. return item;
  520. }
  521. private int? GetStaff(string v)
  522. {
  523. if (!string.IsNullOrEmpty(v))
  524. {
  525. string temName = v.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  526. if (!v.Contains("君龙"))
  527. {
  528. temName = v;
  529. }
  530. var staff = spDb.Staffs.Where<Staff>(s => s.Name == temName).FirstOrDefault();
  531. if (staff != null)
  532. {
  533. return staff.Id;
  534. }
  535. }
  536. return null;
  537. }
  538. private DataTable GetDataFromIPEasy(string ReportName, bool isModifyDate)
  539. {
  540. DataTable dt = new DataTable();
  541. string strSQL = "";
  542. switch (ReportName)
  543. {
  544. case "每月绩效统计--发客户超过一个月未完成案件":
  545. strSQL = @"SELECT p_case_info.case_volume as 我方文号,
  546. i_apply_type.apply_type_zh_cn as 申请类型,
  547. i_business_type.business_type_zh_cn as 业务类型,
  548. i_ctrl_proc.ctrl_proc_zh_cn as 处理事项,
  549. (select case_status_zh_cn from i_case_status where case_status_id=p_proc_info.review_stage) as 案件阶段,
  550. i_case_coefficient.case_coefficient_zh_cn as 案件系数,
  551. i_proc_coefficient.proc_coefficient_zh_cn as 处理事项系数,
  552. (select proc_coefficient_zh_cn from p_proc_info pr
  553. left join i_proc_coefficient pc on pc.proc_coefficient_id=pr.proc_coefficient_id
  554. where case_id=p_case_info.case_id and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'
  555. and pr.seq=
  556. (select max(seq) from p_proc_info pr where case_id=p_case_info.case_id
  557. and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'and seq<p_proc_info.seq)
  558. ) as 前一次OA处理事项系数,
  559. (STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
  560. inner join s_user_info as u on u.user_id = pl.pic_id
  561. inner join p_proc_info pr1 on pr1.proc_id=pl.obj_id
  562. where case_id=p_case_info.case_id and
  563. ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'
  564. and pr1.seq=(
  565. select max(seq) from p_proc_info pr2 where case_id=p_case_info.case_id
  566. and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'
  567. and seq<p_proc_info.seq) FOR XML PATH('') ),1,1,'')) as 前一次OA处理人,
  568. STUFF((SELECT ',' + ur.rank_zh_cn from p_proc_pic_list as pl
  569. inner join s_user_info as u on u.user_id = pl.pic_id
  570. left join i_user_rank ur on ur.rank_id=u.rank_id
  571. where pl.obj_id = p_proc_info.proc_id FOR XML PATH('') ),1,1,'') as 处理人等级,
  572. STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
  573. inner join s_user_info as u on u.user_id = pl.pic_id
  574. where pl.obj_id = p_proc_info.proc_id FOR XML PATH('') ),1,1,'') as 处理人,
  575. STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl
  576. inner join s_user_info as u on u.user_id = pl.revise_user_id
  577. where pl.obj_id = p_proc_info.proc_id FOR XML PATH('') ),1,1,'') as 核稿人,
  578. c_customer.customer_name as 客户名称,
  579. STUFF((SELECT ',' + a.applicant_name_cn from p_applicant_list as al
  580. inner join i_applicant as a on a.applicant_id = al.applicant_id
  581. where al.obj_id = p_case_info.case_id order by al.seq FOR XML PATH('') ),1,1,'') as 申请人,
  582. p_proc_info.finish_date as 处理事项完成日,
  583. p_proc_info.finish_doc_date as 定稿日,
  584. p_proc_info.back_date as 返稿日,
  585. i_case_type.case_type_zh_cn as 案件类型,
  586. i_case_status.case_status_zh_cn as 案件状态,
  587. p_proc_info.proc_note as 处理事项备注,
  588. (select proc_status_zh_cn from i_proc_status where proc_status_id=p_proc_info.proc_status_id) as 处理状态,
  589. p_case_info.case_name as 案件名称,
  590. p_case_info.charge_date as 委案日期,
  591. p_proc_info.cus_due_date as 客户期限,
  592. p_proc_info.int_due_date as 内部期限,
  593. p_proc_info.first_doc_date as 初稿日,
  594. p_case_info.remark as 案件备注,
  595. p_proc_info.translate_count as 翻译字数,
  596. STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl
  597. inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id
  598. where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员,
  599. i_country.country_zh_cn as '国家(地区)'
  600. from p_case_info
  601. inner join p_case_advance_info with(nolock) on p_case_info.case_id=p_case_advance_info.case_id
  602. inner join i_apply_type with(nolock) on i_apply_type.apply_type_id=p_case_info.apply_type_id
  603. inner join i_case_type with(nolock) on i_case_type.case_type_id=p_case_info.case_type_id
  604. inner join i_country with(nolock) on i_country.country_id=p_case_info.country_id
  605. inner join i_case_status with(nolock) on i_case_status.case_status_id=p_case_info.case_status_id
  606. inner join c_customer with(nolock) on c_customer.customer_id=p_case_info.customer_id
  607. left join i_case_coefficient on i_case_coefficient.case_coefficient_id=p_case_info.case_coefficient_id
  608. inner join p_proc_info with(nolock) on p_case_info.case_id=p_proc_info.case_id
  609. inner join i_ctrl_proc with(nolock) on p_proc_info.ctrl_proc_id=i_ctrl_proc.ctrl_proc_id
  610. inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id
  611. inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id
  612. left join p_proc_pic_list with(nolock) on p_proc_pic_list.obj_id=p_proc_info.proc_id
  613. left join s_user_info with(nolock) on s_user_info.user_id=p_proc_pic_list.pic_id
  614. left join i_proc_coefficient on i_proc_coefficient.proc_coefficient_id=p_proc_info.proc_coefficient_id
  615. where
  616. p_case_info.is_enabled=1 and p_proc_info.is_enabled=1 and
  617. s_user_info.dept_id not in ('60e09ee0-fcc7-446f-badc-af9973079fee','34d0e351-71dc-418f-9b6b-bcb67af62fed','599cbe0c-044e-4ffc-9411-96dd9019d8a6') and
  618. p_proc_info.finish_date is null
  619. and p_proc_info.back_date<DATEADD(MM,-1,DATEADD(MM, DATEDIFF(MM,0,getdate()), 0)) and
  620. (p_case_info.case_type_id='31D1A147-2931-43B5-94AE-B72B1525BA8A' ) AND
  621. ( i_ctrl_proc.ctrl_proc_zh_cn='新申请'
  622. or i_ctrl_proc.ctrl_proc_zh_cn='Non'
  623. or i_ctrl_proc.ctrl_proc_zh_cn='无效宣告'
  624. or i_ctrl_proc.ctrl_proc_zh_cn='意见陈述'
  625. or i_ctrl_proc.ctrl_proc_zh_cn='专利挖掘与布局'
  626. or i_ctrl_proc.ctrl_proc_zh_cn='处理审查意见'
  627. or i_ctrl_proc.ctrl_proc_zh_cn='Final'
  628. or i_ctrl_proc.ctrl_proc_zh_cn='复审通知意见陈述'
  629. or i_ctrl_proc.ctrl_proc_zh_cn='申復'
  630. or i_ctrl_proc.ctrl_proc_zh_cn='RCE'
  631. or i_ctrl_proc.ctrl_proc_zh_cn='翻译'
  632. or i_ctrl_proc.ctrl_proc_zh_cn='提出异议复审'
  633. or i_ctrl_proc.ctrl_proc_zh_cn='Advisory'
  634. or i_ctrl_proc.ctrl_proc_zh_cn='复审'
  635. or i_ctrl_proc.ctrl_proc_zh_cn='请求复审'
  636. or i_ctrl_proc.ctrl_proc_zh_cn='提出报告'
  637. or i_ctrl_proc.ctrl_proc_zh_cn='提出公众意见'
  638. or i_ctrl_proc.ctrl_proc_zh_cn='诉讼'
  639. or i_ctrl_proc.ctrl_proc_zh_cn='提出异议'
  640. or i_ctrl_proc.ctrl_proc_zh_cn='补充理由和证据'
  641. or i_ctrl_proc.ctrl_proc_zh_cn='无效分析'
  642. or i_ctrl_proc.ctrl_proc_zh_cn='无效答辩'
  643. )";
  644. break;
  645. case "每月绩效统计--上个月递交完成案件":
  646. strSQL = @"SELECT
  647. p_case_info.case_volume as 我方文号,
  648. i_apply_type.apply_type_zh_cn as 申请类型,
  649. i_business_type.business_type_zh_cn as 业务类型,
  650. i_ctrl_proc.ctrl_proc_zh_cn as 处理事项,
  651. (select case_status_zh_cn from i_case_status where case_status_id=p_proc_info.review_stage) as 案件阶段,
  652. i_case_coefficient.case_coefficient_zh_cn as 案件系数,
  653. i_proc_coefficient.proc_coefficient_zh_cn as 处理事项系数,
  654. (select
  655. proc_coefficient_zh_cn from p_proc_info pr
  656. left join i_proc_coefficient pc on pc.proc_coefficient_id=pr.proc_coefficient_id
  657. where case_id=p_case_info.case_id
  658. and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'
  659. and pr.seq=(select max(seq) from p_proc_info pr where case_id=p_case_info.case_id
  660. and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'and seq<p_proc_info.seq)
  661. ) as 前一次OA处理事项系数,
  662. (STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
  663. inner join s_user_info as u on u.user_id = pl.pic_id
  664. inner join p_proc_info pr1 on pr1.proc_id=pl.obj_id
  665. where case_id=p_case_info.case_id
  666. and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'
  667. and pr1.seq=(select max(seq) from p_proc_info pr2 where case_id=p_case_info.case_id
  668. and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'and seq<p_proc_info.seq) FOR XML PATH('') ),1,1,'')
  669. ) as 前一次OA处理人,
  670. STUFF((SELECT ',' + ur.rank_zh_cn from p_proc_pic_list as pl
  671. inner join s_user_info as u on u.user_id = pl.pic_id
  672. 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 处理人等级,
  673. STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
  674. inner join s_user_info as u on u.user_id = pl.pic_id
  675. where pl.obj_id = p_proc_info.proc_id FOR XML PATH('') ),1,1,'') as 处理人,
  676. STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl
  677. inner join s_user_info as u on u.user_id = pl.revise_user_id
  678. where pl.obj_id = p_case_info.case_id FOR XML PATH('') ),1,1,'') as 案件核稿人,
  679. c_customer.customer_name as 客户名称,
  680. STUFF((SELECT ',' + a.applicant_name_cn from p_applicant_list as al
  681. inner join i_applicant as a on a.applicant_id = al.applicant_id
  682. where al.obj_id = p_case_info.case_id order by al.seq FOR XML PATH('') ),1,1,'') as 申请人,
  683. p_proc_info.finish_date as 处理事项完成日,
  684. p_proc_info.finish_doc_date as 定稿日,
  685. p_proc_info.back_date as 返稿日,
  686. i_case_type.case_type_zh_cn as 案件类型,
  687. i_case_status.case_status_zh_cn as 案件状态,
  688. p_proc_info.proc_note as 处理事项备注,
  689. (select proc_status_zh_cn from i_proc_status where proc_status_id=p_proc_info.proc_status_id) as 处理状态,
  690. p_case_info.case_name as 案件名称,
  691. p_case_info.charge_date as 委案日期,
  692. p_proc_info.cus_due_date as 客户期限,
  693. p_proc_info.int_due_date as 内部期限,
  694. p_proc_info.first_doc_date as 初稿日,
  695. p_case_info.remark as 案件备注,
  696. p_proc_info.translate_count as 翻译字数,
  697. STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl
  698. inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id
  699. where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员,
  700. i_country.country_zh_cn as '国家(地区)'
  701. from p_case_info
  702. inner join p_case_advance_info with(nolock) on p_case_info.case_id=p_case_advance_info.case_id
  703. inner join i_apply_type with(nolock) on i_apply_type.apply_type_id=p_case_info.apply_type_id
  704. inner join i_case_type with(nolock) on i_case_type.case_type_id=p_case_info.case_type_id
  705. inner join i_country with(nolock) on i_country.country_id=p_case_info.country_id
  706. inner join i_case_status with(nolock) on i_case_status.case_status_id=p_case_info.case_status_id
  707. inner join c_customer with(nolock) on c_customer.customer_id=p_case_info.customer_id
  708. left join i_case_coefficient on i_case_coefficient.case_coefficient_id=p_case_info.case_coefficient_id
  709. inner join p_proc_info with(nolock) on p_case_info.case_id=p_proc_info.case_id
  710. inner join i_ctrl_proc with(nolock) on p_proc_info.ctrl_proc_id=i_ctrl_proc.ctrl_proc_id
  711. inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id
  712. inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id
  713. left join p_proc_pic_list with(nolock) on p_proc_pic_list.obj_id=p_proc_info.proc_id
  714. left join s_user_info with(nolock) on s_user_info.user_id=p_proc_pic_list.pic_id
  715. left join i_proc_coefficient on i_proc_coefficient.proc_coefficient_id=p_proc_info.proc_coefficient_id
  716. where
  717. p_case_info.is_enabled=1
  718. and p_proc_info.is_enabled=1
  719. and s_user_info.dept_id not in ('60e09ee0-fcc7-446f-badc-af9973079fee','34d0e351-71dc-418f-9b6b-bcb67af62fed','599cbe0c-044e-4ffc-9411-96dd9019d8a6')
  720. and (p_case_info.case_type_id='31D1A147-2931-43B5-94AE-B72B1525BA8A' )
  721. AND ((p_proc_info.finish_date >= @beginTime and p_proc_info.finish_date<@endTime)) ";
  722. break;
  723. case "每月绩效统计--中国一次OA授权表":
  724. strSQL = @"select
  725. p_case_info.case_volume as 我方文号,
  726. p_case_info.case_name as 案件名称,
  727. p_case_info.app_no as 申请号,
  728. c_customer.customer_name as 客户名称,
  729. STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
  730. inner join s_user_info as u on u.user_id = pl.pic_id
  731. where pl.obj_id = p_case_info.case_id FOR XML PATH('') ),1,1,'') as 案件处理人,
  732. STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl
  733. inner join s_user_info as u on u.user_id = pl.revise_user_id
  734. where pl.obj_id = p_case_info.case_id FOR XML PATH('') ),1,1,'') as 案件核稿人,
  735. p_file_list.post_date as 发文日期,
  736. p_case_info.case_volume_customer as 客户文号,
  737. p_case_info.app_date as 申请日,
  738. i_country.country_zh_cn as '国家(地区)',
  739. STUFF((SELECT ',' + a.applicant_name_cn from p_applicant_list as al
  740. inner join i_applicant as a on a.applicant_id = al.applicant_id
  741. where al.obj_id = p_case_info.case_id order by al.seq FOR XML PATH('') ),1,1,'') as 申请人,
  742. p_file_list.upload_time as 上传日期,
  743. i_file_desc.file_desc_zh_cn as 文件描述,
  744. i_apply_type.apply_type_zh_cn as 申请类型,
  745. STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl
  746. inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id
  747. where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员
  748. from p_case_info
  749. inner join i_apply_type on p_case_info.apply_type_id=i_apply_type.apply_type_id
  750. inner join p_proc_info on p_case_info.case_id=p_proc_info.case_id
  751. inner join p_file_list on p_file_list.obj_id=p_proc_info.proc_id
  752. inner join i_file_desc on i_file_desc.file_desc_id=p_file_list.file_desc_id
  753. inner join c_customer on p_case_info.customer_id=c_customer.customer_id
  754. inner join i_country on i_country.country_id=p_case_info.country_id
  755. where
  756. p_case_info.is_enabled=1
  757. and p_proc_info.is_enabled=1 and p_case_info.country_id='CN'
  758. and p_file_list.file_desc_id='09800D39-D585-49F3-B9DE-50AC689DE9AB'
  759. and p_file_list.file_name not like '%.zip'
  760. 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
  761. and (p_case_info.case_type_id='31D1A147-2931-43B5-94AE-B72B1525BA8A' )
  762. AND ((p_file_list.post_date >= @beginTime and p_file_list.post_date<@endTime))";
  763. break;
  764. case "每月绩效统计--专案进度跟踪~S卷":
  765. strSQL = @"SELECT p_case_info.case_volume as 我方文号,
  766. p_case_info.case_name as 案件名称,
  767. i_case_type.case_type_zh_cn as 案件类型,
  768. i_business_type.business_type_zh_cn as 业务类型,
  769. i_country.country_zh_cn as '国家(地区)',
  770. c_customer.customer_name as 客户名称,
  771. s_dept_info.dept_full_name as 承办部门,
  772. i_case_status.case_status_zh_cn as 案件状态,
  773. i_ctrl_proc.ctrl_proc_zh_cn as 处理事项,
  774. p_proc_info.int_due_date as 内部期限,
  775. p_proc_info.cus_due_date as 客户期限,
  776. p_proc_info.legal_due_date as 官方期限,
  777. p_proc_info.finish_doc_date as 定稿日,
  778. STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
  779. inner join s_user_info as u on u.user_id = pl.pic_id where pl.obj_id = p_proc_info.proc_id
  780. FOR XML PATH('') ),1,1,'') as 处理人,
  781. p_case_info.charge_date as 委案日期,
  782. (select proc_status_zh_cn from i_proc_status where proc_status_id=p_proc_info.proc_status_id) as 处理状态,
  783. p_proc_info.first_doc_date as 初稿日,
  784. STUFF((SELECT ',' + u.cn_name from c_customer_user as cu
  785. inner join s_user_info as u on u.user_id = cu.user_id
  786. where cu.customer_id = p_case_info.customer_id FOR XML PATH('') ),1,1,'') as 流程负责人,
  787. p_proc_info.finish_date as 处理事项完成日,
  788. STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl
  789. inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id
  790. where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员
  791. from p_case_info
  792. inner join p_case_advance_info with(nolock) on p_case_info.case_id=p_case_advance_info.case_id
  793. inner join i_apply_type with(nolock) on i_apply_type.apply_type_id=p_case_info.apply_type_id
  794. inner join i_case_type with(nolock) on i_case_type.case_type_id=p_case_info.case_type_id
  795. inner join i_country with(nolock) on i_country.country_id=p_case_info.country_id
  796. inner join i_case_status with(nolock) on i_case_status.case_status_id=p_case_info.case_status_id
  797. inner join c_customer with(nolock) on c_customer.customer_id=p_case_info.customer_id
  798. inner join p_proc_info with(nolock) on p_case_info.case_id=p_proc_info.case_id
  799. inner join i_ctrl_proc with(nolock) on p_proc_info.ctrl_proc_id=i_ctrl_proc.ctrl_proc_id
  800. inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id
  801. inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id
  802. where p_case_info.is_enabled=1 and p_proc_info.is_enabled=1 and
  803. (isnull (p_proc_info.finish_date,'') ='') AND (i_ctrl_proc.ctrl_proc_zh_cn='提出报告')";
  804. break;
  805. case "每月绩效统计--专案开卷报表~S卷":
  806. strSQL = @"SELECT p_case_info.case_volume as 我方文号,
  807. p_case_info.case_volume_customer as 客户文号,
  808. p_case_info.case_name as 案件名称,
  809. p_case_info.charge_date as 委案日期,
  810. i_case_status.case_status_zh_cn as 案件状态,
  811. i_case_type.case_type_zh_cn as 案件类型,
  812. p_case_info.app_no as 申请号,
  813. p_case_info.app_date as 申请日,
  814. i_business_type.business_type_zh_cn as 业务类型,
  815. STUFF((SELECT ',' + u.cn_name from c_customer_user as cu
  816. 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 流程负责人,
  817. c_customer.customer_name as 客户名称,
  818. STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl
  819. 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 案件核稿人,
  820. STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
  821. 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 案件处理人,
  822. p_case_info.create_time as 开卷日期,
  823. STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl
  824. inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id
  825. where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员,
  826. i_country.country_zh_cn as '国家(地区)'
  827. from p_case_info
  828. inner join p_case_advance_info with(nolock) on p_case_info.case_id=p_case_advance_info.case_id
  829. inner join i_apply_type with(nolock) on i_apply_type.apply_type_id=p_case_info.apply_type_id
  830. inner join i_case_type with(nolock) on i_case_type.case_type_id=p_case_info.case_type_id
  831. inner join i_country with(nolock) on i_country.country_id=p_case_info.country_id
  832. inner join i_case_status with(nolock) on i_case_status.case_status_id=p_case_info.case_status_id
  833. inner join c_customer with(nolock) on c_customer.customer_id=p_case_info.customer_id
  834. inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id
  835. inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id
  836. 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%'
  837. and i_case_status.case_status_zh_cn<>'已完成' and i_case_status.case_status_zh_cn<>'结案'";
  838. break;
  839. }
  840. using (var conn = new SqlConnection(ConfigHelper.GetSectionValue("IPEasySetting:ConnectionStrings")))
  841. {
  842. try
  843. {
  844. conn.Open();
  845. using (var cmd = conn.CreateCommand())
  846. {
  847. cmd.CommandText = strSQL;
  848. cmd.CommandType = CommandType.Text;
  849. if (isModifyDate)
  850. {
  851. cmd.Parameters.Add(new SqlParameter("beginTime", DateTime.Parse(DateTime.Now.AddMonths(-1).ToString("yyyy-MM") + "-01")));
  852. cmd.Parameters.Add(new SqlParameter("endTime", DateTime.Parse(DateTime.Now.ToString("yyyy-MM") + "-01")));
  853. }
  854. using (var reader = cmd.ExecuteReader())
  855. {
  856. dt.Load(reader);
  857. }
  858. }
  859. }
  860. catch (Exception ex)
  861. {
  862. throw ex;
  863. }
  864. }
  865. return dt;
  866. }
  867. }
  868. }