Form1.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807
  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. FlowChart flowChart = new FlowChart();
  158. flowChart.OnInitialized();
  159. flowChart.GetLineParater(new entity.workflowDefine.TrasferCondition() { nextStepId = 1 });
  160. //var test =wispro.sp.utility.EmunHelper.getEnumDescriptionDic<wispro.sp.entity.workflowDefine.LogicSymbols>();
  161. //Console.WriteLine("");
  162. //dynamic dynObj = new ExpandoObject();
  163. //dynObj.Name = "名称";
  164. //dynObj.Text = "aaabc";
  165. //List<dynamic> list = new List<dynamic>();
  166. //for(int i = 0; i < 3; i++)
  167. //{
  168. // dynamic d = new ExpandoObject();
  169. // d.Id = i + 1;
  170. // d.Filed1 = $"Field{i}";
  171. // d.Date = DateTime.Now.AddDays(i);
  172. // list.Add(d);
  173. //}
  174. //dynObj.List = list;
  175. //var temTxt = System.Text.Json.JsonSerializer.Serialize(dynObj);
  176. //var dynamic = System.Text.Json.JsonSerializer.Deserialize<ExpandoObject>(temTxt);
  177. //MessageBox.Show(((IDictionary<string, object>)dynamic)["Name"].ToString());
  178. //wispro.sp.utility.MailUtil.SendEmail("测试邮件标题","测试邮件内容","罗才洋","luocaiyang@139.com");
  179. //CreateAppealModel model = new CreateAppealModel();
  180. //HttpClient http = new HttpClient();
  181. //PerformanceItem item = await http.GetFromJsonAsync<wispro.sp.entity.PerformanceItem>($"http://localhost:39476/api/PerformanceItem/Get?Id=7341");
  182. //List<AppealType> appealTypes = await http.GetFromJsonAsync<List<AppealType>>($"http://localhost:39476/api/Appeal/GetAppealTypes");
  183. //var appealType = appealTypes.Where<AppealType>(a => a.Id == 1).FirstOrDefault();
  184. //await model.Init(item, appealType);
  185. ////await TestQueryFilter();
  186. //List<PerformanceItem> retList = new List<PerformanceItem>();
  187. //var test= retList.Where<PerformanceItem>(p => p.isDanger());
  188. //await InitRules(true);
  189. ////return;
  190. //await ImportUsers();
  191. //await InputPerformanceItem("ExcelFiles\\21.01-21.06 工程师绩效报表-总表.xlsx", true, false, 0);
  192. ////CalMonth cal = new CalMonth()
  193. ////{
  194. //// Year = 2021,
  195. //// Month = 9,
  196. //// Status = 0
  197. ////};
  198. ////await InputPerformanceItem(@"C:\Users\luowen\Downloads\每月绩效统计--发客户超过一个月未完成案件.xlsx", true,false,1, cal);
  199. ////await InputPerformanceItem(@"C:\Users\luowen\Downloads\每月绩效统计--上个月递交完成案件.xlsx", true, false, 1, cal);
  200. ////await InputPerformanceItem(@"C:\Users\luowen\Downloads\每月绩效统计--中国一次OA授权表.xlsx", true, false, 1, cal,true);
  201. //MessageBox.Show("导入完成!");
  202. }
  203. private PerformanceItem Row2Item_1(DataRow row, List<Staff> Staffs, CalMonth calMonth)
  204. {
  205. PerformanceItem item = new PerformanceItem();
  206. item.ApplicationType = row["申请类型"].ToString().Trim();
  207. if(item.ApplicationType != "发明")
  208. {
  209. return null;
  210. }
  211. item.CaseNo = row["我方文号"].ToString().Trim();
  212. if (calMonth != null)
  213. {
  214. item.CalMonth = calMonth;
  215. }
  216. else
  217. {
  218. if (row.Table.Columns.Contains("绩效核算月份"))
  219. {
  220. string strjxyf = row["绩效核算月份"].ToString().Trim();
  221. string[] temYFs = strjxyf.Split(new char[] { '.' });
  222. item.CalMonth = new CalMonth();
  223. item.CalMonth.Year = int.Parse(temYFs[0]);
  224. item.CalMonth.Month = int.Parse(temYFs[1]);
  225. item.CalMonth.Status = 4;
  226. }
  227. else
  228. {
  229. item.CalMonth = new CalMonth();
  230. item.Status = 0;
  231. item.CalMonth.Year = DateTime.Now.AddMonths(-1).Year;
  232. item.CalMonth.Month = DateTime.Now.AddMonths(-1).Month;
  233. }
  234. }
  235. item.ApplicationType = row["申请类型"].ToString().Trim();
  236. item.BusinessType = "普通新申请"; // row["业务类型"].ToString().Trim();
  237. item.AgentFeedbackMemo = "发明一次OA授权"; //row["备注(填表注意事项)"].ToString().Trim();
  238. item.DoItem = "发明一次OA授权"; //row["处理事项"].ToString().Trim();
  239. string strHandler = "";
  240. if (row.Table.Columns.Contains("处理人"))
  241. {
  242. strHandler = row["处理人"].ToString().Trim();
  243. }
  244. else
  245. {
  246. if (row.Table.Columns.Contains("案件处理人"))
  247. {
  248. strHandler = row["案件处理人"].ToString().Trim();
  249. }
  250. }
  251. string[] temHandlers = strHandler.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  252. item.ItemStaffs = new List<ItemStaff>();
  253. foreach (string name in temHandlers)
  254. {
  255. ItemStaff itemStaff = new ItemStaff();
  256. int? iTem = GetStaff(name, Staffs);
  257. if ((iTem != null))
  258. {
  259. //itemStaff.Item = item;
  260. itemStaff.DoPersonId = iTem.Value;
  261. item.ItemStaffs.Add(itemStaff);
  262. }
  263. else
  264. {
  265. itemStaff.DoPerson = new Staff()
  266. {
  267. Name = name,
  268. Account = name,
  269. Password = "12345678",
  270. IsCalPerformsnce = false,
  271. Status = "正式员工",
  272. StaffGradeId = 4
  273. };
  274. item.ItemStaffs.Add(itemStaff);
  275. }
  276. }
  277. if (item.ItemStaffs.Count == 0)
  278. {
  279. System.Diagnostics.Debug.WriteLine($"没有处理人: {item.CaseNo}\t{item.DoItem}");
  280. }
  281. if (row.Table.Columns.Contains("核稿人"))
  282. {
  283. item.ReviewerId = GetStaff(row["核稿人"].ToString().Trim(), Staffs);
  284. }
  285. else
  286. {
  287. if (row.Table.Columns.Contains("案件核稿人"))
  288. {
  289. item.ReviewerId = GetStaff(row["案件核稿人"].ToString().Trim(), Staffs);
  290. }
  291. }
  292. item.Customer = new Customer() { Name = row["客户名称"].ToString().Trim() };
  293. item.ApplicationName = row["申请人"].ToString().Trim();
  294. item.CaseName = row["案件名称"].ToString().Trim();
  295. //案件备注
  296. item.CaseMemo = $"发文日期:{row["发文日期"].ToString().Trim()}\r\n客户文号:{row["客户文号"].ToString().Trim()}\r\n上传日期:{row["上传日期"].ToString().Trim()}\r\n文件描述:{row["文件描述"].ToString().Trim()}";
  297. return item;
  298. }
  299. private PerformanceItem Row2Item(DataRow row, List<Staff> Staffs,CalMonth calMonth)
  300. {
  301. PerformanceItem item = new PerformanceItem();
  302. item.CaseNo = row["我方文号"].ToString().Trim();
  303. if (calMonth != null)
  304. {
  305. item.CalMonth = calMonth;
  306. }
  307. else
  308. {
  309. if (row.Table.Columns.Contains("绩效核算月份"))
  310. {
  311. string strjxyf = row["绩效核算月份"].ToString().Trim();
  312. string[] temYFs = strjxyf.Split(new char[] { '.' });
  313. item.CalMonth = new CalMonth();
  314. item.CalMonth.Year = int.Parse(temYFs[0]);
  315. item.CalMonth.Month = int.Parse(temYFs[1]);
  316. item.CalMonth.Status = 4;
  317. }
  318. else
  319. {
  320. item.CalMonth = new CalMonth();
  321. item.Status = 0;
  322. item.CalMonth.Year = DateTime.Now.AddMonths(-1).Year;
  323. item.CalMonth.Month = DateTime.Now.AddMonths(-1).Month;
  324. }
  325. }
  326. item.ApplicationType = row["申请类型"].ToString().Trim();
  327. item.BusinessType = row["业务类型"].ToString().Trim();
  328. if (row.Table.Columns.Contains("备注(填表注意事项)"))
  329. item.AgentFeedbackMemo = row["备注(填表注意事项)"].ToString().Trim();
  330. item.DoItem = row["处理事项"].ToString().Trim();
  331. item.CaseStage = row["案件阶段"].ToString().Trim();
  332. item.CaseCoefficient = row["案件系数"].ToString().Trim();
  333. item.DoItemCoefficient = row["处理事项系数"].ToString().Trim();
  334. item.PreOastaffId = GetStaff(row["前一次OA处理人"].ToString().Trim(), Staffs);
  335. string strHandler = "";
  336. if (row.Table.Columns.Contains("处理人"))
  337. {
  338. strHandler = row["处理人"].ToString().Trim();
  339. }
  340. else
  341. {
  342. if (row.Table.Columns.Contains("案件处理人"))
  343. {
  344. strHandler = row["案件处理人"].ToString().Trim();
  345. }
  346. }
  347. string[] temHandlers = strHandler.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  348. item.ItemStaffs = new List<ItemStaff>();
  349. foreach (string name in temHandlers)
  350. {
  351. ItemStaff itemStaff = new ItemStaff();
  352. string temName = name.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  353. int? iTem = GetStaff(temName, Staffs);
  354. if ((iTem != null))
  355. {
  356. //itemStaff.Item = item;
  357. itemStaff.DoPersonId = iTem.Value;
  358. item.ItemStaffs.Add(itemStaff);
  359. }
  360. else
  361. {
  362. itemStaff.DoPerson = new Staff()
  363. {
  364. Name = temName,
  365. Account = temName,
  366. Password = "12345678",
  367. IsCalPerformsnce = false,
  368. Status = "已离职",
  369. StaffGradeId = 4
  370. };
  371. item.ItemStaffs.Add(itemStaff);
  372. }
  373. }
  374. if (item.ItemStaffs.Count == 0)
  375. {
  376. System.Diagnostics.Debug.WriteLine($"没有处理人: {item.CaseNo}\t{item.DoItem}");
  377. }
  378. if (row.Table.Columns.Contains("核稿人"))
  379. {
  380. if (!string.IsNullOrEmpty(row["核稿人"].ToString().Trim()))
  381. {
  382. string temName = row["核稿人"].ToString().Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  383. item.ReviewerId = GetStaff(temName.Trim(), Staffs);
  384. }
  385. }
  386. else
  387. {
  388. if (row.Table.Columns.Contains("案件核稿人"))
  389. {
  390. if (!string.IsNullOrEmpty(row["案件核稿人"].ToString().Trim()))
  391. {
  392. string temName = row["案件核稿人"].ToString().Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  393. item.ReviewerId = GetStaff(temName.Trim(), Staffs);
  394. }
  395. }
  396. }
  397. item.Customer = new Customer() { Name = row["客户名称"].ToString().Trim() };
  398. item.ApplicationName = row["申请人"].ToString().Trim();
  399. DateTime temDate = new DateTime();
  400. if (DateTime.TryParse(row["处理事项完成日"].ToString().Trim(), out temDate))
  401. {
  402. item.FinishedDate = temDate;
  403. }
  404. //定稿日
  405. if (DateTime.TryParse(row["定稿日"].ToString().Trim(), out temDate))
  406. {
  407. item.FinalizationDate = temDate;
  408. }
  409. //返稿日
  410. if (DateTime.TryParse(row["返稿日"].ToString().Trim(), out temDate))
  411. {
  412. item.ReturnDate = temDate;
  413. }
  414. //案件类型
  415. item.CaseType = row["案件类型"].ToString().Trim();
  416. //案件状态
  417. item.CaseState = row["案件状态"].ToString().Trim();
  418. //处理事项备注
  419. item.DoItemMemo = row["处理事项备注"].ToString().Trim();
  420. //处理状态
  421. item.DoItemState = row["处理状态"].ToString().Trim();
  422. //案件名称
  423. item.CaseName = row["案件名称"].ToString().Trim();
  424. //委案日期
  425. if (DateTime.TryParse(row["委案日期"].ToString().Trim(), out temDate))
  426. {
  427. item.EntrustingDate = temDate;
  428. }
  429. //客户期限
  430. if (DateTime.TryParse(row["客户期限"].ToString().Trim(), out temDate))
  431. {
  432. item.CustomerLimitDate = temDate;
  433. }
  434. //内部期限
  435. if (DateTime.TryParse(row["内部期限"].ToString().Trim(), out temDate))
  436. {
  437. item.InternalDate = temDate;
  438. }
  439. //初稿日
  440. if (DateTime.TryParse(row["初稿日"].ToString().Trim(), out temDate))
  441. {
  442. item.FirstDraftDate = temDate;
  443. }
  444. //备注(发文严重超期是否属客观原因,若为否,请填写原因)
  445. if (row.Table.Columns.Contains("备注(发文严重超期是否属客观原因,若为否,请填写原因)"))
  446. {
  447. item.OverDueMemo = row["备注(发文严重超期是否属客观原因,若为否,请填写原因)"].ToString().Trim();
  448. }
  449. //案件备注
  450. item.CaseMemo = row["案件备注"].ToString().Trim();
  451. return item;
  452. }
  453. private async Task InputPerformanceItem(string strExcelFile,bool isColumnName,bool ignorHideRows=false,int ColumnNameRow=0,CalMonth calMonth=null,bool isFirstOAFile=false)
  454. {
  455. DataTable dt = NPOIExcel.ExcelToDataTable(strExcelFile, isColumnName,ignorHideRows,ColumnNameRow);
  456. #region 删除重复行
  457. DataTable temdt = new DataTable();
  458. foreach (DataColumn col in dt.Columns)
  459. {
  460. DataColumn temCol = new DataColumn();
  461. temCol.ColumnName = col.ColumnName;
  462. temCol.DataType = col.DataType;
  463. temCol.Caption = col.Caption;
  464. temdt.Columns.Add(temCol);
  465. }
  466. new ExcelHelper().MerageDataTable(temdt, dt);
  467. #endregion
  468. List<Staff> Staffs =await GetStaffsAsync();
  469. foreach(DataRow row in temdt.Rows)
  470. {
  471. PerformanceItem item = null;
  472. if (isFirstOAFile)
  473. {
  474. item = Row2Item_1(row, Staffs, calMonth);
  475. }
  476. else
  477. {
  478. item = Row2Item(row, Staffs, calMonth);
  479. }
  480. if (item != null )
  481. {
  482. if (!InValidDoItem.Contains(item.DoItem))
  483. {
  484. await SavePerformanceItem(item);
  485. }
  486. }
  487. }
  488. }
  489. private int? GetStaff(string v, List<Staff> staffs)
  490. {
  491. if (!string.IsNullOrEmpty(v))
  492. {
  493. string[] temNames = v.Trim().Split(new char[] { '-' },StringSplitOptions.RemoveEmptyEntries);
  494. foreach (Staff sf in staffs)
  495. {
  496. if(sf.Name == temNames[0])
  497. {
  498. return sf.Id;
  499. }
  500. }
  501. }
  502. return null;
  503. }
  504. private async Task ImportUsers()
  505. {
  506. DataTable dt = NPOIExcel.ExcelToDataTable(@"C:\temp\用户列表(2021年10月26日).xlsx", true,false,1);
  507. List<StaffGrade> staffGrades = await GetStaffGrades();
  508. foreach (DataRow row in dt.Rows)
  509. {
  510. Staff staff = new Staff();
  511. staff.Account = row["用户名"].ToString().Trim();
  512. staff.Name = row["姓名"].ToString().Trim();
  513. staff.Tel = row["电话号码"].ToString().Trim();
  514. staff.Mobile = row["手机号码"].ToString().Trim();
  515. staff.Sex = row["性别"].ToString().Trim();
  516. staff.Mail = row["邮箱"].ToString().Trim();
  517. string strGrade = row["工程师等级"].ToString().Trim(); // + "级";
  518. foreach (StaffGrade sg in staffGrades)
  519. {
  520. if (strGrade.Trim() == sg.Grade.Trim())
  521. {
  522. staff.StaffGradeId = sg.Id;
  523. break;
  524. }
  525. }
  526. staff.IsOnJob = (row["是否在职"].ToString().Trim()=="是");
  527. staff.Status = row["岗位状态"].ToString().Trim();
  528. staff.Department = row["部门"].ToString();
  529. staff.WorkPlace = row["工作地"].ToString();
  530. DateTime temDate;
  531. if (DateTime.TryParse(row["入职时间"].ToString(), out temDate))
  532. {
  533. staff.EntyDate = temDate;
  534. }
  535. //staff.IsCalPerformsnce = (row["是否核算绩效"].ToString() == "是");
  536. //staff.Memo = row["备注"].ToString().Trim();
  537. staff.Password = MD5Utility.GetMD5("12345678");
  538. //staff.StaffGradeId = row["姓名"].ToString();
  539. await SaveStaff(staff);
  540. }
  541. }
  542. private string getPinYin(string str)
  543. {
  544. string retStr = "";
  545. for(int i = 0; i < str.Length; i++)
  546. {
  547. ChineseChar cc = new ChineseChar(str[i]);
  548. retStr = retStr + cc.Pinyins[0].ToLower().Replace("1","")
  549. .Replace("2", "").Replace("3", "").Replace("4", "");
  550. }
  551. return retStr;
  552. }
  553. private async Task SaveStaff(Staff obj)
  554. {
  555. HttpClient http = new HttpClient();
  556. var data = await http.PostAsJsonAsync<wispro.sp.entity.Staff>($"http://localhost:39476/api/Staff/Save", obj);
  557. if (data.IsSuccessStatusCode)
  558. {
  559. ApiSaveResponse result = await data.Content.ReadFromJsonAsync<ApiSaveResponse>();
  560. //await Task.Delay(1000);
  561. if (result.Success)
  562. {
  563. }
  564. else
  565. {
  566. }
  567. }
  568. else
  569. {
  570. }
  571. }
  572. private async Task SaveBasePointRule(BasePointRule obj)
  573. {
  574. HttpClient http = new HttpClient();
  575. var data = await http.PostAsJsonAsync<BasePointRule>($"http://localhost:39476/api/BasePointRule/New", obj);
  576. if (data.IsSuccessStatusCode)
  577. {
  578. ApiSaveResponse result = await data.Content.ReadFromJsonAsync<ApiSaveResponse>();
  579. //await Task.Delay(1000);
  580. if (result.Success)
  581. {
  582. }
  583. else
  584. {
  585. System.Diagnostics.Debug.WriteLine($"保存错误: {obj.Rule}\t{obj.PointExpress}\r\n{result.ErrorMessage}");
  586. }
  587. }
  588. else
  589. {
  590. System.Diagnostics.Debug.WriteLine($"调用API错误: {obj.Type}\t{obj.Rule}");
  591. }
  592. }
  593. private async Task SavePerformanceItem(PerformanceItem obj)
  594. {
  595. HttpClient http = new HttpClient();
  596. var data = await http.PostAsJsonAsync<PerformanceItem>($"http://localhost:39476/api/PerformanceItem/New", obj);
  597. if (data.IsSuccessStatusCode)
  598. {
  599. ApiSaveResponse result = await data.Content.ReadFromJsonAsync<ApiSaveResponse>();
  600. //await Task.Delay(1000);
  601. if (result.Success)
  602. {
  603. }
  604. else
  605. {
  606. System.Diagnostics.Debug.WriteLine($"保存错误: {obj.CaseNo}\t{obj.DoItem}\r\n{result.ErrorMessage}");
  607. }
  608. }
  609. else
  610. {
  611. System.Diagnostics.Debug.WriteLine($"调用API错误: {obj.CaseNo}\t{obj.DoItem}");
  612. }
  613. }
  614. private async Task<List<StaffGrade>> GetStaffGrades()
  615. {
  616. HttpClient http = new HttpClient();
  617. var _StaffGrade = await http.GetFromJsonAsync<List<StaffGrade>>($"http://localhost:39476/api/StaffGrade/GetAll");
  618. return _StaffGrade;
  619. }
  620. private async Task<List<Staff>> GetStaffsAsync()
  621. {
  622. HttpClient http = new HttpClient();
  623. ListApiResponse<Staff> data = await http.GetFromJsonAsync<ListApiResponse<Staff>>($"http://localhost:39476/api/Staff/Query?pageIndex=1&pageSize=200");
  624. return data.Results;
  625. }
  626. private void button4_Click(object sender, EventArgs e)
  627. {
  628. Stopwatch watch = new Stopwatch();
  629. watch.Start();
  630. dynamic retObj = wispro.sp.utility.IPEasyUtility.GetPerformanceRecord("S2112392-洗碗机调查分析","提出报告");
  631. PerformanceItem Item = new PerformanceItem();
  632. Item.CaseName = retObj.CaseName;
  633. Item.CaseNo = retObj.CaseNo;
  634. Item.DoItem = retObj.DoItem;
  635. Item.CustomerLimitDate = string.IsNullOrEmpty(retObj.CustomerLimitDate) ? null : DateTime.Parse(retObj.CustomerLimitDate);
  636. Item.Customer = new Customer();
  637. Item.Customer.Name = retObj.CustomerName;
  638. Item.DoItemCoefficient = retObj.DoItemCoefficient;
  639. Item.DoItemMemo = retObj.DoItemMemo;
  640. Item.DoItemState = retObj.DoItemState;
  641. Item.EntrustingDate = string.IsNullOrEmpty(retObj.EntrustingDate) ? null : DateTime.Parse(retObj.EntrustingDate);
  642. Item.FinalizationDate = string.IsNullOrEmpty(retObj.FinalizationDate) ? null : DateTime.Parse(retObj.FinalizationDate);
  643. Item.FinishedDate = string.IsNullOrEmpty(retObj.FinishedDate) ? null : DateTime.Parse(retObj.FinishedDate);
  644. //Item.FirstDraftDate = string.IsNullOrEmpty(retObj.FirstDraftDate) ? null : DateTime.Parse(retObj.FirstDraftDate);
  645. Item.InternalDate = string.IsNullOrEmpty(retObj.InternalDate) ? null : DateTime.Parse(retObj.InternalDate);
  646. if (!string.IsNullOrEmpty(retObj.DoPersons))
  647. {
  648. Item.ItemStaffs = new List<ItemStaff>();
  649. string[] names = retObj.DoPersons.ToString().Split(new char[] { ','},StringSplitOptions.RemoveEmptyEntries);
  650. foreach(var name in names)
  651. {
  652. ItemStaff iStaff = new ItemStaff();
  653. iStaff.DoPerson = new Staff() { Name = name };
  654. Item.ItemStaffs.Add(iStaff);
  655. }
  656. }
  657. Item.ReturnDate = string.IsNullOrEmpty(retObj.ReturnDate) ? null : DateTime.Parse(retObj.ReturnDate);
  658. if (!string.IsNullOrEmpty(retObj.Reviewer))
  659. {
  660. Item.Reviewer = new Staff() { Name = retObj.Reviewer };
  661. }
  662. Item.ApplicationType = retObj.ApplicationType;
  663. Item.BusinessType = retObj.BusinessType;
  664. Item.CaseCoefficient = retObj.CaseCoefficient;
  665. Item.CaseMemo = retObj.CaseMemo;
  666. Item.CaseStage = retObj.CaseStage;
  667. Item.CaseState = retObj.CaseState;
  668. Item.CaseType = retObj.CaseType;
  669. watch.Stop();
  670. System.Diagnostics.Debug.WriteLine("用时{0}毫秒", watch.ElapsedMilliseconds);//获取当前实例测量得出的总运行时间(以毫秒为单位)
  671. //wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--上个月递交完成案件", true);
  672. //wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--发客户超过一个月未完成案件", false);
  673. //wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--中国一次OA授权表", true);
  674. ////每月绩效统计--发客户超过一个月未完成案件
  675. //NewMethod("506aa7ad-c3f4-4ec6-9ec8-ff6b92dcd7c1", "每月绩效统计--发客户超过一个月未完成案件.xlsx", calMonth);
  676. ////每月绩效统计--上个月递交完成案件
  677. //NewMethod("d7308cd2-71e4-4444-9f47-f4d731ddb26a", "每月绩效统计--上个月递交完成案件.xlsx", calMonth);
  678. ////每月绩效统计--中国一次OA授权表
  679. //NewMethod("72454834-afdd-4b98-b42a-0bc912d07610", "每月绩效统计--中国一次OA授权表.xlsx", calMonth, true);
  680. }
  681. }
  682. }