ImportReportJob.cs 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434
  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. //专案数据
  94. DownloadProject_SQL(calMonth);
  95. //DownloadProject(calMonth);
  96. return Task.CompletedTask;
  97. }
  98. private void DownloadReport_SQL(string ReportName, CalMonth calMonth, bool isModifyDate, bool isFirstOA = false)
  99. {
  100. try
  101. {
  102. DataTable data = GetDataFromIPEasy(ReportName,isModifyDate);
  103. InputPerformanctItem(calMonth, isFirstOA, data);
  104. }
  105. catch
  106. {
  107. }
  108. }
  109. private void DownloadReport(string ReportName,CalMonth calMonth,bool isModifyDate,bool isFirstOA=false)
  110. {
  111. string strFileSavePath = utility.ConfigHelper.GetSectionValue("IPEasySetting:DownloadFileSavePath");
  112. string filename = $"{ReportName.Trim()}.xlsx";
  113. string strFilePath = System.IO.Path.Combine(strFileSavePath, filename);
  114. string strFinalPath = System.IO.Path.Combine(strFileSavePath, $"{calMonth.Year}{calMonth.Month}-{filename}");
  115. int tryCount = 0;
  116. tryAgain:
  117. try
  118. {
  119. wispro.sp.utility.IPEasyUtility.DownloadReport(ReportName, isModifyDate);
  120. if (!System.IO.File.Exists(strFilePath))
  121. {
  122. throw new ApplicationException("超时!");
  123. }
  124. }
  125. catch {
  126. tryCount++;
  127. if (tryCount < 5)
  128. {
  129. goto tryAgain;
  130. }
  131. }
  132. System.Threading.Thread.Sleep(5000);
  133. if (System.IO.File.Exists(strFilePath))
  134. {
  135. InputPerformanceItem(strFilePath, true, false, 1, calMonth, isFirstOA);
  136. try
  137. {
  138. System.IO.File.Move(strFilePath, strFinalPath);
  139. }
  140. catch { }
  141. }
  142. else
  143. {
  144. tryCount++;
  145. if (tryCount < 5)
  146. {
  147. goto tryAgain;
  148. }
  149. }
  150. }
  151. private void DownloadProject_SQL(CalMonth calMonth)
  152. {
  153. string[] ReportNames = new string[] { "每月绩效统计--专案进度跟踪~S卷", "每月绩效统计--专案开卷报表~S卷" };
  154. List<PerformanceItem> pfItems = new List<PerformanceItem>();
  155. foreach (var ReportName in ReportNames)
  156. {
  157. DataTable data = GetDataFromIPEasy(ReportName, false);
  158. var Items = GetProjectItem(calMonth, ReportName.Contains("专案开卷报表"),data);
  159. foreach (var item in Items)
  160. {
  161. var temObj = pfItems.FirstOrDefault<PerformanceItem>(s => s.CaseNo == item.CaseNo);
  162. if (temObj == null)
  163. {
  164. item.Type = "专案";
  165. pfItems.Add(item);
  166. }
  167. }
  168. }
  169. //List<BasePointRule> rules = spDb.BasePointRules.ToList<BasePointRule>();
  170. foreach (var item in pfItems)
  171. {
  172. SaveProjectItem(item);
  173. }
  174. }
  175. private void DownloadProject(CalMonth calMonth)
  176. {
  177. string strFileSavePath = utility.ConfigHelper.GetSectionValue("IPEasySetting:DownloadFileSavePath");
  178. int tryCount = 0;
  179. string[] ReportNames =new string[] { "每月绩效统计--专案进度跟踪~S卷", "每月绩效统计--专案开卷报表~S卷" };
  180. List<PerformanceItem> pfItems = new List<PerformanceItem>();
  181. foreach (var ReportName in ReportNames)
  182. {
  183. tryAgain:
  184. try
  185. {
  186. wispro.sp.utility.IPEasyUtility.DownloadReport(ReportName, false);
  187. }
  188. catch
  189. {
  190. tryCount++;
  191. if (tryCount < 5)
  192. {
  193. goto tryAgain;
  194. }
  195. }
  196. System.Threading.Thread.Sleep(5000);
  197. string filename = $"{ReportName.Trim().Replace("~","_")}.xlsx";
  198. string strFilePath = System.IO.Path.Combine(strFileSavePath, filename);
  199. string strFinalPath = System.IO.Path.Combine(strFileSavePath, $"{calMonth.Year}{calMonth.Month}-{filename}");
  200. if (System.IO.File.Exists(strFilePath))
  201. {
  202. var Items = GetProjectItem(strFilePath, calMonth, ReportName.Contains("专案开卷报表"));
  203. foreach (var item in Items)
  204. {
  205. var temObj = pfItems.FirstOrDefault<PerformanceItem>(s => s.CaseNo == item.CaseNo);
  206. if (temObj == null)
  207. {
  208. item.Type = "专案";
  209. pfItems.Add(item);
  210. }
  211. }
  212. try
  213. {
  214. System.IO.File.Move(strFilePath, strFinalPath);
  215. }
  216. catch { }
  217. }
  218. else
  219. {
  220. tryCount++;
  221. if (tryCount < 5)
  222. {
  223. goto tryAgain;
  224. }
  225. }
  226. }
  227. //List<BasePointRule> rules = spDb.BasePointRules.ToList<BasePointRule>();
  228. foreach (var item in pfItems)
  229. {
  230. SaveProjectItem(item);
  231. }
  232. }
  233. private void SaveProjectItem(PerformanceItem item)
  234. {
  235. var temObj = spDb.ProjectInfos.FirstOrDefault(p=>p.CaseNo == item.CaseNo);
  236. if (temObj == null)
  237. {
  238. ProjectInfo project = new ProjectInfo();
  239. project.CaseNo = item.CaseNo;
  240. project.CaseName = item.CaseName;
  241. project.BusinessType = item.BusinessType;
  242. if(item.Customer != null)
  243. {
  244. var temCustomer = spDb.Customers.FirstOrDefault(c => c.Name == item.Customer.Name);
  245. if(temCustomer != null)
  246. {
  247. project.CustomerId = temCustomer.Id;
  248. }
  249. }
  250. project.CaseState = 0;
  251. project.CaseType = item.CaseType;
  252. project.ReviewerId = item.ReviewerId;
  253. project.WorkflowUserId = item.WorkflowUserId;
  254. spDb.ProjectInfos.Add(project);
  255. }
  256. spDb.SaveChanges();
  257. }
  258. private List<PerformanceItem> GetProjectItem(string strPath,CalMonth calMonth,bool isOpenSheet)
  259. {
  260. DataTable dt = NPOIExcel.ExcelToDataTable(strPath, true, true, 1);
  261. return GetProjectItem(calMonth, isOpenSheet, dt);
  262. }
  263. private List<PerformanceItem> GetProjectItem(CalMonth calMonth, bool isOpenSheet, DataTable dt)
  264. {
  265. #region 删除重复行
  266. DataTable temdt = new DataTable();
  267. foreach (DataColumn col in dt.Columns)
  268. {
  269. DataColumn temCol = new DataColumn();
  270. temCol.ColumnName = col.ColumnName;
  271. temCol.DataType = col.DataType;
  272. temCol.Caption = col.Caption;
  273. temdt.Columns.Add(temCol);
  274. }
  275. new ExcelHelper().MerageDataTable(temdt, dt);
  276. #endregion
  277. List<PerformanceItem> Items = new List<PerformanceItem>();
  278. int iRow = 0;
  279. foreach (DataRow row in temdt.Rows)
  280. {
  281. string strDebug = $"{++iRow}\t{row["我方文号"]}";
  282. PerformanceItem item = null;
  283. if (!isOpenSheet)
  284. {
  285. item = Row2Item_2(row, calMonth);
  286. }
  287. else
  288. {
  289. item = Row2Item_3(row, calMonth);
  290. }
  291. if (item != null)
  292. {
  293. item.CalMonth = calMonth;
  294. item.CalMonthId = calMonth.Id;
  295. Items.Add(item);
  296. }
  297. }
  298. return Items;
  299. }
  300. private Task InputPerformanceItem(string strExcelFile, bool isColumnName, bool ignorHideRows = false, int ColumnNameRow = 0, CalMonth calMonth = null, bool isFirstOAFile = false)
  301. {
  302. DataTable dt = NPOIExcel.ExcelToDataTable(strExcelFile, isColumnName, ignorHideRows, ColumnNameRow);
  303. return InputPerformanctItem(calMonth, isFirstOAFile, dt);
  304. }
  305. private Task InputPerformanctItem(CalMonth calMonth, bool isFirstOAFile, DataTable dt)
  306. {
  307. #region 删除重复行
  308. DataTable temdt = new DataTable();
  309. foreach (DataColumn col in dt.Columns)
  310. {
  311. DataColumn temCol = new DataColumn();
  312. temCol.ColumnName = col.ColumnName;
  313. temCol.DataType = col.DataType;
  314. temCol.Caption = col.Caption;
  315. temdt.Columns.Add(temCol);
  316. }
  317. new ExcelHelper().MerageDataTable(temdt, dt);
  318. #endregion
  319. List<BasePointRule> rules = spDb.BasePointRules.ToList<BasePointRule>();
  320. int iRow = 0;
  321. foreach (DataRow row in temdt.Rows)
  322. {
  323. string strDebug = $"{++iRow}\t{row["我方文号"]}";
  324. PerformanceItem item = null;
  325. if (isFirstOAFile)
  326. {
  327. item = Row2Item_1(row, calMonth);
  328. }
  329. else
  330. {
  331. item = Row2Item(row, calMonth);
  332. }
  333. if (item != null)
  334. {
  335. if (!InValidDoItem.Contains(item.DoItem) && !isDBNotFinishedDate(item))
  336. {
  337. //foreach(var temObj in item.ItemStaffs)
  338. //{
  339. // temObj.DoPerson.Name = temObj.DoPerson.Name.Replace("-君龙", "");
  340. //}
  341. SavePerformanceItem(item, rules);
  342. strDebug = $"{strDebug}\t保存成功";
  343. }
  344. else
  345. {
  346. strDebug = $"{strDebug}\t无效处理事项";
  347. }
  348. }
  349. else
  350. {
  351. strDebug = $"{strDebug}\t转换Item为Null";
  352. }
  353. System.Diagnostics.Debug.WriteLine(strDebug);
  354. }
  355. return Task.CompletedTask;
  356. }
  357. private bool isDBNotFinishedDate(PerformanceItem item)
  358. {
  359. return (item.DoItem == "处理审查意见" && item.FinishedDate == null);
  360. }
  361. private Task SavePerformanceItem(PerformanceItem item,List<BasePointRule> rules)
  362. {
  363. try
  364. {
  365. Utility.Utility.CalBasePoint(item, rules);
  366. var ret= new Controllers.PerformanceItemController(spDb,new Services.FileTaskCacheService()).New(item);
  367. if (ret.Success == false)
  368. {
  369. System.Diagnostics.Debug.WriteLine(ret.ErrorMessage);
  370. }
  371. }
  372. catch (Exception ex)
  373. {
  374. System.Diagnostics.Debug.WriteLine(ex.Message);
  375. }
  376. return Task.CompletedTask;
  377. }
  378. private PerformanceItem Row2Item_3(DataRow row, CalMonth calMonth)
  379. {
  380. PerformanceItem item = new PerformanceItem();
  381. item.CaseNo = row["我方文号"].ToString().Trim();
  382. item.CaseName = row["案件名称"].ToString().Trim();
  383. item.CaseType = row["案件类型"].ToString().Trim();
  384. item.BusinessType = row["业务类型"].ToString().Trim();
  385. item.Customer = new Customer();
  386. item.Customer.Name = row["客户名称"].ToString().Trim();
  387. item.CaseState = row["案件状态"].ToString().Trim();
  388. DateTime temDate = new DateTime();
  389. if (DateTime.TryParse(row["委案日期"].ToString().Trim(), out temDate))
  390. {
  391. item.EntrustingDate = temDate;
  392. }
  393. string strHandler = "";
  394. if (row.Table.Columns.Contains("处理人"))
  395. {
  396. strHandler = row["处理人"].ToString().Trim();
  397. }
  398. else
  399. {
  400. if (row.Table.Columns.Contains("案件处理人"))
  401. {
  402. strHandler = row["案件处理人"].ToString().Trim();
  403. }
  404. }
  405. string[] temHandlers = strHandler.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  406. item.ItemStaffs = new List<ItemStaff>();
  407. foreach (string name in temHandlers)
  408. {
  409. ItemStaff itemStaff = new ItemStaff();
  410. string temName = name.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  411. if (!name.Contains("君龙"))
  412. {
  413. temName = name.Trim();
  414. }
  415. int? iTem = GetStaff(name);
  416. if ((iTem != null))
  417. {
  418. //itemStaff.Item = item;
  419. itemStaff.DoPersonId = iTem.Value;
  420. item.ItemStaffs.Add(itemStaff);
  421. }
  422. else
  423. {
  424. itemStaff.DoPerson = new Staff()
  425. {
  426. Name = temName,
  427. Account = temName,
  428. Password = "12345678",
  429. IsCalPerformsnce = false,
  430. Status = "试用期",
  431. StaffGradeId = 4
  432. };
  433. item.ItemStaffs.Add(itemStaff);
  434. }
  435. }
  436. if (item.ItemStaffs.Count == 0)
  437. {
  438. System.Diagnostics.Debug.WriteLine($"没有处理人: {item.CaseNo}\t{item.DoItem}");
  439. }
  440. if (row.Table.Columns.Contains("核稿人"))
  441. {
  442. item.ReviewerId = GetStaff(row["核稿人"].ToString().Trim());
  443. }
  444. else
  445. {
  446. if (row.Table.Columns.Contains("案件核稿人"))
  447. {
  448. item.ReviewerId = GetStaff(row["案件核稿人"].ToString().Trim());
  449. }
  450. }
  451. if (row.Table.Columns.Contains("业务人员"))
  452. {
  453. item.WorkflowUserId = GetStaff(row["业务人员"].ToString().Trim());
  454. }
  455. if (row.Table.Columns.Contains("国家(地区)"))
  456. {
  457. item.Country = row["国家(地区)"].ToString().Trim();
  458. }
  459. return item;
  460. }
  461. private PerformanceItem Row2Item_2(DataRow row, CalMonth calMonth)
  462. {
  463. PerformanceItem item = new PerformanceItem();
  464. item.CaseNo = row["我方文号"].ToString().Trim();
  465. item.CaseName= row["案件名称"].ToString().Trim();
  466. item.CaseType = row["案件类型"].ToString().Trim();
  467. item.BusinessType= row["业务类型"].ToString().Trim();
  468. item.Customer = new Customer();
  469. item.Customer.Name = row["客户名称"].ToString().Trim();
  470. item.CaseState = row["案件状态"].ToString().Trim();
  471. item.DoItem = row["处理事项"].ToString().Trim();
  472. if (row.Table.Columns.Contains("国家(地区)"))
  473. {
  474. item.Country = row["国家(地区)"].ToString().Trim();
  475. }
  476. DateTime temDate = new DateTime();
  477. if (DateTime.TryParse(row["内部期限"].ToString().Trim(), out temDate))
  478. {
  479. item.InternalDate = temDate;
  480. }
  481. if (DateTime.TryParse(row["客户期限"].ToString().Trim(), out temDate))
  482. {
  483. item.CustomerLimitDate = temDate;
  484. }
  485. if (DateTime.TryParse(row["初稿日"].ToString().Trim(), out temDate))
  486. {
  487. item.FirstDraftDate = temDate;
  488. }
  489. if (DateTime.TryParse(row["定稿日"].ToString().Trim(), out temDate))
  490. {
  491. item.FinalizationDate = temDate;
  492. }
  493. if (DateTime.TryParse(row["委案日期"].ToString().Trim(), out temDate))
  494. {
  495. item.EntrustingDate = temDate;
  496. }
  497. if (DateTime.TryParse(row["处理事项完成日"].ToString().Trim(), out temDate))
  498. {
  499. item.FinishedDate = temDate;
  500. }
  501. item.DoItemState = row["处理状态"].ToString().Trim();
  502. string strHandler = "";
  503. if (row.Table.Columns.Contains("处理人"))
  504. {
  505. strHandler = row["处理人"].ToString().Trim();
  506. }
  507. else
  508. {
  509. if (row.Table.Columns.Contains("案件处理人"))
  510. {
  511. strHandler = row["案件处理人"].ToString().Trim();
  512. }
  513. }
  514. string[] temHandlers = strHandler.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  515. item.ItemStaffs = new List<ItemStaff>();
  516. foreach (string name in temHandlers)
  517. {
  518. ItemStaff itemStaff = new ItemStaff();
  519. string temName = name.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  520. if (!name.Contains("君龙"))
  521. {
  522. temName = name.Trim();
  523. }
  524. int? iTem = GetStaff(temName);
  525. if ((iTem != null))
  526. {
  527. //itemStaff.Item = item;
  528. itemStaff.DoPersonId = iTem.Value;
  529. item.ItemStaffs.Add(itemStaff);
  530. }
  531. else
  532. {
  533. itemStaff.DoPerson = new Staff()
  534. {
  535. Name = temName,
  536. Account = temName,
  537. Password = "12345678",
  538. IsCalPerformsnce = false,
  539. Status = "试用期",
  540. StaffGradeId = 4
  541. };
  542. item.ItemStaffs.Add(itemStaff);
  543. }
  544. }
  545. if (item.ItemStaffs.Count == 0)
  546. {
  547. System.Diagnostics.Debug.WriteLine($"没有处理人: {item.CaseNo}\t{item.DoItem}");
  548. }
  549. if (row.Table.Columns.Contains("核稿人"))
  550. {
  551. item.ReviewerId = GetStaff(row["核稿人"].ToString().Trim());
  552. }
  553. else
  554. {
  555. if (row.Table.Columns.Contains("案件核稿人"))
  556. {
  557. item.ReviewerId = GetStaff(row["案件核稿人"].ToString().Trim());
  558. }
  559. }
  560. if (row.Table.Columns.Contains("业务人员"))
  561. {
  562. if (!string.IsNullOrEmpty(row["业务人员"].ToString().Trim()))
  563. {
  564. string name = row["业务人员"].ToString().Trim();
  565. string temName = name.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  566. if (!name.Contains("君龙"))
  567. {
  568. temName = name.Trim();
  569. }
  570. item.WorkflowUserId = GetStaff(temName);
  571. }
  572. }
  573. return item;
  574. }
  575. private PerformanceItem Row2Item_1(DataRow row, CalMonth calMonth)
  576. {
  577. PerformanceItem item = new PerformanceItem();
  578. item.ApplicationType = row["申请类型"].ToString().Trim();
  579. if (item.ApplicationType != "发明")
  580. {
  581. return null;
  582. }
  583. item.CaseNo = row["我方文号"].ToString().Trim();
  584. if (item.CaseNo.StartsWith("S"))
  585. {
  586. return null;
  587. }
  588. if (calMonth != null)
  589. {
  590. item.CalMonth = calMonth;
  591. }
  592. else
  593. {
  594. if (row.Table.Columns.Contains("绩效核算月份"))
  595. {
  596. string strjxyf = row["绩效核算月份"].ToString().Trim();
  597. string[] temYFs = strjxyf.Split(new char[] { '.' });
  598. item.CalMonth = new CalMonth();
  599. item.CalMonth.Year = int.Parse(temYFs[0]);
  600. item.CalMonth.Month = int.Parse(temYFs[1]);
  601. item.CalMonth.Status = 4;
  602. }
  603. else
  604. {
  605. item.CalMonth = new CalMonth();
  606. item.Status = 0;
  607. item.CalMonth.Year = DateTime.Now.AddMonths(-1).Year;
  608. item.CalMonth.Month = DateTime.Now.AddMonths(-1).Month;
  609. }
  610. }
  611. item.ApplicationType = row["申请类型"].ToString().Trim();
  612. item.BusinessType = "普通新申请"; // row["业务类型"].ToString().Trim();
  613. item.AgentFeedbackMemo = "发明一次OA授权"; //row["备注(填表注意事项)"].ToString().Trim();
  614. item.DoItem = "发明一次OA授权"; //row["处理事项"].ToString().Trim();
  615. string strHandler = "";
  616. if (row.Table.Columns.Contains("处理人"))
  617. {
  618. strHandler = row["处理人"].ToString().Trim();
  619. }
  620. else
  621. {
  622. if (row.Table.Columns.Contains("案件处理人"))
  623. {
  624. strHandler = row["案件处理人"].ToString().Trim();
  625. }
  626. }
  627. string[] temHandlers = strHandler.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  628. item.ItemStaffs = new List<ItemStaff>();
  629. foreach (string name in temHandlers)
  630. {
  631. ItemStaff itemStaff = new ItemStaff();
  632. string temName = name.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  633. if (!name.Contains("君龙"))
  634. {
  635. temName = name.Trim();
  636. }
  637. int? iTem = GetStaff(temName);
  638. if ((iTem != null))
  639. {
  640. //itemStaff.Item = item;
  641. itemStaff.DoPersonId = iTem.Value;
  642. item.ItemStaffs.Add(itemStaff);
  643. }
  644. else
  645. {
  646. itemStaff.DoPerson = new Staff()
  647. {
  648. Name = temName,
  649. Account = temName,
  650. Password = "12345678",
  651. IsCalPerformsnce = false,
  652. Status = "试用期",
  653. StaffGradeId = 4
  654. };
  655. item.ItemStaffs.Add(itemStaff);
  656. }
  657. }
  658. if (item.ItemStaffs.Count == 0)
  659. {
  660. System.Diagnostics.Debug.WriteLine($"没有处理人: {item.CaseNo}\t{item.DoItem}");
  661. }
  662. if (row.Table.Columns.Contains("核稿人"))
  663. {
  664. item.ReviewerId = GetStaff(row["核稿人"].ToString().Trim());
  665. }
  666. else
  667. {
  668. if (row.Table.Columns.Contains("案件核稿人"))
  669. {
  670. item.ReviewerId = GetStaff(row["案件核稿人"].ToString().Trim());
  671. }
  672. }
  673. if (row.Table.Columns.Contains("业务人员"))
  674. {
  675. if (!string.IsNullOrEmpty(row["业务人员"].ToString().Trim()))
  676. {
  677. string name = row["业务人员"].ToString();
  678. string temName = row["业务人员"].ToString().Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  679. if (!name.Contains("君龙"))
  680. {
  681. temName = name.Trim();
  682. }
  683. item.WorkflowUserId = GetStaff(temName);
  684. }
  685. }
  686. item.Customer = new Customer() { Name = row["客户名称"].ToString().Trim() };
  687. item.ApplicationName = row["申请人"].ToString().Trim();
  688. item.CaseName = row["案件名称"].ToString().Trim();
  689. if (row.Table.Columns.Contains("国家(地区)"))
  690. {
  691. item.Country = row["国家(地区)"].ToString().Trim();
  692. }
  693. //案件备注
  694. item.CaseMemo = $"发文日期:{row["发文日期"].ToString().Trim()}\r\n客户文号:{row["客户文号"].ToString().Trim()}\r\n上传日期:{row["上传日期"].ToString().Trim()}\r\n文件描述:{row["文件描述"].ToString().Trim()}";
  695. if (row.Table.Columns.Contains("翻译字数"))
  696. {
  697. //item.ReviewerId = GetStaff(row["案件核稿人"].ToString().Trim());
  698. var strWordCount = row["翻译字数"].ToString().Trim();
  699. if (string.IsNullOrEmpty(strWordCount))
  700. {
  701. try
  702. {
  703. item.WordCount = int.Parse(strWordCount);
  704. }
  705. catch { }
  706. }
  707. }
  708. return item;
  709. }
  710. private PerformanceItem Row2Item(DataRow row, CalMonth calMonth)
  711. {
  712. PerformanceItem item = new PerformanceItem();
  713. item.CaseNo = row["我方文号"].ToString().Trim();
  714. if (item.CaseNo.StartsWith("S"))
  715. {
  716. return null;
  717. }
  718. if (calMonth != null)
  719. {
  720. item.CalMonth = calMonth;
  721. }
  722. else
  723. {
  724. if (row.Table.Columns.Contains("绩效核算月份"))
  725. {
  726. string strjxyf = row["绩效核算月份"].ToString().Trim();
  727. string[] temYFs = strjxyf.Split(new char[] { '.' });
  728. item.CalMonth = new CalMonth();
  729. item.CalMonth.Year = int.Parse(temYFs[0]);
  730. item.CalMonth.Month = int.Parse(temYFs[1]);
  731. item.CalMonth.Status = 4;
  732. }
  733. else
  734. {
  735. item.CalMonth = new CalMonth();
  736. item.Status = 0;
  737. item.CalMonth.Year = DateTime.Now.AddMonths(-1).Year;
  738. item.CalMonth.Month = DateTime.Now.AddMonths(-1).Month;
  739. }
  740. }
  741. item.ApplicationType = row["申请类型"].ToString().Trim();
  742. item.BusinessType = row["业务类型"].ToString().Trim();
  743. if (row.Table.Columns.Contains("国家(地区)"))
  744. {
  745. item.Country = row["国家(地区)"].ToString().Trim();
  746. }
  747. if (row.Table.Columns.Contains("备注(填表注意事项)"))
  748. item.AgentFeedbackMemo = row["备注(填表注意事项)"].ToString().Trim();
  749. item.DoItem = row["处理事项"].ToString().Trim();
  750. item.CaseStage = row["案件阶段"].ToString().Trim();
  751. item.CaseCoefficient = row["案件系数"].ToString().Trim();
  752. item.DoItemCoefficient = row["处理事项系数"].ToString().Trim();
  753. item.PreOastaffId = GetStaff(row["前一次OA处理人"].ToString().Trim());
  754. string strHandler = "";
  755. if (row.Table.Columns.Contains("处理人"))
  756. {
  757. strHandler = row["处理人"].ToString().Trim();
  758. }
  759. else
  760. {
  761. if (row.Table.Columns.Contains("案件处理人"))
  762. {
  763. strHandler = row["案件处理人"].ToString().Trim();
  764. }
  765. }
  766. string[] temHandlers = strHandler.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  767. item.ItemStaffs = new List<ItemStaff>();
  768. foreach (string name in temHandlers)
  769. {
  770. ItemStaff itemStaff = new ItemStaff();
  771. string temName = name.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  772. if (!name.Contains("君龙"))
  773. {
  774. temName = name.Trim();
  775. }
  776. int? iTem = GetStaff(temName);
  777. if ((iTem != null))
  778. {
  779. //itemStaff.Item = item;
  780. itemStaff.DoPersonId = iTem.Value;
  781. item.ItemStaffs.Add(itemStaff);
  782. }
  783. else
  784. {
  785. itemStaff.DoPerson = new Staff()
  786. {
  787. Name = temName,
  788. Account = temName,
  789. Password = "12345678",
  790. IsCalPerformsnce = false,
  791. Status = "试用期",
  792. StaffGradeId = 4
  793. };
  794. item.ItemStaffs.Add(itemStaff);
  795. }
  796. }
  797. if (item.ItemStaffs.Count == 0)
  798. {
  799. System.Diagnostics.Debug.WriteLine($"没有处理人: {item.CaseNo}\t{item.DoItem}");
  800. }
  801. if (row.Table.Columns.Contains("核稿人"))
  802. {
  803. if (!string.IsNullOrEmpty(row["核稿人"].ToString().Trim()))
  804. {
  805. string name = row["核稿人"].ToString();
  806. string temName = name.Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  807. if (!name.Contains("君龙"))
  808. {
  809. temName = name.Trim();
  810. }
  811. item.ReviewerId = GetStaff(temName);
  812. }
  813. }
  814. else
  815. {
  816. if (row.Table.Columns.Contains("案件核稿人"))
  817. {
  818. if (!string.IsNullOrEmpty(row["案件核稿人"].ToString().Trim()))
  819. {
  820. string name = row["案件核稿人"].ToString();
  821. string temName = row["案件核稿人"].ToString().Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  822. if (!name.Contains("君龙"))
  823. {
  824. temName = name.Trim();
  825. }
  826. item.ReviewerId = GetStaff(temName);
  827. }
  828. }
  829. }
  830. if (row.Table.Columns.Contains("业务人员"))
  831. {
  832. if (!string.IsNullOrEmpty(row["业务人员"].ToString().Trim()))
  833. {
  834. string name = row["业务人员"].ToString();
  835. string temName = row["业务人员"].ToString().Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  836. if (!name.Contains("君龙"))
  837. {
  838. temName = name.Trim();
  839. }
  840. item.WorkflowUserId = GetStaff(temName);
  841. }
  842. }
  843. item.Customer = new Customer() { Name = row["客户名称"].ToString().Trim() };
  844. item.ApplicationName = row["申请人"].ToString().Trim();
  845. DateTime temDate = new DateTime();
  846. if (DateTime.TryParse(row["处理事项完成日"].ToString().Trim(), out temDate))
  847. {
  848. item.FinishedDate = temDate;
  849. }
  850. //定稿日
  851. if (DateTime.TryParse(row["定稿日"].ToString().Trim(), out temDate))
  852. {
  853. item.FinalizationDate = temDate;
  854. }
  855. //返稿日
  856. if (DateTime.TryParse(row["返稿日"].ToString().Trim(), out temDate))
  857. {
  858. item.ReturnDate = temDate;
  859. }
  860. //案件类型
  861. item.CaseType = row["案件类型"].ToString().Trim();
  862. //案件状态
  863. item.CaseState = row["案件状态"].ToString().Trim();
  864. //处理事项备注
  865. item.DoItemMemo = row["处理事项备注"].ToString().Trim();
  866. //处理状态
  867. item.DoItemState = row["处理状态"].ToString().Trim();
  868. //案件名称
  869. item.CaseName = row["案件名称"].ToString().Trim();
  870. //委案日期
  871. if (DateTime.TryParse(row["委案日期"].ToString().Trim(), out temDate))
  872. {
  873. item.EntrustingDate = temDate;
  874. }
  875. //客户期限
  876. if (DateTime.TryParse(row["客户期限"].ToString().Trim(), out temDate))
  877. {
  878. item.CustomerLimitDate = temDate;
  879. }
  880. //内部期限
  881. if (DateTime.TryParse(row["内部期限"].ToString().Trim(), out temDate))
  882. {
  883. item.InternalDate = temDate;
  884. }
  885. //初稿日
  886. if (DateTime.TryParse(row["初稿日"].ToString().Trim(), out temDate))
  887. {
  888. item.FirstDraftDate = temDate;
  889. }
  890. //备注(发文严重超期是否属客观原因,若为否,请填写原因)
  891. if (row.Table.Columns.Contains("备注(发文严重超期是否属客观原因,若为否,请填写原因)"))
  892. {
  893. item.OverDueMemo = row["备注(发文严重超期是否属客观原因,若为否,请填写原因)"].ToString().Trim();
  894. }
  895. //案件备注
  896. item.CaseMemo = row["案件备注"].ToString().Trim();
  897. if (row.Table.Columns.Contains("翻译字数"))
  898. {
  899. //item.ReviewerId = GetStaff(row["案件核稿人"].ToString().Trim());
  900. var strWordCount = row["翻译字数"].ToString().Trim();
  901. if (string.IsNullOrEmpty(strWordCount))
  902. {
  903. try
  904. {
  905. item.WordCount = int.Parse(strWordCount);
  906. }
  907. catch { }
  908. }
  909. }
  910. return item;
  911. }
  912. private int? GetStaff(string v)
  913. {
  914. if (!string.IsNullOrEmpty(v))
  915. {
  916. string temName = v.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  917. if (!v.Contains("君龙"))
  918. {
  919. temName = v;
  920. }
  921. var staff = spDb.Staffs.Where<Staff>(s => s.Name == temName).FirstOrDefault();
  922. if (staff != null)
  923. {
  924. return staff.Id;
  925. }
  926. }
  927. return null;
  928. }
  929. private DataTable GetDataFromIPEasy(string ReportName, bool isModifyDate)
  930. {
  931. DataTable dt = new DataTable();
  932. string strSQL = "";
  933. switch (ReportName)
  934. {
  935. case "每月绩效统计--发客户超过一个月未完成案件":
  936. strSQL = @"SELECT p_case_info.case_volume as 我方文号,
  937. i_apply_type.apply_type_zh_cn as 申请类型,
  938. i_business_type.business_type_zh_cn as 业务类型,
  939. i_ctrl_proc.ctrl_proc_zh_cn as 处理事项,
  940. (select case_status_zh_cn from i_case_status where case_status_id=p_proc_info.review_stage) as 案件阶段,
  941. i_case_coefficient.case_coefficient_zh_cn as 案件系数,
  942. i_proc_coefficient.proc_coefficient_zh_cn as 处理事项系数,
  943. (select proc_coefficient_zh_cn from p_proc_info pr
  944. left join i_proc_coefficient pc on pc.proc_coefficient_id=pr.proc_coefficient_id
  945. where case_id=p_case_info.case_id and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'
  946. and pr.seq=
  947. (select max(seq) from p_proc_info pr where case_id=p_case_info.case_id
  948. and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'and seq<p_proc_info.seq)
  949. ) as 前一次OA处理事项系数,
  950. (STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
  951. inner join s_user_info as u on u.user_id = pl.pic_id
  952. inner join p_proc_info pr1 on pr1.proc_id=pl.obj_id
  953. where case_id=p_case_info.case_id and
  954. ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'
  955. and pr1.seq=(
  956. select max(seq) from p_proc_info pr2 where case_id=p_case_info.case_id
  957. and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'
  958. and seq<p_proc_info.seq) FOR XML PATH('') ),1,1,'')) as 前一次OA处理人,
  959. STUFF((SELECT ',' + ur.rank_zh_cn from p_proc_pic_list as pl
  960. inner join s_user_info as u on u.user_id = pl.pic_id
  961. left join i_user_rank ur on ur.rank_id=u.rank_id
  962. where pl.obj_id = p_proc_info.proc_id FOR XML PATH('') ),1,1,'') as 处理人等级,
  963. STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
  964. inner join s_user_info as u on u.user_id = pl.pic_id
  965. where pl.obj_id = p_proc_info.proc_id FOR XML PATH('') ),1,1,'') as 处理人,
  966. STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl
  967. inner join s_user_info as u on u.user_id = pl.revise_user_id
  968. where pl.obj_id = p_proc_info.proc_id FOR XML PATH('') ),1,1,'') as 核稿人,
  969. c_customer.customer_name as 客户名称,
  970. STUFF((SELECT ',' + a.applicant_name_cn from p_applicant_list as al
  971. inner join i_applicant as a on a.applicant_id = al.applicant_id
  972. where al.obj_id = p_case_info.case_id order by al.seq FOR XML PATH('') ),1,1,'') as 申请人,
  973. p_proc_info.finish_date as 处理事项完成日,
  974. p_proc_info.finish_doc_date as 定稿日,
  975. p_proc_info.back_date as 返稿日,
  976. i_case_type.case_type_zh_cn as 案件类型,
  977. i_case_status.case_status_zh_cn as 案件状态,
  978. p_proc_info.proc_note as 处理事项备注,
  979. (select proc_status_zh_cn from i_proc_status where proc_status_id=p_proc_info.proc_status_id) as 处理状态,
  980. p_case_info.case_name as 案件名称,
  981. p_case_info.charge_date as 委案日期,
  982. p_proc_info.cus_due_date as 客户期限,
  983. p_proc_info.int_due_date as 内部期限,
  984. p_proc_info.first_doc_date as 初稿日,
  985. p_case_info.remark as 案件备注,
  986. p_proc_info.translate_count as 翻译字数,
  987. STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl
  988. inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id
  989. where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员,
  990. i_country.country_zh_cn as '国家(地区)'
  991. from p_case_info
  992. inner join p_case_advance_info with(nolock) on p_case_info.case_id=p_case_advance_info.case_id
  993. inner join i_apply_type with(nolock) on i_apply_type.apply_type_id=p_case_info.apply_type_id
  994. inner join i_case_type with(nolock) on i_case_type.case_type_id=p_case_info.case_type_id
  995. inner join i_country with(nolock) on i_country.country_id=p_case_info.country_id
  996. inner join i_case_status with(nolock) on i_case_status.case_status_id=p_case_info.case_status_id
  997. inner join c_customer with(nolock) on c_customer.customer_id=p_case_info.customer_id
  998. left join i_case_coefficient on i_case_coefficient.case_coefficient_id=p_case_info.case_coefficient_id
  999. inner join p_proc_info with(nolock) on p_case_info.case_id=p_proc_info.case_id
  1000. inner join i_ctrl_proc with(nolock) on p_proc_info.ctrl_proc_id=i_ctrl_proc.ctrl_proc_id
  1001. inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id
  1002. inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id
  1003. left join p_proc_pic_list with(nolock) on p_proc_pic_list.obj_id=p_proc_info.proc_id
  1004. left join s_user_info with(nolock) on s_user_info.user_id=p_proc_pic_list.pic_id
  1005. left join i_proc_coefficient on i_proc_coefficient.proc_coefficient_id=p_proc_info.proc_coefficient_id
  1006. where
  1007. p_case_info.is_enabled=1 and p_proc_info.is_enabled=1 and
  1008. s_user_info.dept_id not in ('60e09ee0-fcc7-446f-badc-af9973079fee','34d0e351-71dc-418f-9b6b-bcb67af62fed','599cbe0c-044e-4ffc-9411-96dd9019d8a6') and
  1009. p_proc_info.finish_date is null
  1010. and p_proc_info.back_date<DATEADD(MM,-1,DATEADD(MM, DATEDIFF(MM,0,getdate()), 0)) and
  1011. (p_case_info.case_type_id='31D1A147-2931-43B5-94AE-B72B1525BA8A' ) AND
  1012. ( i_ctrl_proc.ctrl_proc_zh_cn='新申请'
  1013. or i_ctrl_proc.ctrl_proc_zh_cn='Non'
  1014. or i_ctrl_proc.ctrl_proc_zh_cn='无效宣告'
  1015. or i_ctrl_proc.ctrl_proc_zh_cn='意见陈述'
  1016. or i_ctrl_proc.ctrl_proc_zh_cn='专利挖掘与布局'
  1017. or i_ctrl_proc.ctrl_proc_zh_cn='处理审查意见'
  1018. or i_ctrl_proc.ctrl_proc_zh_cn='Final'
  1019. or i_ctrl_proc.ctrl_proc_zh_cn='复审通知意见陈述'
  1020. or i_ctrl_proc.ctrl_proc_zh_cn='申復'
  1021. or i_ctrl_proc.ctrl_proc_zh_cn='RCE'
  1022. or i_ctrl_proc.ctrl_proc_zh_cn='翻译'
  1023. or i_ctrl_proc.ctrl_proc_zh_cn='提出异议复审'
  1024. or i_ctrl_proc.ctrl_proc_zh_cn='Advisory'
  1025. or i_ctrl_proc.ctrl_proc_zh_cn='复审'
  1026. or i_ctrl_proc.ctrl_proc_zh_cn='请求复审'
  1027. or i_ctrl_proc.ctrl_proc_zh_cn='提出报告'
  1028. or i_ctrl_proc.ctrl_proc_zh_cn='提出公众意见'
  1029. or i_ctrl_proc.ctrl_proc_zh_cn='诉讼'
  1030. or i_ctrl_proc.ctrl_proc_zh_cn='提出异议'
  1031. or i_ctrl_proc.ctrl_proc_zh_cn='补充理由和证据'
  1032. or i_ctrl_proc.ctrl_proc_zh_cn='无效分析'
  1033. or i_ctrl_proc.ctrl_proc_zh_cn='无效答辩'
  1034. )";
  1035. break;
  1036. case "每月绩效统计--上个月递交完成案件":
  1037. strSQL = @"SELECT
  1038. p_case_info.case_volume as 我方文号,
  1039. i_apply_type.apply_type_zh_cn as 申请类型,
  1040. i_business_type.business_type_zh_cn as 业务类型,
  1041. i_ctrl_proc.ctrl_proc_zh_cn as 处理事项,
  1042. (select case_status_zh_cn from i_case_status where case_status_id=p_proc_info.review_stage) as 案件阶段,
  1043. i_case_coefficient.case_coefficient_zh_cn as 案件系数,
  1044. i_proc_coefficient.proc_coefficient_zh_cn as 处理事项系数,
  1045. (select
  1046. proc_coefficient_zh_cn from p_proc_info pr
  1047. left join i_proc_coefficient pc on pc.proc_coefficient_id=pr.proc_coefficient_id
  1048. where case_id=p_case_info.case_id
  1049. and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'
  1050. and pr.seq=(select max(seq) from p_proc_info pr where case_id=p_case_info.case_id
  1051. and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'and seq<p_proc_info.seq)
  1052. ) as 前一次OA处理事项系数,
  1053. (STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
  1054. inner join s_user_info as u on u.user_id = pl.pic_id
  1055. inner join p_proc_info pr1 on pr1.proc_id=pl.obj_id
  1056. where case_id=p_case_info.case_id
  1057. and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'
  1058. and pr1.seq=(select max(seq) from p_proc_info pr2 where case_id=p_case_info.case_id
  1059. and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'and seq<p_proc_info.seq) FOR XML PATH('') ),1,1,'')
  1060. ) as 前一次OA处理人,
  1061. STUFF((SELECT ',' + ur.rank_zh_cn from p_proc_pic_list as pl
  1062. inner join s_user_info as u on u.user_id = pl.pic_id
  1063. 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 处理人等级,
  1064. STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
  1065. inner join s_user_info as u on u.user_id = pl.pic_id
  1066. where pl.obj_id = p_proc_info.proc_id FOR XML PATH('') ),1,1,'') as 处理人,
  1067. STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl
  1068. inner join s_user_info as u on u.user_id = pl.revise_user_id
  1069. where pl.obj_id = p_case_info.case_id FOR XML PATH('') ),1,1,'') as 案件核稿人,
  1070. c_customer.customer_name as 客户名称,
  1071. STUFF((SELECT ',' + a.applicant_name_cn from p_applicant_list as al
  1072. inner join i_applicant as a on a.applicant_id = al.applicant_id
  1073. where al.obj_id = p_case_info.case_id order by al.seq FOR XML PATH('') ),1,1,'') as 申请人,
  1074. p_proc_info.finish_date as 处理事项完成日,
  1075. p_proc_info.finish_doc_date as 定稿日,
  1076. p_proc_info.back_date as 返稿日,
  1077. i_case_type.case_type_zh_cn as 案件类型,
  1078. i_case_status.case_status_zh_cn as 案件状态,
  1079. p_proc_info.proc_note as 处理事项备注,
  1080. (select proc_status_zh_cn from i_proc_status where proc_status_id=p_proc_info.proc_status_id) as 处理状态,
  1081. p_case_info.case_name as 案件名称,
  1082. p_case_info.charge_date as 委案日期,
  1083. p_proc_info.cus_due_date as 客户期限,
  1084. p_proc_info.int_due_date as 内部期限,
  1085. p_proc_info.first_doc_date as 初稿日,
  1086. p_case_info.remark as 案件备注,
  1087. p_proc_info.translate_count as 翻译字数,
  1088. STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl
  1089. inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id
  1090. where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员,
  1091. i_country.country_zh_cn as '国家(地区)'
  1092. from p_case_info
  1093. inner join p_case_advance_info with(nolock) on p_case_info.case_id=p_case_advance_info.case_id
  1094. inner join i_apply_type with(nolock) on i_apply_type.apply_type_id=p_case_info.apply_type_id
  1095. inner join i_case_type with(nolock) on i_case_type.case_type_id=p_case_info.case_type_id
  1096. inner join i_country with(nolock) on i_country.country_id=p_case_info.country_id
  1097. inner join i_case_status with(nolock) on i_case_status.case_status_id=p_case_info.case_status_id
  1098. inner join c_customer with(nolock) on c_customer.customer_id=p_case_info.customer_id
  1099. left join i_case_coefficient on i_case_coefficient.case_coefficient_id=p_case_info.case_coefficient_id
  1100. inner join p_proc_info with(nolock) on p_case_info.case_id=p_proc_info.case_id
  1101. inner join i_ctrl_proc with(nolock) on p_proc_info.ctrl_proc_id=i_ctrl_proc.ctrl_proc_id
  1102. inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id
  1103. inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id
  1104. left join p_proc_pic_list with(nolock) on p_proc_pic_list.obj_id=p_proc_info.proc_id
  1105. left join s_user_info with(nolock) on s_user_info.user_id=p_proc_pic_list.pic_id
  1106. left join i_proc_coefficient on i_proc_coefficient.proc_coefficient_id=p_proc_info.proc_coefficient_id
  1107. where
  1108. p_case_info.is_enabled=1
  1109. and p_proc_info.is_enabled=1
  1110. and s_user_info.dept_id not in ('60e09ee0-fcc7-446f-badc-af9973079fee','34d0e351-71dc-418f-9b6b-bcb67af62fed','599cbe0c-044e-4ffc-9411-96dd9019d8a6')
  1111. and (p_case_info.case_type_id='31D1A147-2931-43B5-94AE-B72B1525BA8A' )
  1112. AND ((p_proc_info.finish_date >= @beginTime and p_proc_info.finish_date<@endTime)) ";
  1113. break;
  1114. case "每月绩效统计--中国一次OA授权表":
  1115. strSQL = @"select
  1116. p_case_info.case_volume as 我方文号,
  1117. p_case_info.case_name as 案件名称,
  1118. p_case_info.app_no as 申请号,
  1119. c_customer.customer_name as 客户名称,
  1120. STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
  1121. inner join s_user_info as u on u.user_id = pl.pic_id
  1122. where pl.obj_id = p_case_info.case_id FOR XML PATH('') ),1,1,'') as 案件处理人,
  1123. STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl
  1124. inner join s_user_info as u on u.user_id = pl.revise_user_id
  1125. where pl.obj_id = p_case_info.case_id FOR XML PATH('') ),1,1,'') as 案件核稿人,
  1126. p_file_list.post_date as 发文日期,
  1127. p_case_info.case_volume_customer as 客户文号,
  1128. p_case_info.app_date as 申请日,
  1129. i_country.country_zh_cn as '国家(地区)',
  1130. STUFF((SELECT ',' + a.applicant_name_cn from p_applicant_list as al
  1131. inner join i_applicant as a on a.applicant_id = al.applicant_id
  1132. where al.obj_id = p_case_info.case_id order by al.seq FOR XML PATH('') ),1,1,'') as 申请人,
  1133. p_file_list.upload_time as 上传日期,
  1134. i_file_desc.file_desc_zh_cn as 文件描述,
  1135. i_apply_type.apply_type_zh_cn as 申请类型,
  1136. STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl
  1137. inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id
  1138. where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员
  1139. from p_case_info
  1140. inner join i_apply_type on p_case_info.apply_type_id=i_apply_type.apply_type_id
  1141. inner join p_proc_info on p_case_info.case_id=p_proc_info.case_id
  1142. inner join p_file_list on p_file_list.obj_id=p_proc_info.proc_id
  1143. inner join i_file_desc on i_file_desc.file_desc_id=p_file_list.file_desc_id
  1144. inner join c_customer on p_case_info.customer_id=c_customer.customer_id
  1145. inner join i_country on i_country.country_id=p_case_info.country_id
  1146. where
  1147. p_case_info.is_enabled=1
  1148. and p_proc_info.is_enabled=1 and p_case_info.country_id='CN'
  1149. and p_file_list.file_desc_id='09800D39-D585-49F3-B9DE-50AC689DE9AB'
  1150. and p_file_list.file_name not like '%.zip'
  1151. 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
  1152. and (p_case_info.case_type_id='31D1A147-2931-43B5-94AE-B72B1525BA8A' )
  1153. AND ((p_file_list.post_date >= @beginTime and p_file_list.post_date<@endTime))";
  1154. break;
  1155. case "每月绩效统计--专案进度跟踪~S卷":
  1156. strSQL = @"SELECT p_case_info.case_volume as 我方文号,
  1157. p_case_info.case_name as 案件名称,
  1158. i_case_type.case_type_zh_cn as 案件类型,
  1159. i_business_type.business_type_zh_cn as 业务类型,
  1160. i_country.country_zh_cn as '国家(地区)',
  1161. c_customer.customer_name as 客户名称,
  1162. s_dept_info.dept_full_name as 承办部门,
  1163. i_case_status.case_status_zh_cn as 案件状态,
  1164. i_ctrl_proc.ctrl_proc_zh_cn as 处理事项,
  1165. p_proc_info.int_due_date as 内部期限,
  1166. p_proc_info.cus_due_date as 客户期限,
  1167. p_proc_info.legal_due_date as 官方期限,
  1168. p_proc_info.finish_doc_date as 定稿日,
  1169. STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
  1170. inner join s_user_info as u on u.user_id = pl.pic_id where pl.obj_id = p_proc_info.proc_id
  1171. FOR XML PATH('') ),1,1,'') as 处理人,
  1172. p_case_info.charge_date as 委案日期,
  1173. (select proc_status_zh_cn from i_proc_status where proc_status_id=p_proc_info.proc_status_id) as 处理状态,
  1174. p_proc_info.first_doc_date as 初稿日,
  1175. STUFF((SELECT ',' + u.cn_name from c_customer_user as cu
  1176. inner join s_user_info as u on u.user_id = cu.user_id
  1177. where cu.customer_id = p_case_info.customer_id FOR XML PATH('') ),1,1,'') as 流程负责人,
  1178. p_proc_info.finish_date as 处理事项完成日,
  1179. STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl
  1180. inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id
  1181. where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员
  1182. from p_case_info
  1183. inner join p_case_advance_info with(nolock) on p_case_info.case_id=p_case_advance_info.case_id
  1184. inner join i_apply_type with(nolock) on i_apply_type.apply_type_id=p_case_info.apply_type_id
  1185. inner join i_case_type with(nolock) on i_case_type.case_type_id=p_case_info.case_type_id
  1186. inner join i_country with(nolock) on i_country.country_id=p_case_info.country_id
  1187. inner join i_case_status with(nolock) on i_case_status.case_status_id=p_case_info.case_status_id
  1188. inner join c_customer with(nolock) on c_customer.customer_id=p_case_info.customer_id
  1189. inner join p_proc_info with(nolock) on p_case_info.case_id=p_proc_info.case_id
  1190. inner join i_ctrl_proc with(nolock) on p_proc_info.ctrl_proc_id=i_ctrl_proc.ctrl_proc_id
  1191. inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id
  1192. inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id
  1193. where p_case_info.is_enabled=1 and p_proc_info.is_enabled=1 and
  1194. (isnull (p_proc_info.finish_date,'') ='') AND (i_ctrl_proc.ctrl_proc_zh_cn='提出报告')";
  1195. break;
  1196. case "每月绩效统计--专案开卷报表~S卷":
  1197. strSQL = @"SELECT p_case_info.case_volume as 我方文号,
  1198. p_case_info.case_volume_customer as 客户文号,
  1199. p_case_info.case_name as 案件名称,
  1200. p_case_info.charge_date as 委案日期,
  1201. i_case_status.case_status_zh_cn as 案件状态,
  1202. i_case_type.case_type_zh_cn as 案件类型,
  1203. p_case_info.app_no as 申请号,
  1204. p_case_info.app_date as 申请日,
  1205. i_business_type.business_type_zh_cn as 业务类型,
  1206. STUFF((SELECT ',' + u.cn_name from c_customer_user as cu
  1207. 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 流程负责人,
  1208. c_customer.customer_name as 客户名称,
  1209. STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl
  1210. 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 案件核稿人,
  1211. STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
  1212. 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 案件处理人,
  1213. p_case_info.create_time as 开卷日期,
  1214. STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl
  1215. inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id
  1216. where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员,
  1217. i_country.country_zh_cn as '国家(地区)'
  1218. from p_case_info
  1219. inner join p_case_advance_info with(nolock) on p_case_info.case_id=p_case_advance_info.case_id
  1220. inner join i_apply_type with(nolock) on i_apply_type.apply_type_id=p_case_info.apply_type_id
  1221. inner join i_case_type with(nolock) on i_case_type.case_type_id=p_case_info.case_type_id
  1222. inner join i_country with(nolock) on i_country.country_id=p_case_info.country_id
  1223. inner join i_case_status with(nolock) on i_case_status.case_status_id=p_case_info.case_status_id
  1224. inner join c_customer with(nolock) on c_customer.customer_id=p_case_info.customer_id
  1225. inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id
  1226. inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id
  1227. where p_case_info.is_enabled=1 and
  1228. (p_case_info.business_type_id='ad0d4c8f-7c2d-4cbf-a5b4-cc1a64d4c384'
  1229. or p_case_info.business_type_id='20184cc4-1dd8-4d5b-81bd-4b39ca3700f4'
  1230. or p_case_info.business_type_id='94713100-f013-4444-a5a1-1dd1b78d8cdf'
  1231. or p_case_info.business_type_id='f2d4d629-b7a5-4fa5-888d-91029ce7a3f5'
  1232. or p_case_info.business_type_id='32144fb3-2ce0-4ed9-ae6f-a6a09fb66e60') AND
  1233. (DATEDIFF(dd,p_case_info.create_time,getdate())<='31') ";
  1234. break;
  1235. }
  1236. using (var conn = new SqlConnection(ConfigHelper.GetSectionValue("IPEasySetting:ConnectionStrings")))
  1237. {
  1238. try
  1239. {
  1240. conn.Open();
  1241. using (var cmd = conn.CreateCommand())
  1242. {
  1243. cmd.CommandText = strSQL;
  1244. cmd.CommandType = CommandType.Text;
  1245. if (isModifyDate)
  1246. {
  1247. cmd.Parameters.Add(new SqlParameter("beginTime", DateTime.Parse(DateTime.Now.AddMonths(-1).ToString("yyyy-MM") + "-01")));
  1248. cmd.Parameters.Add(new SqlParameter("endTime", DateTime.Parse(DateTime.Now.ToString("yyyy-MM") + "-01")));
  1249. }
  1250. using (var reader = cmd.ExecuteReader())
  1251. {
  1252. dt.Load(reader);
  1253. }
  1254. }
  1255. }
  1256. catch (Exception ex)
  1257. {
  1258. throw ex;
  1259. }
  1260. }
  1261. return dt;
  1262. }
  1263. }
  1264. }