Form1.cs 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880
  1. using DynamicExpresso;
  2. using Microsoft.International.Converters.PinYinConverter;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Configuration;
  7. using System.Data;
  8. using System.Diagnostics;
  9. using System.Drawing;
  10. using System.Dynamic;
  11. using System.Linq;
  12. using System.Net.Http;
  13. using System.Net.Http.Json;
  14. using System.Text;
  15. using System.Threading.Tasks;
  16. using System.Windows.Forms;
  17. using wispro.sp.entity;
  18. using wispro.sp.share;
  19. using wispro.sp.utility;
  20. namespace wispro.sp.winClient
  21. {
  22. public partial class Form1 : Form
  23. {
  24. public Form1()
  25. {
  26. InitializeComponent();
  27. }
  28. private void button1_Click(object sender, EventArgs e)
  29. {
  30. DateTime startTime = DateTime.Now;
  31. frmMerageExcel frm = new frmMerageExcel();
  32. if (frm.ShowDialog() == DialogResult.OK)
  33. {
  34. MessageBox.Show($"合并完成,合并后文件保存在:\r\n{frm.SaveFilePath}\r\n用时:{DateTime.Now - startTime }");
  35. }
  36. }
  37. private void button2_Click(object sender, EventArgs e)
  38. {
  39. OpenFileDialog ofd = new OpenFileDialog()
  40. {
  41. Multiselect = false,
  42. Filter = "*.xls|*.xlsx"
  43. };
  44. string strDinashuRegularFile = ConfigurationSettings.AppSettings["DinashuRegularFile"];
  45. if (ofd.ShowDialog() == DialogResult.OK)
  46. {
  47. new ExcelHelper().FillDianShu(ofd.FileName, strDinashuRegularFile);
  48. }
  49. MessageBox.Show("完成点数输入!");
  50. }
  51. private string[] InValidDoItem = new string[]
  52. {
  53. "案件异常-催缴年费",
  54. "案件异常-视为放弃取得专利权",
  55. "办理登记手续",
  56. "办理登记手续-确认客户是否委托",
  57. "代理所变更",
  58. "绘图",
  59. "技术确认",
  60. "缴年费",
  61. "请求保密审查",
  62. "请求费减",
  63. "请求实审",
  64. "取得申请号",
  65. "取得证书",
  66. "取得专利权评价报告",
  67. "确认官方审查状况",
  68. "询问放弃或复审",
  69. "知识点总结",
  70. "专利权人发明人申请人信息变更",
  71. "专利挖掘与布局",
  72. "我方文号前缀带J",
  73. "开卷",
  74. "请求提前公开",
  75. "取得国际检索报告",
  76. "委外检索",
  77. "中止程序",
  78. "终止",
  79. "案件异常-视为撤回",
  80. "进入国家阶段提醒",
  81. "请求恢复权利",
  82. "请求优先权",
  83. "取得【无效宣告请求审查决定】",
  84. "撤回",
  85. "请求退款",
  86. "确认是否委托申请与类型",
  87. "专利交易",
  88. "专利权评价报告",
  89. "专利权人发明人申请人信息变更+代理所变更"
  90. };
  91. private async Task InitRules(bool isSave)
  92. {
  93. List<BasePointRule> rules = new List<BasePointRule>();
  94. DataTable dt = wispro.sp.utility.NPOIExcel.ExcelToDataTable("ExcelFiles\\20211109-绩效点数规则-lcy-v1.xlsx", true);
  95. PerformanceItem item = new PerformanceItem() { CaseNo = "PAEPO2016277", DoItem= "提交检索主题声明", };
  96. foreach(DataRow row in dt.Rows)
  97. {
  98. BasePointRule rule = new BasePointRule()
  99. {
  100. Rule = row["规则"].ToString(),
  101. PointExpress = row["点数计算"].ToString(),
  102. Priority = int.Parse(row["优先级修订"].ToString()),
  103. Type = row["类型"].ToString()
  104. };
  105. try
  106. {
  107. var interpreter = new Interpreter();
  108. //item.ApplicationType
  109. Func<PerformanceItem, bool> func = interpreter.ParseAsDelegate<Func<PerformanceItem, bool>>(rule.Rule, "p");
  110. bool result = func.Invoke(item);
  111. if (result)
  112. {
  113. item.BasePoint = (double?)interpreter.Eval(rule.PointExpress);
  114. item.Type = rule.Type;
  115. System.Diagnostics.Debug.WriteLine("");
  116. }
  117. rules.Add(rule);
  118. }
  119. catch(Exception ex)
  120. {
  121. System.Diagnostics.Debug.WriteLine(rule.Rule + "\r\n" + ex.ToString());
  122. }
  123. }
  124. if (isSave)
  125. {
  126. foreach (BasePointRule rule in rules)
  127. {
  128. double d;
  129. if(double.TryParse(rule.PointExpress,out d))
  130. {
  131. rule.PointExpress = d.ToString("0.00");
  132. }
  133. await SaveBasePointRule(rule);
  134. }
  135. }
  136. }
  137. public async Task TestQueryFilter()
  138. {
  139. //QueryFilter filter = new QueryFilter();
  140. //filter.ConditionTree = new ExpressTree();
  141. //string ValueType = typeof(PerformanceItem).GetProperty("CaseNo").PropertyType.ToString();
  142. //FieldCondition condition1 = new FieldCondition() { FieldName = "CaseNo", Operator = OperatorEnum.Contains, Value = "PACN", ValueType = ValueType };
  143. //FieldCondition condition2 = new FieldCondition() { FieldName = "CaseNo", Operator = OperatorEnum.Contains, Value = "PAUS", ValueType = ValueType };
  144. //filter.ConditionTree.AddCondition(LogicEnum.And,condition1);
  145. //filter.ConditionTree.AddCondition(LogicEnum.Or, condition2);
  146. //System.Diagnostics.Debug.WriteLine(filter.ConditionTree.ToExpressString("s")); ;
  147. }
  148. enum enumTest
  149. {
  150. [Description("男")]
  151. man,
  152. [Description("女")]
  153. woman
  154. }
  155. private async void button3_Click(object sender, EventArgs e)
  156. {
  157. share.Utility.UserConditionHelper.GetPropertyDescription<Staff>(typeof(PerformanceItem).AssemblyQualifiedName);
  158. #region Demo流程数据
  159. //entity.workflowDefine.Workflow workflow = new entity.workflowDefine.Workflow();
  160. //workflow.Name = "专案绩效流程";
  161. //workflow.Id = 1;
  162. //workflow.EndStepId = -1;
  163. //workflow.InitAction = new entity.workflowDefine.Action();
  164. //workflow.InitAction.Name = "填写请教条";
  165. //List<entity.workflowDefine.Step> Steps = new List<entity.workflowDefine.Step>();
  166. //var step1 = new entity.workflowDefine.Step();
  167. //step1.Name = "部门主管申核";
  168. //step1.Id = 1;
  169. //Steps.Add(step1);
  170. //var step2 = new entity.workflowDefine.Step();
  171. //step2.Name = "老板申核";
  172. //step2.Id = 2;
  173. //Steps.Add(step2);
  174. //var step3 = new entity.workflowDefine.Step();
  175. //step3.Name = "申核结果通知";
  176. //step3.Id = 3;
  177. //Steps.Add(step3);
  178. //var step4 = new entity.workflowDefine.Step();
  179. //step4.Name = "新步骤";
  180. //step4.Id = 4;
  181. //Steps.Add(step4);
  182. //var step5 = new entity.workflowDefine.Step();
  183. //step5.Name = "新步骤";
  184. //step5.Id = 5;
  185. //Steps.Add(step5);
  186. //workflow.EndStepId = 3;
  187. //List<entity.workflowDefine.TrasferCondition> Transfers = new List<entity.workflowDefine.TrasferCondition>();
  188. //var t = new entity.workflowDefine.TrasferCondition();
  189. //t.StepId = null;
  190. //t.nextStepId = 1;
  191. //Transfers.Add(t);
  192. //var t1 = new entity.workflowDefine.TrasferCondition();
  193. //t1.StepId = 1;
  194. //t1.nextStepId = 2;
  195. //Transfers.Add(t1);
  196. //var t2 = new entity.workflowDefine.TrasferCondition();
  197. //t2.StepId = 1;
  198. //t2.nextStepId = 3;
  199. //Transfers.Add(t2);
  200. //var t3 = new entity.workflowDefine.TrasferCondition();
  201. //t3.StepId = 2;
  202. //t3.nextStepId = 3;
  203. //Transfers.Add(t3);
  204. #endregion
  205. //FlowChart flowChart = new FlowChart();
  206. //flowChart.workflow = workflow;
  207. //flowChart.Steps = Steps;
  208. //flowChart.Transfers = Transfers;
  209. //var newStep = new entity.workflowDefine.Step();
  210. //newStep.Name = "新步骤";
  211. //newStep.workflowId = workflow.Id;
  212. //Steps.Add(newStep);
  213. //flowChart.Refresh();
  214. //flowChart.Refresh();
  215. //var test =wispro.sp.utility.EmunHelper.getEnumDescriptionDic<wispro.sp.entity.workflowDefine.LogicSymbols>();
  216. //Console.WriteLine("");
  217. //dynamic dynObj = new ExpandoObject();
  218. //dynObj.Name = "名称";
  219. //dynObj.Text = "aaabc";
  220. //List<dynamic> list = new List<dynamic>();
  221. //for(int i = 0; i < 3; i++)
  222. //{
  223. // dynamic d = new ExpandoObject();
  224. // d.Id = i + 1;
  225. // d.Filed1 = $"Field{i}";
  226. // d.Date = DateTime.Now.AddDays(i);
  227. // list.Add(d);
  228. //}
  229. //dynObj.List = list;
  230. //var temTxt = System.Text.Json.JsonSerializer.Serialize(dynObj);
  231. //var dynamic = System.Text.Json.JsonSerializer.Deserialize<ExpandoObject>(temTxt);
  232. //MessageBox.Show(((IDictionary<string, object>)dynamic)["Name"].ToString());
  233. //wispro.sp.utility.MailUtil.SendEmail("测试邮件标题","测试邮件内容","罗才洋","luocaiyang@139.com");
  234. //CreateAppealModel model = new CreateAppealModel();
  235. //HttpClient http = new HttpClient();
  236. //PerformanceItem item = await http.GetFromJsonAsync<wispro.sp.entity.PerformanceItem>($"http://localhost:39476/api/PerformanceItem/Get?Id=7341");
  237. //List<AppealType> appealTypes = await http.GetFromJsonAsync<List<AppealType>>($"http://localhost:39476/api/Appeal/GetAppealTypes");
  238. //var appealType = appealTypes.Where<AppealType>(a => a.Id == 1).FirstOrDefault();
  239. //await model.Init(item, appealType);
  240. ////await TestQueryFilter();
  241. //List<PerformanceItem> retList = new List<PerformanceItem>();
  242. //var test= retList.Where<PerformanceItem>(p => p.isDanger());
  243. //await InitRules(true);
  244. ////return;
  245. //await ImportUsers();
  246. //await InputPerformanceItem("ExcelFiles\\21.01-21.06 工程师绩效报表-总表.xlsx", true, false, 0);
  247. ////CalMonth cal = new CalMonth()
  248. ////{
  249. //// Year = 2021,
  250. //// Month = 9,
  251. //// Status = 0
  252. ////};
  253. ////await InputPerformanceItem(@"C:\Users\luowen\Downloads\每月绩效统计--发客户超过一个月未完成案件.xlsx", true,false,1, cal);
  254. ////await InputPerformanceItem(@"C:\Users\luowen\Downloads\每月绩效统计--上个月递交完成案件.xlsx", true, false, 1, cal);
  255. ////await InputPerformanceItem(@"C:\Users\luowen\Downloads\每月绩效统计--中国一次OA授权表.xlsx", true, false, 1, cal,true);
  256. //MessageBox.Show("导入完成!");
  257. }
  258. private PerformanceItem Row2Item_1(DataRow row, List<Staff> Staffs, CalMonth calMonth)
  259. {
  260. PerformanceItem item = new PerformanceItem();
  261. item.ApplicationType = row["申请类型"].ToString().Trim();
  262. if(item.ApplicationType != "发明")
  263. {
  264. return null;
  265. }
  266. item.CaseNo = row["我方文号"].ToString().Trim();
  267. if (calMonth != null)
  268. {
  269. item.CalMonth = calMonth;
  270. }
  271. else
  272. {
  273. if (row.Table.Columns.Contains("绩效核算月份"))
  274. {
  275. string strjxyf = row["绩效核算月份"].ToString().Trim();
  276. string[] temYFs = strjxyf.Split(new char[] { '.' });
  277. item.CalMonth = new CalMonth();
  278. item.CalMonth.Year = int.Parse(temYFs[0]);
  279. item.CalMonth.Month = int.Parse(temYFs[1]);
  280. item.CalMonth.Status = 4;
  281. }
  282. else
  283. {
  284. item.CalMonth = new CalMonth();
  285. item.Status = 0;
  286. item.CalMonth.Year = DateTime.Now.AddMonths(-1).Year;
  287. item.CalMonth.Month = DateTime.Now.AddMonths(-1).Month;
  288. }
  289. }
  290. item.ApplicationType = row["申请类型"].ToString().Trim();
  291. item.BusinessType = "普通新申请"; // row["业务类型"].ToString().Trim();
  292. item.AgentFeedbackMemo = "发明一次OA授权"; //row["备注(填表注意事项)"].ToString().Trim();
  293. item.DoItem = "发明一次OA授权"; //row["处理事项"].ToString().Trim();
  294. string strHandler = "";
  295. if (row.Table.Columns.Contains("处理人"))
  296. {
  297. strHandler = row["处理人"].ToString().Trim();
  298. }
  299. else
  300. {
  301. if (row.Table.Columns.Contains("案件处理人"))
  302. {
  303. strHandler = row["案件处理人"].ToString().Trim();
  304. }
  305. }
  306. string[] temHandlers = strHandler.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  307. item.ItemStaffs = new List<ItemStaff>();
  308. foreach (string name in temHandlers)
  309. {
  310. ItemStaff itemStaff = new ItemStaff();
  311. int? iTem = GetStaff(name, Staffs);
  312. if ((iTem != null))
  313. {
  314. //itemStaff.Item = item;
  315. itemStaff.DoPersonId = iTem.Value;
  316. item.ItemStaffs.Add(itemStaff);
  317. }
  318. else
  319. {
  320. itemStaff.DoPerson = new Staff()
  321. {
  322. Name = name,
  323. Account = name,
  324. Password = "12345678",
  325. IsCalPerformsnce = false,
  326. Status = "正式员工",
  327. StaffGradeId = 4
  328. };
  329. item.ItemStaffs.Add(itemStaff);
  330. }
  331. }
  332. if (item.ItemStaffs.Count == 0)
  333. {
  334. System.Diagnostics.Debug.WriteLine($"没有处理人: {item.CaseNo}\t{item.DoItem}");
  335. }
  336. if (row.Table.Columns.Contains("核稿人"))
  337. {
  338. item.ReviewerId = GetStaff(row["核稿人"].ToString().Trim(), Staffs);
  339. }
  340. else
  341. {
  342. if (row.Table.Columns.Contains("案件核稿人"))
  343. {
  344. item.ReviewerId = GetStaff(row["案件核稿人"].ToString().Trim(), Staffs);
  345. }
  346. }
  347. item.Customer = new Customer() { Name = row["客户名称"].ToString().Trim() };
  348. item.ApplicationName = row["申请人"].ToString().Trim();
  349. item.CaseName = row["案件名称"].ToString().Trim();
  350. //案件备注
  351. item.CaseMemo = $"发文日期:{row["发文日期"].ToString().Trim()}\r\n客户文号:{row["客户文号"].ToString().Trim()}\r\n上传日期:{row["上传日期"].ToString().Trim()}\r\n文件描述:{row["文件描述"].ToString().Trim()}";
  352. return item;
  353. }
  354. private PerformanceItem Row2Item(DataRow row, List<Staff> Staffs,CalMonth calMonth)
  355. {
  356. PerformanceItem item = new PerformanceItem();
  357. item.CaseNo = row["我方文号"].ToString().Trim();
  358. if (calMonth != null)
  359. {
  360. item.CalMonth = calMonth;
  361. }
  362. else
  363. {
  364. if (row.Table.Columns.Contains("绩效核算月份"))
  365. {
  366. string strjxyf = row["绩效核算月份"].ToString().Trim();
  367. string[] temYFs = strjxyf.Split(new char[] { '.' });
  368. item.CalMonth = new CalMonth();
  369. item.CalMonth.Year = int.Parse(temYFs[0]);
  370. item.CalMonth.Month = int.Parse(temYFs[1]);
  371. item.CalMonth.Status = 4;
  372. }
  373. else
  374. {
  375. item.CalMonth = new CalMonth();
  376. item.Status = 0;
  377. item.CalMonth.Year = DateTime.Now.AddMonths(-1).Year;
  378. item.CalMonth.Month = DateTime.Now.AddMonths(-1).Month;
  379. }
  380. }
  381. item.ApplicationType = row["申请类型"].ToString().Trim();
  382. item.BusinessType = row["业务类型"].ToString().Trim();
  383. if (row.Table.Columns.Contains("备注(填表注意事项)"))
  384. item.AgentFeedbackMemo = row["备注(填表注意事项)"].ToString().Trim();
  385. item.DoItem = row["处理事项"].ToString().Trim();
  386. item.CaseStage = row["案件阶段"].ToString().Trim();
  387. item.CaseCoefficient = row["案件系数"].ToString().Trim();
  388. item.DoItemCoefficient = row["处理事项系数"].ToString().Trim();
  389. item.PreOastaffId = GetStaff(row["前一次OA处理人"].ToString().Trim(), Staffs);
  390. string strHandler = "";
  391. if (row.Table.Columns.Contains("处理人"))
  392. {
  393. strHandler = row["处理人"].ToString().Trim();
  394. }
  395. else
  396. {
  397. if (row.Table.Columns.Contains("案件处理人"))
  398. {
  399. strHandler = row["案件处理人"].ToString().Trim();
  400. }
  401. }
  402. string[] temHandlers = strHandler.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  403. item.ItemStaffs = new List<ItemStaff>();
  404. foreach (string name in temHandlers)
  405. {
  406. ItemStaff itemStaff = new ItemStaff();
  407. string temName = name.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  408. int? iTem = GetStaff(temName, Staffs);
  409. if ((iTem != null))
  410. {
  411. //itemStaff.Item = item;
  412. itemStaff.DoPersonId = iTem.Value;
  413. item.ItemStaffs.Add(itemStaff);
  414. }
  415. else
  416. {
  417. itemStaff.DoPerson = new Staff()
  418. {
  419. Name = temName,
  420. Account = temName,
  421. Password = "12345678",
  422. IsCalPerformsnce = false,
  423. Status = "已离职",
  424. StaffGradeId = 4
  425. };
  426. item.ItemStaffs.Add(itemStaff);
  427. }
  428. }
  429. if (item.ItemStaffs.Count == 0)
  430. {
  431. System.Diagnostics.Debug.WriteLine($"没有处理人: {item.CaseNo}\t{item.DoItem}");
  432. }
  433. if (row.Table.Columns.Contains("核稿人"))
  434. {
  435. if (!string.IsNullOrEmpty(row["核稿人"].ToString().Trim()))
  436. {
  437. string temName = row["核稿人"].ToString().Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  438. item.ReviewerId = GetStaff(temName.Trim(), Staffs);
  439. }
  440. }
  441. else
  442. {
  443. if (row.Table.Columns.Contains("案件核稿人"))
  444. {
  445. if (!string.IsNullOrEmpty(row["案件核稿人"].ToString().Trim()))
  446. {
  447. string temName = row["案件核稿人"].ToString().Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  448. item.ReviewerId = GetStaff(temName.Trim(), Staffs);
  449. }
  450. }
  451. }
  452. item.Customer = new Customer() { Name = row["客户名称"].ToString().Trim() };
  453. item.ApplicationName = row["申请人"].ToString().Trim();
  454. DateTime temDate = new DateTime();
  455. if (DateTime.TryParse(row["处理事项完成日"].ToString().Trim(), out temDate))
  456. {
  457. item.FinishedDate = temDate;
  458. }
  459. //定稿日
  460. if (DateTime.TryParse(row["定稿日"].ToString().Trim(), out temDate))
  461. {
  462. item.FinalizationDate = temDate;
  463. }
  464. //返稿日
  465. if (DateTime.TryParse(row["返稿日"].ToString().Trim(), out temDate))
  466. {
  467. item.ReturnDate = temDate;
  468. }
  469. //案件类型
  470. item.CaseType = row["案件类型"].ToString().Trim();
  471. //案件状态
  472. item.CaseState = row["案件状态"].ToString().Trim();
  473. //处理事项备注
  474. item.DoItemMemo = row["处理事项备注"].ToString().Trim();
  475. //处理状态
  476. item.DoItemState = row["处理状态"].ToString().Trim();
  477. //案件名称
  478. item.CaseName = row["案件名称"].ToString().Trim();
  479. //委案日期
  480. if (DateTime.TryParse(row["委案日期"].ToString().Trim(), out temDate))
  481. {
  482. item.EntrustingDate = temDate;
  483. }
  484. //客户期限
  485. if (DateTime.TryParse(row["客户期限"].ToString().Trim(), out temDate))
  486. {
  487. item.CustomerLimitDate = temDate;
  488. }
  489. //内部期限
  490. if (DateTime.TryParse(row["内部期限"].ToString().Trim(), out temDate))
  491. {
  492. item.InternalDate = temDate;
  493. }
  494. //初稿日
  495. if (DateTime.TryParse(row["初稿日"].ToString().Trim(), out temDate))
  496. {
  497. item.FirstDraftDate = temDate;
  498. }
  499. //备注(发文严重超期是否属客观原因,若为否,请填写原因)
  500. if (row.Table.Columns.Contains("备注(发文严重超期是否属客观原因,若为否,请填写原因)"))
  501. {
  502. item.OverDueMemo = row["备注(发文严重超期是否属客观原因,若为否,请填写原因)"].ToString().Trim();
  503. }
  504. //案件备注
  505. item.CaseMemo = row["案件备注"].ToString().Trim();
  506. return item;
  507. }
  508. private async Task InputPerformanceItem(string strExcelFile,bool isColumnName,bool ignorHideRows=false,int ColumnNameRow=0,CalMonth calMonth=null,bool isFirstOAFile=false)
  509. {
  510. DataTable dt = NPOIExcel.ExcelToDataTable(strExcelFile, isColumnName,ignorHideRows,ColumnNameRow);
  511. #region 删除重复行
  512. DataTable temdt = new DataTable();
  513. foreach (DataColumn col in dt.Columns)
  514. {
  515. DataColumn temCol = new DataColumn();
  516. temCol.ColumnName = col.ColumnName;
  517. temCol.DataType = col.DataType;
  518. temCol.Caption = col.Caption;
  519. temdt.Columns.Add(temCol);
  520. }
  521. new ExcelHelper().MerageDataTable(temdt, dt);
  522. #endregion
  523. List<Staff> Staffs =await GetStaffsAsync();
  524. foreach(DataRow row in temdt.Rows)
  525. {
  526. PerformanceItem item = null;
  527. if (isFirstOAFile)
  528. {
  529. item = Row2Item_1(row, Staffs, calMonth);
  530. }
  531. else
  532. {
  533. item = Row2Item(row, Staffs, calMonth);
  534. }
  535. if (item != null )
  536. {
  537. if (!InValidDoItem.Contains(item.DoItem))
  538. {
  539. await SavePerformanceItem(item);
  540. }
  541. }
  542. }
  543. }
  544. private int? GetStaff(string v, List<Staff> staffs)
  545. {
  546. if (!string.IsNullOrEmpty(v))
  547. {
  548. string[] temNames = v.Trim().Split(new char[] { '-' },StringSplitOptions.RemoveEmptyEntries);
  549. foreach (Staff sf in staffs)
  550. {
  551. if(sf.Name == temNames[0])
  552. {
  553. return sf.Id;
  554. }
  555. }
  556. }
  557. return null;
  558. }
  559. private async Task ImportUsers()
  560. {
  561. DataTable dt = NPOIExcel.ExcelToDataTable(@"C:\temp\用户列表(2021年10月26日).xlsx", true,false,1);
  562. List<StaffGrade> staffGrades = await GetStaffGrades();
  563. foreach (DataRow row in dt.Rows)
  564. {
  565. Staff staff = new Staff();
  566. staff.Account = row["用户名"].ToString().Trim();
  567. staff.Name = row["姓名"].ToString().Trim();
  568. staff.Tel = row["电话号码"].ToString().Trim();
  569. staff.Mobile = row["手机号码"].ToString().Trim();
  570. staff.Sex = row["性别"].ToString().Trim();
  571. staff.Mail = row["邮箱"].ToString().Trim();
  572. string strGrade = row["工程师等级"].ToString().Trim(); // + "级";
  573. foreach (StaffGrade sg in staffGrades)
  574. {
  575. if (strGrade.Trim() == sg.Grade.Trim())
  576. {
  577. staff.StaffGradeId = sg.Id;
  578. break;
  579. }
  580. }
  581. staff.IsOnJob = (row["是否在职"].ToString().Trim()=="是");
  582. staff.Status = row["岗位状态"].ToString().Trim();
  583. staff.Department = row["部门"].ToString();
  584. staff.WorkPlace = row["工作地"].ToString();
  585. DateTime temDate;
  586. if (DateTime.TryParse(row["入职时间"].ToString(), out temDate))
  587. {
  588. staff.EntyDate = temDate;
  589. }
  590. //staff.IsCalPerformsnce = (row["是否核算绩效"].ToString() == "是");
  591. //staff.Memo = row["备注"].ToString().Trim();
  592. staff.Password = MD5Utility.GetMD5("12345678");
  593. //staff.StaffGradeId = row["姓名"].ToString();
  594. await SaveStaff(staff);
  595. }
  596. }
  597. private string getPinYin(string str)
  598. {
  599. string retStr = "";
  600. for(int i = 0; i < str.Length; i++)
  601. {
  602. ChineseChar cc = new ChineseChar(str[i]);
  603. retStr = retStr + cc.Pinyins[0].ToLower().Replace("1","")
  604. .Replace("2", "").Replace("3", "").Replace("4", "");
  605. }
  606. return retStr;
  607. }
  608. private async Task SaveStaff(Staff obj)
  609. {
  610. HttpClient http = new HttpClient();
  611. var data = await http.PostAsJsonAsync<wispro.sp.entity.Staff>($"http://localhost:39476/api/Staff/Save", obj);
  612. if (data.IsSuccessStatusCode)
  613. {
  614. ApiSaveResponse result = await data.Content.ReadFromJsonAsync<ApiSaveResponse>();
  615. //await Task.Delay(1000);
  616. if (result.Success)
  617. {
  618. }
  619. else
  620. {
  621. }
  622. }
  623. else
  624. {
  625. }
  626. }
  627. private async Task SaveBasePointRule(BasePointRule obj)
  628. {
  629. HttpClient http = new HttpClient();
  630. var data = await http.PostAsJsonAsync<BasePointRule>($"http://localhost:39476/api/BasePointRule/New", obj);
  631. if (data.IsSuccessStatusCode)
  632. {
  633. ApiSaveResponse result = await data.Content.ReadFromJsonAsync<ApiSaveResponse>();
  634. //await Task.Delay(1000);
  635. if (result.Success)
  636. {
  637. }
  638. else
  639. {
  640. System.Diagnostics.Debug.WriteLine($"保存错误: {obj.Rule}\t{obj.PointExpress}\r\n{result.ErrorMessage}");
  641. }
  642. }
  643. else
  644. {
  645. System.Diagnostics.Debug.WriteLine($"调用API错误: {obj.Type}\t{obj.Rule}");
  646. }
  647. }
  648. private async Task SavePerformanceItem(PerformanceItem obj)
  649. {
  650. HttpClient http = new HttpClient();
  651. var data = await http.PostAsJsonAsync<PerformanceItem>($"http://localhost:39476/api/PerformanceItem/New", obj);
  652. if (data.IsSuccessStatusCode)
  653. {
  654. ApiSaveResponse result = await data.Content.ReadFromJsonAsync<ApiSaveResponse>();
  655. //await Task.Delay(1000);
  656. if (result.Success)
  657. {
  658. }
  659. else
  660. {
  661. System.Diagnostics.Debug.WriteLine($"保存错误: {obj.CaseNo}\t{obj.DoItem}\r\n{result.ErrorMessage}");
  662. }
  663. }
  664. else
  665. {
  666. System.Diagnostics.Debug.WriteLine($"调用API错误: {obj.CaseNo}\t{obj.DoItem}");
  667. }
  668. }
  669. private async Task<List<StaffGrade>> GetStaffGrades()
  670. {
  671. HttpClient http = new HttpClient();
  672. var _StaffGrade = await http.GetFromJsonAsync<List<StaffGrade>>($"http://localhost:39476/api/StaffGrade/GetAll");
  673. return _StaffGrade;
  674. }
  675. private async Task<List<Staff>> GetStaffsAsync()
  676. {
  677. HttpClient http = new HttpClient();
  678. ListApiResponse<Staff> data = await http.GetFromJsonAsync<ListApiResponse<Staff>>($"http://localhost:39476/api/Staff/Query?pageIndex=1&pageSize=200");
  679. return data.Results;
  680. }
  681. private void button4_Click(object sender, EventArgs e)
  682. {
  683. Stopwatch watch = new Stopwatch();
  684. watch.Start();
  685. dynamic retObj = wispro.sp.utility.IPEasyUtility.GetPerformanceRecord("S2112392-洗碗机调查分析","提出报告");
  686. PerformanceItem Item = new PerformanceItem();
  687. Item.CaseName = retObj.CaseName;
  688. Item.CaseNo = retObj.CaseNo;
  689. Item.DoItem = retObj.DoItem;
  690. Item.CustomerLimitDate = string.IsNullOrEmpty(retObj.CustomerLimitDate) ? null : DateTime.Parse(retObj.CustomerLimitDate);
  691. Item.Customer = new Customer();
  692. Item.Customer.Name = retObj.CustomerName;
  693. Item.DoItemCoefficient = retObj.DoItemCoefficient;
  694. Item.DoItemMemo = retObj.DoItemMemo;
  695. Item.DoItemState = retObj.DoItemState;
  696. Item.EntrustingDate = string.IsNullOrEmpty(retObj.EntrustingDate) ? null : DateTime.Parse(retObj.EntrustingDate);
  697. Item.FinalizationDate = string.IsNullOrEmpty(retObj.FinalizationDate) ? null : DateTime.Parse(retObj.FinalizationDate);
  698. Item.FinishedDate = string.IsNullOrEmpty(retObj.FinishedDate) ? null : DateTime.Parse(retObj.FinishedDate);
  699. //Item.FirstDraftDate = string.IsNullOrEmpty(retObj.FirstDraftDate) ? null : DateTime.Parse(retObj.FirstDraftDate);
  700. Item.InternalDate = string.IsNullOrEmpty(retObj.InternalDate) ? null : DateTime.Parse(retObj.InternalDate);
  701. if (!string.IsNullOrEmpty(retObj.DoPersons))
  702. {
  703. Item.ItemStaffs = new List<ItemStaff>();
  704. string[] names = retObj.DoPersons.ToString().Split(new char[] { ','},StringSplitOptions.RemoveEmptyEntries);
  705. foreach(var name in names)
  706. {
  707. ItemStaff iStaff = new ItemStaff();
  708. iStaff.DoPerson = new Staff() { Name = name };
  709. Item.ItemStaffs.Add(iStaff);
  710. }
  711. }
  712. Item.ReturnDate = string.IsNullOrEmpty(retObj.ReturnDate) ? null : DateTime.Parse(retObj.ReturnDate);
  713. if (!string.IsNullOrEmpty(retObj.Reviewer))
  714. {
  715. Item.Reviewer = new Staff() { Name = retObj.Reviewer };
  716. }
  717. Item.ApplicationType = retObj.ApplicationType;
  718. Item.BusinessType = retObj.BusinessType;
  719. Item.CaseCoefficient = retObj.CaseCoefficient;
  720. Item.CaseMemo = retObj.CaseMemo;
  721. Item.CaseStage = retObj.CaseStage;
  722. Item.CaseState = retObj.CaseState;
  723. Item.CaseType = retObj.CaseType;
  724. watch.Stop();
  725. System.Diagnostics.Debug.WriteLine("用时{0}毫秒", watch.ElapsedMilliseconds);//获取当前实例测量得出的总运行时间(以毫秒为单位)
  726. //wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--上个月递交完成案件", true);
  727. //wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--发客户超过一个月未完成案件", false);
  728. //wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--中国一次OA授权表", true);
  729. ////每月绩效统计--发客户超过一个月未完成案件
  730. //NewMethod("506aa7ad-c3f4-4ec6-9ec8-ff6b92dcd7c1", "每月绩效统计--发客户超过一个月未完成案件.xlsx", calMonth);
  731. ////每月绩效统计--上个月递交完成案件
  732. //NewMethod("d7308cd2-71e4-4444-9f47-f4d731ddb26a", "每月绩效统计--上个月递交完成案件.xlsx", calMonth);
  733. ////每月绩效统计--中国一次OA授权表
  734. //NewMethod("72454834-afdd-4b98-b42a-0bc912d07610", "每月绩效统计--中国一次OA授权表.xlsx", calMonth, true);
  735. }
  736. }
  737. }