ResourceController.cs 173 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using EyeSoft.Extensions;
  4. using EyeSoft.Reflection;
  5. using NPOI.SS.Formula.Functions;
  6. using OASystem.API.OAMethodLib;
  7. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  8. using OASystem.Domain.AesEncryption;
  9. using OASystem.Domain.Dtos.CRM;
  10. using OASystem.Domain.Dtos.Groups;
  11. using OASystem.Domain.Dtos.PersonnelModule;
  12. using OASystem.Domain.Entities.Groups;
  13. using OASystem.Domain.ViewModels.Groups;
  14. using OASystem.Domain.ViewModels.JuHeExchangeRate;
  15. using OASystem.Domain.ViewModels.QiYeWeChat;
  16. using OASystem.Infrastructure.Repositories.Groups;
  17. using Org.BouncyCastle.Utilities.Encoders;
  18. using System.Data;
  19. using static OASystem.API.OAMethodLib.JWTHelper;
  20. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  21. namespace OASystem.API.Controllers
  22. {
  23. /// <summary>
  24. /// 资料相关
  25. /// </summary>
  26. //[Authorize]
  27. [Route("api/[controller]/[action]")]
  28. public class ResourceController : ControllerBase
  29. {
  30. private readonly IMapper _mapper;
  31. private readonly SqlSugarClient _sqlSugar;
  32. private readonly IConfiguration _config;
  33. private readonly CarDataRepository _carDataRep;
  34. private readonly LocalGuideDataRepository _localGuideDataRep;
  35. private readonly ThreeCodeRepository _ThreeCodeRep;
  36. private readonly HotelDataRepository _hotelDataRep;
  37. private readonly ResItemInfoRepository _resItemInfoRep;
  38. private readonly SetDataRepository _setDataRepository;
  39. private readonly CountryFeeRepository _countryFeeRep;
  40. private readonly SetDataTypeRepository _setDataTypeRep;
  41. private readonly AirTicketAgentRepository _airTicketAgentRep;
  42. private readonly InvitationOfficialActivityDataRepository _InvitationOfficialActivityDataRep;
  43. private readonly OfficialActivitiesRepository _officialActivitiesRep;
  44. private readonly AskDataRepository _askDataRep;
  45. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  46. private readonly TourClientListRepository _tourClientListRep;
  47. private readonly DelegationInfoRepository _delegationInfoRep;
  48. private readonly TranslatorLibraryRepository _translatorRep;
  49. private readonly MediaSuppliersRepository _mediaSupplierRep;
  50. private readonly List<int> _portIds;
  51. private readonly BasicInsuranceCostRepository _insuranceCostRep;
  52. public ResourceController(
  53. IMapper mapper,
  54. IConfiguration config,
  55. SqlSugarClient sqlSugar,
  56. CarDataRepository carDataRep,
  57. LocalGuideDataRepository localGuideDataRep,
  58. ThreeCodeRepository threeCodeRep,
  59. HotelDataRepository hotelDataRep,
  60. ResItemInfoRepository resItemInfoRep,
  61. SetDataRepository setDataRepository,
  62. CountryFeeRepository countryFeeRep,
  63. SetDataTypeRepository setDataTypeRep,
  64. AirTicketAgentRepository airTicketAgentRep,
  65. InvitationOfficialActivityDataRepository invitationOfficialActivityDataRep,
  66. OfficialActivitiesRepository officialActivitiesRep,
  67. AskDataRepository askDataRep,
  68. TicketBlackCodeRepository ticketBlackCodeRep,
  69. TourClientListRepository tourClientListRep,
  70. DelegationInfoRepository delegationInfoRep,
  71. TranslatorLibraryRepository translatorRep,
  72. MediaSuppliersRepository mediaSupplierRep,
  73. BasicInsuranceCostRepository insuranceCostRep
  74. )
  75. {
  76. _mapper = mapper;
  77. _config = config;
  78. _sqlSugar = sqlSugar;
  79. _carDataRep = carDataRep;
  80. _localGuideDataRep = localGuideDataRep;
  81. _ThreeCodeRep = threeCodeRep;
  82. _hotelDataRep = hotelDataRep;
  83. _resItemInfoRep = resItemInfoRep;
  84. _setDataRepository = setDataRepository;
  85. _countryFeeRep = countryFeeRep;
  86. _setDataTypeRep = setDataTypeRep;
  87. _airTicketAgentRep = airTicketAgentRep;
  88. _InvitationOfficialActivityDataRep = invitationOfficialActivityDataRep;
  89. _officialActivitiesRep = officialActivitiesRep;
  90. _askDataRep = askDataRep;
  91. _ticketBlackCodeRep = ticketBlackCodeRep;
  92. _tourClientListRep = tourClientListRep;
  93. _delegationInfoRep = delegationInfoRep;
  94. _translatorRep = translatorRep;
  95. _mediaSupplierRep = mediaSupplierRep;
  96. _portIds = new List<int> { 1, 2, 3 };
  97. _insuranceCostRep = insuranceCostRep;
  98. }
  99. #region 车公司资料板块
  100. /// <summary>
  101. /// 车公司信息查询
  102. /// </summary>
  103. /// <returns></returns>
  104. [HttpPost]
  105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  106. public async Task<IActionResult> QueryCarData(QueryCarDataDto dto)
  107. {
  108. Result LocalGuide = await _carDataRep.QueryCarData(dto);
  109. if (LocalGuide.Code == 0)
  110. {
  111. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  112. }
  113. else
  114. {
  115. return Ok(JsonView(false, LocalGuide.Msg));
  116. }
  117. }
  118. /// <summary>
  119. /// 车公司资料下拉框数据
  120. /// </summary>
  121. /// <returns></returns>
  122. [HttpPost]
  123. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  124. public async Task<IActionResult> QueryCarSelect()
  125. {
  126. var carData = _carDataRep.QueryDto<Res_CarData, CarDataSelectView>().ToList();
  127. if (carData.Count == 0)
  128. {
  129. return Ok(JsonView(false, "暂无数据!"));
  130. }
  131. foreach (var item in carData) EncryptionProcessor.DecryptProperties(item);
  132. carData.Add(new CarDataSelectView { Id = 0, UnitArea = "全部" });
  133. carData = carData.Where((x, i) => carData.FindIndex(z => z.UnitArea == x.UnitArea) == i).ToList();
  134. carData = carData.OrderBy(x => x.Id).ToList();
  135. var data = new List<CarDataSelectView>();
  136. foreach (CarDataSelectView car in carData)
  137. {
  138. if (!string.IsNullOrWhiteSpace(car.UnitArea))
  139. {
  140. data.Add(car);
  141. }
  142. }
  143. return Ok(JsonView(true, "查询成功", data));
  144. }
  145. /// <summary>
  146. /// 根据Id查询车公司详细数据
  147. /// </summary>
  148. /// <returns></returns>
  149. [HttpPost]
  150. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  151. public async Task<IActionResult> QuerCarDataDetailById(QueryCarDataDetailDto dto)
  152. {
  153. string sql = string.Format(@" Select * From Res_CarData With(Nolock) Where Id = {0} ", dto.Id);
  154. var info = _resItemInfoRep._sqlSugar.SqlQueryable<CarDataDetailDataView>(sql).First();
  155. if (info == null)
  156. {
  157. return Ok(JsonView(false, "未找到相关数据!"));
  158. }
  159. EncryptionProcessor.DecryptProperties(info);
  160. return Ok(JsonView(true, "查询成功", info));
  161. }
  162. /// <summary>
  163. /// 车公司信息添加
  164. /// </summary>
  165. /// <returns></returns>
  166. [HttpPost]
  167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  168. public async Task<IActionResult> AddCarData(AddCarDataDto dto)
  169. {
  170. if (string.IsNullOrEmpty(dto.UnitArea)) return Ok(JsonView(false, "请检查单位区域是否填写!"));
  171. if (string.IsNullOrEmpty(dto.UnitName)) return Ok(JsonView(false, "请检查单位名称是否填写!"));
  172. if (string.IsNullOrEmpty(dto.Contact)) return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  173. if (string.IsNullOrEmpty(dto.ContactTel)) return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  174. var carDadaInfo = _carDataRep
  175. .QueryDto<Res_CarData, CarDataView>(a => a.UnitArea == dto.UnitArea &&
  176. a.UnitName == dto.UnitName &&
  177. a.Contact == dto.Contact &&
  178. a.ContactTel == dto.ContactTel
  179. )
  180. .First();
  181. if (carDadaInfo != null) return Ok(JsonView(false, "该信息已存在,请勿重复添加!"));
  182. var carData = _mapper.Map<Res_CarData>(dto);
  183. EncryptionProcessor.EncryptProperties(carData);
  184. int id = await _carDataRep.AddAsyncReturnId(carData);
  185. if (id < 1) return Ok(JsonView(false, "添加失败!"));
  186. return Ok(JsonView(true, "添加成功", new { Id = id }));
  187. }
  188. /// <summary>
  189. /// 车公司信息修改
  190. /// </summary>
  191. /// <returns></returns>
  192. [HttpPost]
  193. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  194. public async Task<IActionResult> UpCarData(UpCarDataDto 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 carData = _mapper.Map<Res_CarData>(dto);
  201. EncryptionProcessor.EncryptProperties(carData);
  202. var res = await _sqlSugar.Updateable(carData)
  203. .IgnoreColumns(x => new { x.CreateUserId, x.CreateTime, x.DeleteTime, x.DeleteUserId, x.IsDel })
  204. .ExecuteCommandAsync();
  205. if (res < 1) { return Ok(JsonView(false, "修改失败!")); }
  206. return Ok(JsonView(true, "修改成功"));
  207. }
  208. /// <summary>
  209. /// 车公司信息删除
  210. /// </summary>
  211. /// <returns></returns>
  212. [HttpPost]
  213. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  214. public async Task<IActionResult> DelCarData(DelCarDataDto dto)
  215. {
  216. bool res = await _carDataRep.SoftDeleteByIdAsync<Res_CarData>(dto.Id.ToString(), dto.DeleteUserId);
  217. if (!res) { return Ok(JsonView(false, "删除失败!")); }
  218. return Ok(JsonView(true, "删除成功"));
  219. }
  220. #endregion
  221. #region 导游地接资料板块
  222. [HttpPost]
  223. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  224. public async Task<IActionResult> LocalGuideBatchEncryption()
  225. {
  226. var infos = await _sqlSugar.Queryable<Res_LocalGuideData>().ToListAsync();
  227. foreach (var item in infos) EncryptionProcessor.EncryptProperties(item);
  228. var updTotal = await _sqlSugar.Updateable(infos).ExecuteCommandAsync();
  229. return Ok(JsonView(true));
  230. }
  231. /// <summary>
  232. /// 导游地接资料查询
  233. /// </summary>
  234. /// <param name="dto"></param>
  235. /// <returns></returns>
  236. [HttpPost]
  237. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  238. public async Task<IActionResult> QueryLocalGuide(QueryLocalGuide dto)
  239. {
  240. Result LocalGuide = await _localGuideDataRep.QueryLocalGuide(dto);
  241. if (LocalGuide.Code == 0)
  242. {
  243. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  244. }
  245. return Ok(JsonView(false, LocalGuide.Msg));
  246. }
  247. /// <summary>
  248. /// 导游地接资料下拉框数据
  249. /// </summary>
  250. /// <returns></returns>
  251. [HttpPost]
  252. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  253. public async Task<IActionResult> QueryLocalGuideSelect()
  254. {
  255. var localGuides = _carDataRep.QueryDto<Res_LocalGuideData, QueryLocalGuideSelectView>().ToList();
  256. if (localGuides.Count == 0)
  257. {
  258. return Ok(JsonView(false, "暂无数据!"));
  259. }
  260. foreach (var item in localGuides) EncryptionProcessor.DecryptProperties(item);
  261. localGuides.Add(new QueryLocalGuideSelectView { Id = 0, UnitArea = "全部" });
  262. localGuides = localGuides.Where((x, i) => localGuides.FindIndex(z => z.UnitArea == x.UnitArea && !string.IsNullOrEmpty(z.UnitArea)) == i).ToList();
  263. localGuides = localGuides.OrderBy(x => x.Id).ToList();
  264. var data = new List<QueryLocalGuideSelectView>();
  265. foreach (QueryLocalGuideSelectView Local in localGuides)
  266. {
  267. if (!string.IsNullOrWhiteSpace(Local.UnitArea))
  268. {
  269. data.Add(Local);
  270. }
  271. }
  272. return Ok(JsonView(true, "查询成功", data));
  273. }
  274. /// <summary>
  275. /// 根据Id查询地接详细数据
  276. /// </summary>
  277. /// <returns></returns>
  278. [HttpPost]
  279. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  280. public async Task<IActionResult> QueryLocalGuideDetailById(QueryLocalGuideDetailDto dto)
  281. {
  282. string sql = string.Format(@" Select * From Res_LocalGuideData With(Nolock) Where Id = {0} ", dto.Id);
  283. var info = _resItemInfoRep._sqlSugar.SqlQueryable<LocalGuideDetailDataView>(sql).First();
  284. if (info == null)
  285. {
  286. return Ok(JsonView(false, "未找到相关数据!"));
  287. }
  288. EncryptionProcessor.DecryptProperties(info);
  289. return Ok(JsonView(true, "查询成功", info));
  290. }
  291. /// <summary>
  292. /// 导游地接信息操作(Status:1.新增,2.修改)
  293. /// </summary>
  294. /// <returns></returns>
  295. [HttpPost]
  296. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  297. public async Task<IActionResult> OperationLocalGuide(LocalGuideOperationDto dto)
  298. {
  299. if (string.IsNullOrEmpty(dto.UnitArea)) return Ok(JsonView(false, "请检查单位区域是否填写!"));
  300. if (string.IsNullOrEmpty(dto.UnitName)) return Ok(JsonView(false, "请检查单位名称是否填写!"));
  301. if (string.IsNullOrEmpty(dto.Contact)) return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  302. if (string.IsNullOrEmpty(dto.ContactTel)) return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  303. Result result = await _localGuideDataRep.LocalGuideOperation(dto);
  304. if (result.Code != 0)
  305. {
  306. return Ok(JsonView(false, result.Msg));
  307. }
  308. return Ok(JsonView(true, result.Msg));
  309. }
  310. /// <summary>
  311. /// 导游地接信息操作(删除)
  312. /// </summary>
  313. /// <returns></returns>
  314. [HttpPost]
  315. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  316. public async Task<IActionResult> DelLocalGuide(LocalGuideDelDto dto)
  317. {
  318. var res = await _localGuideDataRep.SoftDeleteByIdAsync<Res_LocalGuideData>(dto.Id.ToString(), dto.DeleteUserId);
  319. if (!res)
  320. {
  321. return Ok(JsonView(false, "删除失败"));
  322. }
  323. return Ok(JsonView(true, "删除成功!"));
  324. }
  325. #endregion
  326. #region 机场三字码信息
  327. /// <summary>
  328. /// 机场三字码查询
  329. /// </summary>
  330. /// <param name="dto"></param>
  331. /// <returns></returns>
  332. [HttpPost]
  333. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  334. public async Task<IActionResult> QueryThreeCode(QueryThreeCodeDto dto)
  335. {
  336. try
  337. {
  338. Result LocalGuide = await _ThreeCodeRep.QueryThreeCode(dto);
  339. if (LocalGuide.Code == 0)
  340. {
  341. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  342. }
  343. else
  344. {
  345. return Ok(JsonView(false, LocalGuide.Msg));
  346. }
  347. }
  348. catch (Exception ex)
  349. {
  350. return Ok(JsonView(false, "程序错误!"));
  351. throw;
  352. }
  353. }
  354. /// <summary>
  355. /// 机场三字码数据城市下拉框数据
  356. /// </summary>
  357. /// <returns></returns>
  358. [HttpPost]
  359. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  360. public async Task<IActionResult> QueryThreeCodeSelect()
  361. {
  362. try
  363. {
  364. var ThreeCode = _carDataRep.QueryDto<Res_ThreeCode, ThreeCodeSelectView>().ToList();
  365. if (ThreeCode.Count == 0)
  366. {
  367. return Ok(JsonView(false, "暂无数据!"));
  368. }
  369. ThreeCode.Add(new ThreeCodeSelectView { Id = 0, City = "全部" });
  370. ThreeCode = ThreeCode.Where((x, i) => ThreeCode.FindIndex(z => z.City == x.City && z.City != "") == i).ToList();
  371. ThreeCode = ThreeCode.OrderBy(x => x.Id).ToList();
  372. List<ThreeCodeSelectView> data = new List<ThreeCodeSelectView>();
  373. foreach (ThreeCodeSelectView _ThreeCode in ThreeCode)
  374. {
  375. if (!string.IsNullOrWhiteSpace(_ThreeCode.City))
  376. {
  377. data.Add(_ThreeCode);
  378. }
  379. }
  380. return Ok(JsonView(true, "查询成功", data));
  381. }
  382. catch (Exception)
  383. {
  384. return Ok(JsonView(false, "程序错误!"));
  385. throw;
  386. }
  387. }
  388. /// <summary>
  389. /// 机场三字码资料操作(Status:1.新增,2.修改)
  390. /// </summary>
  391. /// <param name="dto"></param>
  392. /// <returns></returns>
  393. [HttpPost]
  394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  395. public async Task<IActionResult> OperationThreeCode(ThreeCodeOperationDto dto)
  396. {
  397. try
  398. {
  399. if (dto.Three == "")
  400. {
  401. return Ok(JsonView(false, "请检查三字码是否填写!"));
  402. }
  403. if (dto.Country == "")
  404. {
  405. return Ok(JsonView(false, "请检查国家是否填写!"));
  406. }
  407. if (dto.City == "")
  408. {
  409. return Ok(JsonView(false, "请检查城市是否填写正确!"));
  410. }
  411. if (dto.AirPort == "")
  412. {
  413. return Ok(JsonView(false, "请检查机场是否填写正确!"));
  414. }
  415. Result result = await _ThreeCodeRep.ThreeCodeOperation(dto);
  416. if (result.Code != 0)
  417. {
  418. return Ok(JsonView(false, result.Msg));
  419. }
  420. return Ok(JsonView(true, result.Msg));
  421. }
  422. catch (Exception ex)
  423. {
  424. return Ok(JsonView(false, "程序错误!"));
  425. throw;
  426. }
  427. }
  428. /// <summary>
  429. /// 机场三字码资料操作(删除)
  430. /// </summary>
  431. /// <returns></returns>
  432. [HttpPost]
  433. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  434. public async Task<IActionResult> DelThreeCode(ThreeCodeDelDto dto)
  435. {
  436. try
  437. {
  438. var res = await _ThreeCodeRep.SoftDeleteByIdAsync<Res_ThreeCode>(dto.Id.ToString(), dto.DeleteUserId);
  439. if (!res)
  440. {
  441. return Ok(JsonView(false, "删除失败"));
  442. }
  443. return Ok(JsonView(true, "删除成功!"));
  444. }
  445. catch (Exception ex)
  446. {
  447. return Ok(JsonView(false, "程序错误!"));
  448. throw;
  449. }
  450. }
  451. /// <summary>
  452. ///根据ID查询三字码信息
  453. /// </summary>
  454. /// <returns></returns>
  455. [HttpPost]
  456. public IActionResult QuerySingleThreeCode(QuerySingleThreeCode dto)
  457. {
  458. var jw = JsonView(false);
  459. var single = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Id == dto.ID && x.IsDel == 0);
  460. if (single != null)
  461. {
  462. jw = JsonView(true, "获取成功!", new
  463. {
  464. single.Three,
  465. Four = single.Four?.Trim(),
  466. single.AirPort,
  467. single.AirPort_En,
  468. single.City,
  469. single.Country,
  470. single.Remark
  471. });
  472. }
  473. else
  474. {
  475. jw.Msg = "暂无!";
  476. }
  477. return Ok(jw);
  478. }
  479. #endregion
  480. #region 代理出票合作方资料
  481. /// <summary>
  482. /// 代理出票合作方资料
  483. /// </summary>
  484. /// <param name="dto"></param>
  485. /// <returns></returns>
  486. [HttpPost]
  487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  488. public async Task<IActionResult> QueryAirTicketAgent(DtoBase dto)
  489. {
  490. var res_AirTicketAgents = _airTicketAgentRep.Query<Res_AirTicketAgent>(a => a.IsDel == 0).ToList();
  491. if (res_AirTicketAgents.Count > 1)
  492. {
  493. res_AirTicketAgents = res_AirTicketAgents.OrderByDescending(a => a.CreateTime).ToList();
  494. if (dto.PageSize == 0 && dto.PageIndex == 0)
  495. {
  496. foreach (var item in res_AirTicketAgents) EncryptionProcessor.DecryptProperties(item);
  497. return Ok(JsonView(true, "查询成功!", res_AirTicketAgents));
  498. }
  499. else
  500. {
  501. int count = res_AirTicketAgents.Count;
  502. float totalPage = (float)count / dto.PageSize;//总页数
  503. if (totalPage == 0) totalPage = 1;
  504. else totalPage = (int)Math.Ceiling((double)totalPage);
  505. var _AirTicketAgent = new List<Res_AirTicketAgent>();
  506. for (int i = 0; i < dto.PageSize; i++)
  507. {
  508. var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
  509. if (RowIndex < res_AirTicketAgents.Count)
  510. {
  511. EncryptionProcessor.DecryptProperties(res_AirTicketAgents[RowIndex]);
  512. _AirTicketAgent.Add(res_AirTicketAgents[RowIndex]);
  513. }
  514. else break;
  515. }
  516. return Ok(JsonView(true, "查询成功!", new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = _AirTicketAgent }));
  517. }
  518. }
  519. return Ok(JsonView(false, "暂无数据!"));
  520. }
  521. /// <summary>
  522. /// 代理出票合作方资料操作(Status:1.新增,2.修改)
  523. /// </summary>
  524. /// <param name="dto"></param>
  525. /// <returns></returns>
  526. [HttpPost]
  527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  528. public async Task<IActionResult> OpAirTicketAgent(OpAirTicketAgentDto dto)
  529. {
  530. if (string.IsNullOrEmpty(dto.Account)) return Ok(JsonView(false, "请检查代理商账户是否填写!"));
  531. if (string.IsNullOrEmpty(dto.Bank)) return Ok(JsonView(false, "请检查代理商银行是否填写!"));
  532. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "请检查代理商名称是否填写正确!"));
  533. Result result = await _airTicketAgentRep.OpAirTicketAgent(dto);
  534. if (result.Code != 0) return Ok(JsonView(false, result.Msg));
  535. return Ok(JsonView(true, result.Msg));
  536. }
  537. /// <summary>
  538. /// 代理出票合作方资料操作(删除)
  539. /// </summary>
  540. /// <returns></returns>
  541. [HttpPost]
  542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  543. public async Task<IActionResult> DelAirTicketAgent(DelBaseDto dto)
  544. {
  545. var res = await _airTicketAgentRep.SoftDeleteByIdAsync<Res_AirTicketAgent>(dto.Id.ToString(), dto.DeleteUserId);
  546. if (!res) return Ok(JsonView(false, "删除失败"));
  547. return Ok(JsonView(true, "删除成功!"));
  548. }
  549. #endregion
  550. #region 酒店资料数据
  551. /// <summary>
  552. /// 酒店信息查询 Page
  553. /// </summary>
  554. /// <param name="dto"></param>
  555. /// <returns></returns>
  556. [HttpPost]
  557. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  558. public async Task<IActionResult> QueryHotelData(QueryHotelDataDto dto)
  559. {
  560. string sqlWhere = string.Empty;
  561. if (!string.IsNullOrWhiteSpace(dto.Name))
  562. {
  563. sqlWhere += string.Format(@" And hd.Name like '%{0}%'", AesEncryptionHelper.Encrypt(dto.Name));
  564. }
  565. if (!string.IsNullOrWhiteSpace(dto.City) && dto.City != "全部")
  566. {
  567. sqlWhere += string.Format(@" And hd.City like '%{0}%'", AesEncryptionHelper.Encrypt(dto.City));
  568. }
  569. if (!string.IsNullOrWhiteSpace(dto.Contact))
  570. {
  571. sqlWhere += string.Format(@" And hd.Contact like '%{0}%'", AesEncryptionHelper.Encrypt(dto.Contact));
  572. }
  573. if (!string.IsNullOrWhiteSpace(dto.ContactPhone))
  574. {
  575. sqlWhere += string.Format(@" And hd.ContactPhone like '%{0}%'", AesEncryptionHelper.Encrypt(dto.ContactPhone));
  576. }
  577. sqlWhere += string.Format(@" And hd.IsDel={0}", 0);
  578. if (!string.IsNullOrEmpty(sqlWhere.Trim()))
  579. {
  580. Regex r = new Regex("And");
  581. sqlWhere = r.Replace(sqlWhere, "Where", 1);
  582. }
  583. string sql = string.Format(@"SELECT
  584. *
  585. FROM
  586. (
  587. SELECT
  588. ROW_NUMBER() OVER (
  589. ORDER BY
  590. hd.CreateTime DESC
  591. ) AS Row_Number,
  592. hd.Id,
  593. hd.City,
  594. hd.[Name],
  595. hd.Tel,
  596. hd.Fax,
  597. hd.Contact,
  598. hd.ContactPhone,
  599. u.CnName AS CreateUserName,
  600. hd.CreateTime
  601. FROM
  602. Res_HotelData hd
  603. WITH
  604. (NoLock)
  605. LEFT JOIN Sys_Users u
  606. WITH
  607. (NoLock) ON hd.CreateUserId = u.Id {0}
  608. ) Temp
  609. ", sqlWhere);
  610. if (dto.PortType == 1)
  611. {
  612. var HotelDataData = await _sqlSugar.SqlQueryable<HotelDataItemView>(sql).ToListAsync();
  613. if (HotelDataData.Count == 0)
  614. {
  615. return Ok(JsonView(false, "暂无数据"));
  616. }
  617. foreach (var item in HotelDataData)
  618. {
  619. EncryptionProcessor.DecryptProperties(item);
  620. }
  621. return Ok(JsonView(true, "操作成功", HotelDataData));
  622. }
  623. else if (dto.PortType == 2 || dto.PortType == 3)
  624. {
  625. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  626. var data = await _sqlSugar.SqlQueryable<HotelDataItemView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total); //ToPageAsync
  627. foreach (var item in data) EncryptionProcessor.DecryptProperties(item);
  628. return Ok(JsonView(true, "操作成功", data, total));
  629. }
  630. else return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
  631. }
  632. /// <summary>
  633. /// 酒店资料
  634. /// 详情
  635. /// add time:2024-05-14 11:57:10
  636. /// </summary>
  637. /// <returns></returns>
  638. [HttpPost]
  639. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  640. public async Task<IActionResult> QueryHotelDataInfo(QueryHotelDataInfoDto dto)
  641. {
  642. var _view = await _hotelDataRep._Info(dto.PortType, dto.Id);
  643. if (_view.Code == 0)
  644. {
  645. return Ok(JsonView(true, _view.Msg, _view.Data));
  646. }
  647. return Ok(JsonView(false, _view.Msg));
  648. }
  649. /// <summary>
  650. /// 酒店资料下拉框数据
  651. /// </summary>
  652. /// <returns></returns>
  653. [HttpPost]
  654. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  655. public async Task<IActionResult> QueryHotelDataSelect()
  656. {
  657. try
  658. {
  659. var HotelData = _carDataRep.QueryDto<Res_HotelData, QueryHotelDataSelect>().ToList();
  660. if (HotelData.Count == 0)
  661. {
  662. return Ok(JsonView(false, "暂无数据!"));
  663. }
  664. //解密
  665. foreach (var item in HotelData)
  666. {
  667. EncryptionProcessor.DecryptProperties(item);
  668. }
  669. HotelData.Add(new QueryHotelDataSelect { Id = 0, City = "全部" });
  670. HotelData = HotelData.Where((x, i) => HotelData.FindIndex(z => z.City == x.City && z.City != "") == i).ToList();
  671. HotelData = HotelData.OrderBy(x => x.Id).ToList();
  672. var data = new List<QueryHotelDataSelect>();
  673. foreach (var Hotel in HotelData)
  674. {
  675. if (!string.IsNullOrWhiteSpace(Hotel.City))
  676. {
  677. data.Add(Hotel);
  678. }
  679. }
  680. return Ok(JsonView(true, "查询成功", data));
  681. }
  682. catch (Exception)
  683. {
  684. return Ok(JsonView(false, "程序错误!"));
  685. throw;
  686. }
  687. }
  688. /// <summary>
  689. /// 酒店资料操作(Status:1.新增,2.修改)
  690. /// </summary>
  691. /// <param name="dto"></param>
  692. /// <returns></returns>
  693. [HttpPost]
  694. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  695. public async Task<IActionResult> OperationHotelData(OperationHotelDto dto)
  696. {
  697. if (string.IsNullOrEmpty(dto.City)) return Ok(JsonView(false, "请检查酒店所在城市是否填写!"));
  698. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "请检查酒店名称是否填写!"));
  699. if (string.IsNullOrEmpty(dto.Address)) return Ok(JsonView(false, "请检查酒店地址是否填写正确!"));
  700. if (string.IsNullOrEmpty(dto.Tel)) return Ok(JsonView(false, "请检查酒店联系方式是否填写正确!"));
  701. Result result = await _hotelDataRep.OperationHotelData(dto);
  702. if (result.Code != 0) return Ok(JsonView(false, result.Msg));
  703. return Ok(JsonView(true, result.Msg));
  704. }
  705. /// <summary>
  706. /// 酒店资料操作(删除)
  707. /// </summary>
  708. /// <returns></returns>
  709. [HttpPost]
  710. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  711. public async Task<IActionResult> DelHotelData(DelHotelDataDto dto)
  712. {
  713. try
  714. {
  715. var res = await _hotelDataRep.SoftDeleteByIdAsync<Res_HotelData>(dto.Id.ToString(), dto.DeleteUserId);
  716. if (!res)
  717. {
  718. return Ok(JsonView(false, "删除失败"));
  719. }
  720. return Ok(JsonView(true, "删除成功!"));
  721. }
  722. catch (Exception ex)
  723. {
  724. return Ok(JsonView(false, "程序错误!"));
  725. throw;
  726. }
  727. }
  728. #endregion
  729. #region 签证费用资料
  730. /// <summary>
  731. /// 签证费用资料查询
  732. /// </summary>
  733. /// <param name="dto"></param>
  734. /// <returns></returns>
  735. [HttpPost]
  736. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  737. public async Task<IActionResult> QueryCountryFeeCost(DtoBase dto)
  738. {
  739. if (dto.PortType == 1)
  740. {
  741. var CountryFee = _countryFeeRep.QueryDto<Res_CountryFeeCost, CountryFeeCostView>().ToList();
  742. if (CountryFee.Count == 0)
  743. {
  744. return Ok(JsonView(false, "暂无数据!"));
  745. }
  746. CountryFee = CountryFee.OrderByDescending(s => s.CreateTime).ToList();
  747. return Ok(JsonView(true, "查询成功", CountryFee));
  748. }
  749. else if (dto.PortType == 2)
  750. {
  751. var CountryFee = _countryFeeRep.QueryDto<Res_CountryFeeCost, CountryFeeCostView>().ToList();
  752. if (CountryFee.Count == 0)
  753. {
  754. return Ok(JsonView(false, "暂无数据!"));
  755. }
  756. CountryFee = CountryFee.OrderByDescending(s => s.CreateTime).ToList();
  757. return Ok(JsonView(true, "查询成功", CountryFee));
  758. }
  759. else
  760. {
  761. return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
  762. }
  763. }
  764. /// <summary>
  765. /// 签证费用资料操作(Status:1.新增,2.修改)
  766. /// </summary>
  767. /// <param name="dto"></param>
  768. /// <returns></returns>
  769. [HttpPost]
  770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  771. public async Task<IActionResult> OperationCountryFeeCost(OperationCountryFeeCostDto dto)
  772. {
  773. if (string.IsNullOrWhiteSpace(dto.VisaContinent))
  774. {
  775. return Ok(JsonView(false, "请检查州名是否填写!"));
  776. }
  777. if (string.IsNullOrWhiteSpace(dto.VisaCountry))
  778. {
  779. return Ok(JsonView(false, "请检查国家名是否填写!"));
  780. }
  781. if (string.IsNullOrWhiteSpace(dto.VisaTime))
  782. {
  783. return Ok(JsonView(false, "请检一般签证时间是否填写正确!"));
  784. }
  785. if (string.IsNullOrWhiteSpace(dto.UrgentTime))
  786. {
  787. return Ok(JsonView(false, "请检加急时间是否填写正确!"));
  788. }
  789. Result result = await _countryFeeRep.OperationCountryFeeCost(dto);
  790. if (result.Code == 0)
  791. {
  792. return Ok(JsonView(true, result.Msg));
  793. }
  794. return Ok(JsonView(false, result.Msg));
  795. }
  796. /// <summary>
  797. /// 签证费用资料操作(删除)
  798. /// </summary>
  799. /// <returns></returns>
  800. [HttpPost]
  801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  802. public async Task<IActionResult> DelCountryFeeCost(DelCountryFeeCostDto dto)
  803. {
  804. var res = await _countryFeeRep.SoftDeleteByIdAsync<Res_CountryFeeCost>(dto.Id.ToString(), dto.DeleteUserId);
  805. if (!res)
  806. {
  807. return Ok(JsonView(false, "删除失败"));
  808. }
  809. return Ok(JsonView(true, "删除成功!"));
  810. }
  811. #endregion
  812. #region 物料信息、供应商维护
  813. #region 供应商
  814. /// <summary>
  815. /// 物料供应商查询
  816. /// </summary>
  817. /// <param name="paras">Json序列化</param>
  818. /// <returns></returns>
  819. [HttpPost]
  820. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  821. public async Task<IActionResult> PostSearchItemVendor(JsonDtoBase _jsonDto)
  822. {
  823. if (string.IsNullOrEmpty(_jsonDto.Paras))
  824. {
  825. return Ok(JsonView(false, "参数为空"));
  826. }
  827. Search_ResItemVendorDto _ItemVendorDto = System.Text.Json.JsonSerializer.Deserialize<Search_ResItemVendorDto>(_jsonDto.Paras);
  828. if (_ItemVendorDto != null)
  829. {
  830. if (_ItemVendorDto.SearchType == 2) //获取列表
  831. {
  832. Res_ItemVendorListView rstList = _resItemInfoRep.GetVendorList(_ItemVendorDto);
  833. return Ok(rstList);
  834. }
  835. else
  836. {
  837. Res_ItemVendorView rstInfo = _resItemInfoRep.getVendorInfo(_ItemVendorDto);
  838. return Ok(rstInfo);
  839. }
  840. }
  841. else
  842. {
  843. return Ok(JsonView(false, "参数反序列化失败"));
  844. }
  845. return Ok(JsonView(false));
  846. }
  847. /// <summary>
  848. /// 创建/编辑/删除供应商信息
  849. /// </summary>
  850. /// <param name="_dto"></param>
  851. /// <returns></returns>
  852. [HttpPost]
  853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  854. public async Task<IActionResult> PostEditItemVendor(Edit_ResItemVendorDto _dto)
  855. {
  856. bool rst = false;
  857. if (_dto.EditType >= 0)
  858. {
  859. if (string.IsNullOrEmpty(_dto.VendorFullName))
  860. {
  861. return Ok(JsonView(false, "全称未填写"));
  862. }
  863. if (string.IsNullOrEmpty(_dto.VendorLinker))
  864. {
  865. return Ok(JsonView(false, "联系人未填写"));
  866. }
  867. if (string.IsNullOrEmpty(_dto.VendorMobile))
  868. {
  869. return Ok(JsonView(false, "联系人手机号未填写"));
  870. }
  871. if (string.IsNullOrEmpty(_dto.BusRange))
  872. {
  873. return Ok(JsonView(false, "经营范围未选择"));
  874. }
  875. if (_dto.EditType == 0)
  876. {
  877. var checkEmpty = _resItemInfoRep.Query<Res_ItemVendor>(s => s.FullName == _dto.VendorFullName).First();
  878. if (checkEmpty != null)
  879. {
  880. return Ok(JsonView(false, "已存在同名供应商"));
  881. }
  882. rst = await _resItemInfoRep.addVendorInfo(_dto);
  883. }
  884. else if (_dto.EditType == 1)
  885. {
  886. if (_dto.VendorId > 0)
  887. {
  888. Res_ItemVendor _entity = _mapper.Map<Res_ItemVendor>(_dto);
  889. rst = await _resItemInfoRep.updVendorInfo(_entity);
  890. }
  891. else
  892. {
  893. return Ok(JsonView(false, "供应商不存在"));
  894. }
  895. }
  896. }
  897. else
  898. {
  899. if (_dto.VendorId < 1 || _dto.SysUserId < 1)
  900. {
  901. return Ok(JsonView(false, "用户Id或供应商Id不存在"));
  902. }
  903. Res_ItemVendor _entity = _mapper.Map<Res_ItemVendor>(_dto);
  904. rst = await _resItemInfoRep.delVendorInfo(_entity);
  905. }
  906. return Ok(JsonView(rst));
  907. }
  908. #endregion
  909. #region 物料信息
  910. /// <summary>
  911. /// 物料信息查询
  912. /// </summary>
  913. /// <param name="paras">Json序列化</param>
  914. /// <returns></returns>
  915. [HttpPost]
  916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  917. public async Task<IActionResult> PostSearchItemInfo(string paras)
  918. {
  919. if (string.IsNullOrEmpty(paras))
  920. {
  921. return Ok(JsonView(false, "参数为空"));
  922. }
  923. Search_ItemInfoDto _ItemInfoDto = System.Text.Json.JsonSerializer.Deserialize<Search_ItemInfoDto>(paras);
  924. if (_ItemInfoDto != null)
  925. {
  926. if (_ItemInfoDto.SearchType == 2) //获取列表
  927. {
  928. Res_ItemInfoListView rstList = _resItemInfoRep.GetItemList(_ItemInfoDto);
  929. return Ok(rstList);
  930. }
  931. else
  932. {
  933. Res_ItemInfoView rstInfo = _resItemInfoRep.getItemInfo(_ItemInfoDto);
  934. return Ok(rstInfo);
  935. }
  936. }
  937. else
  938. {
  939. return Ok(JsonView(false, "参数反序列化失败"));
  940. }
  941. return Ok(JsonView(false));
  942. }
  943. /// <summary>
  944. /// 创建/编辑/删除物料信息
  945. /// </summary>
  946. ///
  947. /// <returns></returns>
  948. [HttpPost]
  949. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  950. public async Task<IActionResult> PostEditItemInfo(Edit_ResItemInfoDto _dto)
  951. {
  952. bool rst = false;
  953. if (_dto.EditType >= 0)
  954. {
  955. if (_dto.VendorId < 1)
  956. {
  957. return Ok(JsonView(false, "未选择供应商"));
  958. }
  959. if (string.IsNullOrEmpty(_dto.ItemName))
  960. {
  961. return Ok(JsonView(false, "物料名称为空"));
  962. }
  963. if (_dto.ItemTypeId < 1)
  964. {
  965. return Ok(JsonView(false, "未选择物料类型"));
  966. }
  967. if (_dto.SysUserId < 1)
  968. {
  969. return Ok(JsonView(false, "当前操作用户Id为空"));
  970. }
  971. if (_dto.CurrRate <= 0)
  972. {
  973. return Ok(JsonView(false, "物料录入价格不能小于等于0"));
  974. }
  975. if (_dto.EditType == 0)
  976. {
  977. //判断物料名称、类型、供应商全部重复
  978. var checkEmpty = _resItemInfoRep.Query<Res_ItemDetailInfo>(s => s.ItemName == _dto.ItemName && s.ItemTypeId == _dto.ItemTypeId && s.VendorId == _dto.VendorId).First();
  979. if (checkEmpty != null)
  980. {
  981. return Ok(JsonView(false, "已存在重复物料信息"));
  982. }
  983. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  984. DateTime dtNow = DateTime.Now;
  985. _entity.CreateUserId = _dto.SysUserId;
  986. _entity.IsDel = 0;
  987. _entity.MaxRate = _dto.CurrRate;
  988. _entity.MaxDt = dtNow;
  989. _entity.CurrRate = _dto.CurrRate;
  990. _entity.CurrDt = dtNow;
  991. _entity.MinRate = _dto.CurrRate;
  992. _entity.MinDt = dtNow;
  993. rst = await _resItemInfoRep.AddAsync<Res_ItemDetailInfo>(_entity) > 0;
  994. }
  995. else if (_dto.EditType == 1)
  996. {
  997. if (_dto.ItemId > 0)
  998. {
  999. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  1000. _entity.Id = _dto.ItemId;
  1001. rst = await _resItemInfoRep.updItemInfo(_entity);
  1002. }
  1003. else
  1004. {
  1005. return Ok(JsonView(false, "供应商不存在"));
  1006. }
  1007. }
  1008. }
  1009. else
  1010. {
  1011. if (_dto.ItemId < 1 || _dto.SysUserId < 1)
  1012. {
  1013. return Ok(JsonView(false, "用户Id或物料信息Id不存在"));
  1014. }
  1015. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  1016. rst = await _resItemInfoRep.delItemInfo(_entity);
  1017. }
  1018. return Ok(JsonView(rst));
  1019. }
  1020. #endregion
  1021. #region 物料类型获取
  1022. #endregion
  1023. #endregion
  1024. #region 备忘录
  1025. /// <summary>
  1026. /// 备忘录查询
  1027. /// </summary>
  1028. /// <param name="paras">Json序列化</param>
  1029. /// <returns></returns>
  1030. [HttpPost]
  1031. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1032. public async Task<IActionResult> PostSearchMemo(JsonDtoBase _jsonDto)
  1033. {
  1034. if (string.IsNullOrEmpty(_jsonDto.Paras))
  1035. {
  1036. return Ok(JsonView(false, "参数为空"));
  1037. }
  1038. Search_ResMemoDto _memoDto = JsonConvert.DeserializeObject<Search_ResMemoDto>(_jsonDto.Paras);
  1039. if (_memoDto != null)
  1040. {
  1041. if (_memoDto.SearchType == 2)
  1042. {
  1043. //获取列表
  1044. string sqlWhere = string.Format(" Where IsDel=0 ");
  1045. #region SqlWhere
  1046. if (!string.IsNullOrEmpty(_memoDto.Abstracts))
  1047. {
  1048. sqlWhere += string.Format(@" And m.Abstracts Like '%{0}%' ", _memoDto.Abstracts);
  1049. }
  1050. if (!string.IsNullOrEmpty(_memoDto.Title))
  1051. {
  1052. sqlWhere += string.Format(@" And m.Title Like '%{0}%' ", _memoDto.Title);
  1053. }
  1054. if (_memoDto.ReadLevel > 0)
  1055. {
  1056. sqlWhere += string.Format(@" And m.ReadLevel = {0} ", _memoDto.ReadLevel);
  1057. }
  1058. #endregion
  1059. int currPIndex = (((_memoDto.PageIndex > 0) ? (_memoDto.PageIndex - 1) : 0) * _memoDto.PageSize) + 1;
  1060. int currPSize = (((_memoDto.PageIndex > 0) ? (_memoDto.PageIndex - 1) : 0) + 1) * _memoDto.PageSize;
  1061. string sql = string.Format(@" Select * From(Select ROW_NUMBER() Over(order By m.Id desc) as RowNumber,
  1062. m.Id as MemoId,d.DepName as DepartmentName,m.ReadLevel,m.Title,m.Abstracts,
  1063. m.LastedEditDt,m.LastedEditorId
  1064. From Res_Memo as m With(Nolock) Inner Join Sys_Users as u With(Nolock) On m.CreateUserId=u.Id
  1065. Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id {2}
  1066. ) as tb Where tb.RowNumber Between {0} And {1} ", currPIndex, currPSize, sqlWhere);
  1067. Res_MemoListView rst = new Res_MemoListView();
  1068. rst.CurrPageIndex = currPIndex;
  1069. rst.CurrPageSize = currPSize;
  1070. List<Res_MemoView> dataSource = _carDataRep._sqlSugar.SqlQueryable<Res_MemoView>(sql).ToList();
  1071. Dictionary<int, string> userDic = new Dictionary<int, string>();
  1072. foreach (var item in dataSource)
  1073. {
  1074. if (userDic.ContainsKey(item.LastedEditorId))
  1075. {
  1076. item.LastedEditor = userDic[item.LastedEditorId];
  1077. }
  1078. else
  1079. {
  1080. Sys_Users _sysUser = _carDataRep.Query<Sys_Users>(s => s.Id == item.LastedEditorId).First();
  1081. userDic[item.LastedEditorId] = _sysUser.CnName;
  1082. item.LastedEditor = _sysUser.CnName;
  1083. }
  1084. }
  1085. rst.DataList = new List<Res_MemoView>(dataSource);
  1086. if (rst.DataList.Count > 0)
  1087. {
  1088. string sqlCount = string.Format(@" Select Id From Res_Memo as m With(Nolock) {0} ", sqlWhere);
  1089. int dataCount = _carDataRep._sqlSugar.SqlQueryable<Res_MemoInfo>(sqlCount).Count();
  1090. rst.DataCount = dataCount;
  1091. }
  1092. return Ok(JsonView(rst));
  1093. }
  1094. else
  1095. {
  1096. //获取对象
  1097. string sqlSingle = string.Format(@" Select
  1098. m.Id as MemoId,d.DepName as DepartmentName,m.ReadLevel,m.Title,m.Abstracts,
  1099. m.LastedEditDt,m.LastedEditor,m.MDFilePath
  1100. From Res_Memo as m With(Nolock) Inner Join Sys_Users as u With(Nolock) On m.CreateUserId=u.Id
  1101. Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _memoDto.MemoId);
  1102. Res_MemoView _result = _carDataRep._sqlSugar.SqlQueryable<Res_MemoView>(sqlSingle).First();
  1103. if (_result != null)
  1104. {
  1105. Sys_Users _sysUser = _carDataRep.Query<Sys_Users>(s => s.Id == _result.LastedEditorId).First();
  1106. _result.LastedEditor = _sysUser.CnName;
  1107. _result.MarkDownContent = new IOOperatorHelper().Read(_result.MDFilePath);
  1108. return Ok(JsonView(_result));
  1109. }
  1110. }
  1111. }
  1112. else
  1113. {
  1114. return Ok(JsonView(false, "参数反序列化失败"));
  1115. }
  1116. return Ok(JsonView(false));
  1117. }
  1118. /// <summary>
  1119. /// 创建/编辑/删除备忘录信息
  1120. /// </summary>
  1121. /// <param name="_dto"></param>
  1122. /// <returns></returns>
  1123. [HttpPost]
  1124. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1125. public async Task<IActionResult> PostEditMemo(Edit_ResMemoDto _dto)
  1126. {
  1127. bool rst = false;
  1128. if (_dto.SysUserId < 1)
  1129. {
  1130. return Ok(JsonView(false, "操作人失效"));
  1131. }
  1132. Sys_Users _sysUser = _resItemInfoRep.Query<Sys_Users>(s => s.Id == _dto.SysUserId).First();
  1133. if (_sysUser == null)
  1134. {
  1135. return Ok(JsonView(false, "操作人失效02"));
  1136. }
  1137. if (_dto.EditType >= 0)
  1138. {
  1139. if (_dto.ReadLevel < 1)
  1140. {
  1141. return Ok(JsonView(false, "未知的阅读等级"));
  1142. }
  1143. if (string.IsNullOrEmpty(_dto.Title.Trim()))
  1144. {
  1145. return Ok(JsonView(false, "标题不能为空"));
  1146. }
  1147. if (string.IsNullOrEmpty(_dto.Content.Trim()))
  1148. {
  1149. return Ok(JsonView(false, "正文内容不能为空"));
  1150. }
  1151. //新增备忘录
  1152. DateTime dtNow = DateTime.Now;
  1153. string dir = AppSettingsHelper.Get("MemoCurrPath");
  1154. string fileName = dtNow.ToString("yyyyMMddHHmmss") + _dto.Title + ".md";
  1155. string content = JsonConvert.SerializeObject(_dto.Content);
  1156. if (_dto.EditType == 0)//新增
  1157. {
  1158. string savePath = new IOOperatorHelper().Write_CoverFile(content, dir, fileName);
  1159. if (savePath.Length > 0)
  1160. {
  1161. Res_MemoInfo _insert = new Res_MemoInfo();
  1162. _insert.Abstracts = _dto.Abstracts;
  1163. _insert.Title = _dto.Title;
  1164. _insert.DepartmentId = _sysUser.DepId;
  1165. _insert.CreateUserId = _sysUser.Id;
  1166. _insert.LastedEditDt = dtNow;
  1167. _insert.LastedEditor = _sysUser.Id;
  1168. _insert.MDFilePath = savePath;
  1169. _insert.ReadLevel = _dto.ReadLevel;
  1170. _insert.Title = _dto.Title;
  1171. int result = await _resItemInfoRep.AddAsync(_insert);
  1172. return Ok(JsonView(result > 0));
  1173. }
  1174. else
  1175. {
  1176. return Ok(JsonView(false, "路径保存失败"));
  1177. }
  1178. }
  1179. else//修改
  1180. {
  1181. if (_dto.MemoId < 1)
  1182. {
  1183. return Ok(JsonView(false, "MemoId不存在"));
  1184. }
  1185. Res_MemoInfo _source = _resItemInfoRep.Query<Res_MemoInfo>(s => s.Id == _dto.MemoId).First();
  1186. if (_source == null)
  1187. {
  1188. return Ok(JsonView(false, "MemoInfo不存在"));
  1189. }
  1190. //修改
  1191. string sourcePath = _source.MDFilePath;
  1192. string recycDir = AppSettingsHelper.Get("MemoRecycleBinPath");
  1193. new IOOperatorHelper().MoveFile(sourcePath, recycDir);
  1194. string savePath = new IOOperatorHelper().Write_CoverFile(content, dir, fileName);
  1195. if (savePath.Length > 0)
  1196. {
  1197. var result = await _resItemInfoRep._sqlSugar.Updateable<Res_MemoInfo>()
  1198. .SetColumns(it => it.LastedEditDt == DateTime.Now)
  1199. .SetColumns(it => it.LastedEditor == _sysUser.Id)
  1200. .SetColumns(it => it.Abstracts == _dto.Abstracts)
  1201. .SetColumns(it => it.MDFilePath == savePath)
  1202. .SetColumns(it => it.ReadLevel == _dto.ReadLevel)
  1203. .SetColumns(it => it.Title == _dto.Title)
  1204. .Where(s => s.Id == _source.Id)
  1205. .ExecuteCommandAsync();
  1206. return Ok(JsonView(result > 0));
  1207. }
  1208. }
  1209. }
  1210. else
  1211. {
  1212. //删除
  1213. if (_dto.MemoId < 1)
  1214. {
  1215. return Ok(JsonView(false, "MemoId不存在"));
  1216. }
  1217. Res_MemoInfo _source = _resItemInfoRep.Query<Res_MemoInfo>(s => s.Id == _dto.MemoId).First();
  1218. if (_source == null)
  1219. {
  1220. return Ok(JsonView(false, "MemoInfo不存在"));
  1221. }
  1222. //修改
  1223. string sourcePath = _source.MDFilePath;
  1224. string recycDir = AppSettingsHelper.Get("MemoRecycleBinPath");
  1225. new IOOperatorHelper().MoveFile(sourcePath, recycDir);
  1226. var result = await _resItemInfoRep._sqlSugar.Updateable<Res_MemoInfo>()
  1227. .SetColumns(it => it.IsDel == 1)
  1228. .SetColumns(it => it.DeleteUserId == _sysUser.Id)
  1229. .SetColumns(it => it.DeleteTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  1230. .Where(s => s.Id == _source.Id)
  1231. .ExecuteCommandAsync();
  1232. return Ok(JsonView(result > 0));
  1233. }
  1234. return Ok(JsonView(rst));
  1235. }
  1236. #endregion
  1237. #region 商邀资料
  1238. /// <summary>
  1239. /// 商邀资料 基础数据源
  1240. /// </summary>
  1241. /// <param name="dto"></param>
  1242. /// <returns></returns>
  1243. [HttpPost]
  1244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1245. public async Task<IActionResult> QueryIOAInitData(QueryIOAInitDataDto dto)
  1246. {
  1247. try
  1248. {
  1249. #region 参数验证
  1250. if (dto.PortType < 1) return Ok(JsonView(false, "请传入有效的PortType参数!"));
  1251. #endregion
  1252. var ExcludedKeyStr = new string[] { "快递费" };
  1253. var ClientKeyStr = new string[] { "邀请函翻译" };
  1254. var expable = Expressionable.Create<Res_InvitationOfficialActivityData>();
  1255. foreach (var key in ClientKeyStr)
  1256. {
  1257. expable = expable.And(it => !it.Contact.Contains(key));
  1258. }
  1259. foreach (var item in ExcludedKeyStr)
  1260. {
  1261. expable = expable.And(it => !it.UnitName.Contains(item));
  1262. }
  1263. List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.JietuanTime).ToList();
  1264. List<Res_InvitationOfficialActivityData> _ioaDatas = _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().Where(it => it.IsDel == 0).Where(expable.ToExpression()).ToList();
  1265. List<Sys_Users> _Users = _sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0).ToList();
  1266. var _countryData = _ioaDatas.Select(it => it.Country).Distinct().ToList(); _countryData.Remove("");
  1267. var _inviterData = _ioaDatas.Select(it => it.UnitName).Distinct().ToList(); _inviterData.Remove("");
  1268. var _contactData = _ioaDatas.Select(it => it.Contact).Distinct().ToList(); _contactData.Remove("");
  1269. var _domainData = _ioaDatas.Select(it => it.Field).Distinct().ToList(); _domainData.Remove("");
  1270. var _groupNameData = _DelegationInfos.Select(it => new { it.Id, it.TeamName }).ToList();
  1271. var _userNameData = _Users.Select(it => new { it.Id, it.CnName }).ToList();
  1272. var _data = new
  1273. {
  1274. CountryData = _countryData,
  1275. InviterData = _inviterData,
  1276. DomainData = _domainData,
  1277. ContactData = _contactData,
  1278. GroupNameData = _groupNameData,
  1279. UserNameData = _userNameData,
  1280. };
  1281. return Ok(JsonView(true, $"查询成功!", _data));
  1282. }
  1283. catch (Exception ex)
  1284. {
  1285. return Ok(JsonView(false, ex.Message));
  1286. }
  1287. }
  1288. /// <summary>
  1289. /// 商邀资料查询
  1290. /// </summary>
  1291. /// <param name="dto"></param>
  1292. /// <returns></returns>
  1293. [HttpPost]
  1294. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1295. public async Task<IActionResult> QueryInvitationOfficialActivityData(QueryInvitationOfficialActivityDataDto dto)
  1296. {
  1297. var ExcludedKeyStr = new string[] { "快递费" };
  1298. var ClientKeyStr = new string[] { "邀请函翻译" };
  1299. try
  1300. {
  1301. #region 参数验证
  1302. if (dto.PageIndex < 1) return Ok(JsonView(false, "请传入有效的PageIndex参数!"));
  1303. if (dto.PageSize < 1) return Ok(JsonView(false, "请传入有效的PageSize参数!"));
  1304. #endregion
  1305. string sqlWhere = string.Empty;
  1306. if (!string.IsNullOrWhiteSpace(dto.Country)) { sqlWhere += string.Format(@" And i.Country like '%{0}%'", dto.Country); }
  1307. if (!string.IsNullOrWhiteSpace(dto.UnitName)) { sqlWhere += string.Format(@" And i.UnitName like '%{0}%'", dto.UnitName); }
  1308. if (!string.IsNullOrWhiteSpace(dto.Contact)) { sqlWhere += string.Format(@" And i.Contact like '%{0}%'", dto.Contact); }
  1309. if (!string.IsNullOrWhiteSpace(dto.Delegation)) { sqlWhere += string.Format(@" And i.Delegation like '%{0}%'", dto.Delegation); }
  1310. if (!string.IsNullOrWhiteSpace(dto.Field)) { sqlWhere += string.Format(@" And i.Field like '%{0}%'", dto.Field); }
  1311. if (dto.CreateUserId != 0 && !string.IsNullOrWhiteSpace(dto.CreateUserId.ToString())) { sqlWhere += string.Format(@" And i.CreateUserId={0}", dto.CreateUserId); }
  1312. if (!string.IsNullOrWhiteSpace(dto.StartCreateTime) && !string.IsNullOrWhiteSpace(dto.EndCreateTime))
  1313. {
  1314. sqlWhere += string.Format(@" And i.CreateTime between '{0}' and '{1}'", dto.StartCreateTime, dto.EndCreateTime);
  1315. }
  1316. sqlWhere += string.Format(@"And i.Isdel={0}", 0);
  1317. foreach (var item in ExcludedKeyStr)
  1318. {
  1319. sqlWhere += $" And i.UnitName not like '%{item}%' ";
  1320. }
  1321. foreach (var item in ClientKeyStr)
  1322. {
  1323. sqlWhere += $" And i.Contact not like '%{item}%' ";
  1324. }
  1325. if (!string.IsNullOrEmpty(sqlWhere.Trim()))
  1326. {
  1327. Regex r = new Regex("And");
  1328. sqlWhere = r.Replace(sqlWhere, "Where", 1);
  1329. }
  1330. string sql = string.Format(@"Select ROW_NUMBER() Over(Order By i.CreateTime Desc) As Row_Number,
  1331. i.*,u.CnName As CreateUserName
  1332. From Res_InvitationOfficialActivityData i
  1333. Left Join Sys_Users u On i.CreateUserId = u.Id {0}", sqlWhere);
  1334. RefAsync<int> totalCount = 0;
  1335. var _ivitiesViews = await _sqlSugar.SqlQueryable<InvitationOfficialActivityDataView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, totalCount);
  1336. //List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().ToList();
  1337. foreach (var item in _ivitiesViews)
  1338. {
  1339. string groupNameStr = "";
  1340. if (!string.IsNullOrEmpty(item.Delegation))
  1341. {
  1342. int[] groupIds = item.Delegation.Split(',').Select(x =>
  1343. {
  1344. int id;
  1345. if (int.TryParse(x, out id)) return id;
  1346. else return id;
  1347. }).ToArray();
  1348. var _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => groupIds.Contains(x.Id) && x.IsDel == 0).ToList();
  1349. foreach (var group in _DelegationInfos)
  1350. {
  1351. groupNameStr += $"{group.TeamName},";
  1352. }
  1353. if (groupNameStr.Length > 1)
  1354. {
  1355. groupNameStr = groupNameStr.Substring(0, groupNameStr.Length - 1);
  1356. }
  1357. }
  1358. item.DelegationStr = groupNameStr;
  1359. }
  1360. return Ok(JsonView(true, $"查询成功!", _ivitiesViews, totalCount));
  1361. }
  1362. catch (Exception ex)
  1363. {
  1364. return Ok(JsonView(false, ex.Message));
  1365. }
  1366. }
  1367. /// <summary>
  1368. /// 根据商邀资料Id查询信息
  1369. /// </summary>
  1370. /// <param name="id"></param>
  1371. /// <returns></returns>
  1372. [HttpGet("{id}")]
  1373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1374. public async Task<IActionResult> QueryInvitationOfficialActivityById(int id)
  1375. {
  1376. if (id < 1) return Ok(JsonView(false, "Id参数错误!"));
  1377. return Ok(await _InvitationOfficialActivityDataRep.Info(id));
  1378. }
  1379. /// <summary>
  1380. /// 商邀资料操作(Status:1.新增,2.修改)
  1381. /// </summary>
  1382. /// <param name="dto"></param>
  1383. /// <returns></returns>
  1384. [HttpPost]
  1385. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1386. public async Task<IActionResult> OpInvitationOfficialActivity([FromForm] OpInvitationOfficialActivityDto dto)
  1387. {
  1388. return Ok(await _InvitationOfficialActivityDataRep.IOA_OP(dto));
  1389. }
  1390. /// <summary>
  1391. /// 商邀资料 删除文件
  1392. /// </summary>
  1393. /// <param name="id"></param>
  1394. /// <param name="fileName"></param>
  1395. /// <returns></returns>
  1396. [HttpDelete("{id}")]
  1397. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1398. public async Task<IActionResult> InvitationOfficialActivityDelFile(int id, string fileName)
  1399. {
  1400. if (id < 1) return Ok(JsonView(false, "请传入有效的Id"));
  1401. if (string.IsNullOrEmpty(fileName)) return Ok(JsonView(false, "文件名称不能为空!"));
  1402. var info = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync(x => x.Id == id);
  1403. if (info == null) return Ok(JsonView(false, "该条数据不存在!"));
  1404. var files = new List<string>();
  1405. try
  1406. {
  1407. files = JsonConvert.DeserializeObject<List<string>>(info.SndFileName);
  1408. }
  1409. catch (Exception) { }
  1410. if (files != null && files.Count > 0 && files.Contains(fileName))
  1411. {
  1412. var filePath = $@"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{fileName}";
  1413. if (System.IO.File.Exists(filePath))
  1414. {
  1415. System.IO.File.Delete(filePath);
  1416. }
  1417. //更改文件值
  1418. files.Remove(fileName);
  1419. var fileUpd = await _sqlSugar.Updateable<Res_InvitationOfficialActivityData>()
  1420. .SetColumns(x => x.SndFileName == JsonConvert.SerializeObject(files))
  1421. .Where(x => x.Id == id)
  1422. .ExecuteCommandAsync();
  1423. if (fileUpd > 0) return Ok(JsonView(true, "操作成功!"));
  1424. }
  1425. return Ok(JsonView(false, "操作失败!"));
  1426. }
  1427. /// <summary>
  1428. /// 删除商邀资料信息
  1429. /// </summary>
  1430. /// <param name="dto"></param>
  1431. /// <returns></returns>
  1432. [HttpPost]
  1433. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1434. public async Task<IActionResult> DelInvitationOfficialActivity(DelBaseDto dto)
  1435. {
  1436. var res = await _InvitationOfficialActivityDataRep.SoftDeleteByIdAsync<Res_InvitationOfficialActivityData>(dto.Id.ToString(), dto.DeleteUserId);
  1437. if (!res) return Ok(JsonView(false, "删除失败"));
  1438. var info = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync(x => x.Id == dto.Id);
  1439. if (info == null) return Ok(JsonView(false, "该条数据不存在!"));
  1440. var files = new List<string>();
  1441. try
  1442. {
  1443. files = JsonConvert.DeserializeObject<List<string>>(info.SndFileName);
  1444. }
  1445. catch (Exception) { }
  1446. if (files != null && files.Count > 0)
  1447. {
  1448. foreach (var fileName in files)
  1449. {
  1450. var filePath = $@"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{fileName}";
  1451. if (System.IO.File.Exists(filePath))
  1452. {
  1453. System.IO.File.Delete(filePath);
  1454. }
  1455. }
  1456. }
  1457. return Ok(JsonView(true, "删除成功!"));
  1458. }
  1459. #endregion
  1460. #region 公务出访
  1461. /// <summary>
  1462. /// 获取团组所有信息,绑定下拉框
  1463. /// </summary>
  1464. /// <param name="dto"></param>
  1465. /// <returns></returns>
  1466. [HttpPost]
  1467. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1468. public async Task<IActionResult> GetGroupAllList(OfficialActivitiesByDiIdDto dto)
  1469. {
  1470. //string groupSql = string.Format("Select * From Grp_DelegationInfo With(NoLock) Where IsDel = 0 Order By CreateTime Desc");
  1471. //List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.SqlQueryable< Grp_DelegationInfo >(groupSql).ToList();
  1472. var _groupData = await _delegationInfoRep.PostShareGroupInfos(1);
  1473. dynamic groupInfos = null;
  1474. if (_groupData.Code == 0) groupInfos = _groupData.Data;
  1475. var data = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.IsDel == 0 && a.STid == 38).ToList();
  1476. var _DeleFile = _sqlSugar.Queryable<Grp_DeleFile>().Where(a => a.Diid == dto.DiId && a.IsDel == 0 && a.Category == 970).ToList();
  1477. var translatorData = _sqlSugar.Queryable<Res_TranslatorLibrary>().Where(a => a.IsDel == 0).Select(x => new { x.Id, x.Name }).ToList();
  1478. return Ok(JsonView(true, "查询成功!", new { Delegation = groupInfos, SetData = data, DeleFile = _DeleFile , TranslatorData = translatorData }));
  1479. }
  1480. /// <summary>
  1481. /// 公务List
  1482. /// </summary>
  1483. /// <param name="dto"></param>
  1484. /// <returns></returns>
  1485. [HttpPost]
  1486. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1487. public async Task<IActionResult> QueryOfficialActivitiesByDiId(OfficialActivitiesByDiIdDto dto)
  1488. {
  1489. return Ok(await _officialActivitiesRep.QueryOfficialActivitiesByDiId(dto));
  1490. }
  1491. /// <summary>
  1492. /// 根据公务出访数据Id查询数据
  1493. /// </summary>
  1494. /// <param name="dto"></param>
  1495. /// <returns></returns>
  1496. [HttpPost]
  1497. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1498. public async Task<IActionResult> QueryOfficialActivitiesById(OfficialActivitiesDiIdDto dto)
  1499. {
  1500. Result groupData = await _officialActivitiesRep.QueryOfficialActivitiesById(dto);
  1501. if (groupData.Code != 0)
  1502. {
  1503. return Ok(JsonView(false, groupData.Msg));
  1504. }
  1505. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1506. }
  1507. /// <summary>
  1508. /// 公务出访操作(Status:1.新增,2.修改)
  1509. /// </summary>
  1510. /// <param name="dto"></param>
  1511. /// <returns></returns>
  1512. [HttpPost]
  1513. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1514. public async Task<IActionResult> OpOfficialActivities(OpOfficialActivitiesDto dto)
  1515. {
  1516. Result groupData = await _officialActivitiesRep.OpOfficialActivities(dto);
  1517. if (groupData.Code != 0)
  1518. {
  1519. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, new { Id = 0 }));
  1520. }
  1521. try
  1522. {
  1523. //公务出访变更发送通知
  1524. await AppNoticeLibrary.SendUserMsg_GroupShare_ToOP(dto.DiId, dto.CreateUserId);
  1525. }
  1526. catch (Exception ex)
  1527. {
  1528. //抄送日志
  1529. }
  1530. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1531. }
  1532. /// <summary>
  1533. /// 上传文件(邮件截图)
  1534. /// </summary>
  1535. /// <param name="file"></param>
  1536. /// <returns></returns>
  1537. [HttpPost]
  1538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1539. public async Task<IActionResult> OfficialActivitiesUploadFiles([FromForm] OfficialActivitiesUploadFilesDto dto)
  1540. {
  1541. string networkPath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1542. string localPath = AppSettingsHelper.Get("GrpFileBasePath");
  1543. string ptfPath = AppSettingsHelper.Get("GrpFileFtpPath");
  1544. if (dto.diId < 1 || dto.currUserId < 1)
  1545. {
  1546. return Ok(JsonView(false, "参数有误,上传失败!"));
  1547. }
  1548. if (dto.files == null || dto.files.Count < 1)
  1549. {
  1550. return Ok(JsonView(false, "文件为空,上传失败!"));
  1551. }
  1552. string localFileDir = $"{localPath}{ptfPath}";
  1553. List<string> fileUrls = new List<string>();
  1554. string[] failFiles = new string[] { };
  1555. foreach (var file in dto.files)
  1556. {
  1557. //文件名称
  1558. string[] fileNameArray = file.FileName.Split(".");
  1559. string projectFileName = $"{fileNameArray[0].ToString().Replace("-", "_").Replace("/", "_")}{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.{fileNameArray[1].ToString()}";
  1560. //上传的文件的路径
  1561. string filePath = $@"{localPath}公务相关文件";
  1562. if (!Directory.Exists(filePath))
  1563. {
  1564. Directory.CreateDirectory(filePath);
  1565. }
  1566. var path = Path.Combine(filePath, projectFileName);
  1567. //using var stream = new FileStream(path, FileMode.Create);
  1568. //await file.CopyToAsync(stream);
  1569. try
  1570. {
  1571. using (FileStream fs = System.IO.File.Create(path))
  1572. {
  1573. file.CopyTo(fs);
  1574. fs.Flush();
  1575. }
  1576. fileUrls.Add($"/{ptfPath}公务相关文件/{projectFileName}");
  1577. }
  1578. catch (Exception ex)
  1579. {
  1580. failFiles.Append(file.FileName);
  1581. }
  1582. }
  1583. var oaInfo = await _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.Id == dto.id).FirstAsync();
  1584. List<string> files = new List<string>();
  1585. var status = false;
  1586. var _oaInfo = new Res_OfficialActivities()
  1587. {
  1588. DiId = dto.diId,
  1589. ScreenshotOfMailUrl = JsonConvert.SerializeObject(fileUrls),
  1590. IsDel = 0,
  1591. CreateUserId = dto.currUserId,
  1592. CreateTime = DateTime.Now
  1593. };
  1594. if (oaInfo == null)
  1595. {
  1596. var id = await _sqlSugar.Insertable<Res_OfficialActivities>(_oaInfo)
  1597. .ExecuteReturnIdentityAsync();
  1598. if (id > 0)
  1599. {
  1600. status = true;
  1601. dto.id = id;
  1602. }
  1603. }
  1604. else
  1605. {
  1606. var oldFiles = string.IsNullOrEmpty(oaInfo.ScreenshotOfMailUrl)
  1607. ? new List<string>()
  1608. : JsonConvert.DeserializeObject<List<string>>(oaInfo.ScreenshotOfMailUrl);
  1609. if (oldFiles.Count > 0)
  1610. {
  1611. fileUrls.AddRange(oldFiles);
  1612. }
  1613. fileUrls = fileUrls.Distinct().ToList();
  1614. if (fileUrls.Count() > 0)
  1615. {
  1616. var upd = await _sqlSugar.Updateable<Res_OfficialActivities>()
  1617. .SetColumns(x => x.ScreenshotOfMailUrl == JsonConvert.SerializeObject(fileUrls))
  1618. .Where(x => x.Id == dto.id)
  1619. .ExecuteCommandAsync();
  1620. if (upd > 0) status = true;
  1621. }
  1622. }
  1623. List<string> returnFileUrls = new List<string>();
  1624. fileUrls.ForEach(x =>
  1625. {
  1626. returnFileUrls.Add($"{networkPath}{x}");
  1627. });
  1628. if (status)
  1629. {
  1630. string msg = "操作成功!";
  1631. if (failFiles.Length > 1)
  1632. {
  1633. foreach (var item in failFiles)
  1634. {
  1635. msg += $"{failFiles}、";
  1636. }
  1637. msg = msg.Substring(0, msg.Length - 1);
  1638. msg += "等文件保存失败!";
  1639. }
  1640. return Ok(JsonView(true, msg, new { id = dto.id, fileUrls = returnFileUrls }));
  1641. }
  1642. return Ok(JsonView(false, "操作失败!"));
  1643. }
  1644. /// <summary>
  1645. /// 删除文件(邮件截图)
  1646. /// </summary>
  1647. /// <param name="file"></param>
  1648. /// <returns></returns>
  1649. [HttpPost]
  1650. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1651. public async Task<IActionResult> OfficialActivitiesDelFile(OfficialActivitiesDelFileDto dto)
  1652. {
  1653. string networkPath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1654. string localPath = AppSettingsHelper.Get("GrpFileBasePath");
  1655. string ptfPath = AppSettingsHelper.Get("GrpFileFtpPath");
  1656. if (dto.Id < 1 || string.IsNullOrEmpty(dto.FileName))
  1657. {
  1658. return Ok(JsonView(false, "参数有误,上传失败!"));
  1659. }
  1660. string localFileDir = $"{localPath}{ptfPath}";
  1661. List<string> fileUrls = new List<string>();
  1662. var oaInfo = await _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.Id == dto.Id).FirstAsync();
  1663. if (oaInfo != null)
  1664. {
  1665. string urlJson = oaInfo.ScreenshotOfMailUrl ?? "";
  1666. if (!string.IsNullOrEmpty(urlJson))
  1667. {
  1668. List<string> urls = JsonConvert.DeserializeObject<List<string>>(urlJson);
  1669. var filePath = urls.Find(x => x.Contains(dto.FileName));
  1670. if (string.IsNullOrEmpty(filePath)) return Ok(JsonView(false, "文件不存在!"));
  1671. var updFile = urls.Remove(filePath);
  1672. if (updFile)
  1673. {
  1674. //删除文件
  1675. string fileUrl = AppSettingsHelper.Get("GrpFileBasePath").Replace(@"/Office/GrpFile", "") + filePath;
  1676. if (System.IO.File.Exists(fileUrl))
  1677. {
  1678. System.IO.File.Delete(fileUrl);
  1679. }
  1680. string urlJsonstr = JsonConvert.SerializeObject(urls);
  1681. var upd = await _sqlSugar.Updateable<Res_OfficialActivities>()
  1682. .SetColumns(x => x.ScreenshotOfMailUrl == urlJsonstr)
  1683. .Where(x => x.Id == dto.Id)
  1684. .ExecuteCommandAsync();
  1685. if (upd > 0) return Ok(JsonView(true, "操作成功!"));
  1686. }
  1687. }
  1688. }
  1689. return Ok(JsonView(false, "操作失败!"));
  1690. }
  1691. /// <summary>
  1692. /// 公务出访 确认、取消邀请
  1693. /// </summary>
  1694. /// <param name="file"></param>
  1695. /// <returns></returns>
  1696. [HttpPost]
  1697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1698. public async Task<IActionResult> OfficialActivitiesInviteOperation(OfficialActivitiesInviteOperationDto dto)
  1699. {
  1700. if (dto.Id < 1) return Ok(JsonView(false, "Id参数有误!"));
  1701. if (dto.Type < 0 || dto.Type > 1) return Ok(JsonView(false, "Type参数有误!"));
  1702. var upd = await _sqlSugar.Updateable<Res_OfficialActivities>()
  1703. .SetColumns(x => x.ConfirmTheInvitation == dto.Type)
  1704. .Where(x => x.Id == dto.Id)
  1705. .ExecuteCommandAsync();
  1706. if (upd > 0) return Ok(JsonView(true, "操作成功!"));
  1707. return Ok(JsonView(false, "操作失败!"));
  1708. }
  1709. /// <summary>
  1710. /// 上传文件
  1711. /// </summary>
  1712. /// <param name="file"></param>
  1713. /// <returns></returns>
  1714. [HttpPost]
  1715. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1716. public async Task<IActionResult> UploadOfficialActivities(IFormFile file)
  1717. {
  1718. try
  1719. {
  1720. int Type = int.Parse(Request.Headers["Type"]);//1公务方简介,2公务活动图片,3发票
  1721. int DiId = int.Parse(Request.Headers["DiId"]);
  1722. int CreateUserId = int.Parse(Request.Headers["CreateUserId"]);
  1723. if (file != null)
  1724. {
  1725. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  1726. //文件名称
  1727. string projectFileName = file.FileName;
  1728. //上传的文件的路径
  1729. string filePath = "";
  1730. if (!Directory.Exists(fileDir))
  1731. {
  1732. Directory.CreateDirectory(fileDir);
  1733. }
  1734. //上传的文件的路径
  1735. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  1736. using (FileStream fs = System.IO.File.Create(filePath))
  1737. {
  1738. file.CopyTo(fs);
  1739. fs.Flush();
  1740. }
  1741. Grp_DeleFile d = new Grp_DeleFile();
  1742. d.Diid = DiId;
  1743. d.Category = 970;
  1744. if (Type == 1) d.Kind = 1;
  1745. else if (Type == 2) d.Kind = 2;
  1746. else if (Type == 3) d.Kind = 3;
  1747. d.FileName = projectFileName;
  1748. d.FilePath = "";
  1749. d.CreateUserId = CreateUserId;
  1750. int id = await _sqlSugar.Insertable(d).ExecuteReturnIdentityAsync();
  1751. return Ok(JsonView(true, "上传成功!", projectFileName));
  1752. }
  1753. else
  1754. {
  1755. return Ok(JsonView(false, "上传失败!"));
  1756. }
  1757. }
  1758. catch (Exception ex)
  1759. {
  1760. return Ok(JsonView(false, "程序错误!"));
  1761. throw;
  1762. }
  1763. }
  1764. /// <summary>
  1765. /// 删除文件
  1766. /// </summary>
  1767. /// <param name="dto"></param>
  1768. /// <returns></returns>
  1769. [HttpPost]
  1770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1771. public async Task<IActionResult> DelloadOfficialActivities(DelBaseDto dto)
  1772. {
  1773. try
  1774. {
  1775. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  1776. Grp_DeleFile _DeleFile = await _sqlSugar.Queryable<Grp_DeleFile>().FirstAsync(a => a.Id == dto.Id);
  1777. if (_DeleFile != null)
  1778. {
  1779. string fileName = _DeleFile.FileName;
  1780. string filePath = fileDir + "/团组增减款项相关文件/" + fileName;
  1781. // 删除该文件
  1782. System.IO.File.Delete(filePath);
  1783. 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();
  1784. return Ok(JsonView(true, "取消文件成功!"));
  1785. }
  1786. else
  1787. {
  1788. return Ok(JsonView(false, "取消文件失败!"));
  1789. }
  1790. }
  1791. catch (Exception ex)
  1792. {
  1793. return Ok(JsonView(false, "程序错误!"));
  1794. throw;
  1795. }
  1796. }
  1797. /// <summary>
  1798. /// 删除公务出访信息
  1799. /// </summary>
  1800. /// <param name="dto"></param>
  1801. /// <returns></returns>
  1802. [HttpPost]
  1803. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1804. public async Task<IActionResult> DelOfficialActivities(DelBaseDto dto)
  1805. {
  1806. _sqlSugar.BeginTran();
  1807. var res = await _officialActivitiesRep.SoftDeleteByIdAsync<Res_OfficialActivities>(dto.Id.ToString(), dto.DeleteUserId);
  1808. if (!res)
  1809. {
  1810. _sqlSugar.RollbackTran();
  1811. return Ok(JsonView(false, "删除失败"));
  1812. }
  1813. #region 删除公务出访
  1814. await _sqlSugar.Updateable<Grp_OfficialDutyLinkTranslator>()
  1815. .SetColumns(x => new Grp_OfficialDutyLinkTranslator()
  1816. {
  1817. DeleteUserId = dto.DeleteUserId,
  1818. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  1819. IsDel = 1,
  1820. Remark = $"公务出访-->删除"
  1821. })
  1822. .Where(x => x.OfficialDutyId == dto.Id)
  1823. .ExecuteCommandAsync();
  1824. #endregion
  1825. _sqlSugar.CommitTran();
  1826. return Ok(JsonView(true, "删除成功!"));
  1827. }
  1828. /// <summary>
  1829. /// 公务出访
  1830. /// 请示范例提示
  1831. /// Add Time:2024-05-13 13:56:44
  1832. /// </summary>
  1833. /// <param name="dto"></param>
  1834. /// <returns></returns>
  1835. [HttpPost]
  1836. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1837. public async Task<IActionResult> PostOfficialActivitiesReqReqSampleTips(PostOfficialActivitiesReqReqSampleTipsDto dto)
  1838. {
  1839. var res = await _officialActivitiesRep.PostReqReqSampleTips(dto.country, dto.area, dto.client);
  1840. if (res.Code == 0)
  1841. {
  1842. return Ok(JsonView(true, "操作成功!", res.Data));
  1843. }
  1844. return Ok(JsonView(false, res.Msg));
  1845. }
  1846. /// <summary>
  1847. /// 公务出访 (省外办,市外办) File Downlaod
  1848. /// </summary>
  1849. /// <param name="dto"></param>
  1850. /// <returns></returns>
  1851. [HttpPost]
  1852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1853. public async Task<IActionResult> OfficialActivitiesFileDownload(OfficialActivitiesFileDownload dto)
  1854. {
  1855. #region 参数验证
  1856. if (dto.FileType < 1 || dto.FileType > 2) return Ok(JsonView(false, "请传入有效的FileType参数. 1 省外办出访请示 2 市外办出访请示", ""));
  1857. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数.", ""));
  1858. #endregion
  1859. //团组基础信息
  1860. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  1861. if (groupInfo == null) return Ok(JsonView(false, "该团组基本信息不存在", ""));
  1862. groupInfo.VisitCountry = groupInfo.VisitCountry.Replace("|", "、");
  1863. //团组公务信息
  1864. var obDatas = _sqlSugar.Queryable<Res_OfficialActivities>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderBy(it => it.Date).ToList();
  1865. //if (obDatas.Count < 1) return Ok(JsonView(false, "请先录入公务信息!"));
  1866. //团组客户名单
  1867. var guestResult = _tourClientListRep._ItemByDiId(1, dto.DiId);
  1868. List<TourClientListByDiIdView> guestInfos = new List<TourClientListByDiIdView>();
  1869. if (guestResult.Result.Code == 0) guestInfos = guestResult.Result.Data as List<TourClientListByDiIdView>;
  1870. string visitCountrys = ""; //××国家(或地区)×天,××国家(或地区)×天
  1871. string countryStayStr = ""; // xx、xx、xx
  1872. //出入境费用 住宿类型
  1873. var dayCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId && it.Type == 1).ToList();
  1874. if (dayCostDatas.Count > 0)
  1875. {
  1876. List<int> nationalIds = dayCostDatas.Select(it => it.NationalTravelFeeId).ToList();
  1877. var nationalDatas = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => nationalIds.Contains(it.Id)).ToList();
  1878. var nationalDataGroupByCountry = nationalDatas.GroupBy(it => it.Country);
  1879. foreach (var item in nationalDataGroupByCountry)
  1880. {
  1881. visitCountrys += $"{item.Key}、";
  1882. int stayDays = nationalIds.Where(it => it == item.ToList()[0].Id).Count();
  1883. countryStayStr += $"{item.Key}{stayDays}天,";
  1884. }
  1885. if (visitCountrys.Length > 0) visitCountrys = visitCountrys.Substring(0, visitCountrys.Length - 1);
  1886. if (countryStayStr.Length > 0) countryStayStr = countryStayStr.Substring(0, countryStayStr.Length - 1);
  1887. }
  1888. else
  1889. {
  1890. visitCountrys = groupInfo.VisitCountry;
  1891. countryStayStr = GeneralMethod.GetCountryStandingTime(groupInfo.Id); //计算国家出访天数
  1892. }
  1893. //出访人数
  1894. int visitPeopleNum = groupInfo.VisitPNumber;
  1895. int visitDaysNum = groupInfo.VisitDays;
  1896. //出访单位
  1897. string obInfoStr = "";
  1898. foreach (var ob in obDatas) obInfoStr += @$"{ob.Client.Trim()}{ob.Job.Trim()}{ob.Contact.Trim()}、";
  1899. if (obInfoStr.Length > 0) obInfoStr = obInfoStr.Substring(0, obInfoStr.Length - 1);
  1900. obInfoStr = obInfoStr ?? "[公务出访未录入]";
  1901. //出访路线
  1902. string lineStr = GeneralMethod.GetGroupCityLine(groupInfo.Id, "—");
  1903. if (dto.FileType == 1)
  1904. {
  1905. //载入模板
  1906. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/省外办出访请示 - 模板.docx";
  1907. var doc = new Document(tempPath);
  1908. DocumentBuilder builder = new DocumentBuilder(doc);
  1909. //键值对存放数据
  1910. Dictionary<string, string> dic = new Dictionary<string, string>();
  1911. //××(组团单位):接团客户信息团组
  1912. dic.Add("GroupClient", $"{groupInfo.ClientUnit}\r\n");
  1913. //关于××(职务、姓名)等×人赴××(国家或地区)进行×××(出访目的)的请示
  1914. string guestName = "";
  1915. string guestJob = "";
  1916. string guestInfoStr = "";
  1917. var guestFirstInfo = guestInfos.FirstOrDefault();
  1918. if (guestFirstInfo != null)
  1919. {
  1920. guestName = guestFirstInfo.LastName.Trim() + guestFirstInfo.FirstName.Trim();
  1921. guestJob = guestFirstInfo.Job.Trim();
  1922. guestInfoStr = $@"{guestJob}、{guestName}";
  1923. }
  1924. guestInfoStr = guestInfoStr ?? "[接团客户名单未录入]";
  1925. string askTitle = $@"关于{guestInfoStr}等{visitPeopleNum}人赴{visitCountrys}进行{groupInfo.VisitPurpose}的请示";
  1926. dic.Add("AskTitle", askTitle);
  1927. //应×××(邀请方名称+邀请人职务和姓名)的邀请,我单位拟派×××(职务、姓名)等×人(人数)于×××年×××月×××日赴×××(国家或地区)进行×××(出访目的)。现请示如下。
  1928. string visitDateStr = @$"{groupInfo.VisitDate.Year}年{groupInfo.VisitDate.Month}月{groupInfo.VisitDate.Day}日";
  1929. string askSubTitle = $@"应{obInfoStr}的邀请,我单位拟派{guestInfoStr}等{visitPeopleNum}人于{visitDateStr}赴{visitCountrys}进行{groupInfo.VisitPurpose}。现请示如下。";
  1930. dic.Add("AskSubTitle", askSubTitle);
  1931. //出访目的
  1932. dic.Add("VisitPurpose", groupInfo.VisitPurpose);
  1933. //出访任务
  1934. //(一)××(国家或地区)
  1935. //1.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)
  1936. //2.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)
  1937. string obBackgroundStr = "";//出访背景
  1938. string taskStr = ""; ; //出访任务
  1939. var countrys = obDatas.GroupBy(it => it.Country);
  1940. int countryIndex = 1;
  1941. foreach (var item in countrys)
  1942. {
  1943. string taskTitle = $"({GetToUpperNumber(countryIndex)}){item.Key}\r\n";
  1944. string taskContent = "";
  1945. string obBackgroundContent = "";
  1946. int obIndex = 1;
  1947. foreach (var obInfo in item.ToList())
  1948. {
  1949. string reqSmaple = "";
  1950. string settingStr = "";
  1951. if (!string.IsNullOrEmpty(obInfo.ReqSample)) reqSmaple = obInfo.ReqSample;
  1952. else reqSmaple = "[公务出访请示范例未录入]";
  1953. if (!string.IsNullOrEmpty(obInfo.Setting)) settingStr = obInfo.Setting;
  1954. else settingStr = "[公务方背景未录入]";
  1955. taskContent += $"{obIndex}. {reqSmaple}\r\n";
  1956. obBackgroundContent += $"{obIndex}. {obInfo.Client}:{settingStr}\r\n";
  1957. obIndex++;
  1958. }
  1959. taskStr += $"{taskTitle}{taskContent}";
  1960. obBackgroundStr += $"{taskTitle}{obBackgroundContent}";
  1961. countryIndex++;
  1962. }
  1963. //出访背景
  1964. if (obBackgroundStr.Length < 1) obBackgroundStr = "[公务出访背景未录入]";
  1965. dic.Add("OBSetting", obBackgroundStr);
  1966. //出访任务
  1967. if (taskStr.Length < 1) taskStr = "[公务出访任务未录入]";
  1968. dic.Add("TaskContent", taskStr);
  1969. //出访时间
  1970. //代表团拟于××年×月×日—×月×日出访,在外停留×天。其中,××国家(或地区)×天,××国家(或地区)×天。
  1971. string visitTimeQuantumStr = $"代表团拟于{groupInfo.VisitStartDate.Year}年{groupInfo.VisitStartDate.Month}月{groupInfo.VisitStartDate.Day}日—{groupInfo.VisitEndDate.Month}月{groupInfo.VisitEndDate.Day}日出访,在外停留{visitDaysNum}天。其中,{countryStayStr}。";
  1972. //出访时间
  1973. dic.Add("TimeQuantum", visitTimeQuantumStr);
  1974. //出访路线
  1975. //成都—××(出境城市名称)—××(转机不出机场)—××(公务所在城市)……—××(入境城市名称)—成都。(例:成都—法兰克福<转机不出机场>—巴黎—巴塞罗那—阿姆斯特丹<转机不出机场>-成都)
  1976. dic.Add("Line", lineStr);
  1977. //scheduling //行程安排
  1978. string schedulingStr = $"[OP行程单暂未生成]";
  1979. #region op行程 根据黑屏代码录入
  1980. var opTripView = GeneralMethod.GetBriefStroke(groupInfo.Id);
  1981. if (opTripView.Code != 0) schedulingStr = $"[{opTripView.Msg}]";
  1982. schedulingStr = "";
  1983. List<Grp_TravelList> travelList = new List<Grp_TravelList>();
  1984. travelList = opTripView.Data as List<Grp_TravelList>;
  1985. if (travelList != null)
  1986. {
  1987. foreach (var item in travelList)
  1988. {
  1989. schedulingStr += $"{item.Date}({item.WeekDay})\r\n{item.Trip}\r\n";
  1990. }
  1991. }
  1992. #endregion
  1993. dic.Add("Scheduling", schedulingStr);
  1994. #region 填充word模板书签内容
  1995. foreach (var key in dic.Keys)
  1996. {
  1997. builder.MoveToBookmark(key);
  1998. builder.Write(dic[key]);
  1999. }
  2000. #endregion
  2001. //获取word里所有表格
  2002. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  2003. //获取所填表格的序数
  2004. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  2005. var rowStart = tableOne.Rows[0]; //获取第1行
  2006. //循环赋值
  2007. for (int i = 0; i < guestInfos.Count; i++)
  2008. {
  2009. var guestInfo = guestInfos[i];
  2010. builder.MoveToCell(0, i + 1, 0, 0);
  2011. builder.Write(guestInfo.LastName + guestInfo.FirstName);
  2012. builder.MoveToCell(0, i + 1, 1, 0);
  2013. int sex = guestInfo.Sex;
  2014. string sexStr = string.Empty;
  2015. if (sex == 0) sexStr = "男";
  2016. else if (sex == 1) sexStr = "女";
  2017. else sexStr = "-";
  2018. builder.Write(sexStr);
  2019. builder.MoveToCell(0, i + 1, 2, 0);
  2020. builder.Write(guestInfo.CompanyFullName + guestInfo.Job);
  2021. builder.MoveToCell(0, i + 1, 3, 0);
  2022. string birthDay = "";
  2023. string birthDayStr = string.Empty;
  2024. if (guestInfo.BirthDay != null)
  2025. {
  2026. birthDayStr = guestInfo.BirthDay.ToString("yyyy.MM");
  2027. }
  2028. builder.Write(birthDayStr);
  2029. }
  2030. //删除多余行
  2031. while (tableOne.Rows.Count > guestInfos.Count + 1)
  2032. {
  2033. tableOne.Rows.RemoveAt(guestInfos.Count + 1);
  2034. }
  2035. var fileDir = AppSettingsHelper.Get("WordBasePath");
  2036. string fileName = $"{groupInfo.TeamName}省外办出访请示{DateTime.Now.ToString("yyyyMMddHHmmss")}.docx";
  2037. string filePath = fileDir + $@"OfficialActivities/{fileName}";
  2038. doc.Save(filePath);
  2039. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/OfficialActivities/{fileName}";
  2040. return Ok(JsonView(true, "操作成功!", Url));
  2041. }
  2042. else if (dto.FileType == 2)
  2043. {
  2044. //载入模板
  2045. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/市外办出访请示 - 模板.docx";
  2046. var doc = new Document(tempPath);
  2047. DocumentBuilder builder = new DocumentBuilder(doc);
  2048. //键值对存放数据
  2049. Dictionary<string, string> dic = new Dictionary<string, string>();
  2050. //××(组团单位):接团客户信息团组
  2051. dic.Add("GroupClient", $"{groupInfo.ClientUnit}");
  2052. dic.Add("GroupClient1", $"{groupInfo.ClientUnit}");
  2053. //关于××(职务、姓名)等×人赴××(国家或地区)进行×××(出访目的)的请示
  2054. string guestName = "";
  2055. string guestJob = "";
  2056. string guestInfoStr = "";
  2057. var guestFirstInfo = guestInfos.FirstOrDefault();
  2058. if (guestFirstInfo != null)
  2059. {
  2060. guestName = guestFirstInfo.LastName.Trim() + guestFirstInfo.FirstName.Trim();
  2061. guestJob = guestFirstInfo.Job;
  2062. guestInfoStr = $@"{guestJob}、{guestName.Trim()}";
  2063. }
  2064. string reqTitle = $@"关于{guestInfoStr}等{visitPeopleNum}人赴{visitCountrys}进行{groupInfo.VisitPurpose}的请示";
  2065. dic.Add("ReqTitle", reqTitle);
  2066. //应×××(邀请方名称+邀请人职务和姓名)的邀请,我单位拟派×××(职务、姓名)等×人(人数)于×××年×××月×××日赴×××(国家或地区)进行×××(出访目的)。
  2067. string visitDateStr = @$"{groupInfo.VisitDate.Year}年{groupInfo.VisitDate.Month}月{groupInfo.VisitDate.Day}日";
  2068. string reqSubTitle = $@"应{obInfoStr}的邀请,我单位拟派{guestInfoStr}等{visitPeopleNum}人于{visitDateStr}赴{visitCountrys}进行{groupInfo.VisitPurpose}。";
  2069. dic.Add("ReqSubTitle", reqSubTitle);
  2070. /*
  2071. * 出访任务
  2072. * (一)××(国家或地区)
  2073. * 1.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)背景:拟拜访机构的优势、拟洽谈项目的前期进展情况等。(例:背景:由×××总领馆联合×××市政府共同举办的“×××活动”将于今年6月在×××举行。)
  2074. * 2.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研等)×××(项目或机构名称等)。(例:拜会友城×××市市长×××,巩固和发展两市传统友谊,商谈两市未来互动交流合作项目。)背景:拟拜访机构的优势、拟洽谈项目的前期进展情况等。(例:背景:×××年×月,×××市与×××市正式缔结友好城市关系。在此框架下,两市开展了一系列友好互访和商务交流。并于×××年×月共同举办了“×××活动”。)
  2075. *
  2076. */
  2077. string taskStr = string.Empty;
  2078. List<string> countrys = obDatas.Where(it => !string.IsNullOrEmpty(it.Country)).Select(it => it.Country).ToList();
  2079. int countryIndex = 1;
  2080. foreach (var item in countrys)
  2081. {
  2082. string taskTitle = $"({GetToUpperNumber(countryIndex)}){item ?? "[公务出访国家未填写]"}\r\n";
  2083. string taskContent = "";
  2084. if (!string.IsNullOrEmpty(item))
  2085. {
  2086. var countryObDatas = obDatas.Where(it => !string.IsNullOrEmpty(it.Country) && it.Country.Contains(item)).OrderBy(it => it.Date).ToList();
  2087. int obIndex = 1;
  2088. if (countryObDatas.Count == 0) taskContent = "[公务出访未录入]\r\n";
  2089. else
  2090. {
  2091. foreach (var obInfo in countryObDatas)
  2092. {
  2093. taskContent += $"{obIndex}.{obInfo.ReqSample ?? "[公务出访请示范例未填写]"}\r\n背景:{obInfo.Setting ?? "[公务出访背景未填写]"}\r\n";
  2094. obIndex++;
  2095. }
  2096. }
  2097. }
  2098. taskStr += $"{taskTitle}{taskContent}";
  2099. countryIndex++;
  2100. }
  2101. if (string.IsNullOrEmpty(taskStr)) taskStr = "××××××";
  2102. //出访任务
  2103. dic.Add("TaskContent", taskStr);
  2104. //出访目的
  2105. dic.Add("VisitPurpose", groupInfo.VisitPurpose);
  2106. //出访信息
  2107. //代表团拟于××年×月×日—×月×日出访,在外停留×天。其中,××国家(或地区)×天,××国家(或地区)×天。出访路线:成都—××(出境城市名称)—××(转机不出机场)—××(公务所在城市)……—××(入境城市名称)—成都。(例:成都—法兰克福<转机不出机场>—巴黎—巴塞罗那—阿姆斯特丹<转机不出机场>-成都)出访费用:由××承担(注明由外方或上级机关承担,还是由派员单位在年度安排的预算经费中列支)。
  2108. string tripInfoStr = "";
  2109. tripInfoStr = $"代表团拟于{groupInfo.VisitStartDate.Year}年{groupInfo.VisitStartDate.Month}月{groupInfo.VisitStartDate.Day}日—{groupInfo.VisitEndDate.Month}月{groupInfo.VisitEndDate.Day}日出访,在外停留{visitDaysNum}天。其中,{countryStayStr}。出访路线:{lineStr}。出访费用:由××承担(注明由外方或上级机关承担,还是由派员单位在年度安排的预算经费中列支)";
  2110. dic.Add("TripInfo", tripInfoStr);
  2111. #region 填充word模板书签内容
  2112. foreach (var key in dic.Keys)
  2113. {
  2114. builder.MoveToBookmark(key);
  2115. builder.Write(dic[key]);
  2116. }
  2117. #endregion
  2118. //获取word里所有表格
  2119. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  2120. //获取所填表格的序数
  2121. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  2122. var rowStart = tableOne.Rows[0]; //获取第1行
  2123. //循环赋值
  2124. for (int i = 0; i < guestInfos.Count; i++)
  2125. {
  2126. var guestInfo = guestInfos[i];
  2127. builder.MoveToCell(0, i + 1, 0, 0);
  2128. builder.Write(guestInfo.LastName + guestInfo.FirstName);
  2129. builder.MoveToCell(0, i + 1, 1, 0);
  2130. int sex = guestInfo.Sex;
  2131. string sexStr = string.Empty;
  2132. if (sex == 0) sexStr = "男";
  2133. else if (sex == 1) sexStr = "女";
  2134. else sexStr = "未设置";
  2135. builder.Write(sexStr);
  2136. builder.MoveToCell(0, i + 1, 2, 0);
  2137. builder.Write(guestInfo.CompanyFullName + guestInfo.Job);
  2138. builder.MoveToCell(0, i + 1, 3, 0);
  2139. DateTime birthDay = guestInfo.BirthDay;
  2140. string birthDayStr = string.Empty;
  2141. if (birthDay != null)
  2142. {
  2143. birthDayStr = birthDay.ToString("yyyy.MM");
  2144. }
  2145. builder.Write(birthDayStr);
  2146. }
  2147. //删除多余行
  2148. while (tableOne.Rows.Count > guestInfos.Count + 1)
  2149. {
  2150. tableOne.Rows.RemoveAt(guestInfos.Count + 1);
  2151. }
  2152. var fileDir = AppSettingsHelper.Get("WordBasePath");
  2153. var fileName = $"{groupInfo.TeamName}市外办出访请示{DateTime.Now.ToString("yyyyMMddHHmmss")}.docx";
  2154. var filePath = fileDir + $@"OfficialActivities/{fileName}";
  2155. doc.Save(filePath);
  2156. var url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/OfficialActivities/{fileName}";
  2157. return Ok(JsonView(true, "操作成功!", url));
  2158. }
  2159. return Ok(JsonView(true, "操作失败!", ""));
  2160. }
  2161. private string GetToUpperNumber(int num)
  2162. {
  2163. string numStr = "";
  2164. if (num == 1) numStr = "一";
  2165. else if (num == 2) numStr = "二";
  2166. else if (num == 3) numStr = "三";
  2167. else if (num == 4) numStr = "四";
  2168. else if (num == 5) numStr = "五";
  2169. else if (num == 6) numStr = "六";
  2170. else if (num == 7) numStr = "七";
  2171. else if (num == 8) numStr = "八";
  2172. else if (num == 9) numStr = "九";
  2173. else if (num == 10) numStr = "十";
  2174. return numStr;
  2175. }
  2176. [HttpPost]
  2177. public IActionResult ExportOfficialActivitiesInfo(ExportOfficialActivitiesInfoDto dto)
  2178. {
  2179. var jw = JsonView(false);
  2180. if (!ModelState.IsValid)
  2181. {
  2182. jw.Data = ModelState;
  2183. return Ok(jw);
  2184. }
  2185. var startTime_bool = DateTime.TryParse(dto.StartTime, out DateTime startTime_parse);
  2186. var endTime_bool = DateTime.TryParse(dto.EndTime, out DateTime endTime_parse);
  2187. if(startTime_parse > endTime_parse)
  2188. {
  2189. jw.Msg = "开始实际不能大于结束时间!";
  2190. return Ok(jw);
  2191. }
  2192. if (startTime_bool && endTime_bool)
  2193. {
  2194. //处理时间模板
  2195. var Query_DB = _sqlSugar.Queryable<Grp_DelegationInfo>()
  2196. .LeftJoin<Res_OfficialActivities>((a, b) => a.Id == b.DiId && b.IsDel == 0)
  2197. .LeftJoin<Sys_Users>((a, b, c) => b.CreateUserId == c.Id && c.IsDel == 0)
  2198. .Where((a, b, c) => a.IsDel == 0 && a.VisitDate >= startTime_parse && a.VisitDate <= endTime_parse)
  2199. .WhereIF(dto.State != -1, (a, b, c) => b.ConfirmTheInvitation == dto.State)
  2200. .Select((a, b, c) => new
  2201. {
  2202. a.TeamName,
  2203. b.Client,
  2204. b.ConfirmTheInvitation,
  2205. b.Contact,
  2206. ConfirmTheInvitationStr = b.ConfirmTheInvitation == 1 ? "是" : "否",
  2207. b.Date,
  2208. b.Nature,
  2209. c.CnName,
  2210. b.Address,
  2211. b.CreateTime
  2212. })
  2213. .ToList()
  2214. .Where(x=>!x.Client.IsNullOrWhiteSpace())
  2215. .ToList();
  2216. if (Query_DB.Count > 0)
  2217. {
  2218. //打开excel
  2219. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath");
  2220. var fileBasePath = AppSettingsHelper.Get("ExcelBasePath");
  2221. var fileName = "公务出访信息.docx";
  2222. //创建数据源Table
  2223. DataTable dtSource = new DataTable();
  2224. dtSource.TableName = "TB";
  2225. var firstElem = Query_DB.First();
  2226. //遍历firstElem所有属性
  2227. foreach (var item in firstElem.GetType().GetProperties())
  2228. {
  2229. dtSource.Columns.Add(item.Name, item.PropertyType);
  2230. }
  2231. foreach (var item in Query_DB)
  2232. {
  2233. DataRow dr = dtSource.NewRow();
  2234. //遍历dtSource所有列头
  2235. foreach (DataColumn column in dtSource.Columns)
  2236. {
  2237. dr[column.ColumnName] = item.GetType().GetProperty(column.ColumnName)?.GetValue(item)?.ToString();
  2238. }
  2239. dtSource.Rows.Add(dr);
  2240. }
  2241. WorkbookDesigner designer = new WorkbookDesigner();
  2242. designer.Workbook = new Workbook(fileBasePath + ("Template/公务出访信息.xlsx"));
  2243. var title = startTime_parse.ToString("yyyy年MM月dd日") + " - " + endTime_parse.ToString("yyyy年MM月dd日") + " 公务出访信息";
  2244. designer.SetDataSource("title", title);
  2245. designer.SetDataSource(dtSource);
  2246. designer.Process();
  2247. var exportSerevePath = fileBasePath + "ExportOfficialActivitiesInfo/" + title + ".xlsx";
  2248. var exportFtpPaht = ftpPath + "ExportOfficialActivitiesInfo/" + title + ".xlsx";
  2249. //保存文件
  2250. designer.Workbook.Save(exportSerevePath);
  2251. jw.Data = AppSettingsHelper.Get("ExcelBaseUrl") + exportFtpPaht;
  2252. jw.Code = 200;
  2253. jw.Msg = "获取成功!";
  2254. }
  2255. else
  2256. {
  2257. jw.Data = "无公务信息!";
  2258. }
  2259. }
  2260. else
  2261. {
  2262. jw.Data = "时间格式错误!";
  2263. }
  2264. return Ok(jw);
  2265. }
  2266. #endregion
  2267. #region 请示数据库
  2268. /// <summary>
  2269. /// 查询请示数据库初始化
  2270. /// </summary>
  2271. /// <param name="dto"></param>
  2272. /// <returns></returns>
  2273. [HttpPost]
  2274. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2275. public async Task<IActionResult> QueryAskData(QueryAskDataDto dto)
  2276. {
  2277. Result groupData = await _askDataRep.QueryAskData(dto);
  2278. if (groupData.Code != 0)
  2279. {
  2280. return Ok(JsonView(false, groupData.Msg));
  2281. }
  2282. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2283. }
  2284. /// <summary>
  2285. /// 根据Id查询请示数据库单条数据
  2286. /// </summary>
  2287. /// <param name="dto"></param>
  2288. /// <returns></returns>
  2289. [HttpPost]
  2290. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2291. public async Task<IActionResult> QueryAskDataById(QueryAskDataByIdDto dto)
  2292. {
  2293. Res_AskData _AskData = await _sqlSugar.Queryable<Res_AskData>().FirstAsync(a => a.IsDel == 0 && a.Id == dto.id);
  2294. if (_AskData == null)
  2295. {
  2296. return Ok(JsonView(true, "暂无数据!", _AskData));
  2297. }
  2298. return Ok(JsonView(true, "查询成功!", _AskData));
  2299. }
  2300. /// <summary>
  2301. /// 请示数据库操作(Status:1.新增,2.修改)
  2302. /// </summary>
  2303. /// <param name="dto"></param>
  2304. /// <returns></returns>
  2305. [HttpPost]
  2306. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2307. public async Task<IActionResult> OpAskData(OpAskDataDto dto)
  2308. {
  2309. Result groupData = await _askDataRep.OpAskData(dto);
  2310. if (groupData.Code != 0)
  2311. {
  2312. return Ok(JsonView(false, groupData.Msg));
  2313. }
  2314. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2315. }
  2316. /// <summary>
  2317. /// 删除请示资料信息
  2318. /// </summary>
  2319. /// <param name="dto"></param>
  2320. /// <returns></returns>
  2321. [HttpPost]
  2322. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2323. public async Task<IActionResult> DelAskData(DelBaseDto dto)
  2324. {
  2325. var res = await _askDataRep.SoftDeleteByIdAsync<Res_AskData>(dto.Id.ToString(), dto.DeleteUserId);
  2326. if (!res)
  2327. {
  2328. return Ok(JsonView(false, "删除失败"));
  2329. }
  2330. return Ok(JsonView(true, "删除成功!"));
  2331. }
  2332. /// <summary>
  2333. /// 请示资料信息
  2334. /// 省外办下载
  2335. /// </summary>
  2336. /// <param name="dto"></param>
  2337. /// <returns></returns>
  2338. [HttpPost]
  2339. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2340. public async Task<IActionResult> AskDataProvinceFAOPFile(AskDataProvinceFileDto dto)
  2341. {
  2342. if (dto.DataIdItem.Length < 1) return Ok(JsonView(false,$"请传入有效的数据Id集合!"));
  2343. if (dto.DiId < 1) return Ok(JsonView(false, $"请传入有效的数据DiId参数!"));
  2344. //大写数字序号
  2345. string[] num = { "一", "二", "三", "四", "五", "六", "七", "八", "九", "十" ,
  2346. "十一","十二","十三","十四","十五","十六","十七","十八","十九","二十",
  2347. "二十一","二十二","二十三","二十四","二十五","二十六","二十七","二十八","二十九","三十",
  2348. "三十一","三十二","三十三","三十四","三十五","三十六","三十七","三十八","三十九","四十"};
  2349. //数据源
  2350. var idItem = dto.DataIdItem.OrderBy(x => x);
  2351. var askDatas = await _sqlSugar.Queryable<Res_AskData>().Where(x => x.IsDel == 0 && idItem.Contains(x.Id)).ToListAsync();
  2352. //书签名
  2353. string Area = "",
  2354. Official = "";
  2355. //表格数据源
  2356. DataTable dt = new DataTable();
  2357. dt.Columns.Add("Country", typeof(string));
  2358. dt.Columns.Add("TalkCase", typeof(string));
  2359. int id = 0;
  2360. int TalkcaseOrder = 0;
  2361. int RowOrder = 0;
  2362. //填充数据
  2363. for (int i = 0; i < askDatas.Count; i++)
  2364. {
  2365. var ad = askDatas[i];
  2366. Area = Area + ad.Country + ad.Area + "、";
  2367. Official = Official + ad.UnitName + "、";
  2368. //填充表格数据源
  2369. DataRow dr = dt.NewRow();
  2370. if (i > 0)
  2371. {
  2372. var adtemp = askDatas[i - 1];
  2373. if (ad.Country == adtemp.Country)
  2374. {
  2375. TalkcaseOrder++;
  2376. dt.Rows[RowOrder]["TalkCase"] = dt.Rows[RowOrder]["TalkCase"] + "\r\n" + (1 + TalkcaseOrder).ToString() + "、" + ad.TalkCase;
  2377. }
  2378. else
  2379. {
  2380. RowOrder++;
  2381. dr = dt.NewRow();
  2382. dr["Country"] = "(" + num[RowOrder] + ")" + ad.Country;
  2383. dr["TalkCase"] = "1、" + ad.TalkCase;
  2384. dt.Rows.Add(dr);
  2385. TalkcaseOrder = 0;
  2386. }
  2387. }
  2388. else
  2389. {
  2390. dr["Country"] = "(" + num[i] + ")" + ad.Country;
  2391. dr["TalkCase"] = "1、" + ad.TalkCase;
  2392. dt.Rows.Add(dr);
  2393. }
  2394. id = ad.Id;
  2395. }
  2396. //模板路径
  2397. var tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/省外办出访请示模板.doc";
  2398. //载入模板
  2399. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  2400. #region 填充word内容
  2401. #region 填充请示内容
  2402. //利用DocumentBuilder处理表格或是书签
  2403. Aspose.Words.DocumentBuilder builder = new DocumentBuilder(doc);
  2404. string bookmark = "";
  2405. try
  2406. {
  2407. for (int i = 0; i < dt.Rows.Count; i++)
  2408. {
  2409. bookmark = bookmark
  2410. + dt.Rows[i]["Country"].ToString() + "\r\n"
  2411. + dt.Rows[i]["TalkCase"].ToString() + "\r\n";
  2412. }
  2413. }
  2414. catch
  2415. {
  2416. }
  2417. #endregion
  2418. #region 填充word模板书签内容
  2419. //团组信息
  2420. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == dto.DiId).FirstAsync();
  2421. //接团客户名单实例
  2422. string client_sql = string.Format(@"
  2423. SELECT
  2424. tcl.Id,
  2425. tcl.DiId,
  2426. tcl.IsAccompany,
  2427. temp.*,
  2428. u.CnName AS Operator,
  2429. tcl.CreateTime AS OperatingTime
  2430. FROM
  2431. Grp_TourClientList tcl
  2432. LEFT JOIN (
  2433. SELECT
  2434. dc.Id AS DcId,
  2435. dc.LastName,
  2436. dc.FirstName,
  2437. ccom.CompanyFullName,
  2438. dc.Job,
  2439. cc.CertNo AS IDCardNo,
  2440. dc.Sex,
  2441. dc.BirthDay
  2442. FROM
  2443. Crm_DeleClient dc
  2444. LEFT JOIN Crm_CustomerCompany ccom ON dc.CrmCompanyId = ccom.Id
  2445. AND ccom.IsDel = 0
  2446. LEFT JOIN Crm_CustomerCert cc ON dc.Id = cc.DcId
  2447. AND cc.SdId = 773
  2448. AND cc.IsDel = 0
  2449. WHERE
  2450. dc.IsDel = 0
  2451. ) temp ON temp.DcId = tcl.ClientId
  2452. LEFT JOIN Sys_Users u ON tcl.CreateUserId = u.Id
  2453. WHERE
  2454. tcl.IsDel = 0
  2455. AND tcl.DiId = {0}", dto.DiId);
  2456. var clientList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(client_sql).ToListAsync();
  2457. //机票代码实例
  2458. DataTable airTable = GeneralMethod.GetTableByBlackCode(dto.DiId);
  2459. //三字码
  2460. var threeCodes = await _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.IsDel == 0 ).ToListAsync();
  2461. //团名
  2462. if (doc.Range.Bookmarks["TeamName"] != null)
  2463. {
  2464. Bookmark mark = doc.Range.Bookmarks["TeamName"];
  2465. mark.Text = di.TeamName;
  2466. }
  2467. //团长名
  2468. if (doc.Range.Bookmarks["ClientName2"] != null)
  2469. {
  2470. Bookmark mark = doc.Range.Bookmarks["ClientName2"];
  2471. if (clientList == null || clientList.Count == 0)
  2472. {
  2473. mark.Text = "【本团尚未录入客户名单,请联系主管!】";
  2474. }
  2475. else
  2476. {
  2477. mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
  2478. }
  2479. }
  2480. if (doc.Range.Bookmarks["ClientName"] != null)
  2481. {
  2482. Bookmark mark = doc.Range.Bookmarks["ClientName"];
  2483. if (clientList == null || clientList.Count == 0)
  2484. {
  2485. mark.Text = "【本团尚未录入客户名单,请联系主管!】";
  2486. }
  2487. else
  2488. {
  2489. mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
  2490. }
  2491. }
  2492. //跟团人数
  2493. if (doc.Range.Bookmarks["ClientNumber2"] != null)
  2494. {
  2495. Bookmark mark = doc.Range.Bookmarks["ClientNumber2"];
  2496. mark.Text = di.VisitPNumber.ToString();
  2497. }
  2498. if (doc.Range.Bookmarks["ClientNumber"] != null)
  2499. {
  2500. Bookmark mark = doc.Range.Bookmarks["ClientNumber"];
  2501. mark.Text = di.VisitPNumber.ToString();
  2502. }
  2503. //地区
  2504. if (doc.Range.Bookmarks["Area"] != null)
  2505. {
  2506. Bookmark mark = doc.Range.Bookmarks["Area"];
  2507. mark.Text = Area.TrimEnd('、');
  2508. }
  2509. if (doc.Range.Bookmarks["Area2"] != null)
  2510. {
  2511. Bookmark mark = doc.Range.Bookmarks["Area2"];
  2512. mark.Text = Area.TrimEnd('、');
  2513. }
  2514. //出访目的
  2515. if (doc.Range.Bookmarks["Destination2"] != null)
  2516. {
  2517. Bookmark mark = doc.Range.Bookmarks["Destination2"];
  2518. mark.Text = di.VisitPurpose;
  2519. }
  2520. if (doc.Range.Bookmarks["Destination"] != null)
  2521. {
  2522. Bookmark mark = doc.Range.Bookmarks["Destination"];
  2523. mark.Text = di.VisitPurpose;
  2524. }
  2525. //邀请方
  2526. if (doc.Range.Bookmarks["Official"] != null)
  2527. {
  2528. Bookmark mark = doc.Range.Bookmarks["Official"];
  2529. mark.Text = Official.TrimEnd('、');
  2530. }
  2531. //出访日期
  2532. if (doc.Range.Bookmarks["VisitDate"] != null)
  2533. {
  2534. Bookmark mark = doc.Range.Bookmarks["VisitDate"];
  2535. mark.Text = di.VisitStartDate.Year + "年"
  2536. + di.VisitStartDate.Month + "月"
  2537. + di.VisitStartDate.Day + "日"
  2538. + "至"
  2539. + di.VisitEndDate.Month + "月"
  2540. + di.VisitEndDate.Day + "日";
  2541. }
  2542. //请示范例
  2543. if (doc.Range.Bookmarks["Temp"] != null)
  2544. {
  2545. Bookmark mark = doc.Range.Bookmarks["Temp"];
  2546. mark.Text = bookmark;
  2547. }
  2548. //出访起止日期
  2549. if (doc.Range.Bookmarks["Duration"] != null)
  2550. {
  2551. Bookmark mark = doc.Range.Bookmarks["Duration"];
  2552. mark.Text = di.VisitStartDate.Year + "年"
  2553. + di.VisitStartDate.Month + "月"
  2554. + di.VisitStartDate.Day + "日"
  2555. + "至"
  2556. + di.VisitEndDate.Month + "月"
  2557. + di.VisitEndDate.Day + "日";
  2558. }
  2559. //出访天数
  2560. if (doc.Range.Bookmarks["Durationdays"] != null)
  2561. {
  2562. Bookmark mark = doc.Range.Bookmarks["Durationdays"];
  2563. mark.Text = di.VisitDays.ToString();
  2564. }
  2565. if (doc.Range.Bookmarks["Durationdays2"] != null)
  2566. {
  2567. Bookmark mark = doc.Range.Bookmarks["Durationdays2"];
  2568. mark.Text = di.VisitDays.ToString();
  2569. }
  2570. #region 根据黑屏代码获取国家呆的天数;获取路线
  2571. string result_CountryAndDay = "", result_Air = "";
  2572. if (airTable.Rows[airTable.Rows.Count - 1]["Day"].ToString() == "")
  2573. {
  2574. result_CountryAndDay = airTable.Rows[airTable.Rows.Count - 1]["Fliagtcode"].ToString();
  2575. result_Air = result_CountryAndDay;
  2576. }
  2577. else
  2578. {
  2579. string place_start, place_end;
  2580. DateTime time_start, time_end;
  2581. Res_ThreeCode three = null;
  2582. for (int i = 0; i < airTable.Rows.Count; i++)
  2583. {
  2584. //三字码实例
  2585. three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(0, 3));
  2586. if (three == null)
  2587. {
  2588. place_start = "【未收录三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
  2589. }
  2590. else
  2591. {
  2592. if (string.IsNullOrEmpty(three.Country))
  2593. {
  2594. place_start = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
  2595. }
  2596. else
  2597. {
  2598. place_start = three.City;
  2599. }
  2600. }
  2601. three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(3, 3));
  2602. if (three == null)
  2603. {
  2604. place_end = "【未收录" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
  2605. }
  2606. else
  2607. {
  2608. if (string.IsNullOrEmpty(three.Country))
  2609. {
  2610. place_end = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
  2611. }
  2612. else
  2613. {
  2614. place_end = three.City;
  2615. }
  2616. }
  2617. result_Air += place_start + "一" + place_end + "一";
  2618. //获取国家和呆的天数
  2619. if (i > 0 && i < airTable.Rows.Count - 1)
  2620. {
  2621. time_start = Convert.ToDateTime(airTable.Rows[i - 1]["Day"]);
  2622. time_end = Convert.ToDateTime(airTable.Rows[i]["Day"]);
  2623. TimeSpan daycount = time_end.Subtract(time_start);
  2624. result_CountryAndDay += place_start + daycount.Days + "天" + ",";
  2625. }
  2626. }
  2627. }
  2628. #endregion
  2629. //每个国家呆的天数
  2630. if (doc.Range.Bookmarks["CountryAndDay"] != null)
  2631. {
  2632. Bookmark mark = doc.Range.Bookmarks["CountryAndDay"];
  2633. mark.Text = result_CountryAndDay.TrimEnd(',');
  2634. }
  2635. #region 出访路线城市字符串去重
  2636. result_Air = result_Air.TrimEnd('一');
  2637. string[] airTemp = result_Air.Split('一');
  2638. airTemp = airTemp.Distinct().ToArray();
  2639. result_Air = "";
  2640. foreach (string str in airTemp)
  2641. {
  2642. result_Air += str + "一";
  2643. }
  2644. result_Air = result_Air + airTemp[0];
  2645. #endregion
  2646. //出访路线
  2647. if (doc.Range.Bookmarks["Air"] != null)
  2648. {
  2649. Bookmark mark = doc.Range.Bookmarks["Air"];
  2650. mark.Text = result_Air;
  2651. }
  2652. #endregion
  2653. #region 客户名单
  2654. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  2655. Aspose.Words.Tables.Table tableClient = allTables[0] as Aspose.Words.Tables.Table;
  2656. if (clientList == null || clientList.Count == 0)
  2657. {
  2658. builder.MoveToCell(0, 1, 0, 0);
  2659. builder.Write("【本团尚未录入客户名单,请联系主管!】");
  2660. }
  2661. else
  2662. {
  2663. for (int i = 0; i < clientList.Count(); i++)
  2664. {
  2665. builder.MoveToCell(0, i + 1, 0, 0);
  2666. builder.Write((i + 1).ToString());
  2667. builder.MoveToCell(0, i + 1, 1, 0);
  2668. builder.Write(clientList[i].LastName.ToString() + clientList[i].FirstName.ToString());
  2669. builder.MoveToCell(0, i + 1, 2, 0);
  2670. builder.Write(clientList[i].Sex.ToString());
  2671. builder.MoveToCell(0, i + 1, 3, 0);
  2672. builder.Write(clientList[i].BirthDay);
  2673. builder.MoveToCell(0, i + 1, 4, 0);
  2674. builder.Write(clientList[i].CompanyFullName + clientList[i].Job.ToString());
  2675. }
  2676. }
  2677. while (tableClient.Rows.Count > clientList.Count + 1)
  2678. {
  2679. tableClient.Rows.RemoveAt(clientList.Count + 1);
  2680. }
  2681. #endregion
  2682. #region 商邀行程
  2683. string content = "", temp1 = "", temp2 = "";
  2684. //获取数据,放到datatable
  2685. var listapt = await _sqlSugar.Queryable<Grp_ApprovalTravel>()
  2686. .LeftJoin<Grp_ApprovalTravelDetails>((at, atd) => at.Id == atd.ParentId)
  2687. .Where((at, atd) => at.IsDel == 0 && at.Diid == dto.DiId)
  2688. .Select((at, atd) => new
  2689. {
  2690. at.Id,
  2691. at.Date,
  2692. atd.Time,
  2693. atd.Details
  2694. })
  2695. .ToListAsync();
  2696. if (listapt == null || listapt.Count == 0)
  2697. {
  2698. content = "尚未生成商邀行程";
  2699. }
  2700. else
  2701. {
  2702. for (int i = 0; i < listapt.Count; i++)
  2703. {
  2704. content = content + " " + listapt[i].Date + "\r\n";
  2705. temp1 = listapt[i].Time;
  2706. temp2 = listapt[i].Details;
  2707. if (!string.IsNullOrEmpty(temp1))
  2708. {
  2709. string[] str = temp1.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2710. string[] str2 = temp2.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2711. for (int j = 0; j < str.Count(); j++)
  2712. {
  2713. content = content + " " + str[j] + str2[j] + "\r\n";
  2714. }
  2715. }
  2716. }
  2717. }
  2718. if (doc.Range.Bookmarks["Content"] != null)
  2719. {
  2720. Bookmark mark = doc.Range.Bookmarks["Content"];
  2721. mark.Text = content;
  2722. }
  2723. while (tableClient.Rows.Count > 1 + clientList.Count)
  2724. {
  2725. tableClient.Rows.RemoveAt(1 + clientList.Count);
  2726. }
  2727. #endregion
  2728. #endregion
  2729. string strFileName = $"/AskData/省外办出访请示{Guid.NewGuid().ToString()}.doc";
  2730. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  2731. var url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  2732. return Ok(JsonView(true,"操作成功!",new { url = url }));
  2733. }
  2734. /// <summary>
  2735. /// 请示资料信息
  2736. /// 市外办下载
  2737. /// </summary>
  2738. /// <param name="dto"></param>
  2739. /// <returns></returns>
  2740. [HttpPost]
  2741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2742. public async Task<IActionResult> AskDataCityFAOPFile(AskDataProvinceFileDto dto)
  2743. {
  2744. if (dto.DataIdItem.Length < 1) return Ok(JsonView(false, $"请传入有效的数据Id集合!"));
  2745. if (dto.DiId < 1) return Ok(JsonView(false, $"请传入有效的数据DiId参数!"));
  2746. //大写数字序号
  2747. string[] num = { "一", "二", "三", "四", "五", "六", "七", "八", "九", "十" ,
  2748. "十一","十二","十三","十四","十五","十六","十七","十八","十九","二十",
  2749. "二十一","二十二","二十三","二十四","二十五","二十六","二十七","二十八","二十九","三十",
  2750. "三十一","三十二","三十三","三十四","三十五","三十六","三十七","三十八","三十九","四十"};
  2751. //数据源
  2752. var idItem = dto.DataIdItem.OrderBy(x => x);
  2753. var askDatas = await _sqlSugar.Queryable<Res_AskData>().Where(x => x.IsDel == 0 && idItem.Contains(x.Id)).ToListAsync();
  2754. //书签名
  2755. string Area = "",
  2756. Official = "";
  2757. //表格数据源
  2758. DataTable dt = new DataTable();
  2759. dt.Columns.Add("Country", typeof(string));
  2760. dt.Columns.Add("TalkCase", typeof(string));
  2761. int id = 0;
  2762. int TalkcaseOrder = 0;
  2763. int RowOrder = 0;
  2764. //填充数据
  2765. for (int i = 0; i < askDatas.Count; i++)
  2766. {
  2767. var ad = askDatas[i];
  2768. Area = Area + ad.Country + ad.Area + "、";
  2769. Official = Official + ad.UnitName + "、";
  2770. //填充表格数据源
  2771. DataRow dr = dt.NewRow();
  2772. if (i > 0)
  2773. {
  2774. var adtemp = askDatas[i - 1];
  2775. if (ad.Country == adtemp.Country)
  2776. {
  2777. TalkcaseOrder++;
  2778. dt.Rows[RowOrder]["TalkCase"] = dt.Rows[RowOrder]["TalkCase"] + "\r\n" + (1 + TalkcaseOrder).ToString() + "、" + ad.TalkCase;
  2779. }
  2780. else
  2781. {
  2782. RowOrder++;
  2783. dr = dt.NewRow();
  2784. dr["Country"] = "(" + num[RowOrder] + ")" + ad.Country;
  2785. dr["TalkCase"] = "1、" + ad.TalkCase;
  2786. dt.Rows.Add(dr);
  2787. TalkcaseOrder = 0;
  2788. }
  2789. }
  2790. else
  2791. {
  2792. dr["Country"] = "(" + num[i] + ")" + ad.Country;
  2793. dr["TalkCase"] = "1、" + ad.TalkCase;
  2794. dt.Rows.Add(dr);
  2795. }
  2796. id = ad.Id;
  2797. }
  2798. //模板路径
  2799. var tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/市外办出访请示.doc";
  2800. //载入模板
  2801. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  2802. #region 填充word内容
  2803. #region 填充请示内容
  2804. //利用DocumentBuilder处理表格或是书签
  2805. Aspose.Words.DocumentBuilder builder = new DocumentBuilder(doc);
  2806. string bookmark = "";
  2807. try
  2808. {
  2809. for (int i = 0; i < dt.Rows.Count; i++)
  2810. {
  2811. bookmark = bookmark
  2812. + dt.Rows[i]["Country"].ToString() + "\r\n"
  2813. + dt.Rows[i]["TalkCase"].ToString() + "\r\n";
  2814. }
  2815. }
  2816. catch
  2817. {
  2818. }
  2819. #endregion
  2820. #region 填充word模板书签内容
  2821. //团组信息
  2822. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == dto.DiId).FirstAsync();
  2823. //接团客户名单实例
  2824. string client_sql = string.Format(@"
  2825. SELECT
  2826. tcl.Id,
  2827. tcl.DiId,
  2828. tcl.IsAccompany,
  2829. temp.*,
  2830. u.CnName AS Operator,
  2831. tcl.CreateTime AS OperatingTime
  2832. FROM
  2833. Grp_TourClientList tcl
  2834. LEFT JOIN (
  2835. SELECT
  2836. dc.Id AS DcId,
  2837. dc.LastName,
  2838. dc.FirstName,
  2839. ccom.CompanyFullName,
  2840. dc.Job,
  2841. cc.CertNo AS IDCardNo,
  2842. dc.Sex,
  2843. dc.BirthDay
  2844. FROM
  2845. Crm_DeleClient dc
  2846. LEFT JOIN Crm_CustomerCompany ccom ON dc.CrmCompanyId = ccom.Id
  2847. AND ccom.IsDel = 0
  2848. LEFT JOIN Crm_CustomerCert cc ON dc.Id = cc.DcId
  2849. AND cc.SdId = 773
  2850. AND cc.IsDel = 0
  2851. WHERE
  2852. dc.IsDel = 0
  2853. ) temp ON temp.DcId = tcl.ClientId
  2854. LEFT JOIN Sys_Users u ON tcl.CreateUserId = u.Id
  2855. WHERE
  2856. tcl.IsDel = 0
  2857. AND tcl.DiId = {0}", dto.DiId);
  2858. var clientList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(client_sql).ToListAsync();
  2859. //机票代码实例
  2860. DataTable airTable = GeneralMethod.GetTableByBlackCode(dto.DiId);
  2861. //三字码
  2862. var threeCodes = await _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.IsDel == 0).ToListAsync();
  2863. //团名
  2864. if (doc.Range.Bookmarks["TeamName"] != null)
  2865. {
  2866. Bookmark mark = doc.Range.Bookmarks["TeamName"];
  2867. mark.Text = di.TeamName;
  2868. }
  2869. //团长名
  2870. if (doc.Range.Bookmarks["ClientName2"] != null)
  2871. {
  2872. Bookmark mark = doc.Range.Bookmarks["ClientName2"];
  2873. if (clientList == null || clientList.Count == 0)
  2874. {
  2875. mark.Text = "【本团尚未录入客户名单,请联系主管!】";
  2876. }
  2877. else
  2878. {
  2879. mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
  2880. }
  2881. }
  2882. if (doc.Range.Bookmarks["ClientName"] != null)
  2883. {
  2884. Bookmark mark = doc.Range.Bookmarks["ClientName"];
  2885. if (clientList == null || clientList.Count == 0)
  2886. {
  2887. mark.Text = "【本团尚未录入客户名单,请联系主管!】";
  2888. }
  2889. else
  2890. {
  2891. mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
  2892. }
  2893. }
  2894. //跟团人数
  2895. if (doc.Range.Bookmarks["ClientNumber2"] != null)
  2896. {
  2897. Bookmark mark = doc.Range.Bookmarks["ClientNumber2"];
  2898. mark.Text = di.VisitPNumber.ToString();
  2899. }
  2900. if (doc.Range.Bookmarks["ClientNumber"] != null)
  2901. {
  2902. Bookmark mark = doc.Range.Bookmarks["ClientNumber"];
  2903. mark.Text = di.VisitPNumber.ToString();
  2904. }
  2905. //地区
  2906. if (doc.Range.Bookmarks["Area"] != null)
  2907. {
  2908. Bookmark mark = doc.Range.Bookmarks["Area"];
  2909. mark.Text = Area.TrimEnd('、');
  2910. }
  2911. if (doc.Range.Bookmarks["Area2"] != null)
  2912. {
  2913. Bookmark mark = doc.Range.Bookmarks["Area2"];
  2914. mark.Text = Area.TrimEnd('、');
  2915. }
  2916. //出访目的
  2917. if (doc.Range.Bookmarks["Destination2"] != null)
  2918. {
  2919. Bookmark mark = doc.Range.Bookmarks["Destination2"];
  2920. mark.Text = di.VisitPurpose;
  2921. }
  2922. if (doc.Range.Bookmarks["Destination"] != null)
  2923. {
  2924. Bookmark mark = doc.Range.Bookmarks["Destination"];
  2925. mark.Text = di.VisitPurpose;
  2926. }
  2927. //邀请方
  2928. if (doc.Range.Bookmarks["Official"] != null)
  2929. {
  2930. Bookmark mark = doc.Range.Bookmarks["Official"];
  2931. mark.Text = Official.TrimEnd('、');
  2932. }
  2933. //出访日期
  2934. if (doc.Range.Bookmarks["VisitDate"] != null)
  2935. {
  2936. Bookmark mark = doc.Range.Bookmarks["VisitDate"];
  2937. mark.Text = di.VisitStartDate.Year + "年"
  2938. + di.VisitStartDate.Month + "月"
  2939. + di.VisitStartDate.Day + "日"
  2940. + "至"
  2941. + di.VisitEndDate.Month + "月"
  2942. + di.VisitEndDate.Day + "日";
  2943. }
  2944. //请示范例
  2945. if (doc.Range.Bookmarks["Temp"] != null)
  2946. {
  2947. Bookmark mark = doc.Range.Bookmarks["Temp"];
  2948. mark.Text = bookmark;
  2949. }
  2950. //出访起止日期
  2951. if (doc.Range.Bookmarks["Duration"] != null)
  2952. {
  2953. Bookmark mark = doc.Range.Bookmarks["Duration"];
  2954. mark.Text = di.VisitStartDate.Year + "年"
  2955. + di.VisitStartDate.Month + "月"
  2956. + di.VisitStartDate.Day + "日"
  2957. + "至"
  2958. + di.VisitEndDate.Month + "月"
  2959. + di.VisitEndDate.Day + "日";
  2960. }
  2961. //出访天数
  2962. if (doc.Range.Bookmarks["Durationdays"] != null)
  2963. {
  2964. Bookmark mark = doc.Range.Bookmarks["Durationdays"];
  2965. mark.Text = di.VisitDays.ToString();
  2966. }
  2967. if (doc.Range.Bookmarks["Durationdays2"] != null)
  2968. {
  2969. Bookmark mark = doc.Range.Bookmarks["Durationdays2"];
  2970. mark.Text = di.VisitDays.ToString();
  2971. }
  2972. #region 根据黑屏代码获取国家呆的天数;获取路线
  2973. string result_CountryAndDay = "", result_Air = "";
  2974. if (airTable.Rows[airTable.Rows.Count - 1]["Day"].ToString() == "")
  2975. {
  2976. result_CountryAndDay = airTable.Rows[airTable.Rows.Count - 1]["Fliagtcode"].ToString();
  2977. result_Air = result_CountryAndDay;
  2978. }
  2979. else
  2980. {
  2981. string place_start, place_end;
  2982. DateTime time_start, time_end;
  2983. Res_ThreeCode three = null;
  2984. for (int i = 0; i < airTable.Rows.Count; i++)
  2985. {
  2986. //三字码实例
  2987. three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(0, 3));
  2988. if (three == null)
  2989. {
  2990. place_start = "【未收录三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
  2991. }
  2992. else
  2993. {
  2994. if (string.IsNullOrEmpty(three.Country))
  2995. {
  2996. place_start = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
  2997. }
  2998. else
  2999. {
  3000. place_start = three.City;
  3001. }
  3002. }
  3003. three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(3, 3));
  3004. if (three == null)
  3005. {
  3006. place_end = "【未收录" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
  3007. }
  3008. else
  3009. {
  3010. if (string.IsNullOrEmpty(three.Country))
  3011. {
  3012. place_end = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
  3013. }
  3014. else
  3015. {
  3016. place_end = three.City;
  3017. }
  3018. }
  3019. result_Air += place_start + "一" + place_end + "一";
  3020. //获取国家和呆的天数
  3021. if (i > 0 && i < airTable.Rows.Count - 1)
  3022. {
  3023. time_start = Convert.ToDateTime(airTable.Rows[i - 1]["Day"]);
  3024. time_end = Convert.ToDateTime(airTable.Rows[i]["Day"]);
  3025. TimeSpan daycount = time_end.Subtract(time_start);
  3026. result_CountryAndDay += place_start + daycount.Days + "天" + ",";
  3027. }
  3028. }
  3029. }
  3030. #endregion
  3031. //每个国家呆的天数
  3032. if (doc.Range.Bookmarks["CountryAndDay"] != null)
  3033. {
  3034. Bookmark mark = doc.Range.Bookmarks["CountryAndDay"];
  3035. mark.Text = result_CountryAndDay.TrimEnd(',');
  3036. }
  3037. #region 出访路线城市字符串去重
  3038. result_Air = result_Air.TrimEnd('一');
  3039. string[] airTemp = result_Air.Split('一');
  3040. airTemp = airTemp.Distinct().ToArray();
  3041. result_Air = "";
  3042. foreach (string str in airTemp)
  3043. {
  3044. result_Air += str + "一";
  3045. }
  3046. result_Air = result_Air + airTemp[0];
  3047. #endregion
  3048. //出访路线
  3049. if (doc.Range.Bookmarks["Air"] != null)
  3050. {
  3051. Bookmark mark = doc.Range.Bookmarks["Air"];
  3052. mark.Text = result_Air;
  3053. }
  3054. #endregion
  3055. #region 客户名单
  3056. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3057. Aspose.Words.Tables.Table tableClient = allTables[0] as Aspose.Words.Tables.Table;
  3058. if (clientList == null || clientList.Count == 0)
  3059. {
  3060. builder.MoveToCell(0, 1, 0, 0);
  3061. builder.Write("【本团尚未录入客户名单,请联系主管!】");
  3062. }
  3063. else
  3064. {
  3065. for (int i = 0; i < clientList.Count(); i++)
  3066. {
  3067. builder.MoveToCell(0, i + 1, 0, 0);
  3068. builder.Write((i + 1).ToString());
  3069. builder.MoveToCell(0, i + 1, 1, 0);
  3070. builder.Write(clientList[i].LastName.ToString() + clientList[i].FirstName.ToString());
  3071. builder.MoveToCell(0, i + 1, 2, 0);
  3072. builder.Write(clientList[i].Sex.ToString());
  3073. builder.MoveToCell(0, i + 1, 3, 0);
  3074. builder.Write(clientList[i].BirthDay);
  3075. builder.MoveToCell(0, i + 1, 4, 0);
  3076. builder.Write(clientList[i].CompanyFullName + clientList[i].Job.ToString());
  3077. }
  3078. }
  3079. while (tableClient.Rows.Count > clientList.Count + 1)
  3080. {
  3081. tableClient.Rows.RemoveAt(clientList.Count + 1);
  3082. }
  3083. #endregion
  3084. #region 商邀行程
  3085. string content = "", temp1 = "", temp2 = "";
  3086. //获取数据,放到datatable
  3087. var listapt = await _sqlSugar.Queryable<Grp_ApprovalTravel>()
  3088. .LeftJoin<Grp_ApprovalTravelDetails>((at, atd) => at.Id == atd.ParentId)
  3089. .Where((at, atd) => at.IsDel == 0 && at.Diid == dto.DiId)
  3090. .Select((at, atd) => new
  3091. {
  3092. at.Id,
  3093. at.Date,
  3094. atd.Time,
  3095. atd.Details
  3096. })
  3097. .ToListAsync();
  3098. if (listapt == null || listapt.Count == 0)
  3099. {
  3100. content = "尚未生成商邀行程";
  3101. }
  3102. else
  3103. {
  3104. for (int i = 0; i < listapt.Count; i++)
  3105. {
  3106. content = content + " " + listapt[i].Date + "\r\n";
  3107. temp1 = listapt[i].Time;
  3108. temp2 = listapt[i].Details;
  3109. if (!string.IsNullOrEmpty(temp1))
  3110. {
  3111. string[] str = temp1.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3112. string[] str2 = temp2.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3113. for (int j = 0; j < str.Count(); j++)
  3114. {
  3115. content = content + " " + str[j] + str2[j] + "\r\n";
  3116. }
  3117. }
  3118. }
  3119. }
  3120. if (doc.Range.Bookmarks["Content"] != null)
  3121. {
  3122. Bookmark mark = doc.Range.Bookmarks["Content"];
  3123. mark.Text = content;
  3124. }
  3125. while (tableClient.Rows.Count > 1 + clientList.Count)
  3126. {
  3127. tableClient.Rows.RemoveAt(1 + clientList.Count);
  3128. }
  3129. #endregion
  3130. #endregion
  3131. string strFileName = $"/AskData/市外办出访请示{Guid.NewGuid().ToString()}.doc";
  3132. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  3133. var url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  3134. return Ok(JsonView(true, "操作成功!", new { url = url }));
  3135. }
  3136. #endregion
  3137. #region 机票黑屏代码
  3138. /// <summary>
  3139. /// 根据团组Id查询黑屏代码列表
  3140. /// </summary>
  3141. /// <param name="dto"></param>
  3142. /// <returns></returns>
  3143. [HttpPost]
  3144. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3145. public async Task<IActionResult> QueryTicketBlackCodeByDiId(QueryTicketBlackCodeByDiIdDto dto)
  3146. {
  3147. try
  3148. {
  3149. Result groupData = await _ticketBlackCodeRep.QueryTicketBlackCodeByDiId(dto);
  3150. if (groupData.Code != 0)
  3151. {
  3152. return Ok(JsonView(false, groupData.Msg));
  3153. }
  3154. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3155. }
  3156. catch (Exception ex)
  3157. {
  3158. return Ok(JsonView(false, "程序错误!"));
  3159. throw;
  3160. }
  3161. }
  3162. /// <summary>
  3163. /// 根据黑屏代码数据Id查询信息
  3164. /// </summary>
  3165. /// <param name="dto"></param>
  3166. /// <returns></returns>
  3167. [HttpPost]
  3168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3169. public async Task<IActionResult> QueryTicketBlackCodeById(QueryTicketBlackCodeByIdDto dto)
  3170. {
  3171. try
  3172. {
  3173. Result groupData = await _ticketBlackCodeRep.QueryTicketBlackCodeById(dto);
  3174. if (groupData.Code != 0)
  3175. {
  3176. return Ok(JsonView(false, groupData.Msg));
  3177. }
  3178. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3179. }
  3180. catch (Exception ex)
  3181. {
  3182. return Ok(JsonView(false, "程序错误!"));
  3183. throw;
  3184. }
  3185. }
  3186. /// <summary>
  3187. /// 黑屏代码操作(Status:1.新增,2.修改)
  3188. /// </summary>
  3189. /// <param name="dto"></param>
  3190. /// <returns></returns>
  3191. [HttpPost]
  3192. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3193. public async Task<IActionResult> OpTicketBlackCode(OpTicketBlackCodeDto dto)
  3194. {
  3195. Result groupData = await _ticketBlackCodeRep.OpTicketBlackCode(dto);
  3196. if (groupData.Code != 0)
  3197. {
  3198. return Ok(JsonView(false, groupData.Msg));
  3199. }
  3200. try
  3201. {
  3202. var tongzhi = _ticketBlackCodeRep.DescBlackToVisa(dto.DiId);
  3203. if (tongzhi.Code == 0)
  3204. {
  3205. var info = tongzhi.Data.GetType().GetProperty("info").GetValue(tongzhi.Data) as List<string>;
  3206. var data = tongzhi.Data.GetType().GetProperty("data").GetValue(tongzhi.Data) as List<CountryDataTime>;
  3207. if (data != null)
  3208. await AppNoticeLibrary.SendUserMsg_blackAirInfo_ToVisaUser(dto.DiId, data);
  3209. }
  3210. //行程代码变更通知
  3211. await AppNoticeLibrary.SendUserMsg_GroupShare_ToDP(dto.DiId, dto.CreateUserId);
  3212. }
  3213. catch (Exception ex)
  3214. {
  3215. throw;
  3216. }
  3217. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3218. }
  3219. /// <summary>
  3220. /// 删除黑屏代码
  3221. /// </summary>
  3222. /// <param name="dto"></param>
  3223. /// <returns></returns>
  3224. [HttpPost]
  3225. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3226. public async Task<IActionResult> DelTicketBlackCode(DelBaseDto dto)
  3227. {
  3228. try
  3229. {
  3230. var res = await _ticketBlackCodeRep.SoftDeleteByIdAsync<Air_TicketBlackCode>(dto.Id.ToString(), dto.DeleteUserId);
  3231. if (!res)
  3232. {
  3233. return Ok(JsonView(false, "删除失败"));
  3234. }
  3235. return Ok(JsonView(true, "删除成功!"));
  3236. }
  3237. catch (Exception ex)
  3238. {
  3239. return Ok(JsonView(false, "程序错误!"));
  3240. throw;
  3241. }
  3242. }
  3243. #endregion
  3244. #region 翻译人员
  3245. /// <summary>
  3246. /// 翻译人员库
  3247. /// Init
  3248. /// </summary>
  3249. /// <param name="id"></param>
  3250. /// <returns></returns>
  3251. [HttpGet()]
  3252. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3253. public async Task<IActionResult> TranslatorLibraryInit()
  3254. {
  3255. var currencyData = await _sqlSugar.Queryable<Sys_SetData>()
  3256. .Where(x => x.IsDel == 0 && x.STid == 66)
  3257. .Select(x => new {
  3258. x.Id,
  3259. x.Name,
  3260. })
  3261. .ToListAsync();
  3262. var officialDutyData = await _sqlSugar.Queryable<Res_OfficialActivities>()
  3263. .LeftJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  3264. .Where((oa, di) => oa.IsDel == 0)
  3265. .Select((oa, di) => new
  3266. {
  3267. oa.Id,
  3268. oa.Client,
  3269. oa.DiId,
  3270. di.TeamName
  3271. })
  3272. .ToListAsync();
  3273. var officialDutyData1 = officialDutyData.GroupBy(x => x.DiId)
  3274. .Select(g => new {
  3275. id = g.Key,
  3276. label = g.FirstOrDefault()?.TeamName ?? "-",
  3277. children = g.Select(g1 => new { id = g1.Id, label = g1.Client }).ToList()
  3278. })
  3279. .ToList();
  3280. var view = new {
  3281. currencyData = currencyData,
  3282. officialDutyData = officialDutyData1
  3283. };
  3284. return Ok(JsonView(view));
  3285. }
  3286. /// <summary>
  3287. /// 翻译人员库
  3288. /// 详情
  3289. /// </summary>
  3290. /// <param name="id"></param>
  3291. /// <returns></returns>
  3292. [HttpGet("id")]
  3293. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3294. public async Task<IActionResult> TranslatorLibraryInfo(int id)
  3295. {
  3296. if (id <1 ) return Ok(JsonView(false,"请传入有效的Id!"));
  3297. var info = await _translatorRep.Query(x => x.Id == id).FirstAsync();
  3298. var view = _mapper.Map<TranslatorLibraryInfoView>(info);
  3299. //var data1 = await _sqlSugar.Queryable<Grp_OfficialDutyLinkTranslator>().Where(x => x.TranslatorId == id).Select(x => x.Id).ToArrayAsync();
  3300. view.OfficialDutyIdItem = await _sqlSugar
  3301. .Queryable<Grp_OfficialDutyLinkTranslator>()
  3302. .Where(x => x.IsDel == 0 && x.TranslatorId == id)
  3303. .Select(x => x.OfficialDutyId)
  3304. .ToArrayAsync();
  3305. return Ok(JsonView(view));
  3306. }
  3307. /// <summary>
  3308. /// 翻译人员库
  3309. /// Item
  3310. /// </summary>
  3311. /// <param name="dto"></param>
  3312. /// <returns></returns>
  3313. [HttpPost]
  3314. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3315. public async Task<IActionResult> TranslatorLibraryItem(TranslatorLibraryItemDto dto)
  3316. {
  3317. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  3318. RefAsync<int> total = 0;
  3319. var view = await _sqlSugar.Queryable<Res_TranslatorLibrary>()
  3320. .Where(x => x.IsDel == 0)
  3321. .WhereIF(!string.IsNullOrEmpty(dto.Name), x => x.Name.Contains(dto.Name))
  3322. .Select(x => new
  3323. {
  3324. x.Id,
  3325. x.Area,
  3326. x.Name,
  3327. Sex = x.Sex == 0 ? "未设置" : x.Sex == 1 ? "男" : "女",
  3328. x.Tel,
  3329. x.Email,
  3330. x.WechatNo,
  3331. x.Language,
  3332. x.Price,
  3333. //x.Currency,
  3334. Currency = SqlFunc.Subqueryable<Sys_SetData>().Where(x1 => x1.Id == x.Currency).Select(x1 => x1.Name) ?? "-",
  3335. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x1.Id == x.CreateUserId).Select(x1 => x1.CnName) ?? "-",
  3336. x.CreateTime,
  3337. x.Remark
  3338. })
  3339. .OrderByDescending(x => x.CreateTime)
  3340. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  3341. return Ok(JsonView(view, total));
  3342. }
  3343. /// <summary>
  3344. /// 翻译人员库
  3345. /// OP
  3346. /// </summary>
  3347. /// <param name="dto"></param>
  3348. /// <returns></returns>
  3349. [HttpPost]
  3350. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3351. public async Task<IActionResult> TranslatorLibraryOp([FromForm]TranslatorLibraryOpDto dto)
  3352. {
  3353. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  3354. if (dto.Status < 1 || dto.Status > 2) return Ok(JsonView(false, MsgTips.Status));
  3355. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  3356. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  3357. var fileNames = new List<string>();
  3358. //D:\FTP\File\OA2023\Office\GrpFile\TranslatorLibrary
  3359. var fileBasePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}TranslatorLibrary";
  3360. #region 保存文件
  3361. if (dto.Files != null)
  3362. {
  3363. if (!System.IO.Directory.Exists(fileBasePath))
  3364. {
  3365. System.IO.Directory.CreateDirectory(fileBasePath);
  3366. }
  3367. foreach (var item in dto.Files)
  3368. {
  3369. if (item.Length < 1) continue;
  3370. var file = item;
  3371. // 将文件保存到指定位置
  3372. var filePath = Path.Combine(fileBasePath, file.FileName);
  3373. using (var stream = new FileStream(filePath, FileMode.Create))
  3374. {
  3375. await file.CopyToAsync(stream);
  3376. }
  3377. //验证文件是否上传成功
  3378. if (!System.IO.File.Exists(filePath))
  3379. {
  3380. foreach (var filePathStr in fileNames)
  3381. {
  3382. System.IO.File.Delete(Path.Combine(fileBasePath, filePathStr));
  3383. }
  3384. return Ok(JsonView(false, "文件上传失败!"));
  3385. }
  3386. fileNames.Add(file.FileName);
  3387. }
  3388. }
  3389. #endregion
  3390. #region 参数处理
  3391. var translatorInfo = _mapper.Map<Res_TranslatorLibrary>(dto);
  3392. #endregion
  3393. _sqlSugar.BeginTran();
  3394. if (dto.Status == 1)
  3395. {
  3396. //验证重复
  3397. var info = await _translatorRep.Query(x => x.Area.Equals(dto.Area) && x.Name.Equals(dto.Name)).FirstAsync();
  3398. if (info != null) return Ok(JsonView(false, "该条数据已存在!"));
  3399. translatorInfo.CreateUserId = currUserInfo.UserId;
  3400. if (fileNames.Count > 0)
  3401. {
  3402. translatorInfo.Files = JsonConvert.SerializeObject(fileNames);
  3403. }
  3404. var id = await _translatorRep.AddAsync(translatorInfo);
  3405. if (id > 0) {
  3406. #region 新增(公务信息关联翻译人员) 关联信息
  3407. if (dto.officialDutyIdItem != null && dto.officialDutyIdItem.Length > 0)
  3408. {
  3409. var officialDutyLinkTranslators = new List<Grp_OfficialDutyLinkTranslator>();
  3410. foreach (var officialDutyId in dto.officialDutyIdItem)
  3411. {
  3412. officialDutyLinkTranslators.Add(new Grp_OfficialDutyLinkTranslator()
  3413. {
  3414. TranslatorId = id,
  3415. OfficialDutyId = officialDutyId,
  3416. CreateUserId = currUserInfo.UserId,
  3417. Remark = $"翻译人员库-->添加"
  3418. });
  3419. }
  3420. if (officialDutyLinkTranslators.Count > 0)
  3421. {
  3422. await _sqlSugar.Insertable(officialDutyLinkTranslators).ExecuteCommandAsync();
  3423. }
  3424. }
  3425. #endregion
  3426. _sqlSugar.CommitTran();
  3427. return Ok(JsonView(true));
  3428. }
  3429. }
  3430. else if (dto.Status == 2)
  3431. {
  3432. var info = await _translatorRep.Query(x => x.Id == dto.Id).FirstAsync();
  3433. if (info != null)
  3434. {
  3435. if (!string.IsNullOrEmpty(info.Files))
  3436. {
  3437. try
  3438. {
  3439. var selectFiles = JsonConvert.DeserializeObject<List<string>>(info.Files);
  3440. fileNames.AddRange(selectFiles);
  3441. }
  3442. catch (Exception)
  3443. {
  3444. }
  3445. }
  3446. }
  3447. if (fileNames.Count > 0)
  3448. {
  3449. translatorInfo.Files = JsonConvert.SerializeObject(fileNames);
  3450. }
  3451. var upd = await _translatorRep
  3452. .UpdateAsync(x => x.Id == dto.Id, x => new Res_TranslatorLibrary()
  3453. {
  3454. Area = translatorInfo.Area,
  3455. Name = translatorInfo.Name,
  3456. Sex = translatorInfo.Sex,
  3457. Photo = translatorInfo.Photo,
  3458. Tel = translatorInfo.Tel,
  3459. Email = translatorInfo.Email,
  3460. WechatNo = translatorInfo.WechatNo,
  3461. OtherSocialAccounts = translatorInfo.OtherSocialAccounts,
  3462. Language = translatorInfo.Language,
  3463. Price = translatorInfo.Price,
  3464. Currency = translatorInfo.Currency,
  3465. Remark = translatorInfo.Remark,
  3466. Files = translatorInfo.Files,
  3467. });
  3468. if (upd) {
  3469. #region 更新(公务信息关联翻译人员) 关联信息
  3470. var officialDutyLinkTranslators_select = await _sqlSugar.Queryable<Grp_OfficialDutyLinkTranslator>()
  3471. .Where(x => x.IsDel == 0 && x.TranslatorId == dto.Id)
  3472. .ToListAsync();
  3473. //删除
  3474. var officialDutyLinkTranslatorIds = officialDutyLinkTranslators_select.Select(x => x.Id).ToList();
  3475. if (officialDutyLinkTranslatorIds.Count > 0)
  3476. {
  3477. await _sqlSugar.Updateable<Grp_OfficialDutyLinkTranslator>()
  3478. .SetColumnsIF(officialDutyLinkTranslatorIds.Count > 0, x => new Grp_OfficialDutyLinkTranslator()
  3479. {
  3480. DeleteUserId = currUserInfo.UserId,
  3481. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  3482. IsDel = 1,
  3483. Remark = $"翻译人员库-->删除"
  3484. })
  3485. .Where(x => officialDutyLinkTranslatorIds.Contains(x.Id))
  3486. .ExecuteCommandAsync();
  3487. }
  3488. if (dto.officialDutyIdItem != null && dto.officialDutyIdItem.Length > 0)
  3489. {
  3490. //添加
  3491. var officialDutyLinkTranslators = new List<Grp_OfficialDutyLinkTranslator>();
  3492. foreach (var officialDutyId in dto.officialDutyIdItem)
  3493. {
  3494. officialDutyLinkTranslators.Add(new Grp_OfficialDutyLinkTranslator()
  3495. {
  3496. TranslatorId = dto.Id,
  3497. OfficialDutyId = officialDutyId,
  3498. CreateUserId = currUserInfo.UserId,
  3499. Remark = $"翻译人员库-->更新"
  3500. });
  3501. }
  3502. if (officialDutyLinkTranslators.Count > 0)
  3503. {
  3504. await _sqlSugar.Insertable(officialDutyLinkTranslators).ExecuteCommandAsync();
  3505. }
  3506. }
  3507. #endregion
  3508. _sqlSugar.CommitTran();
  3509. return Ok(JsonView(true));
  3510. }
  3511. }
  3512. _sqlSugar.RollbackTran();
  3513. return Ok(JsonView(false));
  3514. }
  3515. /// <summary>
  3516. /// 翻译人员库
  3517. /// Del
  3518. /// </summary>
  3519. /// <param name="id"></param>
  3520. /// <returns></returns>
  3521. [HttpDelete("id")]
  3522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3523. public async Task<IActionResult> TranslatorLibraryDel(int id)
  3524. {
  3525. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  3526. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  3527. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  3528. _sqlSugar.BeginTran();
  3529. var upd = await _translatorRep.SoftDeleteByIdAsync<Res_TranslatorLibrary>(id.ToString(), currUserInfo.UserId);
  3530. if (!upd) {
  3531. _sqlSugar.RollbackTran();
  3532. return Ok(JsonView(false));
  3533. }
  3534. #region 删除公务出访
  3535. await _sqlSugar.Updateable<Grp_OfficialDutyLinkTranslator>()
  3536. .SetColumns(x => new Grp_OfficialDutyLinkTranslator() {
  3537. DeleteUserId = currUserInfo.UserId,
  3538. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  3539. IsDel = 1,
  3540. Remark = $"翻译人员库-->删除"
  3541. })
  3542. .Where(x => x.TranslatorId == id)
  3543. .ExecuteCommandAsync();
  3544. #endregion
  3545. _sqlSugar.CommitTran();
  3546. return Ok(JsonView(true));
  3547. }
  3548. #endregion
  3549. #region 策划部供应商资料
  3550. /// <summary>
  3551. /// 策划部供应商资料
  3552. /// Init
  3553. /// </summary>
  3554. /// <returns></returns>
  3555. [HttpGet]
  3556. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3557. public async Task<IActionResult> MediaSupplierInit()
  3558. {
  3559. return Ok(await _mediaSupplierRep.Init());
  3560. }
  3561. /// <summary>
  3562. /// 策划部供应商资料
  3563. /// Info
  3564. /// </summary>
  3565. /// <param name="dto"></param>
  3566. /// <returns></returns>
  3567. [HttpPost]
  3568. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3569. public async Task<IActionResult> MediaSupplierInfo(MediaSupplierInfoDto dto)
  3570. {
  3571. if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  3572. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Port));
  3573. return Ok(await _mediaSupplierRep.Info(dto));
  3574. }
  3575. /// <summary>
  3576. /// 策划部供应商资料
  3577. /// 分页查询
  3578. /// </summary>
  3579. /// <param name="dto"></param>
  3580. /// <returns></returns>
  3581. [HttpPost]
  3582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3583. public async Task<IActionResult> MediaSupplierPageItem(MediaSupplierPageItemDto dto)
  3584. {
  3585. if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  3586. return Ok(await _mediaSupplierRep.PageItem(dto));
  3587. }
  3588. /// <summary>
  3589. /// 策划部供应商资料
  3590. /// 操作(添加 Or 编辑)
  3591. /// </summary>
  3592. /// <param name="dto"></param>
  3593. /// <returns></returns>
  3594. [HttpPost]
  3595. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3596. public async Task<IActionResult> MediaSupplierOp(MediaSupplierAddOrEditDto dto)
  3597. {
  3598. var result = new JsonView() { Code = 400, Msg = "操作失败" };
  3599. var userId = dto.CurrUserId;
  3600. if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  3601. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  3602. return Ok(await _mediaSupplierRep.AddOrEdit(dto));
  3603. }
  3604. /// <summary>
  3605. /// 策划部供应商资料
  3606. /// 删除
  3607. /// </summary>
  3608. /// <param name="dto"></param>
  3609. /// <returns></returns>
  3610. [HttpPost]
  3611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3612. public async Task<IActionResult> MediaSupplierSoftDel(MediaSupplierSoftDelDto dto)
  3613. {
  3614. var result = new JsonView() { Code = 400, Msg = "操作失败" };
  3615. int userId = dto.CurrUserId, id = dto.Id;
  3616. if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  3617. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  3618. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  3619. return Ok(await _mediaSupplierRep.SoftDel(dto));
  3620. }
  3621. #endregion
  3622. #region 保险国家基础费用
  3623. /// <summary>
  3624. /// 保险国家基础费用
  3625. /// Info
  3626. /// </summary>
  3627. /// <param name="dto"></param>
  3628. /// <returns></returns>
  3629. [HttpPost]
  3630. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3631. public async Task<IActionResult> InsuranceCostInfo(InsuranceCostInfoDto dto)
  3632. {
  3633. if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  3634. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Port));
  3635. var id = dto.Id;
  3636. var info = await _sqlSugar.Queryable<Res_BasicInsuranceCost>()
  3637. .Where(x => x.Id == id && x.IsDel == 0)
  3638. .Select(x => new {
  3639. x.Id,
  3640. x.IsSchengen,
  3641. x.CountryName,
  3642. x.Cost,
  3643. x.Remark,
  3644. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(s => s.Id == x.CreateUserId).Select(s => s.CnName),
  3645. x.CreateTime
  3646. })
  3647. .FirstAsync();
  3648. return Ok(JsonView(info));
  3649. }
  3650. /// <summary>
  3651. /// 保险国家基础费用
  3652. /// 分页查询
  3653. /// </summary>
  3654. /// <param name="dto"></param>
  3655. /// <returns></returns>
  3656. [HttpPost]
  3657. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3658. public async Task<IActionResult> InsuranceCostPageItem(InsuranceCostPageItemDto dto)
  3659. {
  3660. if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  3661. RefAsync<int> total = 0;
  3662. var data = await _sqlSugar.Queryable<Res_BasicInsuranceCost>()
  3663. .LeftJoin<Sys_Users>((bic,u) => bic.CreateUserId == u.Id)
  3664. .Where((bic, u) => bic.IsDel == 0)
  3665. .WhereIF(!string.IsNullOrEmpty(dto.Search), (bic, u) => bic.CountryName.Contains(dto.Search))
  3666. .OrderByDescending((bic, u) => bic.Id)
  3667. .Select((bic, u) => new {
  3668. bic.Id,
  3669. bic.IsSchengen,
  3670. bic.CountryName,
  3671. bic.Cost,
  3672. bic.Remark,
  3673. CreateUserName = u.CnName,
  3674. bic.CreateTime
  3675. })
  3676. .ToPageListAsync(dto.PageIndex,dto.PageSize,total);
  3677. return Ok(JsonView(data,total));
  3678. }
  3679. /// <summary>
  3680. /// 保险国家基础费用
  3681. /// 操作(添加 Or 编辑)
  3682. /// </summary>
  3683. /// <param name="dto"></param>
  3684. /// <returns></returns>
  3685. [HttpPost]
  3686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3687. public async Task<IActionResult> InsuranceCostOp(InsuranceCostOpDto dto)
  3688. {
  3689. var result = new JsonView() { Code = 400, Msg = "操作失败" };
  3690. var userId = dto.CurrUserId;
  3691. if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  3692. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  3693. var countryName = dto.CountryName.Trim();
  3694. if (string.IsNullOrEmpty(countryName)) return Ok(JsonView(false,$"国家名称不能为空!"));
  3695. var info = _mapper.Map<Res_BasicInsuranceCost>(dto);
  3696. info.CreateUserId = dto.CurrUserId;
  3697. info.CountryName = countryName;
  3698. if (dto.Id < 1) //添加
  3699. {
  3700. var addInfo = await _insuranceCostRep.Query(x => x.CountryName.Equals(countryName)).FirstAsync();
  3701. if (addInfo != null) return Ok(JsonView(false, $"该国家信息已存在,不可添加!"));
  3702. var add = await _insuranceCostRep.AddAsync(info);
  3703. if (add < 1) return Ok(JsonView(false, "添加失败!"));
  3704. }
  3705. else //修改
  3706. {
  3707. var upd = await _insuranceCostRep.UpdateAsync(x => x.Id == dto.Id, x => new Res_BasicInsuranceCost
  3708. {
  3709. IsSchengen = dto.IsSchengen,
  3710. CountryName = dto.CountryName,
  3711. Cost = dto.Cost,
  3712. Remark = dto.Remark
  3713. });
  3714. if (!upd) return Ok(JsonView(false, "修改失败!"));
  3715. }
  3716. return Ok(JsonView(true));
  3717. }
  3718. /// <summary>
  3719. /// 保险国家基础费用
  3720. /// 删除
  3721. /// </summary>
  3722. /// <param name="dto"></param>
  3723. /// <returns></returns>
  3724. [HttpPost]
  3725. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3726. public async Task<IActionResult> InsuranceCostSoftDel(InsuranceCostSoftDelDto dto)
  3727. {
  3728. int userId = dto.CurrUserId, id = dto.Id;
  3729. if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  3730. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  3731. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  3732. var del = await _insuranceCostRep.SoftDeleteAsync(x => x.Id == id, userId);
  3733. if (!del) return Ok(JsonView(false));
  3734. return Ok(JsonView(true));
  3735. }
  3736. #endregion
  3737. }
  3738. }