Form1.cs 33 KB

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