ImportReportJob.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849
  1. using DynamicExpresso;
  2. using Microsoft.Extensions.DependencyInjection;
  3. using Quartz;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Configuration;
  7. using System.Data;
  8. using System.Linq;
  9. using System.Threading.Tasks;
  10. using wispro.sp.entity;
  11. using wispro.sp.utility;
  12. namespace wispro.sp.api.Job
  13. {
  14. public class ImportReportJob : Quartz.IJob
  15. {
  16. /// <summary>
  17. /// 不需要计算绩效的处理事项
  18. /// </summary>
  19. private string[] InValidDoItem = new string[]
  20. {
  21. "案件异常-催缴年费",
  22. "案件异常-视为放弃取得专利权",
  23. "办理登记手续",
  24. "办理登记手续-确认客户是否委托",
  25. "代理所变更",
  26. "绘图",
  27. "技术确认",
  28. "缴年费",
  29. "请求保密审查",
  30. "请求费减",
  31. "请求实审",
  32. "取得申请号",
  33. "取得证书",
  34. "取得专利权评价报告",
  35. "确认官方审查状况",
  36. "询问放弃或复审",
  37. "知识点总结",
  38. "专利权人发明人申请人信息变更",
  39. "专利挖掘与布局",
  40. "我方文号前缀带J",
  41. "开卷",
  42. "请求提前公开",
  43. "取得国际检索报告",
  44. "委外检索",
  45. "中止程序",
  46. "终止",
  47. "案件异常-视为撤回",
  48. "进入国家阶段提醒",
  49. "请求恢复权利",
  50. "请求优先权",
  51. "取得【无效宣告请求审查决定】",
  52. "撤回",
  53. "请求退款",
  54. "确认是否委托申请与类型",
  55. "专利交易",
  56. "专利权评价报告",
  57. "专利权人发明人申请人信息变更+代理所变更"
  58. };
  59. spDbContext spDb = new spDbContext();
  60. public Task Execute(IJobExecutionContext context)
  61. {
  62. CalMonth calMonth = new CalMonth()
  63. {
  64. Year = DateTime.Now.AddMonths(-1).Year,
  65. Month = DateTime.Now.AddMonths(-1).Month,
  66. Status = 0
  67. };
  68. var temCalMonth = spDb.CalMonths.Where<CalMonth>(x => x.Year == calMonth.Year && x.Month == calMonth.Month).FirstOrDefault();
  69. if (temCalMonth != null)
  70. {
  71. var iCount = spDb.PerformanceItems.Where<PerformanceItem>(p => p.CalMonthId == temCalMonth.Id).Count<PerformanceItem>();
  72. if (iCount > 0)
  73. {
  74. return Task.CompletedTask;
  75. }
  76. calMonth = temCalMonth;
  77. }
  78. else
  79. {
  80. spDb.CalMonths.Add(calMonth);
  81. spDb.SaveChanges();
  82. }
  83. //每月绩效统计--发客户超过一个月未完成案件
  84. DownloadReport( "每月绩效统计--发客户超过一个月未完成案件", calMonth,false);
  85. //每月绩效统计--上个月递交完成案件
  86. DownloadReport("每月绩效统计--上个月递交完成案件", calMonth, true);
  87. //每月绩效统计--中国一次OA授权表
  88. DownloadReport("每月绩效统计--中国一次OA授权表", calMonth, true,true);
  89. //专案数据
  90. DownloadProject(calMonth);
  91. var lstStaff = spDb.Staffs.Where<Staff>(s=>s.ItemStaffs.Where<ItemStaff>(p=>p.Item.CalMonthId == calMonth.Id).Count<ItemStaff>()>0);
  92. foreach (var staff in lstStaff.ToList<Staff>())
  93. {
  94. string strSubject = $"{calMonth.Year}年{calMonth.Month}月绩效数据确认通知";
  95. string strBody = $"<html><body>{staff.Name},您好!<br/></br/>&nbsp;&nbsp;&nbsp;&nbsp;<div>{calMonth.Year}年{calMonth.Month}月绩效数据已生成,请在{DateTime.Now.AddDays(4).ToString("yyyy年MM月dd日")}之前确认完成!</div></body></html>";
  96. string strTo = "luocaiyang@wispro-china.com";
  97. _ = QuartzUtil.AddMailJob(strSubject, strBody, staff.Name, strTo);
  98. }
  99. return Task.CompletedTask;
  100. }
  101. private void DownloadReport(string ReportName,CalMonth calMonth,bool isModifyDate,bool isFirstOA=false)
  102. {
  103. string strFileSavePath = utility.ConfigHelper.GetSectionValue("IPEasySetting:DownloadFileSavePath");
  104. int tryCount = 0;
  105. tryAgain:
  106. try
  107. {
  108. wispro.sp.utility.IPEasyUtility.DownloadReport(ReportName, isModifyDate);
  109. }
  110. catch {
  111. tryCount++;
  112. if (tryCount < 5)
  113. {
  114. goto tryAgain;
  115. }
  116. }
  117. System.Threading.Thread.Sleep(5000);
  118. string filename = $"{ReportName.Trim()}.xlsx";
  119. string strFilePath = System.IO.Path.Combine(strFileSavePath, filename);
  120. string strFinalPath = System.IO.Path.Combine(strFileSavePath, $"{calMonth.Year}{calMonth.Month}-{filename}");
  121. InputPerformanceItem(strFilePath, true, false, 1, calMonth, isFirstOA);
  122. System.IO.File.Move(strFilePath, strFinalPath);
  123. }
  124. private void DownloadProject(CalMonth calMonth)
  125. {
  126. string strFileSavePath = utility.ConfigHelper.GetSectionValue("IPEasySetting:DownloadFileSavePath");
  127. int tryCount = 0;
  128. string[] ReportNames =new string[] { "每月绩效统计--专案进度跟踪~S卷", "每月绩效统计--专案开卷报表~S卷" };
  129. List<PerformanceItem> pfItems = new List<PerformanceItem>();
  130. foreach (var ReportName in ReportNames)
  131. {
  132. tryAgain:
  133. try
  134. {
  135. wispro.sp.utility.IPEasyUtility.DownloadReport(ReportName, false);
  136. }
  137. catch
  138. {
  139. tryCount++;
  140. if (tryCount < 5)
  141. {
  142. goto tryAgain;
  143. }
  144. }
  145. System.Threading.Thread.Sleep(5000);
  146. string filename = $"{ReportName.Trim().Replace("~","_")}.xlsx";
  147. string strFilePath = System.IO.Path.Combine(strFileSavePath, filename);
  148. string strFinalPath = System.IO.Path.Combine(strFileSavePath, $"{calMonth.Year}{calMonth.Month}-{filename}");
  149. var Items = GetProjectItem(strFilePath, calMonth, ReportName.Contains("专案开卷报表"));
  150. foreach(var item in Items)
  151. {
  152. var temObj = pfItems.FirstOrDefault<PerformanceItem>(s => s.CaseNo == item.CaseNo);
  153. if(temObj == null)
  154. {
  155. item.Type = "专案";
  156. pfItems.Add(item);
  157. }
  158. }
  159. System.IO.File.Move(strFilePath, strFinalPath);
  160. }
  161. //List<BasePointRule> rules = spDb.BasePointRules.ToList<BasePointRule>();
  162. foreach (var item in pfItems)
  163. {
  164. SaveProjectItem(item);
  165. }
  166. }
  167. private void SaveProjectItem(PerformanceItem item)
  168. {
  169. var temObj = spDb.ProjectInfos.FirstOrDefault(p=>p.CaseNo == item.CaseNo);
  170. if (temObj == null)
  171. {
  172. ProjectInfo project = new ProjectInfo();
  173. project.CaseNo = item.CaseNo;
  174. project.CaseName = item.CaseName;
  175. project.CaseState = 0;
  176. project.CaseType = item.CaseType;
  177. project.CustomerId = item.CustomerId;
  178. project.ReviewerId = item.ReviewerId;
  179. spDb.ProjectInfos.Add(project);
  180. }
  181. spDb.SaveChanges();
  182. }
  183. private List<PerformanceItem> GetProjectItem(string strPath,CalMonth calMonth,bool isOpenSheet)
  184. {
  185. DataTable dt = NPOIExcel.ExcelToDataTable(strPath, true, true, 1);
  186. #region 删除重复行
  187. DataTable temdt = new DataTable();
  188. foreach (DataColumn col in dt.Columns)
  189. {
  190. DataColumn temCol = new DataColumn();
  191. temCol.ColumnName = col.ColumnName;
  192. temCol.DataType = col.DataType;
  193. temCol.Caption = col.Caption;
  194. temdt.Columns.Add(temCol);
  195. }
  196. new ExcelHelper().MerageDataTable(temdt, dt);
  197. #endregion
  198. List<PerformanceItem> Items = new List<PerformanceItem>();
  199. int iRow = 0;
  200. foreach (DataRow row in temdt.Rows)
  201. {
  202. string strDebug = $"{++iRow}\t{row["我方文号"]}";
  203. PerformanceItem item = null;
  204. if (!isOpenSheet)
  205. {
  206. item = Row2Item_2(row, calMonth);
  207. }
  208. else
  209. {
  210. item = Row2Item_3(row, calMonth);
  211. }
  212. if (item != null)
  213. {
  214. item.CalMonth = calMonth;
  215. item.CalMonthId = calMonth.Id;
  216. Items.Add(item);
  217. }
  218. }
  219. return Items;
  220. }
  221. private Task InputPerformanceItem(string strExcelFile, bool isColumnName, bool ignorHideRows = false, int ColumnNameRow = 0, CalMonth calMonth = null, bool isFirstOAFile = false)
  222. {
  223. DataTable dt = NPOIExcel.ExcelToDataTable(strExcelFile, isColumnName, ignorHideRows, ColumnNameRow);
  224. #region 删除重复行
  225. DataTable temdt = new DataTable();
  226. foreach (DataColumn col in dt.Columns)
  227. {
  228. DataColumn temCol = new DataColumn();
  229. temCol.ColumnName = col.ColumnName;
  230. temCol.DataType = col.DataType;
  231. temCol.Caption = col.Caption;
  232. temdt.Columns.Add(temCol);
  233. }
  234. new ExcelHelper().MerageDataTable(temdt, dt);
  235. #endregion
  236. List<BasePointRule> rules = spDb.BasePointRules.ToList<BasePointRule>();
  237. int iRow = 0;
  238. foreach (DataRow row in temdt.Rows)
  239. {
  240. string strDebug = $"{++iRow}\t{row["我方文号"]}";
  241. PerformanceItem item = null;
  242. if (isFirstOAFile)
  243. {
  244. item = Row2Item_1(row, calMonth);
  245. }
  246. else
  247. {
  248. item = Row2Item(row, calMonth);
  249. }
  250. if (item != null)
  251. {
  252. if (!InValidDoItem.Contains(item.DoItem))
  253. {
  254. SavePerformanceItem(item,rules);
  255. strDebug = $"{strDebug}\t保存成功";
  256. }
  257. else
  258. {
  259. strDebug = $"{strDebug}\t无效处理事项";
  260. }
  261. }
  262. else
  263. {
  264. strDebug = $"{strDebug}\t转换Item为Null";
  265. }
  266. System.Diagnostics.Debug.WriteLine(strDebug);
  267. }
  268. return Task.CompletedTask;
  269. }
  270. private Task SavePerformanceItem(PerformanceItem item,List<BasePointRule> rules)
  271. {
  272. try
  273. {
  274. Utility.Utility.CalBasePoint(item, rules);
  275. var ret= new Controllers.PerformanceItemController(spDb,new Services.FileTaskCacheService()).New(item);
  276. if (ret.Success == false)
  277. {
  278. System.Diagnostics.Debug.WriteLine(ret.ErrorMessage);
  279. }
  280. }
  281. catch (Exception ex)
  282. {
  283. System.Diagnostics.Debug.WriteLine(ex.Message);
  284. }
  285. return Task.CompletedTask;
  286. }
  287. private PerformanceItem Row2Item_3(DataRow row, CalMonth calMonth)
  288. {
  289. PerformanceItem item = new PerformanceItem();
  290. item.CaseNo = row["我方文号"].ToString().Trim();
  291. item.CaseName = row["案件名称"].ToString().Trim();
  292. item.CaseType = row["案件类型"].ToString().Trim();
  293. item.BusinessType = row["业务类型"].ToString().Trim();
  294. item.Customer = new Customer();
  295. item.Customer.Name = row["客户名称"].ToString().Trim();
  296. item.CaseState = row["案件状态"].ToString().Trim();
  297. DateTime temDate = new DateTime();
  298. if (DateTime.TryParse(row["委案日期"].ToString().Trim(), out temDate))
  299. {
  300. item.EntrustingDate = temDate;
  301. }
  302. string strHandler = "";
  303. if (row.Table.Columns.Contains("处理人"))
  304. {
  305. strHandler = row["处理人"].ToString().Trim();
  306. }
  307. else
  308. {
  309. if (row.Table.Columns.Contains("案件处理人"))
  310. {
  311. strHandler = row["案件处理人"].ToString().Trim();
  312. }
  313. }
  314. string[] temHandlers = strHandler.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  315. item.ItemStaffs = new List<ItemStaff>();
  316. foreach (string name in temHandlers)
  317. {
  318. ItemStaff itemStaff = new ItemStaff();
  319. int? iTem = GetStaff(name);
  320. if ((iTem != null))
  321. {
  322. //itemStaff.Item = item;
  323. itemStaff.DoPersonId = iTem.Value;
  324. item.ItemStaffs.Add(itemStaff);
  325. }
  326. else
  327. {
  328. itemStaff.DoPerson = new Staff()
  329. {
  330. Name = name,
  331. Account = name,
  332. Password = "12345678",
  333. IsCalPerformsnce = false,
  334. Status = "正式员工",
  335. StaffGradeId = 4
  336. };
  337. item.ItemStaffs.Add(itemStaff);
  338. }
  339. }
  340. if (item.ItemStaffs.Count == 0)
  341. {
  342. System.Diagnostics.Debug.WriteLine($"没有处理人: {item.CaseNo}\t{item.DoItem}");
  343. }
  344. if (row.Table.Columns.Contains("核稿人"))
  345. {
  346. item.ReviewerId = GetStaff(row["核稿人"].ToString().Trim());
  347. }
  348. else
  349. {
  350. if (row.Table.Columns.Contains("案件核稿人"))
  351. {
  352. item.ReviewerId = GetStaff(row["案件核稿人"].ToString().Trim());
  353. }
  354. }
  355. if (row.Table.Columns.Contains("流程负责人"))
  356. {
  357. item.WorkflowUserId = GetStaff(row["流程负责人"].ToString().Trim());
  358. }
  359. return item;
  360. }
  361. private PerformanceItem Row2Item_2(DataRow row, CalMonth calMonth)
  362. {
  363. PerformanceItem item = new PerformanceItem();
  364. item.CaseNo = row["我方文号"].ToString().Trim();
  365. item.CaseName= row["案件名称"].ToString().Trim();
  366. item.CaseType = row["案件类型"].ToString().Trim();
  367. item.BusinessType= row["业务类型"].ToString().Trim();
  368. item.Customer = new Customer();
  369. item.Customer.Name = row["客户名称"].ToString().Trim();
  370. item.CaseState = row["案件状态"].ToString().Trim();
  371. item.DoItem = row["处理事项"].ToString().Trim();
  372. DateTime temDate = new DateTime();
  373. if (DateTime.TryParse(row["内部期限"].ToString().Trim(), out temDate))
  374. {
  375. item.InternalDate = temDate;
  376. }
  377. if (DateTime.TryParse(row["客户期限"].ToString().Trim(), out temDate))
  378. {
  379. item.CustomerLimitDate = temDate;
  380. }
  381. if (DateTime.TryParse(row["初稿日"].ToString().Trim(), out temDate))
  382. {
  383. item.FirstDraftDate = temDate;
  384. }
  385. if (DateTime.TryParse(row["定稿日"].ToString().Trim(), out temDate))
  386. {
  387. item.FinalizationDate = temDate;
  388. }
  389. if (DateTime.TryParse(row["委案日期"].ToString().Trim(), out temDate))
  390. {
  391. item.EntrustingDate = temDate;
  392. }
  393. if (DateTime.TryParse(row["处理事项完成日"].ToString().Trim(), out temDate))
  394. {
  395. item.FinishedDate = temDate;
  396. }
  397. item.DoItemState = row["处理状态"].ToString().Trim();
  398. string strHandler = "";
  399. if (row.Table.Columns.Contains("处理人"))
  400. {
  401. strHandler = row["处理人"].ToString().Trim();
  402. }
  403. else
  404. {
  405. if (row.Table.Columns.Contains("案件处理人"))
  406. {
  407. strHandler = row["案件处理人"].ToString().Trim();
  408. }
  409. }
  410. string[] temHandlers = strHandler.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  411. item.ItemStaffs = new List<ItemStaff>();
  412. foreach (string name in temHandlers)
  413. {
  414. ItemStaff itemStaff = new ItemStaff();
  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 = name,
  427. Account = name,
  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. return item;
  456. }
  457. private PerformanceItem Row2Item_1(DataRow row, CalMonth calMonth)
  458. {
  459. PerformanceItem item = new PerformanceItem();
  460. item.ApplicationType = row["申请类型"].ToString().Trim();
  461. if (item.ApplicationType != "发明")
  462. {
  463. return null;
  464. }
  465. item.CaseNo = row["我方文号"].ToString().Trim();
  466. if (item.CaseNo.StartsWith("S"))
  467. {
  468. return null;
  469. }
  470. if (calMonth != null)
  471. {
  472. item.CalMonth = calMonth;
  473. }
  474. else
  475. {
  476. if (row.Table.Columns.Contains("绩效核算月份"))
  477. {
  478. string strjxyf = row["绩效核算月份"].ToString().Trim();
  479. string[] temYFs = strjxyf.Split(new char[] { '.' });
  480. item.CalMonth = new CalMonth();
  481. item.CalMonth.Year = int.Parse(temYFs[0]);
  482. item.CalMonth.Month = int.Parse(temYFs[1]);
  483. item.CalMonth.Status = 4;
  484. }
  485. else
  486. {
  487. item.CalMonth = new CalMonth();
  488. item.Status = 0;
  489. item.CalMonth.Year = DateTime.Now.AddMonths(-1).Year;
  490. item.CalMonth.Month = DateTime.Now.AddMonths(-1).Month;
  491. }
  492. }
  493. item.ApplicationType = row["申请类型"].ToString().Trim();
  494. item.BusinessType = "普通新申请"; // row["业务类型"].ToString().Trim();
  495. item.AgentFeedbackMemo = "发明一次OA授权"; //row["备注(填表注意事项)"].ToString().Trim();
  496. item.DoItem = "发明一次OA授权"; //row["处理事项"].ToString().Trim();
  497. string strHandler = "";
  498. if (row.Table.Columns.Contains("处理人"))
  499. {
  500. strHandler = row["处理人"].ToString().Trim();
  501. }
  502. else
  503. {
  504. if (row.Table.Columns.Contains("案件处理人"))
  505. {
  506. strHandler = row["案件处理人"].ToString().Trim();
  507. }
  508. }
  509. string[] temHandlers = strHandler.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  510. item.ItemStaffs = new List<ItemStaff>();
  511. foreach (string name in temHandlers)
  512. {
  513. ItemStaff itemStaff = new ItemStaff();
  514. int? iTem = GetStaff(name);
  515. if ((iTem != null))
  516. {
  517. //itemStaff.Item = item;
  518. itemStaff.DoPersonId = iTem.Value;
  519. item.ItemStaffs.Add(itemStaff);
  520. }
  521. else
  522. {
  523. itemStaff.DoPerson = new Staff()
  524. {
  525. Name = name,
  526. Account = name,
  527. Password = "12345678",
  528. IsCalPerformsnce = false,
  529. Status = "正式员工",
  530. StaffGradeId = 4
  531. };
  532. item.ItemStaffs.Add(itemStaff);
  533. }
  534. }
  535. if (item.ItemStaffs.Count == 0)
  536. {
  537. System.Diagnostics.Debug.WriteLine($"没有处理人: {item.CaseNo}\t{item.DoItem}");
  538. }
  539. if (row.Table.Columns.Contains("核稿人"))
  540. {
  541. item.ReviewerId = GetStaff(row["核稿人"].ToString().Trim());
  542. }
  543. else
  544. {
  545. if (row.Table.Columns.Contains("案件核稿人"))
  546. {
  547. item.ReviewerId = GetStaff(row["案件核稿人"].ToString().Trim());
  548. }
  549. }
  550. item.Customer = new Customer() { Name = row["客户名称"].ToString().Trim() };
  551. item.ApplicationName = row["申请人"].ToString().Trim();
  552. item.CaseName = row["案件名称"].ToString().Trim();
  553. //案件备注
  554. item.CaseMemo = $"发文日期:{row["发文日期"].ToString().Trim()}\r\n客户文号:{row["客户文号"].ToString().Trim()}\r\n上传日期:{row["上传日期"].ToString().Trim()}\r\n文件描述:{row["文件描述"].ToString().Trim()}";
  555. return item;
  556. }
  557. private PerformanceItem Row2Item(DataRow row, CalMonth calMonth)
  558. {
  559. PerformanceItem item = new PerformanceItem();
  560. item.CaseNo = row["我方文号"].ToString().Trim();
  561. if (item.CaseNo.StartsWith("S"))
  562. {
  563. return null;
  564. }
  565. if (calMonth != null)
  566. {
  567. item.CalMonth = calMonth;
  568. }
  569. else
  570. {
  571. if (row.Table.Columns.Contains("绩效核算月份"))
  572. {
  573. string strjxyf = row["绩效核算月份"].ToString().Trim();
  574. string[] temYFs = strjxyf.Split(new char[] { '.' });
  575. item.CalMonth = new CalMonth();
  576. item.CalMonth.Year = int.Parse(temYFs[0]);
  577. item.CalMonth.Month = int.Parse(temYFs[1]);
  578. item.CalMonth.Status = 4;
  579. }
  580. else
  581. {
  582. item.CalMonth = new CalMonth();
  583. item.Status = 0;
  584. item.CalMonth.Year = DateTime.Now.AddMonths(-1).Year;
  585. item.CalMonth.Month = DateTime.Now.AddMonths(-1).Month;
  586. }
  587. }
  588. item.ApplicationType = row["申请类型"].ToString().Trim();
  589. item.BusinessType = row["业务类型"].ToString().Trim();
  590. if (row.Table.Columns.Contains("备注(填表注意事项)"))
  591. item.AgentFeedbackMemo = row["备注(填表注意事项)"].ToString().Trim();
  592. item.DoItem = row["处理事项"].ToString().Trim();
  593. item.CaseStage = row["案件阶段"].ToString().Trim();
  594. item.CaseCoefficient = row["案件系数"].ToString().Trim();
  595. item.DoItemCoefficient = row["处理事项系数"].ToString().Trim();
  596. item.PreOastaffId = GetStaff(row["前一次OA处理人"].ToString().Trim());
  597. string strHandler = "";
  598. if (row.Table.Columns.Contains("处理人"))
  599. {
  600. strHandler = row["处理人"].ToString().Trim();
  601. }
  602. else
  603. {
  604. if (row.Table.Columns.Contains("案件处理人"))
  605. {
  606. strHandler = row["案件处理人"].ToString().Trim();
  607. }
  608. }
  609. string[] temHandlers = strHandler.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  610. item.ItemStaffs = new List<ItemStaff>();
  611. foreach (string name in temHandlers)
  612. {
  613. ItemStaff itemStaff = new ItemStaff();
  614. string temName = name.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  615. int? iTem = GetStaff(temName);
  616. if ((iTem != null))
  617. {
  618. //itemStaff.Item = item;
  619. itemStaff.DoPersonId = iTem.Value;
  620. item.ItemStaffs.Add(itemStaff);
  621. }
  622. else
  623. {
  624. itemStaff.DoPerson = new Staff()
  625. {
  626. Name = temName,
  627. Account = temName,
  628. Password = "12345678",
  629. IsCalPerformsnce = false,
  630. Status = "已离职",
  631. StaffGradeId = 4
  632. };
  633. item.ItemStaffs.Add(itemStaff);
  634. }
  635. }
  636. if (item.ItemStaffs.Count == 0)
  637. {
  638. System.Diagnostics.Debug.WriteLine($"没有处理人: {item.CaseNo}\t{item.DoItem}");
  639. }
  640. if (row.Table.Columns.Contains("核稿人"))
  641. {
  642. if (!string.IsNullOrEmpty(row["核稿人"].ToString().Trim()))
  643. {
  644. string temName = row["核稿人"].ToString().Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  645. item.ReviewerId = GetStaff(temName);
  646. }
  647. }
  648. else
  649. {
  650. if (row.Table.Columns.Contains("案件核稿人"))
  651. {
  652. if (!string.IsNullOrEmpty(row["案件核稿人"].ToString().Trim()))
  653. {
  654. string temName = row["案件核稿人"].ToString().Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  655. item.ReviewerId = GetStaff(temName);
  656. }
  657. }
  658. }
  659. item.Customer = new Customer() { Name = row["客户名称"].ToString().Trim() };
  660. item.ApplicationName = row["申请人"].ToString().Trim();
  661. DateTime temDate = new DateTime();
  662. if (DateTime.TryParse(row["处理事项完成日"].ToString().Trim(), out temDate))
  663. {
  664. item.FinishedDate = temDate;
  665. }
  666. //定稿日
  667. if (DateTime.TryParse(row["定稿日"].ToString().Trim(), out temDate))
  668. {
  669. item.FinalizationDate = temDate;
  670. }
  671. //返稿日
  672. if (DateTime.TryParse(row["返稿日"].ToString().Trim(), out temDate))
  673. {
  674. item.ReturnDate = temDate;
  675. }
  676. //案件类型
  677. item.CaseType = row["案件类型"].ToString().Trim();
  678. //案件状态
  679. item.CaseState = row["案件状态"].ToString().Trim();
  680. //处理事项备注
  681. item.DoItemMemo = row["处理事项备注"].ToString().Trim();
  682. //处理状态
  683. item.DoItemState = row["处理状态"].ToString().Trim();
  684. //案件名称
  685. item.CaseName = row["案件名称"].ToString().Trim();
  686. //委案日期
  687. if (DateTime.TryParse(row["委案日期"].ToString().Trim(), out temDate))
  688. {
  689. item.EntrustingDate = temDate;
  690. }
  691. //客户期限
  692. if (DateTime.TryParse(row["客户期限"].ToString().Trim(), out temDate))
  693. {
  694. item.CustomerLimitDate = temDate;
  695. }
  696. //内部期限
  697. if (DateTime.TryParse(row["内部期限"].ToString().Trim(), out temDate))
  698. {
  699. item.InternalDate = temDate;
  700. }
  701. //初稿日
  702. if (DateTime.TryParse(row["初稿日"].ToString().Trim(), out temDate))
  703. {
  704. item.FirstDraftDate = temDate;
  705. }
  706. //备注(发文严重超期是否属客观原因,若为否,请填写原因)
  707. if (row.Table.Columns.Contains("备注(发文严重超期是否属客观原因,若为否,请填写原因)"))
  708. {
  709. item.OverDueMemo = row["备注(发文严重超期是否属客观原因,若为否,请填写原因)"].ToString().Trim();
  710. }
  711. //案件备注
  712. item.CaseMemo = row["案件备注"].ToString().Trim();
  713. return item;
  714. }
  715. private int? GetStaff(string v)
  716. {
  717. var staff = spDb.Staffs.Where<Staff>(s => s.Name == v).FirstOrDefault();
  718. if(staff != null)
  719. {
  720. return staff.Id;
  721. }
  722. return null;
  723. }
  724. }
  725. }