ResourceController.cs 232 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Dm.util;
  4. using EyeSoft.Collections.Generic;
  5. using EyeSoft.Extensions;
  6. using Microsoft.IdentityModel.Tokens;
  7. using NPOI.SS.UserModel;
  8. using OASystem.API.OAMethodLib;
  9. using OASystem.API.OAMethodLib.HunYuanAPI;
  10. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  11. using OASystem.Domain.AesEncryption;
  12. using OASystem.Domain.Dtos.Groups;
  13. using OASystem.Domain.Entities.Customer;
  14. using OASystem.Domain.Entities.Groups;
  15. using OASystem.Domain.ViewModels.Groups;
  16. using OASystem.Infrastructure.Repositories.Groups;
  17. using System.ComponentModel.DataAnnotations;
  18. using System.Data;
  19. using System.Diagnostics;
  20. using TencentCloud.Common;
  21. using static OASystem.API.OAMethodLib.JWTHelper;
  22. namespace OASystem.API.Controllers
  23. {
  24. /// <summary>
  25. /// 资料相关
  26. /// </summary>
  27. //[Authorize]
  28. [Route("api/[controller]/[action]")]
  29. public class ResourceController : ControllerBase
  30. {
  31. private readonly IMapper _mapper;
  32. private readonly ILogger<ResourceController> _logger;
  33. private readonly SqlSugarClient _sqlSugar;
  34. private readonly IConfiguration _config;
  35. private readonly IHunyuanService _hunyuanService;
  36. private readonly CarDataRepository _carDataRep;
  37. private readonly LocalGuideDataRepository _localGuideDataRep;
  38. private readonly ThreeCodeRepository _ThreeCodeRep;
  39. private readonly HotelDataRepository _hotelDataRep;
  40. private readonly ResItemInfoRepository _resItemInfoRep;
  41. private readonly SetDataRepository _setDataRepository;
  42. private readonly CountryFeeRepository _countryFeeRep;
  43. private readonly SetDataTypeRepository _setDataTypeRep;
  44. private readonly AirTicketAgentRepository _airTicketAgentRep;
  45. private readonly InvitationOfficialActivityDataRepository _InvitationOfficialActivityDataRep;
  46. private readonly OfficialActivitiesRepository _officialActivitiesRep;
  47. private readonly AskDataRepository _askDataRep;
  48. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  49. private readonly TourClientListRepository _tourClientListRep;
  50. private readonly DelegationInfoRepository _delegationInfoRep;
  51. private readonly TranslatorLibraryRepository _translatorRep;
  52. private readonly MediaSuppliersRepository _mediaSupplierRep;
  53. private readonly List<int> _portIds;
  54. private readonly BasicInsuranceCostRepository _insuranceCostRep;
  55. private readonly GamesBudgetMasterRepository _gamesBudgetMasterRep;
  56. private readonly OverseaVehicleRepository _overseaVehicleRep;
  57. private readonly MaterialCostRepository _materialCostRep;
  58. /// <summary>
  59. /// 签证费用归属省份静态数据
  60. /// </summary>
  61. private static readonly List<KeyValuePair<int, string>> _provinceData = new()
  62. {
  63. new(122, "四川"),
  64. new(132, "云南"),
  65. new(103, "重庆"),
  66. new(108, "贵州")
  67. };
  68. public ResourceController(
  69. IMapper mapper,
  70. IConfiguration config,
  71. ILogger<ResourceController> logger,
  72. IHunyuanService hunyuanService,
  73. SqlSugarClient sqlSugar,
  74. CarDataRepository carDataRep,
  75. LocalGuideDataRepository localGuideDataRep,
  76. ThreeCodeRepository threeCodeRep,
  77. HotelDataRepository hotelDataRep,
  78. ResItemInfoRepository resItemInfoRep,
  79. SetDataRepository setDataRepository,
  80. CountryFeeRepository countryFeeRep,
  81. SetDataTypeRepository setDataTypeRep,
  82. AirTicketAgentRepository airTicketAgentRep,
  83. InvitationOfficialActivityDataRepository invitationOfficialActivityDataRep,
  84. OfficialActivitiesRepository officialActivitiesRep,
  85. AskDataRepository askDataRep,
  86. TicketBlackCodeRepository ticketBlackCodeRep,
  87. TourClientListRepository tourClientListRep,
  88. DelegationInfoRepository delegationInfoRep,
  89. TranslatorLibraryRepository translatorRep,
  90. MediaSuppliersRepository mediaSupplierRep,
  91. BasicInsuranceCostRepository insuranceCostRep,
  92. GamesBudgetMasterRepository gamesBudgetMasterRep,
  93. OverseaVehicleRepository overseaVehicleRep,
  94. MaterialCostRepository materialCostRep
  95. )
  96. {
  97. _mapper = mapper;
  98. _config = config;
  99. _logger = logger;
  100. _hunyuanService = hunyuanService;
  101. _sqlSugar = sqlSugar;
  102. _carDataRep = carDataRep;
  103. _localGuideDataRep = localGuideDataRep;
  104. _ThreeCodeRep = threeCodeRep;
  105. _hotelDataRep = hotelDataRep;
  106. _resItemInfoRep = resItemInfoRep;
  107. _setDataRepository = setDataRepository;
  108. _countryFeeRep = countryFeeRep;
  109. _setDataTypeRep = setDataTypeRep;
  110. _airTicketAgentRep = airTicketAgentRep;
  111. _InvitationOfficialActivityDataRep = invitationOfficialActivityDataRep;
  112. _officialActivitiesRep = officialActivitiesRep;
  113. _askDataRep = askDataRep;
  114. _ticketBlackCodeRep = ticketBlackCodeRep;
  115. _tourClientListRep = tourClientListRep;
  116. _delegationInfoRep = delegationInfoRep;
  117. _translatorRep = translatorRep;
  118. _mediaSupplierRep = mediaSupplierRep;
  119. _portIds = new List<int> { 1, 2, 3 };
  120. _insuranceCostRep = insuranceCostRep;
  121. _gamesBudgetMasterRep = gamesBudgetMasterRep;
  122. _overseaVehicleRep = overseaVehicleRep;
  123. _materialCostRep = materialCostRep;
  124. }
  125. #region 车公司资料板块
  126. /// <summary>
  127. /// 车公司信息查询
  128. /// </summary>
  129. /// <returns></returns>
  130. [HttpPost]
  131. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  132. public async Task<IActionResult> QueryCarData(QueryCarDataDto dto)
  133. {
  134. Result LocalGuide = await _carDataRep.QueryCarData(dto);
  135. if (LocalGuide.Code == 0)
  136. {
  137. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  138. }
  139. else
  140. {
  141. return Ok(JsonView(false, LocalGuide.Msg));
  142. }
  143. }
  144. /// <summary>
  145. /// 车公司资料下拉框数据
  146. /// </summary>
  147. /// <returns></returns>
  148. [HttpPost]
  149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  150. public async Task<IActionResult> QueryCarSelect()
  151. {
  152. var carData = _carDataRep.QueryDto<Res_CarData, CarDataSelectView>().ToList();
  153. if (carData.Count == 0)
  154. {
  155. return Ok(JsonView(false, "暂无数据!"));
  156. }
  157. foreach (var item in carData) EncryptionProcessor.DecryptProperties(item);
  158. carData.Add(new CarDataSelectView { Id = 0, UnitArea = "全部" });
  159. carData = carData.Where((x, i) => carData.FindIndex(z => z.UnitArea == x.UnitArea) == i).ToList();
  160. carData = carData.OrderBy(x => x.Id).ToList();
  161. var data = new List<CarDataSelectView>();
  162. foreach (CarDataSelectView car in carData)
  163. {
  164. if (!string.IsNullOrWhiteSpace(car.UnitArea))
  165. {
  166. data.Add(car);
  167. }
  168. }
  169. return Ok(JsonView(true, "查询成功", data));
  170. }
  171. /// <summary>
  172. /// 根据Id查询车公司详细数据
  173. /// </summary>
  174. /// <returns></returns>
  175. [HttpPost]
  176. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  177. public async Task<IActionResult> QuerCarDataDetailById(QueryCarDataDetailDto dto)
  178. {
  179. string sql = string.Format(@" Select * From Res_CarData With(Nolock) Where Id = {0} ", dto.Id);
  180. var info = _resItemInfoRep._sqlSugar.SqlQueryable<CarDataDetailDataView>(sql).First();
  181. if (info == null)
  182. {
  183. return Ok(JsonView(false, "未找到相关数据!"));
  184. }
  185. EncryptionProcessor.DecryptProperties(info);
  186. return Ok(JsonView(true, "查询成功", info));
  187. }
  188. /// <summary>
  189. /// 车公司信息添加
  190. /// </summary>
  191. /// <returns></returns>
  192. [HttpPost]
  193. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  194. public async Task<IActionResult> AddCarData(AddCarDataDto dto)
  195. {
  196. if (string.IsNullOrEmpty(dto.UnitArea)) return Ok(JsonView(false, "请检查单位区域是否填写!"));
  197. if (string.IsNullOrEmpty(dto.UnitName)) return Ok(JsonView(false, "请检查单位名称是否填写!"));
  198. if (string.IsNullOrEmpty(dto.Contact)) return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  199. if (string.IsNullOrEmpty(dto.ContactTel)) return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  200. var carDadaInfo = _carDataRep
  201. .QueryDto<Res_CarData, CarDataView>(a => a.UnitArea == dto.UnitArea &&
  202. a.UnitName == dto.UnitName &&
  203. a.Contact == dto.Contact &&
  204. a.ContactTel == dto.ContactTel
  205. )
  206. .First();
  207. if (carDadaInfo != null) return Ok(JsonView(false, "该信息已存在,请勿重复添加!"));
  208. var carData = _mapper.Map<Res_CarData>(dto);
  209. carData.LastUpdateUserId = dto.CreateUserId;
  210. carData.LastUpdateTime = DateTime.Now;
  211. EncryptionProcessor.EncryptProperties(carData);
  212. int id = await _carDataRep.AddAsyncReturnId(carData);
  213. if (id < 1) return Ok(JsonView(false, "添加失败!"));
  214. return Ok(JsonView(true, "添加成功", new { Id = id }));
  215. }
  216. /// <summary>
  217. /// 车公司信息修改
  218. /// </summary>
  219. /// <returns></returns>
  220. [HttpPost]
  221. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  222. public async Task<IActionResult> UpCarData(UpCarDataDto dto)
  223. {
  224. if (string.IsNullOrEmpty(dto.UnitArea)) return Ok(JsonView(false, "请检查单位区域是否填写!"));
  225. if (string.IsNullOrEmpty(dto.UnitName)) return Ok(JsonView(false, "请检查单位名称是否填写!"));
  226. if (string.IsNullOrEmpty(dto.Contact)) return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  227. if (string.IsNullOrEmpty(dto.ContactTel)) return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  228. var carData = _mapper.Map<Res_CarData>(dto);
  229. carData.LastUpdateTime = DateTime.Now;
  230. EncryptionProcessor.EncryptProperties(carData);
  231. var res = await _sqlSugar.Updateable(carData)
  232. .IgnoreColumns(x => new { x.CreateUserId, x.CreateTime, x.DeleteTime, x.DeleteUserId, x.IsDel })
  233. .ExecuteCommandAsync();
  234. if (res < 1) { return Ok(JsonView(false, "修改失败!")); }
  235. return Ok(JsonView(true, "修改成功"));
  236. }
  237. /// <summary>
  238. /// 车公司信息删除
  239. /// </summary>
  240. /// <returns></returns>
  241. [HttpPost]
  242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  243. public async Task<IActionResult> DelCarData(DelCarDataDto dto)
  244. {
  245. bool res = await _carDataRep.SoftDeleteByIdAsync<Res_CarData>(dto.Id.ToString(), dto.DeleteUserId);
  246. if (!res) { return Ok(JsonView(false, "删除失败!")); }
  247. return Ok(JsonView(true, "删除成功"));
  248. }
  249. #endregion
  250. #region 导游地接资料板块
  251. [HttpPost]
  252. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  253. public async Task<IActionResult> LocalGuideBatchEncryption()
  254. {
  255. var infos = await _sqlSugar.Queryable<Res_LocalGuideData>().ToListAsync();
  256. foreach (var item in infos) EncryptionProcessor.EncryptProperties(item);
  257. await _sqlSugar.Updateable(infos).ExecuteCommandAsync();
  258. return Ok(JsonView(true));
  259. }
  260. /// <summary>
  261. /// 导游地接资料查询
  262. /// </summary>
  263. /// <param name="dto"></param>
  264. /// <returns></returns>
  265. [HttpPost]
  266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  267. public async Task<IActionResult> QueryLocalGuide(QueryLocalGuide dto)
  268. {
  269. Stopwatch stopwatch = Stopwatch.StartNew();
  270. Result LocalGuide = await _localGuideDataRep.QueryLocalGuide(dto);
  271. if (LocalGuide.Code == 0)
  272. {
  273. stopwatch.Stop();
  274. return Ok(JsonView(true, $"查询成功!耗时:{stopwatch.ElapsedMilliseconds} 毫秒", LocalGuide.Data));
  275. }
  276. stopwatch.Stop();
  277. return Ok(JsonView(false, LocalGuide.Msg + $" 耗时:{stopwatch.ElapsedMilliseconds} 毫秒"));
  278. }
  279. /// <summary>
  280. /// 导游地接资料下拉框数据
  281. /// </summary>
  282. /// <returns></returns>
  283. [HttpPost]
  284. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  285. public async Task<IActionResult> QueryLocalGuideSelect()
  286. {
  287. var localGuides = _carDataRep.QueryDto<Res_LocalGuideData, QueryLocalGuideSelectView>().ToList();
  288. if (localGuides.Count == 0)
  289. {
  290. return Ok(JsonView(false, "暂无数据!"));
  291. }
  292. foreach (var item in localGuides) EncryptionProcessor.DecryptProperties(item);
  293. localGuides.Add(new QueryLocalGuideSelectView { Id = 0, UnitArea = "全部" });
  294. localGuides = localGuides.Where((x, i) => localGuides.FindIndex(z => z.UnitArea == x.UnitArea && !string.IsNullOrEmpty(z.UnitArea)) == i).ToList();
  295. localGuides = localGuides.OrderBy(x => x.Id).ToList();
  296. var data = new List<QueryLocalGuideSelectView>();
  297. foreach (QueryLocalGuideSelectView Local in localGuides)
  298. {
  299. if (!string.IsNullOrWhiteSpace(Local.UnitArea))
  300. {
  301. data.Add(Local);
  302. }
  303. }
  304. return Ok(JsonView(true, "查询成功", data));
  305. }
  306. /// <summary>
  307. /// 根据Id查询地接详细数据
  308. /// </summary>
  309. /// <returns></returns>
  310. [HttpPost]
  311. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  312. public async Task<IActionResult> QueryLocalGuideDetailById(QueryLocalGuideDetailDto dto)
  313. {
  314. string sql = string.Format(@" Select * From Res_LocalGuideData With(Nolock) Where Id = {0} ", dto.Id);
  315. var info = _resItemInfoRep._sqlSugar.SqlQueryable<LocalGuideDetailDataView>(sql).First();
  316. if (info == null)
  317. {
  318. return Ok(JsonView(false, "未找到相关数据!"));
  319. }
  320. EncryptionProcessor.DecryptProperties(info);
  321. return Ok(JsonView(true, "查询成功", info));
  322. }
  323. /// <summary>
  324. /// 导游地接信息操作(Status:1.新增,2.修改)
  325. /// </summary>
  326. /// <returns></returns>
  327. [HttpPost]
  328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  329. public async Task<IActionResult> OperationLocalGuide(LocalGuideOperationDto dto)
  330. {
  331. if (string.IsNullOrEmpty(dto.UnitArea)) return Ok(JsonView(false, "请检查单位区域是否填写!"));
  332. if (string.IsNullOrEmpty(dto.UnitName)) return Ok(JsonView(false, "请检查单位名称是否填写!"));
  333. if (string.IsNullOrEmpty(dto.Contact)) return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  334. if (string.IsNullOrEmpty(dto.ContactTel)) return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  335. Result result = await _localGuideDataRep.LocalGuideOperation(dto);
  336. if (result.Code != 0)
  337. {
  338. return Ok(JsonView(false, result.Msg));
  339. }
  340. return Ok(JsonView(true, result.Msg));
  341. }
  342. /// <summary>
  343. /// 导游地接信息操作(删除)
  344. /// </summary>
  345. /// <returns></returns>
  346. [HttpPost]
  347. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  348. public async Task<IActionResult> DelLocalGuide(LocalGuideDelDto dto)
  349. {
  350. var res = await _localGuideDataRep.SoftDeleteByIdAsync<Res_LocalGuideData>(dto.Id.ToString(), dto.DeleteUserId);
  351. if (!res)
  352. {
  353. return Ok(JsonView(false, "删除失败"));
  354. }
  355. return Ok(JsonView(true, "删除成功!"));
  356. }
  357. #endregion
  358. #region 机场三字码信息
  359. /// <summary>
  360. /// 机场三字码查询
  361. /// </summary>
  362. /// <param name="dto"></param>
  363. /// <returns></returns>
  364. [HttpPost]
  365. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  366. public async Task<IActionResult> QueryThreeCode(QueryThreeCodeDto dto)
  367. {
  368. try
  369. {
  370. Result LocalGuide = await _ThreeCodeRep.QueryThreeCode(dto);
  371. if (LocalGuide.Code == 0)
  372. {
  373. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  374. }
  375. else
  376. {
  377. return Ok(JsonView(false, LocalGuide.Msg));
  378. }
  379. }
  380. catch (Exception ex)
  381. {
  382. return Ok(JsonView(false, "程序错误!"));
  383. throw;
  384. }
  385. }
  386. /// <summary>
  387. /// 机场三字码数据城市下拉框数据
  388. /// </summary>
  389. /// <returns></returns>
  390. [HttpPost]
  391. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  392. public async Task<IActionResult> QueryThreeCodeSelect()
  393. {
  394. try
  395. {
  396. var ThreeCode = _carDataRep.QueryDto<Res_ThreeCode, ThreeCodeSelectView>().ToList();
  397. if (ThreeCode.Count == 0)
  398. {
  399. return Ok(JsonView(false, "暂无数据!"));
  400. }
  401. ThreeCode.Add(new ThreeCodeSelectView { Id = 0, City = "全部" });
  402. ThreeCode = ThreeCode.Where((x, i) => ThreeCode.FindIndex(z => z.City == x.City && z.City != "") == i).ToList();
  403. ThreeCode = ThreeCode.OrderBy(x => x.Id).ToList();
  404. List<ThreeCodeSelectView> data = new List<ThreeCodeSelectView>();
  405. foreach (ThreeCodeSelectView _ThreeCode in ThreeCode)
  406. {
  407. if (!string.IsNullOrWhiteSpace(_ThreeCode.City))
  408. {
  409. data.Add(_ThreeCode);
  410. }
  411. }
  412. return Ok(JsonView(true, "查询成功", data));
  413. }
  414. catch (Exception)
  415. {
  416. return Ok(JsonView(false, "程序错误!"));
  417. throw;
  418. }
  419. }
  420. /// <summary>
  421. /// 机场三字码资料操作(Status:1.新增,2.修改)
  422. /// </summary>
  423. /// <param name="dto"></param>
  424. /// <returns></returns>
  425. [HttpPost]
  426. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  427. public async Task<IActionResult> OperationThreeCode(ThreeCodeOperationDto dto)
  428. {
  429. try
  430. {
  431. if (dto.Three == "")
  432. {
  433. return Ok(JsonView(false, "请检查三字码是否填写!"));
  434. }
  435. if (dto.Country == "")
  436. {
  437. return Ok(JsonView(false, "请检查国家是否填写!"));
  438. }
  439. if (dto.City == "")
  440. {
  441. return Ok(JsonView(false, "请检查城市是否填写正确!"));
  442. }
  443. if (dto.AirPort == "")
  444. {
  445. return Ok(JsonView(false, "请检查机场是否填写正确!"));
  446. }
  447. Result result = await _ThreeCodeRep.ThreeCodeOperation(dto);
  448. if (result.Code != 0)
  449. {
  450. return Ok(JsonView(false, result.Msg));
  451. }
  452. return Ok(JsonView(true, result.Msg));
  453. }
  454. catch (Exception ex)
  455. {
  456. return Ok(JsonView(false, "程序错误!"));
  457. throw;
  458. }
  459. }
  460. /// <summary>
  461. /// 机场三字码资料操作(删除)
  462. /// </summary>
  463. /// <returns></returns>
  464. [HttpPost]
  465. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  466. public async Task<IActionResult> DelThreeCode(ThreeCodeDelDto dto)
  467. {
  468. try
  469. {
  470. var res = await _ThreeCodeRep.SoftDeleteByIdAsync<Res_ThreeCode>(dto.Id.ToString(), dto.DeleteUserId);
  471. if (!res)
  472. {
  473. return Ok(JsonView(false, "删除失败"));
  474. }
  475. return Ok(JsonView(true, "删除成功!"));
  476. }
  477. catch (Exception ex)
  478. {
  479. return Ok(JsonView(false, "程序错误!"));
  480. throw;
  481. }
  482. }
  483. /// <summary>
  484. ///根据ID查询三字码信息
  485. /// </summary>
  486. /// <returns></returns>
  487. [HttpPost]
  488. public IActionResult QuerySingleThreeCode(QuerySingleThreeCode dto)
  489. {
  490. var jw = JsonView(false);
  491. var single = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Id == dto.ID && x.IsDel == 0);
  492. if (single != null)
  493. {
  494. jw = JsonView(true, "获取成功!", new
  495. {
  496. single.Three,
  497. Four = single.Four?.Trim(),
  498. single.AirPort,
  499. single.AirPort_En,
  500. single.City,
  501. single.Country,
  502. single.Remark
  503. });
  504. }
  505. else
  506. {
  507. jw.Msg = "暂无!";
  508. }
  509. return Ok(jw);
  510. }
  511. #endregion
  512. #region 代理出票合作方资料
  513. /// <summary>
  514. /// 代理出票合作方资料
  515. /// </summary>
  516. /// <param name="dto"></param>
  517. /// <returns></returns>
  518. [HttpPost]
  519. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  520. public async Task<IActionResult> QueryAirTicketAgent(DtoBase dto)
  521. {
  522. var res_AirTicketAgents = _airTicketAgentRep.Query<Res_AirTicketAgent>(a => a.IsDel == 0).ToList();
  523. if (res_AirTicketAgents.Count > 1)
  524. {
  525. res_AirTicketAgents = res_AirTicketAgents.OrderByDescending(a => a.CreateTime).ToList();
  526. if (dto.PageSize == 0 && dto.PageIndex == 0)
  527. {
  528. foreach (var item in res_AirTicketAgents) EncryptionProcessor.DecryptProperties(item);
  529. return Ok(JsonView(true, "查询成功!", res_AirTicketAgents));
  530. }
  531. else
  532. {
  533. int count = res_AirTicketAgents.Count;
  534. float totalPage = (float)count / dto.PageSize;//总页数
  535. if (totalPage == 0) totalPage = 1;
  536. else totalPage = (int)Math.Ceiling((double)totalPage);
  537. var _AirTicketAgent = new List<Res_AirTicketAgent>();
  538. for (int i = 0; i < dto.PageSize; i++)
  539. {
  540. var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
  541. if (RowIndex < res_AirTicketAgents.Count)
  542. {
  543. EncryptionProcessor.DecryptProperties(res_AirTicketAgents[RowIndex]);
  544. _AirTicketAgent.Add(res_AirTicketAgents[RowIndex]);
  545. }
  546. else break;
  547. }
  548. return Ok(JsonView(true, "查询成功!", new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = _AirTicketAgent }));
  549. }
  550. }
  551. return Ok(JsonView(false, "暂无数据!"));
  552. }
  553. /// <summary>
  554. /// 代理出票合作方资料操作(Status:1.新增,2.修改)
  555. /// </summary>
  556. /// <param name="dto"></param>
  557. /// <returns></returns>
  558. [HttpPost]
  559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  560. public async Task<IActionResult> OpAirTicketAgent(OpAirTicketAgentDto dto)
  561. {
  562. if (string.IsNullOrEmpty(dto.Account)) return Ok(JsonView(false, "请检查代理商账户是否填写!"));
  563. if (string.IsNullOrEmpty(dto.Bank)) return Ok(JsonView(false, "请检查代理商银行是否填写!"));
  564. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "请检查代理商名称是否填写正确!"));
  565. Result result = await _airTicketAgentRep.OpAirTicketAgent(dto);
  566. if (result.Code != 0) return Ok(JsonView(false, result.Msg));
  567. return Ok(JsonView(true, result.Msg));
  568. }
  569. /// <summary>
  570. /// 代理出票合作方资料操作(删除)
  571. /// </summary>
  572. /// <returns></returns>
  573. [HttpPost]
  574. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  575. public async Task<IActionResult> DelAirTicketAgent(DelBaseDto dto)
  576. {
  577. var res = await _airTicketAgentRep.SoftDeleteByIdAsync<Res_AirTicketAgent>(dto.Id.ToString(), dto.DeleteUserId);
  578. if (!res) return Ok(JsonView(false, "删除失败"));
  579. return Ok(JsonView(true, "删除成功!"));
  580. }
  581. #endregion
  582. #region 酒店资料数据
  583. /// <summary>
  584. /// 酒店信息查询 Page
  585. /// </summary>
  586. /// <param name="dto"></param>
  587. /// <returns></returns>
  588. [HttpPost]
  589. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  590. public async Task<IActionResult> QueryHotelData(QueryHotelDataDto dto)
  591. {
  592. string sqlWhere = string.Empty;
  593. if (!string.IsNullOrWhiteSpace(dto.Name))
  594. {
  595. sqlWhere += string.Format(@" And hd.Name like '%{0}%'", AesEncryptionHelper.Encrypt(dto.Name));
  596. }
  597. if (!string.IsNullOrWhiteSpace(dto.City) && dto.City != "全部")
  598. {
  599. sqlWhere += string.Format(@" And hd.City like '%{0}%'", AesEncryptionHelper.Encrypt(dto.City));
  600. }
  601. if (!string.IsNullOrWhiteSpace(dto.Contact))
  602. {
  603. sqlWhere += string.Format(@" And hd.Contact like '%{0}%'", AesEncryptionHelper.Encrypt(dto.Contact));
  604. }
  605. if (!string.IsNullOrWhiteSpace(dto.ContactPhone))
  606. {
  607. sqlWhere += string.Format(@" And hd.ContactPhone like '%{0}%'", AesEncryptionHelper.Encrypt(dto.ContactPhone));
  608. }
  609. sqlWhere += string.Format(@" And hd.IsDel={0}", 0);
  610. if (!string.IsNullOrEmpty(sqlWhere.Trim()))
  611. {
  612. Regex r = new Regex("And");
  613. sqlWhere = r.Replace(sqlWhere, "Where", 1);
  614. }
  615. string sql = string.Format(@"SELECT
  616. *
  617. FROM
  618. (
  619. SELECT
  620. ROW_NUMBER() OVER (
  621. ORDER BY
  622. hd.CreateTime DESC
  623. ) AS Row_Number,
  624. hd.Id,
  625. hd.City,
  626. hd.[Name],
  627. hd.Tel,
  628. hd.Fax,
  629. hd.Contact,
  630. hd.ContactPhone,
  631. u.CnName AS CreateUserName,
  632. hd.CreateTime
  633. FROM
  634. Res_HotelData hd
  635. WITH
  636. (NoLock)
  637. LEFT JOIN Sys_Users u
  638. WITH
  639. (NoLock) ON hd.CreateUserId = u.Id {0}
  640. ) Temp
  641. ", sqlWhere);
  642. if (dto.PortType == 1)
  643. {
  644. var HotelDataData = await _sqlSugar.SqlQueryable<HotelDataItemView>(sql).ToListAsync();
  645. if (HotelDataData.Count == 0)
  646. {
  647. return Ok(JsonView(false, "暂无数据"));
  648. }
  649. foreach (var item in HotelDataData)
  650. {
  651. EncryptionProcessor.DecryptProperties(item);
  652. }
  653. return Ok(JsonView(true, "操作成功", HotelDataData));
  654. }
  655. else if (dto.PortType == 2 || dto.PortType == 3)
  656. {
  657. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  658. var data = await _sqlSugar.SqlQueryable<HotelDataItemView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total); //ToPageAsync
  659. foreach (var item in data) EncryptionProcessor.DecryptProperties(item);
  660. return Ok(JsonView(true, "操作成功", data, total));
  661. }
  662. else return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
  663. }
  664. /// <summary>
  665. /// 酒店资料
  666. /// 详情
  667. /// add time:2024-05-14 11:57:10
  668. /// </summary>
  669. /// <returns></returns>
  670. [HttpPost]
  671. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  672. public async Task<IActionResult> QueryHotelDataInfo(QueryHotelDataInfoDto dto)
  673. {
  674. var _view = await _hotelDataRep._Info(dto.PortType, dto.Id);
  675. if (_view.Code == 0)
  676. {
  677. return Ok(JsonView(true, _view.Msg, _view.Data));
  678. }
  679. return Ok(JsonView(false, _view.Msg));
  680. }
  681. /// <summary>
  682. /// 酒店资料下拉框数据
  683. /// </summary>
  684. /// <returns></returns>
  685. [HttpPost]
  686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  687. public async Task<IActionResult> QueryHotelDataSelect()
  688. {
  689. try
  690. {
  691. var HotelData = _carDataRep.QueryDto<Res_HotelData, QueryHotelDataSelect>().ToList();
  692. if (HotelData.Count == 0)
  693. {
  694. return Ok(JsonView(false, "暂无数据!"));
  695. }
  696. //解密
  697. foreach (var item in HotelData)
  698. {
  699. EncryptionProcessor.DecryptProperties(item);
  700. }
  701. HotelData.Add(new QueryHotelDataSelect { Id = 0, City = "全部" });
  702. HotelData = HotelData.Where((x, i) => HotelData.FindIndex(z => z.City == x.City && z.City != "") == i).ToList();
  703. HotelData = HotelData.OrderBy(x => x.Id).ToList();
  704. var data = new List<QueryHotelDataSelect>();
  705. foreach (var Hotel in HotelData)
  706. {
  707. if (!string.IsNullOrWhiteSpace(Hotel.City))
  708. {
  709. data.Add(Hotel);
  710. }
  711. }
  712. return Ok(JsonView(true, "查询成功", data));
  713. }
  714. catch (Exception)
  715. {
  716. return Ok(JsonView(false, "程序错误!"));
  717. throw;
  718. }
  719. }
  720. /// <summary>
  721. /// 酒店资料操作(Status:1.新增,2.修改)
  722. /// </summary>
  723. /// <param name="dto"></param>
  724. /// <returns></returns>
  725. [HttpPost]
  726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  727. public async Task<IActionResult> OperationHotelData(OperationHotelDto dto)
  728. {
  729. if (string.IsNullOrEmpty(dto.City)) return Ok(JsonView(false, "请检查酒店所在城市是否填写!"));
  730. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "请检查酒店名称是否填写!"));
  731. if (string.IsNullOrEmpty(dto.Address)) return Ok(JsonView(false, "请检查酒店地址是否填写正确!"));
  732. if (string.IsNullOrEmpty(dto.Tel)) return Ok(JsonView(false, "请检查酒店联系方式是否填写正确!"));
  733. Result result = await _hotelDataRep.OperationHotelData(dto);
  734. if (result.Code != 0) return Ok(JsonView(false, result.Msg));
  735. return Ok(JsonView(true, result.Msg));
  736. }
  737. /// <summary>
  738. /// 酒店资料操作(删除)
  739. /// </summary>
  740. /// <returns></returns>
  741. [HttpPost]
  742. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  743. public async Task<IActionResult> DelHotelData(DelHotelDataDto dto)
  744. {
  745. try
  746. {
  747. var res = await _hotelDataRep.SoftDeleteByIdAsync<Res_HotelData>(dto.Id.ToString(), dto.DeleteUserId);
  748. if (!res)
  749. {
  750. return Ok(JsonView(false, "删除失败"));
  751. }
  752. return Ok(JsonView(true, "删除成功!"));
  753. }
  754. catch (Exception ex)
  755. {
  756. return Ok(JsonView(false, "程序错误!"));
  757. throw;
  758. }
  759. }
  760. #endregion
  761. #region 签证费用资料
  762. /// <summary>
  763. /// 签证费用资料查询
  764. /// </summary>
  765. /// <param name="dto"></param>
  766. /// <returns></returns>
  767. [HttpPost]
  768. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  769. public async Task<IActionResult> QueryCountryFeeCost(DtoBase dto)
  770. {
  771. var portType = dto.PortType;
  772. if (portType != 1 && portType != 2 && portType != 3)
  773. return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
  774. var countryVisaFees = await _countryFeeRep
  775. .QueryDto<Res_CountryFeeCost, CountryFeeCostView>()
  776. .OrderByDescending(x => x.CreateTime)
  777. .ToListAsync();
  778. if (countryVisaFees == null || countryVisaFees.Count == 0)
  779. return Ok(JsonView(false, "暂无数据!"));
  780. return Ok(JsonView(true, "查询成功", countryVisaFees));
  781. }
  782. /// <summary>
  783. /// 签证费用资料查询 Page New
  784. /// </summary>
  785. /// <param name="dto"></param>
  786. /// <returns></returns>
  787. [HttpPost]
  788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  789. public async Task<IActionResult> QueryVisaCountryFeeCosts(QueryVisaCountryFeeCostsDto dto)
  790. {
  791. // 校验端口类型
  792. if (dto.PortType != 1 && dto.PortType != 2 && dto.PortType != 3)
  793. return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
  794. var portType = dto.PortType;
  795. RefAsync<int> total = 0;
  796. var query = _countryFeeRep._sqlSugar
  797. .Queryable<Res_CountryFeeCost>()
  798. .Where(x => x.IsDel == 0)
  799. .WhereIF(dto.VisaFeeType >= 0, x => x.VisaFeeType == dto.VisaFeeType)
  800. .WhereIF(!string.IsNullOrEmpty(dto.CountryName), x => x.VisaCountry.Contains(dto.CountryName))
  801. .OrderByDescending(x => x.CreateTime);
  802. var countryVisaFees = await query.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  803. if (!countryVisaFees.Any()) return Ok(JsonView(true, "暂无数据!"));
  804. var view = _mapper.Map<List<CountryFeeCostView>>(countryVisaFees);
  805. return Ok(JsonView(true, "查询成功", view, total));
  806. }
  807. /// <summary>
  808. /// 签证费用资料操作(Status:1.新增,2.修改)
  809. /// </summary>
  810. /// <param name="dto"></param>
  811. /// <returns></returns>
  812. [HttpPost]
  813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  814. public async Task<IActionResult> OperationCountryFeeCost(OperationCountryFeeCostDto dto)
  815. {
  816. if (string.IsNullOrWhiteSpace(dto.VisaContinent) || string.IsNullOrWhiteSpace(dto.VisaCountry))
  817. return Ok(JsonView(false, "请检查州名和国家名是否填写!"));
  818. return Ok(await _countryFeeRep.OperationCountryFeeCost(dto));
  819. }
  820. /// <summary>
  821. /// 签证费用资料操作(删除)
  822. /// </summary>
  823. /// <returns></returns>
  824. [HttpPost]
  825. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  826. public async Task<IActionResult> DelCountryFeeCost(DelCountryFeeCostDto dto)
  827. {
  828. var res = await _countryFeeRep.SoftDeleteByIdAsync<Res_CountryFeeCost>(dto.Id.ToString(), dto.DeleteUserId);
  829. if (!res) return Ok(JsonView(false, "删除失败"));
  830. return Ok(JsonView(true, "删除成功!"));
  831. }
  832. #endregion
  833. #region 签证费用资料 New
  834. /// <summary>
  835. /// 签证费用标准 Init
  836. /// </summary>
  837. /// <returns></returns>
  838. [HttpPost]
  839. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  840. public async Task<IActionResult> VisaFeeStandardInit()
  841. {
  842. //签证费用类型数据
  843. var visaFeeTypeData = new List<KeyValuePair<int, string>>
  844. {
  845. new(0, "因公"),
  846. new(1, "因私")
  847. };
  848. //签证费用归属省份
  849. var data = new
  850. {
  851. VisaFeeType = visaFeeTypeData.Select(x => new { Id = x.Key, Text = x.Value }),
  852. Province = _provinceData.Select(x => new { Id = x.Key, Text = x.Value })
  853. };
  854. return Ok(JsonView(data));
  855. }
  856. /// <summary>
  857. /// 签证费用标准 Info
  858. /// </summary>
  859. /// <param name="dto"></param>
  860. /// <returns></returns>
  861. [HttpPost]
  862. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  863. public async Task<IActionResult> VisaFeeStandardInfo(VisaFeeStandardInfoDto dto)
  864. {
  865. var portType = dto.PortType;
  866. if (portType != 1 && portType != 2 && portType != 3)
  867. return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
  868. return Ok(await _countryFeeRep.InfoAsync(dto.Id));
  869. }
  870. /// <summary>
  871. /// 签证费用标准 List
  872. /// </summary>
  873. /// <param name="dto"></param>
  874. /// <returns></returns>
  875. [HttpPost]
  876. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  877. public async Task<IActionResult> VisaFeeStandardList(VisaFeeStandardListDto dto)
  878. {
  879. return Ok(await _countryFeeRep.PageListAsync(dto));
  880. }
  881. /// <summary>
  882. /// 签证费用标准 Save
  883. /// </summary>
  884. /// <param name="dto"></param>
  885. /// <returns></returns>
  886. [HttpPost]
  887. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  888. public async Task<IActionResult> VisaFeeStandardSave(VisaFeeStandardSaveDto dto)
  889. {
  890. return Ok(await _countryFeeRep.SaveAsync(dto));
  891. }
  892. /// <summary>
  893. /// 签证费用标准 SoftDel
  894. /// </summary>
  895. /// <param name="dto"></param>
  896. /// <returns></returns>
  897. [HttpPost]
  898. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  899. public async Task<IActionResult> VisaFeeStandardSoftDel(VisaFeeStandardSoftDelDto dto)
  900. {
  901. return Ok(await _countryFeeRep.SoftDelAsync(dto.CurrUserId, dto.Id));
  902. }
  903. /// <summary>
  904. /// 根据省份获取签证费用报价
  905. /// </summary>
  906. /// <param name="dto"></param>
  907. /// <returns></returns>
  908. [HttpPost]
  909. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  910. public async Task<IActionResult> VisaFeeQuoteByProvince(VisaFeesByProvinceDto dto)
  911. {
  912. //省份验证
  913. var provinceIds = _provinceData.Select(x => x.Key).ToList();
  914. if (!provinceIds.Contains(dto.ProvinceId))
  915. {
  916. return Ok(JsonView(false, "请选择有效的省份!"));
  917. }
  918. return Ok(await _countryFeeRep.VisaFeeQuoteAsync(dto.ProvinceId, dto.CountryName));
  919. }
  920. #endregion
  921. #region 物料信息、供应商维护
  922. #region 供应商
  923. /// <summary>
  924. /// 物料供应商查询
  925. /// </summary>
  926. /// <param name="_jsonDto">Json序列化</param>
  927. /// <returns></returns>
  928. [HttpPost]
  929. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  930. public async Task<IActionResult> PostSearchItemVendor(JsonDtoBase _jsonDto)
  931. {
  932. if (string.IsNullOrEmpty(_jsonDto.Paras))
  933. {
  934. return Ok(JsonView(false, "参数为空"));
  935. }
  936. Search_ResItemVendorDto _ItemVendorDto = System.Text.Json.JsonSerializer.Deserialize<Search_ResItemVendorDto>(_jsonDto.Paras);
  937. if (_ItemVendorDto != null)
  938. {
  939. if (_ItemVendorDto.SearchType == 2) //获取列表
  940. {
  941. Res_ItemVendorListView rstList = _resItemInfoRep.GetVendorList(_ItemVendorDto);
  942. return Ok(rstList);
  943. }
  944. else
  945. {
  946. Res_ItemVendorView rstInfo = _resItemInfoRep.getVendorInfo(_ItemVendorDto);
  947. return Ok(rstInfo);
  948. }
  949. }
  950. else
  951. {
  952. return Ok(JsonView(false, "参数反序列化失败"));
  953. }
  954. //return Ok(JsonView(false));
  955. }
  956. /// <summary>
  957. /// 创建/编辑/删除供应商信息
  958. /// </summary>
  959. /// <param name="_dto"></param>
  960. /// <returns></returns>
  961. [HttpPost]
  962. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  963. public async Task<IActionResult> PostEditItemVendor(Edit_ResItemVendorDto _dto)
  964. {
  965. bool rst = false;
  966. if (_dto.EditType >= 0)
  967. {
  968. if (string.IsNullOrEmpty(_dto.VendorFullName))
  969. {
  970. return Ok(JsonView(false, "全称未填写"));
  971. }
  972. if (string.IsNullOrEmpty(_dto.VendorLinker))
  973. {
  974. return Ok(JsonView(false, "联系人未填写"));
  975. }
  976. if (string.IsNullOrEmpty(_dto.VendorMobile))
  977. {
  978. return Ok(JsonView(false, "联系人手机号未填写"));
  979. }
  980. if (string.IsNullOrEmpty(_dto.BusRange))
  981. {
  982. return Ok(JsonView(false, "经营范围未选择"));
  983. }
  984. if (_dto.EditType == 0)
  985. {
  986. var checkEmpty = _resItemInfoRep.Query<Res_ItemVendor>(s => s.FullName == _dto.VendorFullName).First();
  987. if (checkEmpty != null)
  988. {
  989. return Ok(JsonView(false, "已存在同名供应商"));
  990. }
  991. rst = await _resItemInfoRep.addVendorInfo(_dto);
  992. }
  993. else if (_dto.EditType == 1)
  994. {
  995. if (_dto.VendorId > 0)
  996. {
  997. Res_ItemVendor _entity = _mapper.Map<Res_ItemVendor>(_dto);
  998. rst = await _resItemInfoRep.updVendorInfo(_entity);
  999. }
  1000. else
  1001. {
  1002. return Ok(JsonView(false, "供应商不存在"));
  1003. }
  1004. }
  1005. }
  1006. else
  1007. {
  1008. if (_dto.VendorId < 1 || _dto.SysUserId < 1)
  1009. {
  1010. return Ok(JsonView(false, "用户Id或供应商Id不存在"));
  1011. }
  1012. Res_ItemVendor _entity = _mapper.Map<Res_ItemVendor>(_dto);
  1013. rst = await _resItemInfoRep.delVendorInfo(_entity);
  1014. }
  1015. return Ok(JsonView(rst));
  1016. }
  1017. #endregion
  1018. #region 物料信息
  1019. /// <summary>
  1020. /// 物料信息查询
  1021. /// </summary>
  1022. /// <param name="paras">Json序列化</param>
  1023. /// <returns></returns>
  1024. [HttpPost]
  1025. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1026. public async Task<IActionResult> PostSearchItemInfo(string paras)
  1027. {
  1028. if (string.IsNullOrEmpty(paras))
  1029. {
  1030. return Ok(JsonView(false, "参数为空"));
  1031. }
  1032. Search_ItemInfoDto _ItemInfoDto = System.Text.Json.JsonSerializer.Deserialize<Search_ItemInfoDto>(paras);
  1033. if (_ItemInfoDto != null)
  1034. {
  1035. if (_ItemInfoDto.SearchType == 2) //获取列表
  1036. {
  1037. Res_ItemInfoListView rstList = _resItemInfoRep.GetItemList(_ItemInfoDto);
  1038. return Ok(rstList);
  1039. }
  1040. else
  1041. {
  1042. Res_ItemInfoView rstInfo = _resItemInfoRep.getItemInfo(_ItemInfoDto);
  1043. return Ok(rstInfo);
  1044. }
  1045. }
  1046. else
  1047. {
  1048. return Ok(JsonView(false, "参数反序列化失败"));
  1049. }
  1050. //return Ok(JsonView(false));
  1051. }
  1052. /// <summary>
  1053. /// 创建/编辑/删除物料信息
  1054. /// </summary>
  1055. ///
  1056. /// <returns></returns>
  1057. [HttpPost]
  1058. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1059. public async Task<IActionResult> PostEditItemInfo(Edit_ResItemInfoDto _dto)
  1060. {
  1061. bool rst = false;
  1062. if (_dto.EditType >= 0)
  1063. {
  1064. if (_dto.VendorId < 1)
  1065. {
  1066. return Ok(JsonView(false, "未选择供应商"));
  1067. }
  1068. if (string.IsNullOrEmpty(_dto.ItemName))
  1069. {
  1070. return Ok(JsonView(false, "物料名称为空"));
  1071. }
  1072. if (_dto.ItemTypeId < 1)
  1073. {
  1074. return Ok(JsonView(false, "未选择物料类型"));
  1075. }
  1076. if (_dto.SysUserId < 1)
  1077. {
  1078. return Ok(JsonView(false, "当前操作用户Id为空"));
  1079. }
  1080. if (_dto.CurrRate <= 0)
  1081. {
  1082. return Ok(JsonView(false, "物料录入价格不能小于等于0"));
  1083. }
  1084. if (_dto.EditType == 0)
  1085. {
  1086. //判断物料名称、类型、供应商全部重复
  1087. var checkEmpty = _resItemInfoRep.Query<Res_ItemDetailInfo>(s => s.ItemName == _dto.ItemName && s.ItemTypeId == _dto.ItemTypeId && s.VendorId == _dto.VendorId).First();
  1088. if (checkEmpty != null)
  1089. {
  1090. return Ok(JsonView(false, "已存在重复物料信息"));
  1091. }
  1092. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  1093. DateTime dtNow = DateTime.Now;
  1094. _entity.CreateUserId = _dto.SysUserId;
  1095. _entity.IsDel = 0;
  1096. _entity.MaxRate = _dto.CurrRate;
  1097. _entity.MaxDt = dtNow;
  1098. _entity.CurrRate = _dto.CurrRate;
  1099. _entity.CurrDt = dtNow;
  1100. _entity.MinRate = _dto.CurrRate;
  1101. _entity.MinDt = dtNow;
  1102. rst = await _resItemInfoRep.AddAsync<Res_ItemDetailInfo>(_entity) > 0;
  1103. }
  1104. else if (_dto.EditType == 1)
  1105. {
  1106. if (_dto.ItemId > 0)
  1107. {
  1108. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  1109. _entity.Id = _dto.ItemId;
  1110. rst = await _resItemInfoRep.updItemInfo(_entity);
  1111. }
  1112. else
  1113. {
  1114. return Ok(JsonView(false, "供应商不存在"));
  1115. }
  1116. }
  1117. }
  1118. else
  1119. {
  1120. if (_dto.ItemId < 1 || _dto.SysUserId < 1)
  1121. {
  1122. return Ok(JsonView(false, "用户Id或物料信息Id不存在"));
  1123. }
  1124. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  1125. rst = await _resItemInfoRep.delItemInfo(_entity);
  1126. }
  1127. return Ok(JsonView(rst));
  1128. }
  1129. #endregion
  1130. #region 物料类型获取
  1131. #endregion
  1132. #endregion
  1133. #region 备忘录
  1134. /// <summary>
  1135. /// 备忘录查询
  1136. /// </summary>
  1137. /// <param name="_jsonDto">Json序列化</param>
  1138. /// <returns></returns>
  1139. [HttpPost]
  1140. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1141. public async Task<IActionResult> PostSearchMemo(JsonDtoBase _jsonDto)
  1142. {
  1143. if (string.IsNullOrEmpty(_jsonDto.Paras))
  1144. {
  1145. return Ok(JsonView(false, "参数为空"));
  1146. }
  1147. Search_ResMemoDto _memoDto = JsonConvert.DeserializeObject<Search_ResMemoDto>(_jsonDto.Paras);
  1148. if (_memoDto != null)
  1149. {
  1150. if (_memoDto.SearchType == 2)
  1151. {
  1152. //获取列表
  1153. string sqlWhere = string.Format(" Where IsDel=0 ");
  1154. #region SqlWhere
  1155. if (!string.IsNullOrEmpty(_memoDto.Abstracts))
  1156. {
  1157. sqlWhere += string.Format(@" And m.Abstracts Like '%{0}%' ", _memoDto.Abstracts);
  1158. }
  1159. if (!string.IsNullOrEmpty(_memoDto.Title))
  1160. {
  1161. sqlWhere += string.Format(@" And m.Title Like '%{0}%' ", _memoDto.Title);
  1162. }
  1163. if (_memoDto.ReadLevel > 0)
  1164. {
  1165. sqlWhere += string.Format(@" And m.ReadLevel = {0} ", _memoDto.ReadLevel);
  1166. }
  1167. #endregion
  1168. int currPIndex = (((_memoDto.PageIndex > 0) ? (_memoDto.PageIndex - 1) : 0) * _memoDto.PageSize) + 1;
  1169. int currPSize = (((_memoDto.PageIndex > 0) ? (_memoDto.PageIndex - 1) : 0) + 1) * _memoDto.PageSize;
  1170. string sql = string.Format(@" Select * From(Select ROW_NUMBER() Over(order By m.Id desc) as RowNumber,
  1171. m.Id as MemoId,d.DepName as DepartmentName,m.ReadLevel,m.Title,m.Abstracts,
  1172. m.LastedEditDt,m.LastedEditorId
  1173. From Res_Memo as m With(Nolock) Inner Join Sys_Users as u With(Nolock) On m.CreateUserId=u.Id
  1174. Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id {2}
  1175. ) as tb Where tb.RowNumber Between {0} And {1} ", currPIndex, currPSize, sqlWhere);
  1176. Res_MemoListView rst = new Res_MemoListView();
  1177. rst.CurrPageIndex = currPIndex;
  1178. rst.CurrPageSize = currPSize;
  1179. List<Res_MemoView> dataSource = _carDataRep._sqlSugar.SqlQueryable<Res_MemoView>(sql).ToList();
  1180. Dictionary<int, string> userDic = new Dictionary<int, string>();
  1181. foreach (var item in dataSource)
  1182. {
  1183. if (userDic.ContainsKey(item.LastedEditorId))
  1184. {
  1185. item.LastedEditor = userDic[item.LastedEditorId];
  1186. }
  1187. else
  1188. {
  1189. var _sysUser = _carDataRep.Query<Sys_Users>(s => s.Id == item.LastedEditorId).First();
  1190. userDic[item.LastedEditorId] = _sysUser.CnName;
  1191. item.LastedEditor = _sysUser.CnName;
  1192. }
  1193. }
  1194. rst.DataList = new List<Res_MemoView>(dataSource);
  1195. if (rst.DataList.Count > 0)
  1196. {
  1197. string sqlCount = string.Format(@" Select Id From Res_Memo as m With(Nolock) {0} ", sqlWhere);
  1198. int dataCount = _carDataRep._sqlSugar.SqlQueryable<Res_MemoInfo>(sqlCount).Count();
  1199. rst.DataCount = dataCount;
  1200. }
  1201. return Ok(JsonView(rst));
  1202. }
  1203. else
  1204. {
  1205. //获取对象
  1206. string sqlSingle = string.Format(@" Select
  1207. m.Id as MemoId,d.DepName as DepartmentName,m.ReadLevel,m.Title,m.Abstracts,
  1208. m.LastedEditDt,m.LastedEditor,m.MDFilePath
  1209. From Res_Memo as m With(Nolock) Inner Join Sys_Users as u With(Nolock) On m.CreateUserId=u.Id
  1210. Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _memoDto.MemoId);
  1211. Res_MemoView _result = _carDataRep._sqlSugar.SqlQueryable<Res_MemoView>(sqlSingle).First();
  1212. if (_result != null)
  1213. {
  1214. var _sysUser = _carDataRep.Query<Sys_Users>(s => s.Id == _result.LastedEditorId).First();
  1215. _result.LastedEditor = _sysUser.CnName;
  1216. _result.MarkDownContent = new IOOperatorHelper().Read(_result.MDFilePath);
  1217. return Ok(JsonView(_result));
  1218. }
  1219. }
  1220. }
  1221. else
  1222. {
  1223. return Ok(JsonView(false, "参数反序列化失败"));
  1224. }
  1225. return Ok(JsonView(false));
  1226. }
  1227. /// <summary>
  1228. /// 创建/编辑/删除备忘录信息
  1229. /// </summary>
  1230. /// <param name="_dto"></param>
  1231. /// <returns></returns>
  1232. [HttpPost]
  1233. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1234. public async Task<IActionResult> PostEditMemo(Edit_ResMemoDto _dto)
  1235. {
  1236. bool rst = false;
  1237. if (_dto.SysUserId < 1)
  1238. {
  1239. return Ok(JsonView(false, "操作人失效"));
  1240. }
  1241. var _sysUser = _resItemInfoRep.Query<Sys_Users>(s => s.Id == _dto.SysUserId).First();
  1242. if (_sysUser == null)
  1243. {
  1244. return Ok(JsonView(false, "操作人失效02"));
  1245. }
  1246. if (_dto.EditType >= 0)
  1247. {
  1248. if (_dto.ReadLevel < 1)
  1249. {
  1250. return Ok(JsonView(false, "未知的阅读等级"));
  1251. }
  1252. if (string.IsNullOrEmpty(_dto.Title.Trim()))
  1253. {
  1254. return Ok(JsonView(false, "标题不能为空"));
  1255. }
  1256. if (string.IsNullOrEmpty(_dto.Content.Trim()))
  1257. {
  1258. return Ok(JsonView(false, "正文内容不能为空"));
  1259. }
  1260. //新增备忘录
  1261. DateTime dtNow = DateTime.Now;
  1262. string dir = AppSettingsHelper.Get("MemoCurrPath");
  1263. string fileName = dtNow.ToString("yyyyMMddHHmmss") + _dto.Title + ".md";
  1264. string content = JsonConvert.SerializeObject(_dto.Content);
  1265. if (_dto.EditType == 0)//新增
  1266. {
  1267. string savePath = new IOOperatorHelper().Write_CoverFile(content, dir, fileName);
  1268. if (savePath.Length > 0)
  1269. {
  1270. Res_MemoInfo _insert = new Res_MemoInfo();
  1271. _insert.Abstracts = _dto.Abstracts;
  1272. _insert.Title = _dto.Title;
  1273. _insert.DepartmentId = _sysUser.DepId;
  1274. _insert.CreateUserId = _sysUser.Id;
  1275. _insert.LastedEditDt = dtNow;
  1276. _insert.LastedEditor = _sysUser.Id;
  1277. _insert.MDFilePath = savePath;
  1278. _insert.ReadLevel = _dto.ReadLevel;
  1279. _insert.Title = _dto.Title;
  1280. int result = await _resItemInfoRep.AddAsync(_insert);
  1281. return Ok(JsonView(result > 0));
  1282. }
  1283. else
  1284. {
  1285. return Ok(JsonView(false, "路径保存失败"));
  1286. }
  1287. }
  1288. else//修改
  1289. {
  1290. if (_dto.MemoId < 1)
  1291. {
  1292. return Ok(JsonView(false, "MemoId不存在"));
  1293. }
  1294. Res_MemoInfo _source = _resItemInfoRep.Query<Res_MemoInfo>(s => s.Id == _dto.MemoId).First();
  1295. if (_source == null)
  1296. {
  1297. return Ok(JsonView(false, "MemoInfo不存在"));
  1298. }
  1299. //修改
  1300. string sourcePath = _source.MDFilePath;
  1301. string recycDir = AppSettingsHelper.Get("MemoRecycleBinPath");
  1302. new IOOperatorHelper().MoveFile(sourcePath, recycDir);
  1303. string savePath = new IOOperatorHelper().Write_CoverFile(content, dir, fileName);
  1304. if (savePath.Length > 0)
  1305. {
  1306. var result = await _resItemInfoRep._sqlSugar.Updateable<Res_MemoInfo>()
  1307. .SetColumns(it => it.LastedEditDt == DateTime.Now)
  1308. .SetColumns(it => it.LastedEditor == _sysUser.Id)
  1309. .SetColumns(it => it.Abstracts == _dto.Abstracts)
  1310. .SetColumns(it => it.MDFilePath == savePath)
  1311. .SetColumns(it => it.ReadLevel == _dto.ReadLevel)
  1312. .SetColumns(it => it.Title == _dto.Title)
  1313. .Where(s => s.Id == _source.Id)
  1314. .ExecuteCommandAsync();
  1315. return Ok(JsonView(result > 0));
  1316. }
  1317. }
  1318. }
  1319. else
  1320. {
  1321. //删除
  1322. if (_dto.MemoId < 1)
  1323. {
  1324. return Ok(JsonView(false, "MemoId不存在"));
  1325. }
  1326. Res_MemoInfo _source = _resItemInfoRep.Query<Res_MemoInfo>(s => s.Id == _dto.MemoId).First();
  1327. if (_source == null)
  1328. {
  1329. return Ok(JsonView(false, "MemoInfo不存在"));
  1330. }
  1331. //修改
  1332. string sourcePath = _source.MDFilePath;
  1333. string recycDir = AppSettingsHelper.Get("MemoRecycleBinPath");
  1334. new IOOperatorHelper().MoveFile(sourcePath, recycDir);
  1335. var result = await _resItemInfoRep._sqlSugar.Updateable<Res_MemoInfo>()
  1336. .SetColumns(it => it.IsDel == 1)
  1337. .SetColumns(it => it.DeleteUserId == _sysUser.Id)
  1338. .SetColumns(it => it.DeleteTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  1339. .Where(s => s.Id == _source.Id)
  1340. .ExecuteCommandAsync();
  1341. return Ok(JsonView(result > 0));
  1342. }
  1343. return Ok(JsonView(rst));
  1344. }
  1345. #endregion
  1346. #region 商邀资料
  1347. /// <summary>
  1348. /// 商邀资料 基础数据源
  1349. /// </summary>
  1350. /// <param name="dto"></param>
  1351. /// <returns></returns>
  1352. [HttpPost]
  1353. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1354. public async Task<IActionResult> QueryIOAInitData(QueryIOAInitDataDto dto)
  1355. {
  1356. #region 参数验证
  1357. if (dto.PortType < 1) return Ok(JsonView(false, "请传入有效的PortType参数!"));
  1358. #endregion
  1359. var ExcludedKeyStr = new string[] { "快递费" };
  1360. var ClientKeyStr = new string[] { "邀请函翻译" };
  1361. List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.JietuanTime).ToList();
  1362. List<Res_InvitationOfficialActivityData> _ioaDatas = _sqlSugar.Queryable<Res_InvitationOfficialActivityData>()
  1363. .Where(it => it.IsDel == 0)
  1364. .Select(x => new Res_InvitationOfficialActivityData
  1365. {
  1366. Country = x.Country,
  1367. UnitName = x.UnitName,
  1368. Contact = x.Contact,
  1369. Field = x.Field,
  1370. })
  1371. .ToList();
  1372. foreach (var item in _ioaDatas)
  1373. {
  1374. EncryptionProcessor.DecryptProperties(item);
  1375. }
  1376. foreach (var item in ExcludedKeyStr)
  1377. {
  1378. _ioaDatas = _ioaDatas.Where(x => string.IsNullOrWhiteSpace(x.UnitName) || !x.UnitName.Contains(item)).ToList();
  1379. }
  1380. foreach (var item in ClientKeyStr)
  1381. {
  1382. _ioaDatas = _ioaDatas.Where(x => string.IsNullOrWhiteSpace(x.Contact) || !x.Contact.Contains(item)).ToList();
  1383. }
  1384. List<Sys_Users> _Users = _sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0).ToList();
  1385. var _countryData = _ioaDatas.Select(it => it.Country).Distinct().ToList(); _countryData.Remove("");
  1386. var _inviterData = _ioaDatas.Select(it => it.UnitName).Distinct().ToList(); _inviterData.Remove("");
  1387. var _contactData = _ioaDatas.Select(it => it.Contact).Distinct().ToList(); _contactData.Remove("");
  1388. var _domainData = _ioaDatas.Select(it => it.Field).Distinct().ToList(); _domainData.Remove("");
  1389. var _groupNameData = _DelegationInfos.Select(it => new { it.Id, it.TeamName }).ToList();
  1390. var _userNameData = _Users.Select(it => new { it.Id, it.CnName }).ToList();
  1391. var _data = new
  1392. {
  1393. CountryData = _countryData,
  1394. InviterData = _inviterData,
  1395. DomainData = _domainData,
  1396. ContactData = _contactData,
  1397. GroupNameData = _groupNameData,
  1398. UserNameData = _userNameData,
  1399. };
  1400. return Ok(JsonView(true, $"查询成功!", _data));
  1401. }
  1402. /// <summary>
  1403. /// 商邀资料查询
  1404. /// </summary>
  1405. /// <param name="dto"></param>
  1406. /// <returns></returns>
  1407. [HttpPost]
  1408. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1409. public async Task<IActionResult> QueryInvitationOfficialActivityData(QueryInvitationOfficialActivityDataDto dto)
  1410. {
  1411. var ExcludedKeyStr = new string[] { "快递费" };
  1412. var ClientKeyStr = new string[] { "邀请函翻译" };
  1413. var columns = "Id,UnitName,Contact,City";
  1414. try
  1415. {
  1416. #region 参数验证
  1417. if (dto.PageIndex < 1) return Ok(JsonView(false, "请传入有效的PageIndex参数!"));
  1418. if (dto.PageSize < 1) return Ok(JsonView(false, "请传入有效的PageSize参数!"));
  1419. #endregion
  1420. //string sqlWhere = string.Empty;
  1421. if (!string.IsNullOrWhiteSpace(dto.Country)) { columns += ",Country"; }
  1422. //if (!string.IsNullOrWhiteSpace(dto.UnitName)) { columns += ",UnitName"; }
  1423. //if (!string.IsNullOrWhiteSpace(dto.Contact)) { columns += ",Contact"; }
  1424. if (!string.IsNullOrWhiteSpace(dto.Delegation)) { columns += ",Delegation"; }
  1425. if (!string.IsNullOrWhiteSpace(dto.Field)) { columns += ",Field"; }
  1426. //if (dto.CreateUserId != 0 && !string.IsNullOrWhiteSpace(dto.CreateUserId.ToString())) { columns += ",CreateUserId"; }
  1427. //if (!string.IsNullOrWhiteSpace(dto.StartCreateTime) && !string.IsNullOrWhiteSpace(dto.EndCreateTime))
  1428. //{
  1429. // columns += ",CreateUserId";
  1430. //}
  1431. DateTime endTime = new DateTime();
  1432. var InvitationOfficialActivityDataList = _sqlSugar.Queryable<Res_InvitationOfficialActivityData>()
  1433. .Where(x => x.IsDel == 0)
  1434. .WhereIF(dto.CreateUserId != 0 && !string.IsNullOrWhiteSpace(dto.CreateUserId.ToString()), x => x.CreateUserId == dto.CreateUserId)
  1435. .WhereIF(DateTime.TryParse(dto.StartCreateTime, out DateTime startTime) && DateTime.TryParse(dto.EndCreateTime, out endTime), x => x.CreateTime >= startTime && x.CreateTime <= endTime)
  1436. .Select(columns)
  1437. .ToList();
  1438. foreach (var item in InvitationOfficialActivityDataList)
  1439. {
  1440. EncryptionProcessor.DecryptProperties(item);
  1441. }
  1442. InvitationOfficialActivityDataList = InvitationOfficialActivityDataList
  1443. .WhereIF(!string.IsNullOrWhiteSpace(dto.Country), x => (!string.IsNullOrWhiteSpace(x.Country) && x.Country.Contains(dto.Country)) || (!string.IsNullOrWhiteSpace(x.City) && x.City.Contains(dto.Country)))
  1444. .WhereIF(!string.IsNullOrWhiteSpace(dto.UnitName), x => !string.IsNullOrWhiteSpace(x.UnitName) && x.UnitName.Contains(dto.UnitName))
  1445. .WhereIF(!string.IsNullOrWhiteSpace(dto.Contact), x => !string.IsNullOrWhiteSpace(x.Contact) && x.Contact.Contains(dto.Contact))
  1446. .WhereIF(!string.IsNullOrWhiteSpace(dto.Delegation), x => !string.IsNullOrWhiteSpace(x.Delegation) && x.Delegation.Contains(dto.Delegation))
  1447. .WhereIF(!string.IsNullOrWhiteSpace(dto.Field), x => !string.IsNullOrWhiteSpace(x.Field) && x.Field.Contains(dto.Field))
  1448. .ToList();
  1449. foreach (var item in ExcludedKeyStr)
  1450. {
  1451. InvitationOfficialActivityDataList = InvitationOfficialActivityDataList.Where(x => string.IsNullOrWhiteSpace(x.UnitName) || !x.UnitName.Contains(item)).ToList();
  1452. //sqlWhere += $" And i.UnitName not like '%{item}%' ";
  1453. }
  1454. foreach (var item in ClientKeyStr)
  1455. {
  1456. InvitationOfficialActivityDataList = InvitationOfficialActivityDataList.Where(x => string.IsNullOrWhiteSpace(x.Contact) || !x.Contact.Contains(item)).ToList();
  1457. //sqlWhere += $" And i.Contact not like '%{item}%' ";
  1458. }
  1459. var ids = InvitationOfficialActivityDataList.Select(x => x.Id);
  1460. RefAsync<int> totalCount = 0;
  1461. var _ivitiesViews = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>()
  1462. .LeftJoin<Sys_Users>((a, b) => b.IsDel == 0 && a.CreateUserId == b.Id)
  1463. .Where((a, b) => ids.Contains(a.Id))
  1464. .OrderByDescending((a, b) => a.CreateTime)
  1465. .Select((a, b) => new InvitationOfficialActivityDataView
  1466. {
  1467. FaceBook = a.FaceBook,
  1468. Id = a.Id,
  1469. CreateUserId = a.CreateUserId,
  1470. IsDel = 0,
  1471. Address = a.Address,
  1472. Background = a.Background,
  1473. City = a.City,
  1474. Contact = a.Contact,
  1475. Country = a.Country,
  1476. CreateTime = a.CreateTime,
  1477. CreateUserName = b.CnName,
  1478. Delegation = a.Delegation,
  1479. Email = a.Email,
  1480. Fax = a.Fax,
  1481. Field = a.Field,
  1482. FilePath = a.FilePath,
  1483. Ins = a.Ins,
  1484. WeChat = a.WeChat,
  1485. UnitWeb = a.UnitWeb,
  1486. UnitName = a.UnitName,
  1487. UnitInfo = a.UnitInfo,
  1488. Tel = a.Tel,
  1489. SndFilePath = a.SndFilePath,
  1490. SndFileName = a.SndFileName,
  1491. Remark = a.Remark,
  1492. OtherInfo = a.OtherInfo,
  1493. Job = a.Job
  1494. })
  1495. .ToPageListAsync(dto.PageIndex, dto.PageSize, totalCount);
  1496. var allGroupIds = new HashSet<int>();
  1497. foreach (var item in _ivitiesViews)
  1498. {
  1499. EncryptionProcessor.DecryptProperties(item);
  1500. if (!string.IsNullOrEmpty(item.Delegation))
  1501. {
  1502. allGroupIds.UnionWith(item.Delegation.Split(',').Select(x =>
  1503. {
  1504. int id;
  1505. if (int.TryParse(x, out id)) return id;
  1506. return 0;
  1507. }).Where(id => id != 0));
  1508. }
  1509. }
  1510. var _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  1511. .Where(x => allGroupIds.Contains(x.Id) && x.IsDel == 0)
  1512. .ToList()
  1513. .GroupBy(x => x.Id)
  1514. .ToDictionary(group => group.Key, group => group.Select(g => g.TeamName));
  1515. foreach (var item in _ivitiesViews)
  1516. {
  1517. string groupNameStr = "";
  1518. if (!string.IsNullOrEmpty(item.Delegation))
  1519. {
  1520. var groupIds = item.Delegation.Split(',').Select(x =>
  1521. {
  1522. int id;
  1523. if (int.TryParse(x, out id)) return id;
  1524. return 0;
  1525. })
  1526. .Where(id => id != 0)
  1527. .ToArray();
  1528. foreach (var id in groupIds)
  1529. {
  1530. if (_DelegationInfos.ContainsKey(id))
  1531. {
  1532. groupNameStr += string.Join("", _DelegationInfos[id]) + ",";
  1533. }
  1534. }
  1535. if (groupNameStr.Length > 1)
  1536. {
  1537. groupNameStr = groupNameStr.Substring(0, groupNameStr.Length - 1);
  1538. }
  1539. }
  1540. item.DelegationStr = groupNameStr;
  1541. }
  1542. return Ok(JsonView(true, $"查询成功!", _ivitiesViews, totalCount));
  1543. }
  1544. catch (Exception ex)
  1545. {
  1546. return Ok(JsonView(false, ex.Message));
  1547. }
  1548. }
  1549. /// <summary>
  1550. /// 商邀资料查询-欧洲
  1551. /// </summary>
  1552. /// <returns></returns>
  1553. [HttpPost]
  1554. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1555. public async Task<IActionResult> QueryInvitationOfficialActivityData1()
  1556. {
  1557. try
  1558. {
  1559. // 定义欧洲国家数组
  1560. string[] europeanCountries = {
  1561. // 北欧国家
  1562. "瑞典", "芬兰", "挪威", "丹麦", "冰岛",
  1563. // 西欧国家
  1564. "英国", "爱尔兰", "法国", "荷兰", "比利时", "卢森堡", "摩纳哥",
  1565. // 中欧国家
  1566. "德国", "瑞士", "奥地利", "波兰", "捷克", "斯洛伐克", "匈牙利", "列支敦士登",
  1567. // 南欧国家
  1568. "意大利", "西班牙", "葡萄牙", "希腊", "马耳他", "圣马力诺", "梵蒂冈", "安道尔",
  1569. "克罗地亚", "斯洛文尼亚", "波斯尼亚和黑塞哥维那", "黑山", "塞尔维亚", "北马其顿", "阿尔巴尼亚", "保加利亚", "罗马尼亚",
  1570. // 东欧国家
  1571. "俄罗斯", "乌克兰", "白俄罗斯", "摩尔多瓦", "爱沙尼亚", "拉脱维亚", "立陶宛"
  1572. };
  1573. var InvitationOfficialActivityDataList = _sqlSugar.Queryable<Res_InvitationOfficialActivityData>()
  1574. .Where(x => x.IsDel == 0)
  1575. .Select(x => new Res_InvitationOfficialActivityData() { Id = x.Id, Country = x.Country })
  1576. .ToList();
  1577. foreach (var item in InvitationOfficialActivityDataList)
  1578. {
  1579. EncryptionProcessor.DecryptProperties(item);
  1580. }
  1581. var ids = InvitationOfficialActivityDataList
  1582. .WhereIF(europeanCountries.Any(), x => !string.IsNullOrWhiteSpace(x.Country) && europeanCountries.Contains(x.Country))
  1583. .Select(x => x.Id)
  1584. .ToList();
  1585. RefAsync<int> totalCount = 0;
  1586. var _ivitiesViews = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>()
  1587. .LeftJoin<Sys_Users>((a, b) => b.IsDel == 0 && a.CreateUserId == b.Id)
  1588. .Where((a, b) => ids.Contains(a.Id))
  1589. .OrderByDescending((a, b) => a.CreateTime)
  1590. .Select((a, b) => new InvitationOfficialActivityDataView1
  1591. {
  1592. Country = a.Country,
  1593. City = a.City,
  1594. UnitName = a.UnitName,
  1595. Field = a.Field,
  1596. Address = a.Address,
  1597. UnitInfo = a.UnitInfo,
  1598. Delegation = a.Delegation,
  1599. OtherInfo = a.OtherInfo
  1600. })
  1601. .ToListAsync();
  1602. var allGroupIds = new HashSet<int>();
  1603. foreach (var item in _ivitiesViews)
  1604. {
  1605. EncryptionProcessor.DecryptProperties(item);
  1606. if (!string.IsNullOrEmpty(item.Delegation))
  1607. {
  1608. allGroupIds.UnionWith(item.Delegation.Split(',').Select(x =>
  1609. {
  1610. int id;
  1611. if (int.TryParse(x, out id)) return id;
  1612. return 0;
  1613. }).Where(id => id != 0));
  1614. }
  1615. }
  1616. var _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  1617. .Where(x => allGroupIds.Contains(x.Id) && x.IsDel == 0)
  1618. .ToList()
  1619. .GroupBy(x => x.Id)
  1620. .ToDictionary(group => group.Key, group => group.Select(g => g.TeamName));
  1621. foreach (var item in _ivitiesViews)
  1622. {
  1623. string groupNameStr = "";
  1624. if (!string.IsNullOrEmpty(item.Delegation))
  1625. {
  1626. var groupIds = item.Delegation.Split(',').Select(x =>
  1627. {
  1628. int id;
  1629. if (int.TryParse(x, out id)) return id;
  1630. return 0;
  1631. })
  1632. .Where(id => id != 0)
  1633. .ToArray();
  1634. foreach (var id in groupIds)
  1635. {
  1636. if (_DelegationInfos.ContainsKey(id))
  1637. {
  1638. groupNameStr += string.Join("", _DelegationInfos[id]) + ",";
  1639. }
  1640. }
  1641. if (groupNameStr.Length > 1)
  1642. {
  1643. groupNameStr = groupNameStr.Substring(0, groupNameStr.Length - 1);
  1644. }
  1645. }
  1646. item.DelegationStr = groupNameStr;
  1647. }
  1648. //获取模板
  1649. string tempPath = (AppSettingsHelper.Get("ExcelBasePath") + "Template/商邀资料模板.xls");
  1650. var designer = new WorkbookDesigner();
  1651. designer.Workbook = new Workbook(tempPath);
  1652. var dt = CommonFun.ToDataTableArray(_ivitiesViews);
  1653. dt.TableName = $"OADataView";
  1654. designer.SetDataSource(dt);
  1655. designer.Process();
  1656. //文件名
  1657. string fileName = $"商邀资料{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  1658. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "InvitationOfficialActivityExport/" + fileName);
  1659. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/InvitationOfficialActivityExport/" + fileName;
  1660. return Ok(JsonView(true, "成功", url));
  1661. }
  1662. catch (Exception ex)
  1663. {
  1664. return Ok(JsonView(false, ex.Message));
  1665. }
  1666. }
  1667. //[HttpPost]
  1668. //public IActionResult EncipherInvitationOfficialActivityData()
  1669. //{
  1670. // var jw = JsonView(false);
  1671. // var List_DB = _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().ToList();
  1672. // try
  1673. // {
  1674. // //foreach (var item in List_DB)
  1675. // //{
  1676. // // EncryptionProcessor.DecryptProperties(item);
  1677. // //}
  1678. // _sqlSugar.BeginTran();
  1679. // foreach (var item in List_DB)
  1680. // {
  1681. // EncryptionProcessor.EncryptProperties(item);
  1682. // }
  1683. // var updateRow = _sqlSugar.Updateable<Res_InvitationOfficialActivityData>(List_DB).ExecuteCommand();
  1684. // jw = JsonView(true, "success", "修改行数:" + updateRow);
  1685. // _sqlSugar.CommitTran();
  1686. // }
  1687. // catch (Exception ex)
  1688. // {
  1689. // _sqlSugar.RollbackTran();
  1690. // jw.Msg = ex.Message;
  1691. // }
  1692. // return Ok(jw);
  1693. //}
  1694. /// <summary>
  1695. /// 根据商邀资料Id查询信息
  1696. /// </summary>
  1697. /// <param name="id"></param>
  1698. /// <returns></returns>
  1699. [HttpGet("{id}")]
  1700. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1701. public async Task<IActionResult> QueryInvitationOfficialActivityById(int id)
  1702. {
  1703. if (id < 1) return Ok(JsonView(false, "Id参数错误!"));
  1704. return Ok(await _InvitationOfficialActivityDataRep.Info(id));
  1705. }
  1706. /// <summary>
  1707. /// 商邀资料操作(Status:1.新增,2.修改)
  1708. /// </summary>
  1709. /// <param name="dto"></param>
  1710. /// <returns></returns>
  1711. [HttpPost]
  1712. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1713. public async Task<IActionResult> OpInvitationOfficialActivity([FromForm] OpInvitationOfficialActivityDto dto)
  1714. {
  1715. return Ok(await _InvitationOfficialActivityDataRep.IOA_OP(dto));
  1716. }
  1717. /// <summary>
  1718. /// 商邀资料 删除文件
  1719. /// </summary>
  1720. /// <param name="id"></param>
  1721. /// <param name="fileName"></param>
  1722. /// <returns></returns>
  1723. [HttpDelete("{id}")]
  1724. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1725. public async Task<IActionResult> InvitationOfficialActivityDelFile(int id, string fileName)
  1726. {
  1727. if (id < 1) return Ok(JsonView(false, "请传入有效的Id"));
  1728. if (string.IsNullOrEmpty(fileName)) return Ok(JsonView(false, "文件名称不能为空!"));
  1729. var info = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync(x => x.Id == id);
  1730. if (info == null) return Ok(JsonView(false, "该条数据不存在!"));
  1731. var files = new List<string>();
  1732. try
  1733. {
  1734. files = JsonConvert.DeserializeObject<List<string>>(info.SndFileName);
  1735. }
  1736. catch (Exception) { }
  1737. if (files != null && files.Count > 0 && files.Contains(fileName))
  1738. {
  1739. var filePath = $@"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{fileName}";
  1740. if (System.IO.File.Exists(filePath))
  1741. {
  1742. System.IO.File.Delete(filePath);
  1743. }
  1744. //更改文件值
  1745. files.Remove(fileName);
  1746. var fileUpd = await _sqlSugar.Updateable<Res_InvitationOfficialActivityData>()
  1747. .SetColumns(x => x.SndFileName == JsonConvert.SerializeObject(files))
  1748. .Where(x => x.Id == id)
  1749. .ExecuteCommandAsync();
  1750. if (fileUpd > 0) return Ok(JsonView(true, "操作成功!"));
  1751. }
  1752. return Ok(JsonView(false, "操作失败!"));
  1753. }
  1754. /// <summary>
  1755. /// 删除商邀资料信息
  1756. /// </summary>
  1757. /// <param name="dto"></param>
  1758. /// <returns></returns>
  1759. [HttpPost]
  1760. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1761. public async Task<IActionResult> DelInvitationOfficialActivity(DelBaseDto dto)
  1762. {
  1763. var res = await _InvitationOfficialActivityDataRep.SoftDeleteByIdAsync<Res_InvitationOfficialActivityData>(dto.Id.ToString(), dto.DeleteUserId);
  1764. if (!res) return Ok(JsonView(false, "删除失败"));
  1765. var info = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync(x => x.Id == dto.Id);
  1766. if (info == null) return Ok(JsonView(false, "该条数据不存在!"));
  1767. var files = new List<string>();
  1768. try
  1769. {
  1770. files = JsonConvert.DeserializeObject<List<string>>(info.SndFileName);
  1771. }
  1772. catch (Exception) { }
  1773. if (files != null && files.Count > 0)
  1774. {
  1775. foreach (var fileName in files)
  1776. {
  1777. var filePath = $@"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{fileName}";
  1778. if (System.IO.File.Exists(filePath))
  1779. {
  1780. System.IO.File.Delete(filePath);
  1781. }
  1782. }
  1783. }
  1784. return Ok(JsonView(true, "删除成功!"));
  1785. }
  1786. /// <summary>
  1787. /// 商邀资料 ExcelExport
  1788. /// </summary>
  1789. /// <param name="dto"></param>
  1790. /// <returns></returns>
  1791. [HttpPost]
  1792. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1793. public async Task<IActionResult> InvitationOfficialActivityExcelExport(QueryInvitationOfficialActivityDataDto dto)
  1794. {
  1795. var ExcludedKeyStr = new string[] { "快递费" };
  1796. var ClientKeyStr = new string[] { "邀请函翻译" };
  1797. var columns = "Id,UnitName,Contact";
  1798. #region 参数验证
  1799. if (dto.PageIndex < 1) return Ok(JsonView(false, "请传入有效的PageIndex参数!"));
  1800. if (dto.PageSize < 1) return Ok(JsonView(false, "请传入有效的PageSize参数!"));
  1801. #endregion
  1802. if (!string.IsNullOrWhiteSpace(dto.Country)) { columns += ",Country"; }
  1803. if (!string.IsNullOrWhiteSpace(dto.Delegation)) { columns += ",Delegation"; }
  1804. if (!string.IsNullOrWhiteSpace(dto.Field)) { columns += ",Field"; }
  1805. DateTime endTime = new DateTime();
  1806. var InvitationOfficialActivityDataList = _sqlSugar.Queryable<Res_InvitationOfficialActivityData>()
  1807. .Where(x => x.IsDel == 0)
  1808. .WhereIF(dto.CreateUserId != 0 && !string.IsNullOrWhiteSpace(dto.CreateUserId.ToString()), x => x.CreateUserId == dto.CreateUserId)
  1809. .WhereIF(DateTime.TryParse(dto.StartCreateTime, out DateTime startTime) && DateTime.TryParse(dto.EndCreateTime, out endTime), x => x.CreateTime >= startTime && x.CreateTime <= endTime)
  1810. .Select(columns)
  1811. .ToList();
  1812. foreach (var item in InvitationOfficialActivityDataList)
  1813. {
  1814. EncryptionProcessor.DecryptProperties(item);
  1815. }
  1816. InvitationOfficialActivityDataList = InvitationOfficialActivityDataList
  1817. .WhereIF(!string.IsNullOrWhiteSpace(dto.Country), x => !string.IsNullOrWhiteSpace(x.Country) && x.Country.Contains(dto.Country))
  1818. .WhereIF(!string.IsNullOrWhiteSpace(dto.UnitName), x => !string.IsNullOrWhiteSpace(x.UnitName) && x.UnitName.Contains(dto.UnitName))
  1819. .WhereIF(!string.IsNullOrWhiteSpace(dto.Contact), x => !string.IsNullOrWhiteSpace(x.Contact) && x.Contact.Contains(dto.Contact))
  1820. .WhereIF(!string.IsNullOrWhiteSpace(dto.Delegation), x => !string.IsNullOrWhiteSpace(x.Delegation) && x.Delegation.Contains(dto.Delegation))
  1821. .WhereIF(!string.IsNullOrWhiteSpace(dto.Field), x => !string.IsNullOrWhiteSpace(x.Field) && x.Field.Contains(dto.Field))
  1822. .ToList();
  1823. foreach (var item in ExcludedKeyStr)
  1824. {
  1825. InvitationOfficialActivityDataList = InvitationOfficialActivityDataList.Where(x => string.IsNullOrWhiteSpace(x.UnitName) || !x.UnitName.Contains(item)).ToList();
  1826. //sqlWhere += $" And i.UnitName not like '%{item}%' ";
  1827. }
  1828. foreach (var item in ClientKeyStr)
  1829. {
  1830. InvitationOfficialActivityDataList = InvitationOfficialActivityDataList.Where(x => string.IsNullOrWhiteSpace(x.Contact) || !x.Contact.Contains(item)).ToList();
  1831. //sqlWhere += $" And i.Contact not like '%{item}%' ";
  1832. }
  1833. var ids = InvitationOfficialActivityDataList.Select(x => x.Id);
  1834. var _ivitiesViews = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>()
  1835. .LeftJoin<Sys_Users>((a, b) => b.IsDel == 0 && a.CreateUserId == b.Id)
  1836. .Where((a, b) => ids.Contains(a.Id))
  1837. .OrderByDescending((a, b) => a.CreateTime)
  1838. .Select((a, b) => new IOAInfoView
  1839. {
  1840. FaceBook = a.FaceBook,
  1841. Id = a.Id,
  1842. Address = a.Address,
  1843. Background = a.Background,
  1844. City = a.City,
  1845. Contact = a.Contact,
  1846. Country = a.Country,
  1847. Delegation = a.Delegation,
  1848. Email = a.Email,
  1849. Fax = a.Fax,
  1850. Field = a.Field,
  1851. Ins = a.Ins,
  1852. WeChat = a.WeChat,
  1853. UnitWeb = a.UnitWeb,
  1854. UnitName = a.UnitName,
  1855. UnitInfo = a.UnitInfo,
  1856. Tel = a.Tel,
  1857. SndFileName = a.SndFileName,
  1858. Remark = a.Remark,
  1859. OtherInfo = a.OtherInfo,
  1860. Job = a.Job
  1861. })
  1862. .ToListAsync();
  1863. if (!_ivitiesViews.Any()) return Ok(JsonView(false, $"您查询的数据暂无内容,不可导出!"));
  1864. var allGroupIds = new HashSet<int>();
  1865. foreach (var item in _ivitiesViews)
  1866. {
  1867. EncryptionProcessor.DecryptProperties(item);
  1868. if (!string.IsNullOrEmpty(item.Delegation))
  1869. {
  1870. allGroupIds.UnionWith(
  1871. item.Delegation.Split(',')
  1872. .Select(x =>
  1873. {
  1874. int id;
  1875. if (int.TryParse(x, out id)) return id;
  1876. return 0;
  1877. })
  1878. .Where(id => id != 0)
  1879. );
  1880. }
  1881. }
  1882. var _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  1883. .Where(x => allGroupIds.Contains(x.Id) && x.IsDel == 0)
  1884. .ToList()
  1885. .GroupBy(x => x.Id)
  1886. .ToDictionary(group => group.Key, group => group.Select(g => g.TeamName));
  1887. foreach (var item in _ivitiesViews)
  1888. {
  1889. string groupNameStr = "";
  1890. if (!string.IsNullOrEmpty(item.Delegation))
  1891. {
  1892. var groupIds = item.Delegation.Split(',').Select(x =>
  1893. {
  1894. int id;
  1895. if (int.TryParse(x, out id)) return id;
  1896. return 0;
  1897. })
  1898. .Where(id => id != 0)
  1899. .ToArray();
  1900. foreach (var id in groupIds)
  1901. {
  1902. if (_DelegationInfos.ContainsKey(id))
  1903. {
  1904. groupNameStr += string.Join("", _DelegationInfos[id]) + ",";
  1905. }
  1906. }
  1907. if (groupNameStr.Length > 1)
  1908. {
  1909. groupNameStr = groupNameStr.Substring(0, groupNameStr.Length - 1);
  1910. }
  1911. }
  1912. item.DelegationStr = groupNameStr;
  1913. }
  1914. //获取模板
  1915. string tempPath = (AppSettingsHelper.Get("ExcelBasePath") + "Template/商邀资料模板.xls");
  1916. var designer = new WorkbookDesigner();
  1917. designer.Workbook = new Workbook(tempPath);
  1918. var dt = CommonFun.ToDataTableArray(_ivitiesViews);
  1919. dt.TableName = $"OADataView";
  1920. designer.SetDataSource(dt);
  1921. designer.Process();
  1922. //文件名
  1923. string fileName = $"商邀资料{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  1924. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "InvitationOfficialActivityExport/" + fileName);
  1925. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/InvitationOfficialActivityExport/" + fileName;
  1926. return Ok(JsonView(true, "成功", url));
  1927. }
  1928. /// <summary>
  1929. /// 商邀资料 导入文件(Excel)模板下载
  1930. /// </summary>
  1931. /// <returns></returns>
  1932. [HttpGet]
  1933. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1934. public async Task<IActionResult> InvitationOfficialActivityExcelTemplateExport()
  1935. {
  1936. //获取模板
  1937. string fileName = $"商邀资料上传文件模板.xls";
  1938. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/Template/" + fileName;
  1939. return Ok(JsonView(true, "成功", url));
  1940. }
  1941. /// <summary>
  1942. /// 商邀资料 上传Excel文件添加
  1943. /// </summary>
  1944. /// <param name="file"></param>
  1945. /// <param name="currUserId"></param>
  1946. /// <returns></returns>
  1947. [HttpPost]
  1948. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1949. public async Task<IActionResult> InvitationOfficialActivityExcelUpload(IFormFile file, int currUserId)
  1950. {
  1951. var fileName = file.FileName;
  1952. var filePostfix = fileName.Split(".")[1].ToUpper();
  1953. if (!filePostfix.Contains("XLS")) return Ok(JsonView(false, $"请传入Excel文件"));
  1954. if (file.Length < 1) return Ok(JsonView(false, $"请传入有效的文件"));
  1955. if (currUserId < 1) return Ok(JsonView(false, $"请传入有效的UserId"));
  1956. //保存文件
  1957. string fileDirPath = string.Format(@"{0}InvitationOfficialActivityExcelUpload/", AppSettingsHelper.Get("ExcelBasePath"));
  1958. if (!Directory.Exists(fileDirPath))
  1959. {
  1960. Directory.CreateDirectory(fileDirPath);
  1961. }
  1962. var filePath = Path.Combine(fileDirPath, fileName);
  1963. await using var stream = new FileStream(filePath, FileMode.Create);
  1964. await file.CopyToAsync(stream);
  1965. //读取保存的文件
  1966. Workbook workbook = new Workbook(filePath);
  1967. if (workbook == null) return Ok(JsonView(false, $"Excel文件不存在!"));
  1968. Worksheet worksheet = workbook.Worksheets[0];
  1969. if (worksheet == null) return Ok(JsonView(false, $"Excel文件工作簿不存在!"));
  1970. var infos = new List<Res_InvitationOfficialActivityData>();
  1971. var groupNames = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName)).Select(x => new { x.Id, x.TeamName }).ToListAsync();
  1972. for (int row = 1; row < worksheet.Cells.MaxDataRow + 1; row++)
  1973. {
  1974. var groupIdsLabel = string.Empty;
  1975. var groupNames1 = worksheet.Cells[row, 14].StringValue ?? "-";
  1976. if (!string.IsNullOrEmpty(groupNames1))
  1977. {
  1978. if (groupNames1.Contains(";"))
  1979. {
  1980. var groupNameArray = groupNames1.Split(";").Where(x => !string.IsNullOrEmpty(x)).ToList();
  1981. var groupIds = groupNames.Where(x => groupNameArray.Contains(x.TeamName)).Select(x => x.Id).ToList();
  1982. if (groupIds.Any()) groupIdsLabel = string.Join(',', groupIds);
  1983. }
  1984. else groupIdsLabel = groupNames.Where(x => groupNames1.Equals(x.TeamName)).FirstOrDefault()?.Id.ToString() ?? string.Empty;
  1985. }
  1986. infos.Add(new Res_InvitationOfficialActivityData()
  1987. {
  1988. Country = worksheet.Cells[row, 0].StringValue ?? "-",
  1989. City = worksheet.Cells[row, 1].StringValue ?? "-",
  1990. UnitName = worksheet.Cells[row, 2].StringValue ?? "-",
  1991. Field = worksheet.Cells[row, 3].StringValue ?? "-",
  1992. Address = worksheet.Cells[row, 4].StringValue ?? "-",
  1993. UnitInfo = worksheet.Cells[row, 5].StringValue ?? "-",
  1994. Contact = worksheet.Cells[row, 6].StringValue ?? "-",
  1995. Job = worksheet.Cells[row, 7].StringValue ?? "-",
  1996. Tel = worksheet.Cells[row, 8].StringValue ?? "-",
  1997. Email = worksheet.Cells[row, 9].StringValue ?? "-",
  1998. WeChat = worksheet.Cells[row, 10].StringValue ?? "-",
  1999. FaceBook = worksheet.Cells[row, 11].StringValue ?? "-",
  2000. Ins = worksheet.Cells[row, 12].StringValue ?? "-",
  2001. Fax = worksheet.Cells[row, 13].StringValue ?? "-",
  2002. Delegation = groupIdsLabel,
  2003. SndFilePath = worksheet.Cells[row, 15].StringValue ?? "-",
  2004. OtherInfo = worksheet.Cells[row, 16].StringValue ?? "-",
  2005. Remark = $"[{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}] Excel上传文件添加! 文件存储地址[{filePath}]",
  2006. CreateUserId = currUserId,
  2007. IsDel = 0
  2008. });
  2009. }
  2010. //加密
  2011. foreach (var item in infos) EncryptionProcessor.EncryptProperties(item);
  2012. var addCount = await _sqlSugar.Insertable(infos).ExecuteCommandAsync();
  2013. if (addCount < 1) return Ok(JsonView(false, "文件上传添加失败!"));
  2014. return Ok(JsonView(true, $"上传文件添加成功!共添加{addCount}条!"));
  2015. }
  2016. #endregion
  2017. #region 商邀资料 AI
  2018. /// <summary>
  2019. /// 商邀资料AI 基础数据源
  2020. /// </summary>
  2021. /// <returns></returns>
  2022. [HttpGet]
  2023. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2024. public async Task<IActionResult> InvitationAIInit()
  2025. {
  2026. // 预定义 UnionAll 查询
  2027. var query1 = _sqlSugar.Queryable<Grp_DelegationInfo>()
  2028. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  2029. .Select(x => new InvitationAIInvNameView { Id = x.Id, Name = x.TeamName, Source = 1, SortTime = x.VisitDate });
  2030. var query2 = _sqlSugar.Queryable<Res_InvitationAI>()
  2031. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.InvName))
  2032. .Select(x => new InvitationAIInvNameView { Id = x.Id, Name = x.InvName, Source = 2, SortTime = x.CreateTime });
  2033. var itemNames = await _sqlSugar.UnionAll(query1, query2)
  2034. .OrderByDescending(x => x.SortTime)
  2035. .Select(x => new { x.Id, x.Name, x.Source })
  2036. .ToListAsync();
  2037. var invDatas = await _sqlSugar.Queryable<Crm_NewClientData>()
  2038. .Where(x => x.IsDel == 0)
  2039. .Select(x => x.Client)
  2040. .ToListAsync();
  2041. var countries = await _sqlSugar.Queryable<Sys_Countries>()
  2042. .Where(x => x.IsDel == 0)
  2043. .Select(x => x.Name_CN)
  2044. .Distinct()
  2045. .ToListAsync();
  2046. // 解密与去重(使用 HashSet 提升性能)
  2047. var unitNames = invDatas
  2048. .Select(item => AesEncryptionHelper.Decrypt(item))
  2049. .Where(val => !string.IsNullOrEmpty(val))
  2050. .Distinct()
  2051. .ToList();
  2052. return Ok(new
  2053. {
  2054. itemNames,
  2055. unitNames,
  2056. countries
  2057. });
  2058. }
  2059. /// <summary>
  2060. /// 商邀资料AI 混元AI查询资料
  2061. /// </summary>
  2062. /// <returns></returns>
  2063. [HttpGet("{name}")]
  2064. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2065. public async Task<IActionResult> InvitationAIItemByName(string name)
  2066. {
  2067. // 基础校验
  2068. if (string.IsNullOrWhiteSpace(name) )
  2069. return Ok(JsonView(false, "请传入有效的名称!"));
  2070. var infos = await _sqlSugar.Queryable<Res_InvitationAI>()
  2071. .Where(x => x.IsDel == 0 && x.InvName == name)
  2072. .Select(x => new {
  2073. x.Id,
  2074. x.InvName,
  2075. x.GroupId,
  2076. x.AiCrawledDetails,
  2077. Entry = x.Entries.FirstOrDefault(),
  2078. })
  2079. .FirstAsync();
  2080. return Ok(JsonView(true, $"查询成功!", infos));
  2081. }
  2082. /// <summary>
  2083. /// 商邀资料AI 混元AI查询资料
  2084. /// </summary>
  2085. /// <returns></returns>
  2086. [HttpPost]
  2087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2088. public async Task<IActionResult> InvitationAISearch(InvitationAISearchDto dto)
  2089. {
  2090. // 基础校验
  2091. if (string.IsNullOrWhiteSpace(dto.UnitName) || string.IsNullOrWhiteSpace(dto.Country))
  2092. return Ok(JsonView(false, "请传入有效的单位名称和国家!"));
  2093. // 当前企业领域
  2094. string industryFocus = string.Empty;
  2095. // 动态计算 AI 需求缺口
  2096. int totalTarget = 15;
  2097. // 词条
  2098. string question = string.Empty;
  2099. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  2100. .Where(x => x.IsDel == 0 && x.Id == dto.GroupId)
  2101. .Select(x => new { x.TeamName, x.VisitPurpose })
  2102. .FirstAsync();
  2103. // 当前企业出访目的
  2104. string objective = groupInfo?.VisitPurpose ?? "商务考察与合作对接";
  2105. string operatorName = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0 && x.Id == dto.CurrUserId).Select(x => x.CnName).FirstAsync() ?? "-";
  2106. var localInvDatas = new List<InvitationAIInfo>(); // 本地数据源(商邀资料)
  2107. #region 本地数据源(商邀资料)
  2108. var rawData = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>()
  2109. .Where(x => x.IsDel == 0 && x.Country.Equals(dto.Country))
  2110. .ToListAsync();
  2111. // 解密
  2112. localInvDatas = rawData.AsParallel().AsOrdered().Select(item => new InvitationAIInfo
  2113. {
  2114. Source = 0, // 明确来源标识
  2115. Region = dto.UnitName,
  2116. NameCn = AesEncryptionHelper.Decrypt(item.UnitName),
  2117. Address = AesEncryptionHelper.Decrypt(item.Address),
  2118. Scope = AesEncryptionHelper.Decrypt(item.Field),
  2119. Contact = AesEncryptionHelper.Decrypt(item.Contact),
  2120. Phone = AesEncryptionHelper.Decrypt(item.Tel),
  2121. Email = AesEncryptionHelper.Decrypt(item.Email),
  2122. OperatedAt = DateTime.Now,
  2123. Operator = operatorName,
  2124. }).ToList();
  2125. #endregion
  2126. #region 混元AI 获取商邀资料
  2127. var hunyuanAIInvDatas = new List<InvitationAIInfo>();
  2128. int aiNeedCount = Math.Max(0, totalTarget - localInvDatas.Count);
  2129. if (aiNeedCount > 0)
  2130. {
  2131. question = @$"# [SYSTEM_CONTEXT]
  2132. - Role: Senior Business Consultant (Global Supply Chain & Cross-border Trade Expert)
  2133. - Framework: S.P.A.R. (Situation-Problem-Action-Result)
  2134. - Target Architecture: .NET 6 DTO Compatible Interface
  2135. # [INPUT_CONFIG]
  2136. - OriginUnit: {{{dto.UnitName}}}
  2137. - TargetCountry: {{{dto.Country}}}
  2138. - Objective: {{{objective}}}
  2139. - DataCount: {{{aiNeedCount}}}
  2140. - OtherConstraints: {{{dto.Remark}}}
  2141. # [ROLE_DEFINITION]
  2142. 你是一位精通全球跨境经贸、海外园区政策及 {{TargetCountry}} 本地准入法规的【顶级商务咨询顾问】。你擅长通过“产业链对等原则(Chain-Parity Principle)”为跨国企业精准匹配具备落地价值的合作伙伴。
  2143. # [BUSINESS_LOGIC_CoT]
  2144. 在生成结果前,请严格执行以下思维链拆解:
  2145. 1. **EntityProfiling**: 识别 {{OriginUnit}} 的核心生态位(如:Supply/Demand/Capital/Logistics)。
  2146. 2. **ParityMatching**: 检索 {{TargetCountry}} 境内业务闭环对等机构(例如:若 Origin 为分销,则 Target 为源头工厂/种植园)。
  2147. 3. **RegulatoryCheck**: 验证目标机构的合规性(如:GACC 备案、SPS 协议、或当地政府特许经营权)。
  2148. 4. **DataSynthesis**: 针对无法直接获取的动态(如 PostUrl),优先检索其官网 News 频道或 LinkedIn 企业号。
  2149. # [CONSTRAINTS_&_STANDARDS]
  2150. - **NamingConvention**: 所有 JSON Key 必须严格遵循 **PascalCase**(例如:`UnitNameCn` 而非 `unit_name_cn`)。
  2151. - **DataIntegrity**:
  2152. - 必须输出精确的 {{DataCount}} 条记录。
  2153. - 优先级:Core (核心机构) > Backup (关联替代机构)。
  2154. - **ValidationRules**:
  2155. - `Phone`: 必须包含 {{TargetCountry}} 国际区号(如 +856, +66 等)。
  2156. - `IntgAdvice`: 必须包含“对等性分析”,解释该机构如何与 {{OriginUnit}} 形成业务闭环(50-100字)。
  2157. - `Status`: 若字段确实无法获取,统一填充 'N/A',禁止编造。
  2158. - **Safety**: 确保推荐机构不涉及敏感黑名单或已破产企业。
  2159. # [INFORMATION_SCHEMA]
  2160. 请将结果填充至以下结构的 JSON 数组中:
  2161. - NameCn: 单位名称(中文)
  2162. - NameEn: 单位名称(英文)
  2163. - Address: 详细地理位置(含省市区街道)
  2164. - Scope: 经营范围(需强调其出口配额、生产能力或行业地位)
  2165. - Contact: 联系人姓名及职务
  2166. - Phone: 拨打全号(含区号)
  2167. - Email: 商务联络邮箱
  2168. - SiteUrl: 官方网站或权威社媒主页
  2169. - PostUrl: 近一年内的商务动态/新闻链接
  2170. - RecLevel: 推荐等级(枚举值:Core, Backup)
  2171. - IntgAdvice: 对接深度建议(基于产业链交合、互补逻辑)
  2172. # [OUTPUT_PROTOCOL]
  2173. - 仅输出一个标准的 JSON Array 字符串。
  2174. - 严禁任何 Markdown 说明文字、代码块之外的解释或开场白。
  2175. - 确保 JSON 语法在 .NET `JsonSerializer.Deserialize` 下可直接解析。
  2176. # [EXECUTION]
  2177. 根据以上配置,开始生成。";
  2178. string response = string.Empty;
  2179. try
  2180. {
  2181. response = await _hunyuanService.ChatCompletionsHunyuan_t1_latestAsync(question);
  2182. }
  2183. catch (HttpRequestException ex)
  2184. {
  2185. _logger.LogError(ex, "网络连接失败,无法调用混元API");
  2186. return Ok(JsonView(false, $"网络连接异常,请检查网络后重试!Ex:{ex.Message}"));
  2187. }
  2188. catch (TaskCanceledException ex)
  2189. {
  2190. _logger.LogError(ex, "请求超时");
  2191. return Ok(JsonView(false, $"AI 响应超时,请稍后再试!Ex:{ex.Message}"));
  2192. }
  2193. catch (TencentCloudSDKException ex)
  2194. {
  2195. // 记录完整日志
  2196. _logger.LogError(ex, "腾讯云API调用失败 | 错误码: {ErrorCode} | 请求ID: {RequestId}", ex.ErrorCode, ex.RequestId);
  2197. // 根据错误码做差异化处理
  2198. if (ex.ErrorCode != null && ex.ErrorCode == "AuthFailure.SignatureExpire")
  2199. {
  2200. return Ok(JsonView(false, $"系统时间异常,请同步时间后重试!Ex:{ex.Message}"));
  2201. }
  2202. else if (ex.ErrorCode != null && ex.ErrorCode.StartsWith("Unauthorized"))
  2203. {
  2204. return Ok(JsonView(false, $"当前账号无权限访问该服务!Ex:{ex.Message}"));
  2205. }
  2206. else
  2207. {
  2208. return Ok(JsonView(false, $"腾讯云服务调用失败,请稍后重试!Ex:{ex.Message}"));
  2209. }
  2210. }
  2211. catch (Exception ex)
  2212. {
  2213. _logger.LogError(ex, "未知错误,调用混元API失败");
  2214. return Ok(JsonView(false, $"未知错误,调用混元API失败!Ex:{ex.Message}"));
  2215. }
  2216. if (!string.IsNullOrWhiteSpace(response))
  2217. {
  2218. // 预处理:过滤 AI 可能返回的 Markdown 标记
  2219. string cleanJson = response.Trim();
  2220. if (cleanJson.StartsWith("```json"))
  2221. cleanJson = cleanJson.Substring(7, cleanJson.Length - 10).Trim();
  2222. else if (cleanJson.StartsWith("```"))
  2223. cleanJson = cleanJson.Substring(3, cleanJson.Length - 6).Trim();
  2224. try
  2225. {
  2226. // 解析并注入 Source 标识
  2227. hunyuanAIInvDatas = JsonConvert.DeserializeObject<List<InvitationAIInfo>>(cleanJson);
  2228. if (hunyuanAIInvDatas != null)
  2229. {
  2230. hunyuanAIInvDatas = hunyuanAIInvDatas.Select(x => {
  2231. x.Source = 1;
  2232. x.Region = dto.Country;
  2233. x.Operator = operatorName;
  2234. x.OperatedAt = DateTime.Now;
  2235. return x;
  2236. }).ToList();
  2237. }
  2238. }
  2239. catch (JsonException ex)
  2240. {
  2241. // 记录日志并考虑 fallback 策略
  2242. _logger.LogError(ex, "Hunyuan AI 响应解析失败。原始数据:{Response}", response);
  2243. }
  2244. }
  2245. }
  2246. #endregion
  2247. #region 数据库操作
  2248. // 数据整合 (高效合并)
  2249. var finalResult = localInvDatas.Concat(hunyuanAIInvDatas).ToList();
  2250. // 词条信息
  2251. var entries = new List<EntryInfo>() { new EntryInfo() {
  2252. Details = question,
  2253. Operator = operatorName,
  2254. OperatedAt = DateTime.Now
  2255. } };
  2256. string invName = $"{dto.UnitName}拜访{dto.Country}";
  2257. // 数据库信息获取方式
  2258. // 1.通过团组 GroupId 关联查询
  2259. var dataInfo = await _sqlSugar.Queryable<Res_InvitationAI>().Where(x => x.IsDel == 0 && x.GroupId == dto.GroupId).FirstAsync();
  2260. // 2.通过InvName 关联查询(考虑到可能存在同名情况,优先使用 GroupId 关联查询,确保数据准确性)
  2261. dataInfo ??= await _sqlSugar.Queryable<Res_InvitationAI>().Where(x => x.IsDel == 0 && x.InvName == invName).FirstAsync();
  2262. // 3.如果以上两种方式都没有查询到数据,则说明是新数据,需要添加到数据库
  2263. if (dataInfo == null)
  2264. {
  2265. // 3.1 新数据,需要添加到数据库
  2266. dataInfo = new Res_InvitationAI()
  2267. {
  2268. InvName = groupInfo?.TeamName ?? invName, //默认团组名称
  2269. GroupId = dto.GroupId,
  2270. AiCrawledDetails = finalResult,
  2271. Entries = entries,
  2272. CreateUserId = dto.CurrUserId
  2273. };
  2274. var insert = await _sqlSugar.Insertable(dataInfo).ExecuteCommandAsync();
  2275. if (insert < 1)
  2276. {
  2277. return Ok(JsonView(false, $"数据新增失败!"));
  2278. }
  2279. }
  2280. else
  2281. {
  2282. // 3.1 数据存在 则更新数据(覆盖原有的AI爬取详情,保留原有的其他字段不变)
  2283. dataInfo.AiCrawledDetails = finalResult;
  2284. var update = await _sqlSugar.Updateable(dataInfo).ExecuteCommandAsync();
  2285. if (update < 1)
  2286. {
  2287. return Ok(JsonView(false, $"数据更新失败!"));
  2288. }
  2289. }
  2290. #endregion
  2291. return Ok(JsonView(true, $"查询成功!", new
  2292. {
  2293. dataInfo.Id,
  2294. dataInfo.InvName,
  2295. dataInfo.GroupId,
  2296. dataInfo.AiCrawledDetails,
  2297. Entry = dataInfo.Entries.FirstOrDefault(),
  2298. }));
  2299. }
  2300. #endregion
  2301. #region 公务出访
  2302. /// <summary>
  2303. /// 获取团组所有信息,绑定下拉框
  2304. /// </summary>
  2305. /// <param name="dto"></param>
  2306. /// <returns></returns>
  2307. [HttpPost]
  2308. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2309. public async Task<IActionResult> GetGroupAllList(OfficialActivitiesByDiIdDto dto)
  2310. {
  2311. //string groupSql = string.Format("Select * From Grp_DelegationInfo With(NoLock) Where IsDel = 0 Order By CreateTime Desc");
  2312. //List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.SqlQueryable< Grp_DelegationInfo >(groupSql).ToList();
  2313. var _groupData = await _delegationInfoRep.PostShareGroupInfos(1);
  2314. dynamic groupInfos = null;
  2315. if (_groupData.Code == 0) groupInfos = _groupData.Data;
  2316. var data = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.IsDel == 0).ToList();
  2317. var data1 = data.Where(a => a.STid == 38).Select(x => new { x.Id, x.Name }).ToList();
  2318. var data2 = data.Where(a => a.STid == 101).Select(x => new { x.Id, x.Name }).ToList();
  2319. //张总安排未参与对接
  2320. if (data2.Any(x => x.Name.Equals("张总安排未参与对接")))
  2321. {
  2322. var zhangZong = data2.FirstOrDefault(x => x.Name.Equals("张总安排未参与对接"));
  2323. if (zhangZong != null) data2.Remove(zhangZong);
  2324. data2.Insert(0, zhangZong);
  2325. }
  2326. var data3 = data.Where(a => a.STid == 66).Select(x => new { x.Id, x.Name, x.Remark }).ToList();
  2327. var _DeleFile = _sqlSugar.Queryable<Grp_DeleFile>().Where(a => a.Diid == dto.DiId && a.IsDel == 0 && a.Category == 970).ToList();
  2328. var translatorData = _sqlSugar.Queryable<Res_TranslatorLibrary>().Where(a => a.IsDel == 0).ToList();
  2329. var translatorData1 = _mapper.Map<List<TranslatorView>>(translatorData);
  2330. foreach (var item in translatorData1) EncryptionProcessor.DecryptProperties(item);
  2331. return Ok(JsonView(true,
  2332. "查询成功!",
  2333. new
  2334. {
  2335. Delegation = groupInfos,
  2336. SetData = data1,
  2337. DataSource = data2,
  2338. currencyData = data3,
  2339. DeleFile = _DeleFile,
  2340. TranslatorData = translatorData1
  2341. }));
  2342. }
  2343. /// <summary>
  2344. /// 公务 团组名称 Page List
  2345. /// </summary>
  2346. /// <param name="dto"></param>
  2347. /// <returns></returns>
  2348. [HttpPost]
  2349. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2350. public async Task<IActionResult> OfficialActivitiesGroupNameList(OfficialActivitiesGroupNameListDto dto)
  2351. {
  2352. var sw = Stopwatch.StartNew();
  2353. if (!SharingStaticData.PortTypes.Contains(dto.PortType))
  2354. {
  2355. return Ok(JsonView(false, MsgTips.Port));
  2356. }
  2357. dto.PageIndex = dto.PageIndex == 0 ? 1 : dto.PageIndex;
  2358. dto.PageSize = dto.PageSize == 0 ? 10 : dto.PageSize;
  2359. RefAsync<int> total = 0;
  2360. // 只查询需要的字段,避免Select后再赋值,减少内存占用
  2361. var groupInfos = await _officialActivitiesRep._sqlSugar
  2362. .Queryable<Grp_DelegationInfo>()
  2363. .Where(x => x.IsDel == 0)
  2364. .WhereIF(!string.IsNullOrEmpty(dto.GroupName), x => x.TeamName.Contains(dto.GroupName))
  2365. .OrderByDescending(x => x.VisitDate)
  2366. .Select(x => new Web_ShareGroupInfoView()
  2367. {
  2368. Id = x.Id,
  2369. TeamName = x.TeamName,
  2370. TourCode = x.TourCode,
  2371. ClientName = x.ClientName,
  2372. VisitCountry = x.VisitCountry,
  2373. VisitStartDate = x.VisitStartDate,
  2374. VisitEndDate = x.VisitEndDate,
  2375. VisitDays = x.VisitDays,
  2376. VisitPNumber = x.VisitPNumber
  2377. })
  2378. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  2379. if (groupInfos.Count > 0)
  2380. {
  2381. for (int i = 0; i < groupInfos.Count; i++)
  2382. {
  2383. var visitCountry = groupInfos[i].VisitCountry;
  2384. groupInfos[i].VisitCountry = !string.IsNullOrEmpty(visitCountry)
  2385. ? _delegationInfoRep.FormartTeamName(visitCountry)
  2386. : string.Empty;
  2387. }
  2388. }
  2389. sw.Stop();
  2390. return Ok(JsonView(true, $"操作成功!耗时:{sw.ElapsedMilliseconds}ms", groupInfos, total));
  2391. }
  2392. /// <summary>
  2393. /// 公务 翻译人员 Page List
  2394. /// </summary>
  2395. /// <param name="dto"></param>
  2396. /// <returns></returns>
  2397. [HttpPost]
  2398. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2399. public async Task<IActionResult> OfficialActivitiesTranslatorList(OfficialActivitiesTranslatorListDto dto)
  2400. {
  2401. var sw = Stopwatch.StartNew();
  2402. if (!SharingStaticData.PortTypes.Contains(dto.PortType))
  2403. {
  2404. return Ok(JsonView(false, MsgTips.Port));
  2405. }
  2406. dto.PageIndex = dto.PageIndex == 0 ? 1 : dto.PageIndex;
  2407. dto.PageSize = dto.PageSize == 0 ? 10 : dto.PageSize;
  2408. var translatorIds = new List<int>();
  2409. if (!string.IsNullOrEmpty(dto.TranslatorName))
  2410. {
  2411. var translators = await _sqlSugar.Queryable<Res_TranslatorLibrary>()
  2412. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.Name))
  2413. .Select(x => new { x.Id, x.Name })
  2414. .ToListAsync();
  2415. if (translators.Any())
  2416. {
  2417. foreach (var item in translators)
  2418. {
  2419. var decryptedName = AesEncryptionHelper.Decrypt(item.Name);
  2420. if (!string.IsNullOrEmpty(decryptedName) && decryptedName.Contains(dto.TranslatorName))
  2421. {
  2422. translatorIds.Add(item.Id);
  2423. }
  2424. }
  2425. }
  2426. if (translatorIds.Count == 0)
  2427. {
  2428. sw.Stop();
  2429. return Ok(JsonView(true, $"暂无翻译人员信息!耗时: {sw.ElapsedMilliseconds}ms", Array.Empty<TranslatorView>(), 0));
  2430. }
  2431. }
  2432. RefAsync<int> total = 0;
  2433. var translatorInfos = await _officialActivitiesRep._sqlSugar
  2434. .Queryable<Res_TranslatorLibrary>()
  2435. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.Name))
  2436. .WhereIF(translatorIds != null && translatorIds.Count > 0, x => translatorIds.Contains(x.Id))
  2437. .OrderByDescending(x => x.CreateTime)
  2438. .Select(x => new TranslatorView()
  2439. {
  2440. Id = x.Id,
  2441. Area = x.Area,
  2442. Name = x.Name,
  2443. Sex = x.Sex,
  2444. Tel = x.Tel,
  2445. Email = x.Email,
  2446. WechatNo = x.WechatNo,
  2447. OtherSocialAccounts = x.OtherSocialAccounts,
  2448. Language = x.Language,
  2449. Price = x.Price,
  2450. Currency = x.Currency,
  2451. })
  2452. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  2453. for (int i = 0; i < translatorInfos.Count; i++)
  2454. {
  2455. EncryptionProcessor.DecryptProperties(translatorInfos[i]);
  2456. }
  2457. sw.Stop();
  2458. string msg = translatorInfos.Count == 0 ? $"暂无您查询的翻译人员信息!耗时: {sw.ElapsedMilliseconds}ms" : $"操作成功!耗时: {sw.ElapsedMilliseconds}ms";
  2459. return Ok(JsonView(true, msg, translatorInfos, total));
  2460. }
  2461. /// <summary>
  2462. /// 公务 绑定下拉框
  2463. /// </summary>
  2464. /// <param name="dto"></param>
  2465. /// <returns></returns>
  2466. [HttpPost]
  2467. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2468. public async Task<IActionResult> OfficialActivitiesInitDatabase(OfficialActivitiesByDiIdDto dto)
  2469. {
  2470. var data = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.IsDel == 0).ToList();
  2471. var data1 = data.Where(a => a.STid == 38).Select(x => new { x.Id, x.Name }).ToList();
  2472. var data2 = data.Where(a => a.STid == 101).Select(x => new { x.Id, x.Name }).ToList();
  2473. //张总安排未参与对接
  2474. if (data2.Any(x => x.Name.Equals("张总安排未参与对接")))
  2475. {
  2476. var zhangZong = data2.FirstOrDefault(x => x.Name.Equals("张总安排未参与对接"));
  2477. if (zhangZong != null) data2.Remove(zhangZong);
  2478. data2.Insert(0, zhangZong);
  2479. }
  2480. var data3 = data.Where(a => a.STid == 66).Select(x => new { x.Id, x.Name, x.Remark }).ToList();
  2481. var _DeleFile = _sqlSugar.Queryable<Grp_DeleFile>().Where(a => a.Diid == dto.DiId && a.IsDel == 0 && a.Category == 970).ToList();
  2482. return Ok(JsonView(true,
  2483. "查询成功!",
  2484. new
  2485. {
  2486. SetData = data1,
  2487. DataSource = data2,
  2488. currencyData = data3,
  2489. DeleFile = _DeleFile
  2490. }));
  2491. }
  2492. /// <summary>
  2493. /// 公务List
  2494. /// </summary>
  2495. /// <param name="dto"></param>
  2496. /// <returns></returns>
  2497. [HttpPost]
  2498. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2499. public async Task<IActionResult> QueryOfficialActivitiesByDiId(OfficialActivitiesByDiIdDto dto)
  2500. {
  2501. return Ok(await _officialActivitiesRep.QueryOfficialActivitiesByDiId(dto));
  2502. }
  2503. /// <summary>
  2504. /// 根据公务出访数据Id查询数据
  2505. /// </summary>
  2506. /// <param name="dto"></param>
  2507. /// <returns></returns>
  2508. [HttpPost]
  2509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2510. public async Task<IActionResult> QueryOfficialActivitiesById(OfficialActivitiesDiIdDto dto)
  2511. {
  2512. Result groupData = await _officialActivitiesRep.QueryOfficialActivitiesById(dto);
  2513. if (groupData.Code != 0)
  2514. {
  2515. return Ok(JsonView(false, groupData.Msg));
  2516. }
  2517. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2518. }
  2519. /// <summary>
  2520. /// 公务出访操作(Status:1.新增,2.修改)
  2521. /// </summary>
  2522. /// <param name="dto"></param>
  2523. /// <returns></returns>
  2524. [HttpPost]
  2525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2526. public async Task<IActionResult> OpOfficialActivities(OpOfficialActivitiesDto dto)
  2527. {
  2528. Result groupData = await _officialActivitiesRep.OpOfficialActivities(dto);
  2529. if (groupData.Code != 0)
  2530. {
  2531. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, new { Id = 0 }));
  2532. }
  2533. try
  2534. {
  2535. //公务出访变更发送通知
  2536. await AppNoticeLibrary.SendUserMsg_GroupShare_ToOP(dto.DiId, dto.CreateUserId);
  2537. }
  2538. catch (Exception ex)
  2539. {
  2540. //抄送日志
  2541. }
  2542. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2543. }
  2544. /// <summary>
  2545. /// 上传文件(邮件截图)
  2546. /// </summary>
  2547. /// <param name="dto"></param>
  2548. /// <returns></returns>
  2549. [HttpPost]
  2550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2551. public async Task<IActionResult> OfficialActivitiesUploadFiles([FromForm] OfficialActivitiesUploadFilesDto dto)
  2552. {
  2553. string networkPath = AppSettingsHelper.Get("GrpFileBaseUrl");
  2554. string localPath = AppSettingsHelper.Get("GrpFileBasePath");
  2555. string ptfPath = AppSettingsHelper.Get("GrpFileFtpPath");
  2556. if (dto.diId < 1 || dto.currUserId < 1)
  2557. {
  2558. return Ok(JsonView(false, "参数有误,上传失败!"));
  2559. }
  2560. if (dto.files == null || dto.files.Count < 1)
  2561. {
  2562. return Ok(JsonView(false, "文件为空,上传失败!"));
  2563. }
  2564. string localFileDir = $"{localPath}{ptfPath}";
  2565. List<string> fileUrls = new List<string>();
  2566. string[] failFiles = new string[] { };
  2567. foreach (var file in dto.files)
  2568. {
  2569. //文件名称
  2570. string[] fileNameArray = file.FileName.Split(".");
  2571. string projectFileName = $"{fileNameArray[0].ToString().Replace("-", "_").Replace("/", "_")}{DateTime.UtcNow:yyyyMMddHHmmss}.{fileNameArray[1]}";
  2572. //上传的文件的路径
  2573. string filePath = $@"{localPath}公务相关文件";
  2574. if (!Directory.Exists(filePath))
  2575. {
  2576. Directory.CreateDirectory(filePath);
  2577. }
  2578. var path = Path.Combine(filePath, projectFileName);
  2579. //using var stream = new FileStream(path, FileMode.Create);
  2580. //await file.CopyToAsync(stream);
  2581. try
  2582. {
  2583. using (FileStream fs = System.IO.File.Create(path))
  2584. {
  2585. file.CopyTo(fs);
  2586. fs.Flush();
  2587. }
  2588. fileUrls.Add($"/{ptfPath}公务相关文件/{projectFileName}");
  2589. }
  2590. catch (Exception ex)
  2591. {
  2592. failFiles.Append(file.FileName);
  2593. }
  2594. }
  2595. var oaInfo = await _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.Id == dto.id).FirstAsync();
  2596. List<string> files = new List<string>();
  2597. var status = false;
  2598. var _oaInfo = new Res_OfficialActivities()
  2599. {
  2600. DiId = dto.diId,
  2601. ScreenshotOfMailUrl = JsonConvert.SerializeObject(fileUrls),
  2602. IsDel = 0,
  2603. CreateUserId = dto.currUserId,
  2604. CreateTime = DateTime.Now
  2605. };
  2606. if (oaInfo == null)
  2607. {
  2608. var id = await _sqlSugar.Insertable<Res_OfficialActivities>(_oaInfo)
  2609. .ExecuteReturnIdentityAsync();
  2610. if (id > 0)
  2611. {
  2612. status = true;
  2613. dto.id = id;
  2614. }
  2615. }
  2616. else
  2617. {
  2618. var oldFiles = string.IsNullOrEmpty(oaInfo.ScreenshotOfMailUrl)
  2619. ? new List<string>()
  2620. : JsonConvert.DeserializeObject<List<string>>(oaInfo.ScreenshotOfMailUrl);
  2621. if (oldFiles.Count > 0)
  2622. {
  2623. fileUrls.AddRange(oldFiles);
  2624. }
  2625. fileUrls = fileUrls.Distinct().ToList();
  2626. if (fileUrls.Count > 0)
  2627. {
  2628. var upd = await _sqlSugar.Updateable<Res_OfficialActivities>()
  2629. .SetColumns(x => x.ScreenshotOfMailUrl == JsonConvert.SerializeObject(fileUrls))
  2630. .Where(x => x.Id == dto.id)
  2631. .ExecuteCommandAsync();
  2632. if (upd > 0) status = true;
  2633. }
  2634. }
  2635. List<string> returnFileUrls = new List<string>();
  2636. fileUrls.ForEach(x =>
  2637. {
  2638. returnFileUrls.Add($"{networkPath}{x}");
  2639. });
  2640. if (status)
  2641. {
  2642. string msg = "操作成功!";
  2643. if (failFiles.Length > 1)
  2644. {
  2645. foreach (var item in failFiles)
  2646. {
  2647. msg += $"{failFiles}、";
  2648. }
  2649. msg = msg.Substring(0, msg.Length - 1);
  2650. msg += "等文件保存失败!";
  2651. }
  2652. return Ok(JsonView(true, msg, new { id = dto.id, fileUrls = returnFileUrls }));
  2653. }
  2654. return Ok(JsonView(false, "操作失败!"));
  2655. }
  2656. /// <summary>
  2657. /// 删除文件(邮件截图)
  2658. /// </summary>
  2659. /// <param name="dto"></param>
  2660. /// <returns></returns>
  2661. [HttpPost]
  2662. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2663. public async Task<IActionResult> OfficialActivitiesDelFile(OfficialActivitiesDelFileDto dto)
  2664. {
  2665. string networkPath = AppSettingsHelper.Get("GrpFileBaseUrl");
  2666. string localPath = AppSettingsHelper.Get("GrpFileBasePath");
  2667. string ptfPath = AppSettingsHelper.Get("GrpFileFtpPath");
  2668. if (dto.Id < 1 || string.IsNullOrEmpty(dto.FileName))
  2669. {
  2670. return Ok(JsonView(false, "参数有误,上传失败!"));
  2671. }
  2672. string localFileDir = $"{localPath}{ptfPath}";
  2673. List<string> fileUrls = new List<string>();
  2674. var oaInfo = await _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.Id == dto.Id).FirstAsync();
  2675. if (oaInfo != null)
  2676. {
  2677. string urlJson = oaInfo.ScreenshotOfMailUrl ?? "";
  2678. if (!string.IsNullOrEmpty(urlJson))
  2679. {
  2680. List<string> urls = JsonConvert.DeserializeObject<List<string>>(urlJson);
  2681. var filePath = urls.Find(x => x.Contains(dto.FileName));
  2682. if (string.IsNullOrEmpty(filePath)) return Ok(JsonView(false, "文件不存在!"));
  2683. var updFile = urls.Remove(filePath);
  2684. if (updFile)
  2685. {
  2686. //删除文件
  2687. string fileUrl = AppSettingsHelper.Get("GrpFileBasePath").Replace(@"/Office/GrpFile", "") + filePath;
  2688. if (System.IO.File.Exists(fileUrl))
  2689. {
  2690. System.IO.File.Delete(fileUrl);
  2691. }
  2692. string urlJsonstr = JsonConvert.SerializeObject(urls);
  2693. var upd = await _sqlSugar.Updateable<Res_OfficialActivities>()
  2694. .SetColumns(x => x.ScreenshotOfMailUrl == urlJsonstr)
  2695. .Where(x => x.Id == dto.Id)
  2696. .ExecuteCommandAsync();
  2697. if (upd > 0) return Ok(JsonView(true, "操作成功!"));
  2698. }
  2699. }
  2700. }
  2701. return Ok(JsonView(false, "操作失败!"));
  2702. }
  2703. /// <summary>
  2704. /// 公务出访 确认、取消邀请
  2705. /// </summary>
  2706. /// <param name="dto"></param>
  2707. /// <returns></returns>
  2708. [HttpPost]
  2709. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2710. public async Task<IActionResult> OfficialActivitiesInviteOperation(OfficialActivitiesInviteOperationDto dto)
  2711. {
  2712. if (dto.Id < 1) return Ok(JsonView(false, "Id参数有误!"));
  2713. if (dto.Type < 0 || dto.Type > 1) return Ok(JsonView(false, "Type参数有误!"));
  2714. var upd = await _sqlSugar.Updateable<Res_OfficialActivities>()
  2715. .SetColumns(x => x.ConfirmTheInvitation == dto.Type)
  2716. .Where(x => x.Id == dto.Id)
  2717. .ExecuteCommandAsync();
  2718. if (upd > 0) return Ok(JsonView(true, "操作成功!"));
  2719. return Ok(JsonView(false, "操作失败!"));
  2720. }
  2721. /// <summary>
  2722. /// 上传文件
  2723. /// </summary>
  2724. /// <param name="file"></param>
  2725. /// <returns></returns>
  2726. [HttpPost]
  2727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2728. public async Task<IActionResult> UploadOfficialActivities(IFormFile file)
  2729. {
  2730. try
  2731. {
  2732. int Type = int.Parse(Request.Headers["Type"]);//1公务方简介,2公务活动图片,3发票
  2733. int DiId = int.Parse(Request.Headers["DiId"]);
  2734. int CreateUserId = int.Parse(Request.Headers["CreateUserId"]);
  2735. if (file != null)
  2736. {
  2737. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2738. //文件名称
  2739. string projectFileName = file.FileName;
  2740. //上传的文件的路径
  2741. string filePath = "";
  2742. if (!Directory.Exists(fileDir))
  2743. {
  2744. Directory.CreateDirectory(fileDir);
  2745. }
  2746. //上传的文件的路径
  2747. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2748. using (FileStream fs = System.IO.File.Create(filePath))
  2749. {
  2750. file.CopyTo(fs);
  2751. fs.Flush();
  2752. }
  2753. Grp_DeleFile d = new Grp_DeleFile();
  2754. d.Diid = DiId;
  2755. d.Category = 970;
  2756. if (Type == 1) d.Kind = 1;
  2757. else if (Type == 2) d.Kind = 2;
  2758. else if (Type == 3) d.Kind = 3;
  2759. d.FileName = projectFileName;
  2760. d.FilePath = "";
  2761. d.CreateUserId = CreateUserId;
  2762. int id = await _sqlSugar.Insertable(d).ExecuteReturnIdentityAsync();
  2763. return Ok(JsonView(true, "上传成功!", projectFileName));
  2764. }
  2765. else
  2766. {
  2767. return Ok(JsonView(false, "上传失败!"));
  2768. }
  2769. }
  2770. catch (Exception ex)
  2771. {
  2772. return Ok(JsonView(false, "程序错误!"));
  2773. throw;
  2774. }
  2775. }
  2776. /// <summary>
  2777. /// 删除文件
  2778. /// </summary>
  2779. /// <param name="dto"></param>
  2780. /// <returns></returns>
  2781. [HttpPost]
  2782. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2783. public async Task<IActionResult> DelloadOfficialActivities(DelBaseDto dto)
  2784. {
  2785. try
  2786. {
  2787. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2788. Grp_DeleFile _DeleFile = await _sqlSugar.Queryable<Grp_DeleFile>().FirstAsync(a => a.Id == dto.Id);
  2789. if (_DeleFile != null)
  2790. {
  2791. string fileName = _DeleFile.FileName;
  2792. string filePath = fileDir + "/团组增减款项相关文件/" + fileName;
  2793. // 删除该文件
  2794. System.IO.File.Delete(filePath);
  2795. 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();
  2796. return Ok(JsonView(true, "取消文件成功!"));
  2797. }
  2798. else
  2799. {
  2800. return Ok(JsonView(false, "取消文件失败!"));
  2801. }
  2802. }
  2803. catch (Exception ex)
  2804. {
  2805. return Ok(JsonView(false, "程序错误!"));
  2806. throw;
  2807. }
  2808. }
  2809. /// <summary>
  2810. /// 删除公务出访信息
  2811. /// </summary>
  2812. /// <param name="dto"></param>
  2813. /// <returns></returns>
  2814. [HttpPost]
  2815. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2816. public async Task<IActionResult> DelOfficialActivities(DelBaseDto dto)
  2817. {
  2818. _sqlSugar.BeginTran();
  2819. var res = await _officialActivitiesRep.SoftDeleteByIdAsync<Res_OfficialActivities>(dto.Id.ToString(), dto.DeleteUserId);
  2820. if (!res)
  2821. {
  2822. _sqlSugar.RollbackTran();
  2823. return Ok(JsonView(false, "删除失败"));
  2824. }
  2825. #region 删除公务出访
  2826. await _sqlSugar.Updateable<Grp_OfficialDutyLinkTranslator>()
  2827. .SetColumns(x => new Grp_OfficialDutyLinkTranslator()
  2828. {
  2829. DeleteUserId = dto.DeleteUserId,
  2830. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  2831. IsDel = 1,
  2832. Remark = $"公务出访-->删除"
  2833. })
  2834. .Where(x => x.OfficialDutyId == dto.Id)
  2835. .ExecuteCommandAsync();
  2836. #endregion
  2837. _sqlSugar.CommitTran();
  2838. return Ok(JsonView(true, "删除成功!"));
  2839. }
  2840. /// <summary>
  2841. /// 公务出访
  2842. /// 请示范例提示
  2843. /// Add Time:2024-05-13 13:56:44
  2844. /// </summary>
  2845. /// <param name="dto"></param>
  2846. /// <returns></returns>
  2847. [HttpPost]
  2848. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2849. public async Task<IActionResult> PostOfficialActivitiesReqReqSampleTips(PostOfficialActivitiesReqReqSampleTipsDto dto)
  2850. {
  2851. var res = await _officialActivitiesRep.PostReqReqSampleTips(dto.country, dto.area, dto.client);
  2852. if (res.Code == 0)
  2853. {
  2854. return Ok(JsonView(true, "操作成功!", res.Data));
  2855. }
  2856. return Ok(JsonView(false, res.Msg));
  2857. }
  2858. /// <summary>
  2859. /// 公务出访 (省外办,市外办) File Downlaod
  2860. /// </summary>
  2861. /// <param name="dto"></param>
  2862. /// <returns></returns>
  2863. [HttpPost]
  2864. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2865. public async Task<IActionResult> OfficialActivitiesFileDownload(OfficialActivitiesFileDownload dto)
  2866. {
  2867. #region 参数验证
  2868. if (dto.FileType < 1 || dto.FileType > 2) return Ok(JsonView(false, "请传入有效的FileType参数. 1 省外办出访请示 2 市外办出访请示", ""));
  2869. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数.", ""));
  2870. #endregion
  2871. //团组基础信息
  2872. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  2873. if (groupInfo == null) return Ok(JsonView(false, "该团组基本信息不存在", ""));
  2874. groupInfo.VisitCountry = groupInfo.VisitCountry.Replace("|", "、");
  2875. //团组公务信息
  2876. var obDatas = _sqlSugar.Queryable<Res_OfficialActivities>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderBy(it => it.Date).ToList();
  2877. //if (obDatas.Count < 1) return Ok(JsonView(false, "请先录入公务信息!"));
  2878. //团组客户名单
  2879. var guestResult = _tourClientListRep._ItemByDiId(1, dto.DiId);
  2880. List<TourClientListByDiIdView> guestInfos = new List<TourClientListByDiIdView>();
  2881. if (guestResult.Result.Code == 0) guestInfos = guestResult.Result.Data as List<TourClientListByDiIdView>;
  2882. string visitCountrys = ""; //××国家(或地区)×天,××国家(或地区)×天
  2883. string countryStayStr = ""; // xx、xx、xx
  2884. //出入境费用 住宿类型
  2885. var dayCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId && it.Type == 1).ToList();
  2886. if (dayCostDatas.Count > 0)
  2887. {
  2888. List<int> nationalIds = dayCostDatas.Select(it => it.NationalTravelFeeId).ToList();
  2889. var nationalDatas = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => nationalIds.Contains(it.Id)).ToList();
  2890. var nationalDataGroupByCountry = nationalDatas.GroupBy(it => it.Country);
  2891. foreach (var item in nationalDataGroupByCountry)
  2892. {
  2893. visitCountrys += $"{item.Key}、";
  2894. int stayDays = nationalIds.Where(it => it == item.ToList()[0].Id).Count();
  2895. countryStayStr += $"{item.Key}{stayDays}天,";
  2896. }
  2897. if (visitCountrys.Length > 0) visitCountrys = visitCountrys.Substring(0, visitCountrys.Length - 1);
  2898. if (countryStayStr.Length > 0) countryStayStr = countryStayStr.Substring(0, countryStayStr.Length - 1);
  2899. }
  2900. else
  2901. {
  2902. visitCountrys = groupInfo.VisitCountry;
  2903. countryStayStr = GeneralMethod.GetCountryStandingTime(groupInfo.Id); //计算国家出访天数
  2904. }
  2905. //出访人数
  2906. int visitPeopleNum = groupInfo.VisitPNumber;
  2907. int visitDaysNum = groupInfo.VisitDays;
  2908. //出访单位
  2909. string obInfoStr = "";
  2910. foreach (var ob in obDatas) obInfoStr += @$"{ob.Client.Trim()}{ob.Job.Trim()}{ob.Contact.Trim()}、";
  2911. if (obInfoStr.Length > 0) obInfoStr = obInfoStr.Substring(0, obInfoStr.Length - 1);
  2912. obInfoStr = obInfoStr ?? "[公务出访未录入]";
  2913. //出访路线
  2914. string lineStr = GeneralMethod.GetGroupCityLine(groupInfo.Id, "—");
  2915. if (dto.FileType == 1)
  2916. {
  2917. //载入模板
  2918. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/省外办出访请示 - 模板.docx";
  2919. var doc = new Document(tempPath);
  2920. DocumentBuilder builder = new DocumentBuilder(doc);
  2921. //键值对存放数据
  2922. Dictionary<string, string> dic = new Dictionary<string, string>();
  2923. //××(组团单位):接团客户信息团组
  2924. dic.Add("GroupClient", $"{groupInfo.ClientUnit}\r\n");
  2925. //关于××(职务、姓名)等×人赴××(国家或地区)进行×××(出访目的)的请示
  2926. string guestName = "";
  2927. string guestJob = "";
  2928. string guestInfoStr = "";
  2929. var guestFirstInfo = guestInfos.FirstOrDefault();
  2930. if (guestFirstInfo != null)
  2931. {
  2932. guestName = guestFirstInfo.LastName.Trim() + guestFirstInfo.FirstName.Trim();
  2933. guestJob = guestFirstInfo.Job.Trim();
  2934. guestInfoStr = $@"{guestJob}、{guestName}";
  2935. }
  2936. guestInfoStr = guestInfoStr ?? "[接团客户名单未录入]";
  2937. string askTitle = $@"关于{guestInfoStr}等{visitPeopleNum}人赴{visitCountrys}进行{groupInfo.VisitPurpose}的请示";
  2938. dic.Add("AskTitle", askTitle);
  2939. //应×××(邀请方名称+邀请人职务和姓名)的邀请,我单位拟派×××(职务、姓名)等×人(人数)于×××年×××月×××日赴×××(国家或地区)进行×××(出访目的)。现请示如下。
  2940. string visitDateStr = @$"{groupInfo.VisitDate.Year}年{groupInfo.VisitDate.Month}月{groupInfo.VisitDate.Day}日";
  2941. string askSubTitle = $@"应{obInfoStr}的邀请,我单位拟派{guestInfoStr}等{visitPeopleNum}人于{visitDateStr}赴{visitCountrys}进行{groupInfo.VisitPurpose}。现请示如下。";
  2942. dic.Add("AskSubTitle", askSubTitle);
  2943. //出访目的
  2944. dic.Add("VisitPurpose", groupInfo.VisitPurpose);
  2945. //出访任务
  2946. //(一)××(国家或地区)
  2947. //1.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)
  2948. //2.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)
  2949. string obBackgroundStr = "";//出访背景
  2950. string taskStr = ""; ; //出访任务
  2951. var countrys = obDatas.GroupBy(it => it.Country);
  2952. int countryIndex = 1;
  2953. foreach (var item in countrys)
  2954. {
  2955. string taskTitle = $"({GetToUpperNumber(countryIndex)}){item.Key}\r\n";
  2956. string taskContent = "";
  2957. string obBackgroundContent = "";
  2958. int obIndex = 1;
  2959. foreach (var obInfo in item.ToList())
  2960. {
  2961. string reqSmaple = "";
  2962. string settingStr = "";
  2963. if (!string.IsNullOrEmpty(obInfo.ReqSample)) reqSmaple = obInfo.ReqSample;
  2964. else reqSmaple = "[公务出访请示范例未录入]";
  2965. if (!string.IsNullOrEmpty(obInfo.Setting)) settingStr = obInfo.Setting;
  2966. else settingStr = "[公务方背景未录入]";
  2967. taskContent += $"{obIndex}. {reqSmaple}\r\n";
  2968. obBackgroundContent += $"{obIndex}. {obInfo.Client}:{settingStr}\r\n";
  2969. obIndex++;
  2970. }
  2971. taskStr += $"{taskTitle}{taskContent}";
  2972. obBackgroundStr += $"{taskTitle}{obBackgroundContent}";
  2973. countryIndex++;
  2974. }
  2975. //出访背景
  2976. if (obBackgroundStr.Length < 1) obBackgroundStr = "[公务出访背景未录入]";
  2977. dic.Add("OBSetting", obBackgroundStr);
  2978. //出访任务
  2979. if (taskStr.Length < 1) taskStr = "[公务出访任务未录入]";
  2980. dic.Add("TaskContent", taskStr);
  2981. //出访时间
  2982. //代表团拟于××年×月×日—×月×日出访,在外停留×天。其中,××国家(或地区)×天,××国家(或地区)×天。
  2983. string visitTimeQuantumStr = $"代表团拟于{groupInfo.VisitStartDate.Year}年{groupInfo.VisitStartDate.Month}月{groupInfo.VisitStartDate.Day}日—{groupInfo.VisitEndDate.Month}月{groupInfo.VisitEndDate.Day}日出访,在外停留{visitDaysNum}天。其中,{countryStayStr}。";
  2984. //出访时间
  2985. dic.Add("TimeQuantum", visitTimeQuantumStr);
  2986. //出访路线
  2987. //成都—××(出境城市名称)—××(转机不出机场)—××(公务所在城市)……—××(入境城市名称)—成都。(例:成都—法兰克福<转机不出机场>—巴黎—巴塞罗那—阿姆斯特丹<转机不出机场>-成都)
  2988. dic.Add("Line", lineStr);
  2989. //scheduling //行程安排
  2990. string schedulingStr = $"[OP行程单暂未生成]";
  2991. #region op行程 根据黑屏代码录入
  2992. var opTripView = GeneralMethod.GetBriefStroke(groupInfo.Id);
  2993. if (opTripView.Code != 0) schedulingStr = $"[{opTripView.Msg}]";
  2994. schedulingStr = "";
  2995. List<Grp_TravelList> travelList = new List<Grp_TravelList>();
  2996. travelList = opTripView.Data as List<Grp_TravelList>;
  2997. if (travelList != null)
  2998. {
  2999. foreach (var item in travelList)
  3000. {
  3001. schedulingStr += $"{item.Date}({item.WeekDay})\r\n{item.Trip}\r\n";
  3002. }
  3003. }
  3004. #endregion
  3005. dic.Add("Scheduling", schedulingStr);
  3006. #region 填充word模板书签内容
  3007. foreach (var key in dic.Keys)
  3008. {
  3009. builder.MoveToBookmark(key);
  3010. builder.Write(dic[key]);
  3011. }
  3012. #endregion
  3013. //获取word里所有表格
  3014. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3015. //获取所填表格的序数
  3016. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3017. var rowStart = tableOne.Rows[0]; //获取第1行
  3018. //循环赋值
  3019. for (int i = 0; i < guestInfos.Count; i++)
  3020. {
  3021. var guestInfo = guestInfos[i];
  3022. builder.MoveToCell(0, i + 1, 0, 0);
  3023. builder.Write(guestInfo.LastName + guestInfo.FirstName);
  3024. builder.MoveToCell(0, i + 1, 1, 0);
  3025. int sex = guestInfo.Sex;
  3026. string sexStr = string.Empty;
  3027. if (sex == 0) sexStr = "男";
  3028. else if (sex == 1) sexStr = "女";
  3029. else sexStr = "-";
  3030. builder.Write(sexStr);
  3031. builder.MoveToCell(0, i + 1, 2, 0);
  3032. builder.Write(guestInfo.CompanyFullName + guestInfo.Job);
  3033. builder.MoveToCell(0, i + 1, 3, 0);
  3034. //string birthDay = "";
  3035. string birthDayStr = string.Empty;
  3036. if (guestInfo.BirthDay != DateTime.MinValue)
  3037. {
  3038. birthDayStr = guestInfo.BirthDay.ToString("yyyy.MM");
  3039. }
  3040. builder.Write(birthDayStr);
  3041. }
  3042. //删除多余行
  3043. while (tableOne.Rows.Count > guestInfos.Count + 1)
  3044. {
  3045. tableOne.Rows.RemoveAt(guestInfos.Count + 1);
  3046. }
  3047. var fileDir = AppSettingsHelper.Get("WordBasePath");
  3048. string fileName = $"{groupInfo.TeamName}省外办出访请示{DateTime.Now.ToString("yyyyMMddHHmmss")}.docx";
  3049. string filePath = fileDir + $@"OfficialActivities/{fileName}";
  3050. doc.Save(filePath);
  3051. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/OfficialActivities/{fileName}";
  3052. return Ok(JsonView(true, "操作成功!", Url));
  3053. }
  3054. else if (dto.FileType == 2)
  3055. {
  3056. //载入模板
  3057. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/市外办出访请示 - 模板.docx";
  3058. var doc = new Document(tempPath);
  3059. DocumentBuilder builder = new DocumentBuilder(doc);
  3060. //键值对存放数据
  3061. var dic = new Dictionary<string, string>
  3062. {
  3063. //××(组团单位):接团客户信息团组
  3064. { "GroupClient", $"{groupInfo.ClientUnit}" },
  3065. { "GroupClient1", $"{groupInfo.ClientUnit}" }
  3066. };
  3067. //关于××(职务、姓名)等×人赴××(国家或地区)进行×××(出访目的)的请示
  3068. string guestName = "";
  3069. string guestJob = "";
  3070. string guestInfoStr = "";
  3071. var guestFirstInfo = guestInfos.FirstOrDefault();
  3072. if (guestFirstInfo != null)
  3073. {
  3074. guestName = guestFirstInfo.LastName.Trim() + guestFirstInfo.FirstName.Trim();
  3075. guestJob = guestFirstInfo.Job;
  3076. guestInfoStr = $@"{guestJob}、{guestName.Trim()}";
  3077. }
  3078. string reqTitle = $@"关于{guestInfoStr}等{visitPeopleNum}人赴{visitCountrys}进行{groupInfo.VisitPurpose}的请示";
  3079. dic.Add("ReqTitle", reqTitle);
  3080. //应×××(邀请方名称+邀请人职务和姓名)的邀请,我单位拟派×××(职务、姓名)等×人(人数)于×××年×××月×××日赴×××(国家或地区)进行×××(出访目的)。
  3081. string visitDateStr = @$"{groupInfo.VisitDate.Year}年{groupInfo.VisitDate.Month}月{groupInfo.VisitDate.Day}日";
  3082. string reqSubTitle = $@"应{obInfoStr}的邀请,我单位拟派{guestInfoStr}等{visitPeopleNum}人于{visitDateStr}赴{visitCountrys}进行{groupInfo.VisitPurpose}。";
  3083. dic.Add("ReqSubTitle", reqSubTitle);
  3084. /*
  3085. * 出访任务
  3086. * (一)××(国家或地区)
  3087. * 1.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)背景:拟拜访机构的优势、拟洽谈项目的前期进展情况等。(例:背景:由×××总领馆联合×××市政府共同举办的“×××活动”将于今年6月在×××举行。)
  3088. * 2.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研等)×××(项目或机构名称等)。(例:拜会友城×××市市长×××,巩固和发展两市传统友谊,商谈两市未来互动交流合作项目。)背景:拟拜访机构的优势、拟洽谈项目的前期进展情况等。(例:背景:×××年×月,×××市与×××市正式缔结友好城市关系。在此框架下,两市开展了一系列友好互访和商务交流。并于×××年×月共同举办了“×××活动”。)
  3089. *
  3090. */
  3091. string taskStr = string.Empty;
  3092. List<string> countrys = obDatas.Where(it => !string.IsNullOrEmpty(it.Country)).Select(it => it.Country).ToList();
  3093. int countryIndex = 1;
  3094. foreach (var item in countrys)
  3095. {
  3096. string taskTitle = $"({GetToUpperNumber(countryIndex)}){item ?? "[公务出访国家未填写]"}\r\n";
  3097. string taskContent = "";
  3098. if (!string.IsNullOrEmpty(item))
  3099. {
  3100. var countryObDatas = obDatas.Where(it => !string.IsNullOrEmpty(it.Country) && it.Country.Contains(item)).OrderBy(it => it.Date).ToList();
  3101. int obIndex = 1;
  3102. if (countryObDatas.Count == 0) taskContent = "[公务出访未录入]\r\n";
  3103. else
  3104. {
  3105. foreach (var obInfo in countryObDatas)
  3106. {
  3107. taskContent += $"{obIndex}.{obInfo.ReqSample ?? "[公务出访请示范例未填写]"}\r\n背景:{obInfo.Setting ?? "[公务出访背景未填写]"}\r\n";
  3108. obIndex++;
  3109. }
  3110. }
  3111. }
  3112. taskStr += $"{taskTitle}{taskContent}";
  3113. countryIndex++;
  3114. }
  3115. if (string.IsNullOrEmpty(taskStr)) taskStr = "××××××";
  3116. //出访任务
  3117. dic.Add("TaskContent", taskStr);
  3118. //出访目的
  3119. dic.Add("VisitPurpose", groupInfo.VisitPurpose);
  3120. //出访信息
  3121. //代表团拟于××年×月×日—×月×日出访,在外停留×天。其中,××国家(或地区)×天,××国家(或地区)×天。出访路线:成都—××(出境城市名称)—××(转机不出机场)—××(公务所在城市)……—××(入境城市名称)—成都。(例:成都—法兰克福<转机不出机场>—巴黎—巴塞罗那—阿姆斯特丹<转机不出机场>-成都)出访费用:由××承担(注明由外方或上级机关承担,还是由派员单位在年度安排的预算经费中列支)。
  3122. string tripInfoStr = "";
  3123. tripInfoStr = $"代表团拟于{groupInfo.VisitStartDate.Year}年{groupInfo.VisitStartDate.Month}月{groupInfo.VisitStartDate.Day}日—{groupInfo.VisitEndDate.Month}月{groupInfo.VisitEndDate.Day}日出访,在外停留{visitDaysNum}天。其中,{countryStayStr}。出访路线:{lineStr}。出访费用:由××承担(注明由外方或上级机关承担,还是由派员单位在年度安排的预算经费中列支)";
  3124. dic.Add("TripInfo", tripInfoStr);
  3125. #region 填充word模板书签内容
  3126. foreach (var key in dic.Keys)
  3127. {
  3128. builder.MoveToBookmark(key);
  3129. builder.Write(dic[key]);
  3130. }
  3131. #endregion
  3132. //获取word里所有表格
  3133. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3134. //获取所填表格的序数
  3135. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3136. var rowStart = tableOne.Rows[0]; //获取第1行
  3137. //循环赋值
  3138. for (int i = 0; i < guestInfos.Count; i++)
  3139. {
  3140. var guestInfo = guestInfos[i];
  3141. builder.MoveToCell(0, i + 1, 0, 0);
  3142. builder.Write(guestInfo.LastName + guestInfo.FirstName);
  3143. builder.MoveToCell(0, i + 1, 1, 0);
  3144. int sex = guestInfo.Sex;
  3145. string sexStr = string.Empty;
  3146. if (sex == 0) sexStr = "男";
  3147. else if (sex == 1) sexStr = "女";
  3148. else sexStr = "未设置";
  3149. builder.Write(sexStr);
  3150. builder.MoveToCell(0, i + 1, 2, 0);
  3151. builder.Write(guestInfo.CompanyFullName + guestInfo.Job);
  3152. builder.MoveToCell(0, i + 1, 3, 0);
  3153. DateTime birthDay = guestInfo.BirthDay;
  3154. string birthDayStr = string.Empty;
  3155. if (birthDay != DateTime.MinValue)
  3156. {
  3157. birthDayStr = birthDay.ToString("yyyy.MM");
  3158. }
  3159. builder.Write(birthDayStr);
  3160. }
  3161. //删除多余行
  3162. while (tableOne.Rows.Count > guestInfos.Count + 1)
  3163. {
  3164. tableOne.Rows.RemoveAt(guestInfos.Count + 1);
  3165. }
  3166. var fileDir = AppSettingsHelper.Get("WordBasePath");
  3167. var fileName = $"{groupInfo.TeamName}市外办出访请示{DateTime.Now:yyyyMMddHHmmss}.docx";
  3168. var filePath = fileDir + $@"OfficialActivities/{fileName}";
  3169. doc.Save(filePath);
  3170. var url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/OfficialActivities/{fileName}";
  3171. return Ok(JsonView(true, "操作成功!", url));
  3172. }
  3173. return Ok(JsonView(true, "操作失败!", ""));
  3174. }
  3175. private static string GetToUpperNumber(int num)
  3176. {
  3177. string numStr = "";
  3178. if (num == 1) numStr = "一";
  3179. else if (num == 2) numStr = "二";
  3180. else if (num == 3) numStr = "三";
  3181. else if (num == 4) numStr = "四";
  3182. else if (num == 5) numStr = "五";
  3183. else if (num == 6) numStr = "六";
  3184. else if (num == 7) numStr = "七";
  3185. else if (num == 8) numStr = "八";
  3186. else if (num == 9) numStr = "九";
  3187. else if (num == 10) numStr = "十";
  3188. return numStr;
  3189. }
  3190. [HttpPost]
  3191. public IActionResult ExportOfficialActivitiesInfo(ExportOfficialActivitiesInfoDto dto)
  3192. {
  3193. var jw = JsonView(false);
  3194. if (!ModelState.IsValid)
  3195. {
  3196. jw.Data = ModelState;
  3197. return Ok(jw);
  3198. }
  3199. var startTime_bool = DateTime.TryParse(dto.StartTime, out DateTime startTime_parse);
  3200. var endTime_bool = DateTime.TryParse(dto.EndTime, out DateTime endTime_parse);
  3201. if (startTime_parse > endTime_parse)
  3202. {
  3203. jw.Msg = "开始实际不能大于结束时间!";
  3204. return Ok(jw);
  3205. }
  3206. if (startTime_bool && endTime_bool)
  3207. {
  3208. //处理时间模板
  3209. var Query_DB = _sqlSugar.Queryable<Grp_DelegationInfo>()
  3210. .LeftJoin<Res_OfficialActivities>((a, b) => a.Id == b.DiId && b.IsDel == 0)
  3211. .LeftJoin<Sys_Users>((a, b, c) => b.CreateUserId == c.Id && c.IsDel == 0)
  3212. .Where((a, b, c) => a.IsDel == 0 && a.VisitDate >= startTime_parse && a.VisitDate <= endTime_parse)
  3213. .WhereIF(dto.State != -1, (a, b, c) => b.ConfirmTheInvitation == dto.State)
  3214. .Select((a, b, c) => new
  3215. {
  3216. a.TeamName,
  3217. b.Client,
  3218. b.ConfirmTheInvitation,
  3219. b.Contact,
  3220. ConfirmTheInvitationStr = b.ConfirmTheInvitation == 1 ? "是" : "否",
  3221. b.Date,
  3222. b.Nature,
  3223. c.CnName,
  3224. b.Address,
  3225. b.CreateTime
  3226. })
  3227. .ToList()
  3228. .Where(x => !x.Client.IsNullOrWhiteSpace())
  3229. .ToList();
  3230. if (Query_DB.Count > 0)
  3231. {
  3232. //打开excel
  3233. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath");
  3234. var fileBasePath = AppSettingsHelper.Get("ExcelBasePath");
  3235. //var fileName = "公务出访信息.docx";
  3236. //创建数据源Table
  3237. DataTable dtSource = new DataTable();
  3238. dtSource.TableName = "TB";
  3239. var firstElem = Query_DB.First();
  3240. //遍历firstElem所有属性
  3241. foreach (var item in firstElem.GetType().GetProperties())
  3242. {
  3243. dtSource.Columns.Add(item.Name, item.PropertyType);
  3244. }
  3245. foreach (var item in Query_DB)
  3246. {
  3247. DataRow dr = dtSource.NewRow();
  3248. //遍历dtSource所有列头
  3249. foreach (DataColumn column in dtSource.Columns)
  3250. {
  3251. dr[column.ColumnName] = item.GetType().GetProperty(column.ColumnName)?.GetValue(item)?.ToString();
  3252. }
  3253. dtSource.Rows.Add(dr);
  3254. }
  3255. WorkbookDesigner designer = new WorkbookDesigner();
  3256. designer.Workbook = new Workbook(fileBasePath + ("Template/公务出访信息.xlsx"));
  3257. var title = startTime_parse.ToString("yyyy年MM月dd日") + " - " + endTime_parse.ToString("yyyy年MM月dd日") + " 公务出访信息";
  3258. designer.SetDataSource("title", title);
  3259. designer.SetDataSource(dtSource);
  3260. designer.Process();
  3261. var exportSerevePath = fileBasePath + "ExportOfficialActivitiesInfo/" + title + ".xlsx";
  3262. var exportFtpPaht = ftpPath + "ExportOfficialActivitiesInfo/" + title + ".xlsx";
  3263. //保存文件
  3264. designer.Workbook.Save(exportSerevePath);
  3265. jw.Data = AppSettingsHelper.Get("ExcelBaseUrl") + exportFtpPaht;
  3266. jw.Code = 200;
  3267. jw.Msg = "获取成功!";
  3268. }
  3269. else
  3270. {
  3271. jw.Data = "无公务信息!";
  3272. }
  3273. }
  3274. else
  3275. {
  3276. jw.Data = "时间格式错误!";
  3277. }
  3278. return Ok(jw);
  3279. }
  3280. #endregion
  3281. #region 请示数据库
  3282. /// <summary>
  3283. /// 查询请示数据库初始化
  3284. /// </summary>
  3285. /// <param name="dto"></param>
  3286. /// <returns></returns>
  3287. [HttpPost]
  3288. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3289. public async Task<IActionResult> QueryAskData(QueryAskDataDto dto)
  3290. {
  3291. Result groupData = await _askDataRep.QueryAskData(dto);
  3292. if (groupData.Code != 0)
  3293. {
  3294. return Ok(JsonView(false, groupData.Msg));
  3295. }
  3296. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3297. }
  3298. /// <summary>
  3299. /// 根据Id查询请示数据库单条数据
  3300. /// </summary>
  3301. /// <param name="dto"></param>
  3302. /// <returns></returns>
  3303. [HttpPost]
  3304. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3305. public async Task<IActionResult> QueryAskDataById(QueryAskDataByIdDto dto)
  3306. {
  3307. Res_AskData _AskData = await _sqlSugar.Queryable<Res_AskData>().FirstAsync(a => a.IsDel == 0 && a.Id == dto.id);
  3308. if (_AskData == null)
  3309. {
  3310. return Ok(JsonView(true, "暂无数据!", _AskData));
  3311. }
  3312. return Ok(JsonView(true, "查询成功!", _AskData));
  3313. }
  3314. /// <summary>
  3315. /// 请示数据库操作(Status:1.新增,2.修改)
  3316. /// </summary>
  3317. /// <param name="dto"></param>
  3318. /// <returns></returns>
  3319. [HttpPost]
  3320. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3321. public async Task<IActionResult> OpAskData(OpAskDataDto dto)
  3322. {
  3323. Result groupData = await _askDataRep.OpAskData(dto);
  3324. if (groupData.Code != 0)
  3325. {
  3326. return Ok(JsonView(false, groupData.Msg));
  3327. }
  3328. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3329. }
  3330. /// <summary>
  3331. /// 删除请示资料信息
  3332. /// </summary>
  3333. /// <param name="dto"></param>
  3334. /// <returns></returns>
  3335. [HttpPost]
  3336. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3337. public async Task<IActionResult> DelAskData(DelBaseDto dto)
  3338. {
  3339. var res = await _askDataRep.SoftDeleteByIdAsync<Res_AskData>(dto.Id.ToString(), dto.DeleteUserId);
  3340. if (!res)
  3341. {
  3342. return Ok(JsonView(false, "删除失败"));
  3343. }
  3344. return Ok(JsonView(true, "删除成功!"));
  3345. }
  3346. /// <summary>
  3347. /// 请示资料信息
  3348. /// 省外办下载
  3349. /// </summary>
  3350. /// <param name="dto"></param>
  3351. /// <returns></returns>
  3352. [HttpPost]
  3353. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3354. public async Task<IActionResult> AskDataProvinceFAOPFile(AskDataProvinceFileDto dto)
  3355. {
  3356. if (dto.DataIdItem.Length < 1) return Ok(JsonView(false, $"请传入有效的数据Id集合!"));
  3357. if (dto.DiId < 1) return Ok(JsonView(false, $"请传入有效的数据DiId参数!"));
  3358. //大写数字序号
  3359. string[] num = { "一", "二", "三", "四", "五", "六", "七", "八", "九", "十" ,
  3360. "十一","十二","十三","十四","十五","十六","十七","十八","十九","二十",
  3361. "二十一","二十二","二十三","二十四","二十五","二十六","二十七","二十八","二十九","三十",
  3362. "三十一","三十二","三十三","三十四","三十五","三十六","三十七","三十八","三十九","四十"};
  3363. //数据源
  3364. var idItem = dto.DataIdItem.OrderBy(x => x);
  3365. var askDatas = await _sqlSugar.Queryable<Res_AskData>().Where(x => x.IsDel == 0 && idItem.Contains(x.Id)).ToListAsync();
  3366. //书签名
  3367. string Area = "",
  3368. Official = "";
  3369. //表格数据源
  3370. DataTable dt = new DataTable();
  3371. dt.Columns.Add("Country", typeof(string));
  3372. dt.Columns.Add("TalkCase", typeof(string));
  3373. int id = 0;
  3374. int TalkcaseOrder = 0;
  3375. int RowOrder = 0;
  3376. //填充数据
  3377. for (int i = 0; i < askDatas.Count; i++)
  3378. {
  3379. var ad = askDatas[i];
  3380. Area = Area + ad.Country + ad.Area + "、";
  3381. Official = Official + ad.UnitName + "、";
  3382. //填充表格数据源
  3383. DataRow dr = dt.NewRow();
  3384. if (i > 0)
  3385. {
  3386. var adtemp = askDatas[i - 1];
  3387. if (ad.Country == adtemp.Country)
  3388. {
  3389. TalkcaseOrder++;
  3390. dt.Rows[RowOrder]["TalkCase"] = dt.Rows[RowOrder]["TalkCase"] + "\r\n" + (1 + TalkcaseOrder).ToString() + "、" + ad.TalkCase;
  3391. }
  3392. else
  3393. {
  3394. RowOrder++;
  3395. dr = dt.NewRow();
  3396. dr["Country"] = "(" + num[RowOrder] + ")" + ad.Country;
  3397. dr["TalkCase"] = "1、" + ad.TalkCase;
  3398. dt.Rows.Add(dr);
  3399. TalkcaseOrder = 0;
  3400. }
  3401. }
  3402. else
  3403. {
  3404. dr["Country"] = "(" + num[i] + ")" + ad.Country;
  3405. dr["TalkCase"] = "1、" + ad.TalkCase;
  3406. dt.Rows.Add(dr);
  3407. }
  3408. id = ad.Id;
  3409. }
  3410. //模板路径
  3411. var tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/省外办出访请示模板.doc";
  3412. //载入模板
  3413. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  3414. #region 填充word内容
  3415. #region 填充请示内容
  3416. //利用DocumentBuilder处理表格或是书签
  3417. Aspose.Words.DocumentBuilder builder = new DocumentBuilder(doc);
  3418. string bookmark = "";
  3419. try
  3420. {
  3421. for (int i = 0; i < dt.Rows.Count; i++)
  3422. {
  3423. bookmark = bookmark
  3424. + dt.Rows[i]["Country"].ToString() + "\r\n"
  3425. + dt.Rows[i]["TalkCase"].ToString() + "\r\n";
  3426. }
  3427. }
  3428. catch
  3429. {
  3430. }
  3431. #endregion
  3432. #region 填充word模板书签内容
  3433. //团组信息
  3434. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == dto.DiId).FirstAsync();
  3435. //接团客户名单实例
  3436. string client_sql = string.Format(@"
  3437. SELECT
  3438. tcl.Id,
  3439. tcl.DiId,
  3440. tcl.IsAccompany,
  3441. temp.*,
  3442. u.CnName AS Operator,
  3443. tcl.CreateTime AS OperatingTime
  3444. FROM
  3445. Grp_TourClientList tcl
  3446. LEFT JOIN (
  3447. SELECT
  3448. dc.Id AS DcId,
  3449. dc.LastName,
  3450. dc.FirstName,
  3451. ccom.CompanyFullName,
  3452. dc.Job,
  3453. cc.CertNo AS IDCardNo,
  3454. dc.Sex,
  3455. dc.BirthDay
  3456. FROM
  3457. Crm_DeleClient dc
  3458. LEFT JOIN Crm_CustomerCompany ccom ON dc.CrmCompanyId = ccom.Id
  3459. AND ccom.IsDel = 0
  3460. LEFT JOIN Crm_CustomerCert cc ON dc.Id = cc.DcId
  3461. AND cc.SdId = 773
  3462. AND cc.IsDel = 0
  3463. WHERE
  3464. dc.IsDel = 0
  3465. ) temp ON temp.DcId = tcl.ClientId
  3466. LEFT JOIN Sys_Users u ON tcl.CreateUserId = u.Id
  3467. WHERE
  3468. tcl.IsDel = 0
  3469. AND tcl.DiId = {0}", dto.DiId);
  3470. var clientList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(client_sql).ToListAsync();
  3471. //机票代码实例
  3472. DataTable airTable = GeneralMethod.GetTableByBlackCode(dto.DiId);
  3473. //三字码
  3474. var threeCodes = await _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.IsDel == 0).ToListAsync();
  3475. //团名
  3476. if (doc.Range.Bookmarks["TeamName"] != null)
  3477. {
  3478. Bookmark mark = doc.Range.Bookmarks["TeamName"];
  3479. mark.Text = di.TeamName;
  3480. }
  3481. //团长名
  3482. if (doc.Range.Bookmarks["ClientName2"] != null)
  3483. {
  3484. Bookmark mark = doc.Range.Bookmarks["ClientName2"];
  3485. if (clientList == null || clientList.Count == 0)
  3486. {
  3487. mark.Text = "【本团尚未录入客户名单,请联系主管!】";
  3488. }
  3489. else
  3490. {
  3491. mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
  3492. }
  3493. }
  3494. if (doc.Range.Bookmarks["ClientName"] != null)
  3495. {
  3496. Bookmark mark = doc.Range.Bookmarks["ClientName"];
  3497. if (clientList == null || clientList.Count == 0)
  3498. {
  3499. mark.Text = "【本团尚未录入客户名单,请联系主管!】";
  3500. }
  3501. else
  3502. {
  3503. mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
  3504. }
  3505. }
  3506. //跟团人数
  3507. if (doc.Range.Bookmarks["ClientNumber2"] != null)
  3508. {
  3509. Bookmark mark = doc.Range.Bookmarks["ClientNumber2"];
  3510. mark.Text = di.VisitPNumber.ToString();
  3511. }
  3512. if (doc.Range.Bookmarks["ClientNumber"] != null)
  3513. {
  3514. Bookmark mark = doc.Range.Bookmarks["ClientNumber"];
  3515. mark.Text = di.VisitPNumber.ToString();
  3516. }
  3517. //地区
  3518. if (doc.Range.Bookmarks["Area"] != null)
  3519. {
  3520. Bookmark mark = doc.Range.Bookmarks["Area"];
  3521. mark.Text = Area.TrimEnd('、');
  3522. }
  3523. if (doc.Range.Bookmarks["Area2"] != null)
  3524. {
  3525. Bookmark mark = doc.Range.Bookmarks["Area2"];
  3526. mark.Text = Area.TrimEnd('、');
  3527. }
  3528. //出访目的
  3529. if (doc.Range.Bookmarks["Destination2"] != null)
  3530. {
  3531. Bookmark mark = doc.Range.Bookmarks["Destination2"];
  3532. mark.Text = di.VisitPurpose;
  3533. }
  3534. if (doc.Range.Bookmarks["Destination"] != null)
  3535. {
  3536. Bookmark mark = doc.Range.Bookmarks["Destination"];
  3537. mark.Text = di.VisitPurpose;
  3538. }
  3539. //邀请方
  3540. if (doc.Range.Bookmarks["Official"] != null)
  3541. {
  3542. Bookmark mark = doc.Range.Bookmarks["Official"];
  3543. mark.Text = Official.TrimEnd('、');
  3544. }
  3545. //出访日期
  3546. if (doc.Range.Bookmarks["VisitDate"] != null)
  3547. {
  3548. Bookmark mark = doc.Range.Bookmarks["VisitDate"];
  3549. mark.Text = di.VisitStartDate.Year + "年"
  3550. + di.VisitStartDate.Month + "月"
  3551. + di.VisitStartDate.Day + "日"
  3552. + "至"
  3553. + di.VisitEndDate.Month + "月"
  3554. + di.VisitEndDate.Day + "日";
  3555. }
  3556. //请示范例
  3557. if (doc.Range.Bookmarks["Temp"] != null)
  3558. {
  3559. Bookmark mark = doc.Range.Bookmarks["Temp"];
  3560. mark.Text = bookmark;
  3561. }
  3562. //出访起止日期
  3563. if (doc.Range.Bookmarks["Duration"] != null)
  3564. {
  3565. Bookmark mark = doc.Range.Bookmarks["Duration"];
  3566. mark.Text = di.VisitStartDate.Year + "年"
  3567. + di.VisitStartDate.Month + "月"
  3568. + di.VisitStartDate.Day + "日"
  3569. + "至"
  3570. + di.VisitEndDate.Month + "月"
  3571. + di.VisitEndDate.Day + "日";
  3572. }
  3573. //出访天数
  3574. if (doc.Range.Bookmarks["Durationdays"] != null)
  3575. {
  3576. Bookmark mark = doc.Range.Bookmarks["Durationdays"];
  3577. mark.Text = di.VisitDays.ToString();
  3578. }
  3579. if (doc.Range.Bookmarks["Durationdays2"] != null)
  3580. {
  3581. Bookmark mark = doc.Range.Bookmarks["Durationdays2"];
  3582. mark.Text = di.VisitDays.ToString();
  3583. }
  3584. #region 根据黑屏代码获取国家呆的天数;获取路线
  3585. string result_CountryAndDay = "", result_Air = "";
  3586. if (airTable.Rows[airTable.Rows.Count - 1]["Day"].ToString() == "")
  3587. {
  3588. result_CountryAndDay = airTable.Rows[airTable.Rows.Count - 1]["Fliagtcode"].ToString();
  3589. result_Air = result_CountryAndDay;
  3590. }
  3591. else
  3592. {
  3593. string place_start, place_end;
  3594. DateTime time_start, time_end;
  3595. Res_ThreeCode three = null;
  3596. for (int i = 0; i < airTable.Rows.Count; i++)
  3597. {
  3598. //三字码实例
  3599. three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(0, 3));
  3600. if (three == null)
  3601. {
  3602. place_start = "【未收录三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
  3603. }
  3604. else
  3605. {
  3606. if (string.IsNullOrEmpty(three.Country))
  3607. {
  3608. place_start = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
  3609. }
  3610. else
  3611. {
  3612. place_start = three.City;
  3613. }
  3614. }
  3615. three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(3, 3));
  3616. if (three == null)
  3617. {
  3618. place_end = "【未收录" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
  3619. }
  3620. else
  3621. {
  3622. if (string.IsNullOrEmpty(three.Country))
  3623. {
  3624. place_end = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
  3625. }
  3626. else
  3627. {
  3628. place_end = three.City;
  3629. }
  3630. }
  3631. result_Air += place_start + "一" + place_end + "一";
  3632. //获取国家和呆的天数
  3633. if (i > 0 && i < airTable.Rows.Count - 1)
  3634. {
  3635. time_start = Convert.ToDateTime(airTable.Rows[i - 1]["Day"]);
  3636. time_end = Convert.ToDateTime(airTable.Rows[i]["Day"]);
  3637. TimeSpan daycount = time_end.Subtract(time_start);
  3638. result_CountryAndDay += place_start + daycount.Days + "天" + ",";
  3639. }
  3640. }
  3641. }
  3642. #endregion
  3643. //每个国家呆的天数
  3644. if (doc.Range.Bookmarks["CountryAndDay"] != null)
  3645. {
  3646. Bookmark mark = doc.Range.Bookmarks["CountryAndDay"];
  3647. mark.Text = result_CountryAndDay.TrimEnd(',');
  3648. }
  3649. #region 出访路线城市字符串去重
  3650. result_Air = result_Air.TrimEnd('一');
  3651. string[] airTemp = result_Air.Split('一');
  3652. airTemp = airTemp.Distinct().ToArray();
  3653. result_Air = "";
  3654. foreach (string str in airTemp)
  3655. {
  3656. result_Air += str + "一";
  3657. }
  3658. result_Air = result_Air + airTemp[0];
  3659. #endregion
  3660. //出访路线
  3661. if (doc.Range.Bookmarks["Air"] != null)
  3662. {
  3663. Bookmark mark = doc.Range.Bookmarks["Air"];
  3664. mark.Text = result_Air;
  3665. }
  3666. #endregion
  3667. #region 客户名单
  3668. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3669. Aspose.Words.Tables.Table tableClient = allTables[0] as Aspose.Words.Tables.Table;
  3670. if (clientList == null || clientList.Count == 0)
  3671. {
  3672. builder.MoveToCell(0, 1, 0, 0);
  3673. builder.Write("【本团尚未录入客户名单,请联系主管!】");
  3674. }
  3675. else
  3676. {
  3677. for (int i = 0; i < clientList.Count; i++)
  3678. {
  3679. builder.MoveToCell(0, i + 1, 0, 0);
  3680. builder.Write((i + 1).ToString());
  3681. builder.MoveToCell(0, i + 1, 1, 0);
  3682. builder.Write(clientList[i].LastName.ToString() + clientList[i].FirstName.ToString());
  3683. builder.MoveToCell(0, i + 1, 2, 0);
  3684. builder.Write(clientList[i].Sex.ToString());
  3685. builder.MoveToCell(0, i + 1, 3, 0);
  3686. builder.Write(clientList[i].BirthDay);
  3687. builder.MoveToCell(0, i + 1, 4, 0);
  3688. builder.Write(clientList[i].CompanyFullName + clientList[i].Job.ToString());
  3689. }
  3690. }
  3691. while (tableClient.Rows.Count > clientList.Count + 1)
  3692. {
  3693. tableClient.Rows.RemoveAt(clientList.Count + 1);
  3694. }
  3695. #endregion
  3696. #region 商邀行程
  3697. string content = "", temp1 = "", temp2 = "";
  3698. //获取数据,放到datatable
  3699. var listapt = await _sqlSugar.Queryable<Grp_ApprovalTravel>()
  3700. .LeftJoin<Grp_ApprovalTravelDetails>((at, atd) => at.Id == atd.ParentId)
  3701. .Where((at, atd) => at.IsDel == 0 && at.Diid == dto.DiId)
  3702. .Select((at, atd) => new
  3703. {
  3704. at.Id,
  3705. at.Date,
  3706. atd.Time,
  3707. atd.Details
  3708. })
  3709. .ToListAsync();
  3710. if (listapt == null || listapt.Count == 0)
  3711. {
  3712. content = "尚未生成商邀行程";
  3713. }
  3714. else
  3715. {
  3716. for (int i = 0; i < listapt.Count; i++)
  3717. {
  3718. content = content + " " + listapt[i].Date + "\r\n";
  3719. temp1 = listapt[i].Time;
  3720. temp2 = listapt[i].Details;
  3721. if (!string.IsNullOrEmpty(temp1))
  3722. {
  3723. string[] str = temp1.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3724. string[] str2 = temp2.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3725. for (int j = 0; j < str.Length; j++)
  3726. {
  3727. content = content + " " + str[j] + str2[j] + "\r\n";
  3728. }
  3729. }
  3730. }
  3731. }
  3732. if (doc.Range.Bookmarks["Content"] != null)
  3733. {
  3734. Bookmark mark = doc.Range.Bookmarks["Content"];
  3735. mark.Text = content;
  3736. }
  3737. while (tableClient.Rows.Count > 1 + clientList.Count)
  3738. {
  3739. tableClient.Rows.RemoveAt(1 + clientList.Count);
  3740. }
  3741. #endregion
  3742. #endregion
  3743. string strFileName = $"/AskData/省外办出访请示{Guid.NewGuid().ToString()}.doc";
  3744. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  3745. var url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  3746. return Ok(JsonView(true, "操作成功!", new { url = url }));
  3747. }
  3748. /// <summary>
  3749. /// 请示资料信息
  3750. /// 市外办下载
  3751. /// </summary>
  3752. /// <param name="dto"></param>
  3753. /// <returns></returns>
  3754. [HttpPost]
  3755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3756. public async Task<IActionResult> AskDataCityFAOPFile(AskDataProvinceFileDto dto)
  3757. {
  3758. if (dto.DataIdItem.Length < 1) return Ok(JsonView(false, $"请传入有效的数据Id集合!"));
  3759. if (dto.DiId < 1) return Ok(JsonView(false, $"请传入有效的数据DiId参数!"));
  3760. //大写数字序号
  3761. string[] num = { "一", "二", "三", "四", "五", "六", "七", "八", "九", "十" ,
  3762. "十一","十二","十三","十四","十五","十六","十七","十八","十九","二十",
  3763. "二十一","二十二","二十三","二十四","二十五","二十六","二十七","二十八","二十九","三十",
  3764. "三十一","三十二","三十三","三十四","三十五","三十六","三十七","三十八","三十九","四十"};
  3765. //数据源
  3766. var idItem = dto.DataIdItem.OrderBy(x => x);
  3767. var askDatas = await _sqlSugar.Queryable<Res_AskData>().Where(x => x.IsDel == 0 && idItem.Contains(x.Id)).ToListAsync();
  3768. //书签名
  3769. string Area = "",
  3770. Official = "";
  3771. //表格数据源
  3772. DataTable dt = new DataTable();
  3773. dt.Columns.Add("Country", typeof(string));
  3774. dt.Columns.Add("TalkCase", typeof(string));
  3775. int id = 0;
  3776. int TalkcaseOrder = 0;
  3777. int RowOrder = 0;
  3778. //填充数据
  3779. for (int i = 0; i < askDatas.Count; i++)
  3780. {
  3781. var ad = askDatas[i];
  3782. Area = Area + ad.Country + ad.Area + "、";
  3783. Official = Official + ad.UnitName + "、";
  3784. //填充表格数据源
  3785. DataRow dr = dt.NewRow();
  3786. if (i > 0)
  3787. {
  3788. var adtemp = askDatas[i - 1];
  3789. if (ad.Country == adtemp.Country)
  3790. {
  3791. TalkcaseOrder++;
  3792. dt.Rows[RowOrder]["TalkCase"] = dt.Rows[RowOrder]["TalkCase"] + "\r\n" + (1 + TalkcaseOrder).ToString() + "、" + ad.TalkCase;
  3793. }
  3794. else
  3795. {
  3796. RowOrder++;
  3797. dr = dt.NewRow();
  3798. dr["Country"] = "(" + num[RowOrder] + ")" + ad.Country;
  3799. dr["TalkCase"] = "1、" + ad.TalkCase;
  3800. dt.Rows.Add(dr);
  3801. TalkcaseOrder = 0;
  3802. }
  3803. }
  3804. else
  3805. {
  3806. dr["Country"] = "(" + num[i] + ")" + ad.Country;
  3807. dr["TalkCase"] = "1、" + ad.TalkCase;
  3808. dt.Rows.Add(dr);
  3809. }
  3810. id = ad.Id;
  3811. }
  3812. //模板路径
  3813. var tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/市外办出访请示.doc";
  3814. //载入模板
  3815. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  3816. #region 填充word内容
  3817. #region 填充请示内容
  3818. //利用DocumentBuilder处理表格或是书签
  3819. Aspose.Words.DocumentBuilder builder = new DocumentBuilder(doc);
  3820. string bookmark = "";
  3821. try
  3822. {
  3823. for (int i = 0; i < dt.Rows.Count; i++)
  3824. {
  3825. bookmark = bookmark
  3826. + dt.Rows[i]["Country"].ToString() + "\r\n"
  3827. + dt.Rows[i]["TalkCase"].ToString() + "\r\n";
  3828. }
  3829. }
  3830. catch
  3831. {
  3832. }
  3833. #endregion
  3834. #region 填充word模板书签内容
  3835. //团组信息
  3836. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == dto.DiId).FirstAsync();
  3837. //接团客户名单实例
  3838. string client_sql = string.Format(@"
  3839. SELECT
  3840. tcl.Id,
  3841. tcl.DiId,
  3842. tcl.IsAccompany,
  3843. temp.*,
  3844. u.CnName AS Operator,
  3845. tcl.CreateTime AS OperatingTime
  3846. FROM
  3847. Grp_TourClientList tcl
  3848. LEFT JOIN (
  3849. SELECT
  3850. dc.Id AS DcId,
  3851. dc.LastName,
  3852. dc.FirstName,
  3853. ccom.CompanyFullName,
  3854. dc.Job,
  3855. cc.CertNo AS IDCardNo,
  3856. dc.Sex,
  3857. dc.BirthDay
  3858. FROM
  3859. Crm_DeleClient dc
  3860. LEFT JOIN Crm_CustomerCompany ccom ON dc.CrmCompanyId = ccom.Id
  3861. AND ccom.IsDel = 0
  3862. LEFT JOIN Crm_CustomerCert cc ON dc.Id = cc.DcId
  3863. AND cc.SdId = 773
  3864. AND cc.IsDel = 0
  3865. WHERE
  3866. dc.IsDel = 0
  3867. ) temp ON temp.DcId = tcl.ClientId
  3868. LEFT JOIN Sys_Users u ON tcl.CreateUserId = u.Id
  3869. WHERE
  3870. tcl.IsDel = 0
  3871. AND tcl.DiId = {0}", dto.DiId);
  3872. var clientList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(client_sql).ToListAsync();
  3873. //机票代码实例
  3874. DataTable airTable = GeneralMethod.GetTableByBlackCode(dto.DiId);
  3875. //三字码
  3876. var threeCodes = await _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.IsDel == 0).ToListAsync();
  3877. //团名
  3878. if (doc.Range.Bookmarks["TeamName"] != null)
  3879. {
  3880. Bookmark mark = doc.Range.Bookmarks["TeamName"];
  3881. mark.Text = di.TeamName;
  3882. }
  3883. //团长名
  3884. if (doc.Range.Bookmarks["ClientName2"] != null)
  3885. {
  3886. Bookmark mark = doc.Range.Bookmarks["ClientName2"];
  3887. if (clientList == null || clientList.Count == 0)
  3888. {
  3889. mark.Text = "【本团尚未录入客户名单,请联系主管!】";
  3890. }
  3891. else
  3892. {
  3893. mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
  3894. }
  3895. }
  3896. if (doc.Range.Bookmarks["ClientName"] != null)
  3897. {
  3898. Bookmark mark = doc.Range.Bookmarks["ClientName"];
  3899. if (clientList == null || clientList.Count == 0)
  3900. {
  3901. mark.Text = "【本团尚未录入客户名单,请联系主管!】";
  3902. }
  3903. else
  3904. {
  3905. mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
  3906. }
  3907. }
  3908. //跟团人数
  3909. if (doc.Range.Bookmarks["ClientNumber2"] != null)
  3910. {
  3911. Bookmark mark = doc.Range.Bookmarks["ClientNumber2"];
  3912. mark.Text = di.VisitPNumber.ToString();
  3913. }
  3914. if (doc.Range.Bookmarks["ClientNumber"] != null)
  3915. {
  3916. Bookmark mark = doc.Range.Bookmarks["ClientNumber"];
  3917. mark.Text = di.VisitPNumber.ToString();
  3918. }
  3919. //地区
  3920. if (doc.Range.Bookmarks["Area"] != null)
  3921. {
  3922. Bookmark mark = doc.Range.Bookmarks["Area"];
  3923. mark.Text = Area.TrimEnd('、');
  3924. }
  3925. if (doc.Range.Bookmarks["Area2"] != null)
  3926. {
  3927. Bookmark mark = doc.Range.Bookmarks["Area2"];
  3928. mark.Text = Area.TrimEnd('、');
  3929. }
  3930. //出访目的
  3931. if (doc.Range.Bookmarks["Destination2"] != null)
  3932. {
  3933. Bookmark mark = doc.Range.Bookmarks["Destination2"];
  3934. mark.Text = di.VisitPurpose;
  3935. }
  3936. if (doc.Range.Bookmarks["Destination"] != null)
  3937. {
  3938. Bookmark mark = doc.Range.Bookmarks["Destination"];
  3939. mark.Text = di.VisitPurpose;
  3940. }
  3941. //邀请方
  3942. if (doc.Range.Bookmarks["Official"] != null)
  3943. {
  3944. Bookmark mark = doc.Range.Bookmarks["Official"];
  3945. mark.Text = Official.TrimEnd('、');
  3946. }
  3947. //出访日期
  3948. if (doc.Range.Bookmarks["VisitDate"] != null)
  3949. {
  3950. Bookmark mark = doc.Range.Bookmarks["VisitDate"];
  3951. mark.Text = di.VisitStartDate.Year + "年"
  3952. + di.VisitStartDate.Month + "月"
  3953. + di.VisitStartDate.Day + "日"
  3954. + "至"
  3955. + di.VisitEndDate.Month + "月"
  3956. + di.VisitEndDate.Day + "日";
  3957. }
  3958. //请示范例
  3959. if (doc.Range.Bookmarks["Temp"] != null)
  3960. {
  3961. Bookmark mark = doc.Range.Bookmarks["Temp"];
  3962. mark.Text = bookmark;
  3963. }
  3964. //出访起止日期
  3965. if (doc.Range.Bookmarks["Duration"] != null)
  3966. {
  3967. Bookmark mark = doc.Range.Bookmarks["Duration"];
  3968. mark.Text = di.VisitStartDate.Year + "年"
  3969. + di.VisitStartDate.Month + "月"
  3970. + di.VisitStartDate.Day + "日"
  3971. + "至"
  3972. + di.VisitEndDate.Month + "月"
  3973. + di.VisitEndDate.Day + "日";
  3974. }
  3975. //出访天数
  3976. if (doc.Range.Bookmarks["Durationdays"] != null)
  3977. {
  3978. Bookmark mark = doc.Range.Bookmarks["Durationdays"];
  3979. mark.Text = di.VisitDays.ToString();
  3980. }
  3981. if (doc.Range.Bookmarks["Durationdays2"] != null)
  3982. {
  3983. Bookmark mark = doc.Range.Bookmarks["Durationdays2"];
  3984. mark.Text = di.VisitDays.ToString();
  3985. }
  3986. #region 根据黑屏代码获取国家呆的天数;获取路线
  3987. string result_CountryAndDay = "", result_Air = "";
  3988. if (airTable.Rows[airTable.Rows.Count - 1]["Day"].ToString() == "")
  3989. {
  3990. result_CountryAndDay = airTable.Rows[airTable.Rows.Count - 1]["Fliagtcode"].ToString();
  3991. result_Air = result_CountryAndDay;
  3992. }
  3993. else
  3994. {
  3995. string place_start, place_end;
  3996. DateTime time_start, time_end;
  3997. Res_ThreeCode three = null;
  3998. for (int i = 0; i < airTable.Rows.Count; i++)
  3999. {
  4000. //三字码实例
  4001. three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(0, 3));
  4002. if (three == null)
  4003. {
  4004. place_start = "【未收录三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
  4005. }
  4006. else
  4007. {
  4008. if (string.IsNullOrEmpty(three.Country))
  4009. {
  4010. place_start = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
  4011. }
  4012. else
  4013. {
  4014. place_start = three.City;
  4015. }
  4016. }
  4017. three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(3, 3));
  4018. if (three == null)
  4019. {
  4020. place_end = "【未收录" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
  4021. }
  4022. else
  4023. {
  4024. if (string.IsNullOrEmpty(three.Country))
  4025. {
  4026. place_end = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
  4027. }
  4028. else
  4029. {
  4030. place_end = three.City;
  4031. }
  4032. }
  4033. result_Air += place_start + "一" + place_end + "一";
  4034. //获取国家和呆的天数
  4035. if (i > 0 && i < airTable.Rows.Count - 1)
  4036. {
  4037. time_start = Convert.ToDateTime(airTable.Rows[i - 1]["Day"]);
  4038. time_end = Convert.ToDateTime(airTable.Rows[i]["Day"]);
  4039. TimeSpan daycount = time_end.Subtract(time_start);
  4040. result_CountryAndDay += place_start + daycount.Days + "天" + ",";
  4041. }
  4042. }
  4043. }
  4044. #endregion
  4045. //每个国家呆的天数
  4046. if (doc.Range.Bookmarks["CountryAndDay"] != null)
  4047. {
  4048. Bookmark mark = doc.Range.Bookmarks["CountryAndDay"];
  4049. mark.Text = result_CountryAndDay.TrimEnd(',');
  4050. }
  4051. #region 出访路线城市字符串去重
  4052. result_Air = result_Air.TrimEnd('一');
  4053. string[] airTemp = result_Air.Split('一');
  4054. airTemp = airTemp.Distinct().ToArray();
  4055. result_Air = "";
  4056. foreach (string str in airTemp)
  4057. {
  4058. result_Air += str + "一";
  4059. }
  4060. result_Air = result_Air + airTemp[0];
  4061. #endregion
  4062. //出访路线
  4063. if (doc.Range.Bookmarks["Air"] != null)
  4064. {
  4065. Bookmark mark = doc.Range.Bookmarks["Air"];
  4066. mark.Text = result_Air;
  4067. }
  4068. #endregion
  4069. #region 客户名单
  4070. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4071. Aspose.Words.Tables.Table tableClient = allTables[0] as Aspose.Words.Tables.Table;
  4072. if (clientList == null || clientList.Count == 0)
  4073. {
  4074. builder.MoveToCell(0, 1, 0, 0);
  4075. builder.Write("【本团尚未录入客户名单,请联系主管!】");
  4076. }
  4077. else
  4078. {
  4079. for (int i = 0; i < clientList.Count; i++)
  4080. {
  4081. builder.MoveToCell(0, i + 1, 0, 0);
  4082. builder.Write((i + 1).ToString());
  4083. builder.MoveToCell(0, i + 1, 1, 0);
  4084. builder.Write(clientList[i].LastName.ToString() + clientList[i].FirstName.ToString());
  4085. builder.MoveToCell(0, i + 1, 2, 0);
  4086. builder.Write(clientList[i].Sex.ToString());
  4087. builder.MoveToCell(0, i + 1, 3, 0);
  4088. builder.Write(clientList[i].BirthDay);
  4089. builder.MoveToCell(0, i + 1, 4, 0);
  4090. builder.Write(clientList[i].CompanyFullName + clientList[i].Job.ToString());
  4091. }
  4092. }
  4093. while (tableClient.Rows.Count > clientList.Count + 1)
  4094. {
  4095. tableClient.Rows.RemoveAt(clientList.Count + 1);
  4096. }
  4097. #endregion
  4098. #region 商邀行程
  4099. string content = "", temp1 = "", temp2 = "";
  4100. //获取数据,放到datatable
  4101. var listapt = await _sqlSugar.Queryable<Grp_ApprovalTravel>()
  4102. .LeftJoin<Grp_ApprovalTravelDetails>((at, atd) => at.Id == atd.ParentId)
  4103. .Where((at, atd) => at.IsDel == 0 && at.Diid == dto.DiId)
  4104. .Select((at, atd) => new
  4105. {
  4106. at.Id,
  4107. at.Date,
  4108. atd.Time,
  4109. atd.Details
  4110. })
  4111. .ToListAsync();
  4112. if (listapt == null || listapt.Count == 0)
  4113. {
  4114. content = "尚未生成商邀行程";
  4115. }
  4116. else
  4117. {
  4118. for (int i = 0; i < listapt.Count; i++)
  4119. {
  4120. content = content + " " + listapt[i].Date + "\r\n";
  4121. temp1 = listapt[i].Time;
  4122. temp2 = listapt[i].Details;
  4123. if (!string.IsNullOrEmpty(temp1))
  4124. {
  4125. string[] str = temp1.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4126. string[] str2 = temp2.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4127. for (int j = 0; j < str.Length; j++)
  4128. {
  4129. content = content + " " + str[j] + str2[j] + "\r\n";
  4130. }
  4131. }
  4132. }
  4133. }
  4134. if (doc.Range.Bookmarks["Content"] != null)
  4135. {
  4136. Bookmark mark = doc.Range.Bookmarks["Content"];
  4137. mark.Text = content;
  4138. }
  4139. while (tableClient.Rows.Count > 1 + clientList.Count)
  4140. {
  4141. tableClient.Rows.RemoveAt(1 + clientList.Count);
  4142. }
  4143. #endregion
  4144. #endregion
  4145. string strFileName = $"/AskData/市外办出访请示{Guid.NewGuid().ToString()}.doc";
  4146. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  4147. var url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  4148. return Ok(JsonView(true, "操作成功!", new { url = url }));
  4149. }
  4150. #endregion
  4151. #region 机票黑屏代码
  4152. /// <summary>
  4153. /// 根据团组Id查询黑屏代码列表
  4154. /// </summary>
  4155. /// <param name="dto"></param>
  4156. /// <returns></returns>
  4157. [HttpPost]
  4158. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4159. public async Task<IActionResult> QueryTicketBlackCodeByDiId(QueryTicketBlackCodeByDiIdDto dto)
  4160. {
  4161. Result groupData = await _ticketBlackCodeRep.QueryTicketBlackCodeByDiId(dto);
  4162. if (groupData.Code != 0)
  4163. {
  4164. return Ok(JsonView(false, groupData.Msg));
  4165. }
  4166. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4167. }
  4168. /// <summary>
  4169. /// 根据黑屏代码数据Id查询信息
  4170. /// </summary>
  4171. /// <param name="dto"></param>
  4172. /// <returns></returns>
  4173. [HttpPost]
  4174. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4175. public async Task<IActionResult> QueryTicketBlackCodeById(QueryTicketBlackCodeByIdDto dto)
  4176. {
  4177. Result groupData = await _ticketBlackCodeRep.QueryTicketBlackCodeById(dto);
  4178. if (groupData.Code != 0)
  4179. {
  4180. return Ok(JsonView(false, groupData.Msg));
  4181. }
  4182. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4183. }
  4184. /// <summary>
  4185. /// 黑屏代码操作(Status:1.新增,2.修改)
  4186. /// </summary>
  4187. /// <param name="dto"></param>
  4188. /// <returns></returns>
  4189. [HttpPost]
  4190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4191. public async Task<IActionResult> OpTicketBlackCode(OpTicketBlackCodeDto dto)
  4192. {
  4193. Result groupData = await _ticketBlackCodeRep.OpTicketBlackCode(dto);
  4194. if (groupData.Code != 0)
  4195. {
  4196. return Ok(JsonView(false, groupData.Msg));
  4197. }
  4198. try
  4199. {
  4200. var tongzhi = _ticketBlackCodeRep.DescBlackToVisa(dto.DiId);
  4201. if (tongzhi.Code == 0)
  4202. {
  4203. var info = tongzhi.Data.GetType().GetProperty("info").GetValue(tongzhi.Data) as List<string>;
  4204. var data = tongzhi.Data.GetType().GetProperty("data").GetValue(tongzhi.Data) as List<CountryDataTime>;
  4205. if (data != null)
  4206. await AppNoticeLibrary.SendUserMsg_blackAirInfo_ToVisaUser(dto.DiId, data);
  4207. }
  4208. //行程代码变更通知
  4209. await AppNoticeLibrary.SendUserMsg_GroupShare_ToDP(dto.DiId, dto.CreateUserId);
  4210. }
  4211. catch (Exception)
  4212. {
  4213. throw;
  4214. }
  4215. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4216. }
  4217. /// <summary>
  4218. /// 删除黑屏代码
  4219. /// </summary>
  4220. /// <param name="dto"></param>
  4221. /// <returns></returns>
  4222. [HttpPost]
  4223. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4224. public async Task<IActionResult> DelTicketBlackCode(DelBaseDto dto)
  4225. {
  4226. var res = await _ticketBlackCodeRep.SoftDeleteByIdAsync<Air_TicketBlackCode>(dto.Id.ToString(), dto.DeleteUserId);
  4227. if (!res)
  4228. {
  4229. return Ok(JsonView(false, "删除失败"));
  4230. }
  4231. return Ok(JsonView(true, "删除成功!"));
  4232. }
  4233. #endregion
  4234. #region 翻译人员
  4235. /// <summary>
  4236. /// 翻译人员库
  4237. /// Init
  4238. /// </summary>
  4239. /// <returns></returns>
  4240. [HttpGet]
  4241. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4242. public async Task<IActionResult> TranslatorLibraryInit()
  4243. {
  4244. var currencyData = await _sqlSugar.Queryable<Sys_SetData>()
  4245. .Where(x => x.IsDel == 0 && x.STid == 66)
  4246. .Select(x => new
  4247. {
  4248. x.Id,
  4249. x.Name,
  4250. })
  4251. .ToListAsync();
  4252. var officialDutyData = await _sqlSugar.Queryable<Res_OfficialActivities>()
  4253. .LeftJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  4254. .Where((oa, di) => oa.IsDel == 0)
  4255. .Select((oa, di) => new
  4256. {
  4257. oa.Id,
  4258. oa.Client,
  4259. oa.DiId,
  4260. di.TeamName
  4261. })
  4262. .ToListAsync();
  4263. var officialDutyData1 = officialDutyData.GroupBy(x => x.DiId)
  4264. .Select(g => new
  4265. {
  4266. id = g.Key,
  4267. label = g.FirstOrDefault()?.TeamName ?? "-",
  4268. children = g.Select(g1 => new { id = g1.Id, label = g1.Client }).ToList()
  4269. })
  4270. .ToList();
  4271. var view = new
  4272. {
  4273. currencyData,
  4274. officialDutyData = officialDutyData1
  4275. };
  4276. return Ok(JsonView(view));
  4277. }
  4278. /// <summary>
  4279. /// 翻译人员库
  4280. /// 详情
  4281. /// </summary>
  4282. /// <param name="id"></param>
  4283. /// <returns></returns>
  4284. [HttpGet("id")]
  4285. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4286. public async Task<IActionResult> TranslatorLibraryInfo(int id)
  4287. {
  4288. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  4289. var info = await _translatorRep.Query(x => x.Id == id).FirstAsync();
  4290. EncryptionProcessor.DecryptProperties(info);
  4291. var view = _mapper.Map<TranslatorLibraryInfoView>(info);
  4292. //var data1 = await _sqlSugar.Queryable<Grp_OfficialDutyLinkTranslator>().Where(x => x.TranslatorId == id).Select(x => x.Id).ToArrayAsync();
  4293. view.OfficialDutyIdItem = await _sqlSugar
  4294. .Queryable<Grp_OfficialDutyLinkTranslator>()
  4295. .Where(x => x.IsDel == 0 && x.TranslatorId == id)
  4296. .Select(x => x.OfficialDutyId)
  4297. .ToArrayAsync();
  4298. return Ok(JsonView(view));
  4299. }
  4300. /// <summary>
  4301. /// 翻译人员库
  4302. /// Item
  4303. /// </summary>
  4304. /// <param name="dto"></param>
  4305. /// <returns></returns>
  4306. [HttpPost]
  4307. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4308. public async Task<IActionResult> TranslatorLibraryItem(TranslatorLibraryItemDto dto)
  4309. {
  4310. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  4311. var name = AesEncryptionHelper.Encrypt(dto.Name);
  4312. RefAsync<int> total = 0;
  4313. var view = await _sqlSugar.Queryable<Res_TranslatorLibrary>()
  4314. .Where(x => x.IsDel == 0)
  4315. .WhereIF(!string.IsNullOrEmpty(name), x => x.Name.Contains(name))
  4316. .Select(x => new TranslatorLibraryItemView()
  4317. {
  4318. Id = x.Id,
  4319. Area = x.Area,
  4320. Name = x.Name,
  4321. Sex = x.Sex == 0 ? "未设置" : x.Sex == 1 ? "男" : "女",
  4322. Tel = x.Tel,
  4323. Email = x.Email,
  4324. WechatNo = x.WechatNo,
  4325. Language = x.Language,
  4326. Price = x.Price,
  4327. Currency = SqlFunc.Subqueryable<Sys_SetData>().Where(x1 => x1.Id == x.Currency).Select(x1 => x1.Name) ?? "-",
  4328. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x1.Id == x.CreateUserId).Select(x1 => x1.CnName) ?? "-",
  4329. LastUpddateTime = x.LastUpdateTime,
  4330. CreateTime = x.CreateTime,
  4331. Remark = x.Remark
  4332. })
  4333. .OrderByDescending(x => x.CreateTime)
  4334. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  4335. foreach (var item in view) EncryptionProcessor.DecryptProperties(item);
  4336. return Ok(JsonView(view, total));
  4337. }
  4338. /// <summary>
  4339. /// 翻译人员库
  4340. /// OP
  4341. /// </summary>
  4342. /// <param name="dto"></param>
  4343. /// <returns></returns>
  4344. [HttpPost]
  4345. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4346. public async Task<IActionResult> TranslatorLibraryOp([FromForm] TranslatorLibraryOpDto dto)
  4347. {
  4348. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  4349. if (dto.Status < 1 || dto.Status > 2) return Ok(JsonView(false, MsgTips.Status));
  4350. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  4351. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  4352. var fileNames = new List<string>();
  4353. //D:\FTP\File\OA2023\Office\GrpFile\TranslatorLibrary
  4354. var fileBasePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}TranslatorLibrary";
  4355. #region 保存文件
  4356. if (dto.Files != null)
  4357. {
  4358. if (!System.IO.Directory.Exists(fileBasePath))
  4359. {
  4360. System.IO.Directory.CreateDirectory(fileBasePath);
  4361. }
  4362. foreach (var item in dto.Files)
  4363. {
  4364. if (item.Length < 1) continue;
  4365. var file = item;
  4366. // 将文件保存到指定位置
  4367. var filePath = Path.Combine(fileBasePath, file.FileName);
  4368. using (var stream = new FileStream(filePath, FileMode.Create))
  4369. {
  4370. await file.CopyToAsync(stream);
  4371. }
  4372. //验证文件是否上传成功
  4373. if (!System.IO.File.Exists(filePath))
  4374. {
  4375. foreach (var filePathStr in fileNames)
  4376. {
  4377. System.IO.File.Delete(Path.Combine(fileBasePath, filePathStr));
  4378. }
  4379. return Ok(JsonView(false, "文件上传失败!"));
  4380. }
  4381. fileNames.Add(file.FileName);
  4382. }
  4383. }
  4384. #endregion
  4385. #region 参数处理
  4386. EncryptionProcessor.EncryptProperties(dto);
  4387. var translatorInfo = _mapper.Map<Res_TranslatorLibrary>(dto);
  4388. translatorInfo.LastUpdateTime = translatorInfo.CreateTime;
  4389. translatorInfo.CreateUserId = currUserInfo.UserId;
  4390. #endregion
  4391. _sqlSugar.BeginTran();
  4392. if (dto.Status == 1)
  4393. {
  4394. //验证重复
  4395. var info = await _translatorRep.Query(x => x.Area.Equals(dto.Area) && x.Name.Equals(dto.Name)).FirstAsync();
  4396. if (info != null) return Ok(JsonView(false, "该条数据已存在!"));
  4397. if (fileNames.Count > 0)
  4398. {
  4399. translatorInfo.Files = AesEncryptionHelper.Encrypt(JsonConvert.SerializeObject(fileNames));
  4400. }
  4401. var id = await _translatorRep.AddAsync(translatorInfo);
  4402. if (id > 0)
  4403. {
  4404. #region 新增(公务信息关联翻译人员) 关联信息
  4405. if (dto.officialDutyIdItem != null && dto.officialDutyIdItem.Length > 0)
  4406. {
  4407. var officialDutyLinkTranslators = new List<Grp_OfficialDutyLinkTranslator>();
  4408. foreach (var officialDutyId in dto.officialDutyIdItem)
  4409. {
  4410. officialDutyLinkTranslators.Add(new Grp_OfficialDutyLinkTranslator()
  4411. {
  4412. TranslatorId = id,
  4413. OfficialDutyId = officialDutyId,
  4414. CreateUserId = currUserInfo.UserId,
  4415. Remark = $"翻译人员库-->添加"
  4416. });
  4417. }
  4418. if (officialDutyLinkTranslators.Count > 0)
  4419. {
  4420. await _sqlSugar.Insertable(officialDutyLinkTranslators).ExecuteCommandAsync();
  4421. }
  4422. }
  4423. #endregion
  4424. _sqlSugar.CommitTran();
  4425. return Ok(JsonView(true));
  4426. }
  4427. }
  4428. else if (dto.Status == 2)
  4429. {
  4430. var info = await _translatorRep.Query(x => x.Id == dto.Id).FirstAsync();
  4431. if (info != null)
  4432. {
  4433. if (!string.IsNullOrEmpty(info.Files))
  4434. {
  4435. try
  4436. {
  4437. var selectFiles = JsonConvert.DeserializeObject<List<string>>(info.Files);
  4438. fileNames.AddRange(selectFiles);
  4439. }
  4440. catch (Exception)
  4441. {
  4442. }
  4443. }
  4444. }
  4445. if (fileNames.Count > 0)
  4446. {
  4447. translatorInfo.Files = AesEncryptionHelper.Encrypt(JsonConvert.SerializeObject(fileNames));
  4448. }
  4449. translatorInfo.LastUpdateTime = DateTime.Now;
  4450. var upd = await _translatorRep
  4451. .UpdateAsync(x => x.Id == dto.Id, x => new Res_TranslatorLibrary()
  4452. {
  4453. Area = translatorInfo.Area,
  4454. Name = translatorInfo.Name,
  4455. Sex = translatorInfo.Sex,
  4456. Photo = translatorInfo.Photo,
  4457. Tel = translatorInfo.Tel,
  4458. Email = translatorInfo.Email,
  4459. WechatNo = translatorInfo.WechatNo,
  4460. OtherSocialAccounts = translatorInfo.OtherSocialAccounts,
  4461. Language = translatorInfo.Language,
  4462. Price = translatorInfo.Price,
  4463. Currency = translatorInfo.Currency,
  4464. Remark = translatorInfo.Remark,
  4465. Files = translatorInfo.Files,
  4466. LastUpdateTime = translatorInfo.LastUpdateTime,
  4467. LastUpdateUserId = translatorInfo.LastUpdateUserId,
  4468. });
  4469. if (upd)
  4470. {
  4471. #region 更新(公务信息关联翻译人员) 关联信息
  4472. var officialDutyLinkTranslators_select = await _sqlSugar.Queryable<Grp_OfficialDutyLinkTranslator>()
  4473. .Where(x => x.IsDel == 0 && x.TranslatorId == dto.Id)
  4474. .ToListAsync();
  4475. //删除
  4476. var officialDutyLinkTranslatorIds = officialDutyLinkTranslators_select.Select(x => x.Id).ToList();
  4477. if (officialDutyLinkTranslatorIds.Count > 0)
  4478. {
  4479. await _sqlSugar.Updateable<Grp_OfficialDutyLinkTranslator>()
  4480. .SetColumnsIF(officialDutyLinkTranslatorIds.Count > 0, x => new Grp_OfficialDutyLinkTranslator()
  4481. {
  4482. DeleteUserId = currUserInfo.UserId,
  4483. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  4484. IsDel = 1,
  4485. Remark = $"翻译人员库-->删除"
  4486. })
  4487. .Where(x => officialDutyLinkTranslatorIds.Contains(x.Id))
  4488. .ExecuteCommandAsync();
  4489. }
  4490. if (dto.officialDutyIdItem != null && dto.officialDutyIdItem.Length > 0)
  4491. {
  4492. //添加
  4493. var officialDutyLinkTranslators = new List<Grp_OfficialDutyLinkTranslator>();
  4494. foreach (var officialDutyId in dto.officialDutyIdItem)
  4495. {
  4496. officialDutyLinkTranslators.Add(new Grp_OfficialDutyLinkTranslator()
  4497. {
  4498. TranslatorId = dto.Id,
  4499. OfficialDutyId = officialDutyId,
  4500. CreateUserId = currUserInfo.UserId,
  4501. Remark = $"翻译人员库-->更新"
  4502. });
  4503. }
  4504. if (officialDutyLinkTranslators.Count > 0)
  4505. {
  4506. await _sqlSugar.Insertable(officialDutyLinkTranslators).ExecuteCommandAsync();
  4507. }
  4508. }
  4509. #endregion
  4510. _sqlSugar.CommitTran();
  4511. return Ok(JsonView(true));
  4512. }
  4513. }
  4514. _sqlSugar.RollbackTran();
  4515. return Ok(JsonView(false));
  4516. }
  4517. /// <summary>
  4518. /// 翻译人员库
  4519. /// Del
  4520. /// </summary>
  4521. /// <param name="id"></param>
  4522. /// <returns></returns>
  4523. [HttpDelete("id")]
  4524. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4525. public async Task<IActionResult> TranslatorLibraryDel(int id)
  4526. {
  4527. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  4528. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  4529. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  4530. _sqlSugar.BeginTran();
  4531. var upd = await _translatorRep.SoftDeleteByIdAsync<Res_TranslatorLibrary>(id.ToString(), currUserInfo.UserId);
  4532. if (!upd)
  4533. {
  4534. _sqlSugar.RollbackTran();
  4535. return Ok(JsonView(false));
  4536. }
  4537. #region 删除公务出访
  4538. await _sqlSugar.Updateable<Grp_OfficialDutyLinkTranslator>()
  4539. .SetColumns(x => new Grp_OfficialDutyLinkTranslator()
  4540. {
  4541. DeleteUserId = currUserInfo.UserId,
  4542. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  4543. IsDel = 1,
  4544. Remark = $"翻译人员库-->删除"
  4545. })
  4546. .Where(x => x.TranslatorId == id)
  4547. .ExecuteCommandAsync();
  4548. #endregion
  4549. _sqlSugar.CommitTran();
  4550. return Ok(JsonView(true));
  4551. }
  4552. #endregion
  4553. #region 策划部供应商资料
  4554. /// <summary>
  4555. /// 策划部供应商资料
  4556. /// Init
  4557. /// </summary>
  4558. /// <returns></returns>
  4559. [HttpGet]
  4560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4561. public async Task<IActionResult> MediaSupplierInit()
  4562. {
  4563. return Ok(await _mediaSupplierRep.Init());
  4564. }
  4565. /// <summary>
  4566. /// 策划部供应商资料
  4567. /// Info
  4568. /// </summary>
  4569. /// <param name="dto"></param>
  4570. /// <returns></returns>
  4571. [HttpPost]
  4572. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4573. public async Task<IActionResult> MediaSupplierInfo(MediaSupplierInfoDto dto)
  4574. {
  4575. if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  4576. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Port));
  4577. return Ok(await _mediaSupplierRep.Info(dto));
  4578. }
  4579. /// <summary>
  4580. /// 策划部供应商资料
  4581. /// 分页查询
  4582. /// </summary>
  4583. /// <param name="dto"></param>
  4584. /// <returns></returns>
  4585. [HttpPost]
  4586. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4587. public async Task<IActionResult> MediaSupplierPageItem(MediaSupplierPageItemDto dto)
  4588. {
  4589. if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  4590. return Ok(await _mediaSupplierRep.PageItem(dto));
  4591. }
  4592. /// <summary>
  4593. /// 策划部供应商资料
  4594. /// 操作(添加 Or 编辑)
  4595. /// </summary>
  4596. /// <param name="dto"></param>
  4597. /// <returns></returns>
  4598. [HttpPost]
  4599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4600. public async Task<IActionResult> MediaSupplierOp(MediaSupplierAddOrEditDto dto)
  4601. {
  4602. var userId = dto.CurrUserId;
  4603. if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  4604. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4605. return Ok(await _mediaSupplierRep.AddOrEdit(dto));
  4606. }
  4607. /// <summary>
  4608. /// 策划部供应商资料
  4609. /// 删除
  4610. /// </summary>
  4611. /// <param name="dto"></param>
  4612. /// <returns></returns>
  4613. [HttpPost]
  4614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4615. public async Task<IActionResult> MediaSupplierSoftDel(MediaSupplierSoftDelDto dto)
  4616. {
  4617. int userId = dto.CurrUserId, id = dto.Id;
  4618. if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  4619. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4620. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  4621. return Ok(await _mediaSupplierRep.SoftDel(dto));
  4622. }
  4623. #endregion
  4624. #region 保险国家基础费用
  4625. /// <summary>
  4626. /// 保险国家基础费用
  4627. /// Info
  4628. /// </summary>
  4629. /// <param name="dto"></param>
  4630. /// <returns></returns>
  4631. [HttpPost]
  4632. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4633. public async Task<IActionResult> InsuranceCostInfo(InsuranceCostInfoDto dto)
  4634. {
  4635. if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  4636. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Port));
  4637. var id = dto.Id;
  4638. var info = await _sqlSugar.Queryable<Res_BasicInsuranceCost>()
  4639. .Where(x => x.Id == id && x.IsDel == 0)
  4640. .Select(x => new
  4641. {
  4642. x.Id,
  4643. x.IsSchengen,
  4644. x.CountryName,
  4645. x.Cost,
  4646. x.Remark,
  4647. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(s => s.Id == x.CreateUserId).Select(s => s.CnName),
  4648. x.CreateTime
  4649. })
  4650. .FirstAsync();
  4651. return Ok(JsonView(info));
  4652. }
  4653. /// <summary>
  4654. /// 保险国家基础费用
  4655. /// 分页查询
  4656. /// </summary>
  4657. /// <param name="dto"></param>
  4658. /// <returns></returns>
  4659. [HttpPost]
  4660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4661. public async Task<IActionResult> InsuranceCostPageItem(InsuranceCostPageItemDto dto)
  4662. {
  4663. if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  4664. RefAsync<int> total = 0;
  4665. var data = await _sqlSugar.Queryable<Res_BasicInsuranceCost>()
  4666. .LeftJoin<Sys_Users>((bic, u) => bic.CreateUserId == u.Id)
  4667. .Where((bic, u) => bic.IsDel == 0)
  4668. .WhereIF(!string.IsNullOrEmpty(dto.Search), (bic, u) => bic.CountryName.Contains(dto.Search))
  4669. .OrderByDescending((bic, u) => bic.Id)
  4670. .Select((bic, u) => new
  4671. {
  4672. bic.Id,
  4673. bic.IsSchengen,
  4674. bic.CountryName,
  4675. bic.Cost,
  4676. bic.Remark,
  4677. CreateUserName = u.CnName,
  4678. bic.CreateTime
  4679. })
  4680. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  4681. return Ok(JsonView(data, total));
  4682. }
  4683. /// <summary>
  4684. /// 保险国家基础费用
  4685. /// 操作(添加 Or 编辑)
  4686. /// </summary>
  4687. /// <param name="dto"></param>
  4688. /// <returns></returns>
  4689. [HttpPost]
  4690. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4691. public async Task<IActionResult> InsuranceCostOp(InsuranceCostOpDto dto)
  4692. {
  4693. var result = new JsonView() { Code = 400, Msg = "操作失败" };
  4694. var userId = dto.CurrUserId;
  4695. if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  4696. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4697. var countryName = dto.CountryName.Trim();
  4698. if (string.IsNullOrEmpty(countryName)) return Ok(JsonView(false, $"国家名称不能为空!"));
  4699. var info = _mapper.Map<Res_BasicInsuranceCost>(dto);
  4700. info.CreateUserId = dto.CurrUserId;
  4701. info.CountryName = countryName;
  4702. if (dto.Id < 1) //添加
  4703. {
  4704. var addInfo = await _insuranceCostRep.Query(x => x.CountryName.Equals(countryName)).FirstAsync();
  4705. if (addInfo != null) return Ok(JsonView(false, $"该国家信息已存在,不可添加!"));
  4706. var add = await _insuranceCostRep.AddAsync(info);
  4707. if (add < 1) return Ok(JsonView(false, "添加失败!"));
  4708. }
  4709. else //修改
  4710. {
  4711. var upd = await _insuranceCostRep.UpdateAsync(x => x.Id == dto.Id, x => new Res_BasicInsuranceCost
  4712. {
  4713. IsSchengen = dto.IsSchengen,
  4714. CountryName = dto.CountryName,
  4715. Cost = dto.Cost,
  4716. Remark = dto.Remark
  4717. });
  4718. if (!upd) return Ok(JsonView(false, "修改失败!"));
  4719. }
  4720. return Ok(JsonView(true));
  4721. }
  4722. /// <summary>
  4723. /// 保险国家基础费用
  4724. /// 删除
  4725. /// </summary>
  4726. /// <param name="dto"></param>
  4727. /// <returns></returns>
  4728. [HttpPost]
  4729. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4730. public async Task<IActionResult> InsuranceCostSoftDel(InsuranceCostSoftDelDto dto)
  4731. {
  4732. int userId = dto.CurrUserId, id = dto.Id;
  4733. if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  4734. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4735. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  4736. var del = await _insuranceCostRep.SoftDeleteAsync(x => x.Id == id, userId);
  4737. if (!del) return Ok(JsonView(false));
  4738. return Ok(JsonView(true));
  4739. }
  4740. #endregion
  4741. #region 世运会成本预算明细
  4742. /// <summary>
  4743. /// 世运会成本预算明细
  4744. /// Info
  4745. /// </summary>
  4746. /// <param name="id"></param>
  4747. /// <returns></returns>
  4748. [HttpGet("{id}")]
  4749. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4750. public async Task<IActionResult> GamesBudgetMasterInfo([Required(ErrorMessage = "数据编号不能为空!")] int id)
  4751. {
  4752. return Ok(await _gamesBudgetMasterRep.InfoAsync(id));
  4753. }
  4754. /// <summary>
  4755. /// 世运会成本预算明细
  4756. /// List
  4757. /// </summary>
  4758. /// <param name="dto"></param>
  4759. /// <returns></returns>
  4760. [HttpPost]
  4761. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4762. public async Task<IActionResult> GamesBudgetMasterList(GamesBudgetMasterListDto dto)
  4763. {
  4764. return Ok(await _gamesBudgetMasterRep.ListAsync(dto));
  4765. }
  4766. /// <summary>
  4767. /// 世运会成本预算明细
  4768. /// OP(Add/Edit)
  4769. /// </summary>
  4770. /// <param name="dto"></param>
  4771. /// <returns></returns>
  4772. [HttpPost]
  4773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4774. public async Task<IActionResult> GamesBudgetMasterOP(GamesBudgetMasterOPDto dto)
  4775. {
  4776. if (dto.Id > 0)
  4777. {
  4778. //修改
  4779. var editDto = _mapper.Map<GamesBudgetMasterEditDto>(dto);
  4780. return Ok(await _gamesBudgetMasterRep.EditAsync(editDto));
  4781. }
  4782. else if (dto.Id < 1)
  4783. {
  4784. //添加
  4785. var addDto = _mapper.Map<GamesBudgetMasterAddDto>(dto);
  4786. return Ok(await _gamesBudgetMasterRep.AddAsync(addDto));
  4787. }
  4788. return Ok(JsonView(false));
  4789. }
  4790. /// <summary>
  4791. /// 世运会成本预算明细
  4792. /// 删除
  4793. /// </summary>
  4794. /// <param name="dto"></param>
  4795. /// <returns></returns>
  4796. [HttpPost]
  4797. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4798. public async Task<IActionResult> GamesBudgetMasterDel(GamesBudgetMasterDelDto dto)
  4799. {
  4800. return Ok(await _gamesBudgetMasterRep.DelAsync(dto));
  4801. }
  4802. #endregion
  4803. #region 境外用车
  4804. /// <summary>
  4805. /// 境外用车
  4806. /// Init
  4807. /// </summary>
  4808. /// <returns></returns>
  4809. [HttpGet()]
  4810. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4811. public async Task<IActionResult> OverseaVehicleInitAsync()
  4812. {
  4813. return Ok(await _overseaVehicleRep.InitAsync());
  4814. }
  4815. /// <summary>
  4816. /// 境外用车
  4817. /// Info
  4818. /// </summary>
  4819. /// <param name="id"></param>
  4820. /// <returns></returns>
  4821. [HttpGet("{id}")]
  4822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4823. public async Task<IActionResult> OverseaVehicleInfoAsync([Required(ErrorMessage = "数据编号不能为空!")] int id)
  4824. {
  4825. return Ok(await _overseaVehicleRep.InfoAsync(id));
  4826. }
  4827. /// <summary>
  4828. /// 境外用车
  4829. /// List
  4830. /// </summary>
  4831. /// <param name="dto"></param>
  4832. /// <returns></returns>
  4833. [HttpPost]
  4834. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4835. public async Task<IActionResult> OverseaVehicleListAsync(OverseaVehicleListDto dto)
  4836. {
  4837. return Ok(await _overseaVehicleRep.ListAsync(dto));
  4838. }
  4839. /// <summary>
  4840. /// 境外用车
  4841. /// OP(Add/Edit)
  4842. /// </summary>
  4843. /// <param name="dto"></param>
  4844. /// <returns></returns>
  4845. [HttpPost]
  4846. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4847. public async Task<IActionResult> OverseaVehicleAddOrEditAsync(OverseaVehicleAddOrEditDto dto)
  4848. {
  4849. if (dto.Id > 0)
  4850. {
  4851. //修改
  4852. return Ok(await _overseaVehicleRep.EditAsync(dto));
  4853. }
  4854. else if (dto.Id < 1)
  4855. {
  4856. //添加
  4857. return Ok(await _overseaVehicleRep.AddAsync(dto));
  4858. }
  4859. return Ok(JsonView(false));
  4860. }
  4861. /// <summary>
  4862. /// 境外用车
  4863. /// 删除
  4864. /// </summary>
  4865. /// <param name="dto"></param>
  4866. /// <returns></returns>
  4867. [HttpPost]
  4868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4869. public async Task<IActionResult> OverseaVehicleDelAsync(OverseaVehicleDelDto dto)
  4870. {
  4871. return Ok(await _overseaVehicleRep.DelAsync(dto));
  4872. }
  4873. #endregion
  4874. #region 物料成本
  4875. /// <summary>
  4876. /// 物料成本列表查询
  4877. /// </summary>
  4878. /// <param name="dto"></param>
  4879. /// <returns></returns>
  4880. [HttpPost]
  4881. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4882. public async Task<IActionResult> MaterialCostList(QueryMaterialCostDto dto)
  4883. {
  4884. var data = await _materialCostRep.GetListAsync(dto);
  4885. return Ok(JsonView(true, "查询成功", data));
  4886. }
  4887. /// <summary>
  4888. /// 物料成本详情
  4889. /// </summary>
  4890. /// <param name="id"></param>
  4891. /// <returns></returns>
  4892. [HttpGet]
  4893. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4894. public async Task<IActionResult> MaterialCostInfo(int id)
  4895. {
  4896. var data = await _materialCostRep.GetDetailAsync(id);
  4897. return Ok(JsonView(true, "查询成功", data));
  4898. }
  4899. /// <summary>
  4900. /// 物料成本添加/修改
  4901. /// </summary>
  4902. /// <param name="dto"></param>
  4903. /// <returns></returns>
  4904. [HttpPost]
  4905. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4906. public async Task<IActionResult> MaterialCostAddOrEdit(UpMaterialCostDto dto)
  4907. {
  4908. if (dto.Id > 0)
  4909. {
  4910. // 修改
  4911. var entity = _mapper.Map<Res_MaterialCost>(dto);
  4912. var result = await _materialCostRep.UpdateAsync(s => s.Id == dto.Id, it => new Res_MaterialCost()
  4913. {
  4914. TypeId = entity.TypeId,
  4915. Name = entity.Name,
  4916. Price = entity.Price,
  4917. Number = entity.Number,
  4918. Unit = entity.Unit,
  4919. SetDataId = entity.SetDataId,
  4920. CityId = entity.CityId,
  4921. Remark = entity.Remark
  4922. });
  4923. return Ok(JsonView(result, result ? "修改成功" : "修改失败"));
  4924. }
  4925. else
  4926. {
  4927. // 添加
  4928. var entity = _mapper.Map<Res_MaterialCost>(dto);
  4929. entity.CreateTime = DateTime.Now;
  4930. var result = await _materialCostRep.AddAsync(entity);
  4931. return Ok(JsonView(result > 0, result > 0 ? "添加成功" : "添加失败"));
  4932. }
  4933. }
  4934. /// <summary>
  4935. /// 物料成本删除
  4936. /// </summary>
  4937. /// <param name="dto"></param>
  4938. /// <returns></returns>
  4939. [HttpPost]
  4940. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4941. public async Task<IActionResult> MaterialCostDel(DelBaseDto dto)
  4942. {
  4943. var result = await _materialCostRep.SoftDeleteAsync(dto.Id.ToString());
  4944. return Ok(JsonView(result, result ? "删除成功" : "删除失败"));
  4945. }
  4946. #endregion
  4947. }
  4948. }