| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765 |
- using RMYY_CallCenter_Api.DB;
- using RMYY_CallCenter_Api.Model;
- using RMYY_CallCenter_Api.Models;
- using RMYY_CallCenter_Api.Models.Enum;
- using RMYY_CallCenter_Api.Models.Input;
- using RMYY_CallCenter_Api.Utility;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.IO;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Web;
- using System.Web.Mvc;
- namespace RMYY_CallCenter_Api.Controllers
- {
- public class FaultRepairController : BaseController
- {
- private Bll.T_Sys_GroupClass gcBll = new Bll.T_Sys_GroupClass();
- private BLL.T_IntegratedScheduling_Base basescheBll = new BLL.T_IntegratedScheduling_Base();
- private BLL.T_FaultRepair_Base baseBll = new BLL.T_FaultRepair_Base();
- private BLL.T_FaultRepair_Evaluate evaBll = new BLL.T_FaultRepair_Evaluate();
- private BLL.T_FaultRepair_OperationLog logBll = new BLL.T_FaultRepair_OperationLog();
- private BLL.T_FaultRepair_Process dealBll = new BLL.T_FaultRepair_Process();
- Bll.T_Sys_GongDan gdbll = new Bll.T_Sys_GongDan();
- private Bll.T_Sys_SystemConfig configBll = new Bll.T_Sys_SystemConfig();
- private Bll.T_Sys_DictionaryValue dictionaryValueBLL = new Bll.T_Sys_DictionaryValue();
- private Bll.T_Sys_Department departmentBLL = new Bll.T_Sys_Department();
- private Bll.T_InvolvedEquip_RepairProcess equipbll = new Bll.T_InvolvedEquip_RepairProcess();
- private BLL.T_Wo_CommonBase cbbll = new BLL.T_Wo_CommonBase();
- private Bll.T_Con_WorkOrder cwbll = new Bll.T_Con_WorkOrder();
- private Bll.AddLogBll Addlogbll = new Bll.AddLogBll();
- private static InternalMessagesController msg = new InternalMessagesController();
- public DataTable GetFileData(string ids, string prefix)
- {
- DataTable dt = DbHelperSQL.Query("select * from T_Sys_Accessories WITH(NOLOCK) where F_FileId in (" + ids + ")").Tables[0];
- foreach (DataRow dr in dt.Rows)
- {
- dr["F_FileUrl"] = prefix + dr["F_FileUrl"].ToString();
- }
- return dt;
- }
- /// <summary>
- /// 工单详情获取设备信息
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- public DataTable GetEquipsData(string ids)
- {
- DataTable dt = DbHelperSQL.Query("select * from T_InvolvedEquip_RepairProcess WITH(NOLOCK) where F_ID in (SELECT COL FROM DBO.SplitToNvarchar('" + ids + "',','))").Tables[0];
- return dt;
- }
- /// <summary>
- /// 上传附件
- /// </summary>
- /// <returns></returns>
- //[Authority]
- public ActionResult UploadFile()
- {
- #region 多个上传
- HttpFileCollectionBase files = Request.Files;
- if (files.Count > 0)
- {
- List<Model.T_Sys_Accessories> acs = new List<Model.T_Sys_Accessories>();
- string path = "/Upload/Files/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/";
- for (int i = 0; i < files.Count; i++)
- {
- HttpPostedFileBase file = files[i];
- string name = FileHelper.Upload(file, path);
- Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
- model_T_Sys_Accessories.F_AddTime = DateTime.Now;//上传时间
- model_T_Sys_Accessories.F_FileName = name;//附件名称
- model_T_Sys_Accessories.F_FileType = Path.GetExtension(file.FileName);//附件类型
- model_T_Sys_Accessories.F_FileUrl = path + name;//附件地址
- model_T_Sys_Accessories.F_Size = file.ContentLength;
- model_T_Sys_Accessories.F_UserCode = User.F_UserCode;//上传人
- int id = new Bll.T_Sys_Accessories().Add(model_T_Sys_Accessories);
- model_T_Sys_Accessories.F_FileId = id;
- acs.Add(model_T_Sys_Accessories);
- }
- return Success("成功", acs);
- }
- else
- {
- return Error("请选择要上传的文件");
- }
- #endregion
- }
- //添加工单
- /// <summary>
- ///添加
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public ActionResult AddFaultRepairWorkOrder(T_FaultRepairBaseinput input)
- {
- Model.T_FaultRepair_Base model = new Model.T_FaultRepair_Base();
- model.F_Applicant = input.Applicant;
- if (string.IsNullOrEmpty(input.ApplicationDept))
- {
- return Error("申请部门是必填");
- }
- model.F_ApplicationDept = input.ApplicationDept.Trim();
- model.F_Phone = input.Phone;
- model.F_Applicantsphone = input.Applicantsphone;
- if (string.IsNullOrEmpty(input.WorkOrderCategory))
- {
- return Error("工单类别是必填");
- }
- model.F_WorkOrderCategory = input.WorkOrderCategory.Trim();
- model.F_Content = input.Content;
- model.F_PlaceOfRepair = input.PlaceOfRepair;
- model.F_File = input.File;
- model.F_WorkOrderCode = DateTime.Now.ToString("yyyyMMddHHmmssfff");//工单编号
- model.F_EmergencyTypes = input.EmergencyTypes;
- string message = "";
- var dicvalue = new Model.T_Sys_GongDan();
- dicvalue = new Bll.T_Sys_GongDan().GetModel(Convert.ToInt32(model.F_WorkOrderCategory));
- if (dicvalue != null)
- {
- message = ",工单类型:故障报修/" + dicvalue.F_Name;
- }
- if (input.IsEnd == 1)
- {
- model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.finish;
- model.F_MaintenanceDept = User.F_DeptId.ToString();
- model.F_Maintenancer = User.F_UserCode;
- model.F_Endtime = DateTime.Now;
- model.F_Deadline = DateTime.Now;
- }
- else if (!string.IsNullOrEmpty(input.MaintenanceDept))
- {
- model.F_MaintenanceDept = input.MaintenanceDept;
- if (!string.IsNullOrEmpty(input.Maintenancer))
- {
- model.F_Maintenancer = input.Maintenancer;
- model.F_AssignTime = DateTime.Now;
- model.F_AssignUser = User.F_UserCode;
- List<Model.T_Sys_GongDan> listgd = gdbll.GetModelList(" F_GDId='" + model.F_WorkOrderCategory + "'");
- int timeout = listgd.First().F_TimeOut;
- model.F_Deadline = DateTime.Now.AddHours(timeout);
-
- msg.AddInternalMessagesInfo("您有新的工单请及时查收", "您有新的工单请及时查收" + "工单编号:" + model.F_WorkOrderCode + message, model.F_Maintenancer, User.F_UserCode, EnumSmsType.repair
- , 0, model.F_WorkOrderCode);
- }
- else
- {
- var user = GetBeOnDuty(input.MaintenanceDept);
- if (user != null && user.Count > 1)
- {
- model.F_Maintenancer = user[0];
- input.Maintenancer = user[0];
- model.F_AssignTime = DateTime.Now;
- model.F_AssignUser = User.F_UserCode;
- List<Model.T_Sys_GongDan> listgd = gdbll.GetModelList(" F_GDId='" + model.F_WorkOrderCategory + "'");
- int timeout = listgd.First().F_TimeOut;
- model.F_Deadline = DateTime.Now.AddHours(timeout);
- msg.AddInternalMessagesInfo("您有新的工单请及时查收", "您有新的工单请及时查收" + "工单编号:" + model.F_WorkOrderCode + message, model.F_Maintenancer, User.F_UserCode, EnumSmsType.repair
- , 0, model.F_WorkOrderCode);
- }
- else
- {
- return Error("请选择指派人员");
- }
- }
- model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.receive;
- }
- else
- {
- model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.neworder;
- }
- model.F_CreateTime = DateTime.Now;
- model.F_CreateUser = User.F_UserCode;
- model.F_CreateUserDept = User.F_DeptId.ToString();
- if (input.LeaveRecordId != null && input.LeaveRecordId > 0)
- {
- var ld = new Bll.T_Call_LeaveRecord().GetModel(input.LeaveRecordId.Value);
- if (ld != null)
- {
- ld.F_Status = 1;
- ld.F_DealTime = DateTime.Now;
- ld.F_UserId = User.F_UserId;
- ld.F_UserCode = User.F_UserCode;
- ld.F_UserName = User.F_UserName;
- ld.F_WorkOrderId = model.F_WorkOrderCode;
- ld.F_Type = 3000;
- new Bll.T_Call_LeaveRecord().Update(ld);
- model.F_LeaveRecordId = input.LeaveRecordId;
- }
- }
- //if (input.CallRecordsId!=null && input.CallRecordsId>0)
- //{
- // var rd = new Bll.T_Call_CallRecords().GetModelByRecordId(input.CallRecordsId.ToString());
- // if (rd != null)
- // {
- // model.F_CallId = rd.CallId;
- // rd.WorkOrderId = model.F_WorkOrderCode;//.F_WorkOrderId;
- // rd.IsExitWorkOrder = true;
- // new Bll.T_Call_CallRecords().Update(rd);
- // model.F_CallRecordId = rd.CallRecordsId;
- // }
- //}
- //else
- if (!string.IsNullOrEmpty(input.CallId))
- {
- model.F_CallId = input.CallId;
- var rd = new Bll.T_Call_CallRecords().GetModelByCallId(input.CallId);
- if (rd != null)
- {
- rd.WorkOrderId = model.F_WorkOrderCode;//.F_WorkOrderId;
- rd.IsExitWorkOrder = true;
- new Bll.T_Call_CallRecords().Update(rd);
- model.F_CallRecordId = rd.CallRecordsId;
- }
- }
- model.F_ReplayCount = 0;
- int returnid = baseBll.Add(model);
- if (User.F_RoleCode != "DDZX" && model.F_WorkOrderState == 0)
- {
- //新工单提醒发给调度中心值班的人
- // 根据排班信息 获取当前调度中心值班的人
- List<string> touserlist= GetDDZXBeOnDuty();
- if(touserlist!=null && touserlist.Count>0)
- foreach (var item in touserlist)
- {
- msg.AddInternalMessagesInfo("您有新的工单请及时查收", "您有新的工单请及时查收" + "工单编号:" + model.F_WorkOrderCode + message, item, User.F_UserCode, EnumSmsType.repair
- , 0, model.F_WorkOrderCode);
- }
-
-
- }
- if (returnid > 0)
- {
- AddAddlog(model.F_WorkOrderCode);
- if (!string.IsNullOrEmpty(input.MaintenanceDept))
- {
- AddAssignlog(model.F_WorkOrderCode, input.MaintenanceDept, input.Maintenancer);
- }
- if (input.IsEnd == 1)
- {
- AddOperatorLog("完结了工单", (int)EnumOperatorType.dealed, model.F_WorkOrderCode);
- }
- return Success("添加成功!", returnid);
- }
- else return Error("添加失败!");
- }
- private List<string> GetDDZXBeOnDuty()
- {
- List<string> userlist = new List<string>();
-
- var GroupClass = new Bll.T_Sys_GroupClass().GetModelList("F_IsDelete=0 and datediff(day , F_Date , getdate())= 0 " +
- "and F_DeptId= ( select F_DeptId from T_Sys_Department where F_deptcode='ZHDDZX') order by F_Id asc");
- if (GroupClass != null && GroupClass.Count > 0)
- {
- userlist = GroupClass.Select(x => x.F_UserCode).ToList();
-
- }
- return userlist;
- }
- //综合保障中心编辑工单
- /// <summary>
- ///编辑
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public ActionResult UpdateFaultRepairWorkOrder(T_FaultRepairBaseinput input)
- {
- Model.T_FaultRepair_Base model = baseBll.GetModel(input.WorkOrderCode);
- model.F_Applicant = input.Applicant;
- model.F_ApplicationDept = input.ApplicationDept;
- model.F_Phone = input.Phone;
- model.F_Applicantsphone = input.Applicantsphone;
- model.F_WorkOrderCategory = input.WorkOrderCategory;
- model.F_Content = input.Content;
- model.F_PlaceOfRepair = input.PlaceOfRepair;
- model.F_File = input.File;
- model.F_EmergencyTypes = input.EmergencyTypes;
- // bool addassignlog = false;
- //综合保障中心没有直接结束的按钮
- #region 综合保障中心 编辑时 没有转派的操作,只修改基础的信息
- //if (input.IsEnd == 1)
- //{
- // model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.finish;
- // model.F_MaintenanceDept = User.F_DeptId.ToString();
- // model.F_Endtime = DateTime.Now;
- // model.F_Maintenancer = User.F_UserCode;
- //}
- //else if (!string.IsNullOrEmpty(input.MaintenanceDept))
- //{
- // if ( string.IsNullOrEmpty(model.F_MaintenanceDept))
- // {
- // model.F_AssignTime = DateTime.Now;
- // model.F_AssignUser = User.F_UserCode;
- // List<Model.T_Sys_GongDan> listgd = gdbll.GetModelList(" F_GDId='" + model.F_WorkOrderCategory + "'");
- // int timeout = listgd.First().F_TimeOut;
- // model.F_Deadline = DateTime.Now.AddHours(timeout);
- // model.F_MaintenanceDept = input.MaintenanceDept;
- // if (!string .IsNullOrEmpty(input.Maintenancer))
- // model.F_Maintenancer = input.Maintenancer;
- // else
- // {
- // var user = GetBeOnDuty(input.MaintenanceDept);
- // if (user != null && user.Count > 1)
- // {
- // model.F_Maintenancer = user[0];
- // }
- // else
- // {
- // return Error("请选择指派人员");
- // }
- // }
- // model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.receive;
- // addassignlog = true;
- // }
- //}
- //else
- //{
- // model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.neworder;
- //}
- #endregion
- model.F_UpdateTime = DateTime.Now;
- if (baseBll.Update(model))
- {
- //if (addassignlog)
- //{
- // AddAssignlog(model.F_WorkOrderCode, input.MaintenanceDept, input.Maintenancer);
- //}
- //if (input.IsEnd == 1)
- //{
- // AddOperatorLog("完结了工单", (int)EnumOperatorType.dealed, model.F_WorkOrderCode);
- //}
- AddOperatorLog(User.F_UserName + "编辑了工单", (int)EnumOperatorType.update, model.F_WorkOrderCode);
- return Success("编辑成功!");
- }
- else return Error("编辑失败!");
- }
- //处理人查收
- public ActionResult CheckWorkOrder(string WorkOrderCode)
- {
- Model.T_FaultRepair_Base model = baseBll.GetModel(WorkOrderCode);
- if (model != null)
- {
- if (model.F_MaintenanceDept == User.F_DeptId.ToString())
- {
- //同一部门的人都可以接单
- //if (!string.IsNullOrEmpty(model.F_Maintenancer) && User.F_UserCode!=model.F_Maintenancer)
- //{
- // return Error("你没有权限查收!");
- //}
- model.F_UpdateTime = DateTime.Now;
- if (string.IsNullOrEmpty(model.F_Maintenancer))
- {
- model.F_Maintenancer = User.F_UserCode;
- }
- model.F_AcceptTime = DateTime.Now;
- model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.dealing;
- baseBll.Update(model);
- AddOperatorLog("查收了工单", (int)EnumOperatorType.check, model.F_WorkOrderCode);
- return Success(" 查收成功!");
- }
- else
- {
- return Error("你没有权限查收!");
- }
- }
- return Error("工单不存在!");
- }
- //处理人退单
- public ActionResult BackWorkOrder(string WorkOrderCode, string BackReason ,int key, string value)
- {
- Model.T_FaultRepair_Base model = baseBll.GetModel(WorkOrderCode);
- string s = ",退回原因:" + value ;
- if (!string.IsNullOrEmpty(BackReason))
- {
- s =s+ "," + BackReason;
- }
- if (model != null)
- {
- if (model.F_MaintenanceDept == User.F_DeptId.ToString())
- {
- string assignuser = model.F_AssignUser;
- model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.neworder;
- model.F_Maintenancer = "";
- model.F_MaintenanceDept = "";
- model.F_AssignTime = null;
- model.F_AssignUser = "";
- model.F_UpdateTime = DateTime.Now;
- model.F_Deadline = null;
- model.F_AcceptTime = null;
- baseBll.Update(model);
-
-
- AddOperatorLogAboutKey("退回了工单" + s, (int)EnumOperatorType.back, model.F_WorkOrderCode,value,key,BackReason);
- msg.AddInternalMessagesInfo("您有工单被退回", "您有工单被退回" + "工单编号:" + model.F_WorkOrderCode+s, assignuser
- , User.F_UserCode, EnumSmsType.repair
- , 0, model.F_WorkOrderCode);
- return Success(" 退回成功!");
- }
- else
- {
- return Error("你没有权限退回!");
- }
- }
- return Error("工单不存在!");
- }
- //维修员能看见当前部门的所有的工单 ,对于所有的工单都能去处理
- //处理完成 、异常完结 Type=0 正常完成 Type=1异常完结 判断是不是返修的工单
- //点击正常完成的时候添加“是否涉及设备,是否涉及设备点击是,出现下拉框可多选设备,选择之后可输入对应的数量和价格
- 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)
- {
- Model.T_FaultRepair_Base model = baseBll.GetModel(WorkOrderCode);
- if (Type == 0 && model.F_WorkOrderState != 6)
- {
- return Error("没有到达之前不能处理工单");
- }
- //判断是不是返修的,
- string sql = "select * from T_FaultRepair_Process where F_WorkOrderCode='" + WorkOrderCode + "' and F_ReturnReason is not null and F_Maintenancer='" + User.F_UserCode + "'";
- DataTable dt = DbHelperSQL.Query(sql).Tables[0];
- if (model != null)
- {
- //正常完成
- if (Type == 0)
- {
- model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.dealed;
-
- //是返修的工单
- if (dt != null && dt.Rows.Count > 0)
- {
- int procid = Convert.ToInt32(dt.Rows[0]["F_ProcessId"].ToString());
- 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 + "'";
- int updateid = DbHelperSQL.ExecuteSql(updatesql);
- if (IsInvolvedEquip == 1)
- {
- string ids = "";
- foreach (Model.T_InvolvedEquip_RepairProcess item in equipmodellist)
- {
- item.F_CreateTime = DateTime.Now;
- item.F_IsDelete = 0;
- item.F_RepairProcessId = procid;
- item.F_WorkOrderCode = WorkOrderCode;
- int equipid = equipbll.Add(item);
- ids += equipid + ",";
- }
- Model.T_FaultRepair_Process promodelnew = dealBll.GetModel(procid);
- model.F_ConfirmEquip = 1;
- promodelnew.F_EquipDetail = ids.Substring(0, ids.LastIndexOf(','));
-
- dealBll.Update(promodelnew);
- }
- if (updateid > 0)
- {
- if (model.F_IsStop != 1)
- { model.F_Endtime = DateTime.Now; }
- baseBll.Update(model);
- msg.AddInternalMessagesInfo("您提交的工单已处理完毕,请及时进行评价", "您提交的工单已处理完毕,请及时进行评价" + "工单编号:" + model.F_WorkOrderCode, model.F_Applicant, User.F_UserCode, EnumSmsType.repair
- , 0, model.F_WorkOrderCode);
- AddOperatorLog("完结了工单", (int)EnumOperatorType.dealed, WorkOrderCode);
- return Success("处理完成");
- }
- else
- return Error("处理失败");
- }
- Model.T_FaultRepair_Process promodel = new Model.T_FaultRepair_Process();
- promodel.F_Isdelete = 0;
- promodel.F_MaintenanceDept = User.F_DeptId.ToString();// model.F_MaintenanceDept;
- promodel.F_Maintenancer = User.F_UserCode;// model.F_Maintenancer;
- promodel.F_ProcessingTime = DateTime.Now;
- promodel.F_Result = Result;
- promodel.F_File = File;
- promodel.F_WorkOrderCode = WorkOrderCode;
- promodel.F_IsInvolvedEquip = IsInvolvedEquip;//0 是否 1 是 是
- promodel.F_FinishType = finishtype; //报修工单完工时增加处理方式:“远程”、“现场”,默认现场,另外工单详情中需要显示该字段信息
- promodel.F_DealType = (int)EnumFaultRepairDealType.normal;
- int id = dealBll.Add(promodel);
- //是否涉及设备点击是,出现下拉框可多选设备,选择之后可输入对应的数量和价格
- if (id > 0 && IsInvolvedEquip == 1)
- {
- string ids = "";
- foreach (Model.T_InvolvedEquip_RepairProcess item in equipmodellist)
- {
- item.F_CreateTime = DateTime.Now;
- item.F_IsDelete = 0;
- item.F_RepairProcessId = id;
- item.F_WorkOrderCode = WorkOrderCode;
- int equipid = equipbll.Add(item);
- ids += equipid + ",";
- }
- model.F_ConfirmEquip = 1;
- Model.T_FaultRepair_Process promodelnew = dealBll.GetModel(id);
- promodelnew.F_EquipDetail = ids.Substring(0, ids.LastIndexOf(','));
- dealBll.Update(promodelnew);
- }
- if (id > 0)
- {
- if (model.F_IsStop != 1)
- { model.F_Endtime = DateTime.Now; }
- baseBll.Update(model);
- msg.AddInternalMessagesInfo("您提交的工单已处理完毕,请及时进行评价", "您提交的工单已处理完毕,请及时进行评价" + "工单编号:" + model.F_WorkOrderCode, model.F_Applicant, User.F_UserCode, EnumSmsType.repair
- , 0, model.F_WorkOrderCode);
- AddOperatorLog("完结了工单", (int)EnumOperatorType.dealed, WorkOrderCode);
- return Success("处理完成");
- }
- else
- return Error("处理失败");
- }
- else
- {
- int dealtype = 0;
- // "自行解决";
- if (User.F_DeptId.ToString() == model.F_ApplicationDept.Trim())//创建工单的人是处理人,存自行解决
- {
- dealtype = (int)EnumFaultRepairDealType.resolve;// "自行解决";
- }
- else
- {
- dealtype = (int)EnumFaultRepairDealType.abnormal;
- }
- model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.exceptionended;
- // model.F_Endtime = DateTime.Now;
- //是返修的工单
- if (dt != null && dt.Rows.Count > 0)
- {
- // promodel.F_ExceptionType = ExceptionType;
- int procid = Convert.ToInt32(dt.Rows[0]["F_ProcessId"].ToString());
- 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 + "'";
- if (DbHelperSQL.ExecuteSql(updatesql) > 0)
- {
- if (model.F_IsStop != 1)
- { model.F_Endtime = DateTime.Now; }
- baseBll.Update(model);
- AddOperatorLog("异常完结了工单", (int)EnumOperatorType.exceptionended, WorkOrderCode);
- return Success("异常完结");
- }
- else
- return Error("异常完结失败");
- }
- //异常完结工单
- Model.T_FaultRepair_Process promodel = new Model.T_FaultRepair_Process();
- promodel.F_Isdelete = 0;
- promodel.F_MaintenanceDept = User.F_DeptId.ToString();// model.F_MaintenanceDept;
- promodel.F_Maintenancer = User.F_UserCode;// model.F_Maintenancer;
- promodel.F_ProcessingTime = DateTime.Now;
- promodel.F_Result = Result;
- promodel.F_File = File;
- promodel.F_WorkOrderCode = WorkOrderCode;
- promodel.F_ExceptionType = ExceptionType;
- promodel.F_DealType = dealtype;
- promodel.F_FinishType = finishtype;
- if (dealBll.Add(promodel) > 0)
- {
- if (model.F_IsStop != 1)
- { model.F_Endtime = DateTime.Now; }
- baseBll.Update(model);
- AddOperatorLog("异常完结了工单", (int)EnumOperatorType.exceptionended, WorkOrderCode);
- return Success("异常完结");
- }
- else
- return Error("异常完结失败");
- }
- }
- return Error("工单不存在");
- }
- //操作:挂起(挂起的工单超时时限不记录到超时时限中,只有处理中未完结的工单可挂起),另外列表显示一列“是否挂起”字段
- //协助.内外协助都生成新工单 Type 0是内部协助 1是外部协助
- public ActionResult AssistWorkOrder(string WorkOrderCode, string WorkOrderCategory, string Maintenancer, string Content, int Type)
- {
- Model.T_FaultRepair_Base model = baseBll.GetModel(WorkOrderCode);
- Model.T_FaultRepair_Base newmodel = new Model.T_FaultRepair_Base();
- if (Type == 0)
- {
- if (string.IsNullOrEmpty(Maintenancer))
- {
- return Error("请选择维修人");
- }
- newmodel.F_Applicant = model.F_Applicant;
- newmodel.F_Applicantsphone = model.F_Applicantsphone;
- newmodel.F_ApplicationDept = string.IsNullOrEmpty(model.F_ApplicationDept) ? "" : model.F_ApplicationDept.Trim();
- newmodel.F_Phone = model.F_Phone;
- newmodel.F_WorkOrderCategory = WorkOrderCategory;
- newmodel.F_Content = Content;
- newmodel.F_PlaceOfRepair = model.F_PlaceOfRepair;
- newmodel.F_Maintenancer = Maintenancer;
- newmodel.F_MaintenanceDept = model.F_MaintenanceDept;
- newmodel.F_AssignTime = DateTime.Now;
- newmodel.F_AssignUser = User.F_UserCode;
- newmodel.F_File = model.F_File;
- List<Model.T_Sys_GongDan> listgd = gdbll.GetModelList(" F_GDId='" + model.F_WorkOrderCategory + "'");
- int timeout = listgd.First().F_TimeOut;
- newmodel.F_Deadline = DateTime.Now.AddHours(timeout);
- newmodel.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.receive;
- newmodel.F_WorkOrderCode = DateTime.Now.ToString("yyyyMMddHHmmssfff");//工单编号
- newmodel.F_CreateTime = DateTime.Now;
- newmodel.F_CreateUser = User.F_UserCode;
- newmodel.F_CreateUserDept = User.F_DeptId.ToString();
- if (baseBll.Add(newmodel) > 0)
- {
- AddAddlog(newmodel.F_WorkOrderCode);
- if (!string.IsNullOrEmpty(Maintenancer))
- {
- AddAssignlog(newmodel.F_WorkOrderCode, model.F_MaintenanceDept, Maintenancer);
- }
- //更新model
- if (!string.IsNullOrEmpty(model.F_InternalWorkOrderCode))
- {
- model.F_InternalWorkOrderCode += "," + newmodel.F_WorkOrderCode;
- }
- else
- {
- model.F_InternalWorkOrderCode = newmodel.F_WorkOrderCode;
- }
- model.F_UpdateTime = DateTime.Now;
- if (model.F_IsStop != 1)
- { model.F_Endtime = DateTime.Now; }
- baseBll.Update(model);
- AddInternalasslog(model.F_WorkOrderCode, newmodel.F_WorkOrderCode);
- return Success("添加成功!");
- }
- else return Error("添加失败!");
- }
- //外协作
- else
- {
- newmodel.F_Applicant = model.F_Applicant;
- newmodel.F_Applicantsphone = model.F_Applicantsphone;
- newmodel.F_ApplicationDept = string.IsNullOrEmpty(model.F_ApplicationDept) ? "" : model.F_ApplicationDept.Trim();
- newmodel.F_Phone = model.F_Phone;
- newmodel.F_WorkOrderCategory = WorkOrderCategory;
- newmodel.F_Content = Content;
- newmodel.F_PlaceOfRepair = model.F_PlaceOfRepair;
- //newmodel.F_Maintenancer = Maintenancer;
- //newmodel.F_MaintenanceDept = model.F_MaintenanceDept;
- newmodel.F_File = model.F_File;
- newmodel.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.neworder;
- newmodel.F_WorkOrderCode = DateTime.Now.ToString("yyyyMMddHHmmssfff");//工单编号
- newmodel.F_CreateTime = DateTime.Now;
- newmodel.F_CreateUser = User.F_UserCode;
- newmodel.F_CreateUserDept = User.F_DeptId.ToString();
- if (baseBll.Add(newmodel) > 0)
- {
- AddOperatorLog("创建了工单", (int)EnumOperatorType.add, newmodel.F_WorkOrderCode);
- //更新原来的工单model
- if (!string.IsNullOrEmpty(model.F_ExternalWorkOrderCode))
- {
- model.F_ExternalWorkOrderCode += "," + newmodel.F_WorkOrderCode;
- }
- else
- {
- model.F_ExternalWorkOrderCode = newmodel.F_WorkOrderCode;
- }
- model.F_UpdateTime = DateTime.Now;
- baseBll.Update(model);
- AddExternalasslog(model.F_WorkOrderCode, newmodel.F_WorkOrderCode);
- return Success("添加成功!");
- }
- else return Error("添加失败!");
- }
- }
- //维修员的列表 待接单 待完成 已完成
- public ActionResult MaintenancerList()
- {
- string sql = " and F_IsDelete=0 ";
- //待接单1 待完成 2 已完成 3
- string strpageindex = RequestString.GetQueryString("page");
- int pageindex = 1;
- string strpagesize = RequestString.GetQueryString("pagesize");
- int pagesize = 10;
- int strstate = RequestString.GetInt("state", -1);
- string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
- string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
- string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
- string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
- string strworkcode = HttpUtility.UrlDecode(RequestString.GetQueryString("workordercode"));
- //当前登录人只能看到当前部门的工单。管理员可以查看所有的工单
- if (User.F_RoleCode != "GLY")
- {
- sql += " and F_MaintenanceDept='" + User.F_DeptId + "'";
- }
- #region 搜索条件
- if (strpageindex.Trim() != "")
- {
- pageindex = Convert.ToInt32(strpageindex);
- }
- if (strpagesize.Trim() != "")
- {
- pagesize = Convert.ToInt32(strpagesize);
- }
- if (strname.Trim() != "" && strname != "undefined")
- {
- sql += " and F_Applicant = '" + strname + "' ";
- }
- if (strtel.Trim() != "" && strtel != "undefined")
- {
- sql += " and (F_Applicantsphone like '%" + strtel + "%' or F_Phone like '%" + strtel + "%') ";
- }
- if (strworkcode.Trim() != "" && strworkcode != "undefined")
- {
- sql += " and F_WorkOrderCode like'%" + strworkcode + "%'";
- }
- if (strstarttime.Trim() != "" && strstarttime != "undefined")
- {
- if (strendtime.Trim() != "" && strendtime != "undefined")
- {
- sql += " and F_CreateTime between '" + strstarttime +
- "' AND '" + strendtime + "'";
- }
- else
- {
- sql += " and F_CreateTime>='" + strstarttime + "' ";
- }
- }
- else
- {
- if (strendtime.Trim() != "" && strendtime != "undefined")
- {
- sql += " and F_CreateTime<='" + strendtime + "' ";
- }
- }
- #endregion
- switch (strstate)
- {
- case 1:
- sql += " and F_WorkOrderState=1";
- break;
- case 2:
- sql += " and (F_WorkOrderState=2 or F_WorkOrderState=6)";
- break;
- case 3:
- sql += " and (F_WorkOrderState>=3 and F_WorkOrderState!=6 )";
- break;
- }
- int recordCount = 0;
- DataTable datatable = Bll.PagerBll.GetListPager
- ("T_FaultRepair_Base ",
- "F_WorkOrderId",
- "*,[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",
- sql,
- "order by F_WorkOrderId desc",
- pagesize,
- pageindex,
- true,
- out recordCount
- );
- datatable = WorkOrderBase.SetOtherField(datatable, MENUENUM.报修列表, User.F_UserCode, User.F_RoleId, 3000);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = datatable,
- total = recordCount
- };
- return Content(obj.ToJson());
- }
- //报修人的列表 已上报 待评价 已完结
- //public ActionResult MyCreateList()
- //{
- // DataTable dt = new DataTable();
- // string sql = " and F_IsDelete=0 and F_CreateUser='" + User.F_UserCode + "'";
- // string strpageindex = RequestString.GetQueryString("page");
- // int pageindex = 1;
- // string strpagesize = RequestString.GetQueryString("pagesize");
- // int pagesize = 10;
- // //待处理传2 已处理传3
- // int strstate = RequestString.GetInt("state", -1);
- // string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
- // string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
- // string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
- // string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
- // string strworkcode = HttpUtility.UrlDecode(RequestString.GetQueryString("workordercode"));
- // #region 搜索条件
- // if (strpageindex.Trim() != "")
- // {
- // pageindex = Convert.ToInt32(strpageindex);
- // }
- // if (strpagesize.Trim() != "")
- // {
- // pagesize = Convert.ToInt32(strpagesize);
- // }
- // if (strname.Trim() != "" && strname != "undefined")
- // {
- // sql += " and F_Applicant = '" + strname + "' ";
- // }
- // if (strtel.Trim() != "" && strtel != "undefined")
- // {
- // sql += " and (F_Applicantsphone like '%" + strtel + "%' or F_Phone like '%" + strtel + "%') ";
- // }
- // if (strworkcode.Trim() != "" && strworkcode != "undefined")
- // {
- // sql += " and F_WorkOrderCode like'%" + strworkcode + "%'";
- // }
- // if (strstarttime.Trim() != "" && strstarttime != "undefined")
- // {
- // if (strendtime.Trim() != "" && strendtime != "undefined")
- // {
- // sql += " and F_CreateTime between '" + strstarttime +
- // "' AND '" + strendtime + "'";
- // }
- // else
- // {
- // sql += " and F_CreateTime>='" + strstarttime + "' ";
- // }
- // }
- // else
- // {
- // if (strendtime.Trim() != "" && strendtime != "undefined")
- // {
- // sql += " and F_CreateTime<='" + strendtime + "' ";
- // }
- // }
- // #endregion
- // //报修人 待处理2 已处理3
- // switch (strstate)
- // {
- // case 2:
- // sql += " and F_WorkOrderState<=3";
- // break;
- // case 3:
- // sql += " and F_WorkOrderState>3";
- // break;
- // }
- // int recordCount = 0;
- // dt = Bll.PagerBll.GetListPager
- // ("T_FaultRepair_Base ",
- // "F_WorkOrderId",
- // "*,[dbo].[GetUserName](F_Maintenancer) Maintenancer,[dbo].[GetUserName](F_Applicant) Applicant",
- // sql,
- // "order by F_WorkOrderId desc",
- // pagesize,
- // pageindex,
- // true,
- // out recordCount
- // );
- // dt.Columns.Add("GapTime", typeof(string));//执行时限
- // dt.Columns.Add("AssistanceState", typeof(string));//协作工单的状态
- // dt.Columns.Add("StateName", typeof(object));//展示的工单状态值
- // dt.Columns.Add("Buttons", typeof(object));//操作按钮
- // foreach (DataRow dr in dt.Rows)
- // {
- // #region 执行时限 不是已完成的工单 展示这个字段
- // if (Convert.ToInt32(dr["F_WorkOrderState"]) < 3)
- // {
- // if (!string.IsNullOrEmpty(dr["F_Deadline"].ToString()))
- // {
- // DateTime deadline = Convert.ToDateTime(dr["F_Deadline"]);
- // TimeSpan ts = deadline.Subtract(DateTime.Now);
- // double tss = double.Parse(Math.Round(ts.TotalSeconds, 0).ToString());
- // if (tss < 0) { tss = -tss; }
- // string gshsj = DateTimeConvert.parseTimeSeconds(tss, 1);
- // if (deadline > DateTime.Now)
- // {
- // dr["GapTime"] = "剩余" + gshsj;
- // }
- // else
- // {
- // dr["GapTime"] = "超时" + gshsj;
- // }
- // }
- // }
- // #endregion
- // #region 展示的工单状态
- // if (Convert.ToInt32(dr["F_WorkOrderState"]) == (int)EnumFaultRepairWorkOrderState.neworder || Convert.ToInt32(dr["F_WorkOrderState"]) == (int)EnumFaultRepairWorkOrderState.receive)
- // {
- // dr["StateName"] = "待接单";
- // }
- // else if (Convert.ToInt32(dr["F_WorkOrderState"]) == (int)EnumFaultRepairWorkOrderState.dealing)
- // {
- // dr["StateName"] = "已接单";
- // }
- // else if (Convert.ToInt32(dr["F_WorkOrderState"]) == (int)EnumFaultRepairWorkOrderState.dealed)
- // {
- // dr["StateName"] = "待评价";
- // }
- // else {
- // dr["StateName"] = "已完成";
- // }
- // #endregion
- // #region 操作按钮
- // var btns = new List<FaultButtonGroup.button>();
- // //待接单 已接单 -自行解决
- // if (Convert.ToInt32(dr["F_WorkOrderState"]) == (int)EnumFaultRepairWorkOrderState.neworder ||
- // Convert.ToInt32(dr["F_WorkOrderState"]) == (int)EnumFaultRepairWorkOrderState.receive ||
- // Convert.ToInt32(dr["F_WorkOrderState"]) == (int)EnumFaultRepairWorkOrderState.dealing
- // )
- // {
- // btns.Add(FaultButtonGroup.solve());
- // }
- // //待评价 评价
- // else if (Convert.ToInt32(dr["F_WorkOrderState"]) == (int)EnumFaultRepairWorkOrderState.dealed)
- // {
- // btns.Add(FaultButtonGroup.evaluate());
- // }
- // else if (Convert.ToInt32(dr["F_WorkOrderState"]) == (int)EnumFaultRepairWorkOrderState.exceptionended ||
- // Convert.ToInt32(dr["F_WorkOrderState"]) == (int)EnumFaultRepairWorkOrderState.finish
- // )
- // {
- // btns.Add(FaultButtonGroup.returndeal());
- // }
- // dr["Buttons"] = btns;
- // #endregion
- // }
- // var obj = new
- // {
- // state = "success",
- // message = "成功",
- // rows = dt,
- // total = recordCount
- // };
- // return Content(obj.ToJson());
- //}
- //工单详情
- public ActionResult GetWorkOrder()
- {
- var configfj = configBll.GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
- string strworkorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("WorkOrderCode"));
- Model.T_FaultRepair_Base model = baseBll.GetModel(strworkorderid);
- int type = RequestString.GetInt("type", 0);//0基本信息1处理结果2协作工单3工单流程4维修记录5评价
- if (!string.IsNullOrEmpty(strworkorderid))
- {
- switch (type)
- {
- case 6:
- 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";
- object dtfx = DbHelperSQL.GetSingle(sqlfx);
- if (dtfx != null && !string.IsNullOrEmpty(dtfx.ToString()))
- {
- return Success("是返修", dtfx.ToString());
- }
- return Success("不是返修");
- case 0:
- //基本信息
- #region
- 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 + "'";
- DataTable dtbase = DbHelperSQL.Query(sql).Tables[0];
- dtbase.Columns.Add("FileUrl", typeof(object));
- dtbase.Columns.Add("StateName");
- dtbase.Columns.Add("TypeName");
- foreach (DataRow dr in dtbase.Rows)
- {
- dr["TypeName"] = "故障报修";
- if (configfj != null && !string.IsNullOrEmpty(dr["F_File"].ToString()))
- {
- dr["FileUrl"] = GetFileData(dr["F_File"].ToString(), configfj.F_ParamValue);
- }
- dr["StateName"] = GetWorkOrderStateStr(User.F_RoleCode, Convert.ToInt32(dr["F_WorkOrderState"]));
-
- }
- return Success("获取成功", dtbase);
- #endregion
- case 1://处理结果
- #region
- 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";
- DataTable dtcl = DbHelperSQL.Query(sqlcl).Tables[0];
- dtcl.Columns.Add("FileUrl", typeof(object));
- dtcl.Columns.Add("Equips", typeof(object));
- foreach (DataRow dr in dtcl.Rows)
- {
- if (configfj != null && !string.IsNullOrEmpty(dr["F_File"].ToString()))
- {
- dr["FileUrl"] = GetFileData(dr["F_File"].ToString(), configfj.F_ParamValue);
- }
- if (!string.IsNullOrEmpty(dr["F_EquipDetail"].ToString()))
- {
- dr["Equips"] = GetEquipsData(dr["F_EquipDetail"].ToString());
- }
- }
- return Success("获取处理结果成功", dtcl);
- #endregion
- case 2://协作工单
- string internalsql = " select F_WorkOrderCode,F_Content,F_MaintenanceDept,F_CreateTime,F_WorkOrderState from T_FaultRepair_Base where F_WorkOrderCode in " +
- "(select col from [dbo].[SplitToNvarchar]('" + model.F_InternalWorkOrderCode + "',',' )) ";
- DataTable internaldt = DbHelperSQL.Query(internalsql).Tables[0];
- string externalsql = " select F_WorkOrderCode,F_Content,F_MaintenanceDept,F_CreateTime,F_WorkOrderState from T_FaultRepair_Base where F_WorkOrderCode in " +
- "(select col from [dbo].[SplitToNvarchar]('" + model.F_ExternalWorkOrderCode + "',',' )) ";
- DataTable externaldt = DbHelperSQL.Query(externalsql).Tables[0];
- if (internaldt != null && internaldt.Rows.Count > 0)
- {
- internaldt.Columns.Add("StateName", typeof(String));
- internaldt.Columns.Add("Mode", typeof(String));
- foreach (DataRow item in internaldt.Rows)
- {
- if (Convert.ToInt32(item["F_WorkOrderState"]) < 3 || Convert.ToInt32(item["F_WorkOrderState"])==6)
- {
- item["StateName"] = "未完成";
- }
- else
- {
- item["StateName"] = "已完成";
- }
- item["Mode"] = "内部协作";
- }
- }
- if (externaldt != null && externaldt.Rows.Count > 0 )
- {
- externaldt.Columns.Add("StateName", typeof(String));
- externaldt.Columns.Add("Mode", typeof(String));
- foreach (DataRow item in externaldt.Rows)
- {
- if (Convert.ToInt32(item["F_WorkOrderState"]) < 3 || Convert.ToInt32(item["F_WorkOrderState"]) == 6)
- {
- item["StateName"] = "未完成";
- }
- else
- {
- item["StateName"] = "已完成";
- }
- item["Mode"] = "外部协作";
- }
- }
- DataTable dtt = new DataTable();
- dtt.Columns.Add("F_WorkOrderCode", typeof(String));
- dtt.Columns.Add("F_Content", typeof(String));
- dtt.Columns.Add("F_MaintenanceDept", typeof(String));
- dtt.Columns.Add("F_WorkOrderState", typeof(String));
- dtt.Columns.Add("F_CreateTime", typeof(DateTime));
- dtt.Columns.Add("StateName", typeof(String));
- dtt.Columns.Add("Mode", typeof(String));
- if (internaldt != null && internaldt.Rows.Count > 0)
- {
- foreach (DataRow row in internaldt.Rows)
- {
- dtt.ImportRow(row);
- }
- }
- if (externaldt != null && externaldt.Rows.Count > 0)
- {
- foreach (DataRow row in externaldt.Rows)
- {
- dtt.ImportRow(row);
- }
- }
- var obj3 = new
- {
- data = dtt,
- };
- return Success("获取协作工单成功", obj3);
- case 3://工单流程
- var sqllog = "select *,[dbo].[GetUserName](F_Operator) username from T_FaultRepair_OperationLog where F_WorkOrderCode = '" + strworkorderid + "' " + " order by F_OperationId desc";
- DataTable dtlog = DbHelperSQL.Query(sqllog).Tables[0];
- return Success("获取工单流程成功", dtlog);
- case 4://维修记录
- 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 + "'";
- DataTable dtcl2 = DbHelperSQL.Query(sqlcl2).Tables[0];
- dtcl2.Columns.Add("Equips", typeof(object));
- dtcl2.Columns.Add("FileUrl", typeof(object));
- foreach (DataRow dr in dtcl2.Rows)
- {
- if (configfj != null && !string.IsNullOrEmpty(dr["F_File"].ToString()))
- {
- dr["FileUrl"] = GetFileData(dr["F_File"].ToString(), configfj.F_ParamValue);
- }
- if (!string.IsNullOrEmpty(dr["F_EquipDetail"].ToString()))
- {
- dr["Equips"] = GetEquipsData(dr["F_EquipDetail"].ToString());
- }
- }
- return Success("获取处理结果成功", dtcl2);
- case 5://评价
- string sqle = "select top 1 * from T_FaultRepair_Evaluate where F_WorkOrderCode='" + strworkorderid + "'" + " order by F_EvaluationTime desc";
- DataTable dte = DbHelperSQL.Query(sqle).Tables[0];
- return Success("获取处理结果成功", dte);
- }
- }
- return Error("没传参数");
- }
- public static string GetWorkOrderStateStr(string userrole, int state)
- {
- List<int> typeIdArray = null;
- typeIdArray = new List<int> { -1, 0, 1, 2, 3, 4, 5, 6 };
- List<string> strArr = null;
- switch (userrole)
- {
- case "DDZX":
- strArr = new List<string> { "-", "待派单", "待查收", "待完成", "已处理", "异常完结", "已完结", "待完成" };
- break;
- case "GLY":
- strArr = new List<string> { "-", "待派单", "待查收", "待完成", "已处理", "异常完结", "已完结", "待完成" };
- break;
- case "WXY":
- strArr = new List<string> { "-", "待接单", "待接单", "待完成", "已完成", "已完成", "已完成", "待完成" };
- break;
- //报修人
- default:
- strArr = new List<string> { "待提交", "待接单", "待接单", "已接单", "待评价", "已完成", "已完成", "已接单" };
- break;
- }
- int index = typeIdArray.IndexOf(state);
- if (index < 0)
- {
- return "";
- }
- return strArr[index];
- }
- //转派 ,派给自己的工单 转给同部门的别的人
- //0 是转同事 1 是转组长
- public ActionResult Transfer(string WorkOrderCode, string ToUserCode, int type = 0)
- {
- Model.T_FaultRepair_Base model = baseBll.GetModel(WorkOrderCode);
- if (model != null && model.F_Maintenancer == User.F_UserCode)
- {
- if (type == 0)
- {
- //转同事
- model.F_Maintenancer = ToUserCode;
- model.F_UpdateTime = DateTime.Now;
- AddOperatorLog("转派工单给" + GetDeptModel(model.F_MaintenanceDept) + "部门" + GetUserModel(ToUserCode), (int)EnumOperatorType.transfer, WorkOrderCode);
- baseBll.Update(model);
- return Success("转派成功");
- }
- else
- {
- //是转组长
- var role = new Bll.T_Sys_Role().GetModelList("F_RoleCode='WXBZZ' and F_State =1");
- var userzz = new Bll.T_Sys_UserAccount().GetModelList("F_DeptId='" + model.F_MaintenanceDept + "' and F_DeleteFlag=0 " +
- "and F_RoleId = '" + role.FirstOrDefault().F_RoleId + "'");
- if (userzz != null && userzz.Count > 0)
- {
- //转同事
- model.F_Maintenancer = userzz.First().F_UserCode;
- model.F_UpdateTime = DateTime.Now;
- AddOperatorLog("转派工单给" + GetDeptModel(model.F_MaintenanceDept) + "部门" + GetUserModel(userzz.First().F_UserCode), (int)EnumOperatorType.transfer, WorkOrderCode);
- baseBll.Update(model);
- return Success("转派成功");
- }
- else
- {
- return Error("没有维修部组长");
- }
- }
- }
- return Error("暂时没有权限操作");
- }
- //调度中心转派
- public ActionResult DDZXTransfer(string WorkOrderCode, string ToUserCode, string ToDept)
- {
- Model.T_FaultRepair_Base model = baseBll.GetModel(WorkOrderCode);
- if (model != null)// && !string.IsNullOrEmpty(ToUserCode) && !string.IsNullOrEmpty(ToDept))
- {
- string mes = "";
- var dicvalue = new Model.T_Sys_GongDan();
- dicvalue = new Bll.T_Sys_GongDan().GetModel(Convert.ToInt32(model.F_WorkOrderCategory));
- if (dicvalue != null)
- {
- mes = ",工单类型:故障报修/" + dicvalue.F_Name;
- }
- model.F_AssignUser = User.F_UserCode;
- model.F_AssignTime = DateTime.Now;
- List<Model.T_Sys_GongDan> listgd = gdbll.GetModelList(" F_GDId='" + model.F_WorkOrderCategory + "'");
- int timeout = listgd.First().F_TimeOut;
- model.F_Deadline = DateTime.Now.AddHours(timeout);
- string message = "";
- //当工单没有选择指派部门的时候,当前工单类型shezhi指派部门,该工单默认到这个指派的部门
- if (string.IsNullOrEmpty(ToDept) || ToDept == "0")
- {
- //根据工单类别判断 是否有指派部门
- List<Model.T_Sys_GongDan> gd = gdbll.GetModelList(" F_GDId='" + model.F_WorkOrderCategory + "'");
- int deptid = listgd.First().F_AutoDept != null ? listgd.First().F_AutoDept.Value : 0;
- if (deptid == 0)
- {
- return Error("当前工单类型没有设置指派部门,请前往设置或者选择指派部门");
- }
- else
- ToDept = deptid.ToString();
- }
- if (!string.IsNullOrEmpty(ToUserCode))
- {
- model.F_Maintenancer = ToUserCode;
- message = "转派工单给" + GetDeptModel(ToDept) + "部门" + GetUserModel(ToUserCode);
- msg.AddInternalMessagesInfo("您有新的工单请及时查收", "您有新的工单请及时查收" + "工单编号:" + model.F_WorkOrderCode + mes, model.F_Maintenancer, User.F_UserCode, EnumSmsType.repair
- , 0, model.F_WorkOrderCode);
- }
- else
- {
- //部门下没有人员不可进行转派
- var usercount = new Bll.T_Sys_UserAccount().GetModelList("F_DeptId='" + ToDept + "' and F_DeleteFlag=0 ");
- if (usercount == null || usercount.Count == 0)
- {
- return Error("当前部门没有人员 ,不可进行转派");
- }
- var user = GetBeOnDuty(ToDept);
- if (user != null && user.Count > 1)
- {
- model.F_Maintenancer = user[0];
- message = "转派工单给" + GetDeptModel(ToDept) + "部门" + GetUserModel(user[0]);
- msg.AddInternalMessagesInfo("您有新的工单请及时查收", "您有新的工单请及时查收" + "工单编号:" + model.F_WorkOrderCode + mes, model.F_Maintenancer, User.F_UserCode, EnumSmsType.repair
- , 0, model.F_WorkOrderCode);
- }
- else
- {
- return Error("请选择指派人员");
- }
- }
- model.F_MaintenanceDept = ToDept;
- model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.receive;
- model.F_UpdateTime = DateTime.Now;
- AddOperatorLog(message, (int)EnumOperatorType.assign, WorkOrderCode);
- baseBll.Update(model);
- return Success("转派成功");
- }
- return Error("暂时没有权限操作");
- }
- /// <summary>
- /// 自动评价
- /// </summary>
- /// <returns></returns>
- [AllowAnonymous]
- public ActionResult Evaluate()
- {
- var dicvalue = new Bll.T_Sys_DictionaryValue().
- GetModelList("F_DictionaryFlag='PJSX' and F_State=1");
- int SX = 2;
- try
- {
- if (dicvalue != null && dicvalue.Count > 0)
- {
- SX = int.Parse(dicvalue.FirstOrDefault().F_Name);
- }
- }
- catch
- {
- SX = 2;
- }
-
- var IntegratedScheduling_Base = new BLL.T_IntegratedScheduling_Base().GetModelList(" F_WorkOrderState=3 and F_IsDelete=0 " +
- "and datediff(minute , F_Endtime , getdate())>'" + SX * 60 + "'");
- if (IntegratedScheduling_Base != null && IntegratedScheduling_Base.Count > 0)
- {
- foreach (var model in IntegratedScheduling_Base)
- {
- Model.T_IntegratedScheduling_Evaluate evamodel = new Model.T_IntegratedScheduling_Evaluate();
- if (model != null)
- {
- evamodel.F_EvaluateContent = SX + "小时未评价自动评价满意";
- // evamodel.F_Quality = 5;
- evamodel.F_Attitude = 5;
- evamodel.F_Efficiency = 5;
- evamodel.F_Evaluator = "";
- evamodel.F_EvaluationTime = DateTime.Now;
- evamodel.F_Isdelete = 0;
- evamodel.F_WorkOrderCode = model.F_WorkOrderCode;
- BLL.T_IntegratedScheduling_Evaluate evabll = new BLL.T_IntegratedScheduling_Evaluate();
- if (evabll.Add(evamodel) > 0)
- {
- model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.finish;
- model.F_UpdateTime = DateTime.Now;
- model.F_Score = 10;
- model.MYD = 0;
- basescheBll.Update(model);
- var conre = DependencyResolver.Current.GetService<SchedulingController>();
- conre.AddOperatorLog("评价了工单", (int)EnumOperatorType.evaluate, model.F_WorkOrderCode);
- }
- else
- continue;
- }
- }
- }
- var FaultRepair_Base = new BLL.T_FaultRepair_Base().GetModelList(" F_WorkOrderState=3 and F_IsDelete=0 " +
- "and datediff(minute , F_Endtime , getdate())>'" + SX * 60 + "'");
- if (FaultRepair_Base != null && FaultRepair_Base.Count > 0)
- {
- foreach (var model in FaultRepair_Base)
- {
- Model.T_FaultRepair_Evaluate evamodel = new Model.T_FaultRepair_Evaluate();
- if (model != null)
- {
- evamodel.F_EvaluateContent = SX + "小时未评价自动评价满意";
- evamodel.F_Quality = 5;
- evamodel.F_Attitude = 5;
- evamodel.F_Efficiency = 5;
- evamodel.F_Evaluator = "";
- evamodel.F_EvaluationTime = DateTime.Now;
- evamodel.F_Isdelete = 0;
- evamodel.F_WorkOrderCode = model.F_WorkOrderCode;
- BLL.T_FaultRepair_Evaluate evabll = new BLL.T_FaultRepair_Evaluate();
- if (evabll.Add(evamodel) > 0)
- {
- model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.finish;
- model.F_UpdateTime = DateTime.Now;
- model.F_Score = 15;
- model.MYD = 0;
- baseBll.Update(model);
- AddEvaluateOperatorLog("评价了工单", (int)EnumOperatorType.evaluate, model.F_WorkOrderCode);
- #region 评价的时候如果有协作工单,协作工单评价数据和主工单保持一致,同时需要记录操作流程
- if (!string.IsNullOrEmpty(model.F_InternalWorkOrderCode))
- {
- string[] codes = model.F_InternalWorkOrderCode.Split(',');
- foreach (string item in codes)
- {
- Model.T_FaultRepair_Evaluate evamodel1 = new Model.T_FaultRepair_Evaluate();
- evamodel1 = evamodel;
- evamodel.F_WorkOrderCode = item;
- evabll.Add(evamodel1);
- AddEvaluateOperatorLog("评价了工单", (int)EnumOperatorType.evaluate, item);
- var intermodel = baseBll.GetModel(item);
- intermodel.F_Score = 15;
- intermodel.MYD = 0;
- baseBll.Update(intermodel);
- }
- }
- if (!string.IsNullOrEmpty(model.F_ExternalWorkOrderCode))
- {
- string[] codes = model.F_ExternalWorkOrderCode.Split(',');
- foreach (string item in codes)
- {
- Model.T_FaultRepair_Evaluate evamodel1 = new Model.T_FaultRepair_Evaluate();
- evamodel1 = evamodel;
- evamodel.F_WorkOrderCode = item;
- evabll.Add(evamodel1);
- AddEvaluateOperatorLog("评价了工单", (int)EnumOperatorType.evaluate, item);
- var extermodel = baseBll.GetModel(item);
- extermodel.F_Score = 15;
- extermodel.MYD = 0;
- baseBll.Update(extermodel);
- }
- }
- #endregion
- }
- else
- continue;
- }
- }
- }
- return Success("评价完成");
- }
- public bool AddEvaluateOperatorLog(string content, int type, string workordercode)
- {
- Model.T_FaultRepair_OperationLog model = new Model.T_FaultRepair_OperationLog();
- model.F_LogContent = content;
- model.F_OperationTime = DateTime.Now;
- model.F_OperationType = type;
- model.F_Operator = "";
- model.F_WorkOrderCode = workordercode;
- logBll.Add(model);
- return true;
- }
- /// <summary>
- /// 自动流转
- /// </summary>
- /// <returns></returns>
- [AllowAnonymous]
- public ActionResult Automatic()
- {
- var dicvalue = new Bll.T_Sys_DictionaryValue().
- GetModelList("F_DictionaryFlag='JDSX' and F_State=1");
- string SX = "10";
- if (dicvalue != null && dicvalue.Count > 0)
- {
- SX = dicvalue.FirstOrDefault().F_Name;
- }
- var FaultRepair_Base = new BLL.T_FaultRepair_Base().GetModelList(" F_WorkOrderState=1 and F_IsDelete=0 " +
- "and datediff(minute , F_AssignTime , getdate())>'" + SX + "'");
- var class1 = new Bll.T_Sys_Class().GetModelList("F_IsDelete=0 and F_IsAutomatic=1 and F_InTime<= getdate() " +
- "and F_OutTime>=getdate() ");
- if (class1!=null && class1.Count >0)
- {
- var GroupClass1 = new Bll.T_Sys_GroupClass().GetModelList($"F_IsDelete=0 and F_ClassCode in(" +
- $"{string.Join(",", class1.Select(x => x.F_Id))}) and datediff(day , F_Date , getdate())= 0 " +
- " order by F_Id asc");
- if (FaultRepair_Base != null && FaultRepair_Base.Count > 0)
- {
- foreach (var model in FaultRepair_Base)
- {
- model.F_AssignTime = DateTime.Now;
- model.F_AssignUser = "系统流转";
- List<Model.T_Sys_GongDan> listgd = gdbll.GetModelList(" F_GDId='" + model.F_WorkOrderCategory + "'");
- int timeout = listgd.First().F_TimeOut;
- model.F_Deadline = DateTime.Now.AddHours(timeout);
- string user = "";
- var GroupClass = GroupClass1.Where(x => x.F_DeptId.ToString() == model.F_MaintenanceDept)
- .OrderBy(x => x.F_Id);
- if (GroupClass != null && GroupClass.Count() > 1)
- {
- var Class = GroupClass.Where(x => x.F_State == 1);
- if (Class != null && Class.Count() > 0)
- {
- var Class1 = GroupClass.Where(x => x.F_State == 0 && x.F_Id > Class.LastOrDefault().F_Id);
- if (Class1 != null && Class1.Count() > 0)
- {
- user = Class1.FirstOrDefault().F_UserCode;
- Class1.FirstOrDefault().F_State = 1;
- new Bll.T_Sys_GroupClass().Update(GroupClass.FirstOrDefault());
- Class.LastOrDefault().F_State = 0;
- new Bll.T_Sys_GroupClass().Update(Class.LastOrDefault());
- }
- else
- {
- user = GroupClass.FirstOrDefault().F_UserCode;
- GroupClass.FirstOrDefault().F_State = 1;
- new Bll.T_Sys_GroupClass().Update(GroupClass.FirstOrDefault());
- Class.LastOrDefault().F_State = 0;
- new Bll.T_Sys_GroupClass().Update(Class.LastOrDefault());
- }
- }
- else
- {
- user = GroupClass.FirstOrDefault().F_UserCode;
- GroupClass.FirstOrDefault().F_State = 1;
- new Bll.T_Sys_GroupClass().Update(GroupClass.FirstOrDefault());
- }
- }
- else
- {
- continue;
- }
- model.F_Maintenancer = user;
- model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.receive;
- model.F_UpdateTime = DateTime.Now;
- AddOperatorLog("超十分钟未接单,自动流转给" + GetDeptModel(model.F_MaintenanceDept) + "部门" + GetUserModel(user), (int)EnumOperatorType.assign, model.F_WorkOrderCode);
- baseBll.Update(model);
- }
- }
- }
-
- return Success("");
- }
- /// <summary>
- /// 获取值班人员
- /// </summary>
- /// <param name="ToDept"></param>
- /// <returns></returns>
- private List<string> GetBeOnDuty(string ToDept)
- {
- List<string> user = new List<string>();
- var role = new Bll.T_Sys_Role().GetModelList("F_RoleCode='WXBZZ' and F_State =1");
- var class1 = new Bll.T_Sys_Class().GetModelList("F_IsDelete=0 and F_IsAutomatic=1 and F_InTime<= getdate() " +
- "and F_OutTime>=getdate() ");
- if (class1!=null && class1.Count >0)
- {
- var GroupClass = new Bll.T_Sys_GroupClass().GetModelList($"F_IsDelete=0 and F_ClassCode in(" +
- $"{string.Join(",", class1.Select(x => x.F_Id))}) and datediff(day , F_Date , getdate())= 0 " +
- "and F_DeptId='" + ToDept + "' order by F_Id asc");
- if (GroupClass != null && GroupClass.Count > 0)
- {
- if (GroupClass.Count == 1)
- {
- user.Add(GroupClass[0].F_UserCode);
- user.Add("有值班人员,自动流转给" + GetDeptModel(ToDept) + "部门" + GetUserModel(GroupClass[0].F_UserCode));
- }
- else
- {
- var Class = GroupClass.Where(x => x.F_State == 1);
- if (Class != null && Class.Count() > 0)
- {
- var Class1 = GroupClass.Where(x => x.F_State == 0 && x.F_Id > Class.LastOrDefault().F_Id);
- if (Class1 != null && Class1.Count() > 0)
- {
- user.Add(Class1.FirstOrDefault().F_UserCode);
- user.Add("有值班人员,自动流转给" + GetDeptModel(ToDept) + "部门" + GetUserModel(Class1.FirstOrDefault().F_UserCode));
- Class1.FirstOrDefault().F_State = 1;
- new Bll.T_Sys_GroupClass().Update(GroupClass[0]);
- Class.LastOrDefault().F_State = 0;
- new Bll.T_Sys_GroupClass().Update(Class.LastOrDefault());
- }
- else
- {
- user.Add(GroupClass[0].F_UserCode);
- user.Add("有值班人员,自动流转给" + GetDeptModel(ToDept) + "部门" + GetUserModel(GroupClass[0].F_UserCode));
- GroupClass[0].F_State = 1;
- new Bll.T_Sys_GroupClass().Update(GroupClass[0]);
- Class.LastOrDefault().F_State = 0;
- new Bll.T_Sys_GroupClass().Update(Class.LastOrDefault());
- }
- }
- else
- {
- user.Add(GroupClass[0].F_UserCode);
- user.Add("有值班人员,自动流转给" + GetDeptModel(ToDept) + "部门" + GetUserModel(GroupClass[0].F_UserCode));
- GroupClass[0].F_State = 1;
- new Bll.T_Sys_GroupClass().Update(GroupClass[0]);
- }
- }
- }
- else
- {
- if (role != null && role.Count > 0)
- {
- var userzz = new Bll.T_Sys_UserAccount().GetModelList("F_DeptId='" + ToDept + "' and F_DeleteFlag=0 " +
- "and F_RoleId = '" + role.FirstOrDefault().F_RoleId + "'");
- if (userzz != null && userzz.Count > 0)
- {
- user.Add(userzz.FirstOrDefault().F_UserCode);
- user.Add("无值班人员,派送给" + GetDeptModel(ToDept) + "部门" + userzz.FirstOrDefault().F_UserName);
- }
- else
- {
- //无值班人员无班组长,随机派送
- var userww = new Bll.T_Sys_UserAccount().GetModelList("F_DeptId='" + ToDept + "' and F_DeleteFlag=0 ");
- user.Add(userww.FirstOrDefault().F_UserCode);
- user.Add("无值班人员无班组长,随机派送给" + GetDeptModel(ToDept) + "部门" + userww.FirstOrDefault().F_UserName);
- }
- }
- }
- }
- else
- {
- if (role != null && role.Count > 0)
- {
- var userzz = new Bll.T_Sys_UserAccount().GetModelList("F_DeptId='" + ToDept + "' and F_DeleteFlag=0 " +
- "and F_RoleId = '" + role.FirstOrDefault().F_RoleId + "'");
- if (userzz != null && userzz.Count > 0)
- {
- user.Add(userzz.FirstOrDefault().F_UserCode);
- user.Add("无值班人员,派送给" + GetDeptModel(ToDept) + "部门" + userzz.FirstOrDefault().F_UserName);
- }
- else
- {
- //无值班人员无班组长,随机派送
- var userww = new Bll.T_Sys_UserAccount().GetModelList("F_DeptId='" + ToDept + "' and F_DeleteFlag=0 ");
- user.Add(userww.FirstOrDefault().F_UserCode);
- user.Add("无值班人员无班组长,随机派送给" + GetDeptModel(ToDept) + "部门" + userww.FirstOrDefault().F_UserName);
- }
- }
- }
- return user;
- }
- //删除工单
- public ActionResult DeleteWorkOrder(string WorkOrderCode)
- {
- Model.T_FaultRepair_Base model = baseBll.GetModel(WorkOrderCode);
- model.F_IsDelete = 1;
- if (baseBll.Update(model))
- {
- AddOperatorLog("删除了工单", (int)EnumOperatorType.delete, WorkOrderCode);
- return Success("删除成功");
- }
- else
- return Error("删除失败");
- }
- // 返修 是申请人提交的返修
- //退回至维修部门班组长(角色),如果没有该角色退回到原来的处理人
- public ActionResult ReturnWorkOrder(string WorkOrderCode, string ReturnReason,int key,string value)
- {
- Model.T_FaultRepair_Base model = baseBll.GetModel(WorkOrderCode);
- string str = "";
- if (!string.IsNullOrEmpty(ReturnReason))
- {
- str = "," + ReturnReason;
- }
- if (model != null && model.F_ApplicationDept.Trim() == User.F_DeptId.ToString())
- {
- //判断返工是不是规定的时间内,工单状态是已完结的工单
- List<Model.T_Sys_GongDan> listgd = gdbll.GetModelList(" F_GDId='" + model.F_WorkOrderCategory + "'");
- int limittime = listgd.First().F_RepairTimeLimit;
- if (model.F_Endtime.Value.AddHours(limittime) >= DateTime.Now)
- {
- Model.T_FaultRepair_Process promodel = new Model.T_FaultRepair_Process();
- promodel.F_Isdelete = 0;
- promodel.F_MaintenanceDept = User.F_DeptId.ToString();// model.F_MaintenanceDept;
- promodel.F_Maintenancer = User.F_UserCode;// model.F_Maintenancer;
- promodel.F_ReturnReason =value+ ReturnReason;
- promodel.F_WorkOrderCode = WorkOrderCode;
- if (dealBll.Add(promodel) > 0)
- {
-
- AddOperatorLogAboutKey("提交了返工,原因:"+value+ str, (int)EnumOperatorType.submitreturn, WorkOrderCode,value,key,ReturnReason);
- 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')";
- string usercode = DbHelperSQL.GetSingle(sql).ToString();
- if (!string.IsNullOrEmpty(usercode))
- {
- model.F_Maintenancer = usercode;
- }
- string s = ",返修原因:" +value+ str;
-
- model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.dealing;
- model.F_ReturnNum += model.F_ReturnNum + 1;
- model.F_UpdateTime = DateTime.Now;
- baseBll.Update(model);
- msg.AddInternalMessagesInfo("您有需要返修的工单,请及时处理", "您有需要返修的工单,请及时处理" + "工单编号:" + model.F_WorkOrderCode+s, model.F_Maintenancer, User.F_UserCode, EnumSmsType.repair
- , 0, model.F_WorkOrderCode);
- return Success("返工成功");
- }
- return Error("返工失败");
- }
- else
- {
- return Error("已超出提交返修期限");
- }
- }
- return Error("暂时没有权限操作");
- }
- //申请人评价
- public ActionResult EvaluateWorkOrder(string WorkOrderCode, string EvaluateContent, int Attitude= 0, int Quality = 0, int Efficiency = 0)
- {
- Model.T_FaultRepair_Base model = baseBll.GetModel(WorkOrderCode);
- Model.T_FaultRepair_Evaluate evamodel = new Model.T_FaultRepair_Evaluate();
- if (model != null)
- {
- if (model.F_ApplicationDept.Trim() == User.F_DeptId.ToString())
- {
- evamodel.F_EvaluateContent = EvaluateContent;
- evamodel.F_Quality = Quality;
- evamodel.F_Attitude = Attitude;
- evamodel.F_Efficiency = Efficiency;
- evamodel.F_Evaluator = User.F_UserCode;
- evamodel.F_EvaluationTime = DateTime.Now;
- evamodel.F_Isdelete = 0;
- evamodel.F_WorkOrderCode = WorkOrderCode;
- BLL.T_FaultRepair_Evaluate evabll = new BLL.T_FaultRepair_Evaluate();
- if (evabll.Add(evamodel) > 0)
- {
- model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.finish;
- model.F_UpdateTime = DateTime.Now;
- //评价=自动确认耗材
- model.F_ConfirmEquip = 2;
- model.F_Score = Attitude + Quality + Efficiency;
- AddOperatorLog("评价了工单", (int)EnumOperatorType.evaluate, model.F_WorkOrderCode);
- if (Attitude < 3 || Quality < 3 || Efficiency < 3)
- {
- model.MYD = 2;
- msg.AddInternalMessagesInfo("您有工单被差评", "您有工单被差评" + "工单编号:" + model.F_WorkOrderCode + "差评原因:" + EvaluateContent, model.F_Maintenancer, User.F_UserCode, EnumSmsType.repair
- , 0, model.F_WorkOrderCode);
- }
- else if (Attitude == 3 || Quality == 3 || Efficiency == 3)
- {
- model.MYD = 1;
- }
- else
- {
- model.MYD = 0;
- }
- baseBll.Update(model);
- #region 评价的时候如果有协作工单,协作工单评价数据和主工单保持一致,同时需要记录操作流程
- if (!string.IsNullOrEmpty(model.F_InternalWorkOrderCode))
- {
- string[] codes = model.F_InternalWorkOrderCode.Split(',');
- foreach (string item in codes)
- {
- var intermodel = baseBll.GetModel(item);
- Model.T_FaultRepair_Evaluate evamodel1 = new Model.T_FaultRepair_Evaluate();
- evamodel1 = evamodel;
- evamodel.F_WorkOrderCode = item;
- evabll.Add(evamodel1);
- if (Attitude < 3 || Quality < 3 || Efficiency < 3)
- {
- intermodel.MYD = 2;
- msg.AddInternalMessagesInfo("您有工单被差评", "您有工单被差评" + "工单编号:" + item + "差评原因:" + EvaluateContent, intermodel.F_Maintenancer, User.F_UserCode, EnumSmsType.repair
- , 0, item);
- }
- else if (Attitude == 3 || Quality == 3 || Efficiency == 3)
- {
- model.MYD = 1;
- }
- else
- {
- model.MYD = 0;
- }
- intermodel.F_Score = Attitude + Quality + Efficiency;
- baseBll.Update(intermodel);
-
- AddOperatorLog("评价了工单", (int)EnumOperatorType.evaluate, item);
- }
- }
- if (!string.IsNullOrEmpty(model.F_ExternalWorkOrderCode))
- {
- string[] codes = model.F_ExternalWorkOrderCode.Split(',');
- foreach (string item in codes)
- {
- var extmodel = baseBll.GetModel(item);
- Model.T_FaultRepair_Evaluate evamodel1 = new Model.T_FaultRepair_Evaluate();
- evamodel1 = evamodel;
- evamodel.F_WorkOrderCode = item;
- evabll.Add(evamodel1);
- if (Attitude < 3 || Quality < 3 || Efficiency < 3)
- {
- extmodel.MYD = 2;
- msg.AddInternalMessagesInfo("您有工单被差评", "您有工单被差评" + "工单编号:" + item + "差评原因:" + EvaluateContent, extmodel.F_Maintenancer, User.F_UserCode, EnumSmsType.repair
- , 0, item);
- }
- else if (Attitude == 3 || Quality == 3 || Efficiency == 3)
- {
- model.MYD = 1;
- }
- else
- {
- model.MYD = 0;
- }
- extmodel.F_Score = Attitude + Quality + Efficiency;
- baseBll.Update(extmodel);
- AddOperatorLog("评价了工单", (int)EnumOperatorType.evaluate, item);
- }
- }
- #endregion
- return Success("评价成功");
- }
- return Error("评价失败");
- }
- else
- {
- return Error("没有权限评价");
- }
- }
- return Error("评价失败");
- }
- /// <summary>
- /// 获取枚举值的描述属性
- /// </summary>
- /// <param name="enumValue"></param>
- /// <returns></returns>
- private string GetEnumDescription(Enum enumValue)
- {
- string value = enumValue.ToString();
- FieldInfo field = enumValue.GetType().GetField(value);
- object[] objs = field.GetCustomAttributes(typeof(DescriptionAttribute), false); //获取描述属性
- if (objs == null || objs.Length == 0) //当描述属性没有时,直接返回名称
- return value;
- DescriptionAttribute descriptionAttribute = (DescriptionAttribute)objs[0];
- return descriptionAttribute.Description;
- }
- #region 添加操作记录
- public bool AddOperatorLogNew(string content, int type, string workordercode,string usercode)
- {
- Model.T_FaultRepair_OperationLog model = new Model.T_FaultRepair_OperationLog();
- model.F_LogContent = content;
- model.F_OperationTime = DateTime.Now;
- model.F_OperationType = type;
- model.F_Operator = usercode;
- model.F_WorkOrderCode = workordercode;
- logBll.Add(model);
- return true;
- }
- public bool AddOperatorLog(string content, int type, string workordercode)
- {
- Model.T_FaultRepair_OperationLog model = new Model.T_FaultRepair_OperationLog();
- model.F_LogContent = content;
- model.F_OperationTime = DateTime.Now;
- model.F_OperationType = type;
- model.F_Operator = User.F_UserCode;
- model.F_WorkOrderCode = workordercode;
- logBll.Add(model);
- return true;
- }
- public bool AddOperatorLogAboutKey(string content, int type, string workordercode,string value,int key,string enterreason)
- {
- Model.T_FaultRepair_OperationLog model = new Model.T_FaultRepair_OperationLog();
- model.F_LogContent = content;
- model.F_OperationTime = DateTime.Now;
- model.F_OperationType = type;
- model.F_Operator = User.F_UserCode;
- model.F_WorkOrderCode = workordercode;
- model.F_AboutKey = key;
- model.F_AboutReason = value;
- model.F_EnterReason = enterreason;
- logBll.Add(model);
- return true;
- }
- public void AddAddlog(string workordercode)
- {
- AddOperatorLog("创建报修工单", (int)EnumOperatorType.add, workordercode);
- }
- public void AddAssignlog(string workordercode, string dept, string maintenancer)
- {
- AddOperatorLog("指派工单给" + GetDeptModel(dept) + "部门" + GetUserModel(maintenancer), (int)EnumOperatorType.assign, workordercode);
- }
- public void AddInternalasslog(string workordercode, string newworkordercode)
- {
- AddOperatorLog("创建内协作工单" + newworkordercode, (int)EnumOperatorType.internalassistance, workordercode);
- }
- public void AddExternalasslog(string workordercode, string newworkordercode)
- {
- AddOperatorLog("创建外协作工单" + newworkordercode, (int)EnumOperatorType.externalassistance, workordercode);
- }
- [AllowAnonymous]
- public bool AddAutoAssignlog(string workordercode, string dept, string maintenancer)
- {
- Model.T_FaultRepair_OperationLog model = new Model.T_FaultRepair_OperationLog();
- model.F_LogContent = "超过十分钟未接单,自动指派工单给" + GetDeptModel(dept) + "部门" + GetUserModel(maintenancer);
- model.F_OperationTime = DateTime.Now;
- model.F_OperationType = (int)EnumOperatorType.assign;
- model.F_Operator = "";
- model.F_WorkOrderCode = workordercode;
- logBll.Add(model);
- return true;
- }
-
- #endregion
- public string GetDeptModel(string deptId = "")
- {
- string sql = " 1=1 ";
- if (!string.IsNullOrWhiteSpace(deptId))
- {
- sql += " and F_DeptId='" + deptId + "'";
- }
- if (string.IsNullOrWhiteSpace(sql))
- return "";
- var role = departmentBLL.GetModelList(sql).FirstOrDefault();
- string name = role.F_DeptName;
- return name;
- }
- public string GetUserModel(string usercode = "")
- {
- string sql = " 1=1 ";
- if (!string.IsNullOrWhiteSpace(usercode))
- {
- sql += " and F_UserCode='" + usercode + "'";
- }
- if (string.IsNullOrEmpty(usercode))
- return "";
- Model.T_Sys_UserAccount ua = new Bll.T_Sys_UserAccount().GetModelList(sql).FirstOrDefault();
- if (ua != null)
- {
- return ua.F_UserName;
- }
- return "";
- }
- //故障报修综合报表
- public ActionResult ExportList()
- {
- string sql = " and F_IsDelete=0 ";
- int isexport = RequestString.GetInt("isexport", -1);
- string strpageindex = RequestString.GetQueryString("page");
- int pageindex = 1;
- string strpagesize = RequestString.GetQueryString("pagesize");
- int pagesize = 10;
- //创建时间 报修人 工单类别 工单状态 维修人 调度人
- string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
- string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
- int category = RequestString.GetInt("category", -1);
- int strstate = RequestString.GetInt("state", -1);
- string applicant = HttpUtility.UrlDecode(RequestString.GetQueryString("applicant"));
- string maintenancer = HttpUtility.UrlDecode(RequestString.GetQueryString("maintenancer"));
- string createuser = HttpUtility.UrlDecode(RequestString.GetQueryString("createuser"));
- Bll.T_Sys_UserAccount blluser = new Bll.T_Sys_UserAccount();
- List<Model.T_Sys_UserAccount> listuser = blluser.GetModelList("F_DeleteFlag=0");
- if (!string.IsNullOrEmpty(createuser))
- {
- try
- {
- int usercode = Convert.ToInt32(createuser);
- sql += " and F_AssignUser='" + usercode + "'";
- }
- catch (Exception)
- {
- Model.T_Sys_UserAccount model = listuser.Find(x => x.F_UserName == createuser);
- if (model != null)
- {
- sql += " and F_AssignUser='" + model.F_UserCode + "'";
- }
- }
- }
- if (!string.IsNullOrEmpty(maintenancer))
- {
- try
- {
- int usercode = Convert.ToInt32(maintenancer);
- sql += " and F_Maintenancer='" + usercode + "'";
- }
- catch (Exception)
- {
- Model.T_Sys_UserAccount model = listuser.Find(x => x.F_UserName == maintenancer);
- if (model != null)
- {
- sql += " and F_Maintenancer='" + model.F_UserCode + "'";
- }
- }
- }
- if (!string.IsNullOrEmpty(applicant))
- {
- try
- {
- int usercode = Convert.ToInt32(applicant);
- sql += " and F_Applicant='" + usercode + "'";
- }
- catch (Exception)
- {
- Model.T_Sys_UserAccount model = listuser.Find(x => x.F_UserName == applicant);
- if (model != null)
- {
- sql += " and F_Applicant='" + model.F_UserCode + "'";
- }
- }
- }
- #region 搜索条件
- if (strpageindex.Trim() != "")
- {
- pageindex = Convert.ToInt32(strpageindex);
- }
- if (strpagesize.Trim() != "")
- {
- pagesize = Convert.ToInt32(strpagesize);
- }
- if (strstarttime.Trim() != "" && strstarttime != "undefined")
- {
- if (strendtime.Trim() != "" && strendtime != "undefined")
- {
- sql += " and F_CreateTime between '" + strstarttime +
- "' AND '" + strendtime + "'";
- }
- else
- {
- sql += " and F_CreateTime>='" + strstarttime + "' ";
- }
- }
- else
- {
- if (strendtime.Trim() != "" && strendtime != "undefined")
- {
- sql += " and F_CreateTime<='" + strendtime + "' ";
- }
- }
- #endregion
- if (strstate > 0)
- {
- sql += " and F_WorkOrderState='" + strstate + "'";
- }
- if (category > 0)
- {
- sql += " and F_WorkOrderCategory='" + category + "'";
- }
- int recordCount = 0;
- if (isexport == 1)
- {
- //执行时限 服务评价
- 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;
- var dtdc = DbHelperSQL.Query(exportsql).Tables[0];
- var msg = new NPOIHelper().ExportToExcel("故障报修综合报表", dtdc);
- if (msg == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- DataTable datatable = Bll.PagerBll.GetListPager
- ("T_FaultRepair_Base ",
- "F_WorkOrderId",
- "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",
- sql,
- "order by F_WorkOrderId desc",
- pagesize,
- pageindex,
- true,
- out recordCount
- );
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = datatable,
- total = recordCount
- };
- return Content(obj.ToJson());
- }
- //挂起
- public ActionResult HangUp(string workordercode, int key, string value, string reason)
- {
- Model.T_FaultRepair_Base model = baseBll.GetModel(workordercode);
- if (model != null && model.F_WorkOrderState != 2 && model.F_WorkOrderState != 6)
- {
- return Error("挂起失败");
- }
- model.F_IsStop = 1;
- model.F_StopTime = DateTime.Now;
- model.F_Endtime = DateTime.Now;
- baseBll.Update(model);
- string str = "";
- if (!string.IsNullOrEmpty(reason))
- {
- str = "," + reason;
- }
- AddOperatorLogAboutKey(User.F_UserCode + "挂起了工单,原因:"+value+ str, (int)EnumOperatorType.hangup, model.F_WorkOrderCode,value,key, reason);
- return Success("挂起成功");
- }
- //到达操作 arrive
- public ActionResult Arrive(string workordercode)
- {
- Model.T_FaultRepair_Base model = baseBll.GetModel(workordercode);
- if (model == null)
- {
- return Error("没有获取到工单号");
- }
- model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.arrive;
- model.F_ArriveTime = DateTime.Now;
- baseBll.Update(model);
- AddOperatorLog(User.F_UserName + "已到达", (int)EnumOperatorType.arrive, model.F_WorkOrderCode);
- return Success("到达操作成功");
- }
- //调度中心 退回到提交人(工单状态gai为“待提交”)
- public ActionResult ReBack(string workordercode, string BackReason)
- {
- Model.T_FaultRepair_Base model = baseBll.GetModel(workordercode);
- if (model == null)
- {
- return Error("没有获取到工单号");
- }
- model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.waitsubmit;
- string s = "";
- if (!string.IsNullOrEmpty(BackReason))
- {
- s += ",退回原因:" + BackReason;
- }
- baseBll.Update(model);
- msg.AddInternalMessagesInfo("您有工单被退回", "您有工单被退回" + "工单编号:" + model.F_WorkOrderCode+s, model.F_Applicant
- , User.F_UserCode, EnumSmsType.repair
- , 0, model.F_WorkOrderCode);
- AddOperatorLog(User.F_UserName + "退回了工单"+s, (int)EnumOperatorType.reback, model.F_WorkOrderCode);
- return Success("退回操作成功");
- }
-
- // 撤回(已指派未接单的可进行撤回,工单状态为“新工单0”)
- public ActionResult Retract(string workordercode, string BackReason)
- {
- Model.T_FaultRepair_Base model = baseBll.GetModel(workordercode);
- if (model == null)
- {
- return Error("没有获取到工单号");
- }
- string s = "";
- if (!string.IsNullOrEmpty(BackReason))
- {
- s += ",撤回原因:" + BackReason;
- }
- model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.neworder;
- model.F_Maintenancer = "";
- model.F_MaintenanceDept = "";
- model.F_AssignTime = null;
- model.F_AssignUser = "";
- model.F_UpdateTime = DateTime.Now;
- model.F_Deadline = null;
- baseBll.Update(model);
- ////催办次数改成0
- //BLL.T_Wo_CommonBase wcbll = new BLL.T_Wo_CommonBase();
- //Model.T_Wo_CommonBase wcmodel = wcbll.GetModel(workordercode);
- //wcmodel.F_UrgeCount = 0;
- //wcmodel.F_UpdateTime = DateTime.Now;
- //wcbll.Update(wcmodel);
- AddOperatorLog(User.F_UserName + "撤回了工单"+s, (int)EnumOperatorType.retract, model.F_WorkOrderCode);
- return Success("撤回操作成功");
- }
- //综合保障中心里 指派(撤回之后可重新转派),同时需要记录操作流程
- public ActionResult Assign(string workordercode, string maintenancer, string maintenanceDept)
- {
- Model.T_FaultRepair_Base model = baseBll.GetModel(workordercode);
- if (model == null)
- {
- return Error("没有获取到工单号");
- }
- if (!string.IsNullOrEmpty(maintenanceDept))
- {
- model.F_AssignTime = DateTime.Now;
- model.F_AssignUser = User.F_UserCode;
- List<Model.T_Sys_GongDan> listgd = gdbll.GetModelList(" F_GDId='" + model.F_WorkOrderCategory + "'");
- int timeout = listgd.First().F_TimeOut;
- model.F_Deadline = DateTime.Now.AddHours(timeout);
- model.F_MaintenanceDept = maintenanceDept;
- if (!string.IsNullOrEmpty(maintenancer))
- model.F_Maintenancer = maintenancer;
- else
- {
- var user = GetBeOnDuty(maintenancer);
- if (user != null && user.Count > 1)
- {
- model.F_Maintenancer = user[0];
- }
- else
- {
- return Error("请选择指派人员");
- }
- }
- model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.receive;
- }
- baseBll.Update(model);
- AddAssignlog(model.F_WorkOrderCode, maintenanceDept, maintenancer);
- return Success("指派操作成功");
- }
- #region 我的提交页面的操作
- //申请人撤回(未指派的工单可撤回,工单状态“待提交”)
- public ActionResult MyRetract(string workordercode,string BackReason)
- {
- Model.T_FaultRepair_Base model = baseBll.GetModel(workordercode);
- if (model == null)
- {
- return Error("没有获取到工单号");
- }
- if (model.F_WorkOrderState == 0)
- {
- string s = "";
- if (!string.IsNullOrEmpty(BackReason))
- {
- s += ",撤回原因:" + BackReason;
- }
- model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.waitsubmit;
- baseBll.Update(model);
- AddOperatorLog(User.F_UserName + "撤回了工单"+s, (int)EnumOperatorType.myretract, model.F_WorkOrderCode);
- return Success("撤回操作成功");
- }
- else
- {
- return Error("不能撤回");
- }
- }
- //我的提交里编辑工单
- /// <summary>
- ///编辑
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public ActionResult MyUpdateFaultRepairWorkOrder(T_FaultRepairBaseinput input)
- {
- Model.T_FaultRepair_Base model = baseBll.GetModel(input.WorkOrderCode);
- model.F_WorkOrderCategory = input.WorkOrderCategory;
- model.F_Content = input.Content;
- model.F_PlaceOfRepair = input.PlaceOfRepair;
- model.F_File = input.File;
- model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.neworder;
- model.F_UpdateTime = DateTime.Now;
- if (baseBll.Update(model))
- {
- AddOperatorLog(User.F_UserName + "编辑了工单", (int)EnumOperatorType.update, model.F_WorkOrderCode);
- return Success("编辑成功!");
- }
- else return Error("编辑失败!");
- }
- #endregion
- //延期
- //接单人在接单之后,如果该工单类型上设置的“可延期次数”大于0显示“延期”按钮;点击延期按钮进行验证是否超过设定的延期次数,超过提醒“已超过规定延迟次数”
- //操作流程记录延期
- public ActionResult frReplay(string workordercode, string days, string type, string workordercategory,string reason,int key, string value)
- {
- Model.T_Sys_GongDan gdmodel = gdbll.GetModel(Convert.ToInt32(workordercategory));
- Model.T_Wo_CommonBase model = cbbll.GetModel(workordercode);
- if (!string.IsNullOrEmpty(reason))
- {
- reason = "," + reason;
- }
- string strreason = ",原因:"+value+ reason;
-
- if (gdmodel.F_CanReplayCount > 0)
- {
- if (gdmodel.F_CanReplayCount >= model.F_ReplayCount + 1)
- {
- //业务咨询流程延期
- if (type == "1000")
- {
- Model.T_Con_WorkOrder cwmodel = cwbll.GetModelByCode(workordercode);
- cwmodel.F_ReplayCount = cwmodel.F_ReplayCount + 1;
- cwbll.Update(cwmodel);
-
- 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);
- }
- //故障报工单延期修
- if (type == "3000")
- {
- Model.T_FaultRepair_Base fbmodel = baseBll.GetModel(workordercode);
- fbmodel.F_ReplayCount = fbmodel.F_ReplayCount + 1;
- baseBll.Update(fbmodel);
- AddOperatorLog("给工单延期" + days+"h"+ strreason, (int)EnumOperatorType.replay, workordercode);
- }
- return Success("成功延期");
- }
- else
- {
- return Error("已超过规定延迟次数");
- }
- }
- return Error("工单类型设置的可延期次数为0");
- }
- /// <summary>
- /// 申请人确认耗材
- /// </summary>
- /// <returns></returns>
- public ActionResult ConfirmEquips(string workordercode,int confirmtype,string reason)
- {
- Model.T_FaultRepair_Base model = baseBll.GetModel(workordercode);
- if (confirmtype == 0)
- {
- string logs = "";
- if (!string.IsNullOrEmpty(reason)) {
- logs = ",原因:" + reason;
- }
- model.F_ConfirmEquip = 0;
- model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.dealing;
- AddOperatorLog("耗材确认有误"+logs, (int)EnumOperatorType.confirm, workordercode);
- }
- else
- {
- model.F_ConfirmEquip = 2;
- AddOperatorLog("确认耗材无误", (int)EnumOperatorType.confirm, workordercode);
- }
- baseBll.Update(model);
- return Success("确认耗材接口");
- }
- //发送超时未接单的消
- //20222031更正为:即将超时 距离截止日期还有十分钟 还未接单的发消息给组长
- public ActionResult AutoSendOverTimeMsg()
- {
- 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";
- DataTable dt = DbHelperSQL.Query(sql).Tables[0];
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow item in dt.Rows)
- {
- //根据处理部门获取班组长 WXBZZ
- 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];
- if (dtuser != null && dtuser.Rows.Count > 0)
- {
- string message = "";
- var dicvalue = new Model.T_Sys_GongDan();
- dicvalue = new Bll.T_Sys_GongDan().GetModel(Convert.ToInt32(item["F_WorkOrderCategory"].ToString()));
- if (dicvalue != null)
- {
- message = ",工单类型:故障报修/" + dicvalue.F_Name;
- }
- message += ",报修科室:" + GetParentDeptName(Convert.ToInt32( item["F_ApplicationDept"].ToString()));
- message += ",工单内容:" + item["F_Content"].ToString();
- message += ",相关人员:" + GetUserModel(item["F_Maintenancer"].ToString());
- msg.AddInternalMessagesInfo("您部门下有工单即将超时未接单", "您部门下有工单即将超时未接单" + "工单编号:" + item["F_WorkOrderCode"].ToString(), dtuser.Rows[0]["F_usercode"].ToString(), User.F_UserCode, EnumSmsType.repair
- , 0, item["F_WorkOrderCode"].ToString());
- }
- }
- }
- return Success("发送超时未接单的消息成功");
- }
-
- StringBuilder returnname = new StringBuilder();
-
- [AllowAnonymous]
-
- public string GetParentDeptName(int deptid)
- {
- var model = departmentBLL.GetModel(deptid);
- if (model != null)
- {
- returnname.Insert(0, model.F_DeptName);
- returnname.Insert(0, "/");
- if (model.F_ParentId != 0)
- {
- GetParentDeptName(model.F_ParentId.Value);
- }
- if (model.F_ParentId == 0)
- {
- string sql = " select T_Woname from T_Wowo_repairyq where T_Woid='" + model.T_Woid + "'";
- string yqname= DbHelperSQL.GetSingle(sql).ToString();
- returnname.Insert(0, yqname);
- }
- }
- return returnname.ToString();
- }
- /// <summary>
- /// 基建后勤类型,10分钟内未接单转派给基建和后勤保障部的值班人员(根据排班表)
- /// </summary>
- /// <returns></returns>
- public ActionResult AutoChangeDealMan()
- {
- string sql = " select F_GDId from T_Sys_GongDan where F_Name='基建后勤类'";
- int gdid =Convert.ToInt32( DbHelperSQL.GetSingle(sql));
-
- if (gdid > 0)
- {
- 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 + "'))";
- DataTable dt = DbHelperSQL.Query(allgd).Tables[0];
- if (dt != null && dt.Rows.Count > 0)
- {
- string sqldept = " select F_DeptId from T_Sys_Department where F_DeptCode='HQBZ'";
- int deptid = Convert.ToInt32(DbHelperSQL.GetSingle(sqldept));
- List<Model.T_Sys_GroupClass> modellist = new List<Model.T_Sys_GroupClass>();
- if (deptid > 0)
- {
- 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 + "')");
- }
- foreach (DataRow item in dt.Rows)
- {
- Model.T_FaultRepair_Base frmodel= baseBll.GetModel(item["F_WorkOrderCode"].ToString());
- if (modellist.Count > 0)
- {
- var shaixuanlist = modellist.Where(x => x.F_UserCode != frmodel.F_Maintenancer).ToList();
- if (shaixuanlist.Count > 0)
- {
- frmodel.F_AssignTime = DateTime.Now;
- frmodel.F_Maintenancer = shaixuanlist.First().F_UserCode;
- frmodel.F_MaintenanceDept = deptid.ToString();
- baseBll.Update(frmodel);
- AddAutoAssignlog(item["F_WorkOrderCode"].ToString(), deptid.ToString(), frmodel.F_Maintenancer);
- }
- }
- }
- }
- return Success("执行成功");
- }
- return Error("基建后勤类型不存在");
- }
- }
- }
|