瀏覽代碼

添加从IPEasy获取案件信息模块

luocaiyang 3 年之前
父節點
當前提交
b1581d7b47

+ 7 - 0
wispro.sp.api/Controllers/AppealController.cs

@@ -246,6 +246,13 @@ namespace wispro.sp.api.Controllers
                         .Include(p => p.Reviewer)
                         .FirstOrDefault();
 
+                    bool ItemIsNull = false;
+                    if(Item == null)
+                    {
+                        ItemIsNull = true;
+                        Item = new PerformanceItem();
+                    }
+
                     if (!string.IsNullOrEmpty(field.MapObjectField) && !string.IsNullOrEmpty(field.MapObjectFieldLabel))
                     {
                         List<InputFieldValue> temValues = new List<InputFieldValue>();

+ 72 - 1
wispro.sp.api/Controllers/PerformanceItemController.cs

@@ -17,7 +17,7 @@ namespace wispro.sp.api.Controllers
 {
     [Route("api/[controller]/[action]")]
     [ApiController]
-    [Authorize]
+    //[Authorize]
     public class PerformanceItemController : ControllerBase
     {
         spDbContext Context;
@@ -658,6 +658,77 @@ namespace wispro.sp.api.Controllers
             return ret;
         }
 
+        
+        public PerformanceItem GetItemFormIPEasy(string CaseNo, string DoItem)
+        {
+            dynamic retObj = wispro.sp.utility.IPEasyUtility.GetPerformanctRecord(CaseNo, DoItem);
+            PerformanceItem Item = new PerformanceItem();
+            Item.CaseName = retObj.CaseName;
+            Item.CaseNo = retObj.CaseNo;
+            Item.DoItem = retObj.DoItem;
+            Item.CustomerLimitDate = string.IsNullOrEmpty(retObj.CustomerLimitDate) ? null : DateTime.Parse(retObj.CustomerLimitDate);
+            Item.Customer = new Customer();
+            Item.Customer.Name = retObj.CustomerName;
+            Item.DoItemCoefficient = retObj.DoItemCoefficient;
+            Item.DoItemMemo = retObj.DoItemMemo;
+            Item.DoItemState = retObj.DoItemState;
+            Item.EntrustingDate = string.IsNullOrEmpty(retObj.EntrustingDate) ? null : DateTime.Parse(retObj.EntrustingDate);
+            Item.FinalizationDate = string.IsNullOrEmpty(retObj.FinalizationDate) ? null : DateTime.Parse(retObj.FinalizationDate);
+            Item.FinishedDate = string.IsNullOrEmpty(retObj.FinishedDate) ? null : DateTime.Parse(retObj.FinishedDate);
+            //Item.FirstDraftDate = string.IsNullOrEmpty(retObj.FirstDraftDate) ? null : DateTime.Parse(retObj.FirstDraftDate);
+            Item.InternalDate = string.IsNullOrEmpty(retObj.InternalDate) ? null : DateTime.Parse(retObj.InternalDate);
+
+            if (!string.IsNullOrEmpty(retObj.DoPersons))
+            {
+
+                Item.ItemStaffs = new List<ItemStaff>();
+                string[] names = retObj.DoPersons.ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
+                foreach (var name in names)
+                {
+
+                    ItemStaff iStaff = new ItemStaff();
+                    iStaff.DoPerson = Context.Staffs.Where<Staff>(s => s.Name == name).FirstOrDefault();
+                    if(iStaff.DoPerson == null)
+                    {
+                        iStaff.DoPerson = new Staff() { Name = name };
+                    }
+                    else
+                    {
+                        iStaff.DoPersonId = iStaff.DoPerson.Id;
+                    }
+
+
+
+                    Item.ItemStaffs.Add(iStaff);
+                }
+            }
+
+            Item.ReturnDate = string.IsNullOrEmpty(retObj.ReturnDate) ? null : DateTime.Parse(retObj.ReturnDate);
+
+            if (!string.IsNullOrEmpty(retObj.Reviewer))
+            {
+                string name = retObj.Reviewer;
+                var temReviewer = Context.Staffs.Where<Staff>(s => s.Name == name).FirstOrDefault();
+                if (temReviewer == null)
+                {
+                    Item.Reviewer = new Staff() { Name = retObj.Reviewer };
+                }
+                else
+                {
+                    Item.Reviewer = temReviewer;
+                    Item.ReviewerId = temReviewer.Id;
+                }
+            }
+            Item.ApplicationType = retObj.ApplicationType;
+            Item.BusinessType = retObj.BusinessType;
+            Item.CaseCoefficient = retObj.CaseCoefficient;
+            Item.CaseMemo = retObj.CaseMemo;
+            Item.CaseStage = retObj.CaseStage;
+            Item.CaseState = retObj.CaseState;
+            Item.CaseType = retObj.CaseType;
+
+            return Item;
+        }
 
     }
 }

