Form1.cs 30 KB

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