1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150 |
- using Aspose.Cells;
- using Aspose.Words;
- using EyeSoft.Extensions;
- using EyeSoft.Reflection;
- using NPOI.SS.Formula.Functions;
- using OASystem.API.OAMethodLib;
- using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
- using OASystem.Domain.Dtos.CRM;
- using OASystem.Domain.Dtos.Groups;
- using OASystem.Domain.Dtos.PersonnelModule;
- using OASystem.Domain.Entities.Groups;
- using OASystem.Domain.ViewModels.Groups;
- using OASystem.Domain.ViewModels.QiYeWeChat;
- using OASystem.Infrastructure.Repositories.Groups;
- using Org.BouncyCastle.Utilities.Encoders;
- using System.Data;
- using static OASystem.API.OAMethodLib.JWTHelper;
- using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
- namespace OASystem.API.Controllers
- {
- /// <summary>
- /// 资料相关
- /// </summary>
- //[Authorize]
- [Route("api/[controller]/[action]")]
- public class ResourceController : ControllerBase
- {
- private readonly IMapper _mapper;
- private readonly SqlSugarClient _sqlSugar;
- private readonly IConfiguration _config;
- private readonly CarDataRepository _carDataRep;
- private readonly LocalGuideDataRepository _localGuideDataRep;
- private readonly ThreeCodeRepository _ThreeCodeRep;
- private readonly HotelDataRepository _hotelDataRep;
- private readonly ResItemInfoRepository _resItemInfoRep;
- private readonly SetDataRepository _setDataRepository;
- private readonly CountryFeeRepository _countryFeeRep;
- private readonly SetDataTypeRepository _setDataTypeRep;
- private readonly AirTicketAgentRepository _airTicketAgentRep;
- private readonly InvitationOfficialActivityDataRepository _InvitationOfficialActivityDataRep;
- private readonly OfficialActivitiesRepository _officialActivitiesRep;
- private readonly AskDataRepository _askDataRep;
- private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
- private readonly TourClientListRepository _tourClientListRep;
- private readonly DelegationInfoRepository _delegationInfoRep;
- private readonly TranslatorLibraryRepository _translatorRep;
- public ResourceController(
- IMapper mapper,
- IConfiguration config,
- SqlSugarClient sqlSugar,
- CarDataRepository carDataRep,
- LocalGuideDataRepository localGuideDataRep,
- ThreeCodeRepository threeCodeRep,
- HotelDataRepository hotelDataRep,
- ResItemInfoRepository resItemInfoRep,
- SetDataRepository setDataRepository,
- CountryFeeRepository countryFeeRep,
- SetDataTypeRepository setDataTypeRep,
- AirTicketAgentRepository airTicketAgentRep,
- InvitationOfficialActivityDataRepository invitationOfficialActivityDataRep,
- OfficialActivitiesRepository officialActivitiesRep,
- AskDataRepository askDataRep,
- TicketBlackCodeRepository ticketBlackCodeRep,
- TourClientListRepository tourClientListRep,
- DelegationInfoRepository delegationInfoRep,
- TranslatorLibraryRepository translatorRep
- )
- {
- _mapper = mapper;
- _config = config;
- _sqlSugar = sqlSugar;
- _carDataRep = carDataRep;
- _localGuideDataRep = localGuideDataRep;
- _ThreeCodeRep = threeCodeRep;
- _hotelDataRep = hotelDataRep;
- _resItemInfoRep = resItemInfoRep;
- _setDataRepository = setDataRepository;
- _countryFeeRep = countryFeeRep;
- _setDataTypeRep = setDataTypeRep;
- _airTicketAgentRep = airTicketAgentRep;
- _InvitationOfficialActivityDataRep = invitationOfficialActivityDataRep;
- _officialActivitiesRep = officialActivitiesRep;
- _askDataRep = askDataRep;
- _ticketBlackCodeRep = ticketBlackCodeRep;
- _tourClientListRep = tourClientListRep;
- _delegationInfoRep = delegationInfoRep;
- _translatorRep = translatorRep;
- }
- #region 车公司资料板块
- /// <summary>
- /// 车公司信息查询
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryCarData(QueryCarDataDto dto)
- {
- try
- {
- Result LocalGuide = await _carDataRep.QueryCarData(dto);
- if (LocalGuide.Code == 0)
- {
- return Ok(JsonView(true, "查询成功", LocalGuide.Data));
- }
- else
- {
- return Ok(JsonView(false, LocalGuide.Msg));
- }
- }
- catch (Exception)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 车公司资料下拉框数据
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryCarSelect()
- {
- try
- {
- var CarData = _carDataRep.QueryDto<Res_CarData, CarDataSelectView>().ToList();
- if (CarData.Count == 0)
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- CarData.Add(new CarDataSelectView { Id = 0, UnitArea = "全部" });
- CarData = CarData.Where((x, i) => CarData.FindIndex(z => z.UnitArea == x.UnitArea) == i).ToList();
- CarData = CarData.OrderBy(x => x.Id).ToList();
- List<CarDataSelectView> data = new List<CarDataSelectView>();
- foreach (CarDataSelectView car in CarData)
- {
- if (!string.IsNullOrWhiteSpace(car.UnitArea))
- {
- data.Add(car);
- }
- }
- return Ok(JsonView(true, "查询成功", data));
- }
- catch (Exception)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 根据Id查询车公司详细数据
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QuerCarDataDetailById(QueryCarDataDetailDto dto)
- {
- string sql = string.Format(@" Select * From Res_CarData With(Nolock) Where Id = {0} ", dto.Id);
- CarDataDetailDataView info = _resItemInfoRep._sqlSugar.SqlQueryable<CarDataDetailDataView>(sql).First();
- if (info == null)
- {
- return Ok(JsonView(false, "未找到相关数据!"));
- }
- return Ok(JsonView(true, "查询成功", info));
- }
- /// <summary>
- /// 车公司信息添加
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> AddCarData(AddCarDataDto dto)
- {
- try
- {
- if (dto.UnitArea == "")
- {
- return Ok(JsonView(false, "请检查单位区域是否填写!"));
- }
- if (dto.UnitName == "")
- {
- return Ok(JsonView(false, "请检查单位名称是否填写!"));
- }
- if (dto.Contact == "")
- {
- return Ok(JsonView(false, "请检查单位联系人是否填写!"));
- }
- if (dto.ContactTel == "")
- {
- return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
- }
- var carDada = _carDataRep.QueryDto<Res_CarData, CarDataView>(a => a.UnitArea == dto.UnitArea && a.UnitName == dto.UnitName && a.Contact == dto.Contact && a.ContactTel == dto.ContactTel).ToList();
- if (carDada.Count != 0)
- {
- return Ok(JsonView(false, "该信息已存在,请勿重复添加!"));
- }
- Res_CarData _CarData = _mapper.Map<Res_CarData>(dto);
- int id = await _carDataRep.AddAsyncReturnId(_CarData);
- if (id == 0)
- {
- return Ok(JsonView(false, "添加失败!"));
- }
- return Ok(JsonView(true, "添加成功", new { Id = id }));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 车公司信息修改
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> UpCarData(UpCarDataDto dto)
- {
- try
- {
- if (dto.UnitArea == "")
- {
- return Ok(JsonView(false, "请检查单位区域是否填写!"));
- }
- if (dto.UnitName == "")
- {
- return Ok(JsonView(false, "请检查单位名称是否填写!"));
- }
- if (dto.Contact == "")
- {
- return Ok(JsonView(false, "请检查单位联系人是否填写!"));
- }
- if (dto.ContactTel == "")
- {
- return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
- }
- bool res = await _carDataRep.UpdateAsync(a => a.Id == dto.Id, a => new Res_CarData
- {
- UnitArea = dto.UnitArea,
- UnitName = dto.UnitName,
- Address = dto.Address,
- Contact = dto.Contact,
- ContactTel = dto.ContactTel,
- ContactEmail = dto.ContactEmail,
- ContactFax = dto.ContactFax,
- CarDes = dto.CarDes,
- CarPicPaths = dto.CarPicPaths,
- OtherInfo = dto.OtherInfo,
- Score = dto.Score,
- QualificationScore = dto.QualificationScore,
- CarAgeScore = dto.CarAgeScore,
- CleanImgScore = dto.CleanImgScore,
- SmellScore = dto.SmellScore,
- WaterPaperScore = dto.WaterPaperScore,
- HardwareScore = dto.HardwareScore,
- TimeScore = dto.TimeScore,
- SafetyScore = dto.SafetyScore,
- DrivingAgeScore = dto.DrivingAgeScore,
- Remark = dto.Remark,
- });
- if (!res) { return Ok(JsonView(false, "修改失败!")); }
- return Ok(JsonView(true, "修改成功"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 车公司信息删除
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelCarData(DelCarDataDto dto)
- {
- try
- {
- bool res = await _carDataRep.SoftDeleteByIdAsync<Res_CarData>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res) { return Ok(JsonView(false, "删除失败!")); }
- return Ok(JsonView(true, "删除成功"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- #endregion
- #region 导游地接资料板块
- /// <summary>
- /// 导游地接资料查询
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryLocalGuide(QueryLocalGuide dto)
- {
- try
- {
- Result LocalGuide = await _localGuideDataRep.QueryLocalGuide(dto);
- if (LocalGuide.Code == 0)
- {
- return Ok(JsonView(true, "查询成功", LocalGuide.Data));
- }
- else
- {
- return Ok(JsonView(false, LocalGuide.Msg));
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 导游地接资料下拉框数据
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryLocalGuideSelect()
- {
- try
- {
- var LocalGuide = _carDataRep.QueryDto<Res_LocalGuideData, QueryLocalGuideSelectView>().ToList();
- if (LocalGuide.Count == 0)
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- LocalGuide.Add(new QueryLocalGuideSelectView { Id = 0, UnitArea = "全部" });
- LocalGuide = LocalGuide.Where((x, i) => LocalGuide.FindIndex(z => z.UnitArea == x.UnitArea && z.UnitArea != "") == i).ToList();
- LocalGuide = LocalGuide.OrderBy(x => x.Id).ToList();
- List<QueryLocalGuideSelectView> data = new List<QueryLocalGuideSelectView>();
- foreach (QueryLocalGuideSelectView Local in LocalGuide)
- {
- if (!string.IsNullOrWhiteSpace(Local.UnitArea))
- {
- data.Add(Local);
- }
- }
- return Ok(JsonView(true, "查询成功", data));
- }
- catch (Exception)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 根据Id查询地接详细数据
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryLocalGuideDetailById(QueryLocalGuideDetailDto dto)
- {
- string sql = string.Format(@" Select * From Res_LocalGuideData With(Nolock) Where Id = {0} ", dto.Id);
- LocalGuideDetailDataView info = _resItemInfoRep._sqlSugar.SqlQueryable<LocalGuideDetailDataView>(sql).First();
- if (info == null)
- {
- return Ok(JsonView(false, "未找到相关数据!"));
- }
- return Ok(JsonView(true, "查询成功", info));
- }
- /// <summary>
- /// 导游地接信息操作(Status:1.新增,2.修改)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OperationLocalGuide(LocalGuideOperationDto dto)
- {
- try
- {
- if (dto.UnitArea == "")
- {
- return Ok(JsonView(false, "请检查单位区域是否填写!"));
- }
- if (dto.UnitName == "")
- {
- return Ok(JsonView(false, "请检查单位名称是否填写!"));
- }
- if (dto.Contact == "")
- {
- return Ok(JsonView(false, "请检查单位联系人是否填写!"));
- }
- if (dto.ContactTel == "")
- {
- return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
- }
- Result result = await _localGuideDataRep.LocalGuideOperation(dto);
- if (result.Code != 0)
- {
- return Ok(JsonView(false, result.Msg));
- }
- return Ok(JsonView(true, result.Msg));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 导游地接信息操作(删除)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelLocalGuide(LocalGuideDelDto dto)
- {
- try
- {
- var res = await _localGuideDataRep.SoftDeleteByIdAsync<Res_LocalGuideData>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- #endregion
- #region 机场三字码信息
- /// <summary>
- /// 机场三字码查询
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryThreeCode(QueryThreeCodeDto dto)
- {
- try
- {
- Result LocalGuide = await _ThreeCodeRep.QueryThreeCode(dto);
- if (LocalGuide.Code == 0)
- {
- return Ok(JsonView(true, "查询成功", LocalGuide.Data));
- }
- else
- {
- return Ok(JsonView(false, LocalGuide.Msg));
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 机场三字码数据城市下拉框数据
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryThreeCodeSelect()
- {
- try
- {
- var ThreeCode = _carDataRep.QueryDto<Res_ThreeCode, ThreeCodeSelectView>().ToList();
- if (ThreeCode.Count == 0)
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- ThreeCode.Add(new ThreeCodeSelectView { Id = 0, City = "全部" });
- ThreeCode = ThreeCode.Where((x, i) => ThreeCode.FindIndex(z => z.City == x.City && z.City != "") == i).ToList();
- ThreeCode = ThreeCode.OrderBy(x => x.Id).ToList();
- List<ThreeCodeSelectView> data = new List<ThreeCodeSelectView>();
- foreach (ThreeCodeSelectView _ThreeCode in ThreeCode)
- {
- if (!string.IsNullOrWhiteSpace(_ThreeCode.City))
- {
- data.Add(_ThreeCode);
- }
- }
- return Ok(JsonView(true, "查询成功", data));
- }
- catch (Exception)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 机场三字码资料操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OperationThreeCode(ThreeCodeOperationDto dto)
- {
- try
- {
- if (dto.Three == "")
- {
- return Ok(JsonView(false, "请检查三字码是否填写!"));
- }
- if (dto.Country == "")
- {
- return Ok(JsonView(false, "请检查国家是否填写!"));
- }
- if (dto.City == "")
- {
- return Ok(JsonView(false, "请检查城市是否填写正确!"));
- }
- if (dto.AirPort == "")
- {
- return Ok(JsonView(false, "请检查机场是否填写正确!"));
- }
- Result result = await _ThreeCodeRep.ThreeCodeOperation(dto);
- if (result.Code != 0)
- {
- return Ok(JsonView(false, result.Msg));
- }
- return Ok(JsonView(true, result.Msg));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 机场三字码资料操作(删除)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelThreeCode(ThreeCodeDelDto dto)
- {
- try
- {
- var res = await _ThreeCodeRep.SoftDeleteByIdAsync<Res_ThreeCode>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- ///根据ID查询三字码信息
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public IActionResult QuerySingleThreeCode(QuerySingleThreeCode dto)
- {
- var jw = JsonView(false);
- var single = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Id == dto.ID && x.IsDel == 0);
- if (single != null)
- {
- jw = JsonView(true, "获取成功!", new
- {
- single.Three,
- Four = single.Four?.Trim(),
- single.AirPort,
- single.AirPort_En,
- single.City,
- single.Country,
- single.Remark
- });
- }
- else
- {
- jw.Msg = "暂无!";
- }
- return Ok(jw);
- }
- #endregion
- #region 代理出票合作方资料
- /// <summary>
- /// 代理出票合作方资料
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryAirTicketAgent(DtoBase dto)
- {
- try
- {
- List<Res_AirTicketAgent> res_AirTicketAgents = _airTicketAgentRep.Query<Res_AirTicketAgent>(a => a.IsDel == 0).ToList();
- if (res_AirTicketAgents.Count != 0)
- {
- res_AirTicketAgents = res_AirTicketAgents.OrderByDescending(a => a.CreateTime).ToList();
- if (dto.PageSize == 0 && dto.PageIndex == 0)
- {
- return Ok(JsonView(true, "查询成功!", res_AirTicketAgents));
- }
- else
- {
- int count = res_AirTicketAgents.Count;
- float totalPage = (float)count / dto.PageSize;//总页数
- if (totalPage == 0) totalPage = 1;
- else totalPage = (int)Math.Ceiling((double)totalPage);
- List<Res_AirTicketAgent> _AirTicketAgent = new List<Res_AirTicketAgent>();
- for (int i = 0; i < dto.PageSize; i++)
- {
- var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
- if (RowIndex < res_AirTicketAgents.Count)
- {
- _AirTicketAgent.Add(res_AirTicketAgents[RowIndex]);
- }
- else
- {
- break;
- }
- }
- return Ok(JsonView(true, "查询成功!", new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = _AirTicketAgent }));
- }
- }
- else
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 代理出票合作方资料操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpAirTicketAgent(OpAirTicketAgentDto dto)
- {
- try
- {
- if (dto.Account == "")
- {
- return Ok(JsonView(false, "请检查代理商账户是否填写!"));
- }
- if (dto.Bank == "")
- {
- return Ok(JsonView(false, "请检查代理商银行是否填写!"));
- }
- if (dto.Name == "")
- {
- return Ok(JsonView(false, "请检查代理商名称是否填写正确!"));
- }
- Result result = await _airTicketAgentRep.OpAirTicketAgent(dto);
- if (result.Code != 0)
- {
- return Ok(JsonView(false, result.Msg));
- }
- return Ok(JsonView(true, result.Msg));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 代理出票合作方资料操作(删除)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelAirTicketAgent(DelBaseDto dto)
- {
- try
- {
- var res = await _airTicketAgentRep.SoftDeleteByIdAsync<Res_AirTicketAgent>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- #endregion
- #region 酒店资料数据
- /// <summary>
- /// 酒店信息查询 Page
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryHotelData(QueryHotelDataDto dto)
- {
- string sqlWhere = string.Empty;
- if (!string.IsNullOrWhiteSpace(dto.Name))
- {
- sqlWhere += string.Format(@" And hd.Name like '%{0}%'", dto.Name);
- }
- if (!string.IsNullOrWhiteSpace(dto.City) && dto.City != "全部")
- {
- sqlWhere += string.Format(@" And hd.City like '%{0}%'", dto.City);
- }
- if (!string.IsNullOrWhiteSpace(dto.Contact))
- {
- sqlWhere += string.Format(@" And hd.Contact like '%{0}%'", dto.Contact);
- }
- if (!string.IsNullOrWhiteSpace(dto.ContactPhone))
- {
- sqlWhere += string.Format(@" And hd.ContactPhone like '%{0}%'", dto.ContactPhone);
- }
- sqlWhere += string.Format(@" And hd.IsDel={0}", 0);
- if (!string.IsNullOrEmpty(sqlWhere.Trim()))
- {
- Regex r = new Regex("And");
- sqlWhere = r.Replace(sqlWhere, "Where", 1);
- }
- string sql = string.Format(@"SELECT
- *
- FROM
- (
- SELECT
- ROW_NUMBER() OVER (
- ORDER BY
- hd.CreateTime DESC
- ) AS Row_Number,
- hd.Id,
- hd.City,
- hd.[Name],
- hd.Tel,
- hd.Fax,
- hd.Contact,
- hd.ContactPhone,
- u.CnName AS CreateUserName,
- hd.CreateTime
- FROM
- Res_HotelData hd
- WITH
- (NoLock)
- LEFT JOIN Sys_Users u
- WITH
- (NoLock) ON hd.CreateUserId = u.Id {0}
- ) Temp
- ", sqlWhere);
- if (dto.PortType == 1)
- {
- List<HotelDataItemView> HotelDataData = await _sqlSugar.SqlQueryable<HotelDataItemView>(sql).ToListAsync();
- if (HotelDataData.Count == 0)
- {
- return Ok(JsonView(false, "暂无数据"));
- }
- return Ok(JsonView(true, "操作成功", HotelDataData));
- }
- else if (dto.PortType == 2 || dto.PortType == 3)
- {
- RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
- var data = await _sqlSugar.SqlQueryable<HotelDataItemView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total); //ToPageAsync
- return Ok(JsonView(true, "操作成功", data, total));
- }
- else return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
- }
- /// <summary>
- /// 酒店资料
- /// 详情
- /// add time:2024-05-14 11:57:10
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryHotelDataInfo(QueryHotelDataInfoDto dto)
- {
- var _view = await _hotelDataRep._Info(dto.PortType, dto.Id);
- if (_view.Code == 0)
- {
- return Ok(JsonView(true, _view.Msg, _view.Data));
- }
- return Ok(JsonView(false, _view.Msg));
- }
- /// <summary>
- /// 酒店资料下拉框数据
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryHotelDataSelect()
- {
- try
- {
- var HotelData = _carDataRep.QueryDto<Res_HotelData, QueryHotelDataSelect>().ToList();
- if (HotelData.Count == 0)
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- HotelData.Add(new QueryHotelDataSelect { Id = 0, City = "全部" });
- HotelData = HotelData.Where((x, i) => HotelData.FindIndex(z => z.City == x.City && z.City != "") == i).ToList();
- HotelData = HotelData.OrderBy(x => x.Id).ToList();
- List<QueryHotelDataSelect> data = new List<QueryHotelDataSelect>();
- foreach (QueryHotelDataSelect Hotel in HotelData)
- {
- if (!string.IsNullOrWhiteSpace(Hotel.City))
- {
- data.Add(Hotel);
- }
- }
- return Ok(JsonView(true, "查询成功", data));
- }
- catch (Exception)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 酒店资料操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OperationHotelData(OperationHotelDto dto)
- {
- if (string.IsNullOrEmpty(dto.City)) return Ok(JsonView(false, "请检查酒店所在城市是否填写!"));
- if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "请检查酒店名称是否填写!"));
- if (string.IsNullOrEmpty(dto.Address)) return Ok(JsonView(false, "请检查酒店地址是否填写正确!"));
- if (string.IsNullOrEmpty(dto.Tel)) return Ok(JsonView(false, "请检查酒店联系方式是否填写正确!"));
- Result result = await _hotelDataRep.OperationHotelData(dto);
- if (result.Code != 0) return Ok(JsonView(false, result.Msg));
- return Ok(JsonView(true, result.Msg));
- }
- /// <summary>
- /// 酒店资料操作(删除)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelHotelData(DelHotelDataDto dto)
- {
- try
- {
- var res = await _hotelDataRep.SoftDeleteByIdAsync<Res_HotelData>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- #endregion
- #region 签证费用资料
- /// <summary>
- /// 签证费用资料查询
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryCountryFeeCost(DtoBase dto)
- {
- if (dto.PortType == 1)
- {
- var CountryFee = _countryFeeRep.QueryDto<Res_CountryFeeCost, CountryFeeCostView>().ToList();
- if (CountryFee.Count == 0)
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- CountryFee = CountryFee.OrderByDescending(s => s.CreateTime).ToList();
- return Ok(JsonView(true, "查询成功", CountryFee));
- }
- else if (dto.PortType == 2)
- {
- var CountryFee = _countryFeeRep.QueryDto<Res_CountryFeeCost, CountryFeeCostView>().ToList();
- if (CountryFee.Count == 0)
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- CountryFee = CountryFee.OrderByDescending(s => s.CreateTime).ToList();
- return Ok(JsonView(true, "查询成功", CountryFee));
- }
- else
- {
- return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
- }
- }
- /// <summary>
- /// 签证费用资料操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OperationCountryFeeCost(OperationCountryFeeCostDto dto)
- {
- if (string.IsNullOrWhiteSpace(dto.VisaContinent))
- {
- return Ok(JsonView(false, "请检查州名是否填写!"));
- }
- if (string.IsNullOrWhiteSpace(dto.VisaCountry))
- {
- return Ok(JsonView(false, "请检查国家名是否填写!"));
- }
- if (string.IsNullOrWhiteSpace(dto.VisaTime))
- {
- return Ok(JsonView(false, "请检一般签证时间是否填写正确!"));
- }
- if (string.IsNullOrWhiteSpace(dto.UrgentTime))
- {
- return Ok(JsonView(false, "请检加急时间是否填写正确!"));
- }
- Result result = await _countryFeeRep.OperationCountryFeeCost(dto);
- if (result.Code == 0)
- {
- return Ok(JsonView(true, result.Msg));
- }
- return Ok(JsonView(false, result.Msg));
- }
- /// <summary>
- /// 签证费用资料操作(删除)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelCountryFeeCost(DelCountryFeeCostDto dto)
- {
- var res = await _countryFeeRep.SoftDeleteByIdAsync<Res_CountryFeeCost>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- #endregion
- #region 物料信息、供应商维护
- #region 供应商
- /// <summary>
- /// 物料供应商查询
- /// </summary>
- /// <param name="paras">Json序列化</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostSearchItemVendor(JsonDtoBase _jsonDto)
- {
- if (string.IsNullOrEmpty(_jsonDto.Paras))
- {
- return Ok(JsonView(false, "参数为空"));
- }
- Search_ResItemVendorDto _ItemVendorDto = System.Text.Json.JsonSerializer.Deserialize<Search_ResItemVendorDto>(_jsonDto.Paras);
- if (_ItemVendorDto != null)
- {
- if (_ItemVendorDto.SearchType == 2) //获取列表
- {
- Res_ItemVendorListView rstList = _resItemInfoRep.GetVendorList(_ItemVendorDto);
- return Ok(rstList);
- }
- else
- {
- Res_ItemVendorView rstInfo = _resItemInfoRep.getVendorInfo(_ItemVendorDto);
- return Ok(rstInfo);
- }
- }
- else
- {
- return Ok(JsonView(false, "参数反序列化失败"));
- }
- return Ok(JsonView(false));
- }
- /// <summary>
- /// 创建/编辑/删除供应商信息
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostEditItemVendor(Edit_ResItemVendorDto _dto)
- {
- bool rst = false;
- if (_dto.EditType >= 0)
- {
- if (string.IsNullOrEmpty(_dto.VendorFullName))
- {
- return Ok(JsonView(false, "全称未填写"));
- }
- if (string.IsNullOrEmpty(_dto.VendorLinker))
- {
- return Ok(JsonView(false, "联系人未填写"));
- }
- if (string.IsNullOrEmpty(_dto.VendorMobile))
- {
- return Ok(JsonView(false, "联系人手机号未填写"));
- }
- if (string.IsNullOrEmpty(_dto.BusRange))
- {
- return Ok(JsonView(false, "经营范围未选择"));
- }
- if (_dto.EditType == 0)
- {
- var checkEmpty = _resItemInfoRep.Query<Res_ItemVendor>(s => s.FullName == _dto.VendorFullName).First();
- if (checkEmpty != null)
- {
- return Ok(JsonView(false, "已存在同名供应商"));
- }
- rst = await _resItemInfoRep.addVendorInfo(_dto);
- }
- else if (_dto.EditType == 1)
- {
- if (_dto.VendorId > 0)
- {
- Res_ItemVendor _entity = _mapper.Map<Res_ItemVendor>(_dto);
- rst = await _resItemInfoRep.updVendorInfo(_entity);
- }
- else
- {
- return Ok(JsonView(false, "供应商不存在"));
- }
- }
- }
- else
- {
- if (_dto.VendorId < 1 || _dto.SysUserId < 1)
- {
- return Ok(JsonView(false, "用户Id或供应商Id不存在"));
- }
- Res_ItemVendor _entity = _mapper.Map<Res_ItemVendor>(_dto);
- rst = await _resItemInfoRep.delVendorInfo(_entity);
- }
- return Ok(JsonView(rst));
- }
- #endregion
- #region 物料信息
- /// <summary>
- /// 物料信息查询
- /// </summary>
- /// <param name="paras">Json序列化</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostSearchItemInfo(string paras)
- {
- if (string.IsNullOrEmpty(paras))
- {
- return Ok(JsonView(false, "参数为空"));
- }
- Search_ItemInfoDto _ItemInfoDto = System.Text.Json.JsonSerializer.Deserialize<Search_ItemInfoDto>(paras);
- if (_ItemInfoDto != null)
- {
- if (_ItemInfoDto.SearchType == 2) //获取列表
- {
- Res_ItemInfoListView rstList = _resItemInfoRep.GetItemList(_ItemInfoDto);
- return Ok(rstList);
- }
- else
- {
- Res_ItemInfoView rstInfo = _resItemInfoRep.getItemInfo(_ItemInfoDto);
- return Ok(rstInfo);
- }
- }
- else
- {
- return Ok(JsonView(false, "参数反序列化失败"));
- }
- return Ok(JsonView(false));
- }
- /// <summary>
- /// 创建/编辑/删除物料信息
- /// </summary>
- ///
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostEditItemInfo(Edit_ResItemInfoDto _dto)
- {
- bool rst = false;
- if (_dto.EditType >= 0)
- {
- if (_dto.VendorId < 1)
- {
- return Ok(JsonView(false, "未选择供应商"));
- }
- if (string.IsNullOrEmpty(_dto.ItemName))
- {
- return Ok(JsonView(false, "物料名称为空"));
- }
- if (_dto.ItemTypeId < 1)
- {
- return Ok(JsonView(false, "未选择物料类型"));
- }
- if (_dto.SysUserId < 1)
- {
- return Ok(JsonView(false, "当前操作用户Id为空"));
- }
- if (_dto.CurrRate <= 0)
- {
- return Ok(JsonView(false, "物料录入价格不能小于等于0"));
- }
- if (_dto.EditType == 0)
- {
- //判断物料名称、类型、供应商全部重复
- var checkEmpty = _resItemInfoRep.Query<Res_ItemDetailInfo>(s => s.ItemName == _dto.ItemName && s.ItemTypeId == _dto.ItemTypeId && s.VendorId == _dto.VendorId).First();
- if (checkEmpty != null)
- {
- return Ok(JsonView(false, "已存在重复物料信息"));
- }
- Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
- DateTime dtNow = DateTime.Now;
- _entity.CreateUserId = _dto.SysUserId;
- _entity.IsDel = 0;
- _entity.MaxRate = _dto.CurrRate;
- _entity.MaxDt = dtNow;
- _entity.CurrRate = _dto.CurrRate;
- _entity.CurrDt = dtNow;
- _entity.MinRate = _dto.CurrRate;
- _entity.MinDt = dtNow;
- rst = await _resItemInfoRep.AddAsync<Res_ItemDetailInfo>(_entity) > 0;
- }
- else if (_dto.EditType == 1)
- {
- if (_dto.ItemId > 0)
- {
- Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
- _entity.Id = _dto.ItemId;
- rst = await _resItemInfoRep.updItemInfo(_entity);
- }
- else
- {
- return Ok(JsonView(false, "供应商不存在"));
- }
- }
- }
- else
- {
- if (_dto.ItemId < 1 || _dto.SysUserId < 1)
- {
- return Ok(JsonView(false, "用户Id或物料信息Id不存在"));
- }
- Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
- rst = await _resItemInfoRep.delItemInfo(_entity);
- }
- return Ok(JsonView(rst));
- }
- #endregion
- #region 物料类型获取
- #endregion
- #endregion
- #region 备忘录
- /// <summary>
- /// 备忘录查询
- /// </summary>
- /// <param name="paras">Json序列化</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostSearchMemo(JsonDtoBase _jsonDto)
- {
- if (string.IsNullOrEmpty(_jsonDto.Paras))
- {
- return Ok(JsonView(false, "参数为空"));
- }
- Search_ResMemoDto _memoDto = JsonConvert.DeserializeObject<Search_ResMemoDto>(_jsonDto.Paras);
- if (_memoDto != null)
- {
- if (_memoDto.SearchType == 2)
- {
- //获取列表
- string sqlWhere = string.Format(" Where IsDel=0 ");
- #region SqlWhere
- if (!string.IsNullOrEmpty(_memoDto.Abstracts))
- {
- sqlWhere += string.Format(@" And m.Abstracts Like '%{0}%' ", _memoDto.Abstracts);
- }
- if (!string.IsNullOrEmpty(_memoDto.Title))
- {
- sqlWhere += string.Format(@" And m.Title Like '%{0}%' ", _memoDto.Title);
- }
- if (_memoDto.ReadLevel > 0)
- {
- sqlWhere += string.Format(@" And m.ReadLevel = {0} ", _memoDto.ReadLevel);
- }
- #endregion
- int currPIndex = (((_memoDto.PageIndex > 0) ? (_memoDto.PageIndex - 1) : 0) * _memoDto.PageSize) + 1;
- int currPSize = (((_memoDto.PageIndex > 0) ? (_memoDto.PageIndex - 1) : 0) + 1) * _memoDto.PageSize;
- string sql = string.Format(@" Select * From(Select ROW_NUMBER() Over(order By m.Id desc) as RowNumber,
- m.Id as MemoId,d.DepName as DepartmentName,m.ReadLevel,m.Title,m.Abstracts,
- m.LastedEditDt,m.LastedEditorId
- From Res_Memo as m With(Nolock) Inner Join Sys_Users as u With(Nolock) On m.CreateUserId=u.Id
- Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id {2}
- ) as tb Where tb.RowNumber Between {0} And {1} ", currPIndex, currPSize, sqlWhere);
- Res_MemoListView rst = new Res_MemoListView();
- rst.CurrPageIndex = currPIndex;
- rst.CurrPageSize = currPSize;
- List<Res_MemoView> dataSource = _carDataRep._sqlSugar.SqlQueryable<Res_MemoView>(sql).ToList();
- Dictionary<int, string> userDic = new Dictionary<int, string>();
- foreach (var item in dataSource)
- {
- if (userDic.ContainsKey(item.LastedEditorId))
- {
- item.LastedEditor = userDic[item.LastedEditorId];
- }
- else
- {
- Sys_Users _sysUser = _carDataRep.Query<Sys_Users>(s => s.Id == item.LastedEditorId).First();
- userDic[item.LastedEditorId] = _sysUser.CnName;
- item.LastedEditor = _sysUser.CnName;
- }
- }
- rst.DataList = new List<Res_MemoView>(dataSource);
- if (rst.DataList.Count > 0)
- {
- string sqlCount = string.Format(@" Select Id From Res_Memo as m With(Nolock) {0} ", sqlWhere);
- int dataCount = _carDataRep._sqlSugar.SqlQueryable<Res_MemoInfo>(sqlCount).Count();
- rst.DataCount = dataCount;
- }
- return Ok(JsonView(rst));
- }
- else
- {
- //获取对象
- string sqlSingle = string.Format(@" Select
- m.Id as MemoId,d.DepName as DepartmentName,m.ReadLevel,m.Title,m.Abstracts,
- m.LastedEditDt,m.LastedEditor,m.MDFilePath
- From Res_Memo as m With(Nolock) Inner Join Sys_Users as u With(Nolock) On m.CreateUserId=u.Id
- Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _memoDto.MemoId);
- Res_MemoView _result = _carDataRep._sqlSugar.SqlQueryable<Res_MemoView>(sqlSingle).First();
- if (_result != null)
- {
- Sys_Users _sysUser = _carDataRep.Query<Sys_Users>(s => s.Id == _result.LastedEditorId).First();
- _result.LastedEditor = _sysUser.CnName;
- _result.MarkDownContent = new IOOperatorHelper().Read(_result.MDFilePath);
- return Ok(JsonView(_result));
- }
- }
- }
- else
- {
- return Ok(JsonView(false, "参数反序列化失败"));
- }
- return Ok(JsonView(false));
- }
- /// <summary>
- /// 创建/编辑/删除备忘录信息
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostEditMemo(Edit_ResMemoDto _dto)
- {
- bool rst = false;
- if (_dto.SysUserId < 1)
- {
- return Ok(JsonView(false, "操作人失效"));
- }
- Sys_Users _sysUser = _resItemInfoRep.Query<Sys_Users>(s => s.Id == _dto.SysUserId).First();
- if (_sysUser == null)
- {
- return Ok(JsonView(false, "操作人失效02"));
- }
- if (_dto.EditType >= 0)
- {
- if (_dto.ReadLevel < 1)
- {
- return Ok(JsonView(false, "未知的阅读等级"));
- }
- if (string.IsNullOrEmpty(_dto.Title.Trim()))
- {
- return Ok(JsonView(false, "标题不能为空"));
- }
- if (string.IsNullOrEmpty(_dto.Content.Trim()))
- {
- return Ok(JsonView(false, "正文内容不能为空"));
- }
- //新增备忘录
- DateTime dtNow = DateTime.Now;
- string dir = AppSettingsHelper.Get("MemoCurrPath");
- string fileName = dtNow.ToString("yyyyMMddHHmmss") + _dto.Title + ".md";
- string content = JsonConvert.SerializeObject(_dto.Content);
- if (_dto.EditType == 0)//新增
- {
- string savePath = new IOOperatorHelper().Write_CoverFile(content, dir, fileName);
- if (savePath.Length > 0)
- {
- Res_MemoInfo _insert = new Res_MemoInfo();
- _insert.Abstracts = _dto.Abstracts;
- _insert.Title = _dto.Title;
- _insert.DepartmentId = _sysUser.DepId;
- _insert.CreateUserId = _sysUser.Id;
- _insert.LastedEditDt = dtNow;
- _insert.LastedEditor = _sysUser.Id;
- _insert.MDFilePath = savePath;
- _insert.ReadLevel = _dto.ReadLevel;
- _insert.Title = _dto.Title;
- int result = await _resItemInfoRep.AddAsync(_insert);
- return Ok(JsonView(result > 0));
- }
- else
- {
- return Ok(JsonView(false, "路径保存失败"));
- }
- }
- else//修改
- {
- if (_dto.MemoId < 1)
- {
- return Ok(JsonView(false, "MemoId不存在"));
- }
- Res_MemoInfo _source = _resItemInfoRep.Query<Res_MemoInfo>(s => s.Id == _dto.MemoId).First();
- if (_source == null)
- {
- return Ok(JsonView(false, "MemoInfo不存在"));
- }
- //修改
- string sourcePath = _source.MDFilePath;
- string recycDir = AppSettingsHelper.Get("MemoRecycleBinPath");
- new IOOperatorHelper().MoveFile(sourcePath, recycDir);
- string savePath = new IOOperatorHelper().Write_CoverFile(content, dir, fileName);
- if (savePath.Length > 0)
- {
- var result = await _resItemInfoRep._sqlSugar.Updateable<Res_MemoInfo>()
- .SetColumns(it => it.LastedEditDt == DateTime.Now)
- .SetColumns(it => it.LastedEditor == _sysUser.Id)
- .SetColumns(it => it.Abstracts == _dto.Abstracts)
- .SetColumns(it => it.MDFilePath == savePath)
- .SetColumns(it => it.ReadLevel == _dto.ReadLevel)
- .SetColumns(it => it.Title == _dto.Title)
- .Where(s => s.Id == _source.Id)
- .ExecuteCommandAsync();
- return Ok(JsonView(result > 0));
- }
- }
- }
- else
- {
- //删除
- if (_dto.MemoId < 1)
- {
- return Ok(JsonView(false, "MemoId不存在"));
- }
- Res_MemoInfo _source = _resItemInfoRep.Query<Res_MemoInfo>(s => s.Id == _dto.MemoId).First();
- if (_source == null)
- {
- return Ok(JsonView(false, "MemoInfo不存在"));
- }
- //修改
- string sourcePath = _source.MDFilePath;
- string recycDir = AppSettingsHelper.Get("MemoRecycleBinPath");
- new IOOperatorHelper().MoveFile(sourcePath, recycDir);
- var result = await _resItemInfoRep._sqlSugar.Updateable<Res_MemoInfo>()
- .SetColumns(it => it.IsDel == 1)
- .SetColumns(it => it.DeleteUserId == _sysUser.Id)
- .SetColumns(it => it.DeleteTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
- .Where(s => s.Id == _source.Id)
- .ExecuteCommandAsync();
- return Ok(JsonView(result > 0));
- }
- return Ok(JsonView(rst));
- }
- #endregion
- #region 商邀资料
- /// <summary>
- /// 商邀资料 基础数据源
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryIOAInitData(QueryIOAInitDataDto dto)
- {
- try
- {
- #region 参数验证
- if (dto.PortType < 1) return Ok(JsonView(false, "请传入有效的PortType参数!"));
- #endregion
- var ExcludedKeyStr = new string[] { "快递费" };
- var ClientKeyStr = new string[] { "邀请函翻译" };
- var expable = Expressionable.Create<Res_InvitationOfficialActivityData>();
- foreach (var key in ClientKeyStr)
- {
- expable = expable.And(it => !it.Contact.Contains(key));
- }
- foreach (var item in ExcludedKeyStr)
- {
- expable = expable.And(it => !it.UnitName.Contains(item));
- }
- List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.JietuanTime).ToList();
- List<Res_InvitationOfficialActivityData> _ioaDatas = _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().Where(it => it.IsDel == 0).Where(expable.ToExpression()).ToList();
- List<Sys_Users> _Users = _sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0).ToList();
- var _countryData = _ioaDatas.Select(it => it.Country).Distinct().ToList(); _countryData.Remove("");
- var _inviterData = _ioaDatas.Select(it => it.UnitName).Distinct().ToList(); _inviterData.Remove("");
- var _contactData = _ioaDatas.Select(it => it.Contact).Distinct().ToList(); _contactData.Remove("");
- var _domainData = _ioaDatas.Select(it => it.Field).Distinct().ToList(); _domainData.Remove("");
- var _groupNameData = _DelegationInfos.Select(it => new { it.Id, it.TeamName }).ToList();
- var _userNameData = _Users.Select(it => new { it.Id, it.CnName }).ToList();
- var _data = new
- {
- CountryData = _countryData,
- InviterData = _inviterData,
- DomainData = _domainData,
- ContactData = _contactData,
- GroupNameData = _groupNameData,
- UserNameData = _userNameData,
- };
- return Ok(JsonView(true, $"查询成功!", _data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 商邀资料查询
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryInvitationOfficialActivityData(QueryInvitationOfficialActivityDataDto dto)
- {
- var ExcludedKeyStr = new string[] { "快递费" };
- var ClientKeyStr = new string[] { "邀请函翻译" };
- try
- {
- #region 参数验证
- if (dto.PageIndex < 1) return Ok(JsonView(false, "请传入有效的PageIndex参数!"));
- if (dto.PageSize < 1) return Ok(JsonView(false, "请传入有效的PageSize参数!"));
- #endregion
- string sqlWhere = string.Empty;
- if (!string.IsNullOrWhiteSpace(dto.Country)) { sqlWhere += string.Format(@" And i.Country like '%{0}%'", dto.Country); }
- if (!string.IsNullOrWhiteSpace(dto.UnitName)) { sqlWhere += string.Format(@" And i.UnitName like '%{0}%'", dto.UnitName); }
- if (!string.IsNullOrWhiteSpace(dto.Contact)) { sqlWhere += string.Format(@" And i.Contact like '%{0}%'", dto.Contact); }
- if (!string.IsNullOrWhiteSpace(dto.Delegation)) { sqlWhere += string.Format(@" And i.Delegation like '%{0}%'", dto.Delegation); }
- if (!string.IsNullOrWhiteSpace(dto.Field)) { sqlWhere += string.Format(@" And i.Field like '%{0}%'", dto.Field); }
- if (dto.CreateUserId != 0 && !string.IsNullOrWhiteSpace(dto.CreateUserId.ToString())) { sqlWhere += string.Format(@" And i.CreateUserId={0}", dto.CreateUserId); }
- if (!string.IsNullOrWhiteSpace(dto.StartCreateTime) && !string.IsNullOrWhiteSpace(dto.EndCreateTime))
- {
- sqlWhere += string.Format(@" And i.CreateTime between '{0}' and '{1}'", dto.StartCreateTime, dto.EndCreateTime);
- }
- sqlWhere += string.Format(@"And i.Isdel={0}", 0);
- foreach (var item in ExcludedKeyStr)
- {
- sqlWhere += $" And i.UnitName not like '%{item}%' ";
- }
- foreach (var item in ClientKeyStr)
- {
- sqlWhere += $" And i.Contact not like '%{item}%' ";
- }
- if (!string.IsNullOrEmpty(sqlWhere.Trim()))
- {
- Regex r = new Regex("And");
- sqlWhere = r.Replace(sqlWhere, "Where", 1);
- }
- string sql = string.Format(@"Select ROW_NUMBER() Over(Order By i.CreateTime Desc) As Row_Number,
- i.*,u.CnName As CreateUserName
- From Res_InvitationOfficialActivityData i
- Left Join Sys_Users u On i.CreateUserId = u.Id {0}", sqlWhere);
- RefAsync<int> totalCount = 0;
- var _ivitiesViews = await _sqlSugar.SqlQueryable<InvitationOfficialActivityDataView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, totalCount);
- //List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().ToList();
- foreach (var item in _ivitiesViews)
- {
- string groupNameStr = "";
- if (!string.IsNullOrEmpty(item.Delegation))
- {
- int[] groupIds = item.Delegation.Split(',').Select(x =>
- {
- int id;
- if (int.TryParse(x, out id)) return id;
- else return id;
- }).ToArray();
- var _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => groupIds.Contains(x.Id) && x.IsDel == 0).ToList();
- foreach (var group in _DelegationInfos)
- {
- groupNameStr += $"{group.TeamName},";
- }
- if (groupNameStr.Length > 1)
- {
- groupNameStr = groupNameStr.Substring(0, groupNameStr.Length - 1);
- }
- }
- item.DelegationStr = groupNameStr;
- }
- return Ok(JsonView(true, $"查询成功!", _ivitiesViews, totalCount));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
-
- /// <summary>
- /// 根据商邀资料Id查询信息
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet("{id}")]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryInvitationOfficialActivityById(int id)
- {
- if (id < 1) return Ok(JsonView(false, "Id参数错误!"));
- return Ok(await _InvitationOfficialActivityDataRep.Info(id));
- }
- /// <summary>
- /// 商邀资料操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpInvitationOfficialActivity([FromForm] OpInvitationOfficialActivityDto dto)
- {
- return Ok(await _InvitationOfficialActivityDataRep.IOA_OP(dto));
- }
- /// <summary>
- /// 商邀资料 删除文件
- /// </summary>
- /// <param name="id"></param>
- /// <param name="fileName"></param>
- /// <returns></returns>
- [HttpDelete("{id}")]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> InvitationOfficialActivityDelFile(int id, string fileName)
- {
- if (id < 1) return Ok(JsonView(false, "请传入有效的Id"));
- if (string.IsNullOrEmpty(fileName)) return Ok(JsonView(false, "文件名称不能为空!"));
- var info = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync(x => x.Id == id);
- if (info == null) return Ok(JsonView(false, "该条数据不存在!"));
- var files = new List<string>();
- try
- {
- files = JsonConvert.DeserializeObject<List<string>>(info.SndFileName);
- }
- catch (Exception) { }
- if (files != null && files.Count > 0 && files.Contains(fileName))
- {
- var filePath = $@"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{fileName}";
- if (System.IO.File.Exists(filePath))
- {
- System.IO.File.Delete(filePath);
- }
- //更改文件值
- files.Remove(fileName);
- var fileUpd = await _sqlSugar.Updateable<Res_InvitationOfficialActivityData>()
- .SetColumns(x => x.SndFileName == JsonConvert.SerializeObject(files))
- .Where(x => x.Id == id)
- .ExecuteCommandAsync();
- if (fileUpd > 0) return Ok(JsonView(true, "操作成功!"));
- }
- return Ok(JsonView(false, "操作失败!"));
- }
- /// <summary>
- /// 删除商邀资料信息
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelInvitationOfficialActivity(DelBaseDto dto)
- {
- var res = await _InvitationOfficialActivityDataRep.SoftDeleteByIdAsync<Res_InvitationOfficialActivityData>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res) return Ok(JsonView(false, "删除失败"));
- var info = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync(x => x.Id == dto.Id);
- if (info == null) return Ok(JsonView(false, "该条数据不存在!"));
- var files = new List<string>();
- try
- {
- files = JsonConvert.DeserializeObject<List<string>>(info.SndFileName);
- }
- catch (Exception) { }
- if (files != null && files.Count > 0)
- {
- foreach (var fileName in files)
- {
- var filePath = $@"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{fileName}";
- if (System.IO.File.Exists(filePath))
- {
- System.IO.File.Delete(filePath);
- }
- }
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- #endregion
- #region 公务出访
- /// <summary>
- /// 获取团组所有信息,绑定下拉框
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetGroupAllList(OfficialActivitiesByDiIdDto dto)
- {
- //string groupSql = string.Format("Select * From Grp_DelegationInfo With(NoLock) Where IsDel = 0 Order By CreateTime Desc");
- //List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.SqlQueryable< Grp_DelegationInfo >(groupSql).ToList();
- var _groupData = await _delegationInfoRep.PostShareGroupInfos(1);
- dynamic groupInfos = null;
- if (_groupData.Code == 0) groupInfos = _groupData.Data;
- var data = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.IsDel == 0 && a.STid == 38).ToList();
- var _DeleFile = _sqlSugar.Queryable<Grp_DeleFile>().Where(a => a.Diid == dto.DiId && a.IsDel == 0 && a.Category == 970).ToList();
- var translatorData = _sqlSugar.Queryable<Res_TranslatorLibrary>().Where(a => a.IsDel == 0).Select(x => new { x.Id, x.Name }).ToList();
- return Ok(JsonView(true, "查询成功!", new { Delegation = groupInfos, SetData = data, DeleFile = _DeleFile , TranslatorData = translatorData }));
- }
- /// <summary>
- /// 公务List
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryOfficialActivitiesByDiId(OfficialActivitiesByDiIdDto dto)
- {
- return Ok(await _officialActivitiesRep.QueryOfficialActivitiesByDiId(dto));
- }
- /// <summary>
- /// 根据公务出访数据Id查询数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryOfficialActivitiesById(OfficialActivitiesDiIdDto dto)
- {
- Result groupData = await _officialActivitiesRep.QueryOfficialActivitiesById(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- /// <summary>
- /// 公务出访操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpOfficialActivities(OpOfficialActivitiesDto dto)
- {
- Result groupData = await _officialActivitiesRep.OpOfficialActivities(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, new { Id = 0 }));
- }
- try
- {
- //公务出访变更发送通知
- await AppNoticeLibrary.SendUserMsg_GroupShare_ToOP(dto.DiId, dto.CreateUserId);
- }
- catch (Exception ex)
- {
- //抄送日志
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- /// <summary>
- /// 上传文件(邮件截图)
- /// </summary>
- /// <param name="file"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OfficialActivitiesUploadFiles([FromForm] OfficialActivitiesUploadFilesDto dto)
- {
- string networkPath = AppSettingsHelper.Get("GrpFileBaseUrl");
- string localPath = AppSettingsHelper.Get("GrpFileBasePath");
- string ptfPath = AppSettingsHelper.Get("GrpFileFtpPath");
- if (dto.diId < 1 || dto.currUserId < 1)
- {
- return Ok(JsonView(false, "参数有误,上传失败!"));
- }
- if (dto.files == null || dto.files.Count < 1)
- {
- return Ok(JsonView(false, "文件为空,上传失败!"));
- }
- string localFileDir = $"{localPath}{ptfPath}";
- List<string> fileUrls = new List<string>();
- string[] failFiles = new string[] { };
- foreach (var file in dto.files)
- {
- //文件名称
- string[] fileNameArray = file.FileName.Split(".");
- string projectFileName = $"{fileNameArray[0].ToString().Replace("-", "_").Replace("/", "_")}{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.{fileNameArray[1].ToString()}";
- //上传的文件的路径
- string filePath = $@"{localPath}公务相关文件";
- if (!Directory.Exists(filePath))
- {
- Directory.CreateDirectory(filePath);
- }
- var path = Path.Combine(filePath, projectFileName);
- //using var stream = new FileStream(path, FileMode.Create);
- //await file.CopyToAsync(stream);
- try
- {
- using (FileStream fs = System.IO.File.Create(path))
- {
- file.CopyTo(fs);
- fs.Flush();
- }
- fileUrls.Add($"/{ptfPath}公务相关文件/{projectFileName}");
- }
- catch (Exception ex)
- {
- failFiles.Append(file.FileName);
- }
- }
- var oaInfo = await _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.Id == dto.id).FirstAsync();
- List<string> files = new List<string>();
- var status = false;
- var _oaInfo = new Res_OfficialActivities()
- {
- DiId = dto.diId,
- ScreenshotOfMailUrl = JsonConvert.SerializeObject(fileUrls),
- IsDel = 0,
- CreateUserId = dto.currUserId,
- CreateTime = DateTime.Now
- };
- if (oaInfo == null)
- {
- var id = await _sqlSugar.Insertable<Res_OfficialActivities>(_oaInfo)
- .ExecuteReturnIdentityAsync();
- if (id > 0)
- {
- status = true;
- dto.id = id;
- }
- }
- else
- {
- var oldFiles = string.IsNullOrEmpty(oaInfo.ScreenshotOfMailUrl)
- ? new List<string>()
- : JsonConvert.DeserializeObject<List<string>>(oaInfo.ScreenshotOfMailUrl);
- if (oldFiles.Count > 0)
- {
- fileUrls.AddRange(oldFiles);
- }
- fileUrls = fileUrls.Distinct().ToList();
- if (fileUrls.Count() > 0)
- {
- var upd = await _sqlSugar.Updateable<Res_OfficialActivities>()
- .SetColumns(x => x.ScreenshotOfMailUrl == JsonConvert.SerializeObject(fileUrls))
- .Where(x => x.Id == dto.id)
- .ExecuteCommandAsync();
- if (upd > 0) status = true;
- }
- }
- List<string> returnFileUrls = new List<string>();
- fileUrls.ForEach(x =>
- {
- returnFileUrls.Add($"{networkPath}{x}");
- });
- if (status)
- {
- string msg = "操作成功!";
- if (failFiles.Length > 1)
- {
- foreach (var item in failFiles)
- {
- msg += $"{failFiles}、";
- }
- msg = msg.Substring(0, msg.Length - 1);
- msg += "等文件保存失败!";
- }
- return Ok(JsonView(true, msg, new { id = dto.id, fileUrls = returnFileUrls }));
- }
- return Ok(JsonView(false, "操作失败!"));
- }
- /// <summary>
- /// 删除文件(邮件截图)
- /// </summary>
- /// <param name="file"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OfficialActivitiesDelFile(OfficialActivitiesDelFileDto dto)
- {
- string networkPath = AppSettingsHelper.Get("GrpFileBaseUrl");
- string localPath = AppSettingsHelper.Get("GrpFileBasePath");
- string ptfPath = AppSettingsHelper.Get("GrpFileFtpPath");
- if (dto.Id < 1 || string.IsNullOrEmpty(dto.FileName))
- {
- return Ok(JsonView(false, "参数有误,上传失败!"));
- }
- string localFileDir = $"{localPath}{ptfPath}";
- List<string> fileUrls = new List<string>();
- var oaInfo = await _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.Id == dto.Id).FirstAsync();
- if (oaInfo != null)
- {
- string urlJson = oaInfo.ScreenshotOfMailUrl ?? "";
- if (!string.IsNullOrEmpty(urlJson))
- {
- List<string> urls = JsonConvert.DeserializeObject<List<string>>(urlJson);
- var filePath = urls.Find(x => x.Contains(dto.FileName));
- if (string.IsNullOrEmpty(filePath)) return Ok(JsonView(false, "文件不存在!"));
- var updFile = urls.Remove(filePath);
- if (updFile)
- {
- //删除文件
- string fileUrl = AppSettingsHelper.Get("GrpFileBasePath").Replace(@"/Office/GrpFile", "") + filePath;
- if (System.IO.File.Exists(fileUrl))
- {
- System.IO.File.Delete(fileUrl);
- }
- string urlJsonstr = JsonConvert.SerializeObject(urls);
- var upd = await _sqlSugar.Updateable<Res_OfficialActivities>()
- .SetColumns(x => x.ScreenshotOfMailUrl == urlJsonstr)
- .Where(x => x.Id == dto.Id)
- .ExecuteCommandAsync();
- if (upd > 0) return Ok(JsonView(true, "操作成功!"));
- }
- }
- }
- return Ok(JsonView(false, "操作失败!"));
- }
- /// <summary>
- /// 公务出访 确认、取消邀请
- /// </summary>
- /// <param name="file"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OfficialActivitiesInviteOperation(OfficialActivitiesInviteOperationDto dto)
- {
- if (dto.Id < 1) return Ok(JsonView(false, "Id参数有误!"));
- if (dto.Type < 0 || dto.Type > 1) return Ok(JsonView(false, "Type参数有误!"));
- var upd = await _sqlSugar.Updateable<Res_OfficialActivities>()
- .SetColumns(x => x.ConfirmTheInvitation == dto.Type)
- .Where(x => x.Id == dto.Id)
- .ExecuteCommandAsync();
- if (upd > 0) return Ok(JsonView(true, "操作成功!"));
- return Ok(JsonView(false, "操作失败!"));
- }
- /// <summary>
- /// 上传文件
- /// </summary>
- /// <param name="file"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> UploadOfficialActivities(IFormFile file)
- {
- try
- {
- int Type = int.Parse(Request.Headers["Type"]);//1公务方简介,2公务活动图片,3发票
- int DiId = int.Parse(Request.Headers["DiId"]);
- int CreateUserId = int.Parse(Request.Headers["CreateUserId"]);
- if (file != null)
- {
- var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
- //文件名称
- string projectFileName = file.FileName;
- //上传的文件的路径
- string filePath = "";
- if (!Directory.Exists(fileDir))
- {
- Directory.CreateDirectory(fileDir);
- }
- //上传的文件的路径
- filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
- using (FileStream fs = System.IO.File.Create(filePath))
- {
- file.CopyTo(fs);
- fs.Flush();
- }
- Grp_DeleFile d = new Grp_DeleFile();
- d.Diid = DiId;
- d.Category = 970;
- if (Type == 1) d.Kind = 1;
- else if (Type == 2) d.Kind = 2;
- else if (Type == 3) d.Kind = 3;
- d.FileName = projectFileName;
- d.FilePath = "";
- d.CreateUserId = CreateUserId;
- int id = await _sqlSugar.Insertable(d).ExecuteReturnIdentityAsync();
- return Ok(JsonView(true, "上传成功!", projectFileName));
- }
- else
- {
- return Ok(JsonView(false, "上传失败!"));
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 删除文件
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelloadOfficialActivities(DelBaseDto dto)
- {
- try
- {
- var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
- Grp_DeleFile _DeleFile = await _sqlSugar.Queryable<Grp_DeleFile>().FirstAsync(a => a.Id == dto.Id);
- if (_DeleFile != null)
- {
- string fileName = _DeleFile.FileName;
- string filePath = fileDir + "/团组增减款项相关文件/" + fileName;
- // 删除该文件
- System.IO.File.Delete(filePath);
- int id = await _sqlSugar.Updateable<Grp_DeleFile>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DeleFile { IsDel = 1, DeleteUserId = dto.DeleteUserId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }).ExecuteCommandAsync();
- return Ok(JsonView(true, "取消文件成功!"));
- }
- else
- {
- return Ok(JsonView(false, "取消文件失败!"));
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 删除公务出访信息
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelOfficialActivities(DelBaseDto dto)
- {
- _sqlSugar.BeginTran();
- var res = await _officialActivitiesRep.SoftDeleteByIdAsync<Res_OfficialActivities>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, "删除失败"));
- }
- #region 删除公务出访
- await _sqlSugar.Updateable<Grp_OfficialDutyLinkTranslator>()
- .SetColumns(x => new Grp_OfficialDutyLinkTranslator()
- {
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
- IsDel = 1,
- Remark = $"公务出访-->删除"
- })
- .Where(x => x.OfficialDutyId == dto.Id)
- .ExecuteCommandAsync();
- #endregion
- _sqlSugar.CommitTran();
- return Ok(JsonView(true, "删除成功!"));
- }
- /// <summary>
- /// 公务出访
- /// 请示范例提示
- /// Add Time:2024-05-13 13:56:44
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostOfficialActivitiesReqReqSampleTips(PostOfficialActivitiesReqReqSampleTipsDto dto)
- {
- var res = await _officialActivitiesRep.PostReqReqSampleTips(dto.country, dto.area, dto.client);
- if (res.Code == 0)
- {
- return Ok(JsonView(true, "操作成功!", res.Data));
- }
- return Ok(JsonView(false, res.Msg));
- }
- /// <summary>
- /// 公务出访 (省外办,市外办) File Downlaod
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OfficialActivitiesFileDownload(OfficialActivitiesFileDownload dto)
- {
- #region 参数验证
- if (dto.FileType < 1 || dto.FileType > 2) return Ok(JsonView(false, "请传入有效的FileType参数. 1 省外办出访请示 2 市外办出访请示", ""));
- if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数.", ""));
- #endregion
- //团组基础信息
- var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
- if (groupInfo == null) return Ok(JsonView(false, "该团组基本信息不存在", ""));
- groupInfo.VisitCountry = groupInfo.VisitCountry.Replace("|", "、");
- //团组公务信息
- var obDatas = _sqlSugar.Queryable<Res_OfficialActivities>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderBy(it => it.Date).ToList();
- //if (obDatas.Count < 1) return Ok(JsonView(false, "请先录入公务信息!"));
- //团组客户名单
- var guestResult = _tourClientListRep._ItemByDiId(1, dto.DiId);
- List<TourClientListByDiIdView> guestInfos = new List<TourClientListByDiIdView>();
- if (guestResult.Result.Code == 0) guestInfos = guestResult.Result.Data as List<TourClientListByDiIdView>;
- string visitCountrys = ""; //××国家(或地区)×天,××国家(或地区)×天
- string countryStayStr = ""; // xx、xx、xx
- //出入境费用 住宿类型
- var dayCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId && it.Type == 1).ToList();
- if (dayCostDatas.Count > 0)
- {
- List<int> nationalIds = dayCostDatas.Select(it => it.NationalTravelFeeId).ToList();
- var nationalDatas = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => nationalIds.Contains(it.Id)).ToList();
- var nationalDataGroupByCountry = nationalDatas.GroupBy(it => it.Country);
- foreach (var item in nationalDataGroupByCountry)
- {
- visitCountrys += $"{item.Key}、";
- int stayDays = nationalIds.Where(it => it == item.ToList()[0].Id).Count();
- countryStayStr += $"{item.Key}{stayDays}天,";
- }
- if (visitCountrys.Length > 0) visitCountrys = visitCountrys.Substring(0, visitCountrys.Length - 1);
- if (countryStayStr.Length > 0) countryStayStr = countryStayStr.Substring(0, countryStayStr.Length - 1);
- }
- else
- {
- visitCountrys = groupInfo.VisitCountry;
- countryStayStr = GeneralMethod.GetCountryStandingTime(groupInfo.Id); //计算国家出访天数
- }
- //出访人数
- int visitPeopleNum = groupInfo.VisitPNumber;
- int visitDaysNum = groupInfo.VisitDays;
- //出访单位
- string obInfoStr = "";
- foreach (var ob in obDatas) obInfoStr += @$"{ob.Client.Trim()}{ob.Job.Trim()}{ob.Contact.Trim()}、";
- if (obInfoStr.Length > 0) obInfoStr = obInfoStr.Substring(0, obInfoStr.Length - 1);
- obInfoStr = obInfoStr ?? "[公务出访未录入]";
- //出访路线
- string lineStr = GeneralMethod.GetGroupCityLine(groupInfo.Id, "—");
- if (dto.FileType == 1)
- {
- //载入模板
- string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/省外办出访请示 - 模板.docx";
- var doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- //键值对存放数据
- Dictionary<string, string> dic = new Dictionary<string, string>();
- //××(组团单位):接团客户信息团组
- dic.Add("GroupClient", $"{groupInfo.ClientUnit}\r\n");
- //关于××(职务、姓名)等×人赴××(国家或地区)进行×××(出访目的)的请示
- string guestName = "";
- string guestJob = "";
- string guestInfoStr = "";
- var guestFirstInfo = guestInfos.FirstOrDefault();
- if (guestFirstInfo != null)
- {
- guestName = guestFirstInfo.LastName.Trim() + guestFirstInfo.FirstName.Trim();
- guestJob = guestFirstInfo.Job.Trim();
- guestInfoStr = $@"{guestJob}、{guestName}";
- }
- guestInfoStr = guestInfoStr ?? "[接团客户名单未录入]";
- string askTitle = $@"关于{guestInfoStr}等{visitPeopleNum}人赴{visitCountrys}进行{groupInfo.VisitPurpose}的请示";
- dic.Add("AskTitle", askTitle);
- //应×××(邀请方名称+邀请人职务和姓名)的邀请,我单位拟派×××(职务、姓名)等×人(人数)于×××年×××月×××日赴×××(国家或地区)进行×××(出访目的)。现请示如下。
- string visitDateStr = @$"{groupInfo.VisitDate.Year}年{groupInfo.VisitDate.Month}月{groupInfo.VisitDate.Day}日";
- string askSubTitle = $@"应{obInfoStr}的邀请,我单位拟派{guestInfoStr}等{visitPeopleNum}人于{visitDateStr}赴{visitCountrys}进行{groupInfo.VisitPurpose}。现请示如下。";
- dic.Add("AskSubTitle", askSubTitle);
- //出访目的
- dic.Add("VisitPurpose", groupInfo.VisitPurpose);
- //出访任务
- //(一)××(国家或地区)
- //1.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)
- //2.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)
- string obBackgroundStr = "";//出访背景
- string taskStr = ""; ; //出访任务
- var countrys = obDatas.GroupBy(it => it.Country);
- int countryIndex = 1;
- foreach (var item in countrys)
- {
- string taskTitle = $"({GetToUpperNumber(countryIndex)}){item.Key}\r\n";
- string taskContent = "";
- string obBackgroundContent = "";
- int obIndex = 1;
- foreach (var obInfo in item.ToList())
- {
- string reqSmaple = "";
- string settingStr = "";
- if (!string.IsNullOrEmpty(obInfo.ReqSample)) reqSmaple = obInfo.ReqSample;
- else reqSmaple = "[公务出访请示范例未录入]";
- if (!string.IsNullOrEmpty(obInfo.Setting)) settingStr = obInfo.Setting;
- else settingStr = "[公务方背景未录入]";
- taskContent += $"{obIndex}. {reqSmaple}\r\n";
- obBackgroundContent += $"{obIndex}. {obInfo.Client}:{settingStr}\r\n";
- obIndex++;
- }
- taskStr += $"{taskTitle}{taskContent}";
- obBackgroundStr += $"{taskTitle}{obBackgroundContent}";
- countryIndex++;
- }
- //出访背景
- if (obBackgroundStr.Length < 1) obBackgroundStr = "[公务出访背景未录入]";
- dic.Add("OBSetting", obBackgroundStr);
- //出访任务
- if (taskStr.Length < 1) taskStr = "[公务出访任务未录入]";
- dic.Add("TaskContent", taskStr);
- //出访时间
- //代表团拟于××年×月×日—×月×日出访,在外停留×天。其中,××国家(或地区)×天,××国家(或地区)×天。
- string visitTimeQuantumStr = $"代表团拟于{groupInfo.VisitStartDate.Year}年{groupInfo.VisitStartDate.Month}月{groupInfo.VisitStartDate.Day}日—{groupInfo.VisitEndDate.Month}月{groupInfo.VisitEndDate.Day}日出访,在外停留{visitDaysNum}天。其中,{countryStayStr}。";
- //出访时间
- dic.Add("TimeQuantum", visitTimeQuantumStr);
- //出访路线
- //成都—××(出境城市名称)—××(转机不出机场)—××(公务所在城市)……—××(入境城市名称)—成都。(例:成都—法兰克福<转机不出机场>—巴黎—巴塞罗那—阿姆斯特丹<转机不出机场>-成都)
- dic.Add("Line", lineStr);
- //scheduling //行程安排
- string schedulingStr = $"[OP行程单暂未生成]";
- #region op行程 根据黑屏代码录入
- var opTripView = GeneralMethod.GetBriefStroke(groupInfo.Id);
- if (opTripView.Code != 0) schedulingStr = $"[{opTripView.Msg}]";
- schedulingStr = "";
- List<Grp_TravelList> travelList = new List<Grp_TravelList>();
- travelList = opTripView.Data as List<Grp_TravelList>;
- if (travelList != null)
- {
- foreach (var item in travelList)
- {
- schedulingStr += $"{item.Date}({item.WeekDay})\r\n{item.Trip}\r\n";
- }
- }
- #endregion
- dic.Add("Scheduling", schedulingStr);
- #region 填充word模板书签内容
- foreach (var key in dic.Keys)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- #endregion
- //获取word里所有表格
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- //获取所填表格的序数
- Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
- var rowStart = tableOne.Rows[0]; //获取第1行
- //循环赋值
- for (int i = 0; i < guestInfos.Count; i++)
- {
- var guestInfo = guestInfos[i];
- builder.MoveToCell(0, i + 1, 0, 0);
- builder.Write(guestInfo.LastName + guestInfo.FirstName);
- builder.MoveToCell(0, i + 1, 1, 0);
- int sex = guestInfo.Sex;
- string sexStr = string.Empty;
- if (sex == 0) sexStr = "男";
- else if (sex == 1) sexStr = "女";
- else sexStr = "-";
- builder.Write(sexStr);
- builder.MoveToCell(0, i + 1, 2, 0);
- builder.Write(guestInfo.CompanyFullName + guestInfo.Job);
- builder.MoveToCell(0, i + 1, 3, 0);
- string birthDay = "";
- string birthDayStr = string.Empty;
- if (guestInfo.BirthDay != null)
- {
- birthDayStr = guestInfo.BirthDay.ToString("yyyy.MM");
- }
- builder.Write(birthDayStr);
- }
- //删除多余行
- while (tableOne.Rows.Count > guestInfos.Count + 1)
- {
- tableOne.Rows.RemoveAt(guestInfos.Count + 1);
- }
- var fileDir = AppSettingsHelper.Get("WordBasePath");
- string fileName = $"{groupInfo.TeamName}省外办出访请示{DateTime.Now.ToString("yyyyMMddHHmmss")}.docx";
- string filePath = fileDir + $@"OfficialActivities/{fileName}";
- doc.Save(filePath);
- string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/OfficialActivities/{fileName}";
- return Ok(JsonView(true, "操作成功!", Url));
- }
- else if (dto.FileType == 2)
- {
- //载入模板
- string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/市外办出访请示 - 模板.docx";
- var doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- //键值对存放数据
- Dictionary<string, string> dic = new Dictionary<string, string>();
- //××(组团单位):接团客户信息团组
- dic.Add("GroupClient", $"{groupInfo.ClientUnit}");
- dic.Add("GroupClient1", $"{groupInfo.ClientUnit}");
- //关于××(职务、姓名)等×人赴××(国家或地区)进行×××(出访目的)的请示
- string guestName = "";
- string guestJob = "";
- string guestInfoStr = "";
- var guestFirstInfo = guestInfos.FirstOrDefault();
- if (guestFirstInfo != null)
- {
- guestName = guestFirstInfo.LastName.Trim() + guestFirstInfo.FirstName.Trim();
- guestJob = guestFirstInfo.Job;
- guestInfoStr = $@"{guestJob}、{guestName.Trim()}";
- }
- string reqTitle = $@"关于{guestInfoStr}等{visitPeopleNum}人赴{visitCountrys}进行{groupInfo.VisitPurpose}的请示";
- dic.Add("ReqTitle", reqTitle);
- //应×××(邀请方名称+邀请人职务和姓名)的邀请,我单位拟派×××(职务、姓名)等×人(人数)于×××年×××月×××日赴×××(国家或地区)进行×××(出访目的)。
- string visitDateStr = @$"{groupInfo.VisitDate.Year}年{groupInfo.VisitDate.Month}月{groupInfo.VisitDate.Day}日";
- string reqSubTitle = $@"应{obInfoStr}的邀请,我单位拟派{guestInfoStr}等{visitPeopleNum}人于{visitDateStr}赴{visitCountrys}进行{groupInfo.VisitPurpose}。";
- dic.Add("ReqSubTitle", reqSubTitle);
- /*
- * 出访任务
- * (一)××(国家或地区)
- * 1.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)背景:拟拜访机构的优势、拟洽谈项目的前期进展情况等。(例:背景:由×××总领馆联合×××市政府共同举办的“×××活动”将于今年6月在×××举行。)
- * 2.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研等)×××(项目或机构名称等)。(例:拜会友城×××市市长×××,巩固和发展两市传统友谊,商谈两市未来互动交流合作项目。)背景:拟拜访机构的优势、拟洽谈项目的前期进展情况等。(例:背景:×××年×月,×××市与×××市正式缔结友好城市关系。在此框架下,两市开展了一系列友好互访和商务交流。并于×××年×月共同举办了“×××活动”。)
- *
- */
- string taskStr = string.Empty;
- List<string> countrys = obDatas.Where(it => !string.IsNullOrEmpty(it.Country)).Select(it => it.Country).ToList();
- int countryIndex = 1;
- foreach (var item in countrys)
- {
- string taskTitle = $"({GetToUpperNumber(countryIndex)}){item ?? "[公务出访国家未填写]"}\r\n";
- string taskContent = "";
- if (!string.IsNullOrEmpty(item))
- {
- var countryObDatas = obDatas.Where(it => !string.IsNullOrEmpty(it.Country) && it.Country.Contains(item)).OrderBy(it => it.Date).ToList();
- int obIndex = 1;
- if (countryObDatas.Count == 0) taskContent = "[公务出访未录入]\r\n";
- else
- {
- foreach (var obInfo in countryObDatas)
- {
- taskContent += $"{obIndex}.{obInfo.ReqSample ?? "[公务出访请示范例未填写]"}\r\n背景:{obInfo.Setting ?? "[公务出访背景未填写]"}\r\n";
- obIndex++;
- }
- }
- }
- taskStr += $"{taskTitle}{taskContent}";
- countryIndex++;
- }
- if (string.IsNullOrEmpty(taskStr)) taskStr = "××××××";
- //出访任务
- dic.Add("TaskContent", taskStr);
- //出访目的
- dic.Add("VisitPurpose", groupInfo.VisitPurpose);
- //出访信息
- //代表团拟于××年×月×日—×月×日出访,在外停留×天。其中,××国家(或地区)×天,××国家(或地区)×天。出访路线:成都—××(出境城市名称)—××(转机不出机场)—××(公务所在城市)……—××(入境城市名称)—成都。(例:成都—法兰克福<转机不出机场>—巴黎—巴塞罗那—阿姆斯特丹<转机不出机场>-成都)出访费用:由××承担(注明由外方或上级机关承担,还是由派员单位在年度安排的预算经费中列支)。
- string tripInfoStr = "";
- tripInfoStr = $"代表团拟于{groupInfo.VisitStartDate.Year}年{groupInfo.VisitStartDate.Month}月{groupInfo.VisitStartDate.Day}日—{groupInfo.VisitEndDate.Month}月{groupInfo.VisitEndDate.Day}日出访,在外停留{visitDaysNum}天。其中,{countryStayStr}。出访路线:{lineStr}。出访费用:由××承担(注明由外方或上级机关承担,还是由派员单位在年度安排的预算经费中列支)";
- dic.Add("TripInfo", tripInfoStr);
- #region 填充word模板书签内容
- foreach (var key in dic.Keys)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- #endregion
- //获取word里所有表格
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- //获取所填表格的序数
- Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
- var rowStart = tableOne.Rows[0]; //获取第1行
- //循环赋值
- for (int i = 0; i < guestInfos.Count; i++)
- {
- var guestInfo = guestInfos[i];
- builder.MoveToCell(0, i + 1, 0, 0);
- builder.Write(guestInfo.LastName + guestInfo.FirstName);
- builder.MoveToCell(0, i + 1, 1, 0);
- int sex = guestInfo.Sex;
- string sexStr = string.Empty;
- if (sex == 0) sexStr = "男";
- else if (sex == 1) sexStr = "女";
- else sexStr = "未设置";
- builder.Write(sexStr);
- builder.MoveToCell(0, i + 1, 2, 0);
- builder.Write(guestInfo.CompanyFullName + guestInfo.Job);
- builder.MoveToCell(0, i + 1, 3, 0);
- DateTime birthDay = guestInfo.BirthDay;
- string birthDayStr = string.Empty;
- if (birthDay != null)
- {
- birthDayStr = birthDay.ToString("yyyy.MM");
- }
- builder.Write(birthDayStr);
- }
- //删除多余行
- while (tableOne.Rows.Count > guestInfos.Count + 1)
- {
- tableOne.Rows.RemoveAt(guestInfos.Count + 1);
- }
- var fileDir = AppSettingsHelper.Get("WordBasePath");
- var fileName = $"{groupInfo.TeamName}市外办出访请示{DateTime.Now.ToString("yyyyMMddHHmmss")}.docx";
- var filePath = fileDir + $@"OfficialActivities/{fileName}";
- doc.Save(filePath);
- var url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/OfficialActivities/{fileName}";
- return Ok(JsonView(true, "操作成功!", url));
- }
- return Ok(JsonView(true, "操作失败!", ""));
- }
- private string GetToUpperNumber(int num)
- {
- string numStr = "";
- if (num == 1) numStr = "一";
- else if (num == 2) numStr = "二";
- else if (num == 3) numStr = "三";
- else if (num == 4) numStr = "四";
- else if (num == 5) numStr = "五";
- else if (num == 6) numStr = "六";
- else if (num == 7) numStr = "七";
- else if (num == 8) numStr = "八";
- else if (num == 9) numStr = "九";
- else if (num == 10) numStr = "十";
- return numStr;
- }
- [HttpPost]
- public IActionResult ExportOfficialActivitiesInfo(ExportOfficialActivitiesInfoDto dto)
- {
- var jw = JsonView(false);
- if (!ModelState.IsValid)
- {
- jw.Data = ModelState;
- return Ok(jw);
- }
- var startTime_bool = DateTime.TryParse(dto.StartTime, out DateTime startTime_parse);
- var endTime_bool = DateTime.TryParse(dto.EndTime, out DateTime endTime_parse);
- if(startTime_parse > endTime_parse)
- {
- jw.Msg = "开始实际不能大于结束时间!";
- return Ok(jw);
- }
- if (startTime_bool && endTime_bool)
- {
- //处理时间模板
- var Query_DB = _sqlSugar.Queryable<Grp_DelegationInfo>()
- .LeftJoin<Res_OfficialActivities>((a, b) => a.Id == b.DiId && b.IsDel == 0)
- .LeftJoin<Sys_Users>((a, b, c) => b.CreateUserId == c.Id && c.IsDel == 0)
- .Where((a, b, c) => a.IsDel == 0 && a.VisitDate >= startTime_parse && a.VisitDate <= endTime_parse)
- .WhereIF(dto.State != -1, (a, b, c) => b.ConfirmTheInvitation == dto.State)
- .Select((a, b, c) => new
- {
- a.TeamName,
- b.Client,
- b.ConfirmTheInvitation,
- b.Contact,
- ConfirmTheInvitationStr = b.ConfirmTheInvitation == 1 ? "是" : "否",
- b.Date,
- b.Nature,
- c.CnName,
- b.Address,
- b.CreateTime
- })
- .ToList()
- .Where(x=>!x.Client.IsNullOrWhiteSpace())
- .ToList();
- if (Query_DB.Count > 0)
- {
- //打开excel
- var ftpPath = AppSettingsHelper.Get("ExcelFtpPath");
- var fileBasePath = AppSettingsHelper.Get("ExcelBasePath");
- var fileName = "公务出访信息.docx";
- //创建数据源Table
- DataTable dtSource = new DataTable();
- dtSource.TableName = "TB";
- var firstElem = Query_DB.First();
- //遍历firstElem所有属性
- foreach (var item in firstElem.GetType().GetProperties())
- {
- dtSource.Columns.Add(item.Name, item.PropertyType);
- }
- foreach (var item in Query_DB)
- {
- DataRow dr = dtSource.NewRow();
- //遍历dtSource所有列头
- foreach (DataColumn column in dtSource.Columns)
- {
- dr[column.ColumnName] = item.GetType().GetProperty(column.ColumnName)?.GetValue(item)?.ToString();
- }
- dtSource.Rows.Add(dr);
- }
- WorkbookDesigner designer = new WorkbookDesigner();
- designer.Workbook = new Workbook(fileBasePath + ("Template/公务出访信息.xlsx"));
- var title = startTime_parse.ToString("yyyy年MM月dd日") + " - " + endTime_parse.ToString("yyyy年MM月dd日") + " 公务出访信息";
- designer.SetDataSource("title", title);
- designer.SetDataSource(dtSource);
- designer.Process();
-
- var exportSerevePath = fileBasePath + "ExportOfficialActivitiesInfo/" + title + ".xlsx";
- var exportFtpPaht = ftpPath + "ExportOfficialActivitiesInfo/" + title + ".xlsx";
- //保存文件
- designer.Workbook.Save(exportSerevePath);
- jw.Data = AppSettingsHelper.Get("ExcelBaseUrl") + exportFtpPaht;
- jw.Code = 200;
- jw.Msg = "获取成功!";
- }
- else
- {
- jw.Data = "无公务信息!";
- }
- }
- else
- {
- jw.Data = "时间格式错误!";
- }
- return Ok(jw);
- }
- #endregion
- #region 请示数据库
- /// <summary>
- /// 查询请示数据库初始化
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryAskData(QueryAskDataDto dto)
- {
- Result groupData = await _askDataRep.QueryAskData(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- /// <summary>
- /// 根据Id查询请示数据库单条数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryAskDataById(QueryAskDataByIdDto dto)
- {
- Res_AskData _AskData = await _sqlSugar.Queryable<Res_AskData>().FirstAsync(a => a.IsDel == 0 && a.Id == dto.id);
- if (_AskData == null)
- {
- return Ok(JsonView(true, "暂无数据!", _AskData));
- }
- return Ok(JsonView(true, "查询成功!", _AskData));
- }
- /// <summary>
- /// 请示数据库操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpAskData(OpAskDataDto dto)
- {
- Result groupData = await _askDataRep.OpAskData(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- /// <summary>
- /// 删除请示资料信息
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelAskData(DelBaseDto dto)
- {
- var res = await _askDataRep.SoftDeleteByIdAsync<Res_AskData>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- /// <summary>
- /// 请示资料信息
- /// 省外办下载
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> AskDataProvinceFAOPFile(AskDataProvinceFileDto dto)
- {
- if (dto.DataIdItem.Length < 1) return Ok(JsonView(false,$"请传入有效的数据Id集合!"));
- if (dto.DiId < 1) return Ok(JsonView(false, $"请传入有效的数据DiId参数!"));
- //大写数字序号
- string[] num = { "一", "二", "三", "四", "五", "六", "七", "八", "九", "十" ,
- "十一","十二","十三","十四","十五","十六","十七","十八","十九","二十",
- "二十一","二十二","二十三","二十四","二十五","二十六","二十七","二十八","二十九","三十",
- "三十一","三十二","三十三","三十四","三十五","三十六","三十七","三十八","三十九","四十"};
- //数据源
- var idItem = dto.DataIdItem.OrderBy(x => x);
- var askDatas = await _sqlSugar.Queryable<Res_AskData>().Where(x => x.IsDel == 0 && idItem.Contains(x.Id)).ToListAsync();
- //书签名
- string Area = "",
- Official = "";
- //表格数据源
- DataTable dt = new DataTable();
- dt.Columns.Add("Country", typeof(string));
- dt.Columns.Add("TalkCase", typeof(string));
- int id = 0;
- int TalkcaseOrder = 0;
- int RowOrder = 0;
- //填充数据
- for (int i = 0; i < askDatas.Count; i++)
- {
- var ad = askDatas[i];
- Area = Area + ad.Country + ad.Area + "、";
- Official = Official + ad.UnitName + "、";
- //填充表格数据源
- DataRow dr = dt.NewRow();
- if (i > 0)
- {
- var adtemp = askDatas[i - 1];
- if (ad.Country == adtemp.Country)
- {
- TalkcaseOrder++;
- dt.Rows[RowOrder]["TalkCase"] = dt.Rows[RowOrder]["TalkCase"] + "\r\n" + (1 + TalkcaseOrder).ToString() + "、" + ad.TalkCase;
- }
- else
- {
- RowOrder++;
- dr = dt.NewRow();
- dr["Country"] = "(" + num[RowOrder] + ")" + ad.Country;
- dr["TalkCase"] = "1、" + ad.TalkCase;
- dt.Rows.Add(dr);
- TalkcaseOrder = 0;
- }
- }
- else
- {
- dr["Country"] = "(" + num[i] + ")" + ad.Country;
- dr["TalkCase"] = "1、" + ad.TalkCase;
- dt.Rows.Add(dr);
- }
- id = ad.Id;
- }
- //模板路径
- var tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/省外办出访请示模板.doc";
- //载入模板
- Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
- #region 填充word内容
- #region 填充请示内容
- //利用DocumentBuilder处理表格或是书签
- Aspose.Words.DocumentBuilder builder = new DocumentBuilder(doc);
- string bookmark = "";
- try
- {
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- bookmark = bookmark
- + dt.Rows[i]["Country"].ToString() + "\r\n"
- + dt.Rows[i]["TalkCase"].ToString() + "\r\n";
- }
- }
- catch
- {
- }
- #endregion
- #region 填充word模板书签内容
- //团组信息
- var di = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == dto.DiId).FirstAsync();
- //接团客户名单实例
- string client_sql = string.Format(@"
- SELECT
- tcl.Id,
- tcl.DiId,
- tcl.IsAccompany,
- temp.*,
- u.CnName AS Operator,
- tcl.CreateTime AS OperatingTime
- FROM
- Grp_TourClientList tcl
- LEFT JOIN (
- SELECT
- dc.Id AS DcId,
- dc.LastName,
- dc.FirstName,
- ccom.CompanyFullName,
- dc.Job,
- cc.CertNo AS IDCardNo,
- dc.Sex,
- dc.BirthDay
- FROM
- Crm_DeleClient dc
- LEFT JOIN Crm_CustomerCompany ccom ON dc.CrmCompanyId = ccom.Id
- AND ccom.IsDel = 0
- LEFT JOIN Crm_CustomerCert cc ON dc.Id = cc.DcId
- AND cc.SdId = 773
- AND cc.IsDel = 0
- WHERE
- dc.IsDel = 0
- ) temp ON temp.DcId = tcl.ClientId
- LEFT JOIN Sys_Users u ON tcl.CreateUserId = u.Id
- WHERE
- tcl.IsDel = 0
- AND tcl.DiId = {0}", dto.DiId);
- var clientList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(client_sql).ToListAsync();
- //机票代码实例
- DataTable airTable = GeneralMethod.GetTableByBlackCode(dto.DiId);
- //三字码
- var threeCodes = await _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.IsDel == 0 ).ToListAsync();
- //团名
- if (doc.Range.Bookmarks["TeamName"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["TeamName"];
- mark.Text = di.TeamName;
- }
- //团长名
- if (doc.Range.Bookmarks["ClientName2"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["ClientName2"];
- if (clientList == null || clientList.Count == 0)
- {
- mark.Text = "【本团尚未录入客户名单,请联系主管!】";
- }
- else
- {
- mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
- }
- }
- if (doc.Range.Bookmarks["ClientName"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["ClientName"];
- if (clientList == null || clientList.Count == 0)
- {
- mark.Text = "【本团尚未录入客户名单,请联系主管!】";
- }
- else
- {
- mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
- }
- }
- //跟团人数
- if (doc.Range.Bookmarks["ClientNumber2"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["ClientNumber2"];
- mark.Text = di.VisitPNumber.ToString();
- }
- if (doc.Range.Bookmarks["ClientNumber"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["ClientNumber"];
- mark.Text = di.VisitPNumber.ToString();
- }
- //地区
- if (doc.Range.Bookmarks["Area"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Area"];
- mark.Text = Area.TrimEnd('、');
- }
- if (doc.Range.Bookmarks["Area2"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Area2"];
- mark.Text = Area.TrimEnd('、');
- }
- //出访目的
- if (doc.Range.Bookmarks["Destination2"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Destination2"];
- mark.Text = di.VisitPurpose;
- }
- if (doc.Range.Bookmarks["Destination"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Destination"];
- mark.Text = di.VisitPurpose;
- }
- //邀请方
- if (doc.Range.Bookmarks["Official"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Official"];
- mark.Text = Official.TrimEnd('、');
- }
- //出访日期
- if (doc.Range.Bookmarks["VisitDate"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["VisitDate"];
- mark.Text = di.VisitStartDate.Year + "年"
- + di.VisitStartDate.Month + "月"
- + di.VisitStartDate.Day + "日"
- + "至"
- + di.VisitEndDate.Month + "月"
- + di.VisitEndDate.Day + "日";
- }
- //请示范例
- if (doc.Range.Bookmarks["Temp"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Temp"];
- mark.Text = bookmark;
- }
- //出访起止日期
- if (doc.Range.Bookmarks["Duration"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Duration"];
- mark.Text = di.VisitStartDate.Year + "年"
- + di.VisitStartDate.Month + "月"
- + di.VisitStartDate.Day + "日"
- + "至"
- + di.VisitEndDate.Month + "月"
- + di.VisitEndDate.Day + "日";
- }
- //出访天数
- if (doc.Range.Bookmarks["Durationdays"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Durationdays"];
- mark.Text = di.VisitDays.ToString();
- }
- if (doc.Range.Bookmarks["Durationdays2"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Durationdays2"];
- mark.Text = di.VisitDays.ToString();
- }
- #region 根据黑屏代码获取国家呆的天数;获取路线
- string result_CountryAndDay = "", result_Air = "";
- if (airTable.Rows[airTable.Rows.Count - 1]["Day"].ToString() == "")
- {
- result_CountryAndDay = airTable.Rows[airTable.Rows.Count - 1]["Fliagtcode"].ToString();
- result_Air = result_CountryAndDay;
- }
- else
- {
- string place_start, place_end;
- DateTime time_start, time_end;
- Res_ThreeCode three = null;
- for (int i = 0; i < airTable.Rows.Count; i++)
- {
- //三字码实例
- three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(0, 3));
- if (three == null)
- {
- place_start = "【未收录三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
- }
- else
- {
- if (string.IsNullOrEmpty(three.Country))
- {
- place_start = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
- }
- else
- {
- place_start = three.City;
- }
- }
- three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(3, 3));
- if (three == null)
- {
- place_end = "【未收录" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
- }
- else
- {
- if (string.IsNullOrEmpty(three.Country))
- {
- place_end = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
- }
- else
- {
- place_end = three.City;
- }
- }
- result_Air += place_start + "一" + place_end + "一";
- //获取国家和呆的天数
- if (i > 0 && i < airTable.Rows.Count - 1)
- {
- time_start = Convert.ToDateTime(airTable.Rows[i - 1]["Day"]);
- time_end = Convert.ToDateTime(airTable.Rows[i]["Day"]);
- TimeSpan daycount = time_end.Subtract(time_start);
- result_CountryAndDay += place_start + daycount.Days + "天" + ",";
- }
- }
- }
- #endregion
- //每个国家呆的天数
- if (doc.Range.Bookmarks["CountryAndDay"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["CountryAndDay"];
- mark.Text = result_CountryAndDay.TrimEnd(',');
- }
- #region 出访路线城市字符串去重
- result_Air = result_Air.TrimEnd('一');
- string[] airTemp = result_Air.Split('一');
- airTemp = airTemp.Distinct().ToArray();
- result_Air = "";
- foreach (string str in airTemp)
- {
- result_Air += str + "一";
- }
- result_Air = result_Air + airTemp[0];
- #endregion
- //出访路线
- if (doc.Range.Bookmarks["Air"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Air"];
- mark.Text = result_Air;
- }
- #endregion
- #region 客户名单
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- Aspose.Words.Tables.Table tableClient = allTables[0] as Aspose.Words.Tables.Table;
- if (clientList == null || clientList.Count == 0)
- {
- builder.MoveToCell(0, 1, 0, 0);
- builder.Write("【本团尚未录入客户名单,请联系主管!】");
- }
- else
- {
- for (int i = 0; i < clientList.Count(); i++)
- {
- builder.MoveToCell(0, i + 1, 0, 0);
- builder.Write((i + 1).ToString());
- builder.MoveToCell(0, i + 1, 1, 0);
- builder.Write(clientList[i].LastName.ToString() + clientList[i].FirstName.ToString());
- builder.MoveToCell(0, i + 1, 2, 0);
- builder.Write(clientList[i].Sex.ToString());
- builder.MoveToCell(0, i + 1, 3, 0);
- builder.Write(clientList[i].BirthDay);
- builder.MoveToCell(0, i + 1, 4, 0);
- builder.Write(clientList[i].CompanyFullName + clientList[i].Job.ToString());
- }
- }
- while (tableClient.Rows.Count > clientList.Count + 1)
- {
- tableClient.Rows.RemoveAt(clientList.Count + 1);
- }
- #endregion
- #region 商邀行程
- string content = "", temp1 = "", temp2 = "";
- //获取数据,放到datatable
- var listapt = await _sqlSugar.Queryable<Grp_ApprovalTravel>()
- .LeftJoin<Grp_ApprovalTravelDetails>((at, atd) => at.Id == atd.ParentId)
- .Where((at, atd) => at.IsDel == 0 && at.Diid == dto.DiId)
- .Select((at, atd) => new
- {
- at.Id,
- at.Date,
- atd.Time,
- atd.Details
- })
- .ToListAsync();
- if (listapt == null || listapt.Count == 0)
- {
- content = "尚未生成商邀行程";
- }
- else
- {
- for (int i = 0; i < listapt.Count; i++)
- {
- content = content + " " + listapt[i].Date + "\r\n";
- temp1 = listapt[i].Time;
- temp2 = listapt[i].Details;
- if (!string.IsNullOrEmpty(temp1))
- {
- string[] str = temp1.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- string[] str2 = temp2.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- for (int j = 0; j < str.Count(); j++)
- {
- content = content + " " + str[j] + str2[j] + "\r\n";
- }
- }
- }
- }
- if (doc.Range.Bookmarks["Content"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Content"];
- mark.Text = content;
- }
- while (tableClient.Rows.Count > 1 + clientList.Count)
- {
- tableClient.Rows.RemoveAt(1 + clientList.Count);
- }
- #endregion
- #endregion
- string strFileName = $"/AskData/省外办出访请示{Guid.NewGuid().ToString()}.doc";
- doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
- var url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
- return Ok(JsonView(true,"操作成功!",new { url = url }));
- }
- /// <summary>
- /// 请示资料信息
- /// 市外办下载
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> AskDataCityFAOPFile(AskDataProvinceFileDto dto)
- {
- if (dto.DataIdItem.Length < 1) return Ok(JsonView(false, $"请传入有效的数据Id集合!"));
- if (dto.DiId < 1) return Ok(JsonView(false, $"请传入有效的数据DiId参数!"));
- //大写数字序号
- string[] num = { "一", "二", "三", "四", "五", "六", "七", "八", "九", "十" ,
- "十一","十二","十三","十四","十五","十六","十七","十八","十九","二十",
- "二十一","二十二","二十三","二十四","二十五","二十六","二十七","二十八","二十九","三十",
- "三十一","三十二","三十三","三十四","三十五","三十六","三十七","三十八","三十九","四十"};
- //数据源
- var idItem = dto.DataIdItem.OrderBy(x => x);
- var askDatas = await _sqlSugar.Queryable<Res_AskData>().Where(x => x.IsDel == 0 && idItem.Contains(x.Id)).ToListAsync();
- //书签名
- string Area = "",
- Official = "";
- //表格数据源
- DataTable dt = new DataTable();
- dt.Columns.Add("Country", typeof(string));
- dt.Columns.Add("TalkCase", typeof(string));
- int id = 0;
- int TalkcaseOrder = 0;
- int RowOrder = 0;
- //填充数据
- for (int i = 0; i < askDatas.Count; i++)
- {
- var ad = askDatas[i];
- Area = Area + ad.Country + ad.Area + "、";
- Official = Official + ad.UnitName + "、";
- //填充表格数据源
- DataRow dr = dt.NewRow();
- if (i > 0)
- {
- var adtemp = askDatas[i - 1];
- if (ad.Country == adtemp.Country)
- {
- TalkcaseOrder++;
- dt.Rows[RowOrder]["TalkCase"] = dt.Rows[RowOrder]["TalkCase"] + "\r\n" + (1 + TalkcaseOrder).ToString() + "、" + ad.TalkCase;
- }
- else
- {
- RowOrder++;
- dr = dt.NewRow();
- dr["Country"] = "(" + num[RowOrder] + ")" + ad.Country;
- dr["TalkCase"] = "1、" + ad.TalkCase;
- dt.Rows.Add(dr);
- TalkcaseOrder = 0;
- }
- }
- else
- {
- dr["Country"] = "(" + num[i] + ")" + ad.Country;
- dr["TalkCase"] = "1、" + ad.TalkCase;
- dt.Rows.Add(dr);
- }
- id = ad.Id;
- }
- //模板路径
- var tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/市外办出访请示.doc";
- //载入模板
- Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
- #region 填充word内容
- #region 填充请示内容
- //利用DocumentBuilder处理表格或是书签
- Aspose.Words.DocumentBuilder builder = new DocumentBuilder(doc);
- string bookmark = "";
- try
- {
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- bookmark = bookmark
- + dt.Rows[i]["Country"].ToString() + "\r\n"
- + dt.Rows[i]["TalkCase"].ToString() + "\r\n";
- }
- }
- catch
- {
- }
- #endregion
- #region 填充word模板书签内容
- //团组信息
- var di = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == dto.DiId).FirstAsync();
- //接团客户名单实例
- string client_sql = string.Format(@"
- SELECT
- tcl.Id,
- tcl.DiId,
- tcl.IsAccompany,
- temp.*,
- u.CnName AS Operator,
- tcl.CreateTime AS OperatingTime
- FROM
- Grp_TourClientList tcl
- LEFT JOIN (
- SELECT
- dc.Id AS DcId,
- dc.LastName,
- dc.FirstName,
- ccom.CompanyFullName,
- dc.Job,
- cc.CertNo AS IDCardNo,
- dc.Sex,
- dc.BirthDay
- FROM
- Crm_DeleClient dc
- LEFT JOIN Crm_CustomerCompany ccom ON dc.CrmCompanyId = ccom.Id
- AND ccom.IsDel = 0
- LEFT JOIN Crm_CustomerCert cc ON dc.Id = cc.DcId
- AND cc.SdId = 773
- AND cc.IsDel = 0
- WHERE
- dc.IsDel = 0
- ) temp ON temp.DcId = tcl.ClientId
- LEFT JOIN Sys_Users u ON tcl.CreateUserId = u.Id
- WHERE
- tcl.IsDel = 0
- AND tcl.DiId = {0}", dto.DiId);
- var clientList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(client_sql).ToListAsync();
- //机票代码实例
- DataTable airTable = GeneralMethod.GetTableByBlackCode(dto.DiId);
- //三字码
- var threeCodes = await _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.IsDel == 0).ToListAsync();
- //团名
- if (doc.Range.Bookmarks["TeamName"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["TeamName"];
- mark.Text = di.TeamName;
- }
- //团长名
- if (doc.Range.Bookmarks["ClientName2"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["ClientName2"];
- if (clientList == null || clientList.Count == 0)
- {
- mark.Text = "【本团尚未录入客户名单,请联系主管!】";
- }
- else
- {
- mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
- }
- }
- if (doc.Range.Bookmarks["ClientName"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["ClientName"];
- if (clientList == null || clientList.Count == 0)
- {
- mark.Text = "【本团尚未录入客户名单,请联系主管!】";
- }
- else
- {
- mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
- }
- }
- //跟团人数
- if (doc.Range.Bookmarks["ClientNumber2"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["ClientNumber2"];
- mark.Text = di.VisitPNumber.ToString();
- }
- if (doc.Range.Bookmarks["ClientNumber"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["ClientNumber"];
- mark.Text = di.VisitPNumber.ToString();
- }
- //地区
- if (doc.Range.Bookmarks["Area"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Area"];
- mark.Text = Area.TrimEnd('、');
- }
- if (doc.Range.Bookmarks["Area2"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Area2"];
- mark.Text = Area.TrimEnd('、');
- }
- //出访目的
- if (doc.Range.Bookmarks["Destination2"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Destination2"];
- mark.Text = di.VisitPurpose;
- }
- if (doc.Range.Bookmarks["Destination"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Destination"];
- mark.Text = di.VisitPurpose;
- }
- //邀请方
- if (doc.Range.Bookmarks["Official"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Official"];
- mark.Text = Official.TrimEnd('、');
- }
- //出访日期
- if (doc.Range.Bookmarks["VisitDate"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["VisitDate"];
- mark.Text = di.VisitStartDate.Year + "年"
- + di.VisitStartDate.Month + "月"
- + di.VisitStartDate.Day + "日"
- + "至"
- + di.VisitEndDate.Month + "月"
- + di.VisitEndDate.Day + "日";
- }
- //请示范例
- if (doc.Range.Bookmarks["Temp"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Temp"];
- mark.Text = bookmark;
- }
- //出访起止日期
- if (doc.Range.Bookmarks["Duration"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Duration"];
- mark.Text = di.VisitStartDate.Year + "年"
- + di.VisitStartDate.Month + "月"
- + di.VisitStartDate.Day + "日"
- + "至"
- + di.VisitEndDate.Month + "月"
- + di.VisitEndDate.Day + "日";
- }
- //出访天数
- if (doc.Range.Bookmarks["Durationdays"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Durationdays"];
- mark.Text = di.VisitDays.ToString();
- }
- if (doc.Range.Bookmarks["Durationdays2"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Durationdays2"];
- mark.Text = di.VisitDays.ToString();
- }
- #region 根据黑屏代码获取国家呆的天数;获取路线
- string result_CountryAndDay = "", result_Air = "";
- if (airTable.Rows[airTable.Rows.Count - 1]["Day"].ToString() == "")
- {
- result_CountryAndDay = airTable.Rows[airTable.Rows.Count - 1]["Fliagtcode"].ToString();
- result_Air = result_CountryAndDay;
- }
- else
- {
- string place_start, place_end;
- DateTime time_start, time_end;
- Res_ThreeCode three = null;
- for (int i = 0; i < airTable.Rows.Count; i++)
- {
- //三字码实例
- three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(0, 3));
- if (three == null)
- {
- place_start = "【未收录三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
- }
- else
- {
- if (string.IsNullOrEmpty(three.Country))
- {
- place_start = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
- }
- else
- {
- place_start = three.City;
- }
- }
- three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(3, 3));
- if (three == null)
- {
- place_end = "【未收录" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
- }
- else
- {
- if (string.IsNullOrEmpty(three.Country))
- {
- place_end = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
- }
- else
- {
- place_end = three.City;
- }
- }
- result_Air += place_start + "一" + place_end + "一";
- //获取国家和呆的天数
- if (i > 0 && i < airTable.Rows.Count - 1)
- {
- time_start = Convert.ToDateTime(airTable.Rows[i - 1]["Day"]);
- time_end = Convert.ToDateTime(airTable.Rows[i]["Day"]);
- TimeSpan daycount = time_end.Subtract(time_start);
- result_CountryAndDay += place_start + daycount.Days + "天" + ",";
- }
- }
- }
- #endregion
- //每个国家呆的天数
- if (doc.Range.Bookmarks["CountryAndDay"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["CountryAndDay"];
- mark.Text = result_CountryAndDay.TrimEnd(',');
- }
- #region 出访路线城市字符串去重
- result_Air = result_Air.TrimEnd('一');
- string[] airTemp = result_Air.Split('一');
- airTemp = airTemp.Distinct().ToArray();
- result_Air = "";
- foreach (string str in airTemp)
- {
- result_Air += str + "一";
- }
- result_Air = result_Air + airTemp[0];
- #endregion
- //出访路线
- if (doc.Range.Bookmarks["Air"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Air"];
- mark.Text = result_Air;
- }
- #endregion
- #region 客户名单
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- Aspose.Words.Tables.Table tableClient = allTables[0] as Aspose.Words.Tables.Table;
- if (clientList == null || clientList.Count == 0)
- {
- builder.MoveToCell(0, 1, 0, 0);
- builder.Write("【本团尚未录入客户名单,请联系主管!】");
- }
- else
- {
- for (int i = 0; i < clientList.Count(); i++)
- {
- builder.MoveToCell(0, i + 1, 0, 0);
- builder.Write((i + 1).ToString());
- builder.MoveToCell(0, i + 1, 1, 0);
- builder.Write(clientList[i].LastName.ToString() + clientList[i].FirstName.ToString());
- builder.MoveToCell(0, i + 1, 2, 0);
- builder.Write(clientList[i].Sex.ToString());
- builder.MoveToCell(0, i + 1, 3, 0);
- builder.Write(clientList[i].BirthDay);
- builder.MoveToCell(0, i + 1, 4, 0);
- builder.Write(clientList[i].CompanyFullName + clientList[i].Job.ToString());
- }
- }
- while (tableClient.Rows.Count > clientList.Count + 1)
- {
- tableClient.Rows.RemoveAt(clientList.Count + 1);
- }
- #endregion
- #region 商邀行程
- string content = "", temp1 = "", temp2 = "";
- //获取数据,放到datatable
- var listapt = await _sqlSugar.Queryable<Grp_ApprovalTravel>()
- .LeftJoin<Grp_ApprovalTravelDetails>((at, atd) => at.Id == atd.ParentId)
- .Where((at, atd) => at.IsDel == 0 && at.Diid == dto.DiId)
- .Select((at, atd) => new
- {
- at.Id,
- at.Date,
- atd.Time,
- atd.Details
- })
- .ToListAsync();
- if (listapt == null || listapt.Count == 0)
- {
- content = "尚未生成商邀行程";
- }
- else
- {
- for (int i = 0; i < listapt.Count; i++)
- {
- content = content + " " + listapt[i].Date + "\r\n";
- temp1 = listapt[i].Time;
- temp2 = listapt[i].Details;
- if (!string.IsNullOrEmpty(temp1))
- {
- string[] str = temp1.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- string[] str2 = temp2.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- for (int j = 0; j < str.Count(); j++)
- {
- content = content + " " + str[j] + str2[j] + "\r\n";
- }
- }
- }
- }
- if (doc.Range.Bookmarks["Content"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Content"];
- mark.Text = content;
- }
- while (tableClient.Rows.Count > 1 + clientList.Count)
- {
- tableClient.Rows.RemoveAt(1 + clientList.Count);
- }
- #endregion
- #endregion
- string strFileName = $"/AskData/市外办出访请示{Guid.NewGuid().ToString()}.doc";
- doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
- var url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
- return Ok(JsonView(true, "操作成功!", new { url = url }));
- }
- #endregion
- #region 机票黑屏代码
- /// <summary>
- /// 根据团组Id查询黑屏代码列表
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryTicketBlackCodeByDiId(QueryTicketBlackCodeByDiIdDto dto)
- {
- try
- {
- Result groupData = await _ticketBlackCodeRep.QueryTicketBlackCodeByDiId(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 根据黑屏代码数据Id查询信息
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryTicketBlackCodeById(QueryTicketBlackCodeByIdDto dto)
- {
- try
- {
- Result groupData = await _ticketBlackCodeRep.QueryTicketBlackCodeById(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 黑屏代码操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpTicketBlackCode(OpTicketBlackCodeDto dto)
- {
- Result groupData = await _ticketBlackCodeRep.OpTicketBlackCode(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- try
- {
- var tongzhi = _ticketBlackCodeRep.DescBlackToVisa(dto.DiId);
- if (tongzhi.Code == 0)
- {
- var info = tongzhi.Data.GetType().GetProperty("info").GetValue(tongzhi.Data) as List<string>;
- var data = tongzhi.Data.GetType().GetProperty("data").GetValue(tongzhi.Data) as List<CountryDataTime>;
- if (data != null)
- await AppNoticeLibrary.SendUserMsg_blackAirInfo_ToVisaUser(dto.DiId, data);
- }
- //行程代码变更通知
- await AppNoticeLibrary.SendUserMsg_GroupShare_ToDP(dto.DiId, dto.CreateUserId);
- }
- catch (Exception ex)
- {
- throw;
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- /// <summary>
- /// 删除黑屏代码
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelTicketBlackCode(DelBaseDto dto)
- {
- try
- {
- var res = await _ticketBlackCodeRep.SoftDeleteByIdAsync<Air_TicketBlackCode>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- #endregion
- #region 翻译人员
- /// <summary>
- /// 翻译人员库
- /// Init
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet()]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> TranslatorLibraryInit()
- {
- var currencyData = await _sqlSugar.Queryable<Sys_SetData>()
- .Where(x => x.IsDel == 0 && x.STid == 66)
- .Select(x => new {
- x.Id,
- x.Name,
- })
- .ToListAsync();
- var officialDutyData = await _sqlSugar.Queryable<Res_OfficialActivities>()
- .LeftJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
- .Where((oa, di) => oa.IsDel == 0)
- .Select((oa, di) => new
- {
- oa.Id,
- oa.Client,
- oa.DiId,
- di.TeamName
- })
- .ToListAsync();
- var officialDutyData1 = officialDutyData.GroupBy(x => x.DiId)
- .Select(g => new {
- id = g.Key,
- label = g.FirstOrDefault()?.TeamName ?? "-",
- children = g.Select(g1 => new { id = g1.Id, label = g1.Client }).ToList()
- })
- .ToList();
- var view = new {
- currencyData = currencyData,
- officialDutyData = officialDutyData1
- };
- return Ok(JsonView(view));
- }
- /// <summary>
- /// 翻译人员库
- /// 详情
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet("id")]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> TranslatorLibraryInfo(int id)
- {
- if (id <1 ) return Ok(JsonView(false,"请传入有效的Id!"));
- var info = await _translatorRep.Query(x => x.Id == id).FirstAsync();
- var view = _mapper.Map<TranslatorLibraryInfoView>(info);
- //var data1 = await _sqlSugar.Queryable<Grp_OfficialDutyLinkTranslator>().Where(x => x.TranslatorId == id).Select(x => x.Id).ToArrayAsync();
- view.OfficialDutyIdItem = await _sqlSugar
- .Queryable<Grp_OfficialDutyLinkTranslator>()
- .Where(x => x.IsDel == 0 && x.TranslatorId == id)
- .Select(x => x.OfficialDutyId)
- .ToArrayAsync();
- return Ok(JsonView(view));
- }
- /// <summary>
- /// 翻译人员库
- /// Item
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> TranslatorLibraryItem(TranslatorLibraryItemDto dto)
- {
- if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
- RefAsync<int> total = 0;
- var view = await _sqlSugar.Queryable<Res_TranslatorLibrary>()
- .Where(x => x.IsDel == 0)
- .WhereIF(!string.IsNullOrEmpty(dto.Name), x => x.Name.Contains(dto.Name))
- .Select(x => new
- {
- x.Id,
- x.Area,
- x.Name,
- Sex = x.Sex == 0 ? "未设置" : x.Sex == 1 ? "男" : "女",
- x.Tel,
- x.Email,
- x.WechatNo,
- x.Language,
- x.Price,
- //x.Currency,
- Currency = SqlFunc.Subqueryable<Sys_SetData>().Where(x1 => x1.Id == x.Currency).Select(x1 => x1.Name) ?? "-",
- CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x1.Id == x.CreateUserId).Select(x1 => x1.CnName) ?? "-",
- x.CreateTime,
- x.Remark
- })
- .OrderByDescending(x => x.CreateTime)
- .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- return Ok(JsonView(view, total));
- }
- /// <summary>
- /// 翻译人员库
- /// OP
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> TranslatorLibraryOp([FromForm]TranslatorLibraryOpDto dto)
- {
- if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
- if (dto.Status < 1 || dto.Status > 2) return Ok(JsonView(false, MsgTips.Status));
- var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
- if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
- var fileNames = new List<string>();
- //D:\FTP\File\OA2023\Office\GrpFile\TranslatorLibrary
- var fileBasePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}TranslatorLibrary";
- #region 保存文件
- if (dto.Files != null)
- {
- if (!System.IO.Directory.Exists(fileBasePath))
- {
- System.IO.Directory.CreateDirectory(fileBasePath);
- }
- foreach (var item in dto.Files)
- {
- if (item.Length < 1) continue;
- var file = item;
- // 将文件保存到指定位置
- var filePath = Path.Combine(fileBasePath, file.FileName);
- using (var stream = new FileStream(filePath, FileMode.Create))
- {
- await file.CopyToAsync(stream);
- }
- //验证文件是否上传成功
- if (!System.IO.File.Exists(filePath))
- {
- foreach (var filePathStr in fileNames)
- {
- System.IO.File.Delete(Path.Combine(fileBasePath, filePathStr));
- }
- return Ok(JsonView(false, "文件上传失败!"));
- }
- fileNames.Add(file.FileName);
- }
- }
- #endregion
- #region 参数处理
- var translatorInfo = _mapper.Map<Res_TranslatorLibrary>(dto);
- #endregion
- _sqlSugar.BeginTran();
- if (dto.Status == 1)
- {
- //验证重复
- var info = await _translatorRep.Query(x => x.Area.Equals(dto.Area) && x.Name.Equals(dto.Name)).FirstAsync();
- if (info != null) return Ok(JsonView(false, "该条数据已存在!"));
- translatorInfo.CreateUserId = currUserInfo.UserId;
- if (fileNames.Count > 0)
- {
- translatorInfo.Files = JsonConvert.SerializeObject(fileNames);
- }
- var id = await _translatorRep.AddAsync(translatorInfo);
- if (id > 0) {
- #region 新增(公务信息关联翻译人员) 关联信息
- if (dto.officialDutyIdItem != null && dto.officialDutyIdItem.Length > 0)
- {
- var officialDutyLinkTranslators = new List<Grp_OfficialDutyLinkTranslator>();
- foreach (var officialDutyId in dto.officialDutyIdItem)
- {
- officialDutyLinkTranslators.Add(new Grp_OfficialDutyLinkTranslator()
- {
- TranslatorId = id,
- OfficialDutyId = officialDutyId,
- CreateUserId = currUserInfo.UserId,
- Remark = $"翻译人员库-->添加"
- });
- }
- if (officialDutyLinkTranslators.Count > 0)
- {
- await _sqlSugar.Insertable(officialDutyLinkTranslators).ExecuteCommandAsync();
- }
- }
- #endregion
- _sqlSugar.CommitTran();
- return Ok(JsonView(true));
- }
- }
- else if (dto.Status == 2)
- {
- var info = await _translatorRep.Query(x => x.Id == dto.Id).FirstAsync();
- if (info != null)
- {
- if (!string.IsNullOrEmpty(info.Files))
- {
- try
- {
- var selectFiles = JsonConvert.DeserializeObject<List<string>>(info.Files);
- fileNames.AddRange(selectFiles);
- }
- catch (Exception)
- {
- }
- }
- }
- if (fileNames.Count > 0)
- {
- translatorInfo.Files = JsonConvert.SerializeObject(fileNames);
- }
- var upd = await _translatorRep
- .UpdateAsync(x => x.Id == dto.Id, x => new Res_TranslatorLibrary()
- {
- Area = translatorInfo.Area,
- Name = translatorInfo.Name,
- Sex = translatorInfo.Sex,
- Photo = translatorInfo.Photo,
- Tel = translatorInfo.Tel,
- Email = translatorInfo.Email,
- WechatNo = translatorInfo.WechatNo,
- OtherSocialAccounts = translatorInfo.OtherSocialAccounts,
- Language = translatorInfo.Language,
- Price = translatorInfo.Price,
- Currency = translatorInfo.Currency,
- Remark = translatorInfo.Remark,
- Files = translatorInfo.Files,
- });
- if (upd) {
- #region 更新(公务信息关联翻译人员) 关联信息
- var officialDutyLinkTranslators_select = await _sqlSugar.Queryable<Grp_OfficialDutyLinkTranslator>()
- .Where(x => x.IsDel == 0 && x.TranslatorId == dto.Id)
- .ToListAsync();
- //删除
- var officialDutyLinkTranslatorIds = officialDutyLinkTranslators_select.Select(x => x.Id).ToList();
- if (officialDutyLinkTranslatorIds.Count > 0)
- {
- await _sqlSugar.Updateable<Grp_OfficialDutyLinkTranslator>()
- .SetColumnsIF(officialDutyLinkTranslatorIds.Count > 0, x => new Grp_OfficialDutyLinkTranslator()
- {
- DeleteUserId = currUserInfo.UserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
- IsDel = 1,
- Remark = $"翻译人员库-->删除"
- })
- .Where(x => officialDutyLinkTranslatorIds.Contains(x.Id))
- .ExecuteCommandAsync();
- }
- if (dto.officialDutyIdItem != null && dto.officialDutyIdItem.Length > 0)
- {
- //添加
- var officialDutyLinkTranslators = new List<Grp_OfficialDutyLinkTranslator>();
- foreach (var officialDutyId in dto.officialDutyIdItem)
- {
- officialDutyLinkTranslators.Add(new Grp_OfficialDutyLinkTranslator()
- {
- TranslatorId = dto.Id,
- OfficialDutyId = officialDutyId,
- CreateUserId = currUserInfo.UserId,
- Remark = $"翻译人员库-->更新"
- });
- }
- if (officialDutyLinkTranslators.Count > 0)
- {
- await _sqlSugar.Insertable(officialDutyLinkTranslators).ExecuteCommandAsync();
- }
- }
-
- #endregion
- _sqlSugar.CommitTran();
- return Ok(JsonView(true));
- }
- }
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false));
- }
- /// <summary>
- /// 翻译人员库
- /// Del
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpDelete("id")]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> TranslatorLibraryDel(int id)
- {
- if (id < 1) return Ok(JsonView(false, MsgTips.Id));
- var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
- if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
- _sqlSugar.BeginTran();
- var upd = await _translatorRep.SoftDeleteByIdAsync<Res_TranslatorLibrary>(id.ToString(), currUserInfo.UserId);
- if (!upd) {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false));
- }
- #region 删除公务出访
- await _sqlSugar.Updateable<Grp_OfficialDutyLinkTranslator>()
- .SetColumns(x => new Grp_OfficialDutyLinkTranslator() {
- DeleteUserId = currUserInfo.UserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
- IsDel = 1,
- Remark = $"翻译人员库-->删除"
- })
- .Where(x => x.TranslatorId == id)
- .ExecuteCommandAsync();
- #endregion
- _sqlSugar.CommitTran();
- return Ok(JsonView(true));
- }
- #endregion
- }
- }
|