+ 2 - 0
wispro.sp.api/Utility/Utility.cs

@@ -36,5 +36,7 @@ namespace wispro.sp.api.Utility
             }
             #endregion
         }
+
+        
     }
 }

+ 136 - 0
wispro.sp.utility/IPEasyUtility.cs

@@ -1,4 +1,6 @@
 using System;
+using System.Data;
+using System.Dynamic;
 using System.Linq;
 using OpenQA.Selenium;
 
@@ -201,5 +203,139 @@ namespace wispro.sp.utility
                 }
             }
         }
+
+        /// <summary>
+        /// 获取案件处理事项记录
+        /// </summary>
+        /// <param name="caseNo"></param>
+        /// <param name="doItemName"></param>
+        /// <returns></returns>
+        public static dynamic GetPerformanctRecord(string caseNo,string doItemName)
+        {
+            string strFileSavePath = ConfigHelper.GetSectionValue("IPEasySetting:DownloadFileSavePath");
+            bool isheadless = (ConfigHelper.GetSectionValue("IPEasySetting:isHeadless") == "true");
+            string Account = ConfigHelper.GetSectionValue("IPEasySetting:Account");
+            string Password = ConfigHelper.GetSectionValue("IPEasySetting:Password");
+
+            OpenQA.Selenium.Chrome.ChromeOptions options = new OpenQA.Selenium.Chrome.ChromeOptions();
+
+
+            options.AddUserProfilePreference("download.default_directory", strFileSavePath);
+            options.AddUserProfilePreference("intl.accept_languages", "nl");
+            options.AddUserProfilePreference("disable-popup-blocking", "true");
+            options.AddUserProfilePreference("profile", new { default_content_setting_values = new { images = 2 } });
+
+            if (isheadless)
+            {
+                options.AddArgument("headless");
+            }
+
+            dynamic retObject = new ExpandoObject();
+
+            retObject.CaseNo = caseNo;
+            retObject.DoItem = doItemName;
+            
+            
+            using (IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver(ConfigHelper.GetSectionValue("IPEasySetting:ChormeDriverPath"), options))
+            {
+
+                driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
+                driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(100);
+
+                //进入登录界面
+                driver.Navigate().GoToUrl("http://47.106.221.167/Login.aspx");
+
+                //输入用户名和密码
+                driver.FindElement(By.Id("txtUser")).SendKeys(Account);
+                driver.FindElement(By.Id("txtPwd")).SendKeys(Password);
+
+                //点击登录按钮
+                driver.FindElement(By.Id("btnLogin")).Click();
+
+                //关闭提示遮罩层
+                driver.FindElement(By.Id("jpwClose")).Click();
+
+                //点击顶部菜单栏中的案件管理菜单
+                driver.FindElement(By.Name("71A7CC35-F597-40E1-9FEF-BE622A3A3B63")).Click();
+
+                //点击左侧 查询 菜单
+                driver.FindElement(By.Name("c3266ab3-521a-4815-8aaf-7dd0bc5a76af")).Click();
+
+                //切换到自定义报表Frame
+                driver.SwitchTo().Frame(1);
+
+                var inputSearch = driver.FindElement(By.Id("case_volume"));
+                inputSearch.SendKeys(caseNo);
+
+                var btnSearch = driver.FindElement(By.Id("btn_Search"));
+                btnSearch.Click();
+
+                var caseLink = driver.FindElement(By.XPath($"//a[contains(text(),'{caseNo}')]"));
+                caseLink.Click();
+                System.Threading.Thread.Sleep(500);
+
+                driver.SwitchTo().ParentFrame().SwitchTo().Frame(2);
+                //driver.SwitchTo().ParentFrame().SwitchTo().Frame(driver.FindElement(By.XPath("//iframe[contains(@src,'CaseInfo.aspx']")));
+                var DoItemLink = driver.FindElement(By.XPath($"//td[contains(text(),'{doItemName}')]"));
+                retObject.CaseStage = DoItemLink.FindElement(By.XPath("following-sibling::td[1]")).Text; //案件阶段
+                retObject.DoItemState = DoItemLink.FindElement(By.XPath("following-sibling::td[2]")).Text;    //处理事项处理状态
+                //var td4 = DoItemLink.FindElement(By.XPath("following-sibling::td[3]")).Text;   //配案日
+                retObject.InternalDate = DoItemLink.FindElement(By.XPath("following-sibling::td[4]")).Text;   //内部期限
+                retObject.CustomerLimitDate = DoItemLink.FindElement(By.XPath("following-sibling::td[5]")).Text;   //客户期限
+                //var td7 = DoItemLink.FindElement(By.XPath("following-sibling::td[6]")).Text;   //官方期限
+                retObject.FinishedDate = DoItemLink.FindElement(By.XPath("following-sibling::td[7]")).Text;   //处理事项完成日
+                retObject.DoPersons = DoItemLink.FindElement(By.XPath("following-sibling::td[8]")).Text;   //处理人
+                retObject.DoItemMemo = DoItemLink.FindElement(By.XPath("following-sibling::td[9]")).Text;   //处理事项备注
+                DoItemLink.Click();
+
+                retObject.FinalizationDate = driver.FindElement(By.Id("p_proc_info__finish_doc_date")).GetAttribute("value"); //定稿日
+                //retObject.FinalizationDate = driver.FindElement(By.Id("p_proc_info__cus_due_date")).GetAttribute("value"); //客户完成日[定稿日]
+                retObject.ReturnDate = driver.FindElement(By.Id("p_proc_info__back_date")).GetAttribute("value"); //返稿日
+                retObject.Reviewer = driver.FindElement(By.Id("p_proc_info__revise_user")).GetAttribute("value");      //核稿人
+                retObject.DoItemCoefficient = driver.FindElement(By.Id("p_proc_info__proc_coefficient")).GetAttribute("value");     //处理事项系数
+
+                driver.FindElement(By.Id("libase")).Click();
+                retObject.CaseName = driver.FindElement(By.Id("p_case_info__case_name")).GetAttribute("value");  //案件名称
+                retObject.CustomerName = driver.FindElement(By.Id("p_case_info__customer_id")).GetAttribute("value");  //客户名称
+                retObject.BusinessType = driver.FindElement(By.Id("p_case_info__business_type_id")).GetAttribute("value");     //业务类型
+
+                retObject.CaseState = GetSelectText(driver.FindElement(By.Id("p_case_info__case_status_id")));
+                retObject.ApplicationType = GetSelectText(driver.FindElement(By.Id("p_case_info__apply_type_id")));
+                
+
+                retObject.CaseType = driver.FindElement(By.Id("p_case_info__case_type_id")).GetAttribute("value");  //案件类型
+                retObject.EntrustingDate = driver.FindElement(By.Id("p_case_info__charge_date")).GetAttribute("value"); //委案日期
+                retObject.CaseMemo = driver.FindElement(By.Id("p_case_info__remark")).GetAttribute("value");    //案件备注
+
+                driver.FindElement(By.XPath($"//span[contains(text(),'扩展信息')]")).Click();
+                //select[@id='p_case_info__case_coefficient_id']
+                retObject.CaseCoefficient = GetSelectText(driver.FindElement(By.Id("p_case_info__case_coefficient_id")));
+
+            }
+
+            return retObject;
+        }
+
+        private static string GetSelectText(IWebElement element)
+        {
+            var strValue = element.GetAttribute("value");
+
+            if (string.IsNullOrEmpty(strValue))
+            {
+                return null;
+            }
+
+            var ops = element.FindElements(By.TagName("option"));
+            foreach (var op in ops)
+            {
+                if (op.GetAttribute("value") == strValue)
+                {
+                    return op.Text;
+                }
+            }
+
+            return null;
+
+        }
     }
 }

