123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783 |
- using Ant.Service.Common;
- using Ant.Service.Common.Enums;
- using Central.Control.Domain;
- using MES.Production.Entity;
- using MES.Production.Service.IService;
- using MES.Production.Service.ServiceImp;
- using ChangFa.Machinery.WebPage.Controllers;
- using Ant.Data;
- using Ant.ORM;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using MongoDB.Driver.Builders;
- using Ant.Service.Mongodb;
- using System.Text;
- using System.Net;
- using Newtonsoft.Json.Linq;
- using Newtonsoft.Json;
- using Ant.Service.Utility;
- using Ant.SuperSocket.Common;
- using MES.Production.Entity.Enum;
- using System.IO;
- using System.Diagnostics;
- using System.Data;
- using MES.Production.Entity.Entity;
- using JsonHelper = Ant.Service.Common.JsonHelper;
- using JsonConverter = Ant.Service.Common.JsonConverter;
- using WebApiHelp = Ant.Service.Common.WebApiHelp;
- using YW_CarParamDetails = Central.Control.Domain.YW_CarParamDetails;
- using YW_UserCar = Central.Control.Domain.YW_UserCar;
- using YW_CarPurchaser = Central.Control.Domain.YW_CarPurchaser;
- namespace ChangFa.Machinery.WebPage.Areas.SysManage.Controllers
- {
- public class CarController : BaseController
- {
- /// <summary>
- /// 字典编码
- /// </summary>
- ICodeManage CodeManage = new CodeManage();
- /// <summary>
- /// 经销商
- /// </summary>
- IDepartmentManage DepartmentManage = new DepartmentManage();
- /// <summary>
- /// 加载列表
- /// </summary>
- /// <returns></returns>
- [UserAuthorizeAttribute(ModuleAlias = "carList", OperaAction = "View")]
- public ActionResult Index()
- {
- try
- {
- #region 处理查询参数
- string posttype = Request.QueryString["posttype"];
- string FK_DPTID = Request.QueryString["FK_DPTID"];
- string CarSate = Request.QueryString["CarSate"];
- string carType = Request.QueryString["LeaseStatus"];
- int state = -1;
- if (!CarSate.IsEmpty())
- {
- state = CarSate.ToInt32();
- }
- #endregion
- #region 加载列表
- var result = BindList(carType.ToInt32(), FK_DPTID, state);
- ViewBag.Search = base.keywords;
- // ViewData["PostType"] = this.CodeManage.GetCode("POSTTYPE");
- //ViewData["post"] = posttype;
- ViewData["levels"] = this.CodeManage.LoadAll(p => p.CODETYPE == "CLLB").OrderBy(p => p.SHOWORDER).ToList();
- ViewData["Department"] = this.DepartmentManage.GetDepartmentByDetailNew();
- ViewData["dptid"] = FK_DPTID;
- ViewData["CarSate"] = CarSate;
- ViewData["cartype"] = this.CodeManage.LoadAll(p => p.CODETYPE == "XMLX").ToList();
- ViewData["typecar"] = carType;
- #endregion
- if (result.IsNull())
- {
- return View();
- }
- else
- {
- return View(result);
- }
- }
- catch (Exception e)
- {
- WriteLog(enumOperator.Select, "加载岗位列表:", e);
- throw e.InnerException;
- }
- }
- /// <summary>
- /// 导出申请审核数据
- /// </summary>
- /// <returns></returns>
- public FileResult CarReturnOutExcel()
- {
- try
- {
- NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook();
- //添加一个sheet
- NPOI.SS.UserModel.ISheet sheet1 = book.CreateSheet("Sheet1");
- //给sheet1添加第一行的头部标题
- NPOI.SS.UserModel.IRow row1 = sheet1.CreateRow(0);
- row1.CreateCell(0).SetCellValue("农机IMEI号");
- row1.CreateCell(1).SetCellValue("农机名称");
- row1.CreateCell(2).SetCellValue("农机型号");
- row1.CreateCell(3).SetCellValue("车架号");
- row1.CreateCell(4).SetCellValue("出厂日期");
- row1.CreateCell(5).SetCellValue("出厂编号");
- row1.CreateCell(6).SetCellValue("所属经销商");
- row1.CreateCell(7).SetCellValue("调拨后经销商");
- row1.CreateCell(8).SetCellValue("申请类型");
- row1.CreateCell(9).SetCellValue("申请人");
- row1.CreateCell(10).SetCellValue("申请时间");
- row1.CreateCell(11).SetCellValue("审核状态");
- #region 加载列表
- List<CarReturnModel> carlist = new List<CarReturnModel>();
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel();
- res.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取用户车辆信息" };
- var usercarlist = orm.Queryable<yw_machinery_return>()
- .InnerJoin<EntYW_Bicycle>((user, city) => user.carid == city.CarID);
- var views = usercarlist.Select((strip, sbicycle) => new { Users = sbicycle, trip = strip });
- views = views.Where(p => p.Users.CarID != "" && p.trip.state == 1);
- var reslut = views.OrderBy(p => p.trip.state).ToList(res);
- if (reslut.IsSuccess)
- {
- int i = 0;
- foreach (var list in reslut.ResultModel)
- {
- yw_machinery_return mod = list.trip; EntYW_Bicycle carmod = list.Users; //Entity.YW_CarPurchaser purchser = list.userpurch;
- i++;
- NPOI.SS.UserModel.IRow rowtemp = sheet1.CreateRow(i);
- rowtemp.CreateCell(0).SetCellValue(carmod.CarID);
- rowtemp.CreateCell(1).SetCellValue(carmod.CarName);
- rowtemp.CreateCell(2).SetCellValue(carmod.CarModel);
- rowtemp.CreateCell(3).SetCellValue(carmod.carBar);
- rowtemp.CreateCell(4).SetCellValue(carmod.productionDate.ToString());
- rowtemp.CreateCell(5).SetCellValue(carmod.FactoryNumber);
- rowtemp.CreateCell(6).SetCellValue(carmod.DistributorsName);
- rowtemp.CreateCell(7).SetCellValue(mod.distributorsName);
- var applytype = "";
- if (mod.apply_type == 1)
- {
- applytype = "退货申请";
- }
- if (mod.apply_type == 2)
- {
- applytype = "返厂申请";
- }
- if (mod.apply_type == 3)
- {
- applytype = "调拨申请";
- }
- rowtemp.CreateCell(8).SetCellValue(applytype);
- rowtemp.CreateCell(9).SetCellValue(mod.add_name);
- rowtemp.CreateCell(10).SetCellValue(mod.add_time.ToString());
- var strstate = "";
- if (mod.state == 0)
- {
- strstate = "未审核";
- }
- if (mod.state == 1)
- {
- strstate = "已通过";
- }
- if (mod.state == 2)
- {
- strstate = "未通过";
- }
- rowtemp.CreateCell(11).SetCellValue(strstate);
- }
- }
- }
- #endregion
- // 写入到客户端
- System.IO.MemoryStream ms = new System.IO.MemoryStream();
- book.Write(ms);
- ms.Seek(0, SeekOrigin.Begin);
- return File(ms, "application/vnd.ms-excel", "农机申请审核.xls");
- }
- catch (Exception e)
- {
- throw e.InnerException;
- }
- }
- /// <summary>
- /// 加载列表
- /// </summary>
- /// <returns></returns>
- [UserAuthorizeAttribute(ModuleAlias = "carReturn", OperaAction = "View")]
- public ActionResult CarReturnList()
- {
- try
- {
- PageInfo pageInfo = new PageInfo(base.page, base.pagesize, 0, Ant.Service.Common.JsonConverter.JsonClass(new List<EntYW_Bicycle>()));
- #region 处理查询参数
- var posttype = Request.QueryString["PostType"];
- string FK_DPTID = Request.QueryString["FK_DPTID"];
- int carType = Request.QueryString["LeaseStatus"].ToInt32();
- string CarSate = Request.QueryString["CarSate"];
- string barcode = Request.QueryString["txt_barcode"];
- string imei = Request.QueryString["txt_imei"];
- string factoryNumber = Request.QueryString["txt_factoryNumber"];
- int state = -1;
- if (!CarSate.IsEmpty())
- {
- state = CarSate.ToInt32();
- }
- #endregion
- #region 加载列表
- List<CarReturnModel> carlist = new List<CarReturnModel>();
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel();
- res.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取用户车辆信息" };
- var usercarlist = orm.Queryable<yw_machinery_return>()
- .InnerJoin<EntYW_Bicycle>((user, city) => user.carid == city.CarID);
- // .InnerJoin<Entity.YW_CarPurchaser>((user, city, province) => city.CarID == province.carId);
- int pageno = (base.page - 1) * base.pagesize;
- var views = usercarlist.Select((strip, sbicycle) => new { Users = sbicycle, trip = strip });
- if (posttype != "-1" && !posttype.IsEmpty())
- {
- var type = posttype.ToInt32();
- views = views.Where(p => p.trip.apply_type == type);
- }
- if (state > 0)
- {
- views = views.Where(p => p.Users.CarSate == state);
- }
- if (!factoryNumber.IsEmpty())
- {
- views = views.Where(p => p.Users.FactoryNumber.Contains(factoryNumber));
- }
- if (!imei.IsEmpty())
- {
- views = views.Where(p => p.Users.CarID.Contains(imei));
- }
- views = views.Where(p => p.Users.CarID != "");
- var reslut = views.OrderBy(p => p.trip.state).ThenByDesc(p => p.trip.add_time).Skip(pageno).Top(pagesize).ToList(res);
- //.Where(p => p.Users.UserId == usermod.userInfo.uid)
- if (reslut.IsSuccess)
- {
- reslut.RecordNum = views.Count();
- foreach (var list in reslut.ResultModel)
- {
- CarReturnModel carReturn = new CarReturnModel();
- yw_machinery_return mod = list.trip; EntYW_Bicycle carmod = list.Users; //Entity.YW_CarPurchaser purchser = list.userpurch;
- carReturn.bicycle = carmod;
- carReturn.carreturn = mod;
- carlist.Add(carReturn);
- }
- pageInfo = new PageInfo(base.page, base.pagesize, reslut.RecordNum, JsonConverter.JsonClass(carlist));
- }
- }
- ViewBag.Search = base.keywords;
- ViewData["levels"] = this.CodeManage.LoadAll(p => p.CODETYPE == "CLLB").OrderBy(p => p.SHOWORDER).ToList();
- ViewData["Department"] = this.DepartmentManage.GetDepartmentByDetailNew();
- ViewData["dptid"] = FK_DPTID;
- ViewData["CarSate"] = CarSate;
- ViewData["PostType"] = posttype;
- ViewData["cartype"] = this.CodeManage.LoadAll(p => p.CODETYPE == "XMLX").ToList();
- ViewData["typecar"] = carType;
- ViewData["levels"] = this.CodeManage.LoadAll(p => p.CODETYPE == "CLLB").OrderBy(p => p.SHOWORDER).ToList();
- //ViewData["levels"] = this.CodeManage.LoadAll(p => p.CODETYPE == "CLLB").ToList();
- ViewData["factoryNumber"] = factoryNumber;
- ViewBag.Search = base.keywords;
- ViewData["barcode"] = barcode;
- ViewData["imei"] = imei;
- return View(pageInfo);
- #endregion
- }
- catch (Exception e)
- {
- WriteLog(enumOperator.Select, "加载岗位列表:", e);
- throw e.InnerException;
- }
- }
- /// <summary>
- /// 解除电子围栏
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public ActionResult LiftedCarFence(string idList)
- {
- Ant.Service.Common.JsonHelper json = new Ant.Service.Common.JsonHelper() { Status = "n", Msg = "解除围栏成功" };
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel request = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "查询菜单的单个实体方法" }
- };
- string id = idList.Split(';')[0]; string carid = idList.Split(';')[1];
- int carstate = CarState.Sales.ToInt32(); Guid guid = new Guid(id);
- var reslut = orm.UpdateByLambda<EntYW_Bicycle>(p => new EntYW_Bicycle { CarSate = carstate }, f => f.ID == guid, request);
- if (reslut.IsSuccess)
- {
- json.Status = "y";
- WriteLog(enumOperator.Remove, "解除围栏:" + json.Msg, enumLog4net.WARN);
- try
- {
- //SocketClient client = new SocketClient();
- //var str = DataHelper.sendRemoveFence(Convert.ToInt64(carid));
- //var body = DataHelper.HexToByte(str);
- //string ip = System.Web.Configuration.WebConfigurationManager.AppSettings["ip"].ToString();
- //int port = System.Web.Configuration.WebConfigurationManager.AppSettings["port"].ToInt32();
- //client.Connect(ip, port);
- //var flag = client.SendData(body);
- //client.Disconnect();
- }
- catch (Exception ex)
- {
- }
- }
- }
- return Json(json);
- }
- /// <summary>
- /// 删除农机
- /// </summary>
- /// <param name="idList">编码ID字符串</param>
- public ActionResult Delete(string idList)
- {
- Ant.Service.Common.JsonHelper json = new JsonHelper() { Status = "n", Msg = "删除农机成功" };
- try
- {
- //是否为空
- if (string.IsNullOrEmpty(idList)) { json.Msg = "未找到要删除的农机"; return Json(json); }
- string[] id = idList.Trim(',').Split(',');
- for (int i = 0; i < id.Length; i++)
- {
- var userId = (id[i]);
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel request = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "查询菜单的单个实体方法" },
- Oid = userId.ToString()
- };
- var reslut = orm.DeleteById<EntYW_Bicycle>(request);
- if (reslut.IsSuccess)
- {
- json.Status = "y";
- WriteLog(enumOperator.Remove, "删除农机:" + json.Msg, enumLog4net.WARN);
- }
- }
- }
- }
- catch (Exception e)
- {
- json.Msg = "删除农机发生内部错误!";
- WriteLog(enumOperator.Remove, "删除农机:", e);
- }
- return Json(json);
- }
- /// <summary>
- /// 加载列表
- /// </summary>
- /// <returns></returns>
- [UserAuthorizeAttribute(ModuleAlias = "carReturn", OperaAction = "View")]
- public ActionResult CarReturnFactory()
- {
- try
- {
- PageInfo pageInfo = new PageInfo(base.page, base.pagesize, 0, JsonConverter.JsonClass(new List<EntYW_Bicycle>()));
- #region 处理查询参数
- string posttype = Request.QueryString["posttype"];
- string FK_DPTID = Request.QueryString["FK_DPTID"];
- string CarSate = Request.QueryString["CarSate"];
- int state = -1;
- if (!CarSate.IsEmpty())
- {
- state = CarSate.ToInt32();
- }
- #endregion
- #region 加载列表
- List<CarReturnModel> carlist = new List<CarReturnModel>();
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel();
- res.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取用户车辆信息" };
- var resultList = new ResponseApplyCarList();
- resultList.resultList = new List<ResponseApplyCar>();
- var usercarlist = orm.Queryable<yw_machinery_return>()
- .InnerJoin<EntYW_Bicycle>((user, city) => user.carid == city.CarID)
- .InnerJoin<YW_CarPurchaser>((user, city, province) => city.CarID == province.carId);
- int pageno = (base.page - 1) * base.pagesize;
- var views = usercarlist.Select((strip, sbicycle, purchser) => new { Users = sbicycle, trip = strip, userpurch = purchser }).Where(f => f.trip.apply_type == 2).OrderByDesc(p => p.Users.ID).ToList(res);
- //.Where(p => p.Users.UserId == usermod.userInfo.uid)
- if (views.IsSuccess)
- {
- foreach (var list in views.ResultModel)
- {
- CarReturnModel carReturn = new CarReturnModel();
- yw_machinery_return mod = list.trip; EntYW_Bicycle carmod = list.Users; YW_CarPurchaser purchser = list.userpurch;
- carReturn.bicycle = carmod;
- carReturn.carreturn = mod;
- carlist.Add(carReturn);
- }
- pageInfo = new PageInfo(base.page, base.pagesize, views.RecordNum, JsonConverter.JsonClass(carlist));
- }
- }
- ViewBag.Search = base.keywords;
- ViewData["levels"] = this.CodeManage.LoadAll(p => p.CODETYPE == "CLLB").ToList();
- ViewData["Department"] = this.DepartmentManage.GetDepartmentByDetail();
- ViewData["dptid"] = FK_DPTID;
- ViewData["CarSate"] = CarSate;
- return View(pageInfo);
- #endregion
- }
- catch (Exception e)
- {
- WriteLog(enumOperator.Select, "加载岗位列表:", e);
- throw e.InnerException;
- }
- }
- public ActionResult CarAllocate(string id)
- {
- ResponseApplyCarInfo userCar = new ResponseApplyCarInfo();
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel();
- res.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取用户车辆信息" };
- Guid carid = new Guid(id);
- var reslut = orm.Queryable<EntYW_Bicycle>().Where(p => p.ID == carid).FirstOrDefault(res);
- if (reslut.IsSuccess)
- {
- EntYW_Bicycle carmod = reslut.ResultModel; //Entity.YW_CarPurchaser purchser = views.ResultModel.userpurch;
- userCar.imei = carmod.CarID;
- userCar.apply_id = carmod.ID.ToString();
- userCar.productBarCode = carmod.carBar;
- userCar.productModel = carmod.CarModel;
- userCar.productName = carmod.CarName;
- userCar.carType = carmod.carType.ToInt32();
- userCar.orgDistributorsName = carmod.DistributorsName;
- userCar.carState = GetCarState.getCarStateStr(carmod.CarSate.ToInt32());
- userCar.FactoryNumber = carmod.FactoryNumber;
- userCar.isOnLine = carmod.LeaseStatus.ToInt32();
- }
- }
- int uid = 0;
- if (CurrentUser.USERTYPE == 2)
- {
- uid = CurrentUser.Id;
- }
- ViewBag.dpt = this.DepartmentManage.GetDepartmentByDetailNew(uid);
- return View(userCar);
- }
- /// <summary>
- /// 保存审核结果
- /// </summary>
- /// <returns></returns>
- public ActionResult SaveApplyCheck(string apply_id)
- {
- JsonHelper json = new JsonHelper() { Msg = "农机申请审核成功", Status = "n", ReUrl = "/Car/DistributorCarList" };
- var notes = Request["notes"];
- var state = Request["checkstate"];
- if (state == "1")
- {
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel();
- res.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取用户车辆信息" };
- Guid guid = new Guid(apply_id);
- var reslut = orm.Queryable<yw_machinery_return>().Where(p => p.id == guid).FirstOrDefault(res);
- if (reslut.IsSuccess)
- {
- yw_machinery_return mod = reslut.ResultModel;
- if (mod.apply_type == 1)//退货
- {
- int carstate = CarState.Storage.ToInt32();
- var reslutcar = orm.UpdateByLambda<EntYW_Bicycle>(p => new EntYW_Bicycle { CarSate = carstate }, f => f.CarID == mod.carid, res);
- {
- var reslutapply = orm.UpdateByLambda<yw_machinery_return>(p => new yw_machinery_return { state = 1, check_time = DateTime.Now }, f => f.id == mod.id, res);
- if (reslutapply.IsSuccess)
- {
- json.Status = "y";
- json.Msg = "退货审核通过";
- }
- var usersalereslut = orm.DeleteByLambda<MES.Production.Entity.YW_CarPurchaser>(p => p.imei == mod.carid, res);
- if (usersalereslut.IsSuccess)
- {
- }
- var userbindreslut = orm.DeleteByLambda<MES.Production.Entity.YW_UserCar>(p => p.carId == mod.carid, res);
- if (userbindreslut.IsSuccess)
- {
- }
- var alarmreslut = orm.DeleteByLambda<YW_AlarmInformation>(p => p.CarId == mod.carid, res);
- if (alarmreslut.IsSuccess)
- {
- }
- }
- }
- if (mod.apply_type == 2)//返厂
- {
- int carstate = CarState.carBind.ToInt32();
- var reslutcar = orm.UpdateByLambda<EntYW_Bicycle>(p => new EntYW_Bicycle { CarSate = carstate, DistributorsID = "", DistributorsName = "" }, f => f.CarID == mod.carid, res);
- {
- var reslutapply = orm.UpdateByLambda<yw_machinery_return>(p => new yw_machinery_return { state = 1 }, f => f.id == mod.id, res);
- if (reslutapply.IsSuccess)
- {
- json.Status = "y";
- json.Msg = "返厂审核通过";
- }
- var usersalereslut = orm.DeleteByLambda<MES.Production.Entity.YW_CarPurchaser>(p => p.imei == mod.carid, res);
- if (usersalereslut.IsSuccess)
- {
- }
- var userbindreslut = orm.DeleteByLambda<MES.Production.Entity.YW_UserCar>(p => p.carId == mod.carid, res);
- if (userbindreslut.IsSuccess)
- {
- }
- var alarmreslut = orm.DeleteByLambda<YW_AlarmInformation>(p => p.CarId == mod.carid, res);
- if (alarmreslut.IsSuccess)
- {
- }
- }
- }
- if (mod.apply_type == 3)//调拨
- {
- int carstate = CarState.OutStock.ToInt32();
- var reslutcar = orm.UpdateByLambda<EntYW_Bicycle>(p => new EntYW_Bicycle { CarSate = carstate, DistributorsID = mod.distributorsID, DistributorsName = mod.distributorsName }, f => f.CarID == mod.carid, res);
- {
- var reslutapply = orm.UpdateByLambda<yw_machinery_return>(p => new yw_machinery_return { state = 1 }, f => f.id == mod.id, res);
- if (reslutapply.IsSuccess)
- {
- json.Status = "y";
- json.Msg = "调拨审核通过";
- }
- var usersalereslut = orm.DeleteByLambda<MES.Production.Entity.YW_CarPurchaser>(p => p.imei == mod.carid, res);
- if (usersalereslut.IsSuccess)
- {
- }
- var userbindreslut = orm.DeleteByLambda<MES.Production.Entity.YW_UserCar>(p => p.carId == mod.carid, res);
- if (userbindreslut.IsSuccess)
- {
- }
- var alarmreslut = orm.DeleteByLambda<YW_AlarmInformation>(p => p.CarId == mod.carid, res);
- if (alarmreslut.IsSuccess)
- {
- }
- }
- }
- if (mod.apply_type == 4)
- {
- //var str = DataHelper.sendLockHexStr(Convert.ToInt64(mod.carid.Trim()));
- //var body = DataHelper.HexToByte(str);
- //SocketClient client = new SocketClient();
- //try
- //{
- // string ip = System.Web.Configuration.WebConfigurationManager.AppSettings["ip"].ToString();
- // int port = System.Web.Configuration.WebConfigurationManager.AppSettings["port"].ToInt32();
- // client.Connect(ip, port);
- // var flag = client.SendData(body);
- // var reslutlock = orm.UpdateByLambda<YW_Apply_CarLock>(p => new YW_Apply_CarLock { state = 2 }, f => f.carid == mod.carid && f.state == 0, res);
- // if (reslutlock.IsSuccess)
- // {
- // }
- // var reslutapply = orm.UpdateByLambda<yw_machinery_return>(p => new yw_machinery_return { state = 1 }, f => f.id == mod.id, res);
- // if (reslutapply.IsSuccess)
- // {
- // json.Status = "y";
- // json.Msg = "审核通过";
- // }
- // client.Disconnect();
- //}
- //catch (Exception ex)
- //{
- //}
- }
- if (mod.apply_type == 5)
- {
- //var str = DataHelper.sendUnLockHexStr(Convert.ToInt64(mod.carid.Trim()));
- //var body = DataHelper.HexToByte(str);
- //SocketClient client = new SocketClient();
- //try
- //{
- // string ip = System.Web.Configuration.WebConfigurationManager.AppSettings["ip"].ToString();
- // int port = System.Web.Configuration.WebConfigurationManager.AppSettings["port"].ToInt32();
- // client.Connect(ip, port);
- // var flag = client.SendData(body);
- // var reslutlock = orm.UpdateByLambda<YW_Apply_CarLock>(p => new YW_Apply_CarLock { state = 2 }, f => f.carid == mod.carid && f.state == 0, res);
- // if (reslutlock.IsSuccess)
- // {
- // }
- // var reslutapply = orm.UpdateByLambda<yw_machinery_return>(p => new yw_machinery_return { state = 1 }, f => f.id == mod.id, res);
- // if (reslutapply.IsSuccess)
- // {
- // json.Status = "y";
- // json.Msg = "审核通过";
- // }
- // client.Disconnect();
- //}
- //catch (Exception ex)
- //{
- //}
- }
- }
- }
- }
- else
- {
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel();
- res.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取用户车辆信息" };
- Guid guid = new Guid(apply_id);
- var reslutapply = orm.UpdateByLambda<yw_machinery_return>(p => new yw_machinery_return { state = 2, noPassNote = notes }, f => f.id == guid, res);
- if (reslutapply.IsSuccess)
- {
- var reslutmod = orm.Queryable<yw_machinery_return>().Where(p => p.id == guid).FirstOrDefault(res);
- if (reslutmod.IsSuccess)
- {
- yw_machinery_return mod = reslutmod.ResultModel;
- orm.UpdateByLambda<EntYW_Bicycle>(p => new EntYW_Bicycle { CarSate = mod.carState }, f => f.CarID == mod.carid, res);
- json.Status = "n";
- json.Msg = "审核不通过";
- }
- }
- }
- }
- return Json(json);
- }
- /// <summary>
- /// 保存调拨数据
- /// </summary>
- /// <param name="info"></param>
- /// <returns></returns>
- public ActionResult SaveCarAllocate(ResponseApplyCarInfo info)
- {
- JsonHelper json = new JsonHelper() { Msg = "农机申请成功", Status = "n", ReUrl = "/Car/DistributorCarList" };
- var applytype = Request["apply_type"].ToInt32();
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel();
- res.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取用户车辆信息" };
- Guid carid = new Guid(info.apply_id);
- var reslut = orm.Queryable<EntYW_Bicycle>().Where(p => p.ID == carid).FirstOrDefault(res);
- if (reslut.IsSuccess)
- {
- EntYW_Bicycle carmod = reslut.ResultModel;
- if (carmod.CarSate > 40 && applytype == 3)
- {
- json.Msg = "已销售无法做调拨!";
- return Json(json);
- }
- if (applytype == 4)//锁车
- {
- if (carmod.LockState.ToBool())
- {
- json.Msg = "已锁车,不能重复申请锁车操作!";
- return Json(json);
- }
- var count = orm.Queryable<yw_machinery_return>().Where(p => p.carid == carmod.CarID && p.state == 0).Count();
- if (count > 0)
- {
- json.Msg = "已申请锁车,不能重复申请锁车,等待审核!";
- return Json(json);
- }
- }
- if (applytype == 5)//解锁
- {
- if (!carmod.LockState.ToBool())
- {
- json.Msg = "已解锁,不能重复申请!";
- return Json(json);
- }
- var count = orm.Queryable<yw_machinery_return>().Where(p => p.carid == carmod.CarID && p.state == 0).Count();
- if (count > 0)
- {
- json.Msg = "已申请解锁,不能重复申请解锁,等待审核!";
- return Json(json);
- }
- }
- SYS_USER usermod = new SYS_USER();
- EntSYS_DISTRIBUTORS dis = new EntSYS_DISTRIBUTORS();
- //var qq = orm.Queryable<EntSYS_DISTRIBUTORS>().LeftJoin<SYS_USER>((diss, us) => diss.ID == us.DPTID);
- //var views = qq.Select((disname, userinfo) => new { DisName = disname, UserInfo = userinfo }).OrderByDesc(p => p.DisName.ID).Where(p => p.DisName.ID == info.distributorsId).FirstOrDefault(res);
- //if (views.IsSuccess)
- //{
- // dis = views.ResultModel.DisName; usermod = views.ResultModel.UserInfo;
- //}
- yw_machinery_return mod = new yw_machinery_return();
- mod.id = Guid.NewGuid();
- mod.carid = carmod.CarID;
- mod.note = Request["notes"];//申请原因
- if (applytype == 0)
- {
- json.Msg = "申请类型不能为空!";
- return Json(json);
- }
- if (applytype == 1)//退货
- {
- }
- if (applytype == 2)//返厂
- {
- }
- if (applytype == 3)//调拨
- {
- var str = string.Empty;
- if (info.note == "10")
- {
- str = "一级商到一级商(有调拨手续)";
- }
- if (info.note == "20")
- {
- str = "一级商到一级商(无调拨手续)";
- }
- if (info.note == "30")
- {
- str = "一级经销商内部调拨";
- }
- if (info.note == "40")
- {
- str = "其它";
- }
- if (str.IsEmpty())
- {
- json.Msg = "调拨申请调拨原因不能为空!";
- return Json(json);
- }
- if (info.distributorsId.IsEmpty())
- {
- json.Msg = "调拨申请经销商不能为空!选择调拨经销商!";
- return Json(json);
- }
- var qq = orm.Queryable<EntSYS_DISTRIBUTORS>().Where(p => p.ID == info.distributorsId).FirstOrDefault(res);
- dis = qq.ResultModel;
- mod.reason = str;
- mod.distributorsID = info.distributorsId;
- mod.distributorsName = dis.NAME;
- mod.distributorsContact = dis.BUSINESSLEVEL.ToString();
- }
- mod.distributorsContact = usermod.NAME;
- mod.distributorsTel = usermod.PHONE;
- mod.carState = mod.carState;
- mod.apply_type = Request["apply_type"].ToInt32();
- mod.orgDistributorsID = carmod.DistributorsID;
- mod.orgDistributorsName = carmod.DistributorsName;
- mod.add_name = CurrentUser.Name;
- mod.add_time = DateTime.Now;
- mod.userId = CurrentUser.Id.ToString();
- var reslutmachinery = orm.Save(mod, res);
- if (reslutmachinery.IsSuccess)
- {
- json.Status = "y";
- //var reslutcar = orm.UpdateByLambda<EntYW_Bicycle>(p => new EntYW_Bicycle { DistributorsID = info.distributorsId, DistributorsName = dis.NAME }, f => f.CarID == mod.carid, res);
- //if (reslutcar.IsSuccess)
- //{
- // json.Status = "y";
- //}
- //else
- //{
- // json.Msg = "保存失败"; ;
- //}
- }
- else
- {
- json.Msg = "保存失败";
- }
- }
- }
- return Json(json);
- }
- /// <summary>
- /// 车辆调拨
- /// </summary>
- /// <returns></returns>
- public ActionResult CarAllocation(string id)
- {
- ResponseApplyCarInfo userCar = new ResponseApplyCarInfo();
- try
- {
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel();
- res.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取用户车辆信息" };
- var usercarlist = orm.Queryable<yw_machinery_return>()
- .InnerJoin<EntYW_Bicycle>((user, city) => user.carid == city.CarID);
- //.InnerJoin<Entity.YW_CarPurchaser>((user, city, province) => city.CarID == province.carId);
- Guid guid = new Guid(id);
- //var views = usercarlist.Select((strip, sbicycle, purchser) => new { Users = sbicycle, trip = strip, userpurch = purchser }).Where(p => p.trip.id == guid).FirstOrDefault(res);
- var views = usercarlist.Select((strip, sbicycle) => new { Users = sbicycle, trip = strip }).Where(p => p.trip.id == guid).FirstOrDefault(res);
- //.Where(p => p.Users.UserId == usermod.userInfo.uid)
- if (views.IsSuccess)
- {
- yw_machinery_return mod = views.ResultModel.trip; EntYW_Bicycle carmod = views.ResultModel.Users; //Entity.YW_CarPurchaser purchser = views.ResultModel.userpurch;
- userCar.imei = carmod.CarID;
- userCar.productBarCode = carmod.carBar;
- userCar.productModel = carmod.CarModel;
- userCar.productName = carmod.CarName;
- userCar.FactoryNumber = carmod.FactoryNumber;
- userCar.apply_type = mod.apply_type.ToString();
- userCar.apply_state = mod.state.ToString();
- userCar.carType = carmod.carType.ToInt32();
- userCar.orgDistributorsID = mod.orgDistributorsID;
- userCar.orgDistributorsName = mod.orgDistributorsName;
- var purrchreslut = orm.Queryable<MES.Production.Entity.YW_CarPurchaser>().Where(p => p.carId == carmod.CarID).FirstOrDefault(res);
- if (purrchreslut.IsSuccess)
- {
- MES.Production.Entity.YW_CarPurchaser purchser = purrchreslut.ResultModel;
- userCar.name = purchser.userName;
- userCar.tel = purchser.userTel;
- userCar.saleDate = purchser.addDate.ToDateTime();
- }
- userCar.note = mod.note;
- userCar.reason = mod.reason;
- userCar.applyName = mod.add_name;
- userCar.apply_id = mod.id.ToString();
- userCar.carState = GetCarState.getCarStateStr(carmod.CarSate.ToInt32());
- userCar.isOnLine = carmod.LeaseStatus.ToInt32();
- if (mod.apply_type == 3)
- {
- var distributorsreslut = orm.Queryable<EntSYS_DISTRIBUTORS>().Where(p => p.ID == mod.distributorsID).FirstOrDefault(res);
- if (distributorsreslut.IsSuccess)
- {
- EntSYS_DISTRIBUTORS dismod = distributorsreslut.ResultModel;
- userCar.distributorsAddress = dismod.Address;
- userCar.distributorsName = dismod.NAME;
- userCar.distributorsContact = "";
- userCar.distributorsTel = "";
- }
- }
- //userCar.productionDate = DateTimeUtility.ConvertDateTimeInt(carmod.productionDate.ToDateTime());
- }
- }
- return View(userCar);
- }
- catch (Exception e)
- {
- WriteLog(enumOperator.Select, "加载岗位列表:", e);
- throw e.InnerException;
- }
- }
- /// <returns></returns>
- public ActionResult atouCarMapList()
- {
- ViewData["provincecode"] = Request["provincecode"];
- ViewData["strprovince"] = Request["strprovince"];
- ViewData["strcode"] = Request["strcode"];
- ViewData["strname"] = Request["strname"];
- return View();
- }
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- [UserAuthorizeAttribute(ModuleAlias = "mapList", OperaAction = "View")]
- public ActionResult mapList()
- {
- ViewData["provincecode"] = Request["provincecode"];
- ViewData["strprovince"] = Request["strprovince"];
- ViewData["strcode"] = Request["strcode"];
- ViewData["strname"] = Request["strname"];
- return View();
- }
- public ActionResult CarParamList(string id)
- {
- PageInfo pageInfo = new PageInfo(base.page, base.pagesize, 0, JsonConverter.JsonClass(new List<EntYW_Bicycle>()));
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取车辆信息" }
- };
- var q = orm.Queryable<MES.Production.Entity.YW_CarParamDetails>();
- if (id.IsEmpty())
- {
- return View(pageInfo);
- }
- q = q.Where(p => p.imei == id);
- int pageno = (page - 1) * pagesize;
- var tripreslut = q.OrderByDesc(p => p.add_time).Skip(pageno).Top(pagesize).ToList(res);
- if (tripreslut.IsSuccess)
- {
- tripreslut.RecordNum = q.Count();
- pageInfo = new PageInfo(base.page, base.pagesize, tripreslut.RecordNum, JsonConverter.JsonClass(tripreslut.ResultModel));
- }
- }
- return View(pageInfo);
- }
- [UserAuthorizeAttribute(ModuleAlias = "machineryList", OperaAction = "List")]
- public ActionResult CarTripList(string id)
- {
- PageInfo pageInfo = new PageInfo(base.page, base.pagesize, 0,JsonConverter.JsonClass(new List<Ent_YW_CarTrip>()));
- var startdate = Request.Params["startdate"]; var enddate = Request.Params["enddate"];
- using (AntORM orm = new AntORM())
- {
- int pageno = (page - 1) * pagesize;
- StringBuilder strsql = new StringBuilder();
- strsql.AppendFormat("SELECT top {0} [T].[ID] AS [ID],[T].[IMEI] AS [IMEI],[T].[StartDate] AS [StartDate],[T].[EndDate] AS [EndDate],[T].[WorkingHours] AS [WorkingHours] ,t.num,t.total FROM (", pagesize);
- strsql.AppendFormat("SELECT[YW_CarTrip].[ID] AS[ID],[YW_CarTrip].[IMEI] AS[IMEI],[YW_CarTrip].[StartDate] AS[StartDate],[YW_CarTrip].[EndDate] AS[EndDate],[YW_CarTrip].[WorkingHours] AS[WorkingHours],");
- strsql.AppendFormat("ROW_NUMBER() OVER(ORDER BY[YW_CarTrip].[StartDate] DESC) AS num,count(1) over() as total FROM [YW_CarTrip] AS[YW_CarTrip] WHERE [YW_CarTrip].[IMEI] = '{0}'", id);
- if (!startdate.IsEmpty() && enddate.IsEmpty())
- {
- var fromdate = startdate.ToDateTime();
- strsql.AppendFormat("[YW_CarTrip].[StartDate]={0}", fromdate);
- }
- if (!enddate.IsEmpty() && startdate.IsEmpty())
- {
- var todate = enddate.ToDateTime();
- strsql.AppendFormat("[YW_CarTrip].[StartDate]={0}", todate);
- }
- if (!startdate.IsEmpty() && !enddate.IsEmpty())
- {
- var fromdate = startdate.ToDateTime();
- var todate = enddate.ToDateTime();
- strsql.AppendFormat(" and ([YW_CarTrip].[StartDate]>'{0}' and [YW_CarTrip].[StartDate]<'{1}') ", fromdate, todate);
- }
- strsql.AppendFormat(") AS[T] WHERE [T].num > {0} order by num asc", pageno);
- RequestItemSqlModel requestItemSql = new RequestItemSqlModel();
- requestItemSql.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取农机行程列表" };
- requestItemSql.db = DataAccessFactory.CreateDataConnection("CyclingItemLog");
- requestItemSql.StrSql = strsql.ToString();
- var tripreslut = orm.GetDataTableList(requestItemSql);
- if (tripreslut.IsSuccess)
- {
- DataTable dtt = tripreslut.DataTable;
- tripreslut.RecordNum = dtt.Rows[0]["total"].ToInt32();
- var jsondata = JsonConverter.ConvertJson(JsonConverter.ToJson(dtt));
- pageInfo = new PageInfo(base.page, base.pagesize, tripreslut.RecordNum, jsondata);
- }
- }
- ViewData["startdate"] = startdate;
- ViewData["enddate"] = enddate;
- ViewData["imei"] = id;
- return View(pageInfo);
- }
- /// <summary>
- /// 生成定位信息JSON文件
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public JsonResult salesMakeMapJsonFile()
- {
- string lat = ""; string lng = ""; string onlinetime = "";
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取车辆信息" }
- };
- var carreslut = orm.Queryable<EntYW_Bicycle>().Where(p => p.CarSate == 1).ToList(res);
- if (carreslut.IsSuccess)
- {
- List<CarGPSModel> carlist = new List<CarGPSModel>();
- foreach (EntYW_Bicycle mod in carreslut.ResultModel)
- {
- CarGPSModel car = new CarGPSModel();
- car.imei = mod.CarID;
- car.barCode = mod.carBar;
- var reslut = orm.Queryable<YW_CarHeartbeat>().Where(p => p.imei == mod.CarID && p.locationtype == 2).OrderByDesc(p => p.add_time).FirstOrDefault(res);
- if (reslut.IsSuccess)
- {
- YW_CarHeartbeat beatenty = reslut.ResultModel;
- var carTrack = new ResponseCarTrack();
- if (beatenty.locationtype == 2)
- {
- var GPS = Ant.SuperSocket.Common.ToolGPSamap.GPSToGDGPS(beatenty.lng.ToDou(), beatenty.lat.ToDou());
- lat = GPS.Split(',')[1];
- lng = GPS.Split(',')[0];
- car.onlineTime = beatenty.add_time.ToDateTime().ToString("yyyy-MM-dd hh:mm:ss");
- car.postType = "GPS位置";
- //enty.isOnline = (mod.LeaseStatus == 1);
- }
- else
- {
- var lbsreslut = orm.Queryable<YW_CarHeartbeat>().Where(p => p.imei == mod.CarID && p.locationtype == 1).OrderByDesc(p => p.add_time).FirstOrDefault(res);
- if (lbsreslut.IsSuccess)
- {
- YW_CarHeartbeat lbsmod = lbsreslut.ResultModel;
- if (lbsmod.mcc > 0)
- {
- var gps = WebApiHelp.getLocationGPS("", lbsmod.mcc.ToInt32(), lbsmod.mnc.ToInt32(), lbsmod.lac.ToInt32(), lbsmod.cellID.ToInt32(), lbsmod.rssi.ToInt32());
- lbsmod.lng = gps.result.location.Split(',')[0].ToDec();
- lbsmod.lat = gps.result.location.Split(',')[1].ToDec();
- var GPS = Ant.SuperSocket.Common.ToolGPSamap.GPSToGDGPS(lbsmod.lng.ToDou(), lbsmod.lat.ToDou());
- lat = GPS.Split(',')[1];
- lng = GPS.Split(',')[0];
- car.onlineTime = lbsmod.add_time.ToDateTime().ToString("yyyy-MM-dd hh:mm:ss");
- car.postType = "LBS位置";
- //enty.isOnline = (mod.LeaseStatus == 1);
- }
- }
- }
- }
- car.id = mod.ID.ToString();
- car.pic = "http://localhost:7907/upload/20170705135420_87460.jpg";
- car.name = mod.CarName + "(" + mod.CarModel + ")";
- car.latitude = lat;
- car.longitude = lng;
- car.online = (mod.LeaseStatus == 1) ? "在线" : "不在线";
- //car.voltage = "14.095 V";
- //car.hydraulic = "368 KPa";
- //car.temperature = "40 ℃";
- //car.speed = "849 转";
- string ip = System.Web.Configuration.WebConfigurationManager.AppSettings["mongoip"].ToString();
- MongoDbHelper mh = new MongoDbHelper(ip, "1000");
- var query = Query.And(Query.EQ("carId", mod.CarID), MongoDB.Driver.Builders.Query.EQ("carReslut", 1));
- string[] order = new string[] { "operatDate" };
- var modstate = mh.FindOneToIndexMax<UserCarParamInfos>(query, order);
- if (modstate.IfNotNull())
- {
- car.hydraulic = modstate.hydraulic + " KPa";
- car.speed = modstate.speed + " 转";
- car.temperature = modstate.temperature + " ℃";
- car.voltage = modstate.voltage + " mV";
- }
- else
- {
- car.hydraulic = "0 KPa";
- car.temperature = "0 ℃";
- car.speed = "0 转";
- car.voltage = "0 V";
- }
- car.address = ToolGPSamap.GPSToPositionString(car.longitude.ToDou(), car.latitude.ToDou());
- carlist.Add(car);
- }
- //var strjs = Newtonsoft.Json.JsonConvert.SerializeObject(carlist);
- //string localPath = Path.Combine(HttpRuntime.AppDomainAppPath, "Upload\\hotfix\\test.json");
- //FileOperate.FileDel(localPath);
- //FileOperate.WriteFile(localPath, strjs);
- return Json(carlist, JsonRequestBehavior.AllowGet);
- }
- }
- return null;
- }
- /// <summary>
- /// 获取自动驾驶农机
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public JsonResult AtouCarMapJsonFile()
- {
- List<CarGPSModel> carlist = new List<CarGPSModel>();
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取车辆信息" }
- };
- var reslut = orm.Queryable<YW_AntoCarList>().ToList(res);
- if (reslut.IsSuccess)
- {
- foreach (YW_AntoCarList antoCarList in reslut.ResultModel)
- {
- CarGPSModel carGPS = new CarGPSModel();
- carGPS.address = antoCarList.Address;
- carGPS.imei = antoCarList.CarID;
- carGPS.name = "自动驾驶农机";
- carGPS.latitude = antoCarList.latitude.ToString();
- carGPS.longitude = antoCarList.longitude.ToString();
- carGPS.voltage = antoCarList.voltage;
- carGPS.temperature = antoCarList.temperature;
- carGPS.speed = antoCarList.speed;
- carGPS.online = "在线";
- carGPS.onlineTime = antoCarList.add_time.ToString();
- carGPS.pic = "";
- carGPS.barCode = "";
- carGPS.id = antoCarList.ID.ToString();
- carGPS.workingHours = "";
- carlist.Add(carGPS);
- }
- }
- }
- return Json(carlist, JsonRequestBehavior.AllowGet);
- }
- /// <summary>
- /// 生成定位信息JSON文件
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public JsonResult makeMapJsonFile(string strcode, string strname)
- {
- string lat = ""; string lng = ""; string onlinetime = "";
- ViewData["provincecode"] = Request["provincecode"];
- ViewData["strprovince"] = Request["strprovince"];
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取车辆信息" }
- };
- var q = orm.Queryable<EntYW_Bicycle>();
- if (CurrentUser.USERTYPE == 3)//销售员
- {
- int saleid = CurrentUser.Id;
- var qq = orm.Queryable<SYS_DISTRIBUTORS>().LeftJoin<YW_UserDistributor>((city, province) => city.ID == province.distributorId).RightJoin<EntYW_Bicycle>((dis, udis, car) => udis.distributorId == car.DistributorsID);
- var views = qq.Select((dis, udis, car) => new { Car = car, UDis = udis }).OrderByDesc(p => p.UDis.ID).Where(p => p.UDis.userId == saleid).ToList(res);
- if (views.IsSuccess)
- {
- var listdis = views.ResultModel;
- List<CarGPSModel> carlist = new List<CarGPSModel>();
- //List<string> Names = new List<string>();
- foreach (var enty in listdis)
- {
- EntYW_Bicycle mod = enty.Car;
- CarGPSModel car = new CarGPSModel();
- car.imei = mod.CarID;
- car.barCode = mod.carBar;
- string ip = System.Web.Configuration.WebConfigurationManager.AppSettings["mongoip"].ToString();
- MongoDbHelper mh = new MongoDbHelper(ip, "1000");
- var query = Query.And(Query.EQ("imei", mod.CarID));
- var modgps = mh.FindOne<userLatestLocation>(query);
- if (modgps.IfNotNull())
- {
- var GPS = Ant.SuperSocket.Common.ToolGPSamap.GPSToGDGPS(modgps.lng.ToDou(), modgps.lat.ToDou());
- lat = GPS.Split(',')[1];
- lng = GPS.Split(',')[0];
- car.onlineTime = modgps.add_time.ToDateTime().ToString("yyyy-MM-dd HH:mm:ss");
- car.postType = "GPS位置";
- }
- else
- {
- var reslut = orm.Queryable<DeviceManage>().Where(p => p.IMEI == mod.CarID).FirstOrDefault(res);
- if (reslut.IsSuccess)
- {
- DeviceManage beatenty = reslut.ResultModel;
- lat = beatenty.latitude.ToString();
- lng = beatenty.longitude.ToString();
- }
- }
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- string sql = "SELECT CAST(SUM(WorkingHours) AS INT) AS [C] FROM YW_CarTrip where imei='" + mod.CarID + "'";
- var sum = orm.db.ExecuteScalar(sql);
- string workhours = DateTimeUtility.MinuteToHour(sum.ToDou());
- car.workingHours = workhours;
- car.id = mod.ID.ToString();
- string url = Request.Url.ToString(); string parm = Request.RawUrl;
- url = url.Replace(parm, "");
- car.pic = url + "/upload/20170705135420_87460.jpg";
- car.name = mod.CarName + "(" + mod.CarModel + ")";
- car.latitude = lat;
- car.longitude = lng;
- car.online = (mod.LeaseStatus == 1) ? "在线" : "不在线";
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- res.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "查询菜单的单个实体方法" };
- var reslutcar = orm.Queryable<YW_CarParamDetails>().Where(p => p.imei == mod.CarID).FirstOrDefault(res);
- if (reslutcar.IsSuccess)
- {
- YW_CarParamDetails locatmod = reslutcar.ResultModel;
- car.hydraulic = locatmod.hydraulic + " KPa";
- car.speed = locatmod.speed + " 转";
- car.temperature = locatmod.temperature + " ℃";
- var v = (locatmod.voltage.ToDou()).ToString("0.00");
- car.voltage = v + " V";
- }
- else
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItemLog");
- res.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "查询菜单的单个实体方法" };
- var reslutparm = orm.Queryable<YW_CarParamDetails>().Where(p => p.imei == mod.CarID).FirstOrDefault(res);
- if (reslutparm.IsSuccess)
- {
- YW_CarParamDetails locatmod = reslutparm.ResultModel;
- car.hydraulic = locatmod.hydraulic + " KPa";
- car.speed = locatmod.speed + " 转";
- car.temperature = locatmod.temperature + " ℃";
- var v = (locatmod.voltage.ToDou()).ToString("0.00");
- car.voltage = v + " V";
- }
- else
- {
- car.hydraulic = "0 KPa";
- car.temperature = "0 ℃";
- car.speed = "0 转";
- car.voltage = "0 V";
- }
- }
- car.address = ToolGPSamap.GPSToPositionString(car.longitude.ToDou(), car.latitude.ToDou());
- carlist.Add(car);
- }
- carlist = carlist.OrderBy(p => p.onlineTime).ToList();
- return Json(carlist, JsonRequestBehavior.AllowGet);
- }
- }
- else
- {
- List<CarGPSModel> carlist = new List<CarGPSModel>();
- var qq = orm.Queryable<EntYW_Bicycle>().LeftJoin<DeviceManage>((city, province) => city.CarID == province.IMEI);
- var views = qq.Select((car, device) => new { Device = device, Car = car }).OrderByDesc(p => p.Car.ID).Where(p => p.Device.City == strname).ToList(res);
- if (views.IsSuccess)
- {
- foreach (var enty in views.ResultModel)
- {
- EntYW_Bicycle mod = enty.Car;
- CarGPSModel car = new CarGPSModel();
- car.imei = mod.CarID;
- car.barCode = mod.carBar;
- //string ip = System.Web.Configuration.WebConfigurationManager.AppSettings["mongoip"].ToString();
- //MongoDbHelper mh = new MongoDbHelper(ip, "1000");
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- var reslut = orm.Queryable<DeviceManage>().Where(p => p.IMEI == mod.CarID).FirstOrDefault(res);
- if (reslut.IsSuccess)
- {
- DeviceManage beatenty = reslut.ResultModel;
- lat = beatenty.latitude.ToString();
- lng = beatenty.longitude.ToString();
- car.onlineTime = beatenty.LastOnlineTime.ToDateTime().ToString("yyyy-MM-dd hh:mm:ss");
- }
- string sql = "SELECT CAST(SUM(WorkingHours) AS INT) AS [C] FROM YW_CarTrip where imei='" + mod.CarID + "'";
- var sum = orm.db.ExecuteScalar(sql);
- string workhours = DateTimeUtility.MinuteToHour(sum.ToDou());
- car.workingHours = workhours;
- car.id = mod.ID.ToString();
- car.pic = "http://localhost:7907/upload/20170705135420_87460.jpg";
- car.name = mod.CarName + "(" + mod.CarModel + ")";
- car.latitude = lat;
- car.longitude = lng;
- car.online = (mod.LeaseStatus == 1) ? "在线" : "不在线";
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- res.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "查询菜单的单个实体方法" };
- var reslutcar = orm.Queryable<YW_CarParamDetails>().Where(p => p.imei == mod.CarID).FirstOrDefault(res);
- if (reslutcar.IsSuccess)
- {
- YW_CarParamDetails locatmod = reslutcar.ResultModel;
- car.hydraulic = locatmod.hydraulic + " KPa";
- car.speed = locatmod.speed + " 转";
- car.temperature = locatmod.temperature + " ℃";
- var v = (locatmod.voltage.ToDou()).ToString("0.00");
- car.voltage = v + " V";
- }
- else
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItemLog");
- res.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "查询菜单的单个实体方法" };
- var reslutparm = orm.Queryable<YW_CarParamDetails>().Where(p => p.imei == mod.CarID).FirstOrDefault(res);
- if (reslutparm.IsSuccess)
- {
- YW_CarParamDetails locatmod = reslutparm.ResultModel;
- car.hydraulic = locatmod.hydraulic + " KPa";
- car.speed = locatmod.speed + " 转";
- car.temperature = locatmod.temperature + " ℃";
- var v = (locatmod.voltage.ToDou()).ToString("0.00");
- car.voltage = v + " V";
- }
- else
- {
- car.hydraulic = "0 KPa";
- car.temperature = "0 ℃";
- car.speed = "0 转";
- car.voltage = "0 V";
- }
- }
- //var querywhere = MongoDB.Driver.Builders.Query<userNewCarECUInfos>.Where(xx => xx.carId == mod.CarID);
- //var locatmod = mh.FindOne<userNewCarECUInfos>(querywhere);
- //if (locatmod.IfNotNull())
- //{
- // car.hydraulic = locatmod.hydraulic + " KPa";
- // car.speed = locatmod.speed + " 转";
- // car.temperature = locatmod.temperature + " ℃";
- // var v = (locatmod.voltage.ToDou() / 1000).ToString("0.00");
- // car.voltage = v + " V";
- //}
- //else
- //{
- // car.hydraulic = "0 KPa";
- // car.temperature = "0 ℃";
- // car.speed = "0 转";
- // car.voltage = "0 V";
- //}
- car.address = ToolGPSamap.GPSToPositionString(car.longitude.ToDou(), car.latitude.ToDou());
- if (car.longitude.ToDou() > 0 && car.latitude.ToDou() > 0)
- carlist.Add(car);
- }
- }
- carlist = carlist.OrderBy(p => p.onlineTime).ToList();
- return Json(carlist, JsonRequestBehavior.AllowGet);
- }
- }
- return null;
- }
- public ActionResult mapDrivingTrack(string id)
- {
- ViewData["carid"] = id;
- return View();
- }
- /// <summary>
- /// 加载列表
- /// </summary>
- /// <returns></returns>
- [UserAuthorizeAttribute(ModuleAlias = "carList", OperaAction = "View")]
- public ActionResult CarList()
- {
- try
- {
- string userid = string.Empty; string distributorsID = string.Empty;
- PageInfo pageInfo = new PageInfo(base.page, base.pagesize, 0, JsonConverter.JsonClass(new List<EntYW_Bicycle>()));
- if (!Request.QueryString["userid"].IsEmpty())
- {
- userid = Request.QueryString["userid"].ToString();
- }
- if (!Request.QueryString["distributorsid"].IsEmpty())
- {
- distributorsID = Request.QueryString["distributorsid"].ToString();
- }
- if (!userid.IsEmpty())
- {
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取公告信息" }
- };
- IQuery<YW_UserCar> dis = orm.Queryable<YW_UserCar>();
- IQuery<EntYW_Bicycle> bicycle = orm.Queryable<EntYW_Bicycle>();
- IJoiningQuery<YW_UserCar, EntYW_Bicycle> user_city = dis.LeftJoin(bicycle, (strip, sbicycle) => strip.carId == sbicycle.CarID);
- var views = user_city.Select((strip, sbicycle) => new { carInfo = sbicycle, trip = strip }).Where(p => p.trip.userId == userid).OrderByDesc(p => p.carInfo.ID).ToList();
- if (views.IsSuccess)
- {
- List<EntYW_Bicycle> listcar = new List<EntYW_Bicycle>();
- foreach (var item in views.ResultModel)
- {
- EntYW_Bicycle mod = item.carInfo;
- YW_UserCar userCar = item.trip;
- mod.lang = (userCar.userIdentity == 1) ? "机主" : "机手";
- listcar.Add(mod);
- }
- pageInfo = new PageInfo(base.page, base.pagesize, views.RecordNum, JsonConverter.JsonClass(listcar));
- }
- }
- }
- else
- {
- if (!distributorsID.IsEmpty())
- {
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取公告信息" }
- };
- var reslut = orm.Queryable<EntYW_Bicycle>().Where(p => p.DistributorsID == distributorsID).ToList(res);
- if (reslut.IsSuccess)
- {
- pageInfo = new PageInfo(base.page, base.pagesize, reslut.RecordNum, JsonConverter.JsonClass(reslut.ResultModel));
- }
- }
- }
- }
- return View(pageInfo);
- }
- catch (Exception e)
- {
- WriteLog(enumOperator.Select, "加载岗位列表:", e);
- throw e.InnerException;
- }
- }
- /// <summary>
- /// 加载列表
- /// </summary>
- /// <returns></returns>
- [UserAuthorizeAttribute(ModuleAlias = "machineryList", OperaAction = "View")]
- public ActionResult MachineryList()
- {
- try
- {
- string posttype = Request.QueryString["posttype"];
- string FK_DPTID = Request.QueryString["FK_DPTID"];
- string CarSate = Request.QueryString["CarSate"];
- int carType = Request.QueryString["LeaseStatus"].ToInt32();
- string barcode = Request.QueryString["txt_barcode"];
- string imei = Request.QueryString["txt_imei"];
- string factoryNumber = Request.QueryString["txt_factoryNumber"];
- string factoryDate = Request.QueryString["txt_factoryDate"];
- int prov = Request.QueryString["hkprov"].ToInt32();
- int state = -1;
- if (!CarSate.IsEmpty())
- {
- state = CarSate.ToInt32();
- }
- int FenceState = -1;
- if (!Request.QueryString["FenceState"].IsEmpty())
- {
- FenceState = Request.QueryString["FenceState"].ToInt32();
- }
- string distributorsID = string.Empty;
- PageInfo pageInfo = new PageInfo(base.page, base.pagesize, 0, JsonConverter.JsonClass(new List<EntYW_Bicycle>()));
- if (CurrentUser.USERTYPE == 0 || CurrentUser.USERTYPE == 8)
- {
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取公告信息" }
- };
- IQuery<EntSYS_DISTRIBUTORS> dis = orm.Queryable<EntSYS_DISTRIBUTORS>();
- IQuery<EntYW_Bicycle> carquery = orm.Queryable<EntYW_Bicycle>();
- var cardis = carquery.LeftJoin(dis, (d, c) => d.DistributorsID == c.ID);
- var qq = cardis.Select((cars, disname) => new { Car = cars, Dis = disname }).Where(a => a.Car.CarSate > 0);
- if (carType > 0)
- qq = qq.Where(p => p.Car.ProductLine == carType);
- if (!FK_DPTID.IsEmpty())
- qq = qq.Where(p => p.Car.DistributorsID == FK_DPTID);
- if (!barcode.IsEmpty())
- {
- qq = qq.Where(p => p.Car.carBar.Contains(barcode));
- }
- if (!imei.IsEmpty())
- {
- qq = qq.Where(p => p.Car.CarID.Contains(imei));
- }
- if (FenceState >= 0)
- {
- qq = qq.Where(p => p.Car.FenceState == FenceState);
- }
- if (CurrentUser.USERTYPE == 8)
- {
- qq = qq.Where(p => p.Car.DistributorsID != "fc674ffb-3044-4f5f-a40d-cf496fac52f7");
- }
- if (state >= 0)
- {
- qq = qq.Where(p => p.Car.CarSate == state);
- }
- if (prov > 0)
- {
- qq = qq.Where(p => p.Dis.Province == prov);
- }
- if (!factoryNumber.IsEmpty())
- {
- qq = qq.Where(p => p.Car.FactoryNumber == factoryNumber);
- }
- if (!factoryDate.IsEmpty())
- {
- DateTime dateTime = factoryDate.ToDateTime(); DateTime dates = dateTime.AddDays(1);
- qq = qq.Where(p => p.Car.OutDate >= dateTime && p.Car.OutDate < dates);
- }
- int pageno = (page - 1) * pagesize;
- var bicycleList = qq.OrderBy(a => a.Car.carBar).Skip(pageno).Top(pagesize).ToList();
- if (bicycleList.IsSuccess)
- {
- bicycleList.RecordNum = qq.Count();
- List<EntYW_Bicycle> listcar = new List<EntYW_Bicycle>();
- foreach (var item in bicycleList.ResultModel)
- {
- EntYW_Bicycle mod = item.Car;
- listcar.Add(mod);
- }
- pageInfo = new PageInfo(base.page, base.pagesize, bicycleList.RecordNum, JsonConverter.JsonClass(listcar));
- }
- }
- }
- else
- {
- //if (CurrentUser.DptInfo.IfNotNull())
- //{
- // if (!CurrentUser.DptInfo.ID.IsEmpty())
- // {
- // distributorsID = CurrentUser.DptInfo.ID;
- // }
- //}
- //else
- //{
- int saleid = CurrentUser.Id;
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取公告信息" }
- };
- var q = orm.Queryable<EntYW_Bicycle>();
- if (!FK_DPTID.IsEmpty())
- {
- q = q.Where(p => p.DistributorsID == FK_DPTID);
- if (carType > 0)
- {
- q = q.Where(p => p.ProductLine == carType);
- }
- if (!barcode.IsEmpty())
- {
- q = q.Where(p => p.carBar.Contains(barcode));
- }
- if (!imei.IsEmpty())
- {
- q = q.Where(p => p.CarID.Contains(imei));
- }
- if (FenceState >= 0)
- {
- q = q.Where(p => p.FenceState == FenceState);
- }
- if (state >= 0)
- {
- q = q.Where(p => p.CarSate == state);
- }
- if (!factoryNumber.IsEmpty())
- {
- q = q.Where(p => p.FactoryNumber == factoryNumber);
- }
- int pageno = (page - 1) * pagesize;
- var bicycleList = q.Skip(pageno).Top(pagesize).ToList();
- if (bicycleList.IsSuccess)
- {
- bicycleList.RecordNum = q.Count();
- List<EntYW_Bicycle> listcar = new List<EntYW_Bicycle>();
- foreach (EntYW_Bicycle item in bicycleList.ResultModel)
- {
- listcar.Add(item);
- }
- pageInfo = new PageInfo(base.page, base.pagesize, bicycleList.RecordNum, JsonConverter.JsonClass(listcar));
- }
- }
- else
- {
- IQuery<EntYW_Bicycle> car = orm.Queryable<EntYW_Bicycle>();
- var dis = orm.Queryable<EntSYS_DISTRIBUTORS>();
- IQuery<EntYW_UserDistributor> userdis = orm.Queryable<EntYW_UserDistributor>();
- IJoiningQuery<EntYW_Bicycle, EntYW_UserDistributor> user_city;
- if (CurrentUser.USERTYPE == 10)
- {
- user_city = car.LeftJoin(userdis, (user, city) => user.DistributorsID == city.distributorId);
- }
- else
- {
- user_city = car.LeftJoin(userdis, (user, city) => user.DistributorsID == city.distributorId && (user.ProductLine == city.ProductLine || user.ProductLine == city.ProductLine1 || user.ProductLine == city.ProductLine2 || user.ProductLine == city.ProductLine3 || user.ProductLine == city.ProductLine4 || user.ProductLine == city.ProductLine5));
- }
- IJoiningQuery<EntYW_Bicycle, EntYW_UserDistributor, EntSYS_DISTRIBUTORS> user_city_province = user_city.InnerJoin(dis, (user, city, province) => (city.distributorId == province.ID));
- var qq = user_city_province.Select((user, city, disname) => new { Users = user, Citys = city, Dis = disname }).Where(a => a.Citys.userId == saleid);
- if (!Request.QueryString["CarSate"].IsEmpty())
- {
- int carstate = CarState.Storage.ToInt32();
- }
- if (carType > 0)
- {
- qq = qq.Where(p => p.Users.carType == carType);
- }
- if (prov > 0)
- {
- qq = qq.Where(p => p.Dis.Province == prov);
- }
- if (!barcode.IsEmpty())
- {
- qq = qq.Where(p => p.Users.carBar.Contains(barcode));
- }
- if (!imei.IsEmpty())
- {
- qq = qq.Where(p => p.Users.CarID.Contains(imei));
- }
- if (FenceState >= 0)
- {
- qq = qq.Where(p => p.Users.FenceState == FenceState);
- }
- if (state >= 0)
- {
- qq = qq.Where(p => p.Users.CarSate == state);
- }
- if (!factoryNumber.IsEmpty())
- {
- qq = qq.Where(p => p.Users.FactoryNumber == factoryNumber);
- }
- if (!factoryDate.IsEmpty())
- {
- DateTime dateTime = factoryDate.ToDateTime(); DateTime dates = dateTime.AddDays(1);
- qq = qq.Where(p => p.Users.OutDate >= dateTime && p.Users.OutDate < dates);
- }
- int pageno = (page - 1) * pagesize;
- var bicycleList = qq.OrderByDesc(p => p.Users.DistributorsID).Skip(pageno).Top(pagesize).ToList();
- if (bicycleList.IsSuccess)
- {
- bicycleList.RecordNum = qq.Count();
- List<EntYW_Bicycle> listcar = new List<EntYW_Bicycle>();
- foreach (var item in bicycleList.ResultModel)
- {
- EntYW_Bicycle carmode = item.Users;
- listcar.Add(carmode);
- }
- pageInfo = new PageInfo(base.page, base.pagesize, bicycleList.RecordNum, JsonConverter.JsonClass(listcar));
- }
- }
- }
- //}
- }
- if (!distributorsID.IsEmpty())
- {
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取公告信息" }
- };
- var q = orm.Queryable<EntYW_Bicycle>().Where(p => p.DistributorsID == distributorsID);
- if (!Request.QueryString["CarSate"].IsEmpty())
- {
- int carstate = CarState.Storage.ToInt32();
- q = q.Where(p => p.CarSate == carstate);
- }
- if (!barcode.IsEmpty())
- {
- q = q.Where(p => p.carBar.Contains(barcode));
- }
- if (!imei.IsEmpty())
- {
- q = q.Where(p => p.CarID.Contains(imei));
- }
- int pageno = (page - 1) * pagesize;
- var reslut = q.OrderBy(a => a.carBar).Skip(pageno).Top(pagesize).ToList(res);
- if (reslut.IsSuccess)
- {
- reslut.RecordNum = q.Count();
- pageInfo = new PageInfo(base.page, base.pagesize, reslut.RecordNum, JsonConverter.JsonClass(reslut.ResultModel));
- }
- }
- }
- int uid = 0;
- if (CurrentUser.USERTYPE == 0 || CurrentUser.USERTYPE == 8)
- {
- uid = 0;
- }
- else
- {
- uid = CurrentUser.Id;
- }
- if (!Request.QueryString["hkprov"].IsEmpty())
- {
- ViewData["hkprov"] = Request.QueryString["hkprov"];
- }
- ViewData["Department"] = this.DepartmentManage.GetDepartmentByDetailNew(uid, prov);
- ViewData["dptid"] = FK_DPTID;
- ViewData["CarSate"] = CarSate;
- ViewData["cartype"] = this.CodeManage.LoadAll(p => p.CODETYPE == "XMLX").ToList();
- ViewData["typecar"] = carType;
- ViewData["levels"] = this.CodeManage.LoadAll(p => p.CODETYPE == "CLLB").OrderBy(p => p.SHOWORDER).ToList();
- //ViewData["levels"] = this.CodeManage.LoadAll(p => p.CODETYPE == "CLLB").ToList();
- ViewData["factoryNumber"] = factoryNumber;
- ViewData["factoryDate"] = factoryDate;
- ViewData["FenceState"] = FenceState;
- ViewBag.Search = base.keywords;
- ViewData["barcode"] = barcode;
- ViewData["imei"] = imei;
- return View(pageInfo);
- }
- catch (Exception e)
- {
- WriteLog(enumOperator.Select, "加载岗位列表:", e);
- throw e.InnerException;
- }
- }
- /// <summary>
- /// 加载列表
- /// </summary>
- /// <returns></returns>
- [UserAuthorizeAttribute(ModuleAlias = "salesCarList", OperaAction = "View")]
- public ActionResult SalesCarList()
- {
- try
- {
- string posttype = Request.QueryString["posttype"];
- string FK_DPTID = Request.QueryString["FK_DPTID"];
- string CarSate = Request.QueryString["CarSate"];
- string barcode = Request.QueryString["txt_barcode"];
- string imei = Request.QueryString["txt_imei"];
- string factoryNumber = Request.QueryString["txt_factoryNumber"];
- int FenceState = -1;
- if (!Request.QueryString["FenceState"].IsEmpty())
- {
- FenceState = Request.QueryString["FenceState"].ToInt32();
- }
- int carType = Request.QueryString["LeaseStatus"].ToInt32();
- int state = -1;
- if (!CarSate.IsEmpty())
- {
- state = CarSate.ToInt32();
- }
- string distributorsID = string.Empty;
- PageInfo pageInfo = new PageInfo(base.page, base.pagesize, 0, JsonConverter.JsonClass(new List<EntYW_Bicycle>()));
- if (CurrentUser.USERTYPE == 0 || CurrentUser.USERTYPE == 8)
- {
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取公告信息" }
- };
- IQuery<EntSYS_DISTRIBUTORS> dis = orm.Queryable<EntSYS_DISTRIBUTORS>();
- IQuery<EntYW_Bicycle> carquery = orm.Queryable<EntYW_Bicycle>();
- var cardis = carquery.LeftJoin(dis, (d, c) => d.DistributorsID == c.ID);
- var qq = cardis.Select((cars, disname) => new { Car = cars, Dis = disname }).Where(a => a.Car.CarSate > 0);
- if (carType > 0)
- qq = qq.Where(p => p.Car.ProductLine == carType);
- if (!FK_DPTID.IsEmpty())
- qq = qq.Where(p => p.Car.DistributorsID == FK_DPTID);
- if (!barcode.IsEmpty())
- {
- qq = qq.Where(p => p.Car.carBar.Contains(barcode));
- }
- if (!imei.IsEmpty())
- {
- qq = qq.Where(p => p.Car.CarID.Contains(imei));
- }
- if (FenceState >= 0)
- {
- qq = qq.Where(p => p.Car.FenceState == FenceState);
- }
- if (CurrentUser.USERTYPE == 8)
- {
- qq = qq.Where(p => p.Car.DistributorsID != "fc674ffb-3044-4f5f-a40d-cf496fac52f7");
- }
- if (state >= 0)
- {
- qq = qq.Where(p => p.Car.CarSate == state);
- }
- if (!factoryNumber.IsEmpty())
- {
- qq = qq.Where(p => p.Car.FactoryNumber == factoryNumber);
- }
- int pageno = (page - 1) * pagesize;
- var bicycleList = qq.OrderBy(a => a.Car.carBar).Skip(pageno).Top(pagesize).ToList();
- if (bicycleList.IsSuccess)
- {
- bicycleList.RecordNum = qq.Count();
- List<EntYW_Bicycle> listcar = new List<EntYW_Bicycle>();
- foreach (var item in bicycleList.ResultModel)
- {
- EntYW_Bicycle mod = item.Car;
- listcar.Add(mod);
- }
- pageInfo = new PageInfo(base.page, base.pagesize, bicycleList.RecordNum, JsonConverter.JsonClass(listcar));
- }
- }
- }
- else
- {
- //if (CurrentUser.DptInfo.IfNotNull()) //经销商
- //{
- // if (!CurrentUser.DptInfo.ID.IsEmpty())
- // {
- // distributorsID = CurrentUser.DptInfo.ID;
- // }
- //}
- //else
- //{
- int saleid = CurrentUser.Id; //业务员
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取公告信息" }
- };
- var q = orm.Queryable<EntYW_Bicycle>();
- if (!FK_DPTID.IsEmpty())
- {
- q = q.Where(p => p.DistributorsID == FK_DPTID);
- if (carType > 0)
- {
- q = q.Where(p => p.ProductLine == carType);
- }
- if (!barcode.IsEmpty())
- {
- q = q.Where(p => p.carBar.Contains(barcode));
- }
- if (!imei.IsEmpty())
- {
- q = q.Where(p => p.CarID.Contains(imei));
- }
- if (FenceState >= 0)
- {
- q = q.Where(p => p.FenceState == FenceState);
- }
- if (state >= 0)
- {
- q = q.Where(p => p.CarSate == state);
- }
- if (!factoryNumber.IsEmpty())
- {
- q = q.Where(p => p.FactoryNumber == factoryNumber);
- }
- int pageno = (page - 1) * pagesize;
- var bicycleList = q.Skip(pageno).Top(pagesize).ToList();
- if (bicycleList.IsSuccess)
- {
- bicycleList.RecordNum = q.Count();
- List<EntYW_Bicycle> listcar = new List<EntYW_Bicycle>();
- foreach (EntYW_Bicycle item in bicycleList.ResultModel)
- {
- listcar.Add(item);
- }
- pageInfo = new PageInfo(base.page, base.pagesize, bicycleList.RecordNum, JsonConverter.JsonClass(listcar));
- }
- }
- else
- {
- IQuery<EntYW_Bicycle> car = orm.Queryable<EntYW_Bicycle>();
- IQuery<EntYW_UserDistributor> userdis = orm.Queryable<EntYW_UserDistributor>();
- IQuery<EntSYS_DISTRIBUTORS> dis = orm.Queryable<EntSYS_DISTRIBUTORS>();
- IJoiningQuery<EntYW_Bicycle, EntYW_UserDistributor> user_city;
- if (CurrentUser.USERTYPE == 10)
- {
- user_city = car.LeftJoin(userdis, (user, city) => user.DistributorsID == city.distributorId);
- }
- else
- {
- user_city = car.LeftJoin(userdis, (user, city) => user.DistributorsID == city.distributorId && (user.ProductLine == city.ProductLine || user.ProductLine == city.ProductLine1 || user.ProductLine == city.ProductLine2 || user.ProductLine == city.ProductLine3 || user.ProductLine == city.ProductLine4 || user.ProductLine == city.ProductLine5));
- }
- IJoiningQuery<EntYW_Bicycle, EntYW_UserDistributor, EntSYS_DISTRIBUTORS> user_city_province = user_city.InnerJoin(dis, (user, city, province) => (city.distributorId == province.ID));
- var qq = user_city_province.Select((user, city, disname) => new { Users = user, Citys = city, Dis = disname }).Where(a => a.Citys.userId == saleid);
- if (!Request.QueryString["CarSate"].IsEmpty())
- {
- int carstate = CarState.Storage.ToInt32();
- }
- if (carType > 0)
- {
- qq = qq.Where(p => p.Users.ProductLine == carType);
- }
- if (!barcode.IsEmpty())
- {
- qq = qq.Where(p => p.Users.carBar.Contains(barcode));
- }
- if (!imei.IsEmpty())
- {
- qq = qq.Where(p => p.Users.CarID.Contains(imei));
- }
- if (FenceState >= 0)
- {
- qq = qq.Where(p => p.Users.FenceState == FenceState);
- }
- if (state >= 0)
- {
- qq = qq.Where(p => p.Users.CarSate == state);
- }
- if (!factoryNumber.IsEmpty())
- {
- qq = qq.Where(p => p.Users.FactoryNumber == factoryNumber);
- }
- int pageno = (page - 1) * pagesize;
- var bicycleList = qq.OrderByDesc(p => p.Users.DistributorsID).Skip(pageno).Top(pagesize).ToList();
- if (bicycleList.IsSuccess)
- {
- bicycleList.RecordNum = qq.Count();
- List<EntYW_Bicycle> listcar = new List<EntYW_Bicycle>();
- foreach (var item in bicycleList.ResultModel)
- {
- EntYW_Bicycle carmode = item.Users;
- EntSYS_DISTRIBUTORS dismod = item.Dis;
- carmode.DistributorsName = dismod.NAME;
- listcar.Add(carmode);
- }
- pageInfo = new PageInfo(base.page, base.pagesize, bicycleList.RecordNum, JsonConverter.JsonClass(listcar));
- }
- }
- }
- //}
- }
- if (!distributorsID.IsEmpty())
- {
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取公告信息" }
- };
- var q = orm.Queryable<EntYW_Bicycle>().Where(p => p.DistributorsID == distributorsID);
- if (!Request.QueryString["CarSate"].IsEmpty())
- {
- int carstate = CarState.Storage.ToInt32();
- q = q.Where(p => p.CarSate == carstate);
- }
- if (!barcode.IsEmpty())
- {
- q = q.Where(p => p.carBar.Contains(barcode));
- }
- if (!imei.IsEmpty())
- {
- q = q.Where(p => p.CarID.Contains(imei));
- }
- if (state >= 0)
- {
- q = q.Where(p => p.CarSate == state);
- }
- if (!factoryNumber.IsEmpty())
- {
- q = q.Where(p => p.FactoryNumber == factoryNumber);
- }
- int pageno = (page - 1) * pagesize;
- var reslut = q.Skip(pageno).Top(pagesize).ToList();
- if (reslut.IsSuccess)
- {
- pageInfo = new PageInfo(base.page, base.pagesize, reslut.RecordNum, JsonConverter.JsonClass(reslut.ResultModel));
- }
- }
- }
- int uid = 0;
- if (CurrentUser.USERTYPE == 0 || CurrentUser.USERTYPE == 8)
- {
- uid = 0;
- }
- else
- {
- uid = CurrentUser.Id;
- }
- ViewData["Department"] = this.DepartmentManage.GetDepartmentByDetailNew(uid);
- ViewData["dptid"] = FK_DPTID;
- ViewData["CarSate"] = CarSate;
- ViewData["FenceState"] = FenceState;
- ViewData["cartype"] = this.CodeManage.LoadAll(p => p.CODETYPE == "XMLX").ToList();
- ViewData["typecar"] = carType;
- ViewData["levels"] = this.CodeManage.LoadAll(p => p.CODETYPE == "CLLB").OrderBy(p => p.SHOWORDER).ToList();
- ViewData["barcode"] = barcode;
- ViewData["factoryNumber"] = factoryNumber;
- ViewData["imei"] = imei;
- return View(pageInfo);
- }
- catch (Exception e)
- {
- WriteLog(enumOperator.Select, "加载岗位列表:", e);
- throw e.InnerException;
- }
- }
- /// <summary>
- /// 锁车列表
- /// </summary>
- /// <returns></returns>
- public ActionResult CarLockList(string id)
- {
- try
- {
- PageInfo pageInfo = new PageInfo(base.page, base.pagesize, 0, JsonConverter.JsonClass(new List<MeterMaintenance>()));
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取公告信息" }
- };
- var reslut = orm.Queryable<MeterMaintenance>().Where(p => p.IMEI == "356802033785329").ToList(res);
- if (reslut.IsSuccess)
- {
- pageInfo = new PageInfo(base.page, base.pagesize, reslut.RecordNum, JsonConverter.JsonClass(reslut.ResultModel));
- }
- }
- return View(pageInfo);
- }
- catch (Exception e)
- {
- WriteLog(enumOperator.Select, "加载岗位列表:", e);
- throw e.InnerException;
- }
- }
- /// <summary>
- /// 加载列表
- /// </summary>
- /// <returns></returns>
- [UserAuthorizeAttribute(ModuleAlias = "SalesCarList", OperaAction = "View,Add,Edit,Export")]
- public ActionResult DistributorCarList()
- {
- try
- {
- string userid = string.Empty; string CarSate = Request.QueryString["CarSate"]; string distributorsID = string.Empty; string LEVEL = string.Empty; string distributorName = string.Empty; string saleId = string.Empty;
- PageInfo pageInfo = new PageInfo(base.page, base.pagesize, 0, JsonConverter.JsonClass(new List<EntYW_Bicycle>()));
- if (!Request.QueryString["distributorsid"].IsEmpty())
- {
- distributorsID = Request.QueryString["distributorsid"].ToString();
- }
- if (!Request.QueryString["distributorLEVEL"].IsEmpty())
- {
- LEVEL = Request.QueryString["distributorLEVEL"].ToString();
- }
- if (!Request.QueryString["distributorsName"].IsEmpty())
- {
- distributorName = Request.QueryString["distributorsName"].ToString();
- }
- if (!Request.QueryString["saleid"].IsEmpty())
- {
- saleId = Request.QueryString["saleid"].ToString();
- }
- if (!distributorsID.IsEmpty())
- {
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取公告信息" }
- };
- var q = orm.Queryable<EntYW_Bicycle>();
- if (!CarSate.IsEmpty() && CarSate != "-1")
- {
- int state = CarSate.ToInt32();
- if (LEVEL == "2")
- {
- q = q.Where(p => p.DistributorsID == distributorsID && p.CarSate == state);
- }
- else
- {
- q = q.Where(p => p.WarehouseID == distributorsID && p.CarSate == state);
- }
- }
- else
- {
- if (LEVEL == "2")
- {
- q = q.Where(p => p.DistributorsID == distributorsID);
- }
- else
- {
- q = q.Where(p => p.WarehouseID == distributorsID);
- }
- }
- int pageno = (page - 1) * pagesize;
- var reslut = q.OrderByDesc(p => p.CreateDate).Skip(pageno).Top(pagesize).ToList(res);
- if (reslut.IsSuccess)
- {
- reslut.RecordNum = q.Count();
- pageInfo = new PageInfo(base.page, base.pagesize, reslut.RecordNum, JsonConverter.JsonClass(reslut.ResultModel));
- }
- }
- }
- //ViewData["levels"] = this.CodeManage.LoadAll(p => p.CODETYPE == "CLLB").ToList();
- ViewData["levels"] = this.CodeManage.LoadAll(p => p.CODETYPE == "CLLB").OrderBy(p => p.SHOWORDER).ToList();
- ViewData["CarSate"] = CarSate;
- ViewData["distributorsid"] = distributorsID;
- ViewData["distributorName"] = distributorName;
- ViewData["saleid"] = saleId;
- return View(pageInfo);
- }
- catch (Exception e)
- {
- WriteLog(enumOperator.Select, "加载岗位列表:", e);
- throw e.InnerException;
- }
- }
- /// <summary>
- /// 加载列表
- /// </summary>
- /// <returns></returns>
- [UserAuthorizeAttribute(ModuleAlias = "Department", OperaAction = "View,Export")]
- public ActionResult DistributorInventoryCarList()
- {
- try
- {
- string userid = string.Empty; string distributorsID = string.Empty; string CarSate = Request.QueryString["CarSate"];
- PageInfo pageInfo = new PageInfo(base.page, base.pagesize, 0, JsonConverter.JsonClass(new List<EntYW_Bicycle>()));
- if (!Request.QueryString["distributorsid"].IsEmpty())
- {
- distributorsID = Request.QueryString["distributorsid"].ToString();
- }
- if (!distributorsID.IsEmpty())
- {
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取公告信息" }
- };
- var q = orm.Queryable<EntYW_Bicycle>();
- if (!CarSate.IsEmpty())
- {
- int state = CarSate.ToInt32();
- q = q.Where(p => p.DistributorsID == distributorsID && p.CarSate == state);
- }
- else
- {
- q = q.Where(p => p.DistributorsID == distributorsID);
- }
- var reslut = q.ToList(res);
- if (reslut.IsSuccess)
- {
- pageInfo = new PageInfo(base.page, base.pagesize, reslut.RecordNum, JsonConverter.JsonClass(reslut.ResultModel));
- }
- }
- }
- ViewData["levels"] = this.CodeManage.LoadAll(p => p.CODETYPE == "CLLB").OrderBy(p => p.SHOWORDER).ToList();
- //ViewData["levels"] = this.CodeManage.LoadAll(p => p.CODETYPE == "CLLB").ToList();
- ViewData["CarSate"] = CarSate;
- ViewData["distributorsid"] = distributorsID;
- return View(pageInfo);
- }
- catch (Exception e)
- {
- WriteLog(enumOperator.Select, "加载岗位列表:", e);
- throw e.InnerException;
- }
- }
- /// <summary>
- /// 申请审校不通过
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult CheckApplyCarPass(string applyid)
- {
- var json = new JsonHelper() { Status = "y", Msg = "Success" };
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel();
- res.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取用户车辆信息" };
- Guid guid = new Guid(applyid);
- var reslut = orm.Queryable<yw_machinery_return>().Where(p => p.id == guid).FirstOrDefault(res);
- if (reslut.IsSuccess)
- {
- yw_machinery_return mod = reslut.ResultModel;
- if (mod.apply_type == 1)//退货
- {
- int carstate = CarState.OutStock.ToInt32();
- var reslutcar = orm.UpdateByLambda<EntYW_Bicycle>(p => new EntYW_Bicycle { CarSate = carstate }, f => f.CarID == mod.carid, res);
- {
- var reslutapply = orm.UpdateByLambda<yw_machinery_return>(p => new yw_machinery_return { state = 1, check_time = DateTime.Now }, f => f.id == mod.id, res);
- if (reslutapply.IsSuccess)
- {
- json.Status = "y";
- json.Msg = "退货审核通过";
- }
- var usersalereslut = orm.DeleteByLambda<YW_CarPurchaser>(p => p.imei == mod.carid, res);
- if (usersalereslut.IsSuccess)
- {
- }
- var userbindreslut = orm.DeleteByLambda<YW_UserCar>(p => p.carId == mod.carid, res);
- if (userbindreslut.IsSuccess)
- {
- }
- var alarmreslut = orm.DeleteByLambda<YW_AlarmInformation>(p => p.CarId == mod.carid, res);
- if (alarmreslut.IsSuccess)
- {
- }
- }
- }
- if (mod.apply_type == 2)//返厂
- {
- int carstate = CarState.carBind.ToInt32();
- var reslutcar = orm.UpdateByLambda<EntYW_Bicycle>(p => new EntYW_Bicycle { CarSate = carstate, DistributorsID = "", DistributorsName = "" }, f => f.CarID == mod.carid, res);
- {
- var reslutapply = orm.UpdateByLambda<yw_machinery_return>(p => new yw_machinery_return { state = 1 }, f => f.id == mod.id, res);
- if (reslutapply.IsSuccess)
- {
- json.Status = "y";
- json.Msg = "返厂审核通过";
- }
- var usersalereslut = orm.DeleteByLambda<YW_CarPurchaser>(p => p.imei == mod.carid, res);
- if (usersalereslut.IsSuccess)
- {
- }
- var userbindreslut = orm.DeleteByLambda<YW_UserCar>(p => p.carId == mod.carid, res);
- if (userbindreslut.IsSuccess)
- {
- }
- var alarmreslut = orm.DeleteByLambda<YW_AlarmInformation>(p => p.CarId == mod.carid, res);
- if (alarmreslut.IsSuccess)
- {
- }
- }
- }
- if (mod.apply_type == 3)//调拨
- {
- int carstate = CarState.OutStock.ToInt32();
- var reslutcar = orm.UpdateByLambda<EntYW_Bicycle>(p => new EntYW_Bicycle { CarSate = carstate, DistributorsID = mod.distributorsID, DistributorsName = mod.distributorsName }, f => f.CarID == mod.carid, res);
- {
- var reslutapply = orm.UpdateByLambda<yw_machinery_return>(p => new yw_machinery_return { state = 1 }, f => f.id == mod.id, res);
- if (reslutapply.IsSuccess)
- {
- json.Status = "y";
- json.Msg = "调拨审核通过";
- }
- var usersalereslut = orm.DeleteByLambda<YW_CarPurchaser>(p => p.imei == mod.carid, res);
- if (usersalereslut.IsSuccess)
- {
- }
- var userbindreslut = orm.DeleteByLambda<YW_UserCar>(p => p.carId == mod.carid, res);
- if (userbindreslut.IsSuccess)
- {
- }
- var alarmreslut = orm.DeleteByLambda<YW_AlarmInformation>(p => p.CarId == mod.carid, res);
- if (alarmreslut.IsSuccess)
- {
- }
- }
- }
- if (mod.apply_type == 4)
- {
- //SendLockCarCmd(mod.carid);
- }
- if (mod.apply_type == 5)
- {
- //SendUnlockCarCmd(mod.carid);
- }
- }
- }
- return Json(json, JsonRequestBehavior.AllowGet);
- }
- /// <summary>
- /// 审核不通过
- /// </summary>
- /// <param name="applyid"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult CheckApplyCarNoPass(string applyid)
- {
- var json = new JsonHelper() { Status = "y", Msg = "Success" };
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel();
- res.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取用户车辆信息" };
- Guid guid = new Guid(applyid);
- var reslutapply = orm.UpdateByLambda<yw_machinery_return>(p => new yw_machinery_return { state = 2 }, f => f.id == guid, res);
- if (reslutapply.IsSuccess)
- {
- var reslutmod = orm.Queryable<yw_machinery_return>().Where(p => p.id == guid).FirstOrDefault(res);
- if (reslutmod.IsSuccess)
- {
- yw_machinery_return mod = reslutmod.ResultModel;
- orm.UpdateByLambda<EntYW_Bicycle>(p => new EntYW_Bicycle { CarSate = mod.carState }, f => f.CarID == mod.carid, res);
- }
- }
- }
- return Json(json, JsonRequestBehavior.AllowGet);
- }
- /// <summary>
- /// 发送锁车指令
- /// </summary>
- [HttpGet]
- public ActionResult SendLockCarCmd(string carid)
- {
- var json = new JsonHelper() { Status = "y", Msg = "Success" };
- var applyName = Request["applyName"];
- var applyReason = Request["applyReason"];
- var applypwd = Request["applyPwd"];
- if (applypwd == "changfa123")
- {
- var str = DataHelper.sendLockHexStr(Convert.ToInt64(carid.Trim()));
- var body = DataHelper.HexToByte(str);
- SocketClient client = new SocketClient();
- try
- {
- string ip = System.Web.Configuration.WebConfigurationManager.AppSettings["ip"].ToString();
- int port = System.Web.Configuration.WebConfigurationManager.AppSettings["port"].ToInt32();
- client.Connect(ip, port);
- var flag = client.SendData(body);
- //string mip = System.Web.Configuration.WebConfigurationManager.AppSettings["mongoip"].ToString();
- //MongoDbHelper mh = new MongoDbHelper(mip, "1000");
- //var querywhere = MongoDB.Driver.Builders.Query<ApplyCarLock>.Where(xx => xx.carid == carid);
- //var locatmod = mh.FindOne<ApplyCarLock>(querywhere);
- //if (locatmod.IsNull())
- //{
- // ApplyCarLock userCar = new ApplyCarLock();
- // userCar.carid = carid;
- // userCar.apply_type = 1; //发送锁车指令
- // userCar.state = 0;
- // userCar.add_name = "服务";
- // userCar.created_at = DateTime.Now;
- // var carflag = mh.Insert(userCar);
- //}
- //else
- //{
- // var update = new MongoDB.Driver.UpdateDocument { { "$set", new MongoDB.Driver.QueryDocument { { "apply_type", 1 }, { "state", 0 } } } };
- // var querystr = MongoDB.Driver.Builders.Query<ApplyCarLock>.Where(xx => xx.carid == carid);
- // if (mh.Update<ApplyCarLock>(querystr, update))
- // {
- // }
- //}
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取公告信息" }
- };
- var reslutlock = orm.UpdateByLambda<YW_Apply_CarLock>(p => new YW_Apply_CarLock { state = 2 }, f => f.carid == carid && f.state == 0, res);
- if (reslutlock.IsSuccess)
- {
- }
- YW_Apply_CarLock apply_CarLock = new YW_Apply_CarLock();
- apply_CarLock.ID = Guid.NewGuid();
- apply_CarLock.apply_type = 1;
- apply_CarLock.apply_name = applyName;
- apply_CarLock.reason = applyReason;
- apply_CarLock.carid = carid;
- apply_CarLock.add_time = DateTime.Now;
- apply_CarLock.state = 0;
- apply_CarLock.add_name = "管理员";
- orm.Save(apply_CarLock, res);
- }
- client.Disconnect();
- }
- catch (Exception ex)
- {
- }
- }
- else
- {
- json.Msg = "申请密码不正确!";
- json.Status = "n";
- }
- //json.Data = Common.JsonConverter.Serialize(this.CodeAreaManage.LoadListAll(p => p.LEVELS == 1));
- return Json(json, JsonRequestBehavior.AllowGet);
- }
- /// <summary>
- /// 发送开锁指令
- /// </summary>
- [HttpGet]
- public ActionResult SendUnlockCarCmd(string carid)
- {
- var json = new JsonHelper() { Status = "y", Msg = "Success" };
- var applyName = Request["applyName"];
- var applyReason = Request["applyReason"];
- var applypwd = Request["applyPwd"];
- if (applypwd == "changfa123")
- {
- var str = DataHelper.sendUnLockHexStr(Convert.ToInt64(carid.Trim()));
- var body = DataHelper.HexToByte(str);
- SocketClient client = new SocketClient();
- try
- {
- string ip = System.Web.Configuration.WebConfigurationManager.AppSettings["ip"].ToString();
- int port = System.Web.Configuration.WebConfigurationManager.AppSettings["port"].ToInt32();
- client.Connect(ip, port);
- var flag = client.SendData(body);
- //string mip = System.Web.Configuration.WebConfigurationManager.AppSettings["mongoip"].ToString();
- //MongoDbHelper mh = new MongoDbHelper(mip, "1000");
- //var querywhere = MongoDB.Driver.Builders.Query<ApplyCarLock>.Where(xx => xx.carid == carid);
- //var applymod = mh.FindOne<ApplyCarLock>(querywhere);
- //if (applymod.IsNull())
- //{
- // ApplyCarLock userCar = new ApplyCarLock();
- // userCar.carid = carid;
- // userCar.apply_type = 2;
- // userCar.state = 0;
- // userCar.add_name = "服务";
- // var carflag = mh.Insert(userCar);
- //}
- //else
- //{
- // var update = new MongoDB.Driver.UpdateDocument { { "$set", new MongoDB.Driver.QueryDocument { { "apply_type", 2 }, { "state", 0 } } } };
- // var querystr = MongoDB.Driver.Builders.Query<ApplyCarLock>.Where(xx => xx.carid == carid);
- // if (mh.Update<ApplyCarLock>(querystr, update))
- // {
- // }
- //}
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取公告信息" }
- };
- var reslutlock = orm.UpdateByLambda<YW_Apply_CarLock>(p => new YW_Apply_CarLock { state = 2 }, f => f.carid == carid && f.state == 0, res);
- if (reslutlock.IsSuccess)
- {
- }
- YW_Apply_CarLock apply_CarLock = new YW_Apply_CarLock();
- apply_CarLock.ID = Guid.NewGuid();
- apply_CarLock.apply_type = 2;
- apply_CarLock.apply_name = applyName;
- apply_CarLock.reason = applyReason;
- apply_CarLock.carid = carid;
- apply_CarLock.add_time = DateTime.Now;
- apply_CarLock.state = 0;
- apply_CarLock.add_name = "管理员";
- orm.Save(apply_CarLock, res);
- }
- client.Disconnect();
- }
- catch (Exception ex)
- {
- }
- }
- else
- {
- json.Msg = "申请密码不正确!";
- json.Status = "n";
- }
- //json.Data = Common.JsonConverter.Serialize(this.CodeAreaManage.LoadListAll(p => p.LEVELS == 1));
- return Json(json, JsonRequestBehavior.AllowGet);
- }
- /// <summary>
- /// 导出excel
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- [UserAuthorizeAttribute(ModuleAlias = "carList", OperaAction = "View")]
- public FileResult Excel()
- {
- //获取list数据
- List<string> list = new List<string>();
- //创建Excel文件的对象
- NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook(); string distributorsID = string.Empty; string CarSate = Request.QueryString["CarSate"];
- //添加一个sheet
- NPOI.SS.UserModel.ISheet sheet1 = book.CreateSheet("Sheet1");
- //给sheet1添加第一行的头部标题
- NPOI.SS.UserModel.IRow row1 = sheet1.CreateRow(0);
- row1.CreateCell(0).SetCellValue("农机IMEI号");
- row1.CreateCell(1).SetCellValue("农机名称");
- row1.CreateCell(2).SetCellValue("车架号");
- row1.CreateCell(3).SetCellValue("所属经销商");
- row1.CreateCell(4).SetCellValue("车辆状态");
- row1.CreateCell(5).SetCellValue("出厂日期");
- //将数据逐步写入sheet1各个行
- if (!Request.QueryString["distributorsid"].IsEmpty())
- {
- distributorsID = Request.QueryString["distributorsid"].ToString();
- }
- if (!distributorsID.IsEmpty())
- {
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取公告信息" }
- };
- var q = orm.Queryable<EntYW_Bicycle>();
- if (!CarSate.IsEmpty())
- {
- int state = CarSate.ToInt32();
- q = q.Where(p => p.DistributorsID == distributorsID && p.CarSate == state);
- }
- else
- {
- q = q.Where(p => p.DistributorsID == distributorsID);
- }
- var reslut = q.ToList(res);
- if (reslut.IsSuccess)
- {
- List<EntYW_Bicycle> modlist = reslut.ResultModel;
- for (int i = 0; i < modlist.Count; i++)
- {
- NPOI.SS.UserModel.IRow rowtemp = sheet1.CreateRow(i + 1);
- rowtemp.CreateCell(0).SetCellValue(modlist[i].CarID);
- rowtemp.CreateCell(1).SetCellValue(modlist[i].CarName);
- rowtemp.CreateCell(2).SetCellValue(modlist[i].CarNumber);
- rowtemp.CreateCell(3).SetCellValue(modlist[i].DistributorsName);
- rowtemp.CreateCell(4).SetCellValue(GetCarState.getCarStateStr(modlist[i].CarSate.ToInt32()));
- rowtemp.CreateCell(5).SetCellValue(modlist[i].productionDate.ToString());
- //rowtemp.CreateCell(5).SetCellValue(list[i].iName);
- //rowtemp.CreateCell(6).SetCellValue(list[i].iPhone);
- //rowtemp.CreateCell(7).SetCellValue(list[i].IntegralSum);
- //rowtemp.CreateCell(8).SetCellValue(list[i].IntegralSy);
- //rowtemp.CreateCell(9).SetCellValue(list[i].IntegralKy);
- }
- }
- }
- }
- // 写入到客户端
- System.IO.MemoryStream ms = new System.IO.MemoryStream();
- book.Write(ms);
- ms.Seek(0, SeekOrigin.Begin);
- return File(ms, "application/vnd.ms-excel", "经销商库存信息.xls");
- }
- /// <summary>
- /// 导出excel
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- [UserAuthorizeAttribute(ModuleAlias = "carList", OperaAction = "View")]
- public FileResult AllCarExcel()
- {
- //获取list数据
- List<string> list = new List<string>();
- //创建Excel文件的对象
- NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook(); string distributorsID = string.Empty; string CarSate = Request.QueryString["CarSate"];
- List<string> namelist = new List<string>();
- //添加一个sheet
- NPOI.SS.UserModel.ISheet sheet1 = book.CreateSheet("Sheet1");
- //给sheet1添加第一行的头部标题
- NPOI.SS.UserModel.IRow row1 = sheet1.CreateRow(0);
- row1.CreateCell(0).SetCellValue("农机IMEI号");
- row1.CreateCell(1).SetCellValue("农机名称");
- row1.CreateCell(2).SetCellValue("车架号");
- row1.CreateCell(3).SetCellValue("所属经销商");
- row1.CreateCell(4).SetCellValue("车辆状态");
- row1.CreateCell(5).SetCellValue("出厂日期");
- //将数据逐步写入sheet1各个行
- if (!Request.QueryString["distributorsid"].IsEmpty())
- {
- distributorsID = Request.QueryString["distributorsid"].ToString();
- }
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取公告信息" }
- };
- var q = orm.Queryable<EntSYS_DISTRIBUTORS>();
- if (!Request.QueryString["hkprovid"].IsEmpty())
- {
- int provid = Request.QueryString["hkprovid"].ToInt32();
- q = q.Where(p => p.Province == provid);
- }
- if (!Request.QueryString["hkcityid"].IsEmpty())
- {
- int provid = Request.QueryString["hkcityid"].ToInt32();
- q = q.Where(p => p.City == provid);
- }
- var reslutd = q.ToList(res);
- if (reslutd.IsSuccess)
- {
- var modellist = reslutd.ResultModel;
- foreach (EntSYS_DISTRIBUTORS md in modellist)
- {
- namelist.Add(md.ID);
- }
- }
- }
- if (namelist.Count > 0)
- {
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取公告信息" }
- };
- var q = orm.Queryable<EntYW_Bicycle>();
- if (!CarSate.IsEmpty())
- {
- int state = CarSate.ToInt32();
- q = q.Where(p => namelist.Contains(p.DistributorsID) && p.CarSate == state);
- }
- else
- {
- q = q.Where(p => namelist.Contains(p.DistributorsID));
- }
- var reslut = q.ToList(res);
- if (reslut.IsSuccess)
- {
- List<EntYW_Bicycle> modlist = reslut.ResultModel;
- for (int i = 0; i < modlist.Count; i++)
- {
- NPOI.SS.UserModel.IRow rowtemp = sheet1.CreateRow(i + 1);
- rowtemp.CreateCell(0).SetCellValue(modlist[i].CarID);
- rowtemp.CreateCell(1).SetCellValue(modlist[i].CarName);
- rowtemp.CreateCell(2).SetCellValue(modlist[i].carBar);
- rowtemp.CreateCell(3).SetCellValue(modlist[i].DistributorsName);
- rowtemp.CreateCell(4).SetCellValue(GetCarState.getCarStateStr(modlist[i].CarSate.ToInt32()));
- rowtemp.CreateCell(5).SetCellValue(modlist[i].productionDate.ToString());
- //rowtemp.CreateCell(5).SetCellValue(list[i].iName);
- //rowtemp.CreateCell(6).SetCellValue(list[i].iPhone);
- //rowtemp.CreateCell(7).SetCellValue(list[i].IntegralSum);
- //rowtemp.CreateCell(8).SetCellValue(list[i].IntegralSy);
- //rowtemp.CreateCell(9).SetCellValue(list[i].IntegralKy);
- }
- }
- }
- }
- // 写入到客户端
- System.IO.MemoryStream ms = new System.IO.MemoryStream();
- book.Write(ms);
- ms.Seek(0, SeekOrigin.Begin);
- return File(ms, "application/vnd.ms-excel", "经销商库存信息.xls");
- }
- /// <summary>
- /// 导出电子围栏内外的数据
- /// </summary>
- /// <returns></returns>
- public FileResult FenceExcel()
- {
- //获取list数据
- List<string> list = new List<string>();
- //创建Excel文件的对象
- NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook(); string distributorsID = string.Empty; string CarSate = Request.QueryString["CarSate"];
- var cartype = Request.QueryString["cartype"];
- var fencetype = Request.QueryString["fencetype"];
- var dptid = Request.QueryString["dptid"];
- //添加一个sheet
- NPOI.SS.UserModel.ISheet sheet1 = book.CreateSheet("Sheet1");
- //给sheet1添加第一行的头部标题
- NPOI.SS.UserModel.IRow row1 = sheet1.CreateRow(0);
- row1.CreateCell(0).SetCellValue("农机IMEI号");
- row1.CreateCell(1).SetCellValue("农机名称");
- row1.CreateCell(2).SetCellValue("农机型号");
- row1.CreateCell(3).SetCellValue("车架号");
- row1.CreateCell(4).SetCellValue("所属经销商");
- row1.CreateCell(5).SetCellValue("围栏状态");
- row1.CreateCell(6).SetCellValue("出厂日期");
- row1.CreateCell(7).SetCellValue("出厂编号");
- //将数据逐步写入sheet1各个行
- if (!Request.QueryString["distributorsid"].IsEmpty())
- {
- distributorsID = Request.QueryString["distributorsid"].ToString();
- }
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取公告信息" }
- };
- var q = orm.Queryable<EntYW_Bicycle>();
- if (!cartype.IsEmpty())
- {
- int typecar = cartype.ToInt32();
- q = q.Where(p => p.carType == typecar);
- }
- if (!fencetype.IsEmpty())
- {
- int typefence = fencetype.ToInt32();
- if (typefence >= 0)
- q = q.Where(p => p.FenceState == typefence);
- }
- if (!dptid.IsEmpty())
- {
- q = q.Where(p => p.DistributorsID == dptid);
- }
- var reslut = q.ToList(res);
- if (reslut.IsSuccess)
- {
- List<EntYW_Bicycle> modlist = reslut.ResultModel;
- for (int i = 0; i < modlist.Count; i++)
- {
- NPOI.SS.UserModel.IRow rowtemp = sheet1.CreateRow(i + 1);
- rowtemp.CreateCell(0).SetCellValue(modlist[i].CarID);
- rowtemp.CreateCell(1).SetCellValue(modlist[i].CarName);
- rowtemp.CreateCell(2).SetCellValue(modlist[i].CarModel);
- rowtemp.CreateCell(3).SetCellValue(modlist[i].carBar);
- rowtemp.CreateCell(4).SetCellValue(modlist[i].DistributorsName);
- string carstatestr = "";
- switch (modlist[i].FenceState)
- {
- case 0:
- carstatestr = "未点火"; break;
- case 1:
- carstatestr = "围栏内"; break;
- case 2:
- carstatestr = "围栏外"; break;
- }
- rowtemp.CreateCell(5).SetCellValue(carstatestr);
- rowtemp.CreateCell(6).SetCellValue(modlist[i].productionDate.ToString());
- rowtemp.CreateCell(7).SetCellValue(modlist[i].FactoryNumber.ToString());
- //rowtemp.CreateCell(5).SetCellValue(list[i].iName);
- //rowtemp.CreateCell(6).SetCellValue(list[i].iPhone);
- //rowtemp.CreateCell(7).SetCellValue(list[i].IntegralSum);
- //rowtemp.CreateCell(8).SetCellValue(modlist[i].OutFenceDate.ToDateTime().ToString());
- //var num = DateTimeUtility.DateTimeDifference(Convert.ToDateTime(modlist[i].OutFenceDate), DateTime.Now);
- //rowtemp.CreateCell(9).SetCellValue(num);
- //orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- //string sql = "select count(1) as num from YW_AlarmInformation where CarId='" + modlist[i].CarID + "' group by CarId";
- //var sum = orm.db.ExecuteScalar(sql);
- //rowtemp.CreateCell(10).SetCellValue(sum.ToDou());
- }
- }
- }
- // 写入到客户端
- System.IO.MemoryStream ms = new System.IO.MemoryStream();
- book.Write(ms);
- ms.Seek(0, SeekOrigin.Begin);
- return File(ms, "application/vnd.ms-excel", "农机信息.xls");
- }
- /// <summary>
- /// 导出电子围栏内外的数据
- /// </summary>
- /// <returns></returns>
- [UserAuthorizeAttribute(ModuleAlias = "machineryList", OperaAction = "List")]
- public FileResult CarTripExcel()
- {
- //获取list数据
- List<string> list = new List<string>();
- //创建Excel文件的对象
- NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook(); string distributorsID = string.Empty; string CarSate = Request.QueryString["CarSate"];
- var cartype = Request.QueryString["cartype"];
- var fencetype = Request.QueryString["fencetype"];
- var dptid = Request.QueryString["dptid"];
- var carid = Request.QueryString["carid"];
- //添加一个sheet
- NPOI.SS.UserModel.ISheet sheet1 = book.CreateSheet("Sheet1");
- //给sheet1添加第一行的头部标题
- NPOI.SS.UserModel.IRow row1 = sheet1.CreateRow(0);
- row1.CreateCell(0).SetCellValue("农机IMEI号");
- row1.CreateCell(1).SetCellValue("开始时间");
- row1.CreateCell(2).SetCellValue("线束时间");
- row1.CreateCell(3).SetCellValue("工作时长");
- //将数据逐步写入sheet1各个行
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItemLog");
- RequestModel res = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取公告信息" }
- };
- var q = orm.Queryable<Ent_YW_CarTrip>();
- if (!carid.IsEmpty())
- {
- q = q.Where(p => p.IMEI == carid);
- }
- var reslut = q.ToList(res);
- if (reslut.IsSuccess)
- {
- List<Ent_YW_CarTrip> modlist = reslut.ResultModel;
- for (int i = 0; i < modlist.Count; i++)
- {
- NPOI.SS.UserModel.IRow rowtemp = sheet1.CreateRow(i + 1);
- rowtemp.CreateCell(0).SetCellValue(modlist[i].IMEI);
- rowtemp.CreateCell(1).SetCellValue(modlist[i].StartDate.ToString());
- rowtemp.CreateCell(2).SetCellValue(modlist[i].EndDate.ToString());
- rowtemp.CreateCell(3).SetCellValue(modlist[i].WorkingHours.ToString());
- }
- }
- }
- // 写入到客户端
- System.IO.MemoryStream ms = new System.IO.MemoryStream();
- book.Write(ms);
- ms.Seek(0, SeekOrigin.Begin);
- return File(ms, "application/vnd.ms-excel", "农机工作时长记录.xls");
- }
- [UserAuthorizeAttribute(ModuleAlias = "SalesCarList", OperaAction = "View")]
- public ActionResult carmap(string id)
- {
- UserCarMapModel userCar = new UserCarMapModel();
- EntYW_Bicycle mod = new EntYW_Bicycle(); string imageUrl = string.Empty;
- if (!id.IsEmpty())
- {
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel request = new RequestModel();
- request.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取单车信息" };
- // Guid guid = new Guid(id);
- //YW_CarHeartbeat beatmod = new YW_CarHeartbeat();
- var reslut = orm.Queryable<EntYW_Bicycle>().Where(p => p.CarID == id).FirstOrDefault(request);
- if (reslut.IsSuccess)
- {
- mod = reslut.ResultModel;
- var qq = orm.Queryable<YW_CarPurchaser>().Where(p => p.carId == id).FirstOrDefault(request);
- if (qq.IsSuccess)
- {
- YW_CarPurchaser purchaser = qq.ResultModel;
- userCar.purchaserName = purchaser.userName;
- userCar.purchaserTel = purchaser.userTel;
- userCar.purchaserTime = purchaser.addDate.ToDateTime();
- }
- DateTime onlineDate = DateTime.Now;
- var beatreslut = orm.Queryable<DeviceManage>().Where(p => p.IMEI == mod.CarID).FirstOrDefault();
- if (beatreslut.IsSuccess)
- {
- DeviceManage devmod = beatreslut.ResultModel;
- onlineDate = devmod.LastOnlineTime.ToDateTime();
- var GPS = Ant.SuperSocket.Common.ToolGPSamap.GPSToGDGPS(devmod.longitude.ToDou(), devmod.latitude.ToDou());
- userCar.lat = GPS.Split(',')[1];
- userCar.lng = GPS.Split(',')[0];
- userCar.LBS = devmod.IsLBS.ToBool();
- }
- //else
- //{
- // var lbsreslut = orm.Queryable<YW_CarHeartbeat>().Where(p => p.imei == mod.CarID && p.locationtype == 1).OrderByDesc(p => p.add_time).FirstOrDefault();
- // if (lbsreslut.IsSuccess)
- // {
- // beatmod = lbsreslut.ResultModel;
- // var gps = Ant.SuperSocket.Common.WebApiHelp.getLocationGPS(mod.CarID, beatmod.mcc.ToInt32(), beatmod.mnc.ToInt32(), beatmod.lac.ToInt32(), beatmod.cellID.ToInt32(), beatmod.rssi.ToInt32());
- // beatmod.lng = gps.result.location.Split(',')[0].ToDec();
- // beatmod.lat = gps.result.location.Split(',')[1].ToDec();
- // var GPS = Ant.SuperSocket.Common.ToolGPSamap.GPSToGDGPS(beatmod.lng.ToDou(), beatmod.lat.ToDou());
- // userCar.lat = GPS.Split(',')[1];
- // userCar.lng = GPS.Split(',')[0];
- // userCar.LBS = true;
- // }
- //}
- userCar.distributorsName = mod.DistributorsName;
- userCar.barCode = mod.carBar;
- userCar.carId = mod.CarID;
- userCar.isOnLine = mod.LeaseStatus.ToInt32();
- userCar.carName = mod.CarName;
- userCar.FactoryNumber = mod.FactoryNumber;
- userCar.CarModel = mod.CarModel;
- StringBuilder sb = new StringBuilder("当前车辆的");
- userCar.carState = mod.CarSate.ToInt32();
- userCar.carNote = GetCarState.getCarStateStr(mod.CarSate.ToInt32());
- userCar.LockState = mod.LockState.ToBool();
- userCar.onlineDate = "最后上报时间:" + onlineDate.ToString("yyyy-MM-dd HH:mm:ss");
- string ip = System.Web.Configuration.WebConfigurationManager.AppSettings["mongoip"].ToString();
- MongoDbHelper mh = new MongoDbHelper(ip, "1000");
- var querywhere = MongoDB.Driver.Builders.Query<userNewCarECUInfos>.Where(xx => xx.carId == mod.CarID);
- var modstate = mh.FindOne<userNewCarECUInfos>(querywhere);
- if (modstate.IfNotNull())
- {
- userCar.hydraulic = modstate.hydraulic;
- userCar.speed = modstate.speed;
- userCar.temperature = modstate.temperature;
- userCar.voltage = modstate.voltage;
- if (userCar.hydraulic.ToInt32() > 0)
- {
- sb.AppendFormat("油压:" + userCar.hydraulic + "KPa");
- }
- if (userCar.temperature.ToInt32() > 0)
- {
- sb.AppendFormat("水温:" + userCar.temperature + "℃");
- }
- if (userCar.speed.ToInt32() > 0)
- {
- sb.AppendFormat("转速:" + userCar.speed);
- }
- if (userCar.voltage.ToInt32() > 0)
- {
- userCar.voltage = (userCar.voltage.ToDou()).ToString("0.00");
- sb.AppendFormat("蓄电池电压:" + userCar.voltage + "V");
- }
- if (userCar.lat.ToDou() > 0 && userCar.lng.ToDou() > 0)
- {
- var resaddress = Ant.SuperSocket.Common.ToolGPSamap.GPSToPositionString(userCar.lng.ToDou(), userCar.lat.ToDou());
- if (resaddress.Length > 0)
- {
- if (userCar.LBS)
- userCar.address = "LBS位置:" + resaddress;
- else
- userCar.address = "GPS位置:" + resaddress;
- }
- }
- }
- else
- {
- userCar.hydraulic = "0";
- userCar.temperature = "0";
- userCar.speed = "0";
- userCar.voltage = "0";
- }
- userCar.carType = mod.carType.ToInt32();
- userCar.Note = sb.ToString();
- var strurl = ((System.Web.HttpRequestWrapper)Request).Url.Authority;
- var proudctline = mod.ProductLine;
- switch (proudctline)
- {
- case 601://轮式拖拉机
- {
- imageUrl = "http://47.96.20.14:8086/upload/png/轮式拖拉机.png";
- }
- break;
- case 615://轮式收割机
- {
- imageUrl = "http://47.96.20.14:8086/upload/png/轮式收割机.png";
- }
- break;
- case 61101://手扶插秧机
- {
- imageUrl = "http://47.96.20.14:8086/upload/png/手扶插秧机.png";
- }
- break;
- case 61102://高速插秧机
- {
- imageUrl = "http://47.96.20.14:8086/upload/png/高速插秧机.png";
- }
- break;
- case 628://花生收获机
- {
- imageUrl = "http://47.96.20.14:8086/upload/png/花生收获机.png";
- }
- break;
- case 612://履带收割机
- {
- imageUrl = "http://47.96.20.14:8086/upload/png/履带收割机.png";
- }
- break;
- case 622://轮式玉米收
- {
- imageUrl = "http://47.96.20.14:8086/upload/png/轮式玉米收.png";
- }
- break;
- default:
- {
- imageUrl = "http://47.96.20.14:8086/Content/map/map-marker-icon.png";
- }
- break;
- }
- userCar.imageUrl = imageUrl;
- //switch (mod.carType.ToInt32())
- //{
- // case 1:
- // {
- // if (mod.LeaseStatus == 0)
- // imageUrl = "http://47.96.20.14:8086/Content/map/tuolaji_hui_default.png";
- // else
- // imageUrl = "http://47.96.20.14:8086/Content/map/tlj.png";
- // }
- // break;
- // case 2:
- // {
- // if (mod.LeaseStatus == 0)
- // imageUrl = "http://47.96.20.14:8086/Content/map/shougeji_hui_default.png";
- // else
- // imageUrl = "http://47.96.20.14:8086/Content/map/sgj.png";
- // }
- // break;
- // case 3:
- // {
- // if (mod.LeaseStatus == 0)
- // imageUrl = "http://47.96.20.14:8086/Content/map/chayangji_hui_default.png";
- // else
- // imageUrl = "http://47.96.20.14:8086/Content/map/cyj.png";
- // }
- // break;
- //}
- //userCar.imageUrl = imageUrl;
- }
- }
- }
- return View(userCar);
- }
- //[UserAuthorizeAttribute(ModuleAlias = "machineryList", OperaAction = "View")]
- public ActionResult machinerymap(string id)
- {
- UserCarMapModel userCar = new UserCarMapModel();
- EntYW_Bicycle mod = new EntYW_Bicycle(); string imageUrl = string.Empty;
- if (!id.IsEmpty())
- {
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel request = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取单车信息" }
- };
- // Guid guid = new Guid(id);
- //YW_CarHeartbeat beatmod = new YW_CarHeartbeat();
- var reslut = orm.Queryable<EntYW_Bicycle>().Where(p => p.CarID == id).FirstOrDefault(request);
- if (reslut.IsSuccess)
- {
- mod = reslut.ResultModel;
- var qq = orm.Queryable<YW_CarPurchaser>().Where(p => p.carId == id).FirstOrDefault(request);
- if (qq.IsSuccess)
- {
- YW_CarPurchaser purchaser = qq.ResultModel;
- userCar.purchaserName = purchaser.userName;
- userCar.purchaserTel = purchaser.userTel;
- userCar.purchaserTime = purchaser.addDate.ToDateTime();
- }
- //string ip = System.Web.Configuration.WebConfigurationManager.AppSettings["mongoip"].ToString();
- //MongoDbHelper mh = new MongoDbHelper(ip, "1000");
- //var query = Query.And(Query.EQ("imei", mod.CarID));
- //var modgps = mh.FindOne<userLatestLocation>(query);
- //if (modgps.IfNotNull())
- //{
- // var GPS = Ant.SuperSocket.Common.ToolGPSamap.GPSToGDGPS(modgps.lng.ToDou(), modgps.lat.ToDou());
- // userCar.lat = GPS.Split(',')[1];
- // userCar.lng = GPS.Split(',')[0];
- // beatmod.add_time = modgps.add_time;
- // userCar.LBS = false;
- //}
- var reslutgps = orm.Queryable<DeviceManage>().Where(p => p.IMEI == mod.CarID).FirstOrDefault(request);
- if (reslutgps.IsSuccess)
- {
- DeviceManage beatenty = reslutgps.ResultModel;
- userCar.lat = beatenty.latitude.ToString();
- userCar.lng = beatenty.longitude.ToString();
- userCar.LBS = beatenty.IsLBS.ToBool();
- // userCar.onlineDate = beatenty.LastOnlineTime.ToDateTime().ToString("yyyy-MM-dd hh:mm:ss");
- userCar.onlineDate = "最后上报时间:" + beatenty.LastOnlineTime.ToDateTime().ToString("yyyy-MM-dd HH:mm:ss");
- }
- userCar.FactoryNumber = mod.FactoryNumber;
- userCar.distributorsName = mod.DistributorsName;
- userCar.barCode = mod.carBar;
- userCar.carId = mod.CarID;
- userCar.isOnLine = mod.LeaseStatus.ToInt32();
- userCar.carName = mod.CarName;
- StringBuilder sb = new StringBuilder("当前车辆的");
- userCar.carState = mod.CarSate.ToInt32();
- userCar.carNote = GetCarState.getCarStateStr(mod.CarSate.ToInt32());
- userCar.LockState = mod.LockState.ToBool();
- userCar.CarModel = mod.CarModel;
- //string ip = System.Web.Configuration.WebConfigurationManager.AppSettings["mongoip"].ToString();
- //MongoDbHelper mh = new MongoDbHelper(ip, "1000");
- //var querywhere = MongoDB.Driver.Builders.Query<userNewCarECUInfos>.Where(xx => xx.carId == mod.CarID);
- //var modstate = mh.FindOne<userNewCarECUInfos>(querywhere);
- //if (modstate.IfNotNull())
- //{
- // userCar.hydraulic = modstate.hydraulic;
- // userCar.speed = modstate.speed;
- // userCar.temperature = modstate.temperature;
- // userCar.voltage = modstate.voltage;
- // if (userCar.hydraulic.ToInt32() > 0)
- // {
- // sb.AppendFormat("油压:" + userCar.hydraulic + "KPa");
- // }
- // if (userCar.temperature.ToInt32() > 0)
- // {
- // sb.AppendFormat("水温:" + userCar.temperature + "℃");
- // }
- // if (userCar.speed.ToInt32() > 0)
- // {
- // sb.AppendFormat("转速:" + userCar.speed);
- // }
- // if (userCar.voltage.ToInt32() > 0)
- // {
- // userCar.voltage = (userCar.voltage.ToDou() / 1000).ToString("0.00");
- // sb.AppendFormat("蓄电池电压:" + userCar.voltage + "V");
- // }
- // orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- // string sql = "SELECT CAST(SUM(WorkingHours) AS INT) AS [C] FROM YW_CarTrip where imei='" + mod.CarID + "'";
- // var sum = orm.db.ExecuteScalar(sql);
- // string workhours = DateTimeUtility.MinuteToHour(sum.ToDou());
- // //sb.AppendFormat("工作时长:" + workhours);
- // userCar.workHours = "工作时长:" + workhours;
- //}
- //else
- //{
- // userCar.hydraulic = "0";
- // userCar.temperature = "0";
- // userCar.speed = "0";
- // userCar.voltage = "0";
- //}
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- request.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "查询菜单的单个实体方法" };
- var reslutcar = orm.Queryable<YW_CarParamDetails>().Where(p => p.imei == mod.CarID).FirstOrDefault(request);
- if (reslutcar.IsSuccess)
- {
- YW_CarParamDetails locatmod = reslutcar.ResultModel;
- userCar.hydraulic = locatmod.hydraulic + " KPa";
- userCar.speed = locatmod.speed + " 转";
- userCar.temperature = locatmod.temperature + " ℃";
- var v = (locatmod.voltage.ToDou()).ToString("0.00");
- userCar.voltage = v + " V";
- }
- else
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItemLog");
- request.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "查询菜单的单个实体方法" };
- var reslutparm = orm.Queryable<YW_CarParamDetails>().Where(p => p.imei == mod.CarID).FirstOrDefault(request);
- if (reslutparm.IsSuccess)
- {
- YW_CarParamDetails locatmod = reslutparm.ResultModel;
- userCar.hydraulic = locatmod.hydraulic + " KPa";
- userCar.speed = locatmod.speed + " 转";
- userCar.temperature = locatmod.temperature + " ℃";
- var v = (locatmod.voltage.ToDou()).ToString("0.00");
- userCar.voltage = v + " V";
- }
- else
- {
- userCar.hydraulic = "0 KPa";
- userCar.temperature = "0 ℃";
- userCar.speed = "0 转";
- userCar.voltage = "0 V";
- }
- }
- if (userCar.lat.ToDou() > 0 && userCar.lng.ToDou() > 0)
- {
- var resaddress = ToolGPSamap.GPSToPositionString(userCar.lng.ToDou(), userCar.lat.ToDou());
- if (resaddress.Length > 0)
- {
- if (userCar.LBS)
- userCar.address = "LBS位置:" + resaddress;
- else
- userCar.address = "GPS位置:" + resaddress;
- }
- }
- userCar.carType = mod.carType.ToInt32();
- userCar.Note = sb.ToString();
- var strurl = ((System.Web.HttpRequestWrapper)Request).Url.Authority;
- var proudctline = mod.ProductLine;
- switch (proudctline)
- {
- case 601://轮式拖拉机
- {
- imageUrl = "http://47.96.20.14:8086/upload/png/轮式拖拉机.png";
- }
- break;
- case 615://轮式收割机
- {
- imageUrl = "http://47.96.20.14:8086/upload/png/轮式收割机.png";
- }
- break;
- case 61101://手扶插秧机
- {
- imageUrl = "http://47.96.20.14:8086/upload/png/手扶插秧机.png";
- }
- break;
- case 61102://高速插秧机
- {
- imageUrl = "http://47.96.20.14:8086/upload/png/高速插秧机.png";
- }
- break;
- case 628://花生收获机
- {
- imageUrl = "http://47.96.20.14:8086/upload/png/花生收获机.png";
- }
- break;
- case 612://履带收割机
- {
- imageUrl = "http://47.96.20.14:8086/upload/png/履带收割机.png";
- }
- break;
- case 622://轮式玉米收
- {
- imageUrl = "http://47.96.20.14:8086/upload/png/轮式玉米收.png";
- }
- break;
- default:
- {
- imageUrl = "http://47.96.20.14:8086/Content/map/map-marker-icon.png";
- }
- break;
- }
- userCar.imageUrl = imageUrl;
- // switch (mod.carType.ToInt32())
- // {
- // case 1:
- // {
- // if (mod.LeaseStatus == 0)
- // imageUrl = "http://47.96.20.14:8086/Content/map/tuolaji_hui_default.png";
- // else
- // imageUrl = "http://47.96.20.14:8086/Content/map/tlj.png";
- // }
- // break;
- // case 2:
- // {
- // if (mod.LeaseStatus == 0)
- // imageUrl = "http://47.96.20.14:8086/Content/map/shougeji_hui_default.png";
- // else
- // imageUrl = "http://47.96.20.14:8086/Content/map/sgj.png";
- // }
- // break;
- // case 3:
- // {
- // if (mod.LeaseStatus == 0)
- // imageUrl = "http://47.96.20.14:8086/Content/map/chayangji_hui_default.png";
- // else
- // imageUrl = "http://47.96.20.14:8086/Content/map/cyj.png";
- // }
- // break;
- // }
- // userCar.imageUrl = imageUrl;
- }
- }
- }
- return View(userCar);
- }
- /// <summary>
- /// 加载用户详情信息(基本)
- /// </summary>
- [UserAuthorizeAttribute(ModuleAlias = "salesCarList", OperaAction = "Detail")]
- public ActionResult Detail(string id)
- {
- try
- {
- ViewData["distributorsid"] = Request["distributorsid"];
- ViewData["distributorName"] = Request["distributorName"];
- Ent_YW_Bicycle mod = new Ent_YW_Bicycle();
- if (!id.IsEmpty())
- {
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel request = new RequestModel();
- request.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取单车信息" };
- mod.ID = new Guid(id);
- var reslut = orm.GetEntity(mod, request);
- if (reslut.IsSuccess)
- {
- mod = reslut.ResultModel;
- }
- }
- }
- ViewData["levels"] = this.CodeManage.LoadAll(p => p.CODETYPE == "CLLB").ToList();
- ViewData["cartype"] = this.CodeManage.LoadAll(p => p.CODETYPE == "XMLX").ToList();
- int uid = 0;
- if (CurrentUser.USERTYPE == 2)
- {
- uid = CurrentUser.Id;
- }
- ViewBag.dpt = this.DepartmentManage.GetDepartmentByDetailNew(uid);
- return View(mod);
- }
- catch (Exception e)
- {
- WriteLog(enumOperator.Select, "加载用户详情发生错误:", e);
- throw e.InnerException;
- }
- }
- /// <summary>
- /// 保存农机车辆
- /// </summary>
- [UserAuthorizeAttribute(ModuleAlias = "salesCarList", OperaAction = "Add,Edit")]
- public ActionResult Save(Ent_YW_Bicycle entity)
- {
- bool isEdit = false;
- string disid = Request.Form["distributorsid"]; string disname = Request.Form["distributorName"];
- //var mod = this.DepartmentManage.Get(p => p.ID == disid);
- JsonHelper json = new JsonHelper() { Msg = "保存车辆成功", Status = "n", ReUrl = "/Car/Index" };
- try
- {
- if (entity != null)
- {
- var _entity = new Ent_YW_Bicycle();
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- if (entity.ID.IsNull())
- {
- var count = orm.Queryable<Ent_YW_Bicycle>().Where(p => p.CarID == entity.CarID).Count();
- if (count > 0)
- {
- json.Msg = "二维码不能重复绑定!";
- }
- else
- {
- var num = orm.Queryable<Ent_YW_Bicycle>().Where(p => p.carBar == entity.carBar).Count();
- if (num > 0)
- {
- json.Msg = "条码不能重复绑定!";
- }
- else
- {
- _entity = entity;
- _entity.ID = Guid.NewGuid();
- _entity.CreateDate = DateTime.Now;
- _entity.Createper = CurrentUser.Name;
- _entity.UpdateDate = DateTime.Now;
- _entity.UpdateUser = this.CurrentUser.Name;
- _entity.DistributorsID = disid;
- _entity.DistributorsName = disname;
- //_entity.CarSate = 4;
- _entity.LockState = false;
- RequestModel res = new RequestModel();
- res.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取单车信息" };
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- var reslutsave = orm.Save(_entity, res);
- if (reslutsave.IsSuccess)
- {
- json.Status = "y";
- }
- else
- {
- json.Msg = "保存失败";
- }
- }
- }
- }
- else
- {
- RequestModel request = new RequestModel();
- request.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取单车信息" };
- _entity.ID = entity.ID;
- var reslut = orm.GetEntity(_entity, request);
- if (reslut.IsSuccess)
- {
- _entity = reslut.ResultModel;
- _entity.CarName = entity.CarName;
- _entity.FactoryNumber = entity.FactoryNumber;
- _entity.UpdateDate = DateTime.Now;
- _entity.UpdateUser = this.CurrentUser.Name;
- _entity.CarID = entity.CarID;
- _entity.CarModel = entity.CarModel;
- _entity.CarSate = entity.CarSate;
- _entity.LeaseStatus = entity.LeaseStatus;
- _entity.lang = entity.lang;
- _entity.DistributorsID = disid;
- _entity.carType = entity.carType;
- _entity.DistributorsName = disname;
- }
- _entity.LockState = false;
- RequestModel res = new RequestModel();
- res.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取单车信息" };
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- var reslutsave = orm.Save(_entity, res);
- if (reslutsave.IsSuccess)
- {
- json.Status = "y";
- }
- else
- {
- json.Msg = "保存失败";
- }
- }
- }
- //判断岗位是否重名
- //if (!this.PostManage.IsExist(p => p.POSTNAME == entity.POSTNAME && p.ID != entity.ID))
- //{
- // if (PostManage.SaveOrUpdate(entity, isEdit))
- // {
- // json.Status = "y";
- // }
- // else
- // {
- // json.Msg = "保存失败";
- // }
- //}
- //else
- //{
- // json.Msg = "岗位" + entity.POSTNAME + "已存在,不能重复添加";
- //}
- }
- else
- {
- json.Msg = "未找到需要保存的车辆信息";
- }
- if (isEdit)
- {
- WriteLog(enumOperator.Edit, "修改车辆信息,结果:" + json.Msg, enumLog4net.INFO);
- }
- else
- {
- WriteLog(enumOperator.Add, "添加车辆信息,结果:" + json.Msg, enumLog4net.INFO);
- }
- }
- catch (Exception e)
- {
- json.Msg = "保存车辆信息发生内部错误!";
- WriteLog(enumOperator.None, "保存车辆信息:", e);
- }
- return Json(json);
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public ActionResult CarAllocateList(string id)
- {
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel request = new RequestModel();
- request.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "查询菜单的单个实体方法" };
- var q = orm.Queryable<yw_machinery_return>().Where(p => p.carid == id);
- int pageno = (page - 1) * pagesize;
- var reslut = q.OrderByDesc(a => a.add_time).Skip(pageno).Top(pagesize).ToList(request);
- if (reslut.IsSuccess)
- {
- reslut.RecordNum = q.Count();
- return View(new PageInfo(base.page, base.pagesize, reslut.RecordNum, JsonConverter.JsonClass(reslut.ResultModel)));
- }
- var mod = new PageInfo(base.page, base.pagesize, reslut.RecordNum, JsonConverter.JsonClass(new List<yw_machinery_return>()));
- return View(mod);
- }
- }
- /// <summary>
- /// 绑定页面需要的属性
- /// </summary>
- public PageInfo BindList(int posttype, string FK_DPTID, int CarSate)
- {
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel request = new RequestModel();
- request.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "查询菜单的单个实体方法" };
- var q = orm.Queryable<EntYW_Bicycle>();
- if (!FK_DPTID.IsEmpty())
- {
- var resultdd = orm.Queryable<EntSYS_DISTRIBUTORS>().Where(p => p.ID == FK_DPTID && p.BUSINESSLEVEL == 1).Count();
- if (resultdd == 0)
- {
- q = q.Where(a => a.DistributorsID == FK_DPTID);//|| a.ScenicID == FK_DPTID
- }
- }
- if (CarSate >= 0)
- {
- q = q.Where(a => a.CarSate == CarSate);
- }
- if (!string.IsNullOrEmpty(keywords))
- {
- q = q.Where(p => p.CarName.Contains(keywords));
- }
- if (posttype > 0)
- {
- q = q.Where(p => p.carType == posttype);
- }
- int pageno = (page - 1) * pagesize;
- var reslut = q.OrderBy(a => a.ID).Skip(pageno).Top(pagesize).ToList(request);
- //var reslut= orm.SqlQuery<YW_Bicycle>(string.Format("select top {0} * from YW_Bicycle where Id>@Id", 1), new { Id = "sfdfdfdf" }).ToList();
- if (reslut.IsSuccess)
- {
- reslut.RecordNum = q.Count();
- List<EntYW_Bicycle> carlist = new List<EntYW_Bicycle>();
- foreach (EntYW_Bicycle mod in reslut.ResultModel)
- {
- int num = orm.Queryable<YW_UserCar>().Where(p => p.carId == mod.CarID).Count();
- if (num > 0)
- {
- mod.lang = "已绑定用户";
- }
- else
- {
- mod.lang = "未绑定用户";
- }
- carlist.Add(mod);
- }
- return new PageInfo(base.page, base.pagesize, reslut.RecordNum, JsonConverter.JsonClass(carlist));
- }
- else
- {
- return new PageInfo(base.page, base.pagesize, reslut.RecordNum, JsonConverter.JsonClass(new List<EntYW_Bicycle>()));
- }
- }
- //return new PageInfo(result.Index, result.PageSize, result.Count, JsonConverter.JsonClass(list));
- }
- }
- }
|