ImportReportJob.cs 48 KB

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