|
@@ -107,16 +107,11 @@ namespace wispro.sp.api.Job
|
|
|
DownloadReport_SQL("每月绩效统计--中国一次OA授权表", calMonth, true, true);
|
|
|
//DownloadReport("每月绩效统计--中国一次OA授权表", calMonth, true,true);
|
|
|
|
|
|
- //专案数据
|
|
|
- DownloadProject_SQL(calMonth);
|
|
|
- //DownloadProject(calMonth);
|
|
|
-
|
|
|
return Task.CompletedTask;
|
|
|
}
|
|
|
|
|
|
private void DownloadReport_SQL(string ReportName, CalMonth calMonth, bool isModifyDate, bool isFirstOA = false)
|
|
|
{
|
|
|
-
|
|
|
try
|
|
|
{
|
|
|
DataTable data = GetDataFromIPEasy(ReportName,isModifyDate);
|
|
@@ -128,242 +123,7 @@ namespace wispro.sp.api.Job
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void DownloadReport(string ReportName,CalMonth calMonth,bool isModifyDate,bool isFirstOA=false)
|
|
|
- {
|
|
|
- string strFileSavePath = utility.ConfigHelper.GetSectionValue("IPEasySetting:DownloadFileSavePath");
|
|
|
- string filename = $"{ReportName.Trim()}.xlsx";
|
|
|
- string strFilePath = System.IO.Path.Combine(strFileSavePath, filename);
|
|
|
- string strFinalPath = System.IO.Path.Combine(strFileSavePath, $"{calMonth.Year}{calMonth.Month}-{filename}");
|
|
|
-
|
|
|
- int tryCount = 0;
|
|
|
-
|
|
|
- tryAgain:
|
|
|
- try
|
|
|
- {
|
|
|
- wispro.sp.utility.IPEasyUtility.DownloadReport(ReportName, isModifyDate);
|
|
|
-
|
|
|
- if (!System.IO.File.Exists(strFilePath))
|
|
|
- {
|
|
|
- throw new ApplicationException("超时!");
|
|
|
- }
|
|
|
- }
|
|
|
- catch {
|
|
|
- tryCount++;
|
|
|
-
|
|
|
- if (tryCount < 5)
|
|
|
- {
|
|
|
- goto tryAgain;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- System.Threading.Thread.Sleep(5000);
|
|
|
- if (System.IO.File.Exists(strFilePath))
|
|
|
- {
|
|
|
- InputPerformanceItem(strFilePath, true, false, 1, calMonth, isFirstOA);
|
|
|
-
|
|
|
- try
|
|
|
- {
|
|
|
- System.IO.File.Move(strFilePath, strFinalPath);
|
|
|
- }
|
|
|
- catch { }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- tryCount++;
|
|
|
-
|
|
|
- if (tryCount < 5)
|
|
|
- {
|
|
|
- goto tryAgain;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void DownloadProject_SQL(CalMonth calMonth)
|
|
|
- {
|
|
|
- string[] ReportNames = new string[] { "每月绩效统计--专案进度跟踪~S卷", "每月绩效统计--专案开卷报表~S卷" };
|
|
|
-
|
|
|
- List<PerformanceItem> pfItems = new List<PerformanceItem>();
|
|
|
- foreach (var ReportName in ReportNames)
|
|
|
- {
|
|
|
- DataTable data = GetDataFromIPEasy(ReportName, false);
|
|
|
-
|
|
|
- var Items = GetProjectItem(calMonth, ReportName.Contains("专案开卷报表"),data);
|
|
|
-
|
|
|
- foreach (var item in Items)
|
|
|
- {
|
|
|
- var temObj = pfItems.FirstOrDefault<PerformanceItem>(s => s.CaseNo == item.CaseNo);
|
|
|
- if (temObj == null)
|
|
|
- {
|
|
|
- item.Type = "专案";
|
|
|
- pfItems.Add(item);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //List<BasePointRule> rules = spDb.BasePointRules.ToList<BasePointRule>();
|
|
|
- foreach (var item in pfItems)
|
|
|
- {
|
|
|
- SaveProjectItem(item);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private void DownloadProject(CalMonth calMonth)
|
|
|
- {
|
|
|
- string strFileSavePath = utility.ConfigHelper.GetSectionValue("IPEasySetting:DownloadFileSavePath");
|
|
|
-
|
|
|
- int tryCount = 0;
|
|
|
-
|
|
|
- string[] ReportNames =new string[] { "每月绩效统计--专案进度跟踪~S卷", "每月绩效统计--专案开卷报表~S卷" };
|
|
|
-
|
|
|
- List<PerformanceItem> pfItems = new List<PerformanceItem>();
|
|
|
- foreach (var ReportName in ReportNames)
|
|
|
- {
|
|
|
- tryAgain:
|
|
|
- try
|
|
|
- {
|
|
|
- wispro.sp.utility.IPEasyUtility.DownloadReport(ReportName, false);
|
|
|
- }
|
|
|
- catch
|
|
|
- {
|
|
|
- tryCount++;
|
|
|
-
|
|
|
- if (tryCount < 5)
|
|
|
- {
|
|
|
- goto tryAgain;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- System.Threading.Thread.Sleep(5000);
|
|
|
- string filename = $"{ReportName.Trim().Replace("~","_")}.xlsx";
|
|
|
- string strFilePath = System.IO.Path.Combine(strFileSavePath, filename);
|
|
|
- string strFinalPath = System.IO.Path.Combine(strFileSavePath, $"{calMonth.Year}{calMonth.Month}-{filename}");
|
|
|
-
|
|
|
- if (System.IO.File.Exists(strFilePath))
|
|
|
- {
|
|
|
-
|
|
|
- var Items = GetProjectItem(strFilePath, calMonth, ReportName.Contains("专案开卷报表"));
|
|
|
-
|
|
|
-
|
|
|
- foreach (var item in Items)
|
|
|
- {
|
|
|
- var temObj = pfItems.FirstOrDefault<PerformanceItem>(s => s.CaseNo == item.CaseNo);
|
|
|
- if (temObj == null)
|
|
|
- {
|
|
|
- item.Type = "专案";
|
|
|
- pfItems.Add(item);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- try
|
|
|
- {
|
|
|
- System.IO.File.Move(strFilePath, strFinalPath);
|
|
|
- }
|
|
|
- catch { }
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- tryCount++;
|
|
|
-
|
|
|
- if (tryCount < 5)
|
|
|
- {
|
|
|
- goto tryAgain;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //List<BasePointRule> rules = spDb.BasePointRules.ToList<BasePointRule>();
|
|
|
- foreach (var item in pfItems)
|
|
|
- {
|
|
|
- SaveProjectItem(item);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private void SaveProjectItem(PerformanceItem item)
|
|
|
- {
|
|
|
- var temObj = spDb.ProjectInfos.FirstOrDefault(p=>p.CaseNo == item.CaseNo);
|
|
|
-
|
|
|
- if (temObj == null)
|
|
|
- {
|
|
|
- ProjectInfo project = new ProjectInfo();
|
|
|
- project.CaseNo = item.CaseNo;
|
|
|
- project.CaseName = item.CaseName;
|
|
|
- project.BusinessType = item.BusinessType;
|
|
|
-
|
|
|
-
|
|
|
- if(item.Customer != null)
|
|
|
- {
|
|
|
- var temCustomer = spDb.Customers.FirstOrDefault(c => c.Name == item.Customer.Name);
|
|
|
- if(temCustomer != null)
|
|
|
- {
|
|
|
- project.CustomerId = temCustomer.Id;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- project.CaseState = 0;
|
|
|
- project.CaseType = item.CaseType;
|
|
|
-
|
|
|
- project.ReviewerId = item.ReviewerId;
|
|
|
- project.WorkflowUserId = item.WorkflowUserId;
|
|
|
-
|
|
|
- spDb.ProjectInfos.Add(project);
|
|
|
- }
|
|
|
-
|
|
|
- spDb.SaveChanges();
|
|
|
- }
|
|
|
-
|
|
|
- private List<PerformanceItem> GetProjectItem(string strPath,CalMonth calMonth,bool isOpenSheet)
|
|
|
- {
|
|
|
- DataTable dt = NPOIExcel.ExcelToDataTable(strPath, true, true, 1);
|
|
|
- return GetProjectItem(calMonth, isOpenSheet, dt);
|
|
|
- }
|
|
|
-
|
|
|
- private List<PerformanceItem> GetProjectItem(CalMonth calMonth, bool isOpenSheet, DataTable dt)
|
|
|
- {
|
|
|
- #region 删除重复行
|
|
|
- DataTable temdt = new DataTable();
|
|
|
- foreach (DataColumn col in dt.Columns)
|
|
|
- {
|
|
|
-
|
|
|
- DataColumn temCol = new DataColumn();
|
|
|
- temCol.ColumnName = col.ColumnName;
|
|
|
- temCol.DataType = col.DataType;
|
|
|
- temCol.Caption = col.Caption;
|
|
|
-
|
|
|
- temdt.Columns.Add(temCol);
|
|
|
- }
|
|
|
-
|
|
|
- new ExcelHelper().MerageDataTable(temdt, dt);
|
|
|
- #endregion
|
|
|
-
|
|
|
- List<PerformanceItem> Items = new List<PerformanceItem>();
|
|
|
- int iRow = 0;
|
|
|
- foreach (DataRow row in temdt.Rows)
|
|
|
- {
|
|
|
- string strDebug = $"{++iRow}\t{row["我方文号"]}";
|
|
|
- PerformanceItem item = null;
|
|
|
- if (!isOpenSheet)
|
|
|
- {
|
|
|
- item = Row2Item_2(row, calMonth);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- item = Row2Item_3(row, calMonth);
|
|
|
- }
|
|
|
-
|
|
|
- if (item != null)
|
|
|
- {
|
|
|
- item.CalMonth = calMonth;
|
|
|
- item.CalMonthId = calMonth.Id;
|
|
|
- Items.Add(item);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return Items;
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
private Task InputPerformanceItem(string strExcelFile, bool isColumnName, bool ignorHideRows = false, int ColumnNameRow = 0, CalMonth calMonth = null, bool isFirstOAFile = false)
|
|
|
{
|
|
|
DataTable dt = NPOIExcel.ExcelToDataTable(strExcelFile, isColumnName, ignorHideRows, ColumnNameRow);
|
|
@@ -457,235 +217,7 @@ namespace wispro.sp.api.Job
|
|
|
return Task.CompletedTask;
|
|
|
}
|
|
|
|
|
|
- private PerformanceItem Row2Item_3(DataRow row, CalMonth calMonth)
|
|
|
- {
|
|
|
- PerformanceItem item = new PerformanceItem();
|
|
|
-
|
|
|
- item.CaseNo = row["我方文号"].ToString().Trim();
|
|
|
- item.CaseName = row["案件名称"].ToString().Trim();
|
|
|
- item.CaseType = row["案件类型"].ToString().Trim();
|
|
|
- item.BusinessType = row["业务类型"].ToString().Trim();
|
|
|
- item.Customer = new Customer();
|
|
|
- item.Customer.Name = row["客户名称"].ToString().Trim();
|
|
|
- item.CaseState = row["案件状态"].ToString().Trim();
|
|
|
-
|
|
|
- DateTime temDate = new DateTime();
|
|
|
- if (DateTime.TryParse(row["委案日期"].ToString().Trim(), out temDate))
|
|
|
- {
|
|
|
- item.EntrustingDate = temDate;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- string strHandler = "";
|
|
|
- if (row.Table.Columns.Contains("处理人"))
|
|
|
- {
|
|
|
- strHandler = row["处理人"].ToString().Trim();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (row.Table.Columns.Contains("案件处理人"))
|
|
|
- {
|
|
|
- strHandler = row["案件处理人"].ToString().Trim();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- string[] temHandlers = strHandler.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
- item.ItemStaffs = new List<ItemStaff>();
|
|
|
-
|
|
|
- foreach (string name in temHandlers)
|
|
|
- {
|
|
|
- ItemStaff itemStaff = new ItemStaff();
|
|
|
- string temName = name.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
|
|
|
-
|
|
|
- if (!name.Contains("君龙"))
|
|
|
- {
|
|
|
- temName = name.Trim();
|
|
|
- }
|
|
|
-
|
|
|
- int? iTem = GetStaff(name);
|
|
|
- if ((iTem != null))
|
|
|
- {
|
|
|
- //itemStaff.Item = item;
|
|
|
- itemStaff.DoPersonId = iTem.Value;
|
|
|
- item.ItemStaffs.Add(itemStaff);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- itemStaff.DoPerson = new Staff()
|
|
|
- {
|
|
|
- Name = temName,
|
|
|
- Account = temName,
|
|
|
- Password = "12345678",
|
|
|
- IsCalPerformsnce = false,
|
|
|
- Status = "试用期",
|
|
|
- StaffGradeId = 4
|
|
|
- };
|
|
|
- item.ItemStaffs.Add(itemStaff);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (item.ItemStaffs.Count == 0)
|
|
|
- {
|
|
|
- System.Diagnostics.Debug.WriteLine($"没有处理人: {item.CaseNo}\t{item.DoItem}");
|
|
|
- }
|
|
|
-
|
|
|
- if (row.Table.Columns.Contains("核稿人"))
|
|
|
- {
|
|
|
- item.ReviewerId = GetStaff(row["核稿人"].ToString().Trim());
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (row.Table.Columns.Contains("案件核稿人"))
|
|
|
- {
|
|
|
- item.ReviewerId = GetStaff(row["案件核稿人"].ToString().Trim());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (row.Table.Columns.Contains("业务人员"))
|
|
|
- {
|
|
|
- item.WorkflowUserId = GetStaff(row["业务人员"].ToString().Trim());
|
|
|
- }
|
|
|
-
|
|
|
- if (row.Table.Columns.Contains("国家(地区)"))
|
|
|
- {
|
|
|
- item.Country = row["国家(地区)"].ToString().Trim();
|
|
|
- }
|
|
|
-
|
|
|
- return item;
|
|
|
- }
|
|
|
- private PerformanceItem Row2Item_2(DataRow row, CalMonth calMonth)
|
|
|
- {
|
|
|
- PerformanceItem item = new PerformanceItem();
|
|
|
-
|
|
|
- item.CaseNo = row["我方文号"].ToString().Trim();
|
|
|
- item.CaseName= row["案件名称"].ToString().Trim();
|
|
|
- item.CaseType = row["案件类型"].ToString().Trim();
|
|
|
- item.BusinessType= row["业务类型"].ToString().Trim();
|
|
|
- item.Customer = new Customer();
|
|
|
- item.Customer.Name = row["客户名称"].ToString().Trim();
|
|
|
- item.CaseState = row["案件状态"].ToString().Trim();
|
|
|
- item.DoItem = row["处理事项"].ToString().Trim();
|
|
|
-
|
|
|
- if (row.Table.Columns.Contains("国家(地区)"))
|
|
|
- {
|
|
|
- item.Country = row["国家(地区)"].ToString().Trim();
|
|
|
- }
|
|
|
-
|
|
|
- DateTime temDate = new DateTime();
|
|
|
- if (DateTime.TryParse(row["内部期限"].ToString().Trim(), out temDate))
|
|
|
- {
|
|
|
- item.InternalDate = temDate;
|
|
|
- }
|
|
|
-
|
|
|
- if (DateTime.TryParse(row["客户期限"].ToString().Trim(), out temDate))
|
|
|
- {
|
|
|
- item.CustomerLimitDate = temDate;
|
|
|
- }
|
|
|
-
|
|
|
- if (DateTime.TryParse(row["初稿日"].ToString().Trim(), out temDate))
|
|
|
- {
|
|
|
- item.FirstDraftDate = temDate;
|
|
|
- }
|
|
|
-
|
|
|
- if (DateTime.TryParse(row["定稿日"].ToString().Trim(), out temDate))
|
|
|
- {
|
|
|
- item.FinalizationDate = temDate;
|
|
|
- }
|
|
|
-
|
|
|
- if (DateTime.TryParse(row["委案日期"].ToString().Trim(), out temDate))
|
|
|
- {
|
|
|
- item.EntrustingDate = temDate;
|
|
|
- }
|
|
|
-
|
|
|
- if (DateTime.TryParse(row["处理事项完成日"].ToString().Trim(), out temDate))
|
|
|
- {
|
|
|
- item.FinishedDate = temDate;
|
|
|
- }
|
|
|
-
|
|
|
- item.DoItemState = row["处理状态"].ToString().Trim();
|
|
|
-
|
|
|
- string strHandler = "";
|
|
|
- if (row.Table.Columns.Contains("处理人"))
|
|
|
- {
|
|
|
- strHandler = row["处理人"].ToString().Trim();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (row.Table.Columns.Contains("案件处理人"))
|
|
|
- {
|
|
|
- strHandler = row["案件处理人"].ToString().Trim();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- string[] temHandlers = strHandler.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
- item.ItemStaffs = new List<ItemStaff>();
|
|
|
-
|
|
|
- foreach (string name in temHandlers)
|
|
|
- {
|
|
|
- ItemStaff itemStaff = new ItemStaff();
|
|
|
- string temName = name.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
|
|
|
- if (!name.Contains("君龙"))
|
|
|
- {
|
|
|
- temName = name.Trim();
|
|
|
- }
|
|
|
- int? iTem = GetStaff(temName);
|
|
|
- if ((iTem != null))
|
|
|
- {
|
|
|
- //itemStaff.Item = item;
|
|
|
- itemStaff.DoPersonId = iTem.Value;
|
|
|
- item.ItemStaffs.Add(itemStaff);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- itemStaff.DoPerson = new Staff()
|
|
|
- {
|
|
|
- Name = temName,
|
|
|
- Account = temName,
|
|
|
- Password = "12345678",
|
|
|
- IsCalPerformsnce = false,
|
|
|
- Status = "试用期",
|
|
|
- StaffGradeId = 4
|
|
|
- };
|
|
|
- item.ItemStaffs.Add(itemStaff);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (item.ItemStaffs.Count == 0)
|
|
|
- {
|
|
|
- System.Diagnostics.Debug.WriteLine($"没有处理人: {item.CaseNo}\t{item.DoItem}");
|
|
|
- }
|
|
|
-
|
|
|
- if (row.Table.Columns.Contains("核稿人"))
|
|
|
- {
|
|
|
- item.ReviewerId = GetStaff(row["核稿人"].ToString().Trim());
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (row.Table.Columns.Contains("案件核稿人"))
|
|
|
- {
|
|
|
- item.ReviewerId = GetStaff(row["案件核稿人"].ToString().Trim());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (row.Table.Columns.Contains("业务人员"))
|
|
|
- {
|
|
|
- if (!string.IsNullOrEmpty(row["业务人员"].ToString().Trim()))
|
|
|
- {
|
|
|
- string name = row["业务人员"].ToString().Trim();
|
|
|
- string temName = name.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
|
|
|
- if (!name.Contains("君龙"))
|
|
|
- {
|
|
|
- temName = name.Trim();
|
|
|
- }
|
|
|
- item.WorkflowUserId = GetStaff(temName);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- return item;
|
|
|
- }
|
|
|
+
|
|
|
private PerformanceItem Row2Item_1(DataRow row, CalMonth calMonth)
|
|
|
{
|
|
|
PerformanceItem item = new PerformanceItem();
|
|
@@ -1390,13 +922,8 @@ namespace wispro.sp.api.Job
|
|
|
inner join c_customer with(nolock) on c_customer.customer_id=p_case_info.customer_id
|
|
|
inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id
|
|
|
inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id
|
|
|
- where p_case_info.is_enabled=1 and
|
|
|
- (p_case_info.business_type_id='ad0d4c8f-7c2d-4cbf-a5b4-cc1a64d4c384'
|
|
|
- or p_case_info.business_type_id='20184cc4-1dd8-4d5b-81bd-4b39ca3700f4'
|
|
|
- or p_case_info.business_type_id='94713100-f013-4444-a5a1-1dd1b78d8cdf'
|
|
|
- or p_case_info.business_type_id='f2d4d629-b7a5-4fa5-888d-91029ce7a3f5'
|
|
|
- or p_case_info.business_type_id='32144fb3-2ce0-4ed9-ae6f-a6a09fb66e60') AND
|
|
|
- (DATEDIFF(dd,p_case_info.create_time,getdate())<='31') ";
|
|
|
+ where p_case_info.is_enabled=1 p_case_info.is_enabled=1 and p_case_info.case_volume like 'S%' and not p_case_info.case_volume like 'SC%'
|
|
|
+ and i_case_status.case_status_zh_cn<>'已完成' and i_case_status.case_status_zh_cn<>'结案'";
|
|
|
break;
|
|
|
}
|
|
|
|