123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434 |
- using DynamicExpresso;
- using Microsoft.Data.SqlClient;
- 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_SQL("每月绩效统计--发客户超过一个月未完成案件", calMonth, false);
- //DownloadReport( "每月绩效统计--发客户超过一个月未完成案件", calMonth,false);
- //每月绩效统计--上个月递交完成案件
- DownloadReport_SQL("每月绩效统计--上个月递交完成案件", calMonth, true);
- //DownloadReport("每月绩效统计--上个月递交完成案件", calMonth, true);
- //每月绩效统计--中国一次OA授权表
- 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);
- InputPerformanctItem(calMonth, isFirstOA, data);
- }
- catch
- {
-
- }
- }
- 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);
- return InputPerformanctItem(calMonth, isFirstOAFile, dt);
- }
- private Task InputPerformanctItem(CalMonth calMonth, bool isFirstOAFile, 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<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;
- }
- private DataTable GetDataFromIPEasy(string ReportName, bool isModifyDate)
- {
- DataTable dt = new DataTable();
- string strSQL = "";
- switch (ReportName)
- {
- case "每月绩效统计--发客户超过一个月未完成案件":
- strSQL = @"SELECT p_case_info.case_volume as 我方文号,
- i_apply_type.apply_type_zh_cn as 申请类型,
- i_business_type.business_type_zh_cn as 业务类型,
- i_ctrl_proc.ctrl_proc_zh_cn as 处理事项,
- (select case_status_zh_cn from i_case_status where case_status_id=p_proc_info.review_stage) as 案件阶段,
- i_case_coefficient.case_coefficient_zh_cn as 案件系数,
- i_proc_coefficient.proc_coefficient_zh_cn as 处理事项系数,
- (select proc_coefficient_zh_cn from p_proc_info pr
- left join i_proc_coefficient pc on pc.proc_coefficient_id=pr.proc_coefficient_id
- where case_id=p_case_info.case_id and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'
- and pr.seq=
- (select max(seq) from p_proc_info pr where case_id=p_case_info.case_id
- and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'and seq<p_proc_info.seq)
- ) as 前一次OA处理事项系数,
- (STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
- inner join s_user_info as u on u.user_id = pl.pic_id
- inner join p_proc_info pr1 on pr1.proc_id=pl.obj_id
- where case_id=p_case_info.case_id and
- ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'
- and pr1.seq=(
- select max(seq) from p_proc_info pr2 where case_id=p_case_info.case_id
- and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'
- and seq<p_proc_info.seq) FOR XML PATH('') ),1,1,'')) as 前一次OA处理人,
- STUFF((SELECT ',' + ur.rank_zh_cn from p_proc_pic_list as pl
- inner join s_user_info as u on u.user_id = pl.pic_id
- left join i_user_rank ur on ur.rank_id=u.rank_id
- where pl.obj_id = p_proc_info.proc_id FOR XML PATH('') ),1,1,'') as 处理人等级,
- STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
- inner join s_user_info as u on u.user_id = pl.pic_id
- where pl.obj_id = p_proc_info.proc_id FOR XML PATH('') ),1,1,'') as 处理人,
- STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl
- inner join s_user_info as u on u.user_id = pl.revise_user_id
- where pl.obj_id = p_proc_info.proc_id FOR XML PATH('') ),1,1,'') as 核稿人,
- c_customer.customer_name as 客户名称,
- STUFF((SELECT ',' + a.applicant_name_cn from p_applicant_list as al
- inner join i_applicant as a on a.applicant_id = al.applicant_id
- where al.obj_id = p_case_info.case_id order by al.seq FOR XML PATH('') ),1,1,'') as 申请人,
- p_proc_info.finish_date as 处理事项完成日,
- p_proc_info.finish_doc_date as 定稿日,
- p_proc_info.back_date as 返稿日,
- i_case_type.case_type_zh_cn as 案件类型,
- i_case_status.case_status_zh_cn as 案件状态,
- p_proc_info.proc_note as 处理事项备注,
- (select proc_status_zh_cn from i_proc_status where proc_status_id=p_proc_info.proc_status_id) as 处理状态,
- p_case_info.case_name as 案件名称,
- p_case_info.charge_date as 委案日期,
- p_proc_info.cus_due_date as 客户期限,
- p_proc_info.int_due_date as 内部期限,
- p_proc_info.first_doc_date as 初稿日,
- p_case_info.remark as 案件备注,
- p_proc_info.translate_count as 翻译字数,
- STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl
- inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id
- where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员,
- i_country.country_zh_cn as '国家(地区)'
- from p_case_info
- inner join p_case_advance_info with(nolock) on p_case_info.case_id=p_case_advance_info.case_id
- inner join i_apply_type with(nolock) on i_apply_type.apply_type_id=p_case_info.apply_type_id
- inner join i_case_type with(nolock) on i_case_type.case_type_id=p_case_info.case_type_id
- inner join i_country with(nolock) on i_country.country_id=p_case_info.country_id
- inner join i_case_status with(nolock) on i_case_status.case_status_id=p_case_info.case_status_id
- inner join c_customer with(nolock) on c_customer.customer_id=p_case_info.customer_id
- left join i_case_coefficient on i_case_coefficient.case_coefficient_id=p_case_info.case_coefficient_id
- inner join p_proc_info with(nolock) on p_case_info.case_id=p_proc_info.case_id
- inner join i_ctrl_proc with(nolock) on p_proc_info.ctrl_proc_id=i_ctrl_proc.ctrl_proc_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
- left join p_proc_pic_list with(nolock) on p_proc_pic_list.obj_id=p_proc_info.proc_id
- left join s_user_info with(nolock) on s_user_info.user_id=p_proc_pic_list.pic_id
- left join i_proc_coefficient on i_proc_coefficient.proc_coefficient_id=p_proc_info.proc_coefficient_id
- where
- p_case_info.is_enabled=1 and p_proc_info.is_enabled=1 and
- s_user_info.dept_id not in ('60e09ee0-fcc7-446f-badc-af9973079fee','34d0e351-71dc-418f-9b6b-bcb67af62fed','599cbe0c-044e-4ffc-9411-96dd9019d8a6') and
- p_proc_info.finish_date is null
- and p_proc_info.back_date<DATEADD(MM,-1,DATEADD(MM, DATEDIFF(MM,0,getdate()), 0)) and
- (p_case_info.case_type_id='31D1A147-2931-43B5-94AE-B72B1525BA8A' ) AND
- ( i_ctrl_proc.ctrl_proc_zh_cn='新申请'
- or i_ctrl_proc.ctrl_proc_zh_cn='Non'
- or i_ctrl_proc.ctrl_proc_zh_cn='无效宣告'
- or i_ctrl_proc.ctrl_proc_zh_cn='意见陈述'
- or i_ctrl_proc.ctrl_proc_zh_cn='专利挖掘与布局'
- or i_ctrl_proc.ctrl_proc_zh_cn='处理审查意见'
- or i_ctrl_proc.ctrl_proc_zh_cn='Final'
- or i_ctrl_proc.ctrl_proc_zh_cn='复审通知意见陈述'
- or i_ctrl_proc.ctrl_proc_zh_cn='申復'
- or i_ctrl_proc.ctrl_proc_zh_cn='RCE'
- or i_ctrl_proc.ctrl_proc_zh_cn='翻译'
- or i_ctrl_proc.ctrl_proc_zh_cn='提出异议复审'
- or i_ctrl_proc.ctrl_proc_zh_cn='Advisory'
- or i_ctrl_proc.ctrl_proc_zh_cn='复审'
- or i_ctrl_proc.ctrl_proc_zh_cn='请求复审'
- or i_ctrl_proc.ctrl_proc_zh_cn='提出报告'
- or i_ctrl_proc.ctrl_proc_zh_cn='提出公众意见'
- or i_ctrl_proc.ctrl_proc_zh_cn='诉讼'
- or i_ctrl_proc.ctrl_proc_zh_cn='提出异议'
- or i_ctrl_proc.ctrl_proc_zh_cn='补充理由和证据'
- or i_ctrl_proc.ctrl_proc_zh_cn='无效分析'
- or i_ctrl_proc.ctrl_proc_zh_cn='无效答辩'
- )";
- break;
- case "每月绩效统计--上个月递交完成案件":
- strSQL = @"SELECT
- p_case_info.case_volume as 我方文号,
- i_apply_type.apply_type_zh_cn as 申请类型,
- i_business_type.business_type_zh_cn as 业务类型,
- i_ctrl_proc.ctrl_proc_zh_cn as 处理事项,
- (select case_status_zh_cn from i_case_status where case_status_id=p_proc_info.review_stage) as 案件阶段,
- i_case_coefficient.case_coefficient_zh_cn as 案件系数,
- i_proc_coefficient.proc_coefficient_zh_cn as 处理事项系数,
- (select
- proc_coefficient_zh_cn from p_proc_info pr
- left join i_proc_coefficient pc on pc.proc_coefficient_id=pr.proc_coefficient_id
- where case_id=p_case_info.case_id
- and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'
- and pr.seq=(select max(seq) from p_proc_info pr where case_id=p_case_info.case_id
- and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'and seq<p_proc_info.seq)
- ) as 前一次OA处理事项系数,
- (STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
- inner join s_user_info as u on u.user_id = pl.pic_id
- inner join p_proc_info pr1 on pr1.proc_id=pl.obj_id
- where case_id=p_case_info.case_id
- and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'
- and pr1.seq=(select max(seq) from p_proc_info pr2 where case_id=p_case_info.case_id
- and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5'and seq<p_proc_info.seq) FOR XML PATH('') ),1,1,'')
- ) as 前一次OA处理人,
- STUFF((SELECT ',' + ur.rank_zh_cn from p_proc_pic_list as pl
- inner join s_user_info as u on u.user_id = pl.pic_id
- left join i_user_rank ur on ur.rank_id=u.rank_id where pl.obj_id = p_proc_info.proc_id FOR XML PATH('') ),1,1,'') as 处理人等级,
- STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
- inner join s_user_info as u on u.user_id = pl.pic_id
- where pl.obj_id = p_proc_info.proc_id FOR XML PATH('') ),1,1,'') as 处理人,
- STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl
- inner join s_user_info as u on u.user_id = pl.revise_user_id
- where pl.obj_id = p_case_info.case_id FOR XML PATH('') ),1,1,'') as 案件核稿人,
- c_customer.customer_name as 客户名称,
- STUFF((SELECT ',' + a.applicant_name_cn from p_applicant_list as al
- inner join i_applicant as a on a.applicant_id = al.applicant_id
- where al.obj_id = p_case_info.case_id order by al.seq FOR XML PATH('') ),1,1,'') as 申请人,
- p_proc_info.finish_date as 处理事项完成日,
- p_proc_info.finish_doc_date as 定稿日,
- p_proc_info.back_date as 返稿日,
- i_case_type.case_type_zh_cn as 案件类型,
- i_case_status.case_status_zh_cn as 案件状态,
- p_proc_info.proc_note as 处理事项备注,
- (select proc_status_zh_cn from i_proc_status where proc_status_id=p_proc_info.proc_status_id) as 处理状态,
- p_case_info.case_name as 案件名称,
- p_case_info.charge_date as 委案日期,
- p_proc_info.cus_due_date as 客户期限,
- p_proc_info.int_due_date as 内部期限,
- p_proc_info.first_doc_date as 初稿日,
- p_case_info.remark as 案件备注,
- p_proc_info.translate_count as 翻译字数,
- STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl
- inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id
- where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员,
- i_country.country_zh_cn as '国家(地区)'
- from p_case_info
- inner join p_case_advance_info with(nolock) on p_case_info.case_id=p_case_advance_info.case_id
- inner join i_apply_type with(nolock) on i_apply_type.apply_type_id=p_case_info.apply_type_id
- inner join i_case_type with(nolock) on i_case_type.case_type_id=p_case_info.case_type_id
- inner join i_country with(nolock) on i_country.country_id=p_case_info.country_id
- inner join i_case_status with(nolock) on i_case_status.case_status_id=p_case_info.case_status_id
- inner join c_customer with(nolock) on c_customer.customer_id=p_case_info.customer_id
- left join i_case_coefficient on i_case_coefficient.case_coefficient_id=p_case_info.case_coefficient_id
- inner join p_proc_info with(nolock) on p_case_info.case_id=p_proc_info.case_id
- inner join i_ctrl_proc with(nolock) on p_proc_info.ctrl_proc_id=i_ctrl_proc.ctrl_proc_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
- left join p_proc_pic_list with(nolock) on p_proc_pic_list.obj_id=p_proc_info.proc_id
- left join s_user_info with(nolock) on s_user_info.user_id=p_proc_pic_list.pic_id
- left join i_proc_coefficient on i_proc_coefficient.proc_coefficient_id=p_proc_info.proc_coefficient_id
- where
- p_case_info.is_enabled=1
- and p_proc_info.is_enabled=1
- and s_user_info.dept_id not in ('60e09ee0-fcc7-446f-badc-af9973079fee','34d0e351-71dc-418f-9b6b-bcb67af62fed','599cbe0c-044e-4ffc-9411-96dd9019d8a6')
- and (p_case_info.case_type_id='31D1A147-2931-43B5-94AE-B72B1525BA8A' )
- AND ((p_proc_info.finish_date >= @beginTime and p_proc_info.finish_date<@endTime)) ";
- break;
- case "每月绩效统计--中国一次OA授权表":
- strSQL = @"select
- p_case_info.case_volume as 我方文号,
- p_case_info.case_name as 案件名称,
- p_case_info.app_no as 申请号,
- c_customer.customer_name as 客户名称,
- STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
- inner join s_user_info as u on u.user_id = pl.pic_id
- where pl.obj_id = p_case_info.case_id FOR XML PATH('') ),1,1,'') as 案件处理人,
- STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl
- inner join s_user_info as u on u.user_id = pl.revise_user_id
- where pl.obj_id = p_case_info.case_id FOR XML PATH('') ),1,1,'') as 案件核稿人,
- p_file_list.post_date as 发文日期,
- p_case_info.case_volume_customer as 客户文号,
- p_case_info.app_date as 申请日,
- i_country.country_zh_cn as '国家(地区)',
- STUFF((SELECT ',' + a.applicant_name_cn from p_applicant_list as al
- inner join i_applicant as a on a.applicant_id = al.applicant_id
- where al.obj_id = p_case_info.case_id order by al.seq FOR XML PATH('') ),1,1,'') as 申请人,
- p_file_list.upload_time as 上传日期,
- i_file_desc.file_desc_zh_cn as 文件描述,
- i_apply_type.apply_type_zh_cn as 申请类型,
- STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl
- inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id
- where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员
- from p_case_info
- inner join i_apply_type on p_case_info.apply_type_id=i_apply_type.apply_type_id
- inner join p_proc_info on p_case_info.case_id=p_proc_info.case_id
- inner join p_file_list on p_file_list.obj_id=p_proc_info.proc_id
- inner join i_file_desc on i_file_desc.file_desc_id=p_file_list.file_desc_id
- inner join c_customer on p_case_info.customer_id=c_customer.customer_id
- inner join i_country on i_country.country_id=p_case_info.country_id
- where
- p_case_info.is_enabled=1
- and p_proc_info.is_enabled=1 and p_case_info.country_id='CN'
- and p_file_list.file_desc_id='09800D39-D585-49F3-B9DE-50AC689DE9AB'
- and p_file_list.file_name not like '%.zip'
- and (select count(*) from p_proc_info where case_id=p_case_info.case_id and ctrl_proc_id='8b96378e-05a0-4a8d-b3d1-39af92fddaf5')=1
- and (p_case_info.case_type_id='31D1A147-2931-43B5-94AE-B72B1525BA8A' )
- AND ((p_file_list.post_date >= @beginTime and p_file_list.post_date<@endTime))";
- break;
- case "每月绩效统计--专案进度跟踪~S卷":
- strSQL = @"SELECT p_case_info.case_volume as 我方文号,
- p_case_info.case_name as 案件名称,
- i_case_type.case_type_zh_cn as 案件类型,
- i_business_type.business_type_zh_cn as 业务类型,
- i_country.country_zh_cn as '国家(地区)',
- c_customer.customer_name as 客户名称,
- s_dept_info.dept_full_name as 承办部门,
- i_case_status.case_status_zh_cn as 案件状态,
- i_ctrl_proc.ctrl_proc_zh_cn as 处理事项,
- p_proc_info.int_due_date as 内部期限,
- p_proc_info.cus_due_date as 客户期限,
- p_proc_info.legal_due_date as 官方期限,
- p_proc_info.finish_doc_date as 定稿日,
- STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
- inner join s_user_info as u on u.user_id = pl.pic_id where pl.obj_id = p_proc_info.proc_id
- FOR XML PATH('') ),1,1,'') as 处理人,
- p_case_info.charge_date as 委案日期,
- (select proc_status_zh_cn from i_proc_status where proc_status_id=p_proc_info.proc_status_id) as 处理状态,
- p_proc_info.first_doc_date as 初稿日,
- STUFF((SELECT ',' + u.cn_name from c_customer_user as cu
- inner join s_user_info as u on u.user_id = cu.user_id
- where cu.customer_id = p_case_info.customer_id FOR XML PATH('') ),1,1,'') as 流程负责人,
- p_proc_info.finish_date as 处理事项完成日,
- STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl
- inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id
- where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员
- from p_case_info
- inner join p_case_advance_info with(nolock) on p_case_info.case_id=p_case_advance_info.case_id
- inner join i_apply_type with(nolock) on i_apply_type.apply_type_id=p_case_info.apply_type_id
- inner join i_case_type with(nolock) on i_case_type.case_type_id=p_case_info.case_type_id
- inner join i_country with(nolock) on i_country.country_id=p_case_info.country_id
- inner join i_case_status with(nolock) on i_case_status.case_status_id=p_case_info.case_status_id
- inner join c_customer with(nolock) on c_customer.customer_id=p_case_info.customer_id
- inner join p_proc_info with(nolock) on p_case_info.case_id=p_proc_info.case_id
- inner join i_ctrl_proc with(nolock) on p_proc_info.ctrl_proc_id=i_ctrl_proc.ctrl_proc_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_proc_info.is_enabled=1 and
- (isnull (p_proc_info.finish_date,'') ='') AND (i_ctrl_proc.ctrl_proc_zh_cn='提出报告')";
- break;
- case "每月绩效统计--专案开卷报表~S卷":
- strSQL = @"SELECT p_case_info.case_volume as 我方文号,
- p_case_info.case_volume_customer as 客户文号,
- p_case_info.case_name as 案件名称,
- p_case_info.charge_date as 委案日期,
- i_case_status.case_status_zh_cn as 案件状态,
- i_case_type.case_type_zh_cn as 案件类型,
- p_case_info.app_no as 申请号,
- p_case_info.app_date as 申请日,
- i_business_type.business_type_zh_cn as 业务类型,
- STUFF((SELECT ',' + u.cn_name from c_customer_user as cu
- inner join s_user_info as u on u.user_id = cu.user_id where cu.customer_id = p_case_info.customer_id FOR XML PATH('') ),1,1,'') as 流程负责人,
- c_customer.customer_name as 客户名称,
- STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl
- inner join s_user_info as u on u.user_id = pl.revise_user_id where pl.obj_id = p_case_info.case_id FOR XML PATH('') ),1,1,'') as 案件核稿人,
- STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
- inner join s_user_info as u on u.user_id = pl.pic_id where pl.obj_id = p_case_info.case_id FOR XML PATH('') ),1,1,'') as 案件处理人,
- p_case_info.create_time as 开卷日期,
- STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl
- inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id
- where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员,
- i_country.country_zh_cn as '国家(地区)'
- from p_case_info
- inner join p_case_advance_info with(nolock) on p_case_info.case_id=p_case_advance_info.case_id
- inner join i_apply_type with(nolock) on i_apply_type.apply_type_id=p_case_info.apply_type_id
- inner join i_case_type with(nolock) on i_case_type.case_type_id=p_case_info.case_type_id
- inner join i_country with(nolock) on i_country.country_id=p_case_info.country_id
- inner join i_case_status with(nolock) on i_case_status.case_status_id=p_case_info.case_status_id
- 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') ";
- break;
- }
-
- using (var conn = new SqlConnection(ConfigHelper.GetSectionValue("IPEasySetting:ConnectionStrings")))
- {
- try
- {
- conn.Open();
- using (var cmd = conn.CreateCommand())
- {
- cmd.CommandText = strSQL;
- cmd.CommandType = CommandType.Text;
- if (isModifyDate)
- {
- cmd.Parameters.Add(new SqlParameter("beginTime", DateTime.Parse(DateTime.Now.AddMonths(-1).ToString("yyyy-MM") + "-01")));
- cmd.Parameters.Add(new SqlParameter("endTime", DateTime.Parse(DateTime.Now.ToString("yyyy-MM") + "-01")));
- }
- using (var reader = cmd.ExecuteReader())
- {
- dt.Load(reader);
- }
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- return dt;
- }
- }
- }
|