Form1.cs 30 KB

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