+ 54 - 3
wispro.sp.winClient/Form1.cs

@@ -5,6 +5,7 @@ using System.Collections.Generic;
 using System.ComponentModel;
 using System.Configuration;
 using System.Data;
+using System.Diagnostics;
 using System.Drawing;
 using System.Linq;
 using System.Net.Http;
@@ -701,9 +702,59 @@ namespace wispro.sp.winClient
 
         private void button4_Click(object sender, EventArgs e)
         {
-            wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--上个月递交完成案件", true);
-            wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--发客户超过一个月未完成案件", false);
-            wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--中国一次OA授权表", true);
+            Stopwatch watch = new Stopwatch();
+            watch.Start();
+           
+            dynamic retObj = wispro.sp.utility.IPEasyUtility.GetPerformanctRecord("S2112392-洗碗机调查分析", "提出报告");
+            PerformanceItem Item = new PerformanceItem();
+            Item.CaseName = retObj.CaseName;
+            Item.CaseNo = retObj.CaseNo;
+            Item.DoItem = retObj.DoItem;
+            Item.CustomerLimitDate = string.IsNullOrEmpty(retObj.CustomerLimitDate) ? null : DateTime.Parse(retObj.CustomerLimitDate);
+            Item.Customer = new Customer();
+            Item.Customer.Name = retObj.CustomerName;
+            Item.DoItemCoefficient = retObj.DoItemCoefficient;
+            Item.DoItemMemo = retObj.DoItemMemo;
+            Item.DoItemState = retObj.DoItemState;
+            Item.EntrustingDate = string.IsNullOrEmpty(retObj.EntrustingDate) ? null : DateTime.Parse(retObj.EntrustingDate);
+            Item.FinalizationDate = string.IsNullOrEmpty(retObj.FinalizationDate) ? null : DateTime.Parse(retObj.FinalizationDate);
+            Item.FinishedDate = string.IsNullOrEmpty(retObj.FinishedDate) ? null : DateTime.Parse(retObj.FinishedDate);
+            //Item.FirstDraftDate = string.IsNullOrEmpty(retObj.FirstDraftDate) ? null : DateTime.Parse(retObj.FirstDraftDate);
+            Item.InternalDate = string.IsNullOrEmpty(retObj.InternalDate) ? null : DateTime.Parse(retObj.InternalDate);
+            
+            if (!string.IsNullOrEmpty(retObj.DoPersons))
+            {
+                Item.ItemStaffs = new List<ItemStaff>();
+                string[] names = retObj.DoPersons.ToString().Split(new char[] { ','},StringSplitOptions.RemoveEmptyEntries);
+                foreach(var name in names)
+                {
+                    ItemStaff iStaff = new ItemStaff();
+                    iStaff.DoPerson = new Staff() { Name = name };
+                    Item.ItemStaffs.Add(iStaff);
+                }
+            }
+
+            Item.ReturnDate = string.IsNullOrEmpty(retObj.ReturnDate) ? null : DateTime.Parse(retObj.ReturnDate);
+
+            if (!string.IsNullOrEmpty(retObj.Reviewer))
+            {
+                Item.Reviewer = new Staff() { Name = retObj.Reviewer };
+            }
+            Item.ApplicationType = retObj.ApplicationType;
+            Item.BusinessType = retObj.BusinessType;
+            Item.CaseCoefficient = retObj.CaseCoefficient;
+            Item.CaseMemo = retObj.CaseMemo;
+            Item.CaseStage = retObj.CaseStage;
+            Item.CaseState = retObj.CaseState;
+            Item.CaseType = retObj.CaseType;
+
+            watch.Stop();
+            System.Diagnostics.Debug.WriteLine("用时{0}毫秒", watch.ElapsedMilliseconds);//获取当前实例测量得出的总运行时间(以毫秒为单位)
+
+
+            //wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--上个月递交完成案件", true);
+            //wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--发客户超过一个月未完成案件", false);
+            //wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--中国一次OA授权表", true);
             ////每月绩效统计--发客户超过一个月未完成案件
             //NewMethod("506aa7ad-c3f4-4ec6-9ec8-ff6b92dcd7c1", "每月绩效统计--发客户超过一个月未完成案件.xlsx", calMonth);