人民医院API

FaultRepairController.cs 119KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765
  1. using RMYY_CallCenter_Api.DB;
  2. using RMYY_CallCenter_Api.Model;
  3. using RMYY_CallCenter_Api.Models;
  4. using RMYY_CallCenter_Api.Models.Enum;
  5. using RMYY_CallCenter_Api.Models.Input;
  6. using RMYY_CallCenter_Api.Utility;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.ComponentModel;
  10. using System.Data;
  11. using System.IO;
  12. using System.Linq;
  13. using System.Reflection;
  14. using System.Text;
  15. using System.Web;
  16. using System.Web.Mvc;
  17. namespace RMYY_CallCenter_Api.Controllers
  18. {
  19. public class FaultRepairController : BaseController
  20. {
  21. private Bll.T_Sys_GroupClass gcBll = new Bll.T_Sys_GroupClass();
  22. private BLL.T_IntegratedScheduling_Base basescheBll = new BLL.T_IntegratedScheduling_Base();
  23. private BLL.T_FaultRepair_Base baseBll = new BLL.T_FaultRepair_Base();
  24. private BLL.T_FaultRepair_Evaluate evaBll = new BLL.T_FaultRepair_Evaluate();
  25. private BLL.T_FaultRepair_OperationLog logBll = new BLL.T_FaultRepair_OperationLog();
  26. private BLL.T_FaultRepair_Process dealBll = new BLL.T_FaultRepair_Process();
  27. Bll.T_Sys_GongDan gdbll = new Bll.T_Sys_GongDan();
  28. private Bll.T_Sys_SystemConfig configBll = new Bll.T_Sys_SystemConfig();
  29. private Bll.T_Sys_DictionaryValue dictionaryValueBLL = new Bll.T_Sys_DictionaryValue();
  30. private Bll.T_Sys_Department departmentBLL = new Bll.T_Sys_Department();
  31. private Bll.T_InvolvedEquip_RepairProcess equipbll = new Bll.T_InvolvedEquip_RepairProcess();
  32. private BLL.T_Wo_CommonBase cbbll = new BLL.T_Wo_CommonBase();
  33. private Bll.T_Con_WorkOrder cwbll = new Bll.T_Con_WorkOrder();
  34. private Bll.AddLogBll Addlogbll = new Bll.AddLogBll();
  35. private static InternalMessagesController msg = new InternalMessagesController();
  36. public DataTable GetFileData(string ids, string prefix)
  37. {
  38. DataTable dt = DbHelperSQL.Query("select * from T_Sys_Accessories WITH(NOLOCK) where F_FileId in (" + ids + ")").Tables[0];
  39. foreach (DataRow dr in dt.Rows)
  40. {
  41. dr["F_FileUrl"] = prefix + dr["F_FileUrl"].ToString();
  42. }
  43. return dt;
  44. }
  45. /// <summary>
  46. /// 工单详情获取设备信息
  47. /// </summary>
  48. /// <param name="ids"></param>
  49. /// <returns></returns>
  50. public DataTable GetEquipsData(string ids)
  51. {
  52. DataTable dt = DbHelperSQL.Query("select * from T_InvolvedEquip_RepairProcess WITH(NOLOCK) where F_ID in (SELECT COL FROM DBO.SplitToNvarchar('" + ids + "',','))").Tables[0];
  53. return dt;
  54. }
  55. /// <summary>
  56. /// 上传附件
  57. /// </summary>
  58. /// <returns></returns>
  59. //[Authority]
  60. public ActionResult UploadFile()
  61. {
  62. #region 多个上传
  63. HttpFileCollectionBase files = Request.Files;
  64. if (files.Count > 0)
  65. {
  66. List<Model.T_Sys_Accessories> acs = new List<Model.T_Sys_Accessories>();
  67. string path = "/Upload/Files/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/";
  68. for (int i = 0; i < files.Count; i++)
  69. {
  70. HttpPostedFileBase file = files[i];
  71. string name = FileHelper.Upload(file, path);
  72. Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
  73. model_T_Sys_Accessories.F_AddTime = DateTime.Now;//上传时间
  74. model_T_Sys_Accessories.F_FileName = name;//附件名称
  75. model_T_Sys_Accessories.F_FileType = Path.GetExtension(file.FileName);//附件类型
  76. model_T_Sys_Accessories.F_FileUrl = path + name;//附件地址
  77. model_T_Sys_Accessories.F_Size = file.ContentLength;
  78. model_T_Sys_Accessories.F_UserCode = User.F_UserCode;//上传人
  79. int id = new Bll.T_Sys_Accessories().Add(model_T_Sys_Accessories);
  80. model_T_Sys_Accessories.F_FileId = id;
  81. acs.Add(model_T_Sys_Accessories);
  82. }
  83. return Success("成功", acs);
  84. }
  85. else
  86. {
  87. return Error("请选择要上传的文件");
  88. }
  89. #endregion
  90. }
  91. //添加工单
  92. /// <summary>
  93. ///添加
  94. /// </summary>
  95. /// <param name="input"></param>
  96. /// <returns></returns>
  97. public ActionResult AddFaultRepairWorkOrder(T_FaultRepairBaseinput input)
  98. {
  99. Model.T_FaultRepair_Base model = new Model.T_FaultRepair_Base();
  100. model.F_Applicant = input.Applicant;
  101. if (string.IsNullOrEmpty(input.ApplicationDept))
  102. {
  103. return Error("申请部门是必填");
  104. }
  105. model.F_ApplicationDept = input.ApplicationDept.Trim();
  106. model.F_Phone = input.Phone;
  107. model.F_Applicantsphone = input.Applicantsphone;
  108. if (string.IsNullOrEmpty(input.WorkOrderCategory))
  109. {
  110. return Error("工单类别是必填");
  111. }
  112. model.F_WorkOrderCategory = input.WorkOrderCategory.Trim();
  113. model.F_Content = input.Content;
  114. model.F_PlaceOfRepair = input.PlaceOfRepair;
  115. model.F_File = input.File;
  116. model.F_WorkOrderCode = DateTime.Now.ToString("yyyyMMddHHmmssfff");//工单编号
  117. model.F_EmergencyTypes = input.EmergencyTypes;
  118. string message = "";
  119. var dicvalue = new Model.T_Sys_GongDan();
  120. dicvalue = new Bll.T_Sys_GongDan().GetModel(Convert.ToInt32(model.F_WorkOrderCategory));
  121. if (dicvalue != null)
  122. {
  123. message = ",工单类型:故障报修/" + dicvalue.F_Name;
  124. }
  125. if (input.IsEnd == 1)
  126. {
  127. model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.finish;
  128. model.F_MaintenanceDept = User.F_DeptId.ToString();
  129. model.F_Maintenancer = User.F_UserCode;
  130. model.F_Endtime = DateTime.Now;
  131. model.F_Deadline = DateTime.Now;
  132. }
  133. else if (!string.IsNullOrEmpty(input.MaintenanceDept))
  134. {
  135. model.F_MaintenanceDept = input.MaintenanceDept;
  136. if (!string.IsNullOrEmpty(input.Maintenancer))
  137. {
  138. model.F_Maintenancer = input.Maintenancer;
  139. model.F_AssignTime = DateTime.Now;
  140. model.F_AssignUser = User.F_UserCode;
  141. List<Model.T_Sys_GongDan> listgd = gdbll.GetModelList(" F_GDId='" + model.F_WorkOrderCategory + "'");
  142. int timeout = listgd.First().F_TimeOut;
  143. model.F_Deadline = DateTime.Now.AddHours(timeout);
  144. msg.AddInternalMessagesInfo("您有新的工单请及时查收", "您有新的工单请及时查收" + "工单编号:" + model.F_WorkOrderCode + message, model.F_Maintenancer, User.F_UserCode, EnumSmsType.repair
  145. , 0, model.F_WorkOrderCode);
  146. }
  147. else
  148. {
  149. var user = GetBeOnDuty(input.MaintenanceDept);
  150. if (user != null && user.Count > 1)
  151. {
  152. model.F_Maintenancer = user[0];
  153. input.Maintenancer = user[0];
  154. model.F_AssignTime = DateTime.Now;
  155. model.F_AssignUser = User.F_UserCode;
  156. List<Model.T_Sys_GongDan> listgd = gdbll.GetModelList(" F_GDId='" + model.F_WorkOrderCategory + "'");
  157. int timeout = listgd.First().F_TimeOut;
  158. model.F_Deadline = DateTime.Now.AddHours(timeout);
  159. msg.AddInternalMessagesInfo("您有新的工单请及时查收", "您有新的工单请及时查收" + "工单编号:" + model.F_WorkOrderCode + message, model.F_Maintenancer, User.F_UserCode, EnumSmsType.repair
  160. , 0, model.F_WorkOrderCode);
  161. }
  162. else
  163. {
  164. return Error("请选择指派人员");
  165. }
  166. }
  167. model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.receive;
  168. }
  169. else
  170. {
  171. model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.neworder;
  172. }
  173. model.F_CreateTime = DateTime.Now;
  174. model.F_CreateUser = User.F_UserCode;
  175. model.F_CreateUserDept = User.F_DeptId.ToString();
  176. if (input.LeaveRecordId != null && input.LeaveRecordId > 0)
  177. {
  178. var ld = new Bll.T_Call_LeaveRecord().GetModel(input.LeaveRecordId.Value);
  179. if (ld != null)
  180. {
  181. ld.F_Status = 1;
  182. ld.F_DealTime = DateTime.Now;
  183. ld.F_UserId = User.F_UserId;
  184. ld.F_UserCode = User.F_UserCode;
  185. ld.F_UserName = User.F_UserName;
  186. ld.F_WorkOrderId = model.F_WorkOrderCode;
  187. ld.F_Type = 3000;
  188. new Bll.T_Call_LeaveRecord().Update(ld);
  189. model.F_LeaveRecordId = input.LeaveRecordId;
  190. }
  191. }
  192. //if (input.CallRecordsId!=null && input.CallRecordsId>0)
  193. //{
  194. // var rd = new Bll.T_Call_CallRecords().GetModelByRecordId(input.CallRecordsId.ToString());
  195. // if (rd != null)
  196. // {
  197. // model.F_CallId = rd.CallId;
  198. // rd.WorkOrderId = model.F_WorkOrderCode;//.F_WorkOrderId;
  199. // rd.IsExitWorkOrder = true;
  200. // new Bll.T_Call_CallRecords().Update(rd);
  201. // model.F_CallRecordId = rd.CallRecordsId;
  202. // }
  203. //}
  204. //else
  205. if (!string.IsNullOrEmpty(input.CallId))
  206. {
  207. model.F_CallId = input.CallId;
  208. var rd = new Bll.T_Call_CallRecords().GetModelByCallId(input.CallId);
  209. if (rd != null)
  210. {
  211. rd.WorkOrderId = model.F_WorkOrderCode;//.F_WorkOrderId;
  212. rd.IsExitWorkOrder = true;
  213. new Bll.T_Call_CallRecords().Update(rd);
  214. model.F_CallRecordId = rd.CallRecordsId;
  215. }
  216. }
  217. model.F_ReplayCount = 0;
  218. int returnid = baseBll.Add(model);
  219. if (User.F_RoleCode != "DDZX" && model.F_WorkOrderState == 0)
  220. {
  221. //新工单提醒发给调度中心值班的人
  222. // 根据排班信息 获取当前调度中心值班的人
  223. List<string> touserlist= GetDDZXBeOnDuty();
  224. if(touserlist!=null && touserlist.Count>0)
  225. foreach (var item in touserlist)
  226. {
  227. msg.AddInternalMessagesInfo("您有新的工单请及时查收", "您有新的工单请及时查收" + "工单编号:" + model.F_WorkOrderCode + message, item, User.F_UserCode, EnumSmsType.repair
  228. , 0, model.F_WorkOrderCode);
  229. }
  230. }
  231. if (returnid > 0)
  232. {
  233. AddAddlog(model.F_WorkOrderCode);
  234. if (!string.IsNullOrEmpty(input.MaintenanceDept))
  235. {
  236. AddAssignlog(model.F_WorkOrderCode, input.MaintenanceDept, input.Maintenancer);
  237. }
  238. if (input.IsEnd == 1)
  239. {
  240. AddOperatorLog("完结了工单", (int)EnumOperatorType.dealed, model.F_WorkOrderCode);
  241. }
  242. return Success("添加成功!", returnid);
  243. }
  244. else return Error("添加失败!");
  245. }
  246. private List<string> GetDDZXBeOnDuty()
  247. {
  248. List<string> userlist = new List<string>();
  249. var GroupClass = new Bll.T_Sys_GroupClass().GetModelList("F_IsDelete=0 and datediff(day , F_Date , getdate())= 0 " +
  250. "and F_DeptId= ( select F_DeptId from T_Sys_Department where F_deptcode='ZHDDZX') order by F_Id asc");
  251. if (GroupClass != null && GroupClass.Count > 0)
  252. {
  253. userlist = GroupClass.Select(x => x.F_UserCode).ToList();
  254. }
  255. return userlist;
  256. }
  257. //综合保障中心编辑工单
  258. /// <summary>
  259. ///编辑
  260. /// </summary>
  261. /// <param name="input"></param>
  262. /// <returns></returns>
  263. public ActionResult UpdateFaultRepairWorkOrder(T_FaultRepairBaseinput input)
  264. {
  265. Model.T_FaultRepair_Base model = baseBll.GetModel(input.WorkOrderCode);
  266. model.F_Applicant = input.Applicant;
  267. model.F_ApplicationDept = input.ApplicationDept;
  268. model.F_Phone = input.Phone;
  269. model.F_Applicantsphone = input.Applicantsphone;
  270. model.F_WorkOrderCategory = input.WorkOrderCategory;
  271. model.F_Content = input.Content;
  272. model.F_PlaceOfRepair = input.PlaceOfRepair;
  273. model.F_File = input.File;
  274. model.F_EmergencyTypes = input.EmergencyTypes;
  275. // bool addassignlog = false;
  276. //综合保障中心没有直接结束的按钮
  277. #region 综合保障中心 编辑时 没有转派的操作,只修改基础的信息
  278. //if (input.IsEnd == 1)
  279. //{
  280. // model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.finish;
  281. // model.F_MaintenanceDept = User.F_DeptId.ToString();
  282. // model.F_Endtime = DateTime.Now;
  283. // model.F_Maintenancer = User.F_UserCode;
  284. //}
  285. //else if (!string.IsNullOrEmpty(input.MaintenanceDept))
  286. //{
  287. // if ( string.IsNullOrEmpty(model.F_MaintenanceDept))
  288. // {
  289. // model.F_AssignTime = DateTime.Now;
  290. // model.F_AssignUser = User.F_UserCode;
  291. // List<Model.T_Sys_GongDan> listgd = gdbll.GetModelList(" F_GDId='" + model.F_WorkOrderCategory + "'");
  292. // int timeout = listgd.First().F_TimeOut;
  293. // model.F_Deadline = DateTime.Now.AddHours(timeout);
  294. // model.F_MaintenanceDept = input.MaintenanceDept;
  295. // if (!string .IsNullOrEmpty(input.Maintenancer))
  296. // model.F_Maintenancer = input.Maintenancer;
  297. // else
  298. // {
  299. // var user = GetBeOnDuty(input.MaintenanceDept);
  300. // if (user != null && user.Count > 1)
  301. // {
  302. // model.F_Maintenancer = user[0];
  303. // }
  304. // else
  305. // {
  306. // return Error("请选择指派人员");
  307. // }
  308. // }
  309. // model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.receive;
  310. // addassignlog = true;
  311. // }
  312. //}
  313. //else
  314. //{
  315. // model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.neworder;
  316. //}
  317. #endregion
  318. model.F_UpdateTime = DateTime.Now;
  319. if (baseBll.Update(model))
  320. {
  321. //if (addassignlog)
  322. //{
  323. // AddAssignlog(model.F_WorkOrderCode, input.MaintenanceDept, input.Maintenancer);
  324. //}
  325. //if (input.IsEnd == 1)
  326. //{
  327. // AddOperatorLog("完结了工单", (int)EnumOperatorType.dealed, model.F_WorkOrderCode);
  328. //}
  329. AddOperatorLog(User.F_UserName + "编辑了工单", (int)EnumOperatorType.update, model.F_WorkOrderCode);
  330. return Success("编辑成功!");
  331. }
  332. else return Error("编辑失败!");
  333. }
  334. //处理人查收
  335. public ActionResult CheckWorkOrder(string WorkOrderCode)
  336. {
  337. Model.T_FaultRepair_Base model = baseBll.GetModel(WorkOrderCode);
  338. if (model != null)
  339. {
  340. if (model.F_MaintenanceDept == User.F_DeptId.ToString())
  341. {
  342. //同一部门的人都可以接单
  343. //if (!string.IsNullOrEmpty(model.F_Maintenancer) && User.F_UserCode!=model.F_Maintenancer)
  344. //{
  345. // return Error("你没有权限查收!");
  346. //}
  347. model.F_UpdateTime = DateTime.Now;
  348. if (string.IsNullOrEmpty(model.F_Maintenancer))
  349. {
  350. model.F_Maintenancer = User.F_UserCode;
  351. }
  352. model.F_AcceptTime = DateTime.Now;
  353. model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.dealing;
  354. baseBll.Update(model);
  355. AddOperatorLog("查收了工单", (int)EnumOperatorType.check, model.F_WorkOrderCode);
  356. return Success(" 查收成功!");
  357. }
  358. else
  359. {
  360. return Error("你没有权限查收!");
  361. }
  362. }
  363. return Error("工单不存在!");
  364. }
  365. //处理人退单
  366. public ActionResult BackWorkOrder(string WorkOrderCode, string BackReason ,int key, string value)
  367. {
  368. Model.T_FaultRepair_Base model = baseBll.GetModel(WorkOrderCode);
  369. string s = ",退回原因:" + value ;
  370. if (!string.IsNullOrEmpty(BackReason))
  371. {
  372. s =s+ "," + BackReason;
  373. }
  374. if (model != null)
  375. {
  376. if (model.F_MaintenanceDept == User.F_DeptId.ToString())
  377. {
  378. string assignuser = model.F_AssignUser;
  379. model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.neworder;
  380. model.F_Maintenancer = "";
  381. model.F_MaintenanceDept = "";
  382. model.F_AssignTime = null;
  383. model.F_AssignUser = "";
  384. model.F_UpdateTime = DateTime.Now;
  385. model.F_Deadline = null;
  386. model.F_AcceptTime = null;
  387. baseBll.Update(model);
  388. AddOperatorLogAboutKey("退回了工单" + s, (int)EnumOperatorType.back, model.F_WorkOrderCode,value,key,BackReason);
  389. msg.AddInternalMessagesInfo("您有工单被退回", "您有工单被退回" + "工单编号:" + model.F_WorkOrderCode+s, assignuser
  390. , User.F_UserCode, EnumSmsType.repair
  391. , 0, model.F_WorkOrderCode);
  392. return Success(" 退回成功!");
  393. }
  394. else
  395. {
  396. return Error("你没有权限退回!");
  397. }
  398. }
  399. return Error("工单不存在!");
  400. }
  401. //维修员能看见当前部门的所有的工单 ,对于所有的工单都能去处理
  402. //处理完成 、异常完结 Type=0 正常完成 Type=1异常完结 判断是不是返修的工单
  403. //点击正常完成的时候添加“是否涉及设备,是否涉及设备点击是,出现下拉框可多选设备,选择之后可输入对应的数量和价格
  404. public ActionResult DealWorkOrder(string WorkOrderCode, int Type, string Result, string File, string finishtype,List<Model.T_InvolvedEquip_RepairProcess> equipmodellist, int ExceptionType = 0, int IsInvolvedEquip = 0)
  405. {
  406. Model.T_FaultRepair_Base model = baseBll.GetModel(WorkOrderCode);
  407. if (Type == 0 && model.F_WorkOrderState != 6)
  408. {
  409. return Error("没有到达之前不能处理工单");
  410. }
  411. //判断是不是返修的,
  412. string sql = "select * from T_FaultRepair_Process where F_WorkOrderCode='" + WorkOrderCode + "' and F_ReturnReason is not null and F_Maintenancer='" + User.F_UserCode + "'";
  413. DataTable dt = DbHelperSQL.Query(sql).Tables[0];
  414. if (model != null)
  415. {
  416. //正常完成
  417. if (Type == 0)
  418. {
  419. model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.dealed;
  420. //是返修的工单
  421. if (dt != null && dt.Rows.Count > 0)
  422. {
  423. int procid = Convert.ToInt32(dt.Rows[0]["F_ProcessId"].ToString());
  424. string updatesql = "UPDATE T_FaultRepair_Process set F_ProcessingTime=GETDATE() , F_FinishType='"+finishtype+"',F_Result='" + Result + "' ,F_File='" + File + "',F_Maintenancer='" + User.F_UserCode + "',F_MaintenanceDept='" + User.F_DeptId + "',F_DealType='" + (int)EnumFaultRepairDealType.normal + "', F_IsInvolvedEquip='" + IsInvolvedEquip + "' where F_ProcessId='" + procid + "'";
  425. int updateid = DbHelperSQL.ExecuteSql(updatesql);
  426. if (IsInvolvedEquip == 1)
  427. {
  428. string ids = "";
  429. foreach (Model.T_InvolvedEquip_RepairProcess item in equipmodellist)
  430. {
  431. item.F_CreateTime = DateTime.Now;
  432. item.F_IsDelete = 0;
  433. item.F_RepairProcessId = procid;
  434. item.F_WorkOrderCode = WorkOrderCode;
  435. int equipid = equipbll.Add(item);
  436. ids += equipid + ",";
  437. }
  438. Model.T_FaultRepair_Process promodelnew = dealBll.GetModel(procid);
  439. model.F_ConfirmEquip = 1;
  440. promodelnew.F_EquipDetail = ids.Substring(0, ids.LastIndexOf(','));
  441. dealBll.Update(promodelnew);
  442. }
  443. if (updateid > 0)
  444. {
  445. if (model.F_IsStop != 1)
  446. { model.F_Endtime = DateTime.Now; }
  447. baseBll.Update(model);
  448. msg.AddInternalMessagesInfo("您提交的工单已处理完毕,请及时进行评价", "您提交的工单已处理完毕,请及时进行评价" + "工单编号:" + model.F_WorkOrderCode, model.F_Applicant, User.F_UserCode, EnumSmsType.repair
  449. , 0, model.F_WorkOrderCode);
  450. AddOperatorLog("完结了工单", (int)EnumOperatorType.dealed, WorkOrderCode);
  451. return Success("处理完成");
  452. }
  453. else
  454. return Error("处理失败");
  455. }
  456. Model.T_FaultRepair_Process promodel = new Model.T_FaultRepair_Process();
  457. promodel.F_Isdelete = 0;
  458. promodel.F_MaintenanceDept = User.F_DeptId.ToString();// model.F_MaintenanceDept;
  459. promodel.F_Maintenancer = User.F_UserCode;// model.F_Maintenancer;
  460. promodel.F_ProcessingTime = DateTime.Now;
  461. promodel.F_Result = Result;
  462. promodel.F_File = File;
  463. promodel.F_WorkOrderCode = WorkOrderCode;
  464. promodel.F_IsInvolvedEquip = IsInvolvedEquip;//0 是否 1 是 是
  465. promodel.F_FinishType = finishtype; //报修工单完工时增加处理方式:“远程”、“现场”,默认现场,另外工单详情中需要显示该字段信息
  466. promodel.F_DealType = (int)EnumFaultRepairDealType.normal;
  467. int id = dealBll.Add(promodel);
  468. //是否涉及设备点击是,出现下拉框可多选设备,选择之后可输入对应的数量和价格
  469. if (id > 0 && IsInvolvedEquip == 1)
  470. {
  471. string ids = "";
  472. foreach (Model.T_InvolvedEquip_RepairProcess item in equipmodellist)
  473. {
  474. item.F_CreateTime = DateTime.Now;
  475. item.F_IsDelete = 0;
  476. item.F_RepairProcessId = id;
  477. item.F_WorkOrderCode = WorkOrderCode;
  478. int equipid = equipbll.Add(item);
  479. ids += equipid + ",";
  480. }
  481. model.F_ConfirmEquip = 1;
  482. Model.T_FaultRepair_Process promodelnew = dealBll.GetModel(id);
  483. promodelnew.F_EquipDetail = ids.Substring(0, ids.LastIndexOf(','));
  484. dealBll.Update(promodelnew);
  485. }
  486. if (id > 0)
  487. {
  488. if (model.F_IsStop != 1)
  489. { model.F_Endtime = DateTime.Now; }
  490. baseBll.Update(model);
  491. msg.AddInternalMessagesInfo("您提交的工单已处理完毕,请及时进行评价", "您提交的工单已处理完毕,请及时进行评价" + "工单编号:" + model.F_WorkOrderCode, model.F_Applicant, User.F_UserCode, EnumSmsType.repair
  492. , 0, model.F_WorkOrderCode);
  493. AddOperatorLog("完结了工单", (int)EnumOperatorType.dealed, WorkOrderCode);
  494. return Success("处理完成");
  495. }
  496. else
  497. return Error("处理失败");
  498. }
  499. else
  500. {
  501. int dealtype = 0;
  502. // "自行解决";
  503. if (User.F_DeptId.ToString() == model.F_ApplicationDept.Trim())//创建工单的人是处理人,存自行解决
  504. {
  505. dealtype = (int)EnumFaultRepairDealType.resolve;// "自行解决";
  506. }
  507. else
  508. {
  509. dealtype = (int)EnumFaultRepairDealType.abnormal;
  510. }
  511. model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.exceptionended;
  512. // model.F_Endtime = DateTime.Now;
  513. //是返修的工单
  514. if (dt != null && dt.Rows.Count > 0)
  515. {
  516. // promodel.F_ExceptionType = ExceptionType;
  517. int procid = Convert.ToInt32(dt.Rows[0]["F_ProcessId"].ToString());
  518. string updatesql = "UPDATE T_FaultRepair_Process set F_ProcessingTime=GETDATE() , F_FinishType='"+finishtype+"',F_Result='" + Result + "' ,F_File='" + File + "',F_UpdateTime= GETDATE(),dealtype='" + dealtype + "' ,F_ExceptionType='" + ExceptionType + "' where F_ProcessId='" + procid + "'";
  519. if (DbHelperSQL.ExecuteSql(updatesql) > 0)
  520. {
  521. if (model.F_IsStop != 1)
  522. { model.F_Endtime = DateTime.Now; }
  523. baseBll.Update(model);
  524. AddOperatorLog("异常完结了工单", (int)EnumOperatorType.exceptionended, WorkOrderCode);
  525. return Success("异常完结");
  526. }
  527. else
  528. return Error("异常完结失败");
  529. }
  530. //异常完结工单
  531. Model.T_FaultRepair_Process promodel = new Model.T_FaultRepair_Process();
  532. promodel.F_Isdelete = 0;
  533. promodel.F_MaintenanceDept = User.F_DeptId.ToString();// model.F_MaintenanceDept;
  534. promodel.F_Maintenancer = User.F_UserCode;// model.F_Maintenancer;
  535. promodel.F_ProcessingTime = DateTime.Now;
  536. promodel.F_Result = Result;
  537. promodel.F_File = File;
  538. promodel.F_WorkOrderCode = WorkOrderCode;
  539. promodel.F_ExceptionType = ExceptionType;
  540. promodel.F_DealType = dealtype;
  541. promodel.F_FinishType = finishtype;
  542. if (dealBll.Add(promodel) > 0)
  543. {
  544. if (model.F_IsStop != 1)
  545. { model.F_Endtime = DateTime.Now; }
  546. baseBll.Update(model);
  547. AddOperatorLog("异常完结了工单", (int)EnumOperatorType.exceptionended, WorkOrderCode);
  548. return Success("异常完结");
  549. }
  550. else
  551. return Error("异常完结失败");
  552. }
  553. }
  554. return Error("工单不存在");
  555. }
  556. //操作:挂起(挂起的工单超时时限不记录到超时时限中,只有处理中未完结的工单可挂起),另外列表显示一列“是否挂起”字段
  557. //协助.内外协助都生成新工单 Type 0是内部协助 1是外部协助
  558. public ActionResult AssistWorkOrder(string WorkOrderCode, string WorkOrderCategory, string Maintenancer, string Content, int Type)
  559. {
  560. Model.T_FaultRepair_Base model = baseBll.GetModel(WorkOrderCode);
  561. Model.T_FaultRepair_Base newmodel = new Model.T_FaultRepair_Base();
  562. if (Type == 0)
  563. {
  564. if (string.IsNullOrEmpty(Maintenancer))
  565. {
  566. return Error("请选择维修人");
  567. }
  568. newmodel.F_Applicant = model.F_Applicant;
  569. newmodel.F_Applicantsphone = model.F_Applicantsphone;
  570. newmodel.F_ApplicationDept = string.IsNullOrEmpty(model.F_ApplicationDept) ? "" : model.F_ApplicationDept.Trim();
  571. newmodel.F_Phone = model.F_Phone;
  572. newmodel.F_WorkOrderCategory = WorkOrderCategory;
  573. newmodel.F_Content = Content;
  574. newmodel.F_PlaceOfRepair = model.F_PlaceOfRepair;
  575. newmodel.F_Maintenancer = Maintenancer;
  576. newmodel.F_MaintenanceDept = model.F_MaintenanceDept;
  577. newmodel.F_AssignTime = DateTime.Now;
  578. newmodel.F_AssignUser = User.F_UserCode;
  579. newmodel.F_File = model.F_File;
  580. List<Model.T_Sys_GongDan> listgd = gdbll.GetModelList(" F_GDId='" + model.F_WorkOrderCategory + "'");
  581. int timeout = listgd.First().F_TimeOut;
  582. newmodel.F_Deadline = DateTime.Now.AddHours(timeout);
  583. newmodel.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.receive;
  584. newmodel.F_WorkOrderCode = DateTime.Now.ToString("yyyyMMddHHmmssfff");//工单编号
  585. newmodel.F_CreateTime = DateTime.Now;
  586. newmodel.F_CreateUser = User.F_UserCode;
  587. newmodel.F_CreateUserDept = User.F_DeptId.ToString();
  588. if (baseBll.Add(newmodel) > 0)
  589. {
  590. AddAddlog(newmodel.F_WorkOrderCode);
  591. if (!string.IsNullOrEmpty(Maintenancer))
  592. {
  593. AddAssignlog(newmodel.F_WorkOrderCode, model.F_MaintenanceDept, Maintenancer);
  594. }
  595. //更新model
  596. if (!string.IsNullOrEmpty(model.F_InternalWorkOrderCode))
  597. {
  598. model.F_InternalWorkOrderCode += "," + newmodel.F_WorkOrderCode;
  599. }
  600. else
  601. {
  602. model.F_InternalWorkOrderCode = newmodel.F_WorkOrderCode;
  603. }
  604. model.F_UpdateTime = DateTime.Now;
  605. if (model.F_IsStop != 1)
  606. { model.F_Endtime = DateTime.Now; }
  607. baseBll.Update(model);
  608. AddInternalasslog(model.F_WorkOrderCode, newmodel.F_WorkOrderCode);
  609. return Success("添加成功!");
  610. }
  611. else return Error("添加失败!");
  612. }
  613. //外协作
  614. else
  615. {
  616. newmodel.F_Applicant = model.F_Applicant;
  617. newmodel.F_Applicantsphone = model.F_Applicantsphone;
  618. newmodel.F_ApplicationDept = string.IsNullOrEmpty(model.F_ApplicationDept) ? "" : model.F_ApplicationDept.Trim();
  619. newmodel.F_Phone = model.F_Phone;
  620. newmodel.F_WorkOrderCategory = WorkOrderCategory;
  621. newmodel.F_Content = Content;
  622. newmodel.F_PlaceOfRepair = model.F_PlaceOfRepair;
  623. //newmodel.F_Maintenancer = Maintenancer;
  624. //newmodel.F_MaintenanceDept = model.F_MaintenanceDept;
  625. newmodel.F_File = model.F_File;
  626. newmodel.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.neworder;
  627. newmodel.F_WorkOrderCode = DateTime.Now.ToString("yyyyMMddHHmmssfff");//工单编号
  628. newmodel.F_CreateTime = DateTime.Now;
  629. newmodel.F_CreateUser = User.F_UserCode;
  630. newmodel.F_CreateUserDept = User.F_DeptId.ToString();
  631. if (baseBll.Add(newmodel) > 0)
  632. {
  633. AddOperatorLog("创建了工单", (int)EnumOperatorType.add, newmodel.F_WorkOrderCode);
  634. //更新原来的工单model
  635. if (!string.IsNullOrEmpty(model.F_ExternalWorkOrderCode))
  636. {
  637. model.F_ExternalWorkOrderCode += "," + newmodel.F_WorkOrderCode;
  638. }
  639. else
  640. {
  641. model.F_ExternalWorkOrderCode = newmodel.F_WorkOrderCode;
  642. }
  643. model.F_UpdateTime = DateTime.Now;
  644. baseBll.Update(model);
  645. AddExternalasslog(model.F_WorkOrderCode, newmodel.F_WorkOrderCode);
  646. return Success("添加成功!");
  647. }
  648. else return Error("添加失败!");
  649. }
  650. }
  651. //维修员的列表 待接单 待完成 已完成
  652. public ActionResult MaintenancerList()
  653. {
  654. string sql = " and F_IsDelete=0 ";
  655. //待接单1 待完成 2 已完成 3
  656. string strpageindex = RequestString.GetQueryString("page");
  657. int pageindex = 1;
  658. string strpagesize = RequestString.GetQueryString("pagesize");
  659. int pagesize = 10;
  660. int strstate = RequestString.GetInt("state", -1);
  661. string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
  662. string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  663. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  664. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  665. string strworkcode = HttpUtility.UrlDecode(RequestString.GetQueryString("workordercode"));
  666. //当前登录人只能看到当前部门的工单。管理员可以查看所有的工单
  667. if (User.F_RoleCode != "GLY")
  668. {
  669. sql += " and F_MaintenanceDept='" + User.F_DeptId + "'";
  670. }
  671. #region 搜索条件
  672. if (strpageindex.Trim() != "")
  673. {
  674. pageindex = Convert.ToInt32(strpageindex);
  675. }
  676. if (strpagesize.Trim() != "")
  677. {
  678. pagesize = Convert.ToInt32(strpagesize);
  679. }
  680. if (strname.Trim() != "" && strname != "undefined")
  681. {
  682. sql += " and F_Applicant = '" + strname + "' ";
  683. }
  684. if (strtel.Trim() != "" && strtel != "undefined")
  685. {
  686. sql += " and (F_Applicantsphone like '%" + strtel + "%' or F_Phone like '%" + strtel + "%') ";
  687. }
  688. if (strworkcode.Trim() != "" && strworkcode != "undefined")
  689. {
  690. sql += " and F_WorkOrderCode like'%" + strworkcode + "%'";
  691. }
  692. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  693. {
  694. if (strendtime.Trim() != "" && strendtime != "undefined")
  695. {
  696. sql += " and F_CreateTime between '" + strstarttime +
  697. "' AND '" + strendtime + "'";
  698. }
  699. else
  700. {
  701. sql += " and F_CreateTime>='" + strstarttime + "' ";
  702. }
  703. }
  704. else
  705. {
  706. if (strendtime.Trim() != "" && strendtime != "undefined")
  707. {
  708. sql += " and F_CreateTime<='" + strendtime + "' ";
  709. }
  710. }
  711. #endregion
  712. switch (strstate)
  713. {
  714. case 1:
  715. sql += " and F_WorkOrderState=1";
  716. break;
  717. case 2:
  718. sql += " and (F_WorkOrderState=2 or F_WorkOrderState=6)";
  719. break;
  720. case 3:
  721. sql += " and (F_WorkOrderState>=3 and F_WorkOrderState!=6 )";
  722. break;
  723. }
  724. int recordCount = 0;
  725. DataTable datatable = Bll.PagerBll.GetListPager
  726. ("T_FaultRepair_Base ",
  727. "F_WorkOrderId",
  728. "*,[dbo].[GetUserName](F_Maintenancer) Maintenancer,[dbo].[GetUserName](F_Applicant) Applicant,[dbo].[GetAssistanceState](F_WorkOrderCode) AssistanceState,(case F_isstop when 1 then '是' when 0 then '否' else '' end ) ishangup",
  729. sql,
  730. "order by F_WorkOrderId desc",
  731. pagesize,
  732. pageindex,
  733. true,
  734. out recordCount
  735. );
  736. datatable = WorkOrderBase.SetOtherField(datatable, MENUENUM.报修列表, User.F_UserCode, User.F_RoleId, 3000);
  737. var obj = new
  738. {
  739. state = "success",
  740. message = "成功",
  741. rows = datatable,
  742. total = recordCount
  743. };
  744. return Content(obj.ToJson());
  745. }
  746. //报修人的列表 已上报 待评价 已完结
  747. //public ActionResult MyCreateList()
  748. //{
  749. // DataTable dt = new DataTable();
  750. // string sql = " and F_IsDelete=0 and F_CreateUser='" + User.F_UserCode + "'";
  751. // string strpageindex = RequestString.GetQueryString("page");
  752. // int pageindex = 1;
  753. // string strpagesize = RequestString.GetQueryString("pagesize");
  754. // int pagesize = 10;
  755. // //待处理传2 已处理传3
  756. // int strstate = RequestString.GetInt("state", -1);
  757. // string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
  758. // string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  759. // string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  760. // string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  761. // string strworkcode = HttpUtility.UrlDecode(RequestString.GetQueryString("workordercode"));
  762. // #region 搜索条件
  763. // if (strpageindex.Trim() != "")
  764. // {
  765. // pageindex = Convert.ToInt32(strpageindex);
  766. // }
  767. // if (strpagesize.Trim() != "")
  768. // {
  769. // pagesize = Convert.ToInt32(strpagesize);
  770. // }
  771. // if (strname.Trim() != "" && strname != "undefined")
  772. // {
  773. // sql += " and F_Applicant = '" + strname + "' ";
  774. // }
  775. // if (strtel.Trim() != "" && strtel != "undefined")
  776. // {
  777. // sql += " and (F_Applicantsphone like '%" + strtel + "%' or F_Phone like '%" + strtel + "%') ";
  778. // }
  779. // if (strworkcode.Trim() != "" && strworkcode != "undefined")
  780. // {
  781. // sql += " and F_WorkOrderCode like'%" + strworkcode + "%'";
  782. // }
  783. // if (strstarttime.Trim() != "" && strstarttime != "undefined")
  784. // {
  785. // if (strendtime.Trim() != "" && strendtime != "undefined")
  786. // {
  787. // sql += " and F_CreateTime between '" + strstarttime +
  788. // "' AND '" + strendtime + "'";
  789. // }
  790. // else
  791. // {
  792. // sql += " and F_CreateTime>='" + strstarttime + "' ";
  793. // }
  794. // }
  795. // else
  796. // {
  797. // if (strendtime.Trim() != "" && strendtime != "undefined")
  798. // {
  799. // sql += " and F_CreateTime<='" + strendtime + "' ";
  800. // }
  801. // }
  802. // #endregion
  803. // //报修人 待处理2 已处理3
  804. // switch (strstate)
  805. // {
  806. // case 2:
  807. // sql += " and F_WorkOrderState<=3";
  808. // break;
  809. // case 3:
  810. // sql += " and F_WorkOrderState>3";
  811. // break;
  812. // }
  813. // int recordCount = 0;
  814. // dt = Bll.PagerBll.GetListPager
  815. // ("T_FaultRepair_Base ",
  816. // "F_WorkOrderId",
  817. // "*,[dbo].[GetUserName](F_Maintenancer) Maintenancer,[dbo].[GetUserName](F_Applicant) Applicant",
  818. // sql,
  819. // "order by F_WorkOrderId desc",
  820. // pagesize,
  821. // pageindex,
  822. // true,
  823. // out recordCount
  824. // );
  825. // dt.Columns.Add("GapTime", typeof(string));//执行时限
  826. // dt.Columns.Add("AssistanceState", typeof(string));//协作工单的状态
  827. // dt.Columns.Add("StateName", typeof(object));//展示的工单状态值
  828. // dt.Columns.Add("Buttons", typeof(object));//操作按钮
  829. // foreach (DataRow dr in dt.Rows)
  830. // {
  831. // #region 执行时限 不是已完成的工单 展示这个字段
  832. // if (Convert.ToInt32(dr["F_WorkOrderState"]) < 3)
  833. // {
  834. // if (!string.IsNullOrEmpty(dr["F_Deadline"].ToString()))
  835. // {
  836. // DateTime deadline = Convert.ToDateTime(dr["F_Deadline"]);
  837. // TimeSpan ts = deadline.Subtract(DateTime.Now);
  838. // double tss = double.Parse(Math.Round(ts.TotalSeconds, 0).ToString());
  839. // if (tss < 0) { tss = -tss; }
  840. // string gshsj = DateTimeConvert.parseTimeSeconds(tss, 1);
  841. // if (deadline > DateTime.Now)
  842. // {
  843. // dr["GapTime"] = "剩余" + gshsj;
  844. // }
  845. // else
  846. // {
  847. // dr["GapTime"] = "超时" + gshsj;
  848. // }
  849. // }
  850. // }
  851. // #endregion
  852. // #region 展示的工单状态
  853. // if (Convert.ToInt32(dr["F_WorkOrderState"]) == (int)EnumFaultRepairWorkOrderState.neworder || Convert.ToInt32(dr["F_WorkOrderState"]) == (int)EnumFaultRepairWorkOrderState.receive)
  854. // {
  855. // dr["StateName"] = "待接单";
  856. // }
  857. // else if (Convert.ToInt32(dr["F_WorkOrderState"]) == (int)EnumFaultRepairWorkOrderState.dealing)
  858. // {
  859. // dr["StateName"] = "已接单";
  860. // }
  861. // else if (Convert.ToInt32(dr["F_WorkOrderState"]) == (int)EnumFaultRepairWorkOrderState.dealed)
  862. // {
  863. // dr["StateName"] = "待评价";
  864. // }
  865. // else {
  866. // dr["StateName"] = "已完成";
  867. // }
  868. // #endregion
  869. // #region 操作按钮
  870. // var btns = new List<FaultButtonGroup.button>();
  871. // //待接单 已接单 -自行解决
  872. // if (Convert.ToInt32(dr["F_WorkOrderState"]) == (int)EnumFaultRepairWorkOrderState.neworder ||
  873. // Convert.ToInt32(dr["F_WorkOrderState"]) == (int)EnumFaultRepairWorkOrderState.receive ||
  874. // Convert.ToInt32(dr["F_WorkOrderState"]) == (int)EnumFaultRepairWorkOrderState.dealing
  875. // )
  876. // {
  877. // btns.Add(FaultButtonGroup.solve());
  878. // }
  879. // //待评价 评价
  880. // else if (Convert.ToInt32(dr["F_WorkOrderState"]) == (int)EnumFaultRepairWorkOrderState.dealed)
  881. // {
  882. // btns.Add(FaultButtonGroup.evaluate());
  883. // }
  884. // else if (Convert.ToInt32(dr["F_WorkOrderState"]) == (int)EnumFaultRepairWorkOrderState.exceptionended ||
  885. // Convert.ToInt32(dr["F_WorkOrderState"]) == (int)EnumFaultRepairWorkOrderState.finish
  886. // )
  887. // {
  888. // btns.Add(FaultButtonGroup.returndeal());
  889. // }
  890. // dr["Buttons"] = btns;
  891. // #endregion
  892. // }
  893. // var obj = new
  894. // {
  895. // state = "success",
  896. // message = "成功",
  897. // rows = dt,
  898. // total = recordCount
  899. // };
  900. // return Content(obj.ToJson());
  901. //}
  902. //工单详情
  903. public ActionResult GetWorkOrder()
  904. {
  905. var configfj = configBll.GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  906. string strworkorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("WorkOrderCode"));
  907. Model.T_FaultRepair_Base model = baseBll.GetModel(strworkorderid);
  908. int type = RequestString.GetInt("type", 0);//0基本信息1处理结果2协作工单3工单流程4维修记录5评价
  909. if (!string.IsNullOrEmpty(strworkorderid))
  910. {
  911. switch (type)
  912. {
  913. case 6:
  914. string sqlfx = " select top 1 F_ReturnReason from T_FaultRepair_Process where F_ReturnReason is not null and F_WorkOrderCode='" + strworkorderid + "' order by F_ProcessingTime desc";
  915. object dtfx = DbHelperSQL.GetSingle(sqlfx);
  916. if (dtfx != null && !string.IsNullOrEmpty(dtfx.ToString()))
  917. {
  918. return Success("是返修", dtfx.ToString());
  919. }
  920. return Success("不是返修");
  921. case 0:
  922. //基本信息
  923. #region
  924. string sql = "select *,[dbo].[GetUserName](F_Applicant) applicantname ,(case when F_Endtime= null then '' else dbo.GetConvertSecond(DATEDIFF(s,F_accepttime,F_endtime)) end) SpendTime,(select F_urgecount from [T_Wo_CommonBase] where F_WoCode='" + strworkorderid + "') F_UrgeCount from T_FaultRepair_Base where F_WorkOrderCode='" + strworkorderid + "'";
  925. DataTable dtbase = DbHelperSQL.Query(sql).Tables[0];
  926. dtbase.Columns.Add("FileUrl", typeof(object));
  927. dtbase.Columns.Add("StateName");
  928. dtbase.Columns.Add("TypeName");
  929. foreach (DataRow dr in dtbase.Rows)
  930. {
  931. dr["TypeName"] = "故障报修";
  932. if (configfj != null && !string.IsNullOrEmpty(dr["F_File"].ToString()))
  933. {
  934. dr["FileUrl"] = GetFileData(dr["F_File"].ToString(), configfj.F_ParamValue);
  935. }
  936. dr["StateName"] = GetWorkOrderStateStr(User.F_RoleCode, Convert.ToInt32(dr["F_WorkOrderState"]));
  937. }
  938. return Success("获取成功", dtbase);
  939. #endregion
  940. case 1://处理结果
  941. #region
  942. string sqlcl = "select top 1 *,[dbo].[GetUserName](F_Maintenancer) username,[dbo].[GetPhoneByUserCode](F_Maintenancer) usertel ,case F_DealType when 0 then '正常完成' when 1 then '异常完成' when 2 then '自行解决' else '' end dealtype from T_FaultRepair_Process where F_WorkOrderCode='" + strworkorderid + "' " + " order by F_ProcessingTime desc";
  943. DataTable dtcl = DbHelperSQL.Query(sqlcl).Tables[0];
  944. dtcl.Columns.Add("FileUrl", typeof(object));
  945. dtcl.Columns.Add("Equips", typeof(object));
  946. foreach (DataRow dr in dtcl.Rows)
  947. {
  948. if (configfj != null && !string.IsNullOrEmpty(dr["F_File"].ToString()))
  949. {
  950. dr["FileUrl"] = GetFileData(dr["F_File"].ToString(), configfj.F_ParamValue);
  951. }
  952. if (!string.IsNullOrEmpty(dr["F_EquipDetail"].ToString()))
  953. {
  954. dr["Equips"] = GetEquipsData(dr["F_EquipDetail"].ToString());
  955. }
  956. }
  957. return Success("获取处理结果成功", dtcl);
  958. #endregion
  959. case 2://协作工单
  960. string internalsql = " select F_WorkOrderCode,F_Content,F_MaintenanceDept,F_CreateTime,F_WorkOrderState from T_FaultRepair_Base where F_WorkOrderCode in " +
  961. "(select col from [dbo].[SplitToNvarchar]('" + model.F_InternalWorkOrderCode + "',',' )) ";
  962. DataTable internaldt = DbHelperSQL.Query(internalsql).Tables[0];
  963. string externalsql = " select F_WorkOrderCode,F_Content,F_MaintenanceDept,F_CreateTime,F_WorkOrderState from T_FaultRepair_Base where F_WorkOrderCode in " +
  964. "(select col from [dbo].[SplitToNvarchar]('" + model.F_ExternalWorkOrderCode + "',',' )) ";
  965. DataTable externaldt = DbHelperSQL.Query(externalsql).Tables[0];
  966. if (internaldt != null && internaldt.Rows.Count > 0)
  967. {
  968. internaldt.Columns.Add("StateName", typeof(String));
  969. internaldt.Columns.Add("Mode", typeof(String));
  970. foreach (DataRow item in internaldt.Rows)
  971. {
  972. if (Convert.ToInt32(item["F_WorkOrderState"]) < 3 || Convert.ToInt32(item["F_WorkOrderState"])==6)
  973. {
  974. item["StateName"] = "未完成";
  975. }
  976. else
  977. {
  978. item["StateName"] = "已完成";
  979. }
  980. item["Mode"] = "内部协作";
  981. }
  982. }
  983. if (externaldt != null && externaldt.Rows.Count > 0 )
  984. {
  985. externaldt.Columns.Add("StateName", typeof(String));
  986. externaldt.Columns.Add("Mode", typeof(String));
  987. foreach (DataRow item in externaldt.Rows)
  988. {
  989. if (Convert.ToInt32(item["F_WorkOrderState"]) < 3 || Convert.ToInt32(item["F_WorkOrderState"]) == 6)
  990. {
  991. item["StateName"] = "未完成";
  992. }
  993. else
  994. {
  995. item["StateName"] = "已完成";
  996. }
  997. item["Mode"] = "外部协作";
  998. }
  999. }
  1000. DataTable dtt = new DataTable();
  1001. dtt.Columns.Add("F_WorkOrderCode", typeof(String));
  1002. dtt.Columns.Add("F_Content", typeof(String));
  1003. dtt.Columns.Add("F_MaintenanceDept", typeof(String));
  1004. dtt.Columns.Add("F_WorkOrderState", typeof(String));
  1005. dtt.Columns.Add("F_CreateTime", typeof(DateTime));
  1006. dtt.Columns.Add("StateName", typeof(String));
  1007. dtt.Columns.Add("Mode", typeof(String));
  1008. if (internaldt != null && internaldt.Rows.Count > 0)
  1009. {
  1010. foreach (DataRow row in internaldt.Rows)
  1011. {
  1012. dtt.ImportRow(row);
  1013. }
  1014. }
  1015. if (externaldt != null && externaldt.Rows.Count > 0)
  1016. {
  1017. foreach (DataRow row in externaldt.Rows)
  1018. {
  1019. dtt.ImportRow(row);
  1020. }
  1021. }
  1022. var obj3 = new
  1023. {
  1024. data = dtt,
  1025. };
  1026. return Success("获取协作工单成功", obj3);
  1027. case 3://工单流程
  1028. var sqllog = "select *,[dbo].[GetUserName](F_Operator) username from T_FaultRepair_OperationLog where F_WorkOrderCode = '" + strworkorderid + "' " + " order by F_OperationId desc";
  1029. DataTable dtlog = DbHelperSQL.Query(sqllog).Tables[0];
  1030. return Success("获取工单流程成功", dtlog);
  1031. case 4://维修记录
  1032. string sqlcl2 = "select *,[dbo].[GetUserName](F_Maintenancer) username,[dbo].[GetPhoneByUserCode](F_Maintenancer) usertel,(case F_DealType when 0 then '正常完成' when 1 then '异常完成' when 2 then '自行解决' else '' end ) dealtype from T_FaultRepair_Process where F_WorkOrderCode='" + strworkorderid + "'";
  1033. DataTable dtcl2 = DbHelperSQL.Query(sqlcl2).Tables[0];
  1034. dtcl2.Columns.Add("Equips", typeof(object));
  1035. dtcl2.Columns.Add("FileUrl", typeof(object));
  1036. foreach (DataRow dr in dtcl2.Rows)
  1037. {
  1038. if (configfj != null && !string.IsNullOrEmpty(dr["F_File"].ToString()))
  1039. {
  1040. dr["FileUrl"] = GetFileData(dr["F_File"].ToString(), configfj.F_ParamValue);
  1041. }
  1042. if (!string.IsNullOrEmpty(dr["F_EquipDetail"].ToString()))
  1043. {
  1044. dr["Equips"] = GetEquipsData(dr["F_EquipDetail"].ToString());
  1045. }
  1046. }
  1047. return Success("获取处理结果成功", dtcl2);
  1048. case 5://评价
  1049. string sqle = "select top 1 * from T_FaultRepair_Evaluate where F_WorkOrderCode='" + strworkorderid + "'" + " order by F_EvaluationTime desc";
  1050. DataTable dte = DbHelperSQL.Query(sqle).Tables[0];
  1051. return Success("获取处理结果成功", dte);
  1052. }
  1053. }
  1054. return Error("没传参数");
  1055. }
  1056. public static string GetWorkOrderStateStr(string userrole, int state)
  1057. {
  1058. List<int> typeIdArray = null;
  1059. typeIdArray = new List<int> { -1, 0, 1, 2, 3, 4, 5, 6 };
  1060. List<string> strArr = null;
  1061. switch (userrole)
  1062. {
  1063. case "DDZX":
  1064. strArr = new List<string> { "-", "待派单", "待查收", "待完成", "已处理", "异常完结", "已完结", "待完成" };
  1065. break;
  1066. case "GLY":
  1067. strArr = new List<string> { "-", "待派单", "待查收", "待完成", "已处理", "异常完结", "已完结", "待完成" };
  1068. break;
  1069. case "WXY":
  1070. strArr = new List<string> { "-", "待接单", "待接单", "待完成", "已完成", "已完成", "已完成", "待完成" };
  1071. break;
  1072. //报修人
  1073. default:
  1074. strArr = new List<string> { "待提交", "待接单", "待接单", "已接单", "待评价", "已完成", "已完成", "已接单" };
  1075. break;
  1076. }
  1077. int index = typeIdArray.IndexOf(state);
  1078. if (index < 0)
  1079. {
  1080. return "";
  1081. }
  1082. return strArr[index];
  1083. }
  1084. //转派 ,派给自己的工单 转给同部门的别的人
  1085. //0 是转同事 1 是转组长
  1086. public ActionResult Transfer(string WorkOrderCode, string ToUserCode, int type = 0)
  1087. {
  1088. Model.T_FaultRepair_Base model = baseBll.GetModel(WorkOrderCode);
  1089. if (model != null && model.F_Maintenancer == User.F_UserCode)
  1090. {
  1091. if (type == 0)
  1092. {
  1093. //转同事
  1094. model.F_Maintenancer = ToUserCode;
  1095. model.F_UpdateTime = DateTime.Now;
  1096. AddOperatorLog("转派工单给" + GetDeptModel(model.F_MaintenanceDept) + "部门" + GetUserModel(ToUserCode), (int)EnumOperatorType.transfer, WorkOrderCode);
  1097. baseBll.Update(model);
  1098. return Success("转派成功");
  1099. }
  1100. else
  1101. {
  1102. //是转组长
  1103. var role = new Bll.T_Sys_Role().GetModelList("F_RoleCode='WXBZZ' and F_State =1");
  1104. var userzz = new Bll.T_Sys_UserAccount().GetModelList("F_DeptId='" + model.F_MaintenanceDept + "' and F_DeleteFlag=0 " +
  1105. "and F_RoleId = '" + role.FirstOrDefault().F_RoleId + "'");
  1106. if (userzz != null && userzz.Count > 0)
  1107. {
  1108. //转同事
  1109. model.F_Maintenancer = userzz.First().F_UserCode;
  1110. model.F_UpdateTime = DateTime.Now;
  1111. AddOperatorLog("转派工单给" + GetDeptModel(model.F_MaintenanceDept) + "部门" + GetUserModel(userzz.First().F_UserCode), (int)EnumOperatorType.transfer, WorkOrderCode);
  1112. baseBll.Update(model);
  1113. return Success("转派成功");
  1114. }
  1115. else
  1116. {
  1117. return Error("没有维修部组长");
  1118. }
  1119. }
  1120. }
  1121. return Error("暂时没有权限操作");
  1122. }
  1123. //调度中心转派
  1124. public ActionResult DDZXTransfer(string WorkOrderCode, string ToUserCode, string ToDept)
  1125. {
  1126. Model.T_FaultRepair_Base model = baseBll.GetModel(WorkOrderCode);
  1127. if (model != null)// && !string.IsNullOrEmpty(ToUserCode) && !string.IsNullOrEmpty(ToDept))
  1128. {
  1129. string mes = "";
  1130. var dicvalue = new Model.T_Sys_GongDan();
  1131. dicvalue = new Bll.T_Sys_GongDan().GetModel(Convert.ToInt32(model.F_WorkOrderCategory));
  1132. if (dicvalue != null)
  1133. {
  1134. mes = ",工单类型:故障报修/" + dicvalue.F_Name;
  1135. }
  1136. model.F_AssignUser = User.F_UserCode;
  1137. model.F_AssignTime = DateTime.Now;
  1138. List<Model.T_Sys_GongDan> listgd = gdbll.GetModelList(" F_GDId='" + model.F_WorkOrderCategory + "'");
  1139. int timeout = listgd.First().F_TimeOut;
  1140. model.F_Deadline = DateTime.Now.AddHours(timeout);
  1141. string message = "";
  1142. //当工单没有选择指派部门的时候,当前工单类型shezhi指派部门,该工单默认到这个指派的部门
  1143. if (string.IsNullOrEmpty(ToDept) || ToDept == "0")
  1144. {
  1145. //根据工单类别判断 是否有指派部门
  1146. List<Model.T_Sys_GongDan> gd = gdbll.GetModelList(" F_GDId='" + model.F_WorkOrderCategory + "'");
  1147. int deptid = listgd.First().F_AutoDept != null ? listgd.First().F_AutoDept.Value : 0;
  1148. if (deptid == 0)
  1149. {
  1150. return Error("当前工单类型没有设置指派部门,请前往设置或者选择指派部门");
  1151. }
  1152. else
  1153. ToDept = deptid.ToString();
  1154. }
  1155. if (!string.IsNullOrEmpty(ToUserCode))
  1156. {
  1157. model.F_Maintenancer = ToUserCode;
  1158. message = "转派工单给" + GetDeptModel(ToDept) + "部门" + GetUserModel(ToUserCode);
  1159. msg.AddInternalMessagesInfo("您有新的工单请及时查收", "您有新的工单请及时查收" + "工单编号:" + model.F_WorkOrderCode + mes, model.F_Maintenancer, User.F_UserCode, EnumSmsType.repair
  1160. , 0, model.F_WorkOrderCode);
  1161. }
  1162. else
  1163. {
  1164. //部门下没有人员不可进行转派
  1165. var usercount = new Bll.T_Sys_UserAccount().GetModelList("F_DeptId='" + ToDept + "' and F_DeleteFlag=0 ");
  1166. if (usercount == null || usercount.Count == 0)
  1167. {
  1168. return Error("当前部门没有人员 ,不可进行转派");
  1169. }
  1170. var user = GetBeOnDuty(ToDept);
  1171. if (user != null && user.Count > 1)
  1172. {
  1173. model.F_Maintenancer = user[0];
  1174. message = "转派工单给" + GetDeptModel(ToDept) + "部门" + GetUserModel(user[0]);
  1175. msg.AddInternalMessagesInfo("您有新的工单请及时查收", "您有新的工单请及时查收" + "工单编号:" + model.F_WorkOrderCode + mes, model.F_Maintenancer, User.F_UserCode, EnumSmsType.repair
  1176. , 0, model.F_WorkOrderCode);
  1177. }
  1178. else
  1179. {
  1180. return Error("请选择指派人员");
  1181. }
  1182. }
  1183. model.F_MaintenanceDept = ToDept;
  1184. model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.receive;
  1185. model.F_UpdateTime = DateTime.Now;
  1186. AddOperatorLog(message, (int)EnumOperatorType.assign, WorkOrderCode);
  1187. baseBll.Update(model);
  1188. return Success("转派成功");
  1189. }
  1190. return Error("暂时没有权限操作");
  1191. }
  1192. /// <summary>
  1193. /// 自动评价
  1194. /// </summary>
  1195. /// <returns></returns>
  1196. [AllowAnonymous]
  1197. public ActionResult Evaluate()
  1198. {
  1199. var dicvalue = new Bll.T_Sys_DictionaryValue().
  1200. GetModelList("F_DictionaryFlag='PJSX' and F_State=1");
  1201. int SX = 2;
  1202. try
  1203. {
  1204. if (dicvalue != null && dicvalue.Count > 0)
  1205. {
  1206. SX = int.Parse(dicvalue.FirstOrDefault().F_Name);
  1207. }
  1208. }
  1209. catch
  1210. {
  1211. SX = 2;
  1212. }
  1213. var IntegratedScheduling_Base = new BLL.T_IntegratedScheduling_Base().GetModelList(" F_WorkOrderState=3 and F_IsDelete=0 " +
  1214. "and datediff(minute , F_Endtime , getdate())>'" + SX * 60 + "'");
  1215. if (IntegratedScheduling_Base != null && IntegratedScheduling_Base.Count > 0)
  1216. {
  1217. foreach (var model in IntegratedScheduling_Base)
  1218. {
  1219. Model.T_IntegratedScheduling_Evaluate evamodel = new Model.T_IntegratedScheduling_Evaluate();
  1220. if (model != null)
  1221. {
  1222. evamodel.F_EvaluateContent = SX + "小时未评价自动评价满意";
  1223. // evamodel.F_Quality = 5;
  1224. evamodel.F_Attitude = 5;
  1225. evamodel.F_Efficiency = 5;
  1226. evamodel.F_Evaluator = "";
  1227. evamodel.F_EvaluationTime = DateTime.Now;
  1228. evamodel.F_Isdelete = 0;
  1229. evamodel.F_WorkOrderCode = model.F_WorkOrderCode;
  1230. BLL.T_IntegratedScheduling_Evaluate evabll = new BLL.T_IntegratedScheduling_Evaluate();
  1231. if (evabll.Add(evamodel) > 0)
  1232. {
  1233. model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.finish;
  1234. model.F_UpdateTime = DateTime.Now;
  1235. model.F_Score = 10;
  1236. model.MYD = 0;
  1237. basescheBll.Update(model);
  1238. var conre = DependencyResolver.Current.GetService<SchedulingController>();
  1239. conre.AddOperatorLog("评价了工单", (int)EnumOperatorType.evaluate, model.F_WorkOrderCode);
  1240. }
  1241. else
  1242. continue;
  1243. }
  1244. }
  1245. }
  1246. var FaultRepair_Base = new BLL.T_FaultRepair_Base().GetModelList(" F_WorkOrderState=3 and F_IsDelete=0 " +
  1247. "and datediff(minute , F_Endtime , getdate())>'" + SX * 60 + "'");
  1248. if (FaultRepair_Base != null && FaultRepair_Base.Count > 0)
  1249. {
  1250. foreach (var model in FaultRepair_Base)
  1251. {
  1252. Model.T_FaultRepair_Evaluate evamodel = new Model.T_FaultRepair_Evaluate();
  1253. if (model != null)
  1254. {
  1255. evamodel.F_EvaluateContent = SX + "小时未评价自动评价满意";
  1256. evamodel.F_Quality = 5;
  1257. evamodel.F_Attitude = 5;
  1258. evamodel.F_Efficiency = 5;
  1259. evamodel.F_Evaluator = "";
  1260. evamodel.F_EvaluationTime = DateTime.Now;
  1261. evamodel.F_Isdelete = 0;
  1262. evamodel.F_WorkOrderCode = model.F_WorkOrderCode;
  1263. BLL.T_FaultRepair_Evaluate evabll = new BLL.T_FaultRepair_Evaluate();
  1264. if (evabll.Add(evamodel) > 0)
  1265. {
  1266. model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.finish;
  1267. model.F_UpdateTime = DateTime.Now;
  1268. model.F_Score = 15;
  1269. model.MYD = 0;
  1270. baseBll.Update(model);
  1271. AddEvaluateOperatorLog("评价了工单", (int)EnumOperatorType.evaluate, model.F_WorkOrderCode);
  1272. #region 评价的时候如果有协作工单,协作工单评价数据和主工单保持一致,同时需要记录操作流程
  1273. if (!string.IsNullOrEmpty(model.F_InternalWorkOrderCode))
  1274. {
  1275. string[] codes = model.F_InternalWorkOrderCode.Split(',');
  1276. foreach (string item in codes)
  1277. {
  1278. Model.T_FaultRepair_Evaluate evamodel1 = new Model.T_FaultRepair_Evaluate();
  1279. evamodel1 = evamodel;
  1280. evamodel.F_WorkOrderCode = item;
  1281. evabll.Add(evamodel1);
  1282. AddEvaluateOperatorLog("评价了工单", (int)EnumOperatorType.evaluate, item);
  1283. var intermodel = baseBll.GetModel(item);
  1284. intermodel.F_Score = 15;
  1285. intermodel.MYD = 0;
  1286. baseBll.Update(intermodel);
  1287. }
  1288. }
  1289. if (!string.IsNullOrEmpty(model.F_ExternalWorkOrderCode))
  1290. {
  1291. string[] codes = model.F_ExternalWorkOrderCode.Split(',');
  1292. foreach (string item in codes)
  1293. {
  1294. Model.T_FaultRepair_Evaluate evamodel1 = new Model.T_FaultRepair_Evaluate();
  1295. evamodel1 = evamodel;
  1296. evamodel.F_WorkOrderCode = item;
  1297. evabll.Add(evamodel1);
  1298. AddEvaluateOperatorLog("评价了工单", (int)EnumOperatorType.evaluate, item);
  1299. var extermodel = baseBll.GetModel(item);
  1300. extermodel.F_Score = 15;
  1301. extermodel.MYD = 0;
  1302. baseBll.Update(extermodel);
  1303. }
  1304. }
  1305. #endregion
  1306. }
  1307. else
  1308. continue;
  1309. }
  1310. }
  1311. }
  1312. return Success("评价完成");
  1313. }
  1314. public bool AddEvaluateOperatorLog(string content, int type, string workordercode)
  1315. {
  1316. Model.T_FaultRepair_OperationLog model = new Model.T_FaultRepair_OperationLog();
  1317. model.F_LogContent = content;
  1318. model.F_OperationTime = DateTime.Now;
  1319. model.F_OperationType = type;
  1320. model.F_Operator = "";
  1321. model.F_WorkOrderCode = workordercode;
  1322. logBll.Add(model);
  1323. return true;
  1324. }
  1325. /// <summary>
  1326. /// 自动流转
  1327. /// </summary>
  1328. /// <returns></returns>
  1329. [AllowAnonymous]
  1330. public ActionResult Automatic()
  1331. {
  1332. var dicvalue = new Bll.T_Sys_DictionaryValue().
  1333. GetModelList("F_DictionaryFlag='JDSX' and F_State=1");
  1334. string SX = "10";
  1335. if (dicvalue != null && dicvalue.Count > 0)
  1336. {
  1337. SX = dicvalue.FirstOrDefault().F_Name;
  1338. }
  1339. var FaultRepair_Base = new BLL.T_FaultRepair_Base().GetModelList(" F_WorkOrderState=1 and F_IsDelete=0 " +
  1340. "and datediff(minute , F_AssignTime , getdate())>'" + SX + "'");
  1341. var class1 = new Bll.T_Sys_Class().GetModelList("F_IsDelete=0 and F_IsAutomatic=1 and F_InTime<= getdate() " +
  1342. "and F_OutTime>=getdate() ");
  1343. if (class1!=null && class1.Count >0)
  1344. {
  1345. var GroupClass1 = new Bll.T_Sys_GroupClass().GetModelList($"F_IsDelete=0 and F_ClassCode in(" +
  1346. $"{string.Join(",", class1.Select(x => x.F_Id))}) and datediff(day , F_Date , getdate())= 0 " +
  1347. " order by F_Id asc");
  1348. if (FaultRepair_Base != null && FaultRepair_Base.Count > 0)
  1349. {
  1350. foreach (var model in FaultRepair_Base)
  1351. {
  1352. model.F_AssignTime = DateTime.Now;
  1353. model.F_AssignUser = "系统流转";
  1354. List<Model.T_Sys_GongDan> listgd = gdbll.GetModelList(" F_GDId='" + model.F_WorkOrderCategory + "'");
  1355. int timeout = listgd.First().F_TimeOut;
  1356. model.F_Deadline = DateTime.Now.AddHours(timeout);
  1357. string user = "";
  1358. var GroupClass = GroupClass1.Where(x => x.F_DeptId.ToString() == model.F_MaintenanceDept)
  1359. .OrderBy(x => x.F_Id);
  1360. if (GroupClass != null && GroupClass.Count() > 1)
  1361. {
  1362. var Class = GroupClass.Where(x => x.F_State == 1);
  1363. if (Class != null && Class.Count() > 0)
  1364. {
  1365. var Class1 = GroupClass.Where(x => x.F_State == 0 && x.F_Id > Class.LastOrDefault().F_Id);
  1366. if (Class1 != null && Class1.Count() > 0)
  1367. {
  1368. user = Class1.FirstOrDefault().F_UserCode;
  1369. Class1.FirstOrDefault().F_State = 1;
  1370. new Bll.T_Sys_GroupClass().Update(GroupClass.FirstOrDefault());
  1371. Class.LastOrDefault().F_State = 0;
  1372. new Bll.T_Sys_GroupClass().Update(Class.LastOrDefault());
  1373. }
  1374. else
  1375. {
  1376. user = GroupClass.FirstOrDefault().F_UserCode;
  1377. GroupClass.FirstOrDefault().F_State = 1;
  1378. new Bll.T_Sys_GroupClass().Update(GroupClass.FirstOrDefault());
  1379. Class.LastOrDefault().F_State = 0;
  1380. new Bll.T_Sys_GroupClass().Update(Class.LastOrDefault());
  1381. }
  1382. }
  1383. else
  1384. {
  1385. user = GroupClass.FirstOrDefault().F_UserCode;
  1386. GroupClass.FirstOrDefault().F_State = 1;
  1387. new Bll.T_Sys_GroupClass().Update(GroupClass.FirstOrDefault());
  1388. }
  1389. }
  1390. else
  1391. {
  1392. continue;
  1393. }
  1394. model.F_Maintenancer = user;
  1395. model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.receive;
  1396. model.F_UpdateTime = DateTime.Now;
  1397. AddOperatorLog("超十分钟未接单,自动流转给" + GetDeptModel(model.F_MaintenanceDept) + "部门" + GetUserModel(user), (int)EnumOperatorType.assign, model.F_WorkOrderCode);
  1398. baseBll.Update(model);
  1399. }
  1400. }
  1401. }
  1402. return Success("");
  1403. }
  1404. /// <summary>
  1405. /// 获取值班人员
  1406. /// </summary>
  1407. /// <param name="ToDept"></param>
  1408. /// <returns></returns>
  1409. private List<string> GetBeOnDuty(string ToDept)
  1410. {
  1411. List<string> user = new List<string>();
  1412. var role = new Bll.T_Sys_Role().GetModelList("F_RoleCode='WXBZZ' and F_State =1");
  1413. var class1 = new Bll.T_Sys_Class().GetModelList("F_IsDelete=0 and F_IsAutomatic=1 and F_InTime<= getdate() " +
  1414. "and F_OutTime>=getdate() ");
  1415. if (class1!=null && class1.Count >0)
  1416. {
  1417. var GroupClass = new Bll.T_Sys_GroupClass().GetModelList($"F_IsDelete=0 and F_ClassCode in(" +
  1418. $"{string.Join(",", class1.Select(x => x.F_Id))}) and datediff(day , F_Date , getdate())= 0 " +
  1419. "and F_DeptId='" + ToDept + "' order by F_Id asc");
  1420. if (GroupClass != null && GroupClass.Count > 0)
  1421. {
  1422. if (GroupClass.Count == 1)
  1423. {
  1424. user.Add(GroupClass[0].F_UserCode);
  1425. user.Add("有值班人员,自动流转给" + GetDeptModel(ToDept) + "部门" + GetUserModel(GroupClass[0].F_UserCode));
  1426. }
  1427. else
  1428. {
  1429. var Class = GroupClass.Where(x => x.F_State == 1);
  1430. if (Class != null && Class.Count() > 0)
  1431. {
  1432. var Class1 = GroupClass.Where(x => x.F_State == 0 && x.F_Id > Class.LastOrDefault().F_Id);
  1433. if (Class1 != null && Class1.Count() > 0)
  1434. {
  1435. user.Add(Class1.FirstOrDefault().F_UserCode);
  1436. user.Add("有值班人员,自动流转给" + GetDeptModel(ToDept) + "部门" + GetUserModel(Class1.FirstOrDefault().F_UserCode));
  1437. Class1.FirstOrDefault().F_State = 1;
  1438. new Bll.T_Sys_GroupClass().Update(GroupClass[0]);
  1439. Class.LastOrDefault().F_State = 0;
  1440. new Bll.T_Sys_GroupClass().Update(Class.LastOrDefault());
  1441. }
  1442. else
  1443. {
  1444. user.Add(GroupClass[0].F_UserCode);
  1445. user.Add("有值班人员,自动流转给" + GetDeptModel(ToDept) + "部门" + GetUserModel(GroupClass[0].F_UserCode));
  1446. GroupClass[0].F_State = 1;
  1447. new Bll.T_Sys_GroupClass().Update(GroupClass[0]);
  1448. Class.LastOrDefault().F_State = 0;
  1449. new Bll.T_Sys_GroupClass().Update(Class.LastOrDefault());
  1450. }
  1451. }
  1452. else
  1453. {
  1454. user.Add(GroupClass[0].F_UserCode);
  1455. user.Add("有值班人员,自动流转给" + GetDeptModel(ToDept) + "部门" + GetUserModel(GroupClass[0].F_UserCode));
  1456. GroupClass[0].F_State = 1;
  1457. new Bll.T_Sys_GroupClass().Update(GroupClass[0]);
  1458. }
  1459. }
  1460. }
  1461. else
  1462. {
  1463. if (role != null && role.Count > 0)
  1464. {
  1465. var userzz = new Bll.T_Sys_UserAccount().GetModelList("F_DeptId='" + ToDept + "' and F_DeleteFlag=0 " +
  1466. "and F_RoleId = '" + role.FirstOrDefault().F_RoleId + "'");
  1467. if (userzz != null && userzz.Count > 0)
  1468. {
  1469. user.Add(userzz.FirstOrDefault().F_UserCode);
  1470. user.Add("无值班人员,派送给" + GetDeptModel(ToDept) + "部门" + userzz.FirstOrDefault().F_UserName);
  1471. }
  1472. else
  1473. {
  1474. //无值班人员无班组长,随机派送
  1475. var userww = new Bll.T_Sys_UserAccount().GetModelList("F_DeptId='" + ToDept + "' and F_DeleteFlag=0 ");
  1476. user.Add(userww.FirstOrDefault().F_UserCode);
  1477. user.Add("无值班人员无班组长,随机派送给" + GetDeptModel(ToDept) + "部门" + userww.FirstOrDefault().F_UserName);
  1478. }
  1479. }
  1480. }
  1481. }
  1482. else
  1483. {
  1484. if (role != null && role.Count > 0)
  1485. {
  1486. var userzz = new Bll.T_Sys_UserAccount().GetModelList("F_DeptId='" + ToDept + "' and F_DeleteFlag=0 " +
  1487. "and F_RoleId = '" + role.FirstOrDefault().F_RoleId + "'");
  1488. if (userzz != null && userzz.Count > 0)
  1489. {
  1490. user.Add(userzz.FirstOrDefault().F_UserCode);
  1491. user.Add("无值班人员,派送给" + GetDeptModel(ToDept) + "部门" + userzz.FirstOrDefault().F_UserName);
  1492. }
  1493. else
  1494. {
  1495. //无值班人员无班组长,随机派送
  1496. var userww = new Bll.T_Sys_UserAccount().GetModelList("F_DeptId='" + ToDept + "' and F_DeleteFlag=0 ");
  1497. user.Add(userww.FirstOrDefault().F_UserCode);
  1498. user.Add("无值班人员无班组长,随机派送给" + GetDeptModel(ToDept) + "部门" + userww.FirstOrDefault().F_UserName);
  1499. }
  1500. }
  1501. }
  1502. return user;
  1503. }
  1504. //删除工单
  1505. public ActionResult DeleteWorkOrder(string WorkOrderCode)
  1506. {
  1507. Model.T_FaultRepair_Base model = baseBll.GetModel(WorkOrderCode);
  1508. model.F_IsDelete = 1;
  1509. if (baseBll.Update(model))
  1510. {
  1511. AddOperatorLog("删除了工单", (int)EnumOperatorType.delete, WorkOrderCode);
  1512. return Success("删除成功");
  1513. }
  1514. else
  1515. return Error("删除失败");
  1516. }
  1517. // 返修 是申请人提交的返修
  1518. //退回至维修部门班组长(角色),如果没有该角色退回到原来的处理人
  1519. public ActionResult ReturnWorkOrder(string WorkOrderCode, string ReturnReason,int key,string value)
  1520. {
  1521. Model.T_FaultRepair_Base model = baseBll.GetModel(WorkOrderCode);
  1522. string str = "";
  1523. if (!string.IsNullOrEmpty(ReturnReason))
  1524. {
  1525. str = "," + ReturnReason;
  1526. }
  1527. if (model != null && model.F_ApplicationDept.Trim() == User.F_DeptId.ToString())
  1528. {
  1529. //判断返工是不是规定的时间内,工单状态是已完结的工单
  1530. List<Model.T_Sys_GongDan> listgd = gdbll.GetModelList(" F_GDId='" + model.F_WorkOrderCategory + "'");
  1531. int limittime = listgd.First().F_RepairTimeLimit;
  1532. if (model.F_Endtime.Value.AddHours(limittime) >= DateTime.Now)
  1533. {
  1534. Model.T_FaultRepair_Process promodel = new Model.T_FaultRepair_Process();
  1535. promodel.F_Isdelete = 0;
  1536. promodel.F_MaintenanceDept = User.F_DeptId.ToString();// model.F_MaintenanceDept;
  1537. promodel.F_Maintenancer = User.F_UserCode;// model.F_Maintenancer;
  1538. promodel.F_ReturnReason =value+ ReturnReason;
  1539. promodel.F_WorkOrderCode = WorkOrderCode;
  1540. if (dealBll.Add(promodel) > 0)
  1541. {
  1542. AddOperatorLogAboutKey("提交了返工,原因:"+value+ str, (int)EnumOperatorType.submitreturn, WorkOrderCode,value,key,ReturnReason);
  1543. string sql = " select top 1 F_UserCode from T_Sys_UserAccount where F_RoleId in (select F_RoleId from T_Sys_Role where F_RoleCode = 'WXBZZ')";
  1544. string usercode = DbHelperSQL.GetSingle(sql).ToString();
  1545. if (!string.IsNullOrEmpty(usercode))
  1546. {
  1547. model.F_Maintenancer = usercode;
  1548. }
  1549. string s = ",返修原因:" +value+ str;
  1550. model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.dealing;
  1551. model.F_ReturnNum += model.F_ReturnNum + 1;
  1552. model.F_UpdateTime = DateTime.Now;
  1553. baseBll.Update(model);
  1554. msg.AddInternalMessagesInfo("您有需要返修的工单,请及时处理", "您有需要返修的工单,请及时处理" + "工单编号:" + model.F_WorkOrderCode+s, model.F_Maintenancer, User.F_UserCode, EnumSmsType.repair
  1555. , 0, model.F_WorkOrderCode);
  1556. return Success("返工成功");
  1557. }
  1558. return Error("返工失败");
  1559. }
  1560. else
  1561. {
  1562. return Error("已超出提交返修期限");
  1563. }
  1564. }
  1565. return Error("暂时没有权限操作");
  1566. }
  1567. //申请人评价
  1568. public ActionResult EvaluateWorkOrder(string WorkOrderCode, string EvaluateContent, int Attitude= 0, int Quality = 0, int Efficiency = 0)
  1569. {
  1570. Model.T_FaultRepair_Base model = baseBll.GetModel(WorkOrderCode);
  1571. Model.T_FaultRepair_Evaluate evamodel = new Model.T_FaultRepair_Evaluate();
  1572. if (model != null)
  1573. {
  1574. if (model.F_ApplicationDept.Trim() == User.F_DeptId.ToString())
  1575. {
  1576. evamodel.F_EvaluateContent = EvaluateContent;
  1577. evamodel.F_Quality = Quality;
  1578. evamodel.F_Attitude = Attitude;
  1579. evamodel.F_Efficiency = Efficiency;
  1580. evamodel.F_Evaluator = User.F_UserCode;
  1581. evamodel.F_EvaluationTime = DateTime.Now;
  1582. evamodel.F_Isdelete = 0;
  1583. evamodel.F_WorkOrderCode = WorkOrderCode;
  1584. BLL.T_FaultRepair_Evaluate evabll = new BLL.T_FaultRepair_Evaluate();
  1585. if (evabll.Add(evamodel) > 0)
  1586. {
  1587. model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.finish;
  1588. model.F_UpdateTime = DateTime.Now;
  1589. //评价=自动确认耗材
  1590. model.F_ConfirmEquip = 2;
  1591. model.F_Score = Attitude + Quality + Efficiency;
  1592. AddOperatorLog("评价了工单", (int)EnumOperatorType.evaluate, model.F_WorkOrderCode);
  1593. if (Attitude < 3 || Quality < 3 || Efficiency < 3)
  1594. {
  1595. model.MYD = 2;
  1596. msg.AddInternalMessagesInfo("您有工单被差评", "您有工单被差评" + "工单编号:" + model.F_WorkOrderCode + "差评原因:" + EvaluateContent, model.F_Maintenancer, User.F_UserCode, EnumSmsType.repair
  1597. , 0, model.F_WorkOrderCode);
  1598. }
  1599. else if (Attitude == 3 || Quality == 3 || Efficiency == 3)
  1600. {
  1601. model.MYD = 1;
  1602. }
  1603. else
  1604. {
  1605. model.MYD = 0;
  1606. }
  1607. baseBll.Update(model);
  1608. #region 评价的时候如果有协作工单,协作工单评价数据和主工单保持一致,同时需要记录操作流程
  1609. if (!string.IsNullOrEmpty(model.F_InternalWorkOrderCode))
  1610. {
  1611. string[] codes = model.F_InternalWorkOrderCode.Split(',');
  1612. foreach (string item in codes)
  1613. {
  1614. var intermodel = baseBll.GetModel(item);
  1615. Model.T_FaultRepair_Evaluate evamodel1 = new Model.T_FaultRepair_Evaluate();
  1616. evamodel1 = evamodel;
  1617. evamodel.F_WorkOrderCode = item;
  1618. evabll.Add(evamodel1);
  1619. if (Attitude < 3 || Quality < 3 || Efficiency < 3)
  1620. {
  1621. intermodel.MYD = 2;
  1622. msg.AddInternalMessagesInfo("您有工单被差评", "您有工单被差评" + "工单编号:" + item + "差评原因:" + EvaluateContent, intermodel.F_Maintenancer, User.F_UserCode, EnumSmsType.repair
  1623. , 0, item);
  1624. }
  1625. else if (Attitude == 3 || Quality == 3 || Efficiency == 3)
  1626. {
  1627. model.MYD = 1;
  1628. }
  1629. else
  1630. {
  1631. model.MYD = 0;
  1632. }
  1633. intermodel.F_Score = Attitude + Quality + Efficiency;
  1634. baseBll.Update(intermodel);
  1635. AddOperatorLog("评价了工单", (int)EnumOperatorType.evaluate, item);
  1636. }
  1637. }
  1638. if (!string.IsNullOrEmpty(model.F_ExternalWorkOrderCode))
  1639. {
  1640. string[] codes = model.F_ExternalWorkOrderCode.Split(',');
  1641. foreach (string item in codes)
  1642. {
  1643. var extmodel = baseBll.GetModel(item);
  1644. Model.T_FaultRepair_Evaluate evamodel1 = new Model.T_FaultRepair_Evaluate();
  1645. evamodel1 = evamodel;
  1646. evamodel.F_WorkOrderCode = item;
  1647. evabll.Add(evamodel1);
  1648. if (Attitude < 3 || Quality < 3 || Efficiency < 3)
  1649. {
  1650. extmodel.MYD = 2;
  1651. msg.AddInternalMessagesInfo("您有工单被差评", "您有工单被差评" + "工单编号:" + item + "差评原因:" + EvaluateContent, extmodel.F_Maintenancer, User.F_UserCode, EnumSmsType.repair
  1652. , 0, item);
  1653. }
  1654. else if (Attitude == 3 || Quality == 3 || Efficiency == 3)
  1655. {
  1656. model.MYD = 1;
  1657. }
  1658. else
  1659. {
  1660. model.MYD = 0;
  1661. }
  1662. extmodel.F_Score = Attitude + Quality + Efficiency;
  1663. baseBll.Update(extmodel);
  1664. AddOperatorLog("评价了工单", (int)EnumOperatorType.evaluate, item);
  1665. }
  1666. }
  1667. #endregion
  1668. return Success("评价成功");
  1669. }
  1670. return Error("评价失败");
  1671. }
  1672. else
  1673. {
  1674. return Error("没有权限评价");
  1675. }
  1676. }
  1677. return Error("评价失败");
  1678. }
  1679. /// <summary>
  1680. /// 获取枚举值的描述属性
  1681. /// </summary>
  1682. /// <param name="enumValue"></param>
  1683. /// <returns></returns>
  1684. private string GetEnumDescription(Enum enumValue)
  1685. {
  1686. string value = enumValue.ToString();
  1687. FieldInfo field = enumValue.GetType().GetField(value);
  1688. object[] objs = field.GetCustomAttributes(typeof(DescriptionAttribute), false); //获取描述属性
  1689. if (objs == null || objs.Length == 0) //当描述属性没有时,直接返回名称
  1690. return value;
  1691. DescriptionAttribute descriptionAttribute = (DescriptionAttribute)objs[0];
  1692. return descriptionAttribute.Description;
  1693. }
  1694. #region 添加操作记录
  1695. public bool AddOperatorLogNew(string content, int type, string workordercode,string usercode)
  1696. {
  1697. Model.T_FaultRepair_OperationLog model = new Model.T_FaultRepair_OperationLog();
  1698. model.F_LogContent = content;
  1699. model.F_OperationTime = DateTime.Now;
  1700. model.F_OperationType = type;
  1701. model.F_Operator = usercode;
  1702. model.F_WorkOrderCode = workordercode;
  1703. logBll.Add(model);
  1704. return true;
  1705. }
  1706. public bool AddOperatorLog(string content, int type, string workordercode)
  1707. {
  1708. Model.T_FaultRepair_OperationLog model = new Model.T_FaultRepair_OperationLog();
  1709. model.F_LogContent = content;
  1710. model.F_OperationTime = DateTime.Now;
  1711. model.F_OperationType = type;
  1712. model.F_Operator = User.F_UserCode;
  1713. model.F_WorkOrderCode = workordercode;
  1714. logBll.Add(model);
  1715. return true;
  1716. }
  1717. public bool AddOperatorLogAboutKey(string content, int type, string workordercode,string value,int key,string enterreason)
  1718. {
  1719. Model.T_FaultRepair_OperationLog model = new Model.T_FaultRepair_OperationLog();
  1720. model.F_LogContent = content;
  1721. model.F_OperationTime = DateTime.Now;
  1722. model.F_OperationType = type;
  1723. model.F_Operator = User.F_UserCode;
  1724. model.F_WorkOrderCode = workordercode;
  1725. model.F_AboutKey = key;
  1726. model.F_AboutReason = value;
  1727. model.F_EnterReason = enterreason;
  1728. logBll.Add(model);
  1729. return true;
  1730. }
  1731. public void AddAddlog(string workordercode)
  1732. {
  1733. AddOperatorLog("创建报修工单", (int)EnumOperatorType.add, workordercode);
  1734. }
  1735. public void AddAssignlog(string workordercode, string dept, string maintenancer)
  1736. {
  1737. AddOperatorLog("指派工单给" + GetDeptModel(dept) + "部门" + GetUserModel(maintenancer), (int)EnumOperatorType.assign, workordercode);
  1738. }
  1739. public void AddInternalasslog(string workordercode, string newworkordercode)
  1740. {
  1741. AddOperatorLog("创建内协作工单" + newworkordercode, (int)EnumOperatorType.internalassistance, workordercode);
  1742. }
  1743. public void AddExternalasslog(string workordercode, string newworkordercode)
  1744. {
  1745. AddOperatorLog("创建外协作工单" + newworkordercode, (int)EnumOperatorType.externalassistance, workordercode);
  1746. }
  1747. [AllowAnonymous]
  1748. public bool AddAutoAssignlog(string workordercode, string dept, string maintenancer)
  1749. {
  1750. Model.T_FaultRepair_OperationLog model = new Model.T_FaultRepair_OperationLog();
  1751. model.F_LogContent = "超过十分钟未接单,自动指派工单给" + GetDeptModel(dept) + "部门" + GetUserModel(maintenancer);
  1752. model.F_OperationTime = DateTime.Now;
  1753. model.F_OperationType = (int)EnumOperatorType.assign;
  1754. model.F_Operator = "";
  1755. model.F_WorkOrderCode = workordercode;
  1756. logBll.Add(model);
  1757. return true;
  1758. }
  1759. #endregion
  1760. public string GetDeptModel(string deptId = "")
  1761. {
  1762. string sql = " 1=1 ";
  1763. if (!string.IsNullOrWhiteSpace(deptId))
  1764. {
  1765. sql += " and F_DeptId='" + deptId + "'";
  1766. }
  1767. if (string.IsNullOrWhiteSpace(sql))
  1768. return "";
  1769. var role = departmentBLL.GetModelList(sql).FirstOrDefault();
  1770. string name = role.F_DeptName;
  1771. return name;
  1772. }
  1773. public string GetUserModel(string usercode = "")
  1774. {
  1775. string sql = " 1=1 ";
  1776. if (!string.IsNullOrWhiteSpace(usercode))
  1777. {
  1778. sql += " and F_UserCode='" + usercode + "'";
  1779. }
  1780. if (string.IsNullOrEmpty(usercode))
  1781. return "";
  1782. Model.T_Sys_UserAccount ua = new Bll.T_Sys_UserAccount().GetModelList(sql).FirstOrDefault();
  1783. if (ua != null)
  1784. {
  1785. return ua.F_UserName;
  1786. }
  1787. return "";
  1788. }
  1789. //故障报修综合报表
  1790. public ActionResult ExportList()
  1791. {
  1792. string sql = " and F_IsDelete=0 ";
  1793. int isexport = RequestString.GetInt("isexport", -1);
  1794. string strpageindex = RequestString.GetQueryString("page");
  1795. int pageindex = 1;
  1796. string strpagesize = RequestString.GetQueryString("pagesize");
  1797. int pagesize = 10;
  1798. //创建时间 报修人 工单类别 工单状态 维修人 调度人
  1799. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  1800. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  1801. int category = RequestString.GetInt("category", -1);
  1802. int strstate = RequestString.GetInt("state", -1);
  1803. string applicant = HttpUtility.UrlDecode(RequestString.GetQueryString("applicant"));
  1804. string maintenancer = HttpUtility.UrlDecode(RequestString.GetQueryString("maintenancer"));
  1805. string createuser = HttpUtility.UrlDecode(RequestString.GetQueryString("createuser"));
  1806. Bll.T_Sys_UserAccount blluser = new Bll.T_Sys_UserAccount();
  1807. List<Model.T_Sys_UserAccount> listuser = blluser.GetModelList("F_DeleteFlag=0");
  1808. if (!string.IsNullOrEmpty(createuser))
  1809. {
  1810. try
  1811. {
  1812. int usercode = Convert.ToInt32(createuser);
  1813. sql += " and F_AssignUser='" + usercode + "'";
  1814. }
  1815. catch (Exception)
  1816. {
  1817. Model.T_Sys_UserAccount model = listuser.Find(x => x.F_UserName == createuser);
  1818. if (model != null)
  1819. {
  1820. sql += " and F_AssignUser='" + model.F_UserCode + "'";
  1821. }
  1822. }
  1823. }
  1824. if (!string.IsNullOrEmpty(maintenancer))
  1825. {
  1826. try
  1827. {
  1828. int usercode = Convert.ToInt32(maintenancer);
  1829. sql += " and F_Maintenancer='" + usercode + "'";
  1830. }
  1831. catch (Exception)
  1832. {
  1833. Model.T_Sys_UserAccount model = listuser.Find(x => x.F_UserName == maintenancer);
  1834. if (model != null)
  1835. {
  1836. sql += " and F_Maintenancer='" + model.F_UserCode + "'";
  1837. }
  1838. }
  1839. }
  1840. if (!string.IsNullOrEmpty(applicant))
  1841. {
  1842. try
  1843. {
  1844. int usercode = Convert.ToInt32(applicant);
  1845. sql += " and F_Applicant='" + usercode + "'";
  1846. }
  1847. catch (Exception)
  1848. {
  1849. Model.T_Sys_UserAccount model = listuser.Find(x => x.F_UserName == applicant);
  1850. if (model != null)
  1851. {
  1852. sql += " and F_Applicant='" + model.F_UserCode + "'";
  1853. }
  1854. }
  1855. }
  1856. #region 搜索条件
  1857. if (strpageindex.Trim() != "")
  1858. {
  1859. pageindex = Convert.ToInt32(strpageindex);
  1860. }
  1861. if (strpagesize.Trim() != "")
  1862. {
  1863. pagesize = Convert.ToInt32(strpagesize);
  1864. }
  1865. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  1866. {
  1867. if (strendtime.Trim() != "" && strendtime != "undefined")
  1868. {
  1869. sql += " and F_CreateTime between '" + strstarttime +
  1870. "' AND '" + strendtime + "'";
  1871. }
  1872. else
  1873. {
  1874. sql += " and F_CreateTime>='" + strstarttime + "' ";
  1875. }
  1876. }
  1877. else
  1878. {
  1879. if (strendtime.Trim() != "" && strendtime != "undefined")
  1880. {
  1881. sql += " and F_CreateTime<='" + strendtime + "' ";
  1882. }
  1883. }
  1884. #endregion
  1885. if (strstate > 0)
  1886. {
  1887. sql += " and F_WorkOrderState='" + strstate + "'";
  1888. }
  1889. if (category > 0)
  1890. {
  1891. sql += " and F_WorkOrderCategory='" + category + "'";
  1892. }
  1893. int recordCount = 0;
  1894. if (isexport == 1)
  1895. {
  1896. //执行时限 服务评价
  1897. string exportsql = "select F_WorkOrderCode 工单编号,F_CreateTime 创建时间,dbo.GetDepName (F_ApplicationDept) 报工科室,[dbo].[GetUserName](F_Applicant) 报修人,F_WorkOrderCategory 工单类别, F_Content 工单内容,(case F_WorkOrderState when 0 then '新工单' when 1 then '待查收'when 2 then '待完成'when 3 then '已处理'when 4 then '异常完结'when 5 then '已完结' when 6 then '已到达' else '' end ) 工单状态,[dbo].[GetUserName](F_Maintenancer) 维修员,F_Endtime 维修时间,dbo.[GetConvertSecond](DATEDIFF(ss,F_CreateTime,F_Endtime)) 工单耗时,[dbo].[GetGapTime](F_Deadline,F_Endtime) 执行时限, F_Score 服务评价,dbo.GetUserName(F_AssignUser) 调度人 from T_FaultRepair_Base where 1=1" + sql;
  1898. var dtdc = DbHelperSQL.Query(exportsql).Tables[0];
  1899. var msg = new NPOIHelper().ExportToExcel("故障报修综合报表", dtdc);
  1900. if (msg == "")
  1901. {
  1902. return Success("导出成功");
  1903. }
  1904. else
  1905. {
  1906. return Error("导出失败");
  1907. }
  1908. }
  1909. DataTable datatable = Bll.PagerBll.GetListPager
  1910. ("T_FaultRepair_Base ",
  1911. "F_WorkOrderId",
  1912. "F_WorkOrderId,F_WorkOrderCode ,F_CreateTime ,dbo.GetDepName(F_ApplicationDept) deptname ,[dbo].[GetUserName](F_Applicant) applicantname ,F_WorkOrderCategory , F_Content ,(case F_WorkOrderState when 0 then '新工单' when 1 then '待查收'when 2 then '待完成'when 3 then '已处理'when 4 then '异常完结'when 5 then '已完结' when 6 then '已到达' else '' end ) workorderstatename,[dbo].[GetUserName](F_Maintenancer) maintenancer,F_Endtime ,dbo.[GetConvertSecond](DATEDIFF(ss,F_CreateTime,F_Endtime)) spendtime ,[dbo].[GetGapTime](F_Deadline,F_Endtime) gaptime , F_Score ,dbo.GetUserName(F_AssignUser) createname",
  1913. sql,
  1914. "order by F_WorkOrderId desc",
  1915. pagesize,
  1916. pageindex,
  1917. true,
  1918. out recordCount
  1919. );
  1920. var obj = new
  1921. {
  1922. state = "success",
  1923. message = "成功",
  1924. rows = datatable,
  1925. total = recordCount
  1926. };
  1927. return Content(obj.ToJson());
  1928. }
  1929. //挂起
  1930. public ActionResult HangUp(string workordercode, int key, string value, string reason)
  1931. {
  1932. Model.T_FaultRepair_Base model = baseBll.GetModel(workordercode);
  1933. if (model != null && model.F_WorkOrderState != 2 && model.F_WorkOrderState != 6)
  1934. {
  1935. return Error("挂起失败");
  1936. }
  1937. model.F_IsStop = 1;
  1938. model.F_StopTime = DateTime.Now;
  1939. model.F_Endtime = DateTime.Now;
  1940. baseBll.Update(model);
  1941. string str = "";
  1942. if (!string.IsNullOrEmpty(reason))
  1943. {
  1944. str = "," + reason;
  1945. }
  1946. AddOperatorLogAboutKey(User.F_UserCode + "挂起了工单,原因:"+value+ str, (int)EnumOperatorType.hangup, model.F_WorkOrderCode,value,key, reason);
  1947. return Success("挂起成功");
  1948. }
  1949. //到达操作 arrive
  1950. public ActionResult Arrive(string workordercode)
  1951. {
  1952. Model.T_FaultRepair_Base model = baseBll.GetModel(workordercode);
  1953. if (model == null)
  1954. {
  1955. return Error("没有获取到工单号");
  1956. }
  1957. model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.arrive;
  1958. model.F_ArriveTime = DateTime.Now;
  1959. baseBll.Update(model);
  1960. AddOperatorLog(User.F_UserName + "已到达", (int)EnumOperatorType.arrive, model.F_WorkOrderCode);
  1961. return Success("到达操作成功");
  1962. }
  1963. //调度中心 退回到提交人(工单状态gai为“待提交”)
  1964. public ActionResult ReBack(string workordercode, string BackReason)
  1965. {
  1966. Model.T_FaultRepair_Base model = baseBll.GetModel(workordercode);
  1967. if (model == null)
  1968. {
  1969. return Error("没有获取到工单号");
  1970. }
  1971. model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.waitsubmit;
  1972. string s = "";
  1973. if (!string.IsNullOrEmpty(BackReason))
  1974. {
  1975. s += ",退回原因:" + BackReason;
  1976. }
  1977. baseBll.Update(model);
  1978. msg.AddInternalMessagesInfo("您有工单被退回", "您有工单被退回" + "工单编号:" + model.F_WorkOrderCode+s, model.F_Applicant
  1979. , User.F_UserCode, EnumSmsType.repair
  1980. , 0, model.F_WorkOrderCode);
  1981. AddOperatorLog(User.F_UserName + "退回了工单"+s, (int)EnumOperatorType.reback, model.F_WorkOrderCode);
  1982. return Success("退回操作成功");
  1983. }
  1984. // 撤回(已指派未接单的可进行撤回,工单状态为“新工单0”)
  1985. public ActionResult Retract(string workordercode, string BackReason)
  1986. {
  1987. Model.T_FaultRepair_Base model = baseBll.GetModel(workordercode);
  1988. if (model == null)
  1989. {
  1990. return Error("没有获取到工单号");
  1991. }
  1992. string s = "";
  1993. if (!string.IsNullOrEmpty(BackReason))
  1994. {
  1995. s += ",撤回原因:" + BackReason;
  1996. }
  1997. model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.neworder;
  1998. model.F_Maintenancer = "";
  1999. model.F_MaintenanceDept = "";
  2000. model.F_AssignTime = null;
  2001. model.F_AssignUser = "";
  2002. model.F_UpdateTime = DateTime.Now;
  2003. model.F_Deadline = null;
  2004. baseBll.Update(model);
  2005. ////催办次数改成0
  2006. //BLL.T_Wo_CommonBase wcbll = new BLL.T_Wo_CommonBase();
  2007. //Model.T_Wo_CommonBase wcmodel = wcbll.GetModel(workordercode);
  2008. //wcmodel.F_UrgeCount = 0;
  2009. //wcmodel.F_UpdateTime = DateTime.Now;
  2010. //wcbll.Update(wcmodel);
  2011. AddOperatorLog(User.F_UserName + "撤回了工单"+s, (int)EnumOperatorType.retract, model.F_WorkOrderCode);
  2012. return Success("撤回操作成功");
  2013. }
  2014. //综合保障中心里 指派(撤回之后可重新转派),同时需要记录操作流程
  2015. public ActionResult Assign(string workordercode, string maintenancer, string maintenanceDept)
  2016. {
  2017. Model.T_FaultRepair_Base model = baseBll.GetModel(workordercode);
  2018. if (model == null)
  2019. {
  2020. return Error("没有获取到工单号");
  2021. }
  2022. if (!string.IsNullOrEmpty(maintenanceDept))
  2023. {
  2024. model.F_AssignTime = DateTime.Now;
  2025. model.F_AssignUser = User.F_UserCode;
  2026. List<Model.T_Sys_GongDan> listgd = gdbll.GetModelList(" F_GDId='" + model.F_WorkOrderCategory + "'");
  2027. int timeout = listgd.First().F_TimeOut;
  2028. model.F_Deadline = DateTime.Now.AddHours(timeout);
  2029. model.F_MaintenanceDept = maintenanceDept;
  2030. if (!string.IsNullOrEmpty(maintenancer))
  2031. model.F_Maintenancer = maintenancer;
  2032. else
  2033. {
  2034. var user = GetBeOnDuty(maintenancer);
  2035. if (user != null && user.Count > 1)
  2036. {
  2037. model.F_Maintenancer = user[0];
  2038. }
  2039. else
  2040. {
  2041. return Error("请选择指派人员");
  2042. }
  2043. }
  2044. model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.receive;
  2045. }
  2046. baseBll.Update(model);
  2047. AddAssignlog(model.F_WorkOrderCode, maintenanceDept, maintenancer);
  2048. return Success("指派操作成功");
  2049. }
  2050. #region 我的提交页面的操作
  2051. //申请人撤回(未指派的工单可撤回,工单状态“待提交”)
  2052. public ActionResult MyRetract(string workordercode,string BackReason)
  2053. {
  2054. Model.T_FaultRepair_Base model = baseBll.GetModel(workordercode);
  2055. if (model == null)
  2056. {
  2057. return Error("没有获取到工单号");
  2058. }
  2059. if (model.F_WorkOrderState == 0)
  2060. {
  2061. string s = "";
  2062. if (!string.IsNullOrEmpty(BackReason))
  2063. {
  2064. s += ",撤回原因:" + BackReason;
  2065. }
  2066. model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.waitsubmit;
  2067. baseBll.Update(model);
  2068. AddOperatorLog(User.F_UserName + "撤回了工单"+s, (int)EnumOperatorType.myretract, model.F_WorkOrderCode);
  2069. return Success("撤回操作成功");
  2070. }
  2071. else
  2072. {
  2073. return Error("不能撤回");
  2074. }
  2075. }
  2076. //我的提交里编辑工单
  2077. /// <summary>
  2078. ///编辑
  2079. /// </summary>
  2080. /// <param name="input"></param>
  2081. /// <returns></returns>
  2082. public ActionResult MyUpdateFaultRepairWorkOrder(T_FaultRepairBaseinput input)
  2083. {
  2084. Model.T_FaultRepair_Base model = baseBll.GetModel(input.WorkOrderCode);
  2085. model.F_WorkOrderCategory = input.WorkOrderCategory;
  2086. model.F_Content = input.Content;
  2087. model.F_PlaceOfRepair = input.PlaceOfRepair;
  2088. model.F_File = input.File;
  2089. model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.neworder;
  2090. model.F_UpdateTime = DateTime.Now;
  2091. if (baseBll.Update(model))
  2092. {
  2093. AddOperatorLog(User.F_UserName + "编辑了工单", (int)EnumOperatorType.update, model.F_WorkOrderCode);
  2094. return Success("编辑成功!");
  2095. }
  2096. else return Error("编辑失败!");
  2097. }
  2098. #endregion
  2099. //延期
  2100. //接单人在接单之后,如果该工单类型上设置的“可延期次数”大于0显示“延期”按钮;点击延期按钮进行验证是否超过设定的延期次数,超过提醒“已超过规定延迟次数”
  2101. //操作流程记录延期
  2102. public ActionResult frReplay(string workordercode, string days, string type, string workordercategory,string reason,int key, string value)
  2103. {
  2104. Model.T_Sys_GongDan gdmodel = gdbll.GetModel(Convert.ToInt32(workordercategory));
  2105. Model.T_Wo_CommonBase model = cbbll.GetModel(workordercode);
  2106. if (!string.IsNullOrEmpty(reason))
  2107. {
  2108. reason = "," + reason;
  2109. }
  2110. string strreason = ",原因:"+value+ reason;
  2111. if (gdmodel.F_CanReplayCount > 0)
  2112. {
  2113. if (gdmodel.F_CanReplayCount >= model.F_ReplayCount + 1)
  2114. {
  2115. //业务咨询流程延期
  2116. if (type == "1000")
  2117. {
  2118. Model.T_Con_WorkOrder cwmodel = cwbll.GetModelByCode(workordercode);
  2119. cwmodel.F_ReplayCount = cwmodel.F_ReplayCount + 1;
  2120. cwbll.Update(cwmodel);
  2121. var itemid = Addlogbll.AddLogAboutKey(cwmodel.F_ID, 0, 0, User.F_UserName + "(" + User.F_UserCode + ")" + "给工单延期" + days + "h"+ strreason, (int)EnumItemType.Delay, 14, "", 0, User.F_UserCode,key,value, reason);
  2122. }
  2123. //故障报工单延期修
  2124. if (type == "3000")
  2125. {
  2126. Model.T_FaultRepair_Base fbmodel = baseBll.GetModel(workordercode);
  2127. fbmodel.F_ReplayCount = fbmodel.F_ReplayCount + 1;
  2128. baseBll.Update(fbmodel);
  2129. AddOperatorLog("给工单延期" + days+"h"+ strreason, (int)EnumOperatorType.replay, workordercode);
  2130. }
  2131. return Success("成功延期");
  2132. }
  2133. else
  2134. {
  2135. return Error("已超过规定延迟次数");
  2136. }
  2137. }
  2138. return Error("工单类型设置的可延期次数为0");
  2139. }
  2140. /// <summary>
  2141. /// 申请人确认耗材
  2142. /// </summary>
  2143. /// <returns></returns>
  2144. public ActionResult ConfirmEquips(string workordercode,int confirmtype,string reason)
  2145. {
  2146. Model.T_FaultRepair_Base model = baseBll.GetModel(workordercode);
  2147. if (confirmtype == 0)
  2148. {
  2149. string logs = "";
  2150. if (!string.IsNullOrEmpty(reason)) {
  2151. logs = ",原因:" + reason;
  2152. }
  2153. model.F_ConfirmEquip = 0;
  2154. model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.dealing;
  2155. AddOperatorLog("耗材确认有误"+logs, (int)EnumOperatorType.confirm, workordercode);
  2156. }
  2157. else
  2158. {
  2159. model.F_ConfirmEquip = 2;
  2160. AddOperatorLog("确认耗材无误", (int)EnumOperatorType.confirm, workordercode);
  2161. }
  2162. baseBll.Update(model);
  2163. return Success("确认耗材接口");
  2164. }
  2165. //发送超时未接单的消
  2166. //20222031更正为:即将超时 距离截止日期还有十分钟 还未接单的发消息给组长
  2167. public ActionResult AutoSendOverTimeMsg()
  2168. {
  2169. string sql = " select F_Deadline,F_WorkOrderState, * from T_FaultRepair_Base where F_WorkOrderState=1 and DATEDIFF(mi, GETDATE(), F_Deadline)< 10 and DATEDIFF(mi, GETDATE(), F_Deadline)> 0";
  2170. DataTable dt = DbHelperSQL.Query(sql).Tables[0];
  2171. if (dt != null && dt.Rows.Count > 0)
  2172. {
  2173. foreach (DataRow item in dt.Rows)
  2174. {
  2175. //根据处理部门获取班组长 WXBZZ
  2176. var dtuser = DbHelperSQL.Query(" select top 1 F_usercode from T_Sys_UserAccount where F_DeptId='' and F_RoleId=(select F_roleid from T_Sys_Role where F_RoleCode='WXBZZ')").Tables[0];
  2177. if (dtuser != null && dtuser.Rows.Count > 0)
  2178. {
  2179. string message = "";
  2180. var dicvalue = new Model.T_Sys_GongDan();
  2181. dicvalue = new Bll.T_Sys_GongDan().GetModel(Convert.ToInt32(item["F_WorkOrderCategory"].ToString()));
  2182. if (dicvalue != null)
  2183. {
  2184. message = ",工单类型:故障报修/" + dicvalue.F_Name;
  2185. }
  2186. message += ",报修科室:" + GetParentDeptName(Convert.ToInt32( item["F_ApplicationDept"].ToString()));
  2187. message += ",工单内容:" + item["F_Content"].ToString();
  2188. message += ",相关人员:" + GetUserModel(item["F_Maintenancer"].ToString());
  2189. msg.AddInternalMessagesInfo("您部门下有工单即将超时未接单", "您部门下有工单即将超时未接单" + "工单编号:" + item["F_WorkOrderCode"].ToString(), dtuser.Rows[0]["F_usercode"].ToString(), User.F_UserCode, EnumSmsType.repair
  2190. , 0, item["F_WorkOrderCode"].ToString());
  2191. }
  2192. }
  2193. }
  2194. return Success("发送超时未接单的消息成功");
  2195. }
  2196. StringBuilder returnname = new StringBuilder();
  2197. [AllowAnonymous]
  2198. public string GetParentDeptName(int deptid)
  2199. {
  2200. var model = departmentBLL.GetModel(deptid);
  2201. if (model != null)
  2202. {
  2203. returnname.Insert(0, model.F_DeptName);
  2204. returnname.Insert(0, "/");
  2205. if (model.F_ParentId != 0)
  2206. {
  2207. GetParentDeptName(model.F_ParentId.Value);
  2208. }
  2209. if (model.F_ParentId == 0)
  2210. {
  2211. string sql = " select T_Woname from T_Wowo_repairyq where T_Woid='" + model.T_Woid + "'";
  2212. string yqname= DbHelperSQL.GetSingle(sql).ToString();
  2213. returnname.Insert(0, yqname);
  2214. }
  2215. }
  2216. return returnname.ToString();
  2217. }
  2218. /// <summary>
  2219. /// 基建后勤类型,10分钟内未接单转派给基建和后勤保障部的值班人员(根据排班表)
  2220. /// </summary>
  2221. /// <returns></returns>
  2222. public ActionResult AutoChangeDealMan()
  2223. {
  2224. string sql = " select F_GDId from T_Sys_GongDan where F_Name='基建后勤类'";
  2225. int gdid =Convert.ToInt32( DbHelperSQL.GetSingle(sql));
  2226. if (gdid > 0)
  2227. {
  2228. string allgd = " select * from T_FaultRepair_Base where F_accepttime is null and DATEDIFF(MINUTE, F_AssignTime, GETDATE()) > 10 and F_WorkOrderCategory in (select * from dbo.getvalueid('" + gdid + "'))";
  2229. DataTable dt = DbHelperSQL.Query(allgd).Tables[0];
  2230. if (dt != null && dt.Rows.Count > 0)
  2231. {
  2232. string sqldept = " select F_DeptId from T_Sys_Department where F_DeptCode='HQBZ'";
  2233. int deptid = Convert.ToInt32(DbHelperSQL.GetSingle(sqldept));
  2234. List<Model.T_Sys_GroupClass> modellist = new List<Model.T_Sys_GroupClass>();
  2235. if (deptid > 0)
  2236. {
  2237. modellist = gcBll.GetModelList("F_IsDelete = 0 and F_Date = CONVERT(varchar, GETDATE(), 120) and F_ClassCode in (select F_Id from t_sys_class where F_IsDelete = 0 and CONVERT(varchar, GETDATE(), 108) between F_InTime and F_OutTime and F_DeptId = '" + deptid + "')");
  2238. }
  2239. foreach (DataRow item in dt.Rows)
  2240. {
  2241. Model.T_FaultRepair_Base frmodel= baseBll.GetModel(item["F_WorkOrderCode"].ToString());
  2242. if (modellist.Count > 0)
  2243. {
  2244. var shaixuanlist = modellist.Where(x => x.F_UserCode != frmodel.F_Maintenancer).ToList();
  2245. if (shaixuanlist.Count > 0)
  2246. {
  2247. frmodel.F_AssignTime = DateTime.Now;
  2248. frmodel.F_Maintenancer = shaixuanlist.First().F_UserCode;
  2249. frmodel.F_MaintenanceDept = deptid.ToString();
  2250. baseBll.Update(frmodel);
  2251. AddAutoAssignlog(item["F_WorkOrderCode"].ToString(), deptid.ToString(), frmodel.F_Maintenancer);
  2252. }
  2253. }
  2254. }
  2255. }
  2256. return Success("执行成功");
  2257. }
  2258. return Error("基建后勤类型不存在");
  2259. }
  2260. }
  2261. }