1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075 |
- using DynamicExpresso;
- using Microsoft.Data.SqlClient;
- using Microsoft.Extensions.DependencyInjection;
- using NPOI.SS.Formula.Functions;
- using Quartz;
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Data;
- using System.IO;
- using System.Linq;
- using System.Net.Http;
- using System.Threading.Tasks;
- using System.Xml.Serialization;
- using wispro.sp.entity;
- using wispro.sp.utility;
- using static System.Net.WebRequestMethods;
- namespace wispro.sp.api.Job
- {
- public class ImportReportJob : Quartz.IJob
- {
-
- /// <summary>
- /// 不需要计算绩效的处理事项
- /// </summary>
- private string[] InValidDoItem = new string[]
- {
- "案件异常-催缴年费",
- "案件异常-视为放弃取得专利权",
- "办理登记手续",
- "办理登记手续-确认客户是否委托",
- "代理所变更",
- "绘图",
- "技术确认",
- "缴年费",
- "请求保密审查",
- "请求费减",
- "请求实审",
- "取得申请号",
- "取得证书",
- "取得专利权评价报告",
- "确认官方审查状况",
- "询问放弃或复审",
- "知识点总结",
- "专利权人发明人申请人信息变更",
- "专利挖掘与布局",
- "我方文号前缀带J",
- "开卷",
- "请求提前公开",
- "取得国际检索报告",
- "委外检索",
- "中止程序",
- "终止",
- "案件异常-视为撤回",
- "进入国家阶段提醒",
- "请求恢复权利",
- "请求优先权",
- "取得【无效宣告请求审查决定】",
- "撤回",
- "请求退款",
- "确认是否委托申请与类型",
- "专利交易",
- "专利权评价报告",
- "专利权人发明人申请人信息变更+代理所变更",
- "补缴费用"
- };
-
- spDbContext spDb = new spDbContext();
-
- public Task ImportData(int i)
- {
- 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>();
- calMonth = temCalMonth;
- }
- else
- {
- spDb.CalMonths.Add(calMonth);
- spDb.SaveChanges();
- }
- switch (i)
- {
- case 0:
- DownloadReport_SQL("每月绩效统计--发客户超过一个月未完成案件", calMonth, false);
- break;
- case 1:
- DownloadReport_SQL("每月绩效统计--上个月递交完成案件", calMonth, true);
- break;
- case 2:
- DownloadReport_SQL("每月绩效统计--中国一次OA授权表", calMonth, true, true);
- break;
- }
- return Task.CompletedTask;
- }
-
- 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);
- 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 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)
- {
- if(dt == null)
- {
- return Task.CompletedTask;
- }
- #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(new spDbContext(),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_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();
- }
- 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 = utility.MD5Utility.GetMD5("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 = utility.MD5Utility.GetMD5("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)
- {
- try
- {
- return wispro.sp.utility.IPEasyUtility.DownloadReport(ReportName, isModifyDate);
- }
- catch {
- return null;
- }
- #region 利用维德系统服务器上的API获取
- // int iTry = 0;
- //tryAgain:
- // try
- // {
-
- // HttpClient http = new HttpClient();
- // var bytRespon = http.GetAsync($"{ConfigHelper.GetSectionValue("IPEasySetting:ipEeasyApi")}/api/ipEasy/GetDataFromIPEasy?ReportName={ReportName}&isModifyDate={isModifyDate}").Result;
- // if (bytRespon.IsSuccessStatusCode)
- // {
- // string result = bytRespon.Content.ReadAsStringAsync().Result.Replace("\"", string.Empty);
- // byte[] data = Convert.FromBase64String(result);
- // //byte[] data = bytRespon.Content.ReadAsByteArrayAsync().Result;//Here is the problem
- // XmlSerializer serializer = new XmlSerializer(typeof(System.Data.DataTable));
- // MemoryStream memory = new MemoryStream(data);
- // DataTable dt = (DataTable)serializer.Deserialize(memory);
- // return dt;
- // }
- // else
- // {
- // if (iTry < 3)
- // {
- // iTry++;
- // goto tryAgain;
- // }
-
- // }
- // }
- // catch (Exception ex)
- // {
- // if (iTry < 3)
- // {
- // iTry++;
- // goto tryAgain;
- // }
- // }
- // return null;
- #endregion
- #region old code 从维德数据库中直接读取
- // 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.upload_time >= @beginTime and p_file_list.upload_time<@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 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;
- // }
- // 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;
- #endregion
- }
- }
- }
|