PerformanceItemController.cs 120 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832
  1. using DynamicExpresso;
  2. using Microsoft.AspNetCore.Authorization;
  3. using Microsoft.AspNetCore.Http;
  4. using Microsoft.AspNetCore.Mvc;
  5. using Microsoft.AspNetCore.StaticFiles;
  6. using Microsoft.EntityFrameworkCore;
  7. using Microsoft.Extensions.Caching.Memory;
  8. using Microsoft.Extensions.Hosting;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Data;
  12. using System.IO;
  13. using System.Linq;
  14. using System.Linq.Expressions;
  15. using System.Threading;
  16. using System.Threading.Tasks;
  17. using wispro.sp.api.Services;
  18. using wispro.sp.api.Utility;
  19. using wispro.sp.entity;
  20. using wispro.sp.share;
  21. using wispro.sp.utility;
  22. namespace wispro.sp.api.Controllers
  23. {
  24. [Route("api/[controller]/[action]")]
  25. [ApiController]
  26. [Authorize]
  27. public class PerformanceItemController : ControllerBase
  28. {
  29. spDbContext Context;
  30. IFileTaskService fileTaskService;
  31. public PerformanceItemController(spDbContext context, IFileTaskService _fileTaskService)
  32. {
  33. Context = context;
  34. fileTaskService = _fileTaskService;
  35. }
  36. public ApiSaveResponse RemoveDBNotFinishDate(int year,int month)
  37. {
  38. ApiSaveResponse ret = new ApiSaveResponse();
  39. ret.Success = true;
  40. var itemList = Context.PerformanceItems.Include(p=>p.ItemStaffs).Where(p => p.CalMonth.Year == year &&
  41. p.CalMonth.Month == month &&
  42. p.DoItem =="处理审查意见" &&
  43. p.FinishedDate ==null);
  44. using var t = Context.Database.BeginTransaction();
  45. try
  46. {
  47. foreach (var item in itemList.ToList())
  48. {
  49. if (item != null)
  50. {
  51. Context.ItemStaffs.RemoveRange(item.ItemStaffs);
  52. Context.PerformanceItems.Remove(item);
  53. }
  54. }
  55. Context.SaveChanges();
  56. t.Commit();
  57. return ret;
  58. }
  59. catch (Exception ex)
  60. {
  61. t.Rollback();
  62. ret.Success = false;
  63. ret.ErrorMessage = ex.Message;
  64. return ret;
  65. }
  66. }
  67. public bool IsExist(PerformanceItem item)
  68. {
  69. var results = Context.PerformanceItems.Where<PerformanceItem>(x =>
  70. x.CaseNo == item.CaseNo &&
  71. x.DoItem == item.DoItem &&
  72. x.CaseStage == item.CaseStage &&
  73. x.CalMonth.Year == item.CalMonth.Year &&
  74. x.CalMonth.Month == item.CalMonth.Month);
  75. if(results.Count() > 0)
  76. {
  77. return true;
  78. }
  79. else
  80. {
  81. return false;
  82. }
  83. }
  84. public ApiSaveResponse New(PerformanceItem item)
  85. {
  86. ApiSaveResponse ret = new ApiSaveResponse();
  87. ret.Success = true;
  88. using (Context.Database.BeginTransaction())
  89. {
  90. try
  91. {
  92. var results = Context.PerformanceItems.Where<PerformanceItem>(x =>
  93. x.CaseNo == item.CaseNo && x.DoItem == item.DoItem && x.DoItem != "提出报告" && x.CaseStage == item.CaseStage);
  94. if (item.DoItem.ToUpper() == "提交IDS")
  95. {
  96. //提交IDS 添加完成日期做完判断是否已算绩效的条件
  97. results = Context.PerformanceItems.Where<PerformanceItem>(x=>x.CaseNo == item.CaseNo && x.DoItem == item.DoItem && x.FinishedDate == item.FinishedDate);
  98. }
  99. var items = results.Include(pi => pi.CalMonth).FirstOrDefault<PerformanceItem>();
  100. if (items != null)
  101. {
  102. item.AgentFeedbackMemo = "已算绩效";
  103. item.DoItemMemo = $"{items.DoItemMemo}\r\n{items.CalMonth.Year}-{items.CalMonth.Month}已计算!";
  104. item.BasePoint = 0;
  105. }
  106. if (item.CalMonth != null)
  107. {
  108. var calMonth = Context.CalMonths.Where<CalMonth>(c => c.Year == item.CalMonth.Year && c.Month == item.CalMonth.Month).FirstOrDefault();
  109. if(calMonth == null)
  110. {
  111. Context.CalMonths.Add(item.CalMonth);
  112. if (item.BasePoint > 0)
  113. {
  114. _calItemJX(item,Context);
  115. }
  116. Context.SaveChanges();
  117. }
  118. else
  119. {
  120. item.CalMonth = calMonth;
  121. }
  122. item.CalMonthId = item.CalMonth.Id;
  123. item.CalMonth = null;
  124. }
  125. if (!string.IsNullOrEmpty(item.Customer.Name))
  126. {
  127. var temCustomer = Context.Customers.Where<Customer>(c => c.Name == item.Customer.Name).FirstOrDefault();
  128. if (temCustomer == null)
  129. {
  130. temCustomer = new Customer() { Name = item.Customer.Name };
  131. //item.Customer.Id = 0;
  132. Context.Customers.Add(temCustomer);
  133. Context.SaveChanges();
  134. item.Customer = temCustomer;
  135. //item.CustomerId = item.Customer.Id;
  136. }
  137. else
  138. {
  139. item.Customer = temCustomer;
  140. }
  141. item.CustomerId = item.Customer.Id;
  142. item.Customer = null;
  143. }
  144. else
  145. {
  146. item.Customer = null;
  147. }
  148. var ItemStaffs = item.ItemStaffs;
  149. item.ItemStaffs = null;
  150. Context.PerformanceItems.Add(item);
  151. Context.SaveChanges();
  152. foreach (ItemStaff itemStaff in ItemStaffs)
  153. {
  154. itemStaff.ItemId = item.Id;
  155. itemStaff.Item = null;
  156. if (itemStaff.DoPersonId == 0 && itemStaff.DoPerson != null)
  157. {
  158. var temStaff = Context.Staffs.FirstOrDefault<Staff>(s => s.Name == itemStaff.DoPerson.Name);
  159. if (temStaff != null)
  160. {
  161. itemStaff.DoPersonId = temStaff.Id;
  162. itemStaff.DoPerson = null;
  163. }
  164. else
  165. {
  166. Context.Staffs.Add(itemStaff.DoPerson);
  167. Context.SaveChanges();
  168. itemStaff.DoPersonId = itemStaff.DoPerson.Id;
  169. itemStaff.DoPerson = null;
  170. }
  171. }
  172. }
  173. Context.ItemStaffs.AddRange(ItemStaffs);
  174. Context.SaveChanges();
  175. Context.Database.CommitTransaction();
  176. }
  177. catch (Exception ex)
  178. {
  179. ret.Success = false;
  180. ret.ErrorMessage = ex.Message;
  181. Context.Database.RollbackTransaction();
  182. }
  183. }
  184. return ret;
  185. }
  186. /// <summary>
  187. /// 更新绩效记录信息
  188. /// </summary>
  189. /// <param name="id">绩效记录编号</param>
  190. /// <param name="field">栏位,多个位以|杠隔开</param>
  191. /// <param name="value">栏位值,多个以|杠隔开</param>
  192. /// <returns></returns>
  193. public ApiSaveResponse UpdateFieldValue(int id,string field,string value)
  194. {
  195. ApiSaveResponse ret = new ApiSaveResponse();
  196. ret.Success = true;
  197. var item = Context.PerformanceItems.Include(p=>p.Customer).FirstOrDefault<PerformanceItem>(p => p.Id == id);
  198. if (item == null)
  199. {
  200. ret.Success = false;
  201. ret.ErrorMessage = $"不存在的{id}";
  202. return ret;
  203. }
  204. if(string.IsNullOrEmpty(field) )
  205. {
  206. ret.Success = false;
  207. ret.ErrorMessage = $"参数不对!";
  208. return ret;
  209. }
  210. string[] fields = field.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
  211. string[] values = new string[] { null };
  212. if (!string.IsNullOrEmpty(value))
  213. {
  214. values = value.Split(new char[] { '|' });
  215. }
  216. if (fields.Length != values.Length) {
  217. ret.Success = false;
  218. ret.ErrorMessage = "栏位和值对不匹配";
  219. }
  220. else
  221. {
  222. for(int i = 0; i < fields.Length; i++)
  223. {
  224. string temField = fields[i];
  225. string temValue = values[i];
  226. switch (temField)
  227. {
  228. case "AgentFeedbackMemo":
  229. item.AgentFeedbackMemo = temValue;
  230. break;
  231. case "CaseCoefficient":
  232. item.CaseCoefficient = temValue;
  233. //此处添加保存到流程系统的代码
  234. break;
  235. case "DoItemCoefficient":
  236. item.DoItemCoefficient = temValue;
  237. //此处添加保存到流程系统的代码
  238. break;
  239. case "WordCount":
  240. int wordCount;
  241. if (int.TryParse(temValue, out wordCount))
  242. {
  243. item.WordCount = wordCount;
  244. }
  245. else
  246. {
  247. item.WordCount = null;
  248. //ret.Success = false;
  249. //ret.ErrorMessage = "所给的栏位值不能转换成数字!";
  250. //return ret;
  251. }
  252. break;
  253. case "ReturnCasseNo":
  254. item.ReturnCasseNo = temValue;
  255. break;
  256. }
  257. }
  258. if (item.AgentFeedbackMemo != "特殊点数申诉")
  259. {
  260. Utility.Utility.CalBasePoint(item, Context.BasePointRules.ToList());
  261. if (item.BasePoint > 0)
  262. {
  263. _calItemJX(item,Context);
  264. }
  265. Context.SaveChanges();
  266. }
  267. }
  268. return ret;
  269. }
  270. public ListApiResponse<PerformanceItem> Query(int pageIndex,int pageSize)
  271. {
  272. ListApiResponse<PerformanceItem> ret = new ListApiResponse<PerformanceItem>();
  273. var results = Context.PerformanceItems
  274. .Where<PerformanceItem>(s =>
  275. (s.ItemStaffs.Where<ItemStaff>(iStaff => iStaff.DoPerson.Name == User.Identity.Name).Count() > 0 || s.Reviewer.Name == User.Identity.Name)
  276. && s.CalMonth.Status != 4);
  277. ret.TotalCount = results.Count();
  278. List<PerformanceItem> retList = results
  279. .Include(pi=>pi.ItemStaffs).ThenInclude(iStaff=>iStaff.DoPerson)
  280. .Include(pi=>pi.Reviewer)
  281. .Include(pi=>pi.Customer)
  282. .Include(pi=>pi.CalMonth)
  283. .OrderByDescending(o=>o.Id)
  284. .Skip<PerformanceItem>((pageIndex - 1) * pageSize).Take(pageSize).ToList<PerformanceItem>();
  285. #region 将某些属性设为null,避免循环取值造成返回json过大
  286. foreach (PerformanceItem item in retList)
  287. {
  288. foreach (ItemStaff itemStaff in item.ItemStaffs)
  289. {
  290. itemStaff.DoPerson.ItemStaffs = null;
  291. itemStaff.DoPerson.ReviewerItems = null;
  292. itemStaff.Item = null;
  293. }
  294. item.Reviewer.ReviewerItems = null;
  295. item.Reviewer.Customers = null;
  296. item.Reviewer.ItemStaffs = null;
  297. item.Customer.PerformanceItems = null;
  298. item.CalMonth.PerformanceItems = null;
  299. }
  300. #endregion
  301. ret.Results = retList;
  302. return ret;
  303. }
  304. public PerformanceItem Get(int Id)
  305. {
  306. var results = Context.PerformanceItems
  307. .Where<PerformanceItem>(s =>s.Id == Id);
  308. PerformanceItem item = results
  309. .Include(pi => pi.ItemStaffs).ThenInclude(iStaff => iStaff.DoPerson)
  310. .Include(pi => pi.Reviewer)
  311. .Include(pi => pi.Customer)
  312. .Include(pi => pi.CalMonth)
  313. .OrderByDescending(o => o.Id)
  314. .FirstOrDefault();
  315. #region 将某些属性设为null,避免循环取值造成返回json过大
  316. foreach (ItemStaff itemStaff in item.ItemStaffs)
  317. {
  318. itemStaff.DoPerson.ItemStaffs = null;
  319. itemStaff.DoPerson.ReviewerItems = null;
  320. itemStaff.Item = null;
  321. }
  322. if (item.Reviewer != null)
  323. {
  324. item.Reviewer.ReviewerItems = null;
  325. item.Reviewer.Customers = null;
  326. item.Reviewer.ItemStaffs = null;
  327. }
  328. item.Customer.PerformanceItems = null;
  329. item.CalMonth.PerformanceItems = null;
  330. #endregion
  331. return item;
  332. }
  333. /// <summary>
  334. /// 获取给定用户的绩效清单
  335. /// </summary>
  336. /// <param name="userid">用户id</param>
  337. /// <param name="type">获取类型;0:处理中;1:所有;4:已归档</param>
  338. /// <returns></returns>
  339. public ListApiResponse<PerformanceItem> GetMyList(int userid, int type,int pageIndex=1,int pageSize = 10)
  340. {
  341. ListApiResponse<PerformanceItem> ret = new ListApiResponse<PerformanceItem>();
  342. var results = Context.PerformanceItems
  343. .Where<PerformanceItem>(s =>
  344. (s.ItemStaffs.Where<ItemStaff>(iStaff => iStaff.DoPerson.Id == userid ).Count() > 0 || s.Reviewer.Id == userid )
  345. && s.CalMonth.Status == type);
  346. ret.TotalCount = results.Count();
  347. List<PerformanceItem> retList = results
  348. .Include(pi => pi.ItemStaffs).ThenInclude(iStaff => iStaff.DoPerson)
  349. .Include(pi => pi.Reviewer)
  350. .Include(pi => pi.Customer)
  351. .Include(pi => pi.CalMonth)
  352. .OrderByDescending(o => o.Id)
  353. .Skip<PerformanceItem>((pageIndex - 1) * pageSize).Take(pageSize)
  354. .ToList<PerformanceItem>();
  355. #region 将某些属性设为null,避免循环取值造成返回json过大
  356. foreach (PerformanceItem item in retList)
  357. {
  358. foreach(ItemStaff itemStaff in item.ItemStaffs)
  359. {
  360. itemStaff.DoPerson.ItemStaffs = null;
  361. itemStaff.DoPerson.ReviewerItems = null;
  362. itemStaff.Item = null;
  363. }
  364. item.Reviewer.ReviewerItems = null;
  365. item.Reviewer.Customers = null;
  366. item.Reviewer.ItemStaffs = null;
  367. item.Customer.PerformanceItems = null;
  368. item.CalMonth.PerformanceItems = null;
  369. }
  370. #endregion
  371. ret.Results = retList;
  372. return ret;
  373. }
  374. /// <summary>
  375. /// 获取个人难度系数
  376. /// </summary>
  377. /// <param name="calMonth">绩效月份</param>
  378. /// <param name="userId">用户Id</param>
  379. /// <param name="isReivewer">是否审核个人难度系数</param>
  380. /// <returns></returns>
  381. private NanduStatics PersonNanduStatics(CalMonth calMonth,int userId,spDbContext spDb,bool isReivewer = false)
  382. {
  383. NanduStatics retObj = new NanduStatics();
  384. IDictionary<string, double> CaseXiShu = new Dictionary<string, double>();
  385. var list = spDb.CaseCeoffcients;
  386. foreach (var cx in list.ToList<CaseCeoffcient>())
  387. {
  388. CaseXiShu.Add(cx.Ceoffcient, cx.Value);
  389. }
  390. string jxType = isReivewer ? "新申请审核" : "新申请处理";
  391. var results = spDb.StaffStatistics.Where(s => s.CalMonthId == calMonth.Id && s.jxType == jxType && s.StaffId == userId);
  392. if (!isReivewer)
  393. {
  394. results = spDb.StaffStatistics.Where(s => s.CalMonthId == calMonth.Id && (s.jxType == jxType || s.jxType == "专案处理") && s.StaffId == userId);
  395. }
  396. #region 循环计算
  397. int iCount = 0;
  398. double d = 0.0;
  399. var retList = results.ToList();
  400. foreach (var item in retList)
  401. {
  402. string strCaseCeoffcient = item.Item.CaseCoefficient;
  403. if (string.IsNullOrEmpty(strCaseCeoffcient))
  404. {
  405. strCaseCeoffcient = "B";
  406. }
  407. #region 严重延期降系数
  408. if (item.Item.isDanger() && string.IsNullOrEmpty(item.Item.OverDueMemo))
  409. {
  410. switch (item.Item.CaseCoefficient)
  411. {
  412. case "S":
  413. strCaseCeoffcient = "A";
  414. break;
  415. case "A":
  416. strCaseCeoffcient = "B";
  417. break;
  418. case "B":
  419. strCaseCeoffcient = "C";
  420. break;
  421. case "C":
  422. strCaseCeoffcient = "D";
  423. break;
  424. }
  425. }
  426. #endregion
  427. switch (strCaseCeoffcient)
  428. {
  429. case "S":
  430. if (item.Item.Type == "专案")
  431. {
  432. retObj.S += item.totalBasePoint.Value;
  433. }
  434. else
  435. {
  436. retObj.S += 1;
  437. }
  438. break;
  439. case "A":
  440. if (item.Item.Type == "专案")
  441. {
  442. retObj.A += item.totalBasePoint.Value;
  443. }
  444. else
  445. {
  446. retObj.A += 1;
  447. }
  448. break;
  449. case "B":
  450. if (item.Item.Type == "专案")
  451. {
  452. retObj.B += item.totalBasePoint.Value;
  453. }
  454. else
  455. {
  456. retObj.B += 1;
  457. }
  458. break;
  459. case "C":
  460. if (item.Item.Type == "专案")
  461. {
  462. retObj.C += item.totalBasePoint.Value;
  463. }
  464. else
  465. {
  466. retObj.C += 1;
  467. }
  468. break;
  469. case "D":
  470. if (item.Item.Type == "专案")
  471. {
  472. retObj.D += item.totalBasePoint.Value;
  473. }
  474. else
  475. {
  476. retObj.D += 1;
  477. }
  478. break;
  479. default:
  480. if (item.Item.Type == "专案")
  481. {
  482. retObj.B += item.totalBasePoint.Value;
  483. }
  484. else
  485. {
  486. retObj.B += 1;
  487. }
  488. break;
  489. }
  490. if (CaseXiShu.ContainsKey(strCaseCeoffcient))
  491. {
  492. d += CaseXiShu[strCaseCeoffcient];
  493. iCount += 1;
  494. }
  495. }
  496. #endregion
  497. retObj.NanduXS = d / (double)iCount;
  498. return retObj;
  499. }
  500. /// <summary>
  501. /// 获取总难度系数
  502. /// </summary>
  503. /// <param name="calMonth"></param>
  504. /// <returns></returns>
  505. private NanduStatics DegreeOfDifficulty(CalMonth calMonth,spDbContext spDb)
  506. {
  507. NanduStatics retObj = new NanduStatics();
  508. IDictionary<string, double> CaseXiShu = new Dictionary<string, double>();
  509. var list = Context.CaseCeoffcients;
  510. foreach (var cx in list.ToList<CaseCeoffcient>())
  511. {
  512. CaseXiShu.Add(cx.Ceoffcient, cx.Value);
  513. }
  514. var results = spDb.PerformanceItems.Where<PerformanceItem>(p => p.CalMonthId == calMonth.Id && ((p.Type == "新申请" && p.BasePoint > 0) || p.Type == "专案") && p.BasePoint > 0.0);
  515. #region 循环计算
  516. int iCount = 0;
  517. double d = 0.0;
  518. var retList = results.ToList();
  519. foreach (var item in retList)
  520. {
  521. string strCaseCeoffcient = item.CaseCoefficient;
  522. if (string.IsNullOrEmpty(strCaseCeoffcient))
  523. {
  524. strCaseCeoffcient = "B";
  525. }
  526. #region 严重延期降系数
  527. if (item.isDanger() && string.IsNullOrEmpty(item.OverDueMemo))
  528. {
  529. switch (item.CaseCoefficient)
  530. {
  531. case "S":
  532. strCaseCeoffcient = "A";
  533. break;
  534. case "A":
  535. strCaseCeoffcient = "B";
  536. break;
  537. case "B":
  538. strCaseCeoffcient = "C";
  539. break;
  540. case "C":
  541. strCaseCeoffcient = "D";
  542. break;
  543. }
  544. }
  545. #endregion
  546. switch (strCaseCeoffcient)
  547. {
  548. case "S":
  549. if(item.Type == "专案")
  550. {
  551. retObj.S += item.BasePoint.Value;
  552. }
  553. else
  554. {
  555. retObj.S += 1;
  556. }
  557. break;
  558. case "A":
  559. if (item.Type == "专案")
  560. {
  561. retObj.A += item.BasePoint.Value;
  562. }
  563. else
  564. {
  565. retObj.A += 1;
  566. }
  567. break;
  568. case "B":
  569. if (item.Type == "专案")
  570. {
  571. retObj.B += item.BasePoint.Value;
  572. }
  573. else
  574. {
  575. retObj.B += 1;
  576. }
  577. break;
  578. case "C":
  579. if (item.Type == "专案")
  580. {
  581. retObj.C += item.BasePoint.Value;
  582. }
  583. else
  584. {
  585. retObj.C += 1;
  586. }
  587. break;
  588. case "D":
  589. if (item.Type == "专案")
  590. {
  591. retObj.D += item.BasePoint.Value;
  592. }
  593. else
  594. {
  595. retObj.D += 1;
  596. }
  597. break;
  598. default:
  599. if (item.Type == "专案")
  600. {
  601. retObj.B += item.BasePoint.Value;
  602. }
  603. else
  604. {
  605. retObj.B += 1;
  606. }
  607. break;
  608. }
  609. if (CaseXiShu.ContainsKey(strCaseCeoffcient))
  610. {
  611. d += CaseXiShu[strCaseCeoffcient];
  612. iCount += 1;
  613. }
  614. }
  615. #endregion
  616. retObj.NanduXS = d / (double)iCount;
  617. return retObj;
  618. }
  619. public List<string> GetFeedbackString(int itemId)
  620. {
  621. PerformanceItem item = Context.PerformanceItems.FirstOrDefault<PerformanceItem>(p => p.Id == itemId);
  622. if(item != null)
  623. {
  624. return Utility.Utility.GetFeedbackMemos(item, Context.BasePointRules.ToList());
  625. }
  626. return new List<string>();
  627. }
  628. private List<StaffStatistics> _CalMyStatistics(CalMonth calMonth, int? userid = null)
  629. {
  630. var retList = Context.StaffStatistics.Where(s => s.CalMonthId == calMonth.Id);
  631. if (userid != null)
  632. {
  633. retList = retList.Where(s => s.StaffId == userid);
  634. }
  635. var retData2 = retList.GroupBy(s => new { s.CalMonthId, s.StaffId, s.jxType })
  636. .Select(g => new
  637. {
  638. StaffId = g.Key.StaffId,
  639. CalMonthId = g.Key.CalMonthId,
  640. jxType = g.Key.jxType,
  641. FinianlPoint = g.Sum(s => s.FinianlPoint),
  642. totalBasePoint = g.Sum(s => s.totalBasePoint),
  643. totalActuallyPoint = g.Sum(s => s.totalActuallyPoint)
  644. });
  645. List<StaffStatistics> temList = new List<StaffStatistics>();
  646. foreach (var key in retData2)
  647. {
  648. temList.Add(new StaffStatistics()
  649. {
  650. StaffId = key.StaffId,
  651. CalMonthId = key.CalMonthId,
  652. jxType = key.jxType,
  653. totalBasePoint = key.totalBasePoint,
  654. totalActuallyPoint = key.totalActuallyPoint,
  655. FinianlPoint = key.FinianlPoint
  656. });
  657. }
  658. return temList;
  659. #region old code
  660. ////未归档,从绩效记录中统计数据
  661. //var results = Context.PerformanceItems.Where<PerformanceItem>(s => s.CalMonth.Id == calMonth.Id);
  662. //if (userid != null)
  663. //{
  664. // results = Context.PerformanceItems.Where<PerformanceItem>(s =>
  665. // (s.ItemStaffs.Where<ItemStaff>(iStaff => iStaff.DoPerson.Id == userid).Count() > 0 || s.Reviewer.Id == userid)
  666. // && s.CalMonth.Id == calMonth.Id);
  667. //}
  668. //List<PerformanceItem> ItemList = results
  669. // .Include(pi => pi.ItemStaffs).ThenInclude(iStaff => iStaff.DoPerson)
  670. // .Include(pi => pi.Reviewer).ThenInclude(p=>p.StaffGrade)
  671. // .Include(pi => pi.Customer)
  672. // .OrderByDescending(o => o.Id)
  673. // .ToList<PerformanceItem>();
  674. //List<StaffStatistics> retList = new List<StaffStatistics>();
  675. //List<VerifyCoefficient> verifyCoefficients = Context.VerifyCoefficients.ToList<VerifyCoefficient>();
  676. //var Rules = Context.BasePointRules.ToList();
  677. //foreach (PerformanceItem item in ItemList)
  678. //{
  679. // //if (item.BasePoint == null)
  680. // //{
  681. // if (item.AgentFeedbackMemo != "特殊点数申诉")
  682. // {
  683. // Utility.Utility.CalBasePoint(item, Rules);
  684. // Context.SaveChanges();
  685. // }
  686. // //}
  687. // if (item.BasePoint != null && item.BasePoint.Value > 0)
  688. // {
  689. // double doPersonBasePoint = item.BasePoint.Value;
  690. // List<StaffStatistics> itemStatistics = _calItemJX(calMonth, verifyCoefficients, item,Context);
  691. // List<StaffStatistics> temItemStatics;
  692. // if (userid != null)
  693. // {
  694. // temItemStatics = itemStatistics.Where<StaffStatistics>(s => s.StaffId == userid).ToList();
  695. // }
  696. // else
  697. // {
  698. // temItemStatics = itemStatistics;
  699. // }
  700. // foreach (StaffStatistics retUserValue in temItemStatics)
  701. // {
  702. // var temValue = retList.Where<StaffStatistics>(s => s.StaffId == retUserValue.StaffId && s.jxType == retUserValue.jxType && s.CalMonthId == calMonth.Id).FirstOrDefault();
  703. // if (temValue != null)
  704. // {
  705. // temValue.totalBasePoint += retUserValue.totalBasePoint;
  706. // temValue.totalActuallyPoint += retUserValue.totalActuallyPoint;
  707. // }
  708. // else
  709. // {
  710. // retList.Add(retUserValue);
  711. // }
  712. // }
  713. // }
  714. //}
  715. //if (userid != null)
  716. //{
  717. // retList = retList.Where<StaffStatistics>(s => s.StaffId == userid.Value).ToList();
  718. //}
  719. //return retList;
  720. #endregion
  721. }
  722. private void _RefreshBasePoint()
  723. {
  724. spDbContext spDb = new spDbContext();
  725. var lstItem = spDb.PerformanceItems.Include(p => p.Customer).Where(p => p.CalMonth.Status != 4).ToList();
  726. var rules = spDb.BasePointRules.ToList();
  727. foreach (var item in lstItem)
  728. {
  729. if (item.AgentFeedbackMemo != "特殊点数申诉")
  730. {
  731. Utility.Utility.CalBasePoint(item, rules);
  732. if(item.BasePoint > 0)
  733. {
  734. _calItemJX(item,spDb);
  735. }
  736. spDb.SaveChanges();
  737. }
  738. }
  739. }
  740. public ApiSaveResponse RefreshBasePoint()
  741. {
  742. System.Threading.Thread t = new Thread(_RefreshBasePoint);
  743. t.Start();
  744. return new ApiSaveResponse() {
  745. Success = true
  746. };
  747. }
  748. public ApiSaveResponse RefreshFromIPEasyById(int itemId)
  749. {
  750. var Item = Context.PerformanceItems.Include(p=>p.Customer).Include(p=>p.ItemStaffs).ThenInclude(p=>p.DoPerson).FirstOrDefault(p => p.Id == itemId);
  751. if (Item != null)
  752. {
  753. new Job.UpdateJXDataFromIPEasyJob().UpdateFromIPEasy(Item, Context);
  754. }
  755. Utility.Utility.CalBasePoint(Item, Context.BasePointRules.ToList());
  756. if(Item.BasePoint > 0)
  757. {
  758. _calItemJX(Item,Context);
  759. }
  760. Context.SaveChanges();
  761. return new ApiSaveResponse()
  762. {
  763. Success = true
  764. };
  765. }
  766. public ApiSaveResponse RefreshFromIPEasy_Batch(int type)
  767. {
  768. new Job.UpdateJXDataFromIPEasyJob().RefreshFromIPEasy(type);
  769. return new ApiSaveResponse()
  770. {
  771. Success = true
  772. };
  773. }
  774. public ApiSaveResponse RefreshFromIPEasy(string CaseNo,string DoItem,string caseStage)
  775. {
  776. var Item = Context.PerformanceItems.Include(p=>p.Customer).FirstOrDefault(p=>p.CaseNo == CaseNo && p.DoItem == DoItem && p.CaseStage == caseStage);
  777. if(Item != null)
  778. {
  779. new Job.UpdateJXDataFromIPEasyJob().UpdateFromIPEasy(Item,Context);
  780. }
  781. return new ApiSaveResponse()
  782. {
  783. Success = true
  784. };
  785. }
  786. public ApiSaveResponse CompareExcel2DB()
  787. {
  788. System.Threading.Thread t = new Thread(new ThreadStart(_CompareExcel2DB));
  789. t.Start();
  790. return new ApiSaveResponse()
  791. {
  792. Success = true
  793. };
  794. }
  795. public FileProcessTask CurrentData2Excel()
  796. {
  797. CalMonth calMonth = Context.CalMonths.FirstOrDefault(c => c.Status == 0);
  798. if (calMonth != null)
  799. {
  800. var filename = $"{DateTime.Now.ToString("yyyyMMddhhmmss")}-{calMonth.Year}{calMonth.Month}线下绩效核算数据.xlsx";
  801. var attachfileSavePath = utility.ConfigHelper.GetSectionValue("AttachFileSavePath");
  802. var filePath = Path.Combine(attachfileSavePath, filename);
  803. var fileTask = new FileProcessTask()
  804. {
  805. Id = Guid.NewGuid().ToString(),
  806. FileName = filename,
  807. FilePath = filePath,
  808. Processed = 0
  809. };
  810. fileTaskService.Add(fileTask);
  811. System.Threading.Thread t = new System.Threading.Thread(new ParameterizedThreadStart(Export2ExcelThread));
  812. t.Start(fileTask);
  813. return fileTask;
  814. }
  815. return null;
  816. }
  817. private void Export2ExcelThread(object attfile)
  818. {
  819. FileProcessTask file = (FileProcessTask)attfile;
  820. spDbContext spDb = new spDbContext();
  821. List<PerformanceItem> items = spDb.PerformanceItems
  822. .Include(p => p.Reviewer).ThenInclude(p => p.StaffGrade)
  823. .Include(p=>p.PreOastaff)
  824. .Include(p => p.Customer)
  825. .Include(p => p.CalMonth)
  826. .Include(p => p.ItemStaffs).ThenInclude(s => s.DoPerson).ThenInclude(s => s.StaffGrade)
  827. .Where(p => p.CalMonth.Status == 0 && !p.CaseNo.StartsWith("J")).OrderBy(p => p.CaseNo).ThenBy(p => p.DoItem).ToList();
  828. DataTable dt = new DataTable();
  829. #region 栏位名称
  830. dt.Columns.Add("我方文号",typeof(string));
  831. dt.Columns.Add("申请类型", typeof(string));
  832. dt.Columns.Add("业务类型", typeof(string));
  833. dt.Columns.Add("备注(填表注意事项)", typeof(string));
  834. dt.Columns.Add("处理事项", typeof(string));
  835. dt.Columns.Add("案件阶段", typeof(string));
  836. dt.Columns.Add("案件系数", typeof(string));
  837. dt.Columns.Add("处理事项系数", typeof(string));
  838. dt.Columns.Add("前一次OA处理事项系数", typeof(string));
  839. dt.Columns.Add("前一次OA处理人", typeof(string));
  840. dt.Columns.Add("处理人等级", typeof(string));
  841. dt.Columns.Add("基本点数", typeof(string));
  842. dt.Columns.Add("核稿系数", typeof(string));
  843. dt.Columns.Add("核稿绩效", typeof(string));
  844. dt.Columns.Add("处理人", typeof(string));
  845. dt.Columns.Add("核稿人", typeof(string));
  846. dt.Columns.Add("客户名称", typeof(string));
  847. dt.Columns.Add("申请人", typeof(string));
  848. dt.Columns.Add("处理事项完成日", typeof(string));
  849. dt.Columns.Add("定稿日", typeof(string));
  850. dt.Columns.Add("返稿日", typeof(string));
  851. dt.Columns.Add("案件类型", typeof(string));
  852. dt.Columns.Add("案件状态", typeof(string));
  853. dt.Columns.Add("处理事项备注", typeof(string));
  854. dt.Columns.Add("处理状态", typeof(string));
  855. dt.Columns.Add("案件名称", typeof(string));
  856. dt.Columns.Add("委案日期", typeof(string));
  857. dt.Columns.Add("客户期限", typeof(string));
  858. dt.Columns.Add("内部期限", typeof(string));
  859. dt.Columns.Add("初稿日", typeof(string));
  860. dt.Columns.Add("翻译字数", typeof(string));
  861. dt.Columns.Add("备注(发文严重超期是否属客观原因,若为否,请填写原因", typeof(string));
  862. dt.Columns.Add("绩效类型", typeof(string));
  863. dt.Columns.Add("案件备注", typeof(string));
  864. dt.Columns.Add("处理人绩效系数", typeof(string));
  865. dt.Columns.Add("系统核算绩效", typeof(string));
  866. dt.Columns.Add("实际处理人", typeof(string));
  867. #endregion
  868. var verifyCeoffients = spDb.VerifyCoefficients.ToList();
  869. var Rules = spDb.BasePointRules.ToList();
  870. file.Size = items.Count;
  871. foreach(var p in items)
  872. {
  873. List<ItemStaff> temItemStaffs = p.ItemStaffs.ToList();
  874. string strCaseMemo = "";
  875. string strHandler = "";
  876. temItemStaffs = new List<ItemStaff>();
  877. foreach (var iStaff in p.ItemStaffs)
  878. {
  879. strHandler = string.IsNullOrEmpty(strHandler)?iStaff.DoPerson.Name : $"{strHandler},{iStaff.DoPerson.Name}";
  880. if (iStaff.DoPerson.Status == "试用期")
  881. {
  882. strCaseMemo = string.IsNullOrEmpty(strCaseMemo) ? $"{iStaff.DoPerson.Name}在试用期" : $"{strCaseMemo},{iStaff.DoPerson.Name}在试用期";
  883. }
  884. else
  885. {
  886. if(!iStaff.DoPerson.IsCalPerformsnce )
  887. strCaseMemo = string.IsNullOrEmpty(strCaseMemo) ? $"{iStaff.DoPerson.Name}不计算绩效" : $"{strCaseMemo},{iStaff.DoPerson.Name}不计算绩效";
  888. }
  889. if(iStaff.DoPersonId == p.ReviewerId)
  890. {
  891. strCaseMemo = String.IsNullOrEmpty(strCaseMemo) ? "核稿人与处理人相同" : $"{strCaseMemo},核稿人与处理人相同";
  892. }
  893. }
  894. var staffStatics = spDb.StaffStatistics.Include(s=>s.Staff).ThenInclude(s=>s.StaffGrade).Where(s=>s.ItemId == p.Id && s.jxType.Contains("处理"));
  895. var reviewStatic = spDb.StaffStatistics.Include(s => s.Staff).ThenInclude(s => s.StaffGrade).FirstOrDefault(s => s.ItemId == p.Id && s.jxType.Contains("审核"));
  896. foreach (var iStaff in staffStatics.ToList())
  897. {
  898. DataRow row = dt.NewRow();
  899. row["我方文号"] = p.CaseNo;
  900. row["申请类型"] = p.ApplicationType;
  901. row["实际处理人"] = strHandler;
  902. if(p.ApplicationName != null && p.ApplicationName.Contains("OPPO") && p.ApplicationType == "实用新型")
  903. {
  904. row["申请类型"] = "发明";
  905. row["案件备注"] = $"{row["案件备注"]}\r\nOPPO案件实用新型修改为发明】";
  906. }
  907. row["处理事项"] = p.DoItem;
  908. row["业务类型"] = p.BusinessType;
  909. row["备注(填表注意事项)"] = p.AgentFeedbackMemo;
  910. if(p.Type == "专案")
  911. {
  912. row["备注(填表注意事项)"] = $"{row["备注(填表注意事项)"]}【主管给定点数】专案";
  913. row["处理事项"] = "提出报告";
  914. }
  915. if(p.ItemStaffs.Count() > 1)
  916. {
  917. row["备注(填表注意事项)"] = $"{row["备注(填表注意事项)"]},{strHandler}合写";
  918. }
  919. row["案件阶段"] = p.CaseStage;
  920. row["案件系数"] = p.CaseCoefficient;
  921. if(p.isDanger() && string.IsNullOrEmpty(p.OverDueMemo) && p.Type =="新申请")
  922. {
  923. switch (p.CaseCoefficient)
  924. {
  925. case "S":
  926. row["案件系数"] = "A";
  927. break;
  928. case "A":
  929. row["案件系数"] = "B";
  930. break;
  931. case "B":
  932. row["案件系数"] = "C";
  933. break;
  934. case "C":
  935. row["案件系数"] = "D";
  936. break;
  937. }
  938. row["案件备注"] = $"{row["案件备注"]}\r\n严重延期降系数【{p.CaseCoefficient}->{row["案件系数"]}】";
  939. }
  940. row["处理事项系数"] = p.DoItemCoefficient;
  941. row["前一次OA处理事项系数"] = "";
  942. row["前一次OA处理人"] = p.PreOastaff?.Name;
  943. row["处理人"] = iStaff.Staff.Name;
  944. row["基本点数"] = iStaff.totalBasePoint;
  945. row["处理人绩效系数"] = iStaff.Staff.StaffGrade.Grade;
  946. if(reviewStatic != null)
  947. {
  948. row["核稿人"] = reviewStatic.Staff.Name;
  949. }
  950. row["客户名称"] = p.Customer?.Name;
  951. row["申请人"] = p.ApplicationName;
  952. row["处理事项完成日"] = p.FinishedDate?.ToString("yyyy-MM-dd");
  953. row["定稿日"] = p.FinalizationDate?.ToString("yyyy-MM-dd");
  954. row["返稿日"] = p.ReturnDate?.ToString("yyyy-MM-dd");
  955. row["案件类型"] = p.CaseType;
  956. row["案件状态"] = p.CaseState;
  957. row["处理事项备注"] = p.DoItemMemo;
  958. row["处理状态"] = p.DoItemState;
  959. row["案件名称"] = p.CaseName;
  960. row["委案日期"] = p.EntrustingDate?.ToString("yyyy-MM-dd");
  961. row["客户期限"] = p.CustomerLimitDate?.ToString("yyyy-MM-dd");
  962. row["内部期限"] = p.InternalDate?.ToString("yyyy-MM-dd");
  963. row["初稿日"] = p.FirstDraftDate?.ToString("yyyy-MM-dd");
  964. row["翻译字数"] = p.WordCount;
  965. row["备注(发文严重超期是否属客观原因,若为否,请填写原因"] = p.OverDueMemo;
  966. row["绩效类型"] = p.Type;
  967. row["案件备注"] = $"{p.CaseMemo}\r\n{row["案件备注"]}";
  968. if (!string.IsNullOrEmpty(strCaseMemo))
  969. {
  970. row["案件备注"] = $"{strCaseMemo}\r\n{row["案件备注"]}";
  971. }
  972. dt.Rows.Add(row);
  973. }
  974. file.Processed += 1;
  975. }
  976. NPOIExcel.DataTableToExcel(dt, file.FilePath);
  977. file.Finished = true;
  978. }
  979. private void _CompareExcel2DB()
  980. {
  981. DataTable excelDT = NPOIExcel.ExcelToDataTable("c:\\temp\\220112-工程师绩效总表-12月-v2F.xlsx", true, true, 0,2);
  982. DataTable retTable = new DataTable();
  983. retTable.Columns.Add("我方文号");
  984. retTable.Columns.Add("申请类型");
  985. retTable.Columns.Add("业务类型");
  986. retTable.Columns.Add("备注(填表注意事项)");
  987. retTable.Columns.Add("备注(填表注意事项)【系统】");
  988. retTable.Columns.Add("处理事项");
  989. retTable.Columns.Add("处理事项【系统】");
  990. retTable.Columns.Add("案件阶段");
  991. retTable.Columns.Add("案件阶段【系统】");
  992. retTable.Columns.Add("案件系数");
  993. retTable.Columns.Add("案件系数【系统】");
  994. retTable.Columns.Add("处理事项系数");
  995. retTable.Columns.Add("处理事项系数【系统】");
  996. retTable.Columns.Add("处理人等级");
  997. retTable.Columns.Add("处理人等级【系统】");
  998. retTable.Columns.Add("处理人系数");
  999. retTable.Columns.Add("处理人系数【系统】");
  1000. retTable.Columns.Add("基本点数");
  1001. retTable.Columns.Add("基本点数【系统】");
  1002. retTable.Columns.Add("核稿系数");
  1003. retTable.Columns.Add("核稿系数【系统】");
  1004. retTable.Columns.Add("核稿绩效");
  1005. retTable.Columns.Add("核稿绩效【系统】");
  1006. retTable.Columns.Add("处理人");
  1007. retTable.Columns.Add("处理人【系统】");
  1008. retTable.Columns.Add("核稿人");
  1009. retTable.Columns.Add("核稿人【系统】");
  1010. retTable.Columns.Add("严重超期备注原因");
  1011. retTable.Columns.Add("严重超期备注原因【系统】");
  1012. retTable.Columns.Add("是否一致");
  1013. retTable.Columns.Add("不一致原因");
  1014. spDbContext spDb = new spDbContext();
  1015. List<PerformanceItem> items = spDb.PerformanceItems
  1016. .Include(p=>p.Reviewer).ThenInclude(p=>p.StaffGrade)
  1017. .Include(p=>p.Customer)
  1018. .Include(p=>p.ItemStaffs).ThenInclude(s=>s.DoPerson).ThenInclude(s=>s.StaffGrade)
  1019. .Where(p=>p.CalMonth.Status ==0 && !p.CaseNo.StartsWith("J")).OrderBy(p=>p.CaseNo).ThenBy(p=>p.DoItem).ToList();
  1020. excelDT.DefaultView.Sort = "我方文号,处理事项";
  1021. DataTable temDt = excelDT.DefaultView.ToTable();
  1022. int iTable = 0;
  1023. int iList = 0;
  1024. CalMonth calMonth = spDb.CalMonths.FirstOrDefault(p=>p.Status ==0);
  1025. var verifyCoefficients = spDb.VerifyCoefficients.ToList();
  1026. var Rules = spDb.BasePointRules.ToList();
  1027. while (iTable < temDt.Rows.Count && iList < items.Count)
  1028. {
  1029. System.Diagnostics.Debug.WriteLine($"Excel:{iTable}/{temDt.Rows.Count}\t{iList}/{items.Count}");
  1030. DataRow row = temDt.Rows[iTable];
  1031. PerformanceItem item = items[iList];
  1032. if(row["我方文号"].ToString() == item.CaseNo && (row["处理事项"].ToString() == item.DoItem || (row["备注(填表注意事项)"].ToString()== "发明一次OA授权" && item.DoItem == "发明一次OA授权")))
  1033. {
  1034. var temRow = retTable.NewRow();
  1035. int iBegin = iTable;
  1036. int iEnd = iTable;
  1037. #region 判断是否有重复记录,并将Excel表中的记录生成临时表中的一行记录
  1038. if (iEnd < temDt.Rows.Count - 1)
  1039. {
  1040. while (temDt.Rows[iEnd]["我方文号"].ToString() == temDt.Rows[iEnd + 1]["我方文号"].ToString() &&
  1041. temDt.Rows[iEnd]["处理事项"].ToString() == temDt.Rows[iEnd + 1]["处理事项"].ToString())
  1042. {
  1043. iEnd++;
  1044. }
  1045. }
  1046. temRow["我方文号"] = temDt.Rows[iTable]["我方文号"];
  1047. temRow["处理事项"] = temDt.Rows[iTable]["处理事项"];
  1048. temRow["申请类型"] = temDt.Rows[iTable]["申请类型"];
  1049. temRow["业务类型"] = temDt.Rows[iTable]["业务类型"];
  1050. temRow["案件阶段"] = temDt.Rows[iTable]["案件阶段"];
  1051. temRow["案件系数"] = temDt.Rows[iTable]["案件系数"];
  1052. temRow["处理事项系数"] = temDt.Rows[iTable]["处理事项系数"];
  1053. temRow["核稿人"] = temDt.Rows[iTable]["核稿人"];
  1054. temRow["备注(填表注意事项)"] = temDt.Rows[iTable]["备注(填表注意事项)"];
  1055. temRow["处理人等级"] = temDt.Rows[iTable]["处理人等级"];
  1056. temRow["基本点数"] = temDt.Rows[iTable]["基本点数"];
  1057. temRow["核稿系数"] = temDt.Rows[iTable]["核稿系数"];
  1058. temRow["处理人"] = temDt.Rows[iTable]["处理人"];
  1059. temRow["严重超期备注原因"] = temDt.Rows[iTable]["备注(发文严重超期是否属客观原因,若为否,请填写原因)"];
  1060. for (int i = iBegin; i <= iEnd; i++)
  1061. {
  1062. temRow["备注(填表注意事项)"] =string.IsNullOrEmpty(temRow["备注(填表注意事项)"].ToString()) ?temDt.Rows[i]["备注(填表注意事项)"] :$"{temRow["备注(填表注意事项)"]}{temDt.Rows[i]["备注(填表注意事项)"]}";
  1063. //temRow["基本点数"] = string.IsNullOrEmpty(temRow["基本点数"].ToString()) ? temDt.Rows[i]["基本点数"] : $"{temRow["基本点数"]},{temDt.Rows[i]["基本点数"]}";
  1064. temRow["核稿系数"] = string.IsNullOrEmpty(temRow["核稿系数"].ToString()) ? temDt.Rows[i]["核稿系数"] : $"{temRow["核稿系数"]},{temDt.Rows[i]["核稿系数"]}";
  1065. if (!temRow["处理人"].ToString().Contains(temDt.Rows[i]["处理人"].ToString()))
  1066. {
  1067. temRow["处理人"] = string.IsNullOrEmpty(temRow["处理人"].ToString()) ? temDt.Rows[i]["处理人"] : $"{temRow["处理人"]},{temDt.Rows[i]["处理人"]}";
  1068. temRow["处理人等级"] = string.IsNullOrEmpty(temRow["处理人等级"].ToString()) ? temDt.Rows[i]["处理人等级"] : $"{temRow["处理人等级"]},{temDt.Rows[i]["处理人等级"]}";
  1069. }
  1070. temRow["严重超期备注原因"] = string.IsNullOrEmpty(temRow["严重超期备注原因"].ToString()) ? temDt.Rows[i]["备注(发文严重超期是否属客观原因,若为否,请填写原因)"] : $"{temRow["严重超期备注原因"]}{temDt.Rows[i]["备注(发文严重超期是否属客观原因,若为否,请填写原因)"]}";
  1071. }
  1072. iTable = iEnd;
  1073. #endregion
  1074. Utility.Utility.CalBasePoint(item, Rules);
  1075. List<StaffStatistics> retPoints = new List<StaffStatistics>();
  1076. try
  1077. {
  1078. retPoints = _calItemJX( verifyCoefficients, item, spDb);
  1079. }
  1080. catch { }
  1081. temRow["案件阶段【系统】"] = item.CaseStage;
  1082. temRow["案件系数【系统】"] = item.CaseCoefficient;
  1083. temRow["处理事项系数【系统】"] = item.DoItemCoefficient;
  1084. temRow["核稿人【系统】"] = item.Reviewer?.Name;
  1085. temRow["备注(填表注意事项)【系统】"] = item.AgentFeedbackMemo;
  1086. temRow["基本点数【系统】"] = item.BasePoint?.ToString();
  1087. temRow["严重超期备注原因"] = item.OverDueMemo;
  1088. if (retPoints != null && retPoints.Count > 0)
  1089. {
  1090. temRow["核稿绩效【系统】"] = retPoints.FirstOrDefault(p => p.StaffId == item.ReviewerId && p.jxType.Contains("审核"))?.totalBasePoint;
  1091. foreach (var itemStaff in item.ItemStaffs)
  1092. {
  1093. //temRow["基本点数【系统】"] = string.IsNullOrEmpty(temRow["基本点数【系统】"].ToString()) ? retPoints.FirstOrDefault(p => p.StaffId == itemStaff.DoPersonId)?.totalBasePoint.ToString() : $"{temRow["基本点数【系统】"]},{retPoints.FirstOrDefault(p => p.StaffId == itemStaff.DoPersonId)?.totalBasePoint}";
  1094. temRow["处理人等级【系统】"] = string.IsNullOrEmpty(temRow["处理人等级【系统】"].ToString()) ? itemStaff.DoPerson.StaffGrade?.Grade : $"{temRow["处理人等级【系统】"]},{itemStaff.DoPerson.StaffGrade?.Grade }";
  1095. temRow["处理人【系统】"] = string.IsNullOrEmpty(temRow["处理人【系统】"].ToString()) ? itemStaff.DoPerson.Name : $"{temRow["处理人【系统】"]},{itemStaff.DoPerson.Name}";
  1096. if (item.ReviewerId != null)
  1097. {
  1098. #region 取审核人等级审核等级系数
  1099. VerifyCoefficient vcoefficient
  1100. = verifyCoefficients.Where<VerifyCoefficient>(v =>
  1101. v.CheckerId == item.Reviewer.StaffGradeId
  1102. && v.DoPersonId == itemStaff.DoPerson.StaffGradeId)
  1103. .FirstOrDefault<VerifyCoefficient>();
  1104. #endregion
  1105. if (vcoefficient != null)
  1106. {
  1107. temRow["核稿系数【系统】"] = string.IsNullOrEmpty(temRow["核稿系数【系统】"].ToString()) ? vcoefficient.Coefficient.ToString() : $"{temRow["核稿系数【系统】"]},{vcoefficient.Coefficient}";
  1108. }
  1109. }
  1110. }
  1111. }
  1112. temRow["是否一致"] = "";
  1113. temRow["不一致原因"] = "";
  1114. if(temRow["案件阶段【系统】"].ToString().Trim() != temRow["案件阶段"].ToString().Trim())
  1115. {
  1116. temRow["不一致原因"] = string.IsNullOrEmpty(temRow["不一致原因"].ToString()) ? "案件阶段" : $"{temRow["不一致原因"]},案件阶段";
  1117. }
  1118. if (temRow["案件系数【系统】"].ToString().Trim() != temRow["案件系数"].ToString().Trim())
  1119. {
  1120. temRow["不一致原因"] = string.IsNullOrEmpty(temRow["不一致原因"].ToString()) ? "案件系数" : $"{temRow["不一致原因"]},案件系数";
  1121. }
  1122. if (temRow["处理事项系数【系统】"].ToString().Trim() != temRow["处理事项系数"].ToString().Trim())
  1123. {
  1124. temRow["不一致原因"] = string.IsNullOrEmpty(temRow["不一致原因"].ToString()) ? "处理事项系数" : $"{temRow["不一致原因"]},处理事项系数";
  1125. }
  1126. if (temRow["核稿人【系统】"].ToString().Trim() != temRow["核稿人"].ToString().Trim())
  1127. {
  1128. temRow["不一致原因"] = string.IsNullOrEmpty(temRow["不一致原因"].ToString()) ? "核稿人" : $"{temRow["不一致原因"]},核稿人";
  1129. }
  1130. if (temRow["基本点数【系统】"].ToString().Trim() != temRow["基本点数"].ToString().Trim())
  1131. {
  1132. temRow["不一致原因"] = string.IsNullOrEmpty(temRow["不一致原因"].ToString()) ? "基本点数" : $"{temRow["不一致原因"]},基本点数";
  1133. }
  1134. if (temRow["严重超期备注原因【系统】"].ToString().Trim() != temRow["严重超期备注原因"].ToString().Trim())
  1135. {
  1136. temRow["不一致原因"] = string.IsNullOrEmpty(temRow["不一致原因"].ToString()) ? "严重超期备注原因" : $"{temRow["不一致原因"]},严重超期备注原因";
  1137. }
  1138. if (!string.IsNullOrEmpty(temRow["不一致原因"].ToString()))
  1139. {
  1140. temRow["是否一致"] = "不一致";
  1141. }
  1142. retTable.Rows.Add(temRow);
  1143. iTable++;
  1144. iList++;
  1145. }
  1146. else
  1147. {
  1148. string strDT = $"{row["我方文号"]}-{row["处理事项"]}";
  1149. string strList = $"{item.CaseNo}-{item.DoItem}";
  1150. if (strDT.CompareTo(strList) > 0)
  1151. {
  1152. var temRow = retTable.NewRow();
  1153. Utility.Utility.CalBasePoint(item, Rules);
  1154. List<StaffStatistics> retPoints = new List<StaffStatistics>();
  1155. try
  1156. {
  1157. retPoints = _calItemJX( verifyCoefficients, item, spDb);
  1158. }
  1159. catch { }
  1160. temRow["我方文号"] = item.CaseNo;
  1161. temRow["处理事项"] = item.DoItem;
  1162. temRow["申请类型"] = item.ApplicationType;
  1163. temRow["业务类型"] = item.BusinessType;
  1164. temRow["案件阶段【系统】"] = item.CaseStage;
  1165. temRow["案件系数【系统】"] = item.CaseCoefficient;
  1166. temRow["处理事项系数【系统】"] = item.DoItemCoefficient;
  1167. temRow["核稿人【系统】"] = item.Reviewer?.Name;
  1168. temRow["备注(填表注意事项)【系统】"] = item.AgentFeedbackMemo;
  1169. temRow["基本点数【系统】"] = item.BasePoint?.ToString();
  1170. temRow["严重超期备注原因"] = item.OverDueMemo;
  1171. if (item.ReviewerId != null)
  1172. {
  1173. temRow["核稿绩效【系统】"] = retPoints.FirstOrDefault(p => p.StaffId == item.ReviewerId)?.totalBasePoint;
  1174. }
  1175. foreach (var itemStaff in item.ItemStaffs)
  1176. {
  1177. //if (itemStaff.DoPerson.Status != "试用期")
  1178. //{
  1179. // if (retPoints != null && retPoints.Count > 0)
  1180. // {
  1181. // temRow["基本点数【系统】"] = string.IsNullOrEmpty(temRow["基本点数【系统】"].ToString()) ? retPoints.FirstOrDefault(p => p.StaffId == itemStaff.DoPersonId)?.totalBasePoint.ToString() : $"{temRow["基本点数【系统】"]},{retPoints.FirstOrDefault(p => p.StaffId == itemStaff.DoPersonId)?.totalBasePoint}";
  1182. // }
  1183. //}
  1184. temRow["处理人等级【系统】"] = string.IsNullOrEmpty(temRow["处理人等级【系统】"].ToString()) ? itemStaff.DoPerson.StaffGrade?.Grade : $"{temRow["处理人等级【系统】"]},{itemStaff.DoPerson.StaffGrade?.Grade }";
  1185. temRow["处理人系数【系统】"] = string.IsNullOrEmpty(temRow["处理人系数【系统】"].ToString()) ? itemStaff.DoPerson.StaffGrade?.Coefficient : $"{temRow["处理人系数【系统】"]},{itemStaff.DoPerson.StaffGrade?.Coefficient}";
  1186. temRow["处理人【系统】"] = string.IsNullOrEmpty(temRow["处理人【系统】"].ToString()) ? itemStaff.DoPerson.Name : $"{temRow["处理人【系统】"]},{itemStaff.DoPerson.Name}";
  1187. if (item.ReviewerId != null)
  1188. {
  1189. #region 取审核人等级审核等级系数
  1190. VerifyCoefficient vcoefficient
  1191. = verifyCoefficients.Where<VerifyCoefficient>(v =>
  1192. v.CheckerId == item.Reviewer.StaffGradeId
  1193. && v.DoPersonId == itemStaff.DoPerson.StaffGradeId)
  1194. .FirstOrDefault<VerifyCoefficient>();
  1195. #endregion
  1196. if (vcoefficient != null)
  1197. {
  1198. temRow["核稿系数【系统】"] = string.IsNullOrEmpty(temRow["核稿系数【系统】"].ToString()) ? vcoefficient.Coefficient.ToString() : $"{temRow["核稿系数【系统】"]},{vcoefficient.Coefficient}";
  1199. }
  1200. }
  1201. }
  1202. temRow["是否一致"] = "不一致";
  1203. temRow["不一致原因"] = "Excel中没有,系统中有";
  1204. retTable.Rows.Add(temRow);
  1205. iList++;
  1206. }
  1207. else
  1208. {
  1209. var temRow = retTable.NewRow();
  1210. int iBegin = iTable;
  1211. int iEnd = iTable;
  1212. #region 判断是否有重复记录,并将Excel表中的记录生成临时表中的一行记录
  1213. if (iEnd < temDt.Rows.Count - 1)
  1214. {
  1215. while (temDt.Rows[iEnd]["我方文号"].ToString() == temDt.Rows[iEnd + 1]["我方文号"].ToString() &&
  1216. temDt.Rows[iEnd]["处理事项"].ToString() == temDt.Rows[iEnd + 1]["处理事项"].ToString())
  1217. {
  1218. iEnd++;
  1219. }
  1220. }
  1221. temRow["我方文号"] = temDt.Rows[iTable]["我方文号"];
  1222. temRow["处理事项"] = temDt.Rows[iTable]["处理事项"];
  1223. temRow["申请类型"] = temDt.Rows[iTable]["申请类型"];
  1224. temRow["业务类型"] = temDt.Rows[iTable]["业务类型"];
  1225. temRow["案件阶段"] = temDt.Rows[iTable]["案件阶段"];
  1226. temRow["案件系数"] = temDt.Rows[iTable]["案件系数"];
  1227. temRow["处理事项系数"] = temDt.Rows[iTable]["处理事项系数"];
  1228. temRow["核稿人"] = temDt.Rows[iTable]["核稿人"];
  1229. temRow["备注(填表注意事项)"] = temDt.Rows[iTable]["备注(填表注意事项)"];
  1230. temRow["处理人等级"] = temDt.Rows[iTable]["处理人等级"];
  1231. temRow["基本点数"] = temDt.Rows[iTable]["基本点数"];
  1232. temRow["核稿系数"] = temDt.Rows[iTable]["核稿系数"];
  1233. temRow["核稿绩效"] = temDt.Rows[iTable]["核稿绩效"];
  1234. temRow["处理人"] = temDt.Rows[iTable]["处理人"];
  1235. temRow["严重超期备注原因"] = temDt.Rows[iTable]["备注(发文严重超期是否属客观原因,若为否,请填写原因)"];
  1236. for (int i = iBegin+1; i <= iEnd; i++)
  1237. {
  1238. temRow["备注(填表注意事项)"] = string.IsNullOrEmpty(temRow["备注(填表注意事项)"].ToString()) ? temDt.Rows[i]["备注(填表注意事项)"] : $"{temRow["备注(填表注意事项)"]}{temDt.Rows[i]["备注(填表注意事项)"]}";
  1239. //temRow["基本点数"] = string.IsNullOrEmpty(temRow["基本点数"].ToString()) ? temDt.Rows[i]["基本点数"] : $"{temRow["基本点数"]},{temDt.Rows[i]["基本点数"]}";
  1240. temRow["核稿绩效"] = string.IsNullOrEmpty(temRow["核稿绩效"].ToString()) ? temDt.Rows[i]["核稿绩效"] : $"{temRow["核稿绩效"]},{temDt.Rows[i]["核稿绩效"]}";
  1241. if (!temRow["处理人"].ToString().Contains(temDt.Rows[i]["处理人"].ToString()))
  1242. {
  1243. temRow["处理人"] = string.IsNullOrEmpty(temRow["处理人"].ToString()) ? temDt.Rows[i]["处理人"] : $"{temRow["处理人"]},{temDt.Rows[i]["处理人"]}";
  1244. temRow["处理人等级"] = string.IsNullOrEmpty(temRow["处理人等级"].ToString()) ? temDt.Rows[i]["处理人等级"] : $"{temRow["处理人等级"]},{temDt.Rows[i]["处理人等级"]}";
  1245. }
  1246. temRow["严重超期备注原因"] = string.IsNullOrEmpty(temRow["严重超期备注原因"].ToString()) ? temDt.Rows[i]["备注(发文严重超期是否属客观原因,若为否,请填写原因)"] : $"{temRow["严重超期备注原因"]}{temDt.Rows[i]["备注(发文严重超期是否属客观原因,若为否,请填写原因)"]}";
  1247. }
  1248. iTable = iEnd;
  1249. #endregion
  1250. temRow["是否一致"] = "不一致";
  1251. temRow["不一致原因"] = "系统中没有,Excel中有";
  1252. retTable.Rows.Add(temRow);
  1253. iTable++;
  1254. }
  1255. }
  1256. }
  1257. if (iList <=items.Count)
  1258. {
  1259. while(iList <items.Count){
  1260. var item = items[iList];
  1261. var temRow = retTable.NewRow();
  1262. Utility.Utility.CalBasePoint(item, Rules);
  1263. List<StaffStatistics> retPoints = new List<StaffStatistics>();
  1264. try
  1265. {
  1266. retPoints = _calItemJX( verifyCoefficients, item, spDb);
  1267. }
  1268. catch { }
  1269. temRow["我方文号"] = item.CaseNo;
  1270. temRow["处理事项"] = item.DoItem;
  1271. temRow["申请类型"] = item.ApplicationType;
  1272. temRow["业务类型"] = item.BusinessType;
  1273. temRow["案件阶段【系统】"] = item.CaseStage;
  1274. temRow["案件系数【系统】"] = item.CaseCoefficient;
  1275. temRow["处理事项系数【系统】"] = item.DoItemCoefficient;
  1276. temRow["核稿人【系统】"] = item.Reviewer?.Name;
  1277. temRow["备注(填表注意事项)【系统】"] = item.AgentFeedbackMemo;
  1278. temRow["基本点数【系统】"] = "";// item.BasePoint?.ToString();
  1279. temRow["严重超期备注原因"] = item.OverDueMemo;
  1280. if (item.ReviewerId != null)
  1281. {
  1282. temRow["核稿绩效【系统】"] = retPoints.FirstOrDefault(p => p.StaffId == item.ReviewerId)?.totalBasePoint;
  1283. }
  1284. foreach (var itemStaff in item.ItemStaffs)
  1285. {
  1286. //if (itemStaff.DoPerson.Status != "试用期")
  1287. //{
  1288. // if (retPoints != null && retPoints.Count > 0)
  1289. // {
  1290. // temRow["基本点数【系统】"] = string.IsNullOrEmpty(temRow["基本点数【系统】"].ToString()) ? retPoints.FirstOrDefault(p => p.StaffId == itemStaff.DoPersonId)?.totalBasePoint.ToString() : $"{temRow["基本点数【系统】"]},{retPoints.FirstOrDefault(p => p.StaffId == itemStaff.DoPersonId)?.totalBasePoint}";
  1291. // }
  1292. //}
  1293. temRow["处理人等级【系统】"] = string.IsNullOrEmpty(temRow["处理人等级【系统】"].ToString()) ? itemStaff.DoPerson.StaffGrade?.Grade : $"{temRow["处理人等级【系统】"]},{itemStaff.DoPerson.StaffGrade?.Grade }";
  1294. temRow["处理人系数【系统】"] = string.IsNullOrEmpty(temRow["处理人系数【系统】"].ToString()) ? itemStaff.DoPerson.StaffGrade?.Coefficient : $"{temRow["处理人系数【系统】"]},{itemStaff.DoPerson.StaffGrade?.Coefficient}";
  1295. temRow["处理人【系统】"] = string.IsNullOrEmpty(temRow["处理人【系统】"].ToString()) ? itemStaff.DoPerson.Name : $"{temRow["处理人【系统】"]},{itemStaff.DoPerson.Name}";
  1296. if (item.ReviewerId != null)
  1297. {
  1298. #region 取审核人等级审核等级系数
  1299. VerifyCoefficient vcoefficient
  1300. = verifyCoefficients.Where<VerifyCoefficient>(v =>
  1301. v.CheckerId == item.Reviewer.StaffGradeId
  1302. && v.DoPersonId == itemStaff.DoPerson.StaffGradeId)
  1303. .FirstOrDefault<VerifyCoefficient>();
  1304. #endregion
  1305. if (vcoefficient != null)
  1306. {
  1307. temRow["核稿系数【系统】"] = string.IsNullOrEmpty(temRow["核稿系数【系统】"].ToString()) ? vcoefficient.Coefficient.ToString() : $"{temRow["核稿系数【系统】"]},{vcoefficient.Coefficient}";
  1308. }
  1309. }
  1310. }
  1311. temRow["是否一致"] = "不一致";
  1312. temRow["不一致原因"] = "Excel中没有,系统中有";
  1313. iList++;
  1314. retTable.Rows.Add(temRow);
  1315. }
  1316. }
  1317. else
  1318. {
  1319. while (iTable < temDt.Rows.Count)
  1320. {
  1321. var temRow = retTable.NewRow();
  1322. int iBegin = iTable;
  1323. int iEnd = iTable;
  1324. #region 判断是否有重复记录,并将Excel表中的记录生成临时表中的一行记录
  1325. while (temDt.Rows[iTable]["我方文号"].ToString() == temDt.Rows[iTable + 1]["我方文号"].ToString() &&
  1326. temDt.Rows[iTable]["处理事项"].ToString() == temDt.Rows[iTable + 1]["处理事项"].ToString())
  1327. {
  1328. iEnd++;
  1329. }
  1330. temRow["我方文号"] = temDt.Rows[iTable]["我方文号"];
  1331. temRow["处理事项"] = temDt.Rows[iTable]["处理事项"];
  1332. temRow["申请类型"] = temDt.Rows[iTable]["申请类型"];
  1333. temRow["业务类型"] = temDt.Rows[iTable]["业务类型"];
  1334. temRow["案件阶段"] = temDt.Rows[iTable]["案件阶段"];
  1335. temRow["案件系数"] = temDt.Rows[iTable]["案件系数"];
  1336. temRow["处理事项系数"] = temDt.Rows[iTable]["处理事项系数"];
  1337. temRow["核稿人"] = temDt.Rows[iTable]["核稿人"];
  1338. temRow["备注(填表注意事项)"] = temDt.Rows[iTable]["备注(填表注意事项)"];
  1339. temRow["处理人等级"] = temDt.Rows[iTable]["处理人等级"];
  1340. temRow["基本点数"] = temDt.Rows[iTable]["基本点数"];
  1341. temRow["核稿系数"] = temDt.Rows[iTable]["核稿系数"];
  1342. temRow["核稿绩效"] = temDt.Rows[iTable]["核稿绩效"];
  1343. temRow["处理人"] = temDt.Rows[iTable]["处理人"];
  1344. temRow["严重超期备注原因"] = temDt.Rows[iTable]["备注(发文严重超期是否属客观原因,若为否,请填写原因)"];
  1345. for (int i = iBegin + 1; i <= iEnd; i++)
  1346. {
  1347. temRow["备注(填表注意事项)"] = string.IsNullOrEmpty(temRow["备注(填表注意事项)"].ToString()) ? temDt.Rows[i]["备注(填表注意事项)"] : $"{temRow["备注(填表注意事项)"]}{temDt.Rows[i]["备注(填表注意事项)"]}";
  1348. //temRow["基本点数"] = string.IsNullOrEmpty(temRow["基本点数"].ToString()) ? temDt.Rows[i]["基本点数"] : $"{temRow["基本点数"]},{temDt.Rows[i]["基本点数"]}";
  1349. temRow["核稿绩效"] = string.IsNullOrEmpty(temRow["核稿绩效"].ToString()) ? temDt.Rows[i]["核稿绩效"] : $"{temRow["核稿绩效"]},{temDt.Rows[i]["核稿绩效"]}";
  1350. if (!temRow["处理人"].ToString().Contains(temDt.Rows[i]["处理人"].ToString()))
  1351. {
  1352. temRow["处理人"] = string.IsNullOrEmpty(temRow["处理人"].ToString()) ? temDt.Rows[i]["处理人"] : $"{temRow["处理人"]},{temDt.Rows[i]["处理人"]}";
  1353. temRow["处理人等级"] = string.IsNullOrEmpty(temRow["处理人等级"].ToString()) ? temDt.Rows[i]["处理人等级"] : $"{temRow["处理人等级"]},{temDt.Rows[i]["处理人等级"]}";
  1354. }
  1355. temRow["严重超期备注原因"] = string.IsNullOrEmpty(temRow["严重超期备注原因"].ToString()) ? temDt.Rows[i]["严重超期备注原因"] : $"{temRow["严重超期备注原因"]}{temDt.Rows[i]["严重超期备注原因"]}";
  1356. }
  1357. iTable = iEnd;
  1358. #endregion
  1359. temRow["是否一致"] = "不一致";
  1360. temRow["不一致原因"] = "系统中没有,Excel中有";
  1361. retTable.Rows.Add(temRow);
  1362. iTable++;
  1363. }
  1364. }
  1365. NPOIExcel.DataTableToExcel(retTable, "c:\\temp\\202112-系统线下绩效记录对比.xlsx");
  1366. }
  1367. public List<StaffStatistics> CalItemJX(int itemid)
  1368. {
  1369. var Item = Context.PerformanceItems.Include(p=>p.CalMonth).FirstOrDefault(p=>p.Id == itemid);
  1370. List<VerifyCoefficient> verifyCoefficients = Context.VerifyCoefficients.ToList<VerifyCoefficient>();
  1371. return _calItemJX(verifyCoefficients,Item,Context);
  1372. }
  1373. private void _calItemJX(PerformanceItem Item,spDbContext spDb)
  1374. {
  1375. List<VerifyCoefficient> verifyCoefficients = spDb.VerifyCoefficients.ToList<VerifyCoefficient>();
  1376. var jxList = _calItemJX( verifyCoefficients, Item, spDb);
  1377. var oldJxList = spDb.StaffStatistics.Where(p=>p.ItemId == Item.Id);
  1378. spDb.StaffStatistics.RemoveRange(oldJxList);
  1379. spDb.SaveChanges();
  1380. foreach (var jx in jxList)
  1381. {
  1382. if(jx.totalBasePoint == 0)
  1383. {
  1384. return;
  1385. }
  1386. jx.ItemId = Item.Id;
  1387. spDb.StaffStatistics.Add(jx);
  1388. spDb.SaveChanges();
  1389. }
  1390. }
  1391. private List<StaffStatistics> _calItemJX( List<VerifyCoefficient> verifyCoefficients, PerformanceItem item,spDbContext spDb)
  1392. {
  1393. System.Collections.Hashtable doPersonsBL = new System.Collections.Hashtable();
  1394. List<StaffStatistics> itemStatistics = new List<StaffStatistics>();
  1395. if (item.ReviewerId != null)
  1396. {
  1397. item.Reviewer = spDb.Staffs.Include(s => s.StaffGrade).FirstOrDefault(p => p.Id == item.ReviewerId);
  1398. //spDb.Entry(item.Reviewer).Reference(b => b.StaffGrade).Load();
  1399. }
  1400. List<ItemStaff> temIStaffs = new List<ItemStaff>();
  1401. int syqUsers = 0;
  1402. foreach(var itemStaff in item.ItemStaffs)
  1403. {
  1404. if (itemStaff.DoPerson == null)
  1405. {
  1406. itemStaff.DoPerson = spDb.Staffs.Include(s => s.StaffGrade).FirstOrDefault(p => p.Id == itemStaff.DoPersonId);
  1407. }
  1408. if(itemStaff.DoPerson.Status == "试用期" || !itemStaff.DoPerson.IsCalPerformsnce )
  1409. {
  1410. syqUsers += 1;
  1411. }
  1412. else
  1413. {
  1414. temIStaffs.Add(itemStaff);
  1415. }
  1416. }
  1417. if(syqUsers == item.ItemStaffs.Count)
  1418. {
  1419. if(item.Reviewer != null)
  1420. {
  1421. temIStaffs.Add(new ItemStaff() { DoPersonId = item.ReviewerId.Value, ItemId = item.Id });
  1422. }
  1423. }
  1424. bool isPJFP = true;
  1425. double total = temIStaffs.Count();
  1426. if (temIStaffs.Where<ItemStaff>(p => p.PerformancePoint != null || p.PerformancePoint == 0).Count() > 0)
  1427. {
  1428. total = temIStaffs.Select(i => i.PerformancePoint.Value).Sum();
  1429. isPJFP = false;
  1430. }
  1431. foreach (ItemStaff itemStaff in temIStaffs)
  1432. {
  1433. if(itemStaff.DoPerson == null)
  1434. {
  1435. itemStaff.DoPerson = spDb.Staffs.Include(s=>s.StaffGrade).FirstOrDefault(p=>p.Id==itemStaff.DoPersonId);
  1436. }
  1437. //spDb.Entry(itemStaff).Reference(b => b.DoPerson).Load();
  1438. //spDb.Entry(itemStaff.DoPerson).Reference(b => b.StaffGrade).Load();
  1439. #region 计算审核人绩效点数,核稿人绩效点数按照核稿人与个处理人的核稿系数计算后加总,没有找到核稿系数(比如同级别),核稿系数为0
  1440. if (item.ReviewerId != null && item.Type != "专案" &&
  1441. temIStaffs.FirstOrDefault(s=>s.DoPersonId == item.ReviewerId) == null)
  1442. {
  1443. #region 取审核人等级审核等级系数
  1444. VerifyCoefficient vcoefficient
  1445. = verifyCoefficients.Where<VerifyCoefficient>(v =>
  1446. v.CheckerId == item.Reviewer.StaffGradeId
  1447. && v.DoPersonId == itemStaff.DoPerson.StaffGradeId)
  1448. .FirstOrDefault<VerifyCoefficient>();
  1449. #endregion
  1450. if (vcoefficient != null)
  1451. {
  1452. double reviewerBasePoint = item.BasePoint.Value * vcoefficient.Coefficient;
  1453. string temJxType = $"{item.Type}审核";
  1454. var temReviewerStatic = itemStatistics.Where<StaffStatistics>(s => s.StaffId == item.ReviewerId && s.jxType == temJxType && s.CalMonth.Id == item.CalMonthId).FirstOrDefault();
  1455. if (temReviewerStatic != null)
  1456. {
  1457. temReviewerStatic.totalBasePoint += reviewerBasePoint;
  1458. temReviewerStatic.totalActuallyPoint += reviewerBasePoint;
  1459. }
  1460. else
  1461. {
  1462. if (itemStaff.DoPerson.Status != "试用期" && item.Reviewer.IsCalPerformsnce ) //判断是否在职
  1463. {
  1464. temReviewerStatic = new StaffStatistics()
  1465. {
  1466. CalMonthId = item.CalMonthId,
  1467. StaffId = item.ReviewerId.Value,
  1468. totalBasePoint = reviewerBasePoint,
  1469. totalActuallyPoint = reviewerBasePoint,
  1470. jxType = temJxType
  1471. };
  1472. itemStatistics.Add(temReviewerStatic);
  1473. }
  1474. }
  1475. }
  1476. }
  1477. #endregion
  1478. #region 计算各处理人的绩效点数
  1479. double handlerBasePoint;
  1480. if (item.Type != "专案")
  1481. {
  1482. if (isPJFP)
  1483. {
  1484. handlerBasePoint = item.BasePoint.Value * 1.0 / total;
  1485. }
  1486. else
  1487. {
  1488. handlerBasePoint = item.BasePoint.Value * itemStaff.PerformancePoint.Value / total;
  1489. }
  1490. }
  1491. else
  1492. {
  1493. if (itemStaff.PerformancePoint == null)
  1494. {
  1495. if (isPJFP)
  1496. {
  1497. handlerBasePoint = item.BasePoint.Value * 1.0 / total;
  1498. }
  1499. else
  1500. {
  1501. handlerBasePoint = item.BasePoint.Value * itemStaff.PerformancePoint.Value / total;
  1502. }
  1503. }
  1504. else
  1505. {
  1506. if(item.ItemStaffs.Count ==1 && itemStaff .PerformancePoint == 0)
  1507. {
  1508. handlerBasePoint = item.BasePoint.Value;
  1509. }
  1510. else
  1511. {
  1512. handlerBasePoint = itemStaff.PerformancePoint.Value;
  1513. }
  1514. }
  1515. }
  1516. string handlerJxType = $"{item.Type}处理";
  1517. var temStatic = itemStatistics.Where<StaffStatistics>(s => s.StaffId == itemStaff.DoPersonId && s.jxType == handlerJxType && s.CalMonth.Id == item.CalMonthId).FirstOrDefault();
  1518. if (temStatic != null)
  1519. {
  1520. temStatic.totalBasePoint += handlerBasePoint;
  1521. if (item.Type == "OA" || item.Type == "新申请")
  1522. {
  1523. temStatic.totalActuallyPoint += handlerBasePoint * itemStaff.DoPerson.StaffGrade.Coefficient;
  1524. }
  1525. else
  1526. {
  1527. temStatic.totalActuallyPoint += handlerBasePoint;
  1528. }
  1529. }
  1530. else
  1531. {
  1532. if (itemStaff.DoPerson.StaffGradeId != null && itemStaff.DoPerson.IsCalPerformsnce)
  1533. {
  1534. if (item.Type == "OA" || item.Type == "新申请")
  1535. {
  1536. if (itemStaff.DoPerson.Status == "试用期" && item.Reviewer != null)
  1537. {
  1538. temStatic = new StaffStatistics()
  1539. {
  1540. CalMonthId = item.CalMonthId,
  1541. StaffId = item.Reviewer.Id,
  1542. totalActuallyPoint= handlerBasePoint * item.Reviewer.StaffGrade.Coefficient,
  1543. totalBasePoint = handlerBasePoint,
  1544. jxType = handlerJxType
  1545. };
  1546. itemStatistics.Add(temStatic);
  1547. }
  1548. else
  1549. {
  1550. itemStaff.DoPerson.StaffGrade = spDb.StaffGrades.FirstOrDefault(s=>s.Id == itemStaff.DoPerson.StaffGradeId);
  1551. temStatic = new StaffStatistics()
  1552. {
  1553. //CalMonth = calMonth,
  1554. CalMonthId = item.CalMonthId,
  1555. StaffId = itemStaff.DoPersonId,
  1556. totalActuallyPoint = handlerBasePoint * itemStaff.DoPerson.StaffGrade.Coefficient,
  1557. totalBasePoint = handlerBasePoint,
  1558. jxType = handlerJxType
  1559. };
  1560. itemStatistics.Add(temStatic);
  1561. }
  1562. }
  1563. else
  1564. {
  1565. temStatic = new StaffStatistics()
  1566. {
  1567. //CalMonth = calMonth,
  1568. CalMonthId = item.CalMonthId,
  1569. StaffId = itemStaff.DoPersonId,
  1570. totalBasePoint = handlerBasePoint,
  1571. totalActuallyPoint = handlerBasePoint,
  1572. jxType = handlerJxType
  1573. };
  1574. itemStatistics.Add(temStatic);
  1575. }
  1576. }
  1577. }
  1578. #endregion
  1579. }
  1580. return itemStatistics;
  1581. }
  1582. private void _CalJXPoint(CalMonth calMonth,spDbContext spDb)
  1583. {
  1584. NanduStatics gspjXS = DegreeOfDifficulty(calMonth,spDb);
  1585. calMonth.NanduXS = gspjXS.NanduXS;
  1586. calMonth.S = gspjXS.S;
  1587. calMonth.A = gspjXS.A;
  1588. calMonth.B = gspjXS.B;
  1589. calMonth.C = gspjXS.C;
  1590. calMonth.D = gspjXS.D;
  1591. var retList = spDb.StaffStatistics.Where(s => s.CalMonthId == calMonth.Id).ToList();
  1592. #region 新申请处理+专案处理 奖励点数
  1593. double jlPoint = 0;
  1594. if (calMonth.S.HasValue)
  1595. {
  1596. jlPoint = jlPoint + (calMonth.S.Value * 1.5);
  1597. }
  1598. if (calMonth.A.HasValue)
  1599. {
  1600. jlPoint = jlPoint + (calMonth.A.Value * 0.5);
  1601. }
  1602. #endregion
  1603. double? totalFPBLPoint = 0; //新申请处理+专案 分配比率总点数
  1604. #region 难度系数
  1605. IDictionary<int, NanduStatics> staffXiShu = new Dictionary<int, NanduStatics>();
  1606. IDictionary<int, NanduStatics> ReivewerXiShu = new Dictionary<int, NanduStatics>();
  1607. foreach (StaffStatistics ss in retList)
  1608. {
  1609. if (ss.jxType == "新申请处理" || ss.jxType == "专案处理")
  1610. {
  1611. #region 新申请处理+专案处理
  1612. if (!staffXiShu.ContainsKey(ss.StaffId))
  1613. {
  1614. NanduStatics nandu = PersonNanduStatics(calMonth, ss.StaffId,spDb);
  1615. staffXiShu.Add(ss.StaffId, nandu);
  1616. }
  1617. ss.FinianlPoint = ss.totalActuallyPoint * staffXiShu[ss.StaffId].NanduXS / gspjXS.NanduXS;
  1618. totalFPBLPoint += ss.FinianlPoint;
  1619. ss.NanduXS = staffXiShu[ss.StaffId].NanduXS;
  1620. ss.S = staffXiShu[ss.StaffId].S;
  1621. ss.A = staffXiShu[ss.StaffId].A;
  1622. ss.B = staffXiShu[ss.StaffId].B;
  1623. ss.C = staffXiShu[ss.StaffId].C;
  1624. ss.D = staffXiShu[ss.StaffId].D;
  1625. #endregion
  1626. }
  1627. else
  1628. {
  1629. if (ss.jxType == "新申请审核")
  1630. {
  1631. if (!ReivewerXiShu.ContainsKey(ss.StaffId))
  1632. {
  1633. NanduStatics nandu = PersonNanduStatics(calMonth, ss.StaffId,spDb, true);
  1634. ReivewerXiShu.Add(ss.StaffId, nandu);
  1635. }
  1636. ss.FinianlPoint = ss.totalBasePoint * ReivewerXiShu[ss.StaffId].NanduXS / gspjXS.NanduXS;
  1637. ss.NanduXS = ReivewerXiShu[ss.StaffId].NanduXS;
  1638. ss.S = ReivewerXiShu[ss.StaffId].S;
  1639. ss.A = ReivewerXiShu[ss.StaffId].A;
  1640. ss.B = ReivewerXiShu[ss.StaffId].B;
  1641. ss.C = ReivewerXiShu[ss.StaffId].C;
  1642. ss.D = ReivewerXiShu[ss.StaffId].D;
  1643. spDb.SaveChanges();
  1644. }
  1645. else
  1646. {
  1647. ss.FinianlPoint = ss.totalBasePoint;
  1648. spDb.SaveChanges();
  1649. }
  1650. }
  1651. }
  1652. foreach (StaffStatistics ss in retList)
  1653. {
  1654. if (ss.jxType == "新申请处理" || ss.jxType == "专案处理")
  1655. {
  1656. ss.FinianlPoint = ss.FinianlPoint / totalFPBLPoint * (totalFPBLPoint + jlPoint);
  1657. Context.SaveChanges();
  1658. }
  1659. }
  1660. #endregion
  1661. }
  1662. public void CalJXPoint(int year, int month)
  1663. {
  1664. CalMonth calMonth = Context.CalMonths.Where<CalMonth>(c => c.Month == month && c.Year == year).FirstOrDefault();
  1665. if (calMonth != null)
  1666. {
  1667. using (var t = Context.Database.BeginTransaction())
  1668. {
  1669. try
  1670. {
  1671. var result = Context.StaffStatistics.Where(s => s.CalMonthId == calMonth.Id);
  1672. Context.StaffStatistics.RemoveRange(result);
  1673. var itemList = Context.PerformanceItems.Include(s => s.ItemStaffs).
  1674. Where(s => s.CalMonthId == calMonth.Id).ToList();
  1675. var rules = Context.BasePointRules.ToList();
  1676. foreach (var item in itemList)
  1677. {
  1678. Utility.Utility.CalBasePoint(item, rules);
  1679. Context.SaveChanges();
  1680. if (item.BasePoint > 0)
  1681. {
  1682. _calItemJX(item,Context);
  1683. }
  1684. //_CalItemJX(item.Id);
  1685. }
  1686. _CalJXPoint(calMonth, Context);
  1687. t.Commit();
  1688. }
  1689. catch (Exception ex)
  1690. {
  1691. t.Rollback();
  1692. }
  1693. }
  1694. }
  1695. }
  1696. /// <summary>
  1697. /// 新申请/专案:
  1698. /// 调整点数 = 分配比例点数/分配比例点数之和*总点数
  1699. /// 等级调整点数+项目组点数之和 = 基础点数 * 代理人等级系数 + 项目组案件调整点数
  1700. /// 分配比例点数 = 个人平均难度系数 / 总平均难度系数 *(等级调整点数+项目组点数之和)
  1701. /// 总点数=等级调整点数+项目组点数之和+奖励点数
  1702. /// 奖励点数= S案数量*1.5 + A案数量 * 0.5
  1703. /// 难度系数=(S案数量*2.5 + A案数量* 1.5 + B案数量*1.0 + C案数量*0.7+ D案数量*0.4) / 总案件数量
  1704. /// 总案件数量= S案数量 + A案数量 + B案数量 + C案数量+ D案数量
  1705. /// OA :
  1706. /// 调整点数= 基础点数 * 等级系数
  1707. /// 其他:
  1708. /// 直接加和基础点数 不需要乘以系数
  1709. /// </summary>
  1710. /// <param name="year"></param>
  1711. /// <param name="month"></param>
  1712. /// <returns></returns>
  1713. public ApiSaveResponse FinishedCalMonth(int year,int month)
  1714. {
  1715. CalMonth calMonth = Context.CalMonths.Where<CalMonth>(c => c.Month == month && c.Year == year).FirstOrDefault();
  1716. if (calMonth != null || calMonth.Status !=4)
  1717. {
  1718. using (var t = Context.Database.BeginTransaction())
  1719. {
  1720. try
  1721. {
  1722. _CalJXPoint(calMonth, Context);
  1723. calMonth.Status = 4;
  1724. Context.SaveChanges();
  1725. t.Commit();
  1726. return new ApiSaveResponse()
  1727. {
  1728. Success = true
  1729. };
  1730. }
  1731. catch (Exception ex)
  1732. {
  1733. t.Rollback();
  1734. return new ApiSaveResponse()
  1735. {
  1736. Success = false,
  1737. ErrorMessage = ex.Message
  1738. };
  1739. }
  1740. }
  1741. }
  1742. else
  1743. {
  1744. return new ApiSaveResponse()
  1745. {
  1746. Success = false,
  1747. ErrorMessage ="指定月份没有数据或者已归档!"
  1748. };
  1749. }
  1750. }
  1751. /// <summary>
  1752. /// 计算指定用户,指定年月的绩效统计信息
  1753. /// </summary>
  1754. /// <param name="userid"></param>
  1755. /// <param name="year"></param>
  1756. /// <param name="month"></param>
  1757. /// <returns></returns>
  1758. public List<StaffStatistics> CalMyStatistics(int year,int month, int? userid=null)
  1759. {
  1760. //object retList;
  1761. //string strKey = $"CalMyStatistics:{year}-{month}-{userid}";
  1762. //if(!MyMemoryCache.TryGetValue(strKey,out retList))
  1763. //{
  1764. CalMonth calMonth = Context.CalMonths.Where<CalMonth>(c => c.Month == month && c.Year == year).FirstOrDefault();
  1765. if (calMonth == null)
  1766. {
  1767. return null;
  1768. }
  1769. else
  1770. {
  1771. return _CalMyStatistics(calMonth, userid);
  1772. #region old code
  1773. //if (calMonth.Status == 4)
  1774. //{
  1775. // //已归档,归档数据库中直接取出记录
  1776. // if (userid == null)
  1777. // {
  1778. // retList = Context.StaffStatistics.Where<StaffStatistics>(s => s.CalMonthId == calMonth.Id).ToList<StaffStatistics>();
  1779. // }
  1780. // else
  1781. // {
  1782. // retList = Context.StaffStatistics.Where<StaffStatistics>(s => s.CalMonthId == calMonth.Id && s.StaffId == userid).ToList<StaffStatistics>();
  1783. // }
  1784. //}
  1785. //else
  1786. //{
  1787. // try
  1788. // {
  1789. // retList = _CalMyStatistics(calMonth, userid);
  1790. // }
  1791. // catch(Exception ex)
  1792. // {
  1793. // StreamWriter sw = System.IO.File.AppendText("c:\\temp\\log.txt");
  1794. // sw.WriteLine($"{ex.Message}");
  1795. // sw.Flush();
  1796. // sw.Close();
  1797. // sw.Dispose();
  1798. // }
  1799. //}
  1800. //// Set cache options.
  1801. //var cacheEntryOptions = new MemoryCacheEntryOptions()
  1802. // // Keep in cache for this time, reset time if accessed.
  1803. // .SetSlidingExpiration(TimeSpan.FromHours(1));
  1804. //foreach(var temObj in (List<StaffStatistics>)retList)
  1805. //{
  1806. // temObj.CalMonth.PerformanceItems = null;
  1807. //}
  1808. //// Save data in cache.
  1809. //MyMemoryCache.SetValue(strKey, retList);
  1810. //return (List<StaffStatistics>)retList;
  1811. #endregion
  1812. }
  1813. //}
  1814. //else
  1815. //{
  1816. // var temList = (List<StaffStatistics>)retList;
  1817. // foreach (var temObj in temList)
  1818. // {
  1819. // temObj.CalMonth.PerformanceItems = null;
  1820. // }
  1821. // return temList;
  1822. //}
  1823. }
  1824. private string GetExpress(IList<FieldCondition> conditions)
  1825. {
  1826. string str = "";
  1827. foreach(var c in conditions)
  1828. {
  1829. if (string.IsNullOrEmpty(str))
  1830. {
  1831. str = c.ToExpressString("s");
  1832. }
  1833. else
  1834. {
  1835. if(c.LogicOperate == LogicEnum.And)
  1836. {
  1837. str = $"({str}) && {c.ToExpressString("s")}";
  1838. }
  1839. else
  1840. {
  1841. str = $"({str}) || {c.ToExpressString("s")}";
  1842. }
  1843. }
  1844. }
  1845. return str;
  1846. }
  1847. [HttpGet,HttpPost]
  1848. public FileProcessTask ExportData(QueryFilter queryFilter)
  1849. {
  1850. var filename = $"{DateTime.Now.ToString("yyyyMMddhhmmss")}-绩效数据下载.xlsx";
  1851. var attachfileSavePath = utility.ConfigHelper.GetSectionValue("AttachFileSavePath");
  1852. var filePath = Path.Combine(attachfileSavePath, filename);
  1853. var fileTask = new FileProcessTask()
  1854. {
  1855. Id = Guid.NewGuid().ToString(),
  1856. FileName = filename,
  1857. FilePath = filePath,
  1858. Processed = 0
  1859. };
  1860. fileTaskService.Add(fileTask);
  1861. ThreadObject threadObject = new ThreadObject()
  1862. {
  1863. queryFilter = queryFilter,
  1864. fileTask = fileTask
  1865. };
  1866. System.Threading.Thread t = new System.Threading.Thread(new ParameterizedThreadStart(ExportDataThread));
  1867. t.Start(threadObject);
  1868. return fileTask;
  1869. }
  1870. internal class ThreadObject
  1871. {
  1872. public QueryFilter queryFilter { get; set; }
  1873. public FileProcessTask fileTask { get; set; }
  1874. }
  1875. private void ExportDataThread(object tObj)
  1876. {
  1877. QueryFilter queryFilter = ((ThreadObject)tObj).queryFilter;
  1878. FileProcessTask fileTask = ((ThreadObject)tObj).fileTask;
  1879. IQueryable<PerformanceItem> response = NewMethod(queryFilter);
  1880. var retList = response
  1881. .Include(p=>p.Customer)
  1882. .Include(p=>p.ItemStaffs).ThenInclude(p=>p.DoPerson).ThenInclude(p=>p.StaffGrade)
  1883. .Include(p=>p.Reviewer).ThenInclude(p=>p.StaffGrade)
  1884. .Include(p=>p.PreOastaff)
  1885. .Include(p=>p.CalMonth)
  1886. .ToList<PerformanceItem>();
  1887. DataTable dt = new DataTable();
  1888. #region 添加栏位
  1889. dt.Columns.Add("我方文号",typeof(string));
  1890. dt.Columns.Add("申请类型", typeof(string));
  1891. dt.Columns.Add("业务类型", typeof(string));
  1892. dt.Columns.Add("备注(填表注意事项)", typeof(string));
  1893. dt.Columns.Add("处理事项", typeof(string));
  1894. dt.Columns.Add("案件阶段", typeof(string));
  1895. dt.Columns.Add("案件系数", typeof(string));
  1896. dt.Columns.Add("处理事项系数", typeof(string));
  1897. dt.Columns.Add("前一次OA处理事项系数", typeof(string));
  1898. dt.Columns.Add("前一次OA处理人", typeof(string));
  1899. dt.Columns.Add("处理人等级", typeof(string));
  1900. dt.Columns.Add("基本点数", typeof(string));
  1901. dt.Columns.Add("核稿系数", typeof(string));
  1902. dt.Columns.Add("核稿绩效", typeof(string));
  1903. dt.Columns.Add("处理人", typeof(string));
  1904. dt.Columns.Add("核稿人", typeof(string));
  1905. dt.Columns.Add("客户名称", typeof(string));
  1906. dt.Columns.Add("申请人", typeof(string));
  1907. dt.Columns.Add("处理事项完成日", typeof(string));
  1908. dt.Columns.Add("定稿日", typeof(string));
  1909. dt.Columns.Add("返稿日", typeof(string));
  1910. dt.Columns.Add("案件类型", typeof(string));
  1911. dt.Columns.Add("案件状态", typeof(string));
  1912. dt.Columns.Add("处理事项备注", typeof(string));
  1913. dt.Columns.Add("处理状态", typeof(string));
  1914. dt.Columns.Add("案件名称", typeof(string));
  1915. dt.Columns.Add("委案日期", typeof(string));
  1916. dt.Columns.Add("客户期限", typeof(string));
  1917. dt.Columns.Add("内部期限", typeof(string));
  1918. dt.Columns.Add("初稿日", typeof(string));
  1919. dt.Columns.Add("备注(发文严重超期是否属客观原因,若为否,请填写原因)", typeof(string));
  1920. dt.Columns.Add("备注", typeof(string));
  1921. #endregion
  1922. List<VerifyCoefficient> verifyCoefficients = new spDbContext().VerifyCoefficients.ToList();
  1923. fileTask.Size = retList.Count;
  1924. foreach (var item in retList)
  1925. {
  1926. fileTask.Processed += 1;
  1927. if (item.CaseNo.StartsWith("J"))
  1928. {
  1929. continue;
  1930. }
  1931. try
  1932. {
  1933. var row = dt.NewRow();
  1934. row["我方文号"] = item.CaseNo;
  1935. row["申请类型"] = item.ApplicationType;
  1936. row["业务类型"] = item.BusinessType;
  1937. row["备注(填表注意事项)"] = item.AgentFeedbackMemo;
  1938. row["处理事项"] = item.DoItem;
  1939. row["案件阶段"] = item.CaseStage;
  1940. row["案件系数"] = item.CaseCoefficient;
  1941. row["处理事项系数"] = item.DoItemCoefficient;
  1942. row["前一次OA处理事项系数"] = "";
  1943. if (item.PreOastaffId.HasValue)
  1944. {
  1945. row["前一次OA处理人"] = item.PreOastaff?.Name;
  1946. }
  1947. string strISLevels = "";
  1948. string strISNames = "";
  1949. foreach (var istaff in item.ItemStaffs)
  1950. {
  1951. strISLevels = string.IsNullOrEmpty(strISLevels)?istaff.DoPerson.StaffGrade?.Grade : $"{strISLevels},{istaff.DoPerson.StaffGrade?.Grade}";
  1952. strISNames = string.IsNullOrEmpty(strISNames)?istaff.DoPerson.Name : $"{strISNames},{istaff.DoPerson.Name}";
  1953. }
  1954. row["处理人等级"] = strISLevels;
  1955. row["基本点数"] = item.BasePoint;
  1956. row["处理人"] = strISNames;
  1957. row["核稿人"] = item.Reviewer?.Name;
  1958. if (item.ReviewerId != null && item.BasePoint.HasValue)
  1959. {
  1960. var jxList = _calItemJX( verifyCoefficients, item, new spDbContext());
  1961. row["核稿系数"] = "";
  1962. var temJx = jxList.FirstOrDefault<StaffStatistics>(s => s.jxType.Contains("审核") && s.StaffId == item.ReviewerId);
  1963. if (temJx != null)
  1964. {
  1965. row["核稿绩效"] = temJx.totalBasePoint;
  1966. }
  1967. }
  1968. row["客户名称"] = item.Customer?.Name;
  1969. row["申请人"] = item.ApplicationName;
  1970. row["处理事项完成日"] = item.FinishedDate?.ToString("yyyy-MM-dd");
  1971. row["定稿日"] = item.FinalizationDate?.ToString("yyyy-MM-dd");
  1972. row["返稿日"] = item.ReturnDate?.ToString("yyyy-MM-dd");
  1973. row["案件类型"] = item.CaseType;
  1974. row["案件状态"] = item.CaseState;
  1975. row["处理事项备注"] = item.DoItemState;
  1976. row["处理状态"] = item.DoItemState;
  1977. row["案件名称"] = item.CaseName;
  1978. row["委案日期"] = item.EntrustingDate?.ToString("yyyy-MM-dd");
  1979. row["客户期限"] = item.CustomerLimitDate?.ToString("yyyy-MM-dd");
  1980. row["内部期限"] = item.InternalDate?.ToString("yyyy-MM-dd"); ;
  1981. row["初稿日"] = item.FirstDraftDate?.ToString("yyyy-MM-dd");
  1982. row["备注(发文严重超期是否属客观原因,若为否,请填写原因)"] = item.OverDueMemo;
  1983. row["备注"] = item.DoItemMemo;
  1984. dt.Rows.Add(row);
  1985. }
  1986. catch(Exception ex)
  1987. {
  1988. throw ex;
  1989. }
  1990. }
  1991. utility.NPOIExcel.DataTableToExcel(dt,fileTask.FilePath);
  1992. fileTask.Finished = true;
  1993. }
  1994. [HttpPost]
  1995. public ListApiResponse<PerformanceItem> QueryFilter(QueryFilter queryFilter)
  1996. {
  1997. ListApiResponse<PerformanceItem> ret = new ListApiResponse<PerformanceItem>();
  1998. IQueryable<PerformanceItem> response = NewMethod(queryFilter);
  1999. int totals = response.ToList<PerformanceItem>().Count;
  2000. if (totals > 0 && totals < (queryFilter.PageIndex - 1) * queryFilter.PageSize)
  2001. {
  2002. response = response
  2003. .Include(pi => pi.ItemStaffs).ThenInclude(iStaff => iStaff.DoPerson)
  2004. .Include(pi => pi.Reviewer)
  2005. .Include(pi => pi.Customer)
  2006. .Include(pi => pi.CalMonth)
  2007. .OrderConditions<PerformanceItem>(queryFilter.Sorts);
  2008. //.Pager<PerformanceItem>(1, queryFilter.PageSize, out totals);
  2009. }
  2010. else
  2011. {
  2012. response = response
  2013. .Include(pi => pi.ItemStaffs).ThenInclude(iStaff => iStaff.DoPerson)
  2014. .Include(pi => pi.Reviewer)
  2015. .Include(pi => pi.Customer)
  2016. .Include(pi => pi.CalMonth)
  2017. .OrderConditions<PerformanceItem>(queryFilter.Sorts);
  2018. //.Pager<PerformanceItem>(queryFilter.PageIndex, queryFilter.PageSize, out totals);
  2019. }
  2020. ret.TotalCount = totals;
  2021. var retList = response.ToList<PerformanceItem>().Skip((queryFilter.PageIndex-1) *queryFilter.PageSize).Take(queryFilter.PageSize);
  2022. #region 将某些属性设为null,避免循环取值造成返回json过大
  2023. foreach (PerformanceItem item in retList)
  2024. {
  2025. foreach (ItemStaff itemStaff in item.ItemStaffs)
  2026. {
  2027. itemStaff.DoPerson.ItemStaffs = null;
  2028. itemStaff.DoPerson.ReviewerItems = null;
  2029. itemStaff.Item = null;
  2030. }
  2031. if (item.Reviewer != null)
  2032. {
  2033. item.Reviewer.ReviewerItems = null;
  2034. item.Reviewer.Customers = null;
  2035. item.Reviewer.ItemStaffs = null;
  2036. }
  2037. if (item.WorkflowUser != null)
  2038. {
  2039. item.WorkflowUser.ReviewerItems = null;
  2040. item.WorkflowUser.Customers = null;
  2041. item.WorkflowUser.ItemStaffs = null;
  2042. }
  2043. if (item.Customer != null)
  2044. {
  2045. item.Customer.PerformanceItems = null;
  2046. }
  2047. if (item.CalMonth != null)
  2048. {
  2049. item.CalMonth.PerformanceItems = null;
  2050. }
  2051. }
  2052. #endregion
  2053. ret.Results = retList.ToList();
  2054. return ret;
  2055. }
  2056. private IQueryable<PerformanceItem> NewMethod(QueryFilter queryFilter)
  2057. {
  2058. string strExpress = "";
  2059. string strCalMonth = "";
  2060. if (queryFilter.CalMonthId.HasValue)
  2061. {
  2062. strCalMonth = $"s.CalMonthId == {queryFilter.CalMonthId}";
  2063. }
  2064. else
  2065. {
  2066. if(queryFilter.jxType == jxType.finished)
  2067. {
  2068. strCalMonth = $"s.CalMonth.Status == 4";
  2069. }
  2070. else
  2071. {
  2072. strCalMonth = $"s.CalMonth.Status != 4";
  2073. }
  2074. //strCalMonth = $"s.CalMonth.Status == {Convert.ToInt32(queryFilter.jxType)}";
  2075. }
  2076. if (!string.IsNullOrEmpty(strExpress))
  2077. {
  2078. strExpress = $"{strExpress} && {strCalMonth}";
  2079. }
  2080. else
  2081. {
  2082. strExpress = strCalMonth;
  2083. }
  2084. if (queryFilter.ConditionTree != null)
  2085. {
  2086. string strTem = GetExpress(queryFilter.ConditionTree);
  2087. if (!string.IsNullOrEmpty(strTem))
  2088. {
  2089. strExpress = $"{strExpress} && ({strTem})";
  2090. }
  2091. }
  2092. var interpreter = new Interpreter();
  2093. Expression<Func<PerformanceItem, bool>> dynamicWhere = interpreter.ParseAsExpression<Func<PerformanceItem, bool>>(strExpress, "s");
  2094. IQueryable<PerformanceItem> response;
  2095. if (queryFilter.userId > 0)
  2096. {
  2097. if (queryFilter.DoingOrReview == 0)
  2098. {
  2099. response = new spDbContext().PerformanceItems.Where<PerformanceItem>(dynamicWhere).Where(s => (s.ItemStaffs.Where<ItemStaff>(iStaff => iStaff.DoPerson.Id == queryFilter.userId).Count() > 0));
  2100. }
  2101. else
  2102. {
  2103. response = new spDbContext().PerformanceItems.Where<PerformanceItem>(dynamicWhere).Where(s => s.ReviewerId == queryFilter.userId);
  2104. }
  2105. }
  2106. else
  2107. {
  2108. response = new spDbContext().PerformanceItems.Where<PerformanceItem>(dynamicWhere);
  2109. }
  2110. return response;
  2111. }
  2112. public ApiSaveResponse AddProjectContents(ProjectContents projectContents)
  2113. {
  2114. ApiSaveResponse retResponse = new ApiSaveResponse();
  2115. retResponse.Success = true;
  2116. if (projectContents != null && projectContents.ProjectWorkContents != null && projectContents.ProjectWorkContents.Count > 0)
  2117. {
  2118. using (var t = Context.Database.BeginTransaction())
  2119. {
  2120. try
  2121. {
  2122. CalMonth calMonth = Context.CalMonths.FirstOrDefault<CalMonth>(c => c.Status == 0);
  2123. if (calMonth == null)
  2124. {
  2125. retResponse.Success = false;
  2126. retResponse.ErrorMessage = "不存在正在处理的绩效月度!";
  2127. return retResponse;
  2128. }
  2129. else
  2130. {
  2131. projectContents.ProjectContentRecord.CalMonthId = calMonth.Id;
  2132. projectContents.ProjectContentRecord.CalMonth = null;
  2133. var staff = Context.Staffs.FirstOrDefault(s=>s.Name == User.Identity.Name);
  2134. projectContents.ProjectContentRecord.StaffId = staff.Id;
  2135. projectContents.ProjectContentRecord.State = 0;
  2136. }
  2137. var project = Context.ProjectInfos.FirstOrDefault(p => p.CaseNo == projectContents.ProjectContentRecord.ProjectNo && p.CaseState ==0);
  2138. if (project != null)
  2139. {
  2140. var pRecord = Context.ProjectContentRecords.FirstOrDefault(p=>p.ProjectNo == projectContents.ProjectContentRecord.ProjectNo
  2141. && p.StaffId == projectContents.ProjectContentRecord.StaffId
  2142. && p.CalMonthId == projectContents.ProjectContentRecord.CalMonthId);
  2143. if(pRecord != null)
  2144. {
  2145. retResponse.Success = false;
  2146. retResponse.ErrorMessage = $"您已提交专案【{projectContents.ProjectContentRecord.ProjectNo}】{pRecord.CalMonth.Year}年{pRecord.CalMonth.Month}月的工作内容!";
  2147. return retResponse;
  2148. }
  2149. Context.ProjectContentRecords.Add(projectContents.ProjectContentRecord);
  2150. foreach (var doItem in projectContents.ProjectWorkContents)
  2151. {
  2152. doItem.ContentRecordId = projectContents.ProjectContentRecord.Id;
  2153. Context.ProjectWorkContents.Add(doItem);
  2154. }
  2155. t.Commit();
  2156. }
  2157. else
  2158. {
  2159. retResponse.Success = false;
  2160. retResponse.ErrorMessage = "专案不存在或专案已完成!";
  2161. return retResponse;
  2162. }
  2163. }
  2164. catch (Exception ex)
  2165. {
  2166. retResponse.Success = false;
  2167. retResponse.ErrorMessage = ex.Message;
  2168. t.Rollback();
  2169. return retResponse;
  2170. }
  2171. }
  2172. }
  2173. return retResponse;
  2174. }
  2175. public PerformanceItem GetCaseInfo(string CaseNo)
  2176. {
  2177. var retObj = Context.PerformanceItems.OrderByDescending(p=>p.CalMonthId).FirstOrDefault<PerformanceItem>(p=>p.CaseNo == CaseNo.Trim());
  2178. if(retObj == null)
  2179. {
  2180. retObj = new IPEasyController(Context).GetCaseInfo(CaseNo);
  2181. }
  2182. return retObj;
  2183. }
  2184. public PerformanceItem GetItemInfo(string CaseNo, string DoItem)
  2185. {
  2186. var retObj = Context.PerformanceItems.FirstOrDefault<PerformanceItem>(p => p.CaseNo == CaseNo.Trim() && p.DoItem == DoItem.Trim());
  2187. if (retObj == null)
  2188. {
  2189. retObj = new IPEasyController(Context).GetItemInfo(CaseNo,DoItem);
  2190. }
  2191. return retObj;
  2192. }
  2193. public PerformanceItem GetItemInfoByCaseStage(string CaseNo, string DoItem,string caseStage,bool UpdateFromIPEasy=true)
  2194. {
  2195. var retObj = Context.PerformanceItems.Include(p=>p.Customer).FirstOrDefault<PerformanceItem>(p => p.CaseNo == CaseNo.Trim()
  2196. && p.DoItem == DoItem.Trim() && p.CaseStage == caseStage);
  2197. if (retObj == null && UpdateFromIPEasy)
  2198. {
  2199. var temObj = IPEasyUtility.GetPerformanceRecord(CaseNo, DoItem, caseStage);
  2200. System.Dynamic.ExpandoObject temExpandoObject = (System.Dynamic.ExpandoObject)temObj;
  2201. retObj = new PerformanceItem();
  2202. retObj.CaseNo = temObj.CaseNo.ToString();
  2203. retObj.CaseName = temObj.CaseName.ToString();
  2204. try
  2205. {
  2206. if (temObj.ApplicationType != null)
  2207. retObj.ApplicationType = temObj.ApplicationType.ToString();
  2208. if (temObj.CaseMemo != null)
  2209. retObj.CaseMemo = temObj.CaseMemo.ToString();
  2210. if (temObj.BusinessType != null)
  2211. retObj.BusinessType = temObj.BusinessType.ToString();
  2212. if (temObj.DoItem != null)
  2213. retObj.DoItem = temObj.DoItem.ToString();
  2214. if (temObj.CaseStage != null)
  2215. retObj.CaseStage = temObj.CaseStage.ToString();
  2216. if (temObj.CaseType != null)
  2217. retObj.CaseType = temObj.CaseType.ToString();
  2218. if (temObj.DoItemState != null)
  2219. retObj.DoItemState = temObj.DoItemState.ToString();
  2220. if (temObj.DoItemCoefficient != null)
  2221. retObj.DoItemCoefficient = temObj.DoItemCoefficient.ToString();
  2222. if (temObj.CaseCoefficient != null)
  2223. retObj.CaseCoefficient = temObj.CaseCoefficient.ToString();
  2224. if (temObj.EntrustingDate != null)
  2225. {
  2226. if (!string.IsNullOrEmpty(temObj.EntrustingDate.ToString()))
  2227. retObj.EntrustingDate = DateTime.Parse(temObj.EntrustingDate.ToString());
  2228. }
  2229. if (temObj.InternalDate != null)
  2230. {
  2231. if (!string.IsNullOrEmpty(temObj.InternalDate.ToString()))
  2232. retObj.InternalDate = DateTime.Parse(temObj.InternalDate.ToString());
  2233. }
  2234. if (temObj.CustomerLimitDate != null)
  2235. {
  2236. if (!string.IsNullOrEmpty(temObj.InternalDate.ToString()))
  2237. retObj.CustomerLimitDate = DateTime.Parse(temObj.InternalDate.ToString());
  2238. }
  2239. if (temObj.ReturnDate != null)
  2240. {
  2241. if (!string.IsNullOrEmpty(temObj.ReturnDate.ToString()))
  2242. retObj.ReturnDate = DateTime.Parse(temObj.ReturnDate.ToString());
  2243. }
  2244. if (temObj.FinalizationDate != null)
  2245. {
  2246. if (!string.IsNullOrEmpty(temObj.FinalizationDate.ToString()))
  2247. retObj.FinalizationDate = DateTime.Parse(temObj.FinalizationDate.ToString());
  2248. }
  2249. if (temObj.FinishedDate != null)
  2250. {
  2251. if (!string.IsNullOrEmpty(temObj.FinishedDate.ToString()))
  2252. retObj.FinishedDate = DateTime.Parse(temObj.FinishedDate.ToString());
  2253. }
  2254. }
  2255. catch { }
  2256. int temWordCount;
  2257. if (temObj.WordCount != null)
  2258. {
  2259. if (int.TryParse(temObj.WordCount, out temWordCount))
  2260. {
  2261. retObj.WordCount = temWordCount;
  2262. }
  2263. }
  2264. try
  2265. {
  2266. if (temObj.CustomerName != null)
  2267. {
  2268. string strCustomer = temObj.CustomerName.ToString();
  2269. retObj.Customer = new Customer() { Name = strCustomer };
  2270. var temCustomer = Context.Customers.Where(c => c.Name == strCustomer.Trim()).FirstOrDefault();
  2271. if (temCustomer != null)
  2272. {
  2273. retObj.CustomerId = temCustomer.Id;
  2274. }
  2275. }
  2276. }
  2277. catch { }
  2278. try
  2279. {
  2280. if (temObj.Reviewer != null)
  2281. {
  2282. string strReViewer = temObj.Reviewer.ToString();
  2283. var temReviewer = Context.Staffs.Where(s => s.Name == strReViewer.Trim()).FirstOrDefault();
  2284. if (temReviewer != null)
  2285. {
  2286. retObj.ReviewerId = temReviewer.Id;
  2287. }
  2288. }
  2289. }
  2290. catch { }
  2291. if (temObj.DoPersons != null)
  2292. {
  2293. string DoPersons = temObj.DoPersons.ToString();
  2294. string[] Persons = DoPersons.Split(new char[] { ',' });
  2295. List<ItemStaff> itemStaffs = new List<ItemStaff>();
  2296. foreach (var doPerson in Persons)
  2297. {
  2298. itemStaffs.Add(new ItemStaff() { DoPerson = new Staff() { Name = doPerson } });
  2299. }
  2300. retObj.ItemStaffs = itemStaffs;
  2301. }
  2302. }
  2303. return retObj;
  2304. }
  2305. public PerformanceItem GetItemInfoByMonthId(string CaseNo, string DoItem, string caseStage,int calMonthId)
  2306. {
  2307. var retObj = Context.PerformanceItems.Include(p => p.Customer).FirstOrDefault<PerformanceItem>(p => p.CaseNo == CaseNo.Trim()
  2308. && p.DoItem == DoItem.Trim() && p.CalMonthId == calMonthId);
  2309. if(retObj != null)
  2310. {
  2311. if(string.IsNullOrEmpty (retObj.CaseStage) && string.IsNullOrEmpty(caseStage))
  2312. {
  2313. return retObj;
  2314. }
  2315. else
  2316. {
  2317. if(retObj.CaseStage == caseStage)
  2318. {
  2319. return retObj;
  2320. }
  2321. else
  2322. {
  2323. return null;
  2324. }
  2325. }
  2326. }
  2327. else
  2328. {
  2329. return null;
  2330. }
  2331. }
  2332. public bool MovePerformance2ProjectInfo()
  2333. {
  2334. var response = Context.PerformanceItems.Include(p=>p.ItemStaffs)
  2335. .Where<PerformanceItem>(p => p.CaseNo.StartsWith("S") && p.CalMonth.Status == 0);
  2336. var pList = response.ToList<PerformanceItem>();
  2337. foreach(var p in pList)
  2338. {
  2339. ProjectInfo project = new ProjectInfo();
  2340. project.CaseNo = p.CaseNo;
  2341. project.CaseName = p.CaseName;
  2342. project.CaseState = 0;
  2343. project.CaseType = p.CaseType;
  2344. project.CustomerId = p.CustomerId;
  2345. project.ReviewerId = p.ReviewerId;
  2346. Context.ProjectInfos.Add(project);
  2347. foreach(ItemStaff iStaff in p.ItemStaffs)
  2348. {
  2349. Context.ItemStaffs.Remove(iStaff);
  2350. }
  2351. Context.PerformanceItems.Remove(p);
  2352. Context.SaveChanges();
  2353. }
  2354. return true;
  2355. }
  2356. }
  2357. }