1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003 |
- using DynamicExpresso;
- using Microsoft.Extensions.DependencyInjection;
- using Quartz;
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Data;
- using System.Linq;
- using System.Threading.Tasks;
- using wispro.sp.entity;
- using wispro.sp.utility;
- namespace wispro.sp.api.Job
- {
- public class ImportReportJob : Quartz.IJob
- {
-
- /// <summary>
- /// 不需要计算绩效的处理事项
- /// </summary>
- private string[] InValidDoItem = new string[]
- {
- "案件异常-催缴年费",
- "案件异常-视为放弃取得专利权",
- "办理登记手续",
- "办理登记手续-确认客户是否委托",
- "代理所变更",
- "绘图",
- "技术确认",
- "缴年费",
- "请求保密审查",
- "请求费减",
- "请求实审",
- "取得申请号",
- "取得证书",
- "取得专利权评价报告",
- "确认官方审查状况",
- "询问放弃或复审",
- "知识点总结",
- "专利权人发明人申请人信息变更",
- "专利挖掘与布局",
- "我方文号前缀带J",
- "开卷",
- "请求提前公开",
- "取得国际检索报告",
- "委外检索",
- "中止程序",
- "终止",
- "案件异常-视为撤回",
- "进入国家阶段提醒",
- "请求恢复权利",
- "请求优先权",
- "取得【无效宣告请求审查决定】",
- "撤回",
- "请求退款",
- "确认是否委托申请与类型",
- "专利交易",
- "专利权评价报告",
- "专利权人发明人申请人信息变更+代理所变更"
- };
-
- spDbContext spDb = new spDbContext();
-
-
- public Task Execute(IJobExecutionContext context)
- {
- CalMonth calMonth = new CalMonth()
- {
- Year = DateTime.Now.AddMonths(-1).Year,
- Month = DateTime.Now.AddMonths(-1).Month,
- Status = 0
- };
- var temCalMonth = spDb.CalMonths.Where<CalMonth>(x => x.Year == calMonth.Year && x.Month == calMonth.Month).FirstOrDefault();
- if (temCalMonth != null)
- {
-
- var iCount = spDb.PerformanceItems.Where<PerformanceItem>(p => p.CalMonthId == temCalMonth.Id).Count<PerformanceItem>();
- if (iCount > 0)
- {
- return Task.CompletedTask;
- }
- calMonth = temCalMonth;
- }
- else
- {
- spDb.CalMonths.Add(calMonth);
- spDb.SaveChanges();
- }
- //每月绩效统计--发客户超过一个月未完成案件
- DownloadReport( "每月绩效统计--发客户超过一个月未完成案件", calMonth,false);
-
- //每月绩效统计--上个月递交完成案件
- DownloadReport("每月绩效统计--上个月递交完成案件", calMonth, true);
-
- //每月绩效统计--中国一次OA授权表
- DownloadReport("每月绩效统计--中国一次OA授权表", calMonth, true,true);
- //专案数据
- DownloadProject(calMonth);
- return Task.CompletedTask;
- }
- 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);
-
- InputPerformanceItem(strFilePath, true, false, 1, calMonth, isFirstOA);
- System.IO.File.Move(strFilePath, strFinalPath);
- }
- 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}");
- 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);
- }
- }
- System.IO.File.Move(strFilePath, strFinalPath);
- }
- //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);
- #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);
- #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<BasePointRule> rules = spDb.BasePointRules.ToList<BasePointRule>();
- int iRow = 0;
- foreach (DataRow row in temdt.Rows)
- {
- string strDebug = $"{++iRow}\t{row["我方文号"]}";
- PerformanceItem item = null;
- if (isFirstOAFile)
- {
- item = Row2Item_1(row, calMonth);
- }
- else
- {
- item = Row2Item(row, calMonth);
- }
- if (item != null)
- {
- if (!InValidDoItem.Contains(item.DoItem) && !isDBNotFinishedDate(item))
- {
- //foreach(var temObj in item.ItemStaffs)
- //{
- // temObj.DoPerson.Name = temObj.DoPerson.Name.Replace("-君龙", "");
- //}
- SavePerformanceItem(item, rules);
-
- strDebug = $"{strDebug}\t保存成功";
- }
- else
- {
- strDebug = $"{strDebug}\t无效处理事项";
- }
- }
- else
- {
- strDebug = $"{strDebug}\t转换Item为Null";
- }
- System.Diagnostics.Debug.WriteLine(strDebug);
- }
- return Task.CompletedTask;
- }
- private bool isDBNotFinishedDate(PerformanceItem item)
- {
- return (item.DoItem == "处理审查意见" && item.FinishedDate == null);
- }
- private Task SavePerformanceItem(PerformanceItem item,List<BasePointRule> rules)
- {
- try
- {
- Utility.Utility.CalBasePoint(item, rules);
- var ret= new Controllers.PerformanceItemController(spDb,new Services.FileTaskCacheService()).New(item);
- if (ret.Success == false)
- {
- System.Diagnostics.Debug.WriteLine(ret.ErrorMessage);
- }
- }
- catch (Exception ex)
- {
- System.Diagnostics.Debug.WriteLine(ex.Message);
- }
- 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();
- item.ApplicationType = row["申请类型"].ToString().Trim();
- if (item.ApplicationType != "发明")
- {
- return null;
- }
- item.CaseNo = row["我方文号"].ToString().Trim();
- if (item.CaseNo.StartsWith("S"))
- {
- return null;
- }
-
- if (calMonth != null)
- {
- item.CalMonth = calMonth;
- }
- else
- {
- if (row.Table.Columns.Contains("绩效核算月份"))
- {
- string strjxyf = row["绩效核算月份"].ToString().Trim();
- string[] temYFs = strjxyf.Split(new char[] { '.' });
- item.CalMonth = new CalMonth();
- item.CalMonth.Year = int.Parse(temYFs[0]);
- item.CalMonth.Month = int.Parse(temYFs[1]);
- item.CalMonth.Status = 4;
- }
- else
- {
- item.CalMonth = new CalMonth();
- item.Status = 0;
- item.CalMonth.Year = DateTime.Now.AddMonths(-1).Year;
- item.CalMonth.Month = DateTime.Now.AddMonths(-1).Month;
- }
- }
- item.ApplicationType = row["申请类型"].ToString().Trim();
- item.BusinessType = "普通新申请"; // row["业务类型"].ToString().Trim();
- item.AgentFeedbackMemo = "发明一次OA授权"; //row["备注(填表注意事项)"].ToString().Trim();
- item.DoItem = "发明一次OA授权"; //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();
- string temName = row["业务人员"].ToString().Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
- if (!name.Contains("君龙"))
- {
- temName = name.Trim();
- }
- item.WorkflowUserId = GetStaff(temName);
- }
- }
- item.Customer = new Customer() { Name = row["客户名称"].ToString().Trim() };
- item.ApplicationName = row["申请人"].ToString().Trim();
- item.CaseName = row["案件名称"].ToString().Trim();
- if (row.Table.Columns.Contains("国家(地区)"))
- {
- item.Country = row["国家(地区)"].ToString().Trim();
- }
- //案件备注
- item.CaseMemo = $"发文日期:{row["发文日期"].ToString().Trim()}\r\n客户文号:{row["客户文号"].ToString().Trim()}\r\n上传日期:{row["上传日期"].ToString().Trim()}\r\n文件描述:{row["文件描述"].ToString().Trim()}";
-
- if (row.Table.Columns.Contains("翻译字数"))
- {
- //item.ReviewerId = GetStaff(row["案件核稿人"].ToString().Trim());
- var strWordCount = row["翻译字数"].ToString().Trim();
- if (string.IsNullOrEmpty(strWordCount))
- {
- try
- {
- item.WordCount = int.Parse(strWordCount);
- }
- catch { }
-
- }
- }
- return item;
- }
- private PerformanceItem Row2Item(DataRow row, CalMonth calMonth)
- {
- PerformanceItem item = new PerformanceItem();
- item.CaseNo = row["我方文号"].ToString().Trim();
- if (item.CaseNo.StartsWith("S"))
- {
- return null;
- }
- if (calMonth != null)
- {
- item.CalMonth = calMonth;
- }
- else
- {
- if (row.Table.Columns.Contains("绩效核算月份"))
- {
- string strjxyf = row["绩效核算月份"].ToString().Trim();
- string[] temYFs = strjxyf.Split(new char[] { '.' });
- item.CalMonth = new CalMonth();
- item.CalMonth.Year = int.Parse(temYFs[0]);
- item.CalMonth.Month = int.Parse(temYFs[1]);
- item.CalMonth.Status = 4;
- }
- else
- {
- item.CalMonth = new CalMonth();
- item.Status = 0;
- item.CalMonth.Year = DateTime.Now.AddMonths(-1).Year;
- item.CalMonth.Month = DateTime.Now.AddMonths(-1).Month;
- }
- }
- item.ApplicationType = row["申请类型"].ToString().Trim();
- item.BusinessType = row["业务类型"].ToString().Trim();
- if (row.Table.Columns.Contains("国家(地区)"))
- {
- item.Country = row["国家(地区)"].ToString().Trim();
- }
- if (row.Table.Columns.Contains("备注(填表注意事项)"))
- item.AgentFeedbackMemo = row["备注(填表注意事项)"].ToString().Trim();
- item.DoItem = row["处理事项"].ToString().Trim();
- item.CaseStage = row["案件阶段"].ToString().Trim();
- item.CaseCoefficient = row["案件系数"].ToString().Trim();
- item.DoItemCoefficient = row["处理事项系数"].ToString().Trim();
- item.PreOastaffId = GetStaff(row["前一次OA处理人"].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("核稿人"))
- {
- if (!string.IsNullOrEmpty(row["核稿人"].ToString().Trim()))
- {
- string name = row["核稿人"].ToString();
- string temName = name.Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
- if (!name.Contains("君龙"))
- {
- temName = name.Trim();
- }
- item.ReviewerId = GetStaff(temName);
- }
- }
- else
- {
- if (row.Table.Columns.Contains("案件核稿人"))
- {
- if (!string.IsNullOrEmpty(row["案件核稿人"].ToString().Trim()))
- {
- string name = row["案件核稿人"].ToString();
- string temName = row["案件核稿人"].ToString().Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
- if (!name.Contains("君龙"))
- {
- temName = name.Trim();
- }
- item.ReviewerId = GetStaff(temName);
- }
- }
- }
- if (row.Table.Columns.Contains("业务人员"))
- {
- if (!string.IsNullOrEmpty(row["业务人员"].ToString().Trim()))
- {
- string name = row["业务人员"].ToString();
- string temName = row["业务人员"].ToString().Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
- if (!name.Contains("君龙"))
- {
- temName = name.Trim();
- }
- item.WorkflowUserId = GetStaff(temName);
- }
- }
- item.Customer = new Customer() { Name = row["客户名称"].ToString().Trim() };
- item.ApplicationName = row["申请人"].ToString().Trim();
- DateTime temDate = new DateTime();
- if (DateTime.TryParse(row["处理事项完成日"].ToString().Trim(), out temDate))
- {
- item.FinishedDate = temDate;
- }
- //定稿日
- if (DateTime.TryParse(row["定稿日"].ToString().Trim(), out temDate))
- {
- item.FinalizationDate = temDate;
- }
- //返稿日
- if (DateTime.TryParse(row["返稿日"].ToString().Trim(), out temDate))
- {
- item.ReturnDate = temDate;
- }
- //案件类型
- item.CaseType = row["案件类型"].ToString().Trim();
- //案件状态
- item.CaseState = row["案件状态"].ToString().Trim();
- //处理事项备注
- item.DoItemMemo = row["处理事项备注"].ToString().Trim();
- //处理状态
- item.DoItemState = row["处理状态"].ToString().Trim();
- //案件名称
- item.CaseName = row["案件名称"].ToString().Trim();
- //委案日期
- if (DateTime.TryParse(row["委案日期"].ToString().Trim(), out temDate))
- {
- item.EntrustingDate = temDate;
- }
- //客户期限
- if (DateTime.TryParse(row["客户期限"].ToString().Trim(), out temDate))
- {
- item.CustomerLimitDate = temDate;
- }
- //内部期限
- if (DateTime.TryParse(row["内部期限"].ToString().Trim(), out temDate))
- {
- item.InternalDate = temDate;
- }
- //初稿日
- if (DateTime.TryParse(row["初稿日"].ToString().Trim(), out temDate))
- {
- item.FirstDraftDate = temDate;
- }
- //备注(发文严重超期是否属客观原因,若为否,请填写原因)
- if (row.Table.Columns.Contains("备注(发文严重超期是否属客观原因,若为否,请填写原因)"))
- {
- item.OverDueMemo = row["备注(发文严重超期是否属客观原因,若为否,请填写原因)"].ToString().Trim();
- }
- //案件备注
- item.CaseMemo = row["案件备注"].ToString().Trim();
- if (row.Table.Columns.Contains("翻译字数"))
- {
- //item.ReviewerId = GetStaff(row["案件核稿人"].ToString().Trim());
- var strWordCount = row["翻译字数"].ToString().Trim();
- if (string.IsNullOrEmpty(strWordCount))
- {
- try
- {
- item.WordCount = int.Parse(strWordCount);
- }
- catch { }
- }
- }
- return item;
- }
- private int? GetStaff(string v)
- {
- if (!string.IsNullOrEmpty(v))
- {
- string temName = v.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
- if (!v.Contains("君龙"))
- {
- temName = v;
- }
- var staff = spDb.Staffs.Where<Staff>(s => s.Name == temName).FirstOrDefault();
- if (staff != null)
- {
- return staff.Id;
- }
- }
- return null;
- }
- }
- }
|