12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041 |
- using Aspose.Cells;
- using EyeSoft.Messanging;
- using Microsoft.EntityFrameworkCore.Metadata;
- using Microsoft.Extensions.Configuration.UserSecrets;
- using OASystem.Domain;
- using OASystem.Domain.Entities.Customer;
- using OASystem.Domain.Entities.Financial;
- using OASystem.Domain.Entities.Groups;
- using Org.BouncyCastle.Asn1.Cmp;
- using System.Collections;
- using static OASystem.API.OAMethodLib.GeneralMethod;
- using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
- using static QRCoder.PayloadGenerator;
- using static Quartz.Logging.OperationName;
- using static OASystem.API.OAMethodLib.JWTHelper;
- using System.Runtime.Intrinsics.Arm;
- using OASystem.Domain.Dtos.Statistics;
- using OASystem.Domain.AesEncryption;
- namespace OASystem.API.Controllers
- {
-
-
-
-
- [Route("api/[controller]/[action]")]
- public class SystemController : ControllerBase
- {
- private readonly CompanyRepository _syscomRep;
- private readonly DepartmentRepository _sysDepRep;
- private readonly UsersRepository _userRep;
- private readonly IMapper _mapper;
- private readonly SqlSugarClient _sqlSugar;
- private readonly MessageRepository _messageRep;
- private readonly SetDataRepository _setDataRepository;
- private readonly SystemMenuPermissionRepository _SystemMenuPermissionRepository;
- private readonly CompanyRepository _CompanyRepository;
- private readonly PageFunctionPermissionRepository _PageFunctionPermissionRepository;
- private readonly SystemMenuAndFunctionRepository _SystemMenuAndFunctionRepository;
- private readonly JobPostAuthorityRepository _JobPostAuthorityRepository;
- private readonly JobPostRepository _jobRep;
- private readonly SetDataTypeRepository _setDataTypeRep;
- private readonly UserAuthorityRepository _UserAuthorityRepository;
- private readonly List<int> _operationTypeList = new List<int>() { 1, 2, 3, 4, 5 };
- private readonly List<int> _taskTypeList = new List<int>() { 6 };
- public SystemController(
- CompanyRepository syscom,
- DepartmentRepository sysDepRep,
- UsersRepository userRep,
- IMapper mapper,
- SqlSugarClient sqlSugar,
- SetDataRepository setDataRepository,
- CompanyRepository companyRepository,
- SystemMenuPermissionRepository systemMenuPermissionRepository,
- PageFunctionPermissionRepository pageFunctionPermissionRepository,
- SystemMenuAndFunctionRepository systemMenuAndFunctionRepository,
- JobPostAuthorityRepository jobPostAuthorityRepository,
- JobPostRepository jobRep,
- UserAuthorityRepository userAuthorityRepository,
- MessageRepository messageRep,
- SetDataTypeRepository setDataTypeRep
- )
- {
- _syscomRep = syscom;
- _sysDepRep = sysDepRep;
- _messageRep = messageRep;
- _userRep = userRep;
- _mapper = mapper;
- _sqlSugar = sqlSugar;
- _setDataRepository = setDataRepository;
- _CompanyRepository = companyRepository;
- _SystemMenuPermissionRepository = systemMenuPermissionRepository;
- _PageFunctionPermissionRepository = pageFunctionPermissionRepository;
- _SystemMenuAndFunctionRepository = systemMenuAndFunctionRepository;
- _JobPostAuthorityRepository = jobPostAuthorityRepository;
- _UserAuthorityRepository = userAuthorityRepository;
- _jobRep = jobRep;
- _setDataTypeRep = setDataTypeRep;
- }
- #region 消息
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PsotMsgPageList(MsgDto dto)
- {
- var msgData = await _messageRep.GetMsgList(dto);
- if (msgData.Code != 0)
- {
- return Ok(JsonView(false, msgData.Msg));
- }
- return Ok(JsonView(msgData.Data));
- }
- #region 消息列表 - 分开
-
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PotsMsgTypeData(MsgTypeDto dto)
- {
- if (dto.PortType < 1 || dto.PortType > 3)
- {
- return Ok(JsonView(false, "请输入有效的PortType参数。1 Web 2 Android 3 IOS"));
- }
- if (dto.UserId < 1)
- {
- return Ok(JsonView(false, "请输入有效的UserId参数。"));
- }
- var msgData = await _messageRep.PotsMsgTypeData(dto);
- if (msgData.Code != 0)
- {
- return Ok(JsonView(400, msgData.Msg, new string[] { }));
- }
- return Ok(JsonView(true, msgData.Msg, msgData.Data));
- }
-
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PotsMessagePageList(PotsMessagePageListDto dto)
- {
- #region 参数验证
- if (dto.PortType < 1 || dto.PortType > 3)
- {
- return Ok(JsonView(false, "请输入有效的PortType参数。1 Web 2 Android 3 IOS"));
- }
- var typeData = await _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 77).Select(it => it.Id).ToListAsync();
- if (typeData.Count < 0)
- {
- return Ok(JsonView(false, "消息类型不存在"));
- }
- if (!typeData.Contains(dto.Type))
- {
- return Ok(JsonView(false, "请输入有效的Type参数。1021 团组操作通知 1020 任务操作通知 "));
- }
- if (dto.UserId < 1)
- {
- return Ok(JsonView(false, "请输入有效的UserId参数。"));
- }
- if (dto.ReadStatus < 1 || dto.ReadStatus > 3)
- {
- return Ok(JsonView(false, "请输入有效的ReadStatus参数。1 全部(包含已读/未读) 2 未读 3 已读"));
- }
- #endregion
-
- string msgSqlWhere = $" And smra.ReadableUId = {dto.UserId}";
-
- string typeStr = "";
- List<NotificationTypeView> messageTypeViews = AppSettingsHelper.Get<NotificationTypeView>("MessageNotificationType");
- if (dto.Type == 1020)
- {
- typeStr = String.Join(",", messageTypeViews.Where(it => it.TypeId == 1020).FirstOrDefault().MsgTypeIds.ToList());
- }
- else if (dto.Type == 1021)
- {
- typeStr = String.Join(",", messageTypeViews.Where(it => it.TypeId == 1021).FirstOrDefault().MsgTypeIds.ToList());
- }
- else if (dto.Type == 1022)
- {
- typeStr = String.Join(",", messageTypeViews.Where(it => it.TypeId == 1022).FirstOrDefault().MsgTypeIds.ToList());
- }
- if (!string.IsNullOrEmpty(typeStr))
- {
- msgSqlWhere += $" And sm.Type In ({typeStr})";
- }
-
- if (dto.ReadStatus == 1) msgSqlWhere += "";
- else if (dto.ReadStatus == 2) msgSqlWhere += $" And smra.IsRead = {0}";
- else if (dto.ReadStatus == 3) msgSqlWhere += $" And smra.IsRead = {1}";
- string msgSql = string.Format(@"Select * From(
- Select row_number() over(order by sm.ReleaseTime Desc) as RowNumber,
- sm.Id,sm.Type,sm.Title,sm.Content,sd.DepName issuerDep,su.CnName issuerUser,
- sm.ReleaseTime,smra.ReadableUId,smra.IsRead,sm.DiId,sm.Param
- From Sys_Message sm
- Inner Join Sys_MessageReadAuth smra On sm.Id = smra.MsgId
- Inner Join Sys_Users su On sm.IssuerId = su.Id
- Inner Join Sys_Department sd On su.DepId = sd.Id
- Inner Join Sys_Users suAuth On smra.ReadableUId = suAuth.Id
- Where sm.IsDel = 0
- And smra.IsDel = 0 {0}
- ) Temp", msgSqlWhere);
- try
- {
- RefAsync<int> totalCount = 0;
- var data = await _sqlSugar.SqlQueryable<MessageListView>(msgSql).ToPageListAsync(dto.PageIndex, dto.PageSize, totalCount);
- return Ok(JsonView(true, "操作成功!", data, totalCount));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
-
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PotsMessageUnreadTotalCount(PotsMessageUnreadTotalCountDto dto)
- {
- #region 参数验证
- if (dto.UserId < 1)
- {
- return Ok(JsonView(false, "请输入有效的UserId参数。"));
- }
- #endregion
- try
- {
- int messageUnReadCount = 0;
- int announcementUnReadCount = 0;
- var data = await _messageRep.GetUnReadCount(dto.UserId);
- if (data != null)
- {
- messageUnReadCount = data;
- }
- var data1 = await _messageRep.GetAnnouncementUnReadCount(dto.UserId);
- if (data1 != null)
- {
- announcementUnReadCount = data1;
- }
- return Ok(JsonView(true, "操作成功!", new { messageUnReadCount = messageUnReadCount, announcementUnReadCount = announcementUnReadCount }));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- #endregion
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostMsgInfo(MsgInfoDto dto)
- {
- if (dto.PortType < 1 || dto.PortType > 3)
- {
- return Ok(JsonView(false, "请输入有效的PortType参数。1 Web 2 Android 3 IOS"));
- }
- var msgData = await _messageRep.GetMsgInfo(dto);
- if (msgData.Code != 0)
- {
- return Ok(JsonView(false, msgData.Msg));
- }
- return Ok(JsonView(true, "操作成功!", msgData.Data));
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> SetMessageRead(MsgSetReadDto dto)
- {
- var msgData = await _messageRep.SetMsgRead(dto);
- if (msgData.Code != 0)
- {
- return Ok(JsonView(false, msgData.Msg));
- }
- return Ok(JsonView(true));
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DeleMsg(MsgDeleteDto dto)
- {
- var msgData = await _messageRep.DelMsg(dto);
- if (msgData.Code != 0)
- {
- return Ok(JsonView(false, msgData.Msg));
- }
- return Ok(JsonView(true));
- }
- #endregion
- #region 数据类型资料
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QuerySetData(SetDataDto dto)
- {
- try
- {
- if (dto.DataType == 0)
- {
- return Ok(JsonView(false, "请传类型Id!"));
- }
- var setData = _setDataRepository.QueryDto<Sys_SetData, SetDataView>(s => s.STid == dto.DataType && s.IsDel == 0).ToList();
- if (setData.Count == 0)
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- return Ok(JsonView(true, "查询成功!", setData));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public IActionResult QuerySetDataInitByArr(QuerySetDataInitByArr Dto)
- {
- var DbQuery = _setDataRepository.QueryDto<Sys_SetData, SetDataView>(s => Dto.DataTypeArr.Contains(s.STid)).ToList();
- var GroupResult = DbQuery.GroupBy(x => x.STid).Select(x => new
- {
- key = x.Key,
- Arr = x.ToList()
- });
- return Ok(JsonView(true, "查询成功!", GroupResult));
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QuerySetDataType(SetDataTypeDto dto)
- {
- try
- {
- Result setDataType = await _setDataTypeRep.QuerySetDataType(dto);
- if (setDataType.Code == 0)
- {
- return Ok(JsonView(true, "查询成功", setDataType.Data));
- }
- else
- {
- return Ok(JsonView(false, setDataType.Msg));
- }
- }
- catch (Exception)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OperationSetDataType(OperationSetDataTypeDto dto)
- {
- try
- {
- if (dto.Name == "")
- {
- return Ok(JsonView(false, "请检查类型名称是否填写!"));
- }
- Result result = await _setDataTypeRep.OperationSetDataType(dto);
- if (result.Code != 0)
- {
- return Ok(JsonView(false, result.Msg));
- }
- return Ok(JsonView(true, result.Msg));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelSetDataType(DelSetDataTypeDto dto)
- {
- try
- {
- var res = await _setDataTypeRep.SoftDeleteByIdAsync<Sys_SetDataType>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- #endregion
- #region 数据类型板块
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QuerySetDataInfo(SetDataIDto dto)
- {
- try
- {
- Result setData = await _setDataRepository.QuerySetData(dto);
- if (setData.Code == 0)
- {
- return Ok(JsonView(true, "查询成功", setData.Data));
- }
- else
- {
- return Ok(JsonView(false, setData.Msg));
- }
- }
- catch (Exception)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OperationSetData(OperationSetDataDto dto)
- {
- try
- {
- if (dto.Name == "")
- {
- return Ok(JsonView(false, "请检查板块名称是否填写!"));
- }
- Result result = await _setDataRepository.OperationSetData(dto);
- if (result.Code != 0)
- {
- return Ok(JsonView(false, result.Msg));
- }
- return Ok(JsonView(true, result.Msg));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelSetData(DelSetDataDto dto)
- {
- try
- {
- var res = await _setDataRepository.SoftDeleteByIdAsync<Sys_SetData>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- #endregion
- #region 企业操作
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> getCompanyList(DtoBase dto)
- {
- if (dto.PortType == 1)
- {
- var CompanyDataResult = _CompanyRepository.GetCompanyData();
- if (CompanyDataResult.Code != 0)
- {
- return Ok(JsonView(CompanyDataResult.Msg));
- }
- List<CompanyView> companyListView = _mapper.Map<List<CompanyView>>(CompanyDataResult.Data);
- for (int i = 0; i < companyListView.Count; i++)
- {
- if (companyListView[i].ParentCompanyId != 0)
- {
- companyListView[i].ParentCompanyName = companyListView.Find(x => x.Id == companyListView[i].ParentCompanyId).CompanyName;
- }
- if (companyListView[i].ContactUserId != 0)
- {
- var user = _userRep.QueryDto<Sys_Users, UserInfoWebView>(x => x.Id == companyListView[i].ContactUserId).ToList();
- if (user.Count != 0)
- {
- companyListView[i].ContactUserName = user[0].CnName;
- }
- }
- }
- return Ok(JsonView(true, "查询成功!", companyListView));
- }
- else if (dto.PortType == 2)
- {
- var CompanyDataResult = _CompanyRepository.GetCompanyData();
- if (CompanyDataResult.Code != 0)
- {
- return Ok(JsonView(CompanyDataResult.Msg));
- }
- return Ok(JsonView(true, "查询成功!", CompanyDataResult.Data));
- }
- else if (dto.PortType == 3)
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- else
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> AddCompany(AddCompanyDto dto)
- {
- if (string.IsNullOrWhiteSpace(dto.CompanyName) || dto.CreateUserId == 0 || string.IsNullOrWhiteSpace(dto.CompanyCode))
- {
- return Ok(JsonView(false, "请检查信息是否输入完整!"));
- }
- else if (string.IsNullOrWhiteSpace(dto.Tel))
- {
- return Ok(JsonView(false, "请检查联系方式是否输入正确!"));
- }
- else
- {
- Sys_Company _Company = _mapper.Map<Sys_Company>(dto);
- Result data = await _syscomRep.AddCompany(_Company);
- if (data.Code != 0)
- {
- return Ok(JsonView(false, "添加失败!"));
- }
- return Ok(JsonView(true, "添加成功"));
- }
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EditCompany(EditCompanyDto dto)
- {
- if (string.IsNullOrWhiteSpace(dto.CompanyName) || string.IsNullOrWhiteSpace(dto.CompanyCode) || string.IsNullOrWhiteSpace(dto.Address) || dto.ContactUserId == 0)
- {
- return Ok(JsonView(false, "请检查信息是否输入完整!"));
- }
- else if (string.IsNullOrWhiteSpace(dto.Tel))
- {
- return Ok(JsonView(false, "请检查联系方式是否输入正确!"));
- }
- else
- {
- bool res = await _syscomRep.UpdateAsync(a => a.Id == dto.Id, a => new Sys_Company
- {
- CompanyName = dto.CompanyName,
- CompanyCode = dto.CompanyCode,
- Address = dto.Address,
- ParentCompanyId = dto.ParentCompanyId,
- Tel = dto.Tel,
- ContactUserId = dto.ContactUserId,
- Remark = dto.Remark,
- });
- if (!res) { return Ok(JsonView(false, "修改失败")); }
- return Ok(JsonView(true, "修改成功!"));
- }
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelCompany(DelCompanyDto dto)
- {
- bool res = await _syscomRep.SoftDeleteAsync<Sys_Company>(dto.Id.ToString());
- if (!res) { return Ok(JsonView(false, "删除失败")); }
- return Ok(JsonView(true, "删除成功"));
- }
- #endregion
- #region 部门操作
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryDepartmentList(DepartmentDto dto)
- {
- try
- {
- if (dto.PortType == 1)
- {
- if (dto.CompanyId != 0)
- {
- var result = _sysDepRep.QueryDto<Sys_Department, DepartmentIView>(s => s.CompanyId == dto.CompanyId).ToList();
- if (result.Count == 0)
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- for (int i = 0; i < result.Count; i++)
- {
- if (result[i].ParentDepId != 0)
- {
- result[i].ParentDepName = result.Find(x => x.Id == result[i].ParentDepId).ParentDepName;
- }
- var company = _sysDepRep.QueryDto<Sys_Company, CompanyView>(s => s.Id == result[i].CompanyId).ToList();
- if (company.Count != 0)
- {
- result[i].CompanyName = company[0].CompanyName;
- }
- return Ok(JsonView(true, "查询成功!", result));
- }
- }
- else
- {
- var result = _sysDepRep.QueryDto<Sys_Department, DepartmentIView>(s => s.IsDel <= 1).ToList();
- if (result.Count == 0)
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- for (int i = 0; i < result.Count; i++)
- {
- if (result[i].ParentDepId != 0)
- {
- result[i].ParentDepName = result.Find(x => x.Id == result[i].ParentDepId).ParentDepName;
- }
- var company = _sysDepRep.QueryDto<Sys_Company, CompanyView>(s => s.Id == result[i].CompanyId).ToList();
- if (company.Count != 0)
- {
- result[i].CompanyName = company[0].CompanyName;
- }
- }
- return Ok(JsonView(true, "查询成功!", result));
- }
- return Ok(JsonView(false, "暂无数据!"));
- }
- else if (dto.PortType == 2)
- {
- var result = _sysDepRep.QueryDto<Sys_Department, DepartmentIView>(s => s.CompanyId == dto.CompanyId).ToList();
- if (result.Count == 0)
- {
- return Ok(JsonView(400, "暂无数据!", new List<string>()));
- }
- return Ok(JsonView(true, "查询成功!", result));
- }
- else if (dto.PortType == 3)
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- else
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> AddDepartment(AddDepartmentDto dto)
- {
- try
- {
- if (dto.CreateUserId == 0 || string.IsNullOrWhiteSpace(dto.DepName) || dto.CompanyId == 0 || string.IsNullOrWhiteSpace(dto.DepCode))
- {
- return Ok(JsonView(false, "请检查信息是否输入完整!"));
- }
- else
- {
- Sys_Department _Department = _mapper.Map<Sys_Department>(dto);
- int id = await _sysDepRep.AddAsyncReturnId(_Department);
- if (id == 0)
- {
- return Ok(JsonView(false, "添加失败!"));
- }
- return Ok(JsonView(true, "添加成功!", new { Id = id }));
- }
- }
- catch (Exception)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EditDepartment(EditDepartmentDto dto)
- {
- try
- {
- if (dto.Id == 0 || string.IsNullOrWhiteSpace(dto.DepName) || dto.CompanyId == 0 || string.IsNullOrWhiteSpace(dto.DepCode))
- {
- return Ok(JsonView(false, "请检查信息是否输入完整!"));
- }
- else
- {
- bool res = await _sysDepRep.UpdateAsync<Sys_Department>(a => a.Id == dto.Id, a => new Sys_Department
- {
- CompanyId = dto.CompanyId,
- DepCode = dto.DepCode,
- DepName = dto.DepName,
- ParentDepId = dto.ParentDepId,
- Remark = dto.Remark,
- });
- if (!res)
- {
- return Ok(JsonView(false, "修改失败!"));
- }
- return Ok(JsonView(true, "修改成功!"));
- }
- }
- catch (Exception)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelDepartment(DelDepartmentDto dto)
- {
- try
- {
- if (dto.Id == 0)
- {
- return Ok(JsonView(-1, "请检查信息是否输入完整!", null));
- }
- else
- {
- bool res = await _sysDepRep.SoftDeleteAsync<Sys_Department>(dto.Id.ToString());
- if (!res)
- {
- return Ok(JsonView(false, "删除失败!"));
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- }
- catch (Exception)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- #endregion
- #region 岗位板块
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryJobPost(QueryJobPostDto dto)
- {
- try
- {
- if (dto.PortType == 1)
- {
- string sqlWhere = string.Empty;
- if (dto.CompanyId != 0)
- {
- sqlWhere += string.Format(@" And jp.CompanyId={0}", dto.CompanyId);
- }
- if (dto.DepId != 0)
- {
- sqlWhere += string.Format(@" And jp.DepId={0}", dto.DepId);
- }
- sqlWhere += string.Format(@" And jp.IsDel={0}", 0);
- if (!string.IsNullOrEmpty(sqlWhere.Trim()))
- {
- Regex r = new Regex("And");
- sqlWhere = r.Replace(sqlWhere, "Where", 1);
- }
- List<Sys_JobPostI> jobList = await _jobRep.QueryJobPost(sqlWhere);
- List<JobPostView> List = _mapper.Map<List<JobPostView>>(jobList);
- if (jobList.Count == 0)
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- return Ok(JsonView(true, "查询成功!", jobList));
- }
- else if (dto.PortType == 2)
- {
- var result = _jobRep.QueryDto<Sys_JobPost, JobPostView>(s => s.CompanyId == dto.CompanyId && s.DepId == dto.DepId).ToList();
- if (result.Count == 0)
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- return Ok(JsonView(true, "查询成功!", result));
- }
- else if (dto.PortType == 3)
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- else
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> AddJobPost(AddJobPostDto dto)
- {
- try
- {
- Sys_JobPost sys_Job = _mapper.Map<Sys_JobPost>(dto);
- int id = await _jobRep.AddAsyncReturnId(sys_Job);
- if (id == 0)
- {
- return Ok(JsonView(false, "添加失败"));
- }
- return Ok(JsonView(true, "添加成功", new { Id = id }));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EditJobPost(EditJobPostDto dto)
- {
- try
- {
- bool res = await _jobRep.UpdateAsync<Sys_JobPost>(a => a.Id == dto.Id, a => new Sys_JobPost
- {
- CompanyId = dto.CompanyId,
- DepId = dto.DepId,
- JobName = dto.JobName,
- Remark = dto.Remark,
- });
- if (!res)
- {
- return Ok(JsonView(false, "修改失败"));
- }
- return Ok(JsonView(true, "修改成功"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelJobPost(DelJobPostDto dto)
- {
- try
- {
- bool res = await _jobRep.SoftDeleteAsync<Sys_JobPost>(dto.Id.ToString());
- if (!res)
- {
- return Ok(JsonView(false, "删除失败!"));
- }
- return Ok(JsonView(true, "删除成功"));
- }
- catch (Exception)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- #endregion
- #region 用户操作
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetUserNameList(DtoBase dto)
- {
- var result = _userRep.GetUserNameList(dto.PortType);
- if (result.Result.Code != 0)
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- return Ok(JsonView(true, "查询成功!", result.Result.Data));
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetUserList(DtoBase dto)
- {
- var result = _userRep.GetUserList(dto.PortType, string.Empty);
- if (result.Result.Code != 0)
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- return Ok(JsonView(true, "查询成功!", result.Result.Data));
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryUserList(UserDto dto)
- {
- string sqlWhere = string.Format(" Where su.IsDel = 0 ");
- if (dto.CompanyId != 0)
- {
- sqlWhere += string.Format(@" And su.CompanyId={0}", dto.CompanyId);
- }
- if (dto.DepId != 0)
- {
- sqlWhere += string.Format(@" And su.DepId={0}", dto.DepId);
- }
- if (dto.JobPostId != 0)
- {
- sqlWhere += string.Format(@" And su.JobPostId={0}", dto.JobPostId);
- }
- List<UserInfo> _userList = await _userRep.QueryUser(sqlWhere);
- if (_userList.Count == 0)
- {
- return Ok(JsonView(400, "暂无数据!", new List<String>()));
- }
- foreach (var item in _userList) EncryptionProcessor.DecryptProperties(item);
- List<UserInfoWebView> userList = _mapper.Map<List<UserInfoWebView>>(_userList);
- return Ok(JsonView(true, "查询成功!", userList));
- }
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> UserInfo(UserInfoDto dto)
- {
- if (dto.Id < 1) return Ok(JsonView(false, "请选择有效的userId!"));
- if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
- var _view = await _sqlSugar.Queryable<Sys_Users>()
- .Where(x => x.IsDel == 0 && x.Id == dto.Id)
- .Select(x => new
- {
- x.Id,
- x.CnName,
- x.EnName,
- x.Number,
- x.CompanyId,
- x.DepId,
- x.JobPostId,
- x.Password,
- x.Sex,
- x.Ext,
- x.Phone,
- x.UrgentPhone,
- x.Email,
- x.Address,
- x.Edate,
-
- x.Birthday,
- x.IDCard,
- x.StartWorkDate,
- x.GraduateInstitutions,
- x.Professional,
- x.Education,
- x.TheOrAdultEducation,
- x.MaritalStatus,
- x.HomeAddress,
- x.UsePeriod,
- x.WorkExperience,
- x.Certificate,
-
- x.Remark
- }).FirstAsync();
-
- EncryptionProcessor.DecryptProperties(_view);
- return Ok(JsonView(true, "操作成功!", _view));
- }
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EditUserInfo(EditUserInfoDto _dto)
- {
- EditUserInfoDtoValidator validator = new EditUserInfoDtoValidator();
- var validatorRes = await validator.ValidateAsync(_dto);
- if (!validatorRes.IsValid)
- {
- var errors = new StringBuilder();
- foreach (var error in validatorRes.Errors) errors.AppendLine(error.ErrorMessage);
- return Ok(JsonView(false, errors.ToString()));
- }
- var userInfo = _mapper.Map<Sys_Users>(_dto);
- if (_dto.CurrUserId < 1) return Ok(JsonView(false, "暂无修改权限!"));
-
- List<int> userIds = new List<int>() {
- 4 ,
- 5 ,
- 117 ,
- 208 ,
- 230 ,
- 233 ,
- 234 ,
- 235 ,
- 309 ,
- };
- if (!userIds.Contains(_dto.CurrUserId)) return Ok(JsonView(false, "暂无修改权限!"));
-
- EncryptionProcessor.EncryptProperties(userInfo);
- var res = await _sqlSugar.Updateable(userInfo)
- .IgnoreColumns(x => new
- {
- x.QiyeChatUserId,
- x.Rdate,
- x.Seniority,
- x.HrAudit,
- x.CreateUserId,
- x.CreateTime,
- x.DeleteUserId,
- x.DeleteTime,
- x.IsDel
- })
- .Where(x => x.Id == _dto.Id)
- .ExecuteCommandAsync();
- if (res > 0) return Ok(JsonView(true, "操作成功!"));
- return Ok(JsonView(false, "操作失败!"));
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EditUser(EditUserDto dto)
- {
- if(dto.CurrUserId < 1) return Ok(JsonView(false, "暂无修改权限!"));
-
- var userIds = new List<int>() {
- 4 ,
- 5 ,
- 117 ,
- 208 ,
- 230 ,
- 233 ,
- 234 ,
- 235 ,
- 309 ,
- };
- if (!userIds.Contains(dto.CurrUserId)) return Ok(JsonView(false, "暂无修改权限!"));
- bool res = await _userRep.UpdateAsync<Sys_Users>(a => a.Id == dto.Id, a => new Sys_Users
- {
- Number = dto.Number,
- CompanyId = dto.CompanyId,
- DepId = dto.DepId,
- JobPostId = dto.JobPostId,
- Ext = dto.Ext,
- UsePeriod = dto.UsePeriod,
-
- });
- if (!res)
- {
- return Ok(JsonView(false, "修改失败!"));
- }
- return Ok(JsonView(true, "修改成功!"));
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EditMyUser(EditMyUserDto dto)
- {
- if (string.IsNullOrWhiteSpace(dto.CnName) ||
- string.IsNullOrWhiteSpace(dto.Address) ||
- string.IsNullOrWhiteSpace(dto.IDCard) ||
- dto.Sex != 0 && dto.Sex != 1 ||
- string.IsNullOrWhiteSpace(dto.MaritalStatus) ||
- string.IsNullOrWhiteSpace(dto.HomeAddress) ||
- dto.Birthday >= DateTime.Now.AddYears(-1))
- {
- return Ok(JsonView(false, "请完善你的个人信息!"));
- }
- else if (string.IsNullOrWhiteSpace(dto.GraduateInstitutions) ||
- string.IsNullOrWhiteSpace(dto.Professional) ||
- dto.Education == 0 ||
- string.IsNullOrWhiteSpace(dto.GraduateInstitutions))
- {
- return Ok(JsonView(false, "请完善你的学历信息!"));
- }
- else if (string.IsNullOrWhiteSpace(dto.Phone) ||
- string.IsNullOrWhiteSpace(dto.UrgentPhone) ||
- string.IsNullOrWhiteSpace(dto.Email))
- {
- return Ok(JsonView(false, "请检查联系方式、紧急联系人及邮箱输写是否正确!"));
- }
- else
- {
-
- var phone = AesEncryptionHelper.Encrypt(dto.Phone);
- var urgentPhone = AesEncryptionHelper.Encrypt(dto.UrgentPhone);
- var IDCard = AesEncryptionHelper.Encrypt(dto.IDCard);
- bool res = await _userRep.UpdateAsync<Sys_Users>(a => a.Id == dto.Id, a => new Sys_Users
- {
- CnName = dto.CnName,
- EnName = dto.EnName,
- Sex = dto.Sex,
- Phone = phone,
- UrgentPhone = urgentPhone,
- Email = dto.Email,
- Address = dto.Address,
- Edate = dto.Edate,
- Birthday = dto.Birthday,
- IDCard = IDCard,
- GraduateInstitutions = dto.GraduateInstitutions,
- Professional = dto.Professional,
- Education = dto.Education,
- TheOrAdultEducation = dto.TheOrAdultEducation,
- MaritalStatus = dto.MaritalStatus,
- HomeAddress = dto.HomeAddress,
- WorkExperience = dto.WorkExperience,
- Certificate = dto.Certificate
- });
- if (!res)
- {
- return Ok(JsonView(false, "修改失败!"));
- }
- return Ok(JsonView(true, "修改成功!"));
- }
- }
-
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostUserDelById(UserDelDto dto)
- {
- if (dto == null)
- {
- return Ok(JsonView(false, "参数不能为空!"));
- }
- var _Users = _sqlSugar.Queryable<Sys_Users>().First(a => a.IsDel == 0 && a.Id == dto.Id);
- if (_Users != null)
- {
- var sys_UsersList = _sqlSugar.Queryable<Sys_Users>().Where(a => a.IsDel == 0 && a.CompanyId == _Users.CompanyId).ToList();
- if (sys_UsersList.Count == 1)
- {
- return Ok(JsonView(false, "该人员为公司最后一位,不可删除!"));
- }
- }
- bool res = await _userRep.UpdateAsync<Sys_Users>(a => a.Id == dto.Id, a => new Sys_Users
- {
- IsDel = 1,
- DeleteUserId = dto.OperateUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
- Rdate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
- });
- if (!res)
- {
- return Ok(JsonView(false, "操作失败!"));
- }
- return Ok(JsonView(true, "操作成功!"));
- }
-
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PersonnelAudit(PersonnelAuditDto dto)
- {
- if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
- if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
- if (dto.IsAudit < 1 || dto.IsAudit > 2) return Ok(JsonView(false, "请传入有效的IsAudit参数!1:通过 2拒绝"));
- bool res = await _userRep.UpdateAsync<Sys_Users>(a => a.Id == dto.Id, a => new Sys_Users { HrAudit = dto.IsAudit });
- if (res)
- {
-
- var userData = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == dto.Id).First();
- int depId = 0, postId = 0;
- if (userData != null) { depId = userData.DepId; postId = userData.JobPostId; }
- bool s = DefaultPostAuth(depId, postId, dto.Id, dto.UserId);
- string str = $"基础页面权限添加失败!";
- if (s) str = $"基础页面权限添加成功!";
- return Ok(JsonView(true, $"操作成功!{str}"));
- }
- return Ok(JsonView(false, "操作失败!"));
- }
-
-
-
-
-
- [HttpPost]
- public IActionResult QueryUserByDepart(QueryUserByDepartDto dto)
- {
- var jw = JsonView(false);
- if (dto.DepartId < 1)
- {
- jw.Msg = "请传入正确的部门id";
- return Ok(jw);
- }
- string sql = $@"SELECT * FROM Sys_Users su WHERE su.JobPostId in (SELECT id FROM Sys_JobPost sj WHERE sj.IsDel = 0 AND sj.DepId = {dto.DepartId} )
- AND su.IsDel = 0 ";
- var result = _sqlSugar.SqlQueryable<Sys_Users>(sql).Select(x => new
- {
- x.Id,
- x.CnName,
- x.EnName
- }).ToList();
- jw.Data = result;
- jw.Code = 200;
- jw.Msg = "获取成功!";
- return Ok(jw);
- }
- #endregion
- #region 权限模块
-
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetAuth(AuthDto dto)
- {
- Result result = new Result();
-
- var setDataResult = await _setDataRepository.GetSySDefultModule();
- if (setDataResult.Code != 0)
- {
- return Ok(JsonView(setDataResult.Msg));
- }
-
- var PageOperation = _PageFunctionPermissionRepository.QueryDto<Sys_PageFunctionPermission, Sys_PageFunctionPermission>(x => x.IsEnable == 1).ToList();
-
- var Sys_SystemMenuAndFunction = _SystemMenuAndFunctionRepository.QueryDto<Sys_SystemMenuAndFunction, SystemMenuAndFunctionView>().ToList();
-
- var SystemMenuPermissionData = _SystemMenuPermissionRepository.QueryDto<Sys_SystemMenuPermission, SystemMenuPermissionView>(x => x.Mid == dto.moduleId && x.IsEnable == 1).ToList();
- if (SystemMenuPermissionData == null || SystemMenuPermissionData.Count() == 0)
- {
- return Ok(JsonView("暂无数据"));
- }
- ArrayList viewData = new ArrayList();
-
- foreach (var item in SystemMenuPermissionData)
- {
- ArrayList ids = new ArrayList();
- foreach (var viewop in PageOperation)
- {
- var op = Sys_SystemMenuAndFunction.FirstOrDefault(x => x.SmId == item.Id && x.FId == viewop.Id);
- if (op != null)
- {
- ids.Add(viewop.Id);
- }
- }
- viewData.Add(new
- {
- Id = item.Id,
- Mid = item.Mid,
- Name = item.Name,
- SystemMenuCode = item.SystemMenuCode,
- opList = ids,
- selList = new string[0]
- });
- }
-
- var CompanyDataResult = _CompanyRepository.GetCompanyData();
- if (CompanyDataResult.Code != 0)
- {
- return Ok(JsonView(CompanyDataResult.Msg));
- }
- result.Code = 0;
- result.Msg = "成功!";
- var Dyresult = new
- {
- setDataResult = setDataResult.Data,
- CompanyDataResult = CompanyDataResult.Data,
- SystemMenuPermissionData = viewData,
- PageOperation = PageOperation,
- };
- return Ok(JsonView(200, "成功!", Dyresult));
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public IActionResult QueryJobAuth(QueryJobAuthDto dto)
- {
-
- var DBdata = _JobPostAuthorityRepository.QueryDto<Sys_JobPostAuthority, JobPostAuthorityView>(x => x.JpId == dto.jobid).ToList();
- var SystemMenuPermissionData = _SystemMenuPermissionRepository.QueryDto<Sys_SystemMenuPermission, SystemMenuPermissionView>(x => x.Mid == dto.moduleId).ToList();
- if (SystemMenuPermissionData == null || SystemMenuPermissionData.Count() == 0)
- {
- return Ok(JsonView("暂无数据"));
- }
-
- var PageOperation = _PageFunctionPermissionRepository.QueryDto<Sys_PageFunctionPermission, Sys_PageFunctionPermission>().ToList();
-
- var Sys_SystemMenuAndFunction = _SystemMenuAndFunctionRepository.QueryDto<Sys_SystemMenuAndFunction, SystemMenuAndFunctionView>().ToList();
- ArrayList viewData = new ArrayList();
-
- foreach (var item in SystemMenuPermissionData)
- {
- ArrayList ids = new ArrayList();
- foreach (var viewop in PageOperation)
- {
- var op = Sys_SystemMenuAndFunction.FirstOrDefault(x => x.SmId == item.Id && x.FId == viewop.Id);
- if (op != null)
- {
- ids.Add(viewop.Id);
- }
- }
-
- var DBwhere = DBdata.Where(x => x.SmId == item.Id && x.JpId == dto.jobid).ToList();
- viewData.Add(new
- {
- Id = item.Id,
- Mid = item.Mid,
- Name = item.Name,
- SystemMenuCode = item.SystemMenuCode,
- opList = ids,
- selList = DBwhere.Select(x => x.FId)
- });
- }
- return Ok(JsonView(200, "成功!", viewData));
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> SaveJobAuth(SaveJobDto dto)
- {
-
- var Sys_SystemMenuAndFunction = _SystemMenuAndFunctionRepository.QueryDto<Sys_SystemMenuAndFunction, SystemMenuAndFunctionView>().ToList();
- var RemoveJobPostAuthList = _SystemMenuAndFunctionRepository._sqlSugar.SqlQueryable<Sys_JobPostAuthority>($@"
- select a.* from Sys_JobPostAuthority a, Sys_SetData b ,Sys_SystemMenuPermission c
- where a.SmId = c.Id and c.Mid = b.Id and JpId = {dto.Jpid} and c.Mid ={dto.modulId}
- ").ToList();
- List<Sys_JobPostAuthority> adds = new List<Sys_JobPostAuthority>();
- foreach (var item in dto.Savejobs)
- {
- foreach (var fid in item.FIds)
- {
- var whereobj = Sys_SystemMenuAndFunction.FirstOrDefault(x => x.FId == fid && x.SmId == item.SmId);
- if (whereobj != null)
- {
- adds.Add(new Sys_JobPostAuthority
- {
- CreateTime = DateTime.Now,
- CreateUserId = dto.UserId,
- FId = fid,
- JpId = dto.Jpid,
- SmId = item.SmId
- });
- }
- }
- }
- _JobPostAuthorityRepository.BeginTran();
- try
- {
- bool isdel = await _JobPostAuthorityRepository.DeletesAsync<Sys_JobPostAuthority>(RemoveJobPostAuthList);
- int UpRows = _JobPostAuthorityRepository.Adds<Sys_JobPostAuthority>(adds);
-
- var jobUserAll = await QueryUserList(new UserDto { PortType = 2, JobPostId = dto.Jpid });
- List<UserInfoWebView> users = null;
- var QueryUserListApiResult = (((jobUserAll as OkObjectResult).Value) as OASystem.Domain.ViewModels.JsonView);
- if (QueryUserListApiResult != null)
- {
- if (QueryUserListApiResult.Code == 200)
- {
- users = QueryUserListApiResult.Data as List<UserInfoWebView>;
- }
- }
- if (users != null && users.Count > 0)
- {
- List<Sys_UserAuthority> userAuth = null;
- var uids = string.Join(',', users.Select(x => x.Id)).TrimEnd(',');
- var RemoveUserAuthorityListAndTemp = _UserAuthorityRepository._sqlSugar.SqlQueryable<Sys_UserAuthority>($@"
- select a.* from Sys_UserAuthority a, Sys_SetData b ,Sys_SystemMenuPermission c
- where a.SmId = c.Id and c.Mid = b.Id and uid in ({uids}) and c.Mid = {dto.modulId} and IsTemp = 1
- ").ToList();
- foreach (var user in users)
- {
-
- isdel = await _UserAuthorityRepository.DeletesAsync<Sys_UserAuthority>
- (RemoveUserAuthorityListAndTemp.FindAll(x => x.UId == user.Id));
- userAuth = adds.Select(x => new Sys_UserAuthority
- {
- CreateTime = DateTime.Now,
- CreateUserId = dto.UserId,
- FId = x.FId,
- SmId = x.SmId,
- UId = user.Id,
- IsTemp = 1,
- }).ToList();
-
- int AddRows = _UserAuthorityRepository.Adds<Sys_UserAuthority>(userAuth);
- }
- }
- }
- catch (Exception ex)
- {
- _JobPostAuthorityRepository.RollbackTran();
- return Ok(JsonView("系统错误!"));
- }
- _JobPostAuthorityRepository.CommitTran();
- return Ok(JsonView(200, "成功", new { }));
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public IActionResult QueryUserAuth(QueryUserAuthDto dto)
- {
-
- var DBdata = _UserAuthorityRepository.QueryDto<Sys_UserAuthority, UserAuthorityView>(x => x.UId == dto.Userid).ToList();
- var SystemMenuPermissionData = _SystemMenuPermissionRepository.QueryDto<Sys_SystemMenuPermission, SystemMenuPermissionView>(x => x.Mid == dto.moduleId).ToList();
- if (SystemMenuPermissionData == null || SystemMenuPermissionData.Count() == 0)
- {
- return Ok(JsonView("暂无数据"));
- }
-
- var PageOperation = _PageFunctionPermissionRepository.QueryDto<Sys_PageFunctionPermission, Sys_PageFunctionPermission>(x => x.IsEnable == 1).ToList();
-
- var Sys_SystemMenuAndFunction = _SystemMenuAndFunctionRepository.QueryDto<Sys_SystemMenuAndFunction, SystemMenuAndFunctionView>().ToList();
- ArrayList viewData = new ArrayList();
-
- foreach (var item in SystemMenuPermissionData)
- {
- ArrayList ids = new ArrayList();
- foreach (var viewop in PageOperation)
- {
- var op = Sys_SystemMenuAndFunction.FirstOrDefault(x => x.SmId == item.Id && x.FId == viewop.Id);
- if (op != null)
- {
- ids.Add(viewop.Id);
- }
- }
-
- var DBwhere = DBdata.Where(x => x.SmId == item.Id && x.UId == dto.Userid).ToList();
- viewData.Add(new
- {
- Id = item.Id,
- Mid = item.Mid,
- Name = item.Name,
- SystemMenuCode = item.SystemMenuCode,
- opList = ids,
- selList = DBwhere.Select(x => x.FId)
- });
- }
- return Ok(JsonView(200, "成功!", viewData));
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public IActionResult QueryUserAuthByUserId(QueryUserAuthByUserIdDto dto)
- {
- string sql = string.Format(@" Select sd1.Id as ModuleId,sd1.Name as ModuleName,sm.Id as MenuId,sm.Name as MenuName From Sys_UserAuthority as u With(Nolock)
- Inner Join Sys_SystemMenuPermission as sm With(Nolock) On u.SmId = sm.Id
- Inner Join Sys_SetData as sd1 With(Nolock) On sm.Mid = sd1.Id
- Where u.IsDel = 0 And sm.IsDel = 0
- And u.UId = {0} And u.FId = 1 ", dto.UserId);
- List<SystemModule_UserAuthSqlView> _dataSource = _sqlSugar.SqlQueryable<SystemModule_UserAuthSqlView>(sql).ToList();
- List<SystemModule_UserAuthView> result = new List<SystemModule_UserAuthView>();
- foreach (SystemModule_UserAuthSqlView item in _dataSource)
- {
- if (result.FirstOrDefault(s => s.ModuleId == item.ModuleId) == null)
- {
- List<SystemModule_UserAuthSqlView> tempList = _dataSource.Where(s => s.ModuleId == item.ModuleId).ToList();
- List<SystemMenu_UserAuthView> menuList = new List<SystemMenu_UserAuthView>();
- foreach (SystemModule_UserAuthSqlView item2 in tempList)
- {
- SystemMenu_UserAuthView menu = new SystemMenu_UserAuthView() { MenuId = item2.MenuId, MenuName = item2.MenuName };
- menuList.Add(menu);
- }
- SystemModule_UserAuthView module = new SystemModule_UserAuthView() { MenuList = menuList, ModuleId = item.ModuleId, ModuleName = item.ModuleName };
- result.Add(module);
- }
- }
- return Ok(JsonView(200, "成功!", result));
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> SaveUserAuth(SaveUserDto dto)
- {
-
- var Sys_SystemMenuAndFunction = _SystemMenuAndFunctionRepository.QueryDto<Sys_SystemMenuAndFunction, SystemMenuAndFunctionView>().ToList();
-
- var userpageList = _SystemMenuPermissionRepository._sqlSugar.SqlQueryable<Sys_UserAuthority>($@"
- select a.* from Sys_UserAuthority a, Sys_SetData b ,Sys_SystemMenuPermission c
- where a.SmId = c.Id and c.Mid = b.Id and uid = {dto.uid} and c.Mid ={dto.Modulid}
- ").ToList();
- List<Sys_UserAuthority> adds = new List<Sys_UserAuthority>();
- foreach (var item in dto.Savejobs)
- {
- foreach (var fid in item.FIds)
- {
- var whereobj = Sys_SystemMenuAndFunction.FirstOrDefault(x => x.FId == fid && x.SmId == item.SmId);
- if (whereobj != null)
- {
- adds.Add(new Sys_UserAuthority
- {
- CreateTime = DateTime.Now,
- CreateUserId = dto.UserId,
- FId = fid,
- UId = dto.uid,
- SmId = item.SmId,
- IsTemp = 0
- });
- }
- }
- }
- _JobPostAuthorityRepository.BeginTran();
- try
- {
- List<Sys_UserAuthority> userAuth = null;
-
- bool isdel = await _UserAuthorityRepository.DeletesAsync<Sys_UserAuthority>(userpageList);
- userAuth = adds.Select(x => new Sys_UserAuthority
- {
- CreateTime = DateTime.Now,
- CreateUserId = dto.UserId,
- FId = x.FId,
- SmId = x.SmId,
- UId = dto.uid,
- IsTemp = 0,
- }).ToList();
-
- int AddRows = _UserAuthorityRepository.Adds<Sys_UserAuthority>(userAuth);
- }
- catch (Exception ex)
- {
- _JobPostAuthorityRepository.RollbackTran();
- return Ok(JsonView("系统错误!"));
- }
- _JobPostAuthorityRepository.CommitTran();
- return Ok(JsonView(200, "成功", new { }));
- }
- #endregion
- #region 页面配置
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PageConfigInit()
- {
- ArrayList arr = new ArrayList();
- var viewList = await _setDataRepository.GetSetDataAndPageInfoBySTId();
- if (viewList.Code != 0)
- {
- return Ok(JsonView(viewList.Msg));
- }
- var ModList = await _setDataRepository.GetSySDefultModule();
- return Ok(JsonView(new
- {
- viewList,
- ModList,
- }));
- }
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EditPageInfo(SetDataAndPageInfoDto dto)
- {
- JsonView view = null;
- _SystemMenuPermissionRepository.BeginTran();
- var istrue = await _SystemMenuPermissionRepository.UpdateAsync(x => x.Id == dto.Pageid, x => new Sys_SystemMenuPermission
- {
- AndroidUrl = dto.AndroidUrl,
- CreateTime = DateTime.Now,
- Icon = dto.Icon,
- IosUrl = dto.IosUrl,
- Name = dto.PageName,
- PhoneIsEnable = dto.PagePhoneIsEnable,
- CreateUserId = dto.UserId,
- IsDel = 0,
- IsEnable = dto.PageIsEnable,
- Mid = dto.Modulid,
- Remark = dto.PageRemark,
- SystemMenuCode = dto.SystemMenuCode,
- WebUrl = dto.WebUrl,
- });
- if (istrue)
- {
-
- await _SystemMenuAndFunctionRepository.DeleteAsync(x => x.SmId == dto.Pageid);
- List<Sys_SystemMenuAndFunction> binFun = new List<Sys_SystemMenuAndFunction>();
- foreach (var item in dto.FunArr)
- {
- binFun.Add(new Sys_SystemMenuAndFunction
- {
- CreateTime = DateTime.Now,
- CreateUserId = dto.UserId,
- FId = item,
- SmId = dto.Pageid,
- IsDel = 0,
- });
- }
- int number = _SystemMenuAndFunctionRepository.Adds<Sys_SystemMenuAndFunction>(binFun);
- view = JsonView(istrue);
- _SystemMenuPermissionRepository.CommitTran();
- }
- else
- {
- _SystemMenuPermissionRepository.RollbackTran();
- view = JsonView("添加失败");
- }
- return Ok(view);
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> AddPageInfo(SetDataAndPageInfoDto dto)
- {
- JsonView view = null;
- _SystemMenuPermissionRepository.BeginTran();
- int number = await _SystemMenuPermissionRepository.AddAsyncReturnId(new Sys_SystemMenuPermission
- {
- AndroidUrl = dto.AndroidUrl,
- CreateTime = DateTime.Now,
- Icon = dto.Icon,
- IosUrl = dto.IosUrl,
- Name = dto.PageName,
- PhoneIsEnable = dto.PagePhoneIsEnable,
- CreateUserId = dto.UserId,
- IsDel = 0,
- IsEnable = dto.PageIsEnable,
- Mid = dto.Modulid,
- Remark = dto.PageRemark,
- SystemMenuCode = dto.SystemMenuCode,
- WebUrl = dto.WebUrl,
- });
- List<Sys_SystemMenuAndFunction> binFun = new List<Sys_SystemMenuAndFunction>();
- foreach (var item in dto.FunArr)
- {
- binFun.Add(new Sys_SystemMenuAndFunction
- {
- CreateTime = DateTime.Now,
- CreateUserId = dto.UserId,
- FId = item,
- SmId = number,
- IsDel = 0,
- });
- }
- number = _SystemMenuAndFunctionRepository.Adds<Sys_SystemMenuAndFunction>(binFun);
- if (number > 0)
- {
- view = JsonView(number);
- _SystemMenuPermissionRepository.CommitTran();
- }
- else
- {
- _SystemMenuPermissionRepository.RollbackTran();
- view = JsonView("添加失败");
- }
- return Ok(view);
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelPageInfo(List<SystemMenuDelDto> Dto)
- {
- JsonView view = new JsonView();
- if (Dto.Count > 0)
- {
- try
- {
- _SystemMenuPermissionRepository.BeginTran();
- bool istrue = false;
- foreach (var item in Dto)
- {
- istrue = await _SystemMenuPermissionRepository.SoftDeleteAsync(item.Pageid.ToString());
- if (!istrue)
- {
- throw new Exception("修改失败");
- }
- }
- view.Code = 200;
- view.Msg = "删除成功!";
- view.Data = istrue;
- _SystemMenuPermissionRepository.CommitTran();
- }
- catch (Exception)
- {
- _SystemMenuPermissionRepository.RollbackTran();
- }
- }
- return Ok(JsonView(view));
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryPageFunById(PageFunDto Dto)
- {
-
- var pageAndFunList = _SystemMenuAndFunctionRepository.QueryDto<Sys_SystemMenuAndFunction, SystemMenuAndFunctionView>().ToList();
-
- var pageFunList = _PageFunctionPermissionRepository.QueryDto<Sys_PageFunctionPermission, Sys_PageFunctionPermission>(x => x.IsEnable == 1).ToList();
- ArrayList arr = new ArrayList();
- foreach (var item in pageFunList)
- {
- var FindVal = pageAndFunList.Find(x => x.SmId == Dto.Pageid && x.FId == item.Id);
- if (FindVal == null)
- {
- arr.Add(new
- {
- id = item.Id,
- name = item.FunctionName,
- value = false
- });
- }
- else
- {
- arr.Add(new
- {
- id = item.Id,
- name = item.FunctionName,
- value = true
- });
- }
- }
- return Ok(JsonView(arr));
- }
- #endregion
- #region 页面操作
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PageFunInit()
- {
- var PageFunInit = _PageFunctionPermissionRepository.QueryDto<Sys_PageFunctionPermission, PageFunctionPermissionView>().ToList();
- if (PageFunInit == null)
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- return Ok(JsonView(true, "查询成功!", PageFunInit));
- }
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OperationFun(OperationFunInitDta dto)
- {
- Result result = await _PageFunctionPermissionRepository.OperationFunInit(dto);
- if (result.Code != 0)
- {
- return Ok(JsonView(false, result.Msg));
- }
- return Ok(JsonView(true, result.Msg));
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelFun(DelFunInitDta dto)
- {
- var res = await _PageFunctionPermissionRepository.SoftDeleteByIdAsync<Sys_PageFunctionPermission>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- #endregion
- #region 各部门首页消息提示
-
-
-
-
- [HttpGet("{portType}")]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DepartmentHomePageMessagePrompts(int portType)
- {
- var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
- if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
- var department = currUserInfo.Department;
- if (portType < 1 || portType > 3) return Ok(JsonView(false, MsgTips.Port));
- if (portType == 1 || portType == 2 || portType == 3)
- {
-
- var lastMoth = DateTime.Now.AddMonths(-1);
- var (startDate, endDate) = CommonFun.GetMonthStartAndEndDates(lastMoth.Year, lastMoth.Month);
- var startDateTime = Convert.ToDateTime(startDate.ToString("yyyy-MM-dd 00:00:00"));
- var endDateTime = Convert.ToDateTime(endDate.ToString("yyyy-MM-dd 23:59:59"));
-
- var currStartDate = Convert.ToDateTime($"{DateTime.Now.Year}-01-01 00:00:00");
- var currEntDate = Convert.ToDateTime($"{DateTime.Now.Year}-12-31 23:59:59");
- if (department.Equals("总经办"))
- {
-
-
- #region 市场部客户资源
-
- var users = await _sqlSugar.Queryable<Sys_Users>()
- .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
- .Where((u, d) => u.IsDel == 0 && (d.DepName.Contains("市场部") || u.Id == 21))
- .Select((u, d) => new { u.Id, u.CnName })
- .ToListAsync();
- var marketData = await _sqlSugar.Queryable<Crm_NewClientData>()
- .LeftJoin<Sys_Users>((ncd, u) => ncd.CreateUserId == u.Id)
- .Where((ncd, u) => ncd.IsDel == 0 && ncd.CreateTime >= startDateTime && ncd.CreateTime <= endDateTime)
- .Select((ncd, u) => new
- {
- Area = ncd.Location,
- ncd.Client,
- ncd.Contact,
- ncd.Job,
- Tel = ncd.Telephone,
- ncd.CreateUserId,
- CreatleUserName = u.CnName,
- ncd.CreateTime,
- })
- .ToListAsync();
- foreach (var item in marketData) EncryptionProcessor.DecryptProperties(item);
- var marketDataGroup = marketData.GroupBy(x => x.CreateUserId).Select(g => new { CreateUserId = g.Key, Items = g.ToList(), Count = g.Count() });
- var marketData2 = new List<dynamic>();
- foreach (var user in users)
- {
- var userMarketData = marketDataGroup.FirstOrDefault(x => user.Id == x.CreateUserId);
- if (userMarketData != null)
- {
- marketData2.Add(new
- {
- uId = user.Id,
- name = user.CnName,
- count = userMarketData.Count,
- msgTips = $"上月新增市场客户资源共{userMarketData.Count}条",
- userMarketData = userMarketData.Items
- });
- }
- else
- {
- marketData2.Add(new
- {
- uId = user.Id,
- name = user.CnName,
- count = 0,
- msgTips = $"上月新增市场客户资源共{0}条",
- userMarketData = new List<dynamic>() { },
- });
- }
- }
- var marketData1 = new
- {
- msgTips = $"上月新增市场客户资源共{marketData.Count}条",
- Data = marketData2,
- };
- #endregion
- #region op地接导游
-
- var opTourGuideData = await _sqlSugar.Queryable<Res_LocalGuideData>()
- .LeftJoin<Sys_Users>((lgd, u) => lgd.CreateUserId == u.Id)
- .Where((lgd, u) => lgd.IsDel == 0 && lgd.CreateTime >= startDateTime && lgd.CreateTime <= endDateTime)
- .Select((lgd, u) => new
- {
- Area = lgd.UnitArea,
- Client = lgd.UnitName,
- lgd.Contact,
- Job = "",
- Tel = lgd.ContactTel,
- lgd.CreateUserId,
- CreatleUserName = u.CnName,
- lgd.CreateTime,
- })
- .ToListAsync();
- foreach (var item in opTourGuideData) EncryptionProcessor.DecryptProperties(item);
- var opTourGuideDataGroups = opTourGuideData.GroupBy(x => x.CreateUserId)
- .Select(g => new {
- uId = g.Key,
- name = g.ToList().FirstOrDefault()?.CreatleUserName ?? "-",
- msgTips = $"上月新增OP地接导游资源共{g.Count()}条",
- userTourGuideData = g.ToList(),
- Count = g.Count()
- });
- var opTourGuideData1 = new
- {
- msgTips = $"上月新增OP地接导游资源共{opTourGuideData.Count}条",
- Data = opTourGuideDataGroups,
- };
- #endregion
- #region op车数据
-
- var opCarData = await _sqlSugar.Queryable<Res_CarData>()
- .LeftJoin<Sys_Users>((cd, u) => cd.CreateUserId == u.Id)
- .Where((cd, u) => cd.IsDel == 0 && cd.CreateTime >= startDateTime && cd.CreateTime <= endDateTime)
- .Select((cd, u) => new CarDataMsgTipsView()
- {
- Area = cd.UnitArea,
- Client = cd.UnitName,
- Contact = cd.Contact,
- Job = "",
- Tel = cd.ContactTel,
- CreateUserId = cd.CreateUserId,
- CreatleUserName = u.CnName,
- CreateTime = cd.CreateTime,
- })
- .ToListAsync();
- foreach (var item in opCarData) EncryptionProcessor.DecryptProperties(item);
- var opCarDataGroups = opCarData.GroupBy(x => x.CreateUserId)
- .Select(g => new {
- uId = g.Key,
- name = g.ToList().FirstOrDefault()?.CreatleUserName ?? "-",
- msgTips = $"上月新增OP地接车资源共{g.Count()}条",
- userTourGuideData = g.ToList(),
- Count = g.Count()
- });
- var opCarData1 = new
- {
- msgTips = $"上月新增OP地接车资源共{opCarData.Count}条",
- Data = opCarDataGroups,
- };
- #endregion
- #region 商邀数据
-
- var invitationData = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>()
- .LeftJoin<Sys_Users>((ioa, u) => ioa.CreateUserId == u.Id)
- .Where((ioa, u) => ioa.IsDel == 0 && ioa.CreateTime >= startDateTime && ioa.CreateTime <= endDateTime)
- .Select((ioa, u) => new
- {
-
- Area = string.Format("{0}{1}", ioa.Country, ioa.City),
- Client = ioa.UnitName,
- ioa.Contact,
- ioa.Job,
- ioa.Tel,
- ioa.CreateUserId,
- CreatleUserName = u.CnName,
- ioa.CreateTime,
- })
- .ToListAsync();
- var invitationGroups = invitationData.GroupBy(x => x.CreateUserId)
- .Select(g => new {
- uId = g.Key,
- name = g.ToList().FirstOrDefault()?.CreatleUserName ?? "-",
- msgTips = $"上月新增商邀资源共{g.Count()}条",
- userTourGuideData = g.ToList(),
- Count = g.Count()
- });
- var invitationData1 = new
- {
- msgTips = $"上月新增商邀资源共{invitationData.Count}条",
- Data = invitationGroups,
- };
- #endregion
- #region 团组收款数据
-
- var groupCollectionData = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
- .LeftJoin<Sys_Users>((fr, u) => fr.CreateUserId == u.Id)
- .LeftJoin<Grp_DelegationInfo>((fr, u, di) => fr.Diid == di.Id)
- .LeftJoin<Sys_SetData>((fr, u, di, sd) => fr.Currency == sd.Id)
- .Where((fr, u, di, sd) => fr.IsDel == 0 && fr.CreateTime >= startDateTime && fr.CreateTime <= endDateTime)
- .Select((fr, u, di, sd) => new
- {
- fr.PriceName,
- fr.Price,
- fr.Count,
- fr.Unit,
- fr.ItemSumPrice,
- Currency = sd.Name,
- GroupName = di.TeamName,
- fr.CreateUserId,
- CreateUserName = u.CnName,
- fr.CreateTime,
- })
- .ToListAsync();
- var groupCollectionGroups = groupCollectionData.GroupBy(x => x.CreateUserId)
- .Select(g => new
- {
- uId = g.Key,
- name = g.ToList().FirstOrDefault()?.CreateUserName ?? "-",
- msgTips = $"上月累计团组收款共{g.Count()}条",
- userTourGuideData = g.ToList(),
- Count = g.Count()
- });
- var groupCollectionData2 = new
- {
- msgTips = $"上月累计团组收款共{groupCollectionData.Count}条",
- Data = groupCollectionGroups,
- };
- #endregion
- var materialData = new
- {
- marketData = marketData1,
- opTourGuideData = opTourGuideData1,
- opCarData = opCarData1,
- invitationData = invitationData1,
- groupCollectionData = groupCollectionData2
- };
-
- #region 日付申请未审核数据
- var dailyPaymentData = await _sqlSugar.Queryable<Fin_DailyFeePayment>()
- .LeftJoin<Sys_Users>((dfp, u) => dfp.CreateUserId == u.Id)
- .Where(dfp => dfp.IsDel == 0 &&
- dfp.MAudit == 0 &&
- dfp.CreateTime >= currStartDate &&
- dfp.CreateTime <= currEntDate
- )
- .OrderBy(dfp => dfp.CreateTime, OrderByType.Desc)
-
- .Select((dfp, u) => new
- {
- id = dfp.Id,
- amountName = dfp.Instructions,
- amount = dfp.SumPrice,
- fAuditStatus = dfp.FAudit == 1 ? "审核通过" :
- dfp.FAudit == 2 ? "审核未通过" : "未审核",
- fAuditDate = dfp.FAuditDate,
- dfp.CreateUserId,
- CreateUserName = u.CnName,
- dfp.CreateTime
- })
- .ToListAsync();
- var dailyPaymentGroups = dailyPaymentData.GroupBy(x => x.CreateUserId)
- .Select(g => new
- {
- uId = g.Key,
- name = g.ToList().FirstOrDefault()?.CreateUserName ?? "-",
- msgTips = $"本年有{g.Count()}条未审核日常付款申请条",
- userTourGuideData = g.ToList(),
- Count = g.Count()
- });
- var dailyPaymentData1 = new
- {
- msgTips = $"本年有{dailyPaymentData.Count()}条未审核日常付款申请条",
- Data = dailyPaymentGroups,
- };
- #endregion
- #region 团组费用未审核数据
- var groupPaymentData = await _sqlSugar.Queryable<Grp_CreditCardPayment>()
- .LeftJoin<Grp_DelegationInfo>((ccp, di) => ccp.DIId == di.Id)
- .Where((ccp, di) => ccp.IsDel == 0 &&
- ccp.IsAuditGM == 0 &&
- ccp.CreateTime >= currStartDate &&
- ccp.CreateTime <= currEntDate
- )
- .Select((ccp, di) => new
- {
- ccp.Id,
- ccp.DIId,
- GroupName = di.TeamName,
- ccp.CreateTime,
- })
- .ToListAsync();
- var groupPaymentGroups = groupPaymentData.GroupBy(x => x.DIId)
- .Select(g => new
- {
- uId = g.Key,
- name = g.ToList().FirstOrDefault()?.GroupName ?? "-",
- msgTips = $"本年有{g.Count()}条未审核团组费用申请条",
- userTourGuideData = g.ToList(),
- Count = g.Count()
- });
- var groupPaymentData1 = new
- {
- msgTips = $"本年有{groupPaymentData.Count()}条未审核团组费用申请条",
- Data = groupPaymentGroups,
- };
- #endregion
- var feeUnAuditData = new
- {
- dailyPaymentData = dailyPaymentData1,
- groupPaymentData = groupPaymentData1
- };
- return Ok(JsonView(new { materialData = materialData, feeUnAuditData = feeUnAuditData }));
- }
- else if (department.Equals("国交部"))
- {
- #region 团组费用录入提示
-
- var groupModlue = new List<int>() {
- 76,
- 79,
- 80,
- 81,
-
- 85,
- 98,
-
-
- };
- var crrDate = DateTime.Now.ToString("yyyy-MM-dd");
- var groupModlueData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => groupModlue.Contains(x.Id)).ToListAsync();
- var groupFeeData = await _sqlSugar.Queryable<Sys_SetData>()
- .LeftJoin<Grp_CreditCardPayment>((sd, ccp) => sd.Id == ccp.CTable)
- .LeftJoin<Grp_DelegationInfo>((sd, ccp, di) => ccp.DIId == di.Id)
- .Where((sd, ccp, di) => ccp.IsDel == 0 &&
- di.IsDel == 0 &&
- groupModlue.Contains(ccp.CTable) &&
- di.VisitEndDate.AddDays(-3).ToString("yyyy-MM-dd").Equals(crrDate)
- )
- .GroupBy((sd, ccp, di) => new { di.Id, di.TeamName, ccp.CTable, sd.Name })
- .Select((sd, ccp, di) => new {
- diId = di.Id,
- groupName = di.TeamName,
- groupType = ccp.CTable,
- groupTypeName = sd.Name,
-
- count = SqlFunc.AggregateCount(ccp.CTable),
- })
- .ToListAsync();
- var groupFeeData1 = groupFeeData.GroupBy(x => x.diId);
- var groupNotFilledFeeData = new List<dynamic>();
- foreach (var groupFee in groupFeeData1)
- {
- var diId = groupFee.Key;
- var addData = groupFeeData.Where(x => x.diId == diId).Select(x => x.groupType).ToList();
- if (addData.Count < 1) continue;
- var unAddData = groupModlue.Except(addData).ToList();
- if (unAddData.Count < 1) continue;
- foreach (var typeId in unAddData)
- {
- groupNotFilledFeeData.Add(new
- {
- diId = diId,
- groupName = groupFee.FirstOrDefault()?.groupName ?? "-",
- groupType = typeId,
- groupTypeName = groupModlueData.Find(x => x.Id == typeId)?.Name ?? "-",
- count = 0
- });
- }
- }
- #endregion
- #region 日付申请 -- 未审核数据
- var depUserData = await _sqlSugar.Queryable<Sys_Users>()
- .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
- .LeftJoin<Sys_JobPost>((u, d, jp) => u.JobPostId == jp.Id)
- .Where((u, d, jp) => u.IsDel == 0 && d.DepName.Contains("国交部"))
- .Select((u, d, jp) => new
- {
- u.Id,
- u.CnName,
- u.DepId,
- d.DepName,
- u.JobPostId,
- jp.JobName
- })
- .ToListAsync();
- var depUserData1 = depUserData.Select(x => x.Id).ToList();
- var unAuditDailyFeeData = await _sqlSugar.Queryable<Fin_DailyFeePayment>()
- .LeftJoin<Sys_Users>((dfp, u) => dfp.CreateUserId == u.Id)
- .Where((dfp, u) => dfp.IsDel == 0 &&
- depUserData1.Contains(dfp.CreateUserId) &&
- dfp.MAudit == 0 &&
- dfp.CreateTime >= currStartDate &&
- dfp.CreateTime <= currEntDate
- )
- .Select((dfp, u) => new
- {
- id = dfp.Id,
- amountName = dfp.Instructions,
- amount = dfp.SumPrice,
- fAuditStatus = dfp.FAudit == 1 ? "审核通过" :
- dfp.FAudit == 2 ? "审核未通过" : "未审核",
- fAuditDate = dfp.FAuditDate,
- dfp.CreateUserId,
- CreateUserName = u.CnName,
- dfp.CreateTime
- })
- .ToArrayAsync();
- #endregion
- var jobs = new List<string>() { "经理", "主管" };
- if (jobs.Contains( currUserInfo.Role))
- {
- #region 经理、主管
-
- var dailyPaymentData = new
- {
- msgTips = $"本年有{unAuditDailyFeeData.Count()}条未审核日常付款申请条",
- Data = new
- {
- uId = currUserInfo.UserId,
- name = currUserInfo.UserName,
- msgTips = $"本年有{unAuditDailyFeeData.Count()}条未审核日常付款申请条",
- userTourGuideData = unAuditDailyFeeData,
- Count = unAuditDailyFeeData.Count()
- }
- };
- var groupNotFilledFeeDataAll = groupNotFilledFeeData
- .GroupBy(x => x.diId)
- .Select(g => new
- {
- uId = g.Key,
- name = g.ToList().FirstOrDefault()?.groupName ?? "-",
- msgTips = $"-",
- hotelFeeData = g.Select(x1 => new
- {
- x1.groupType,
- x1.groupTypeName
- }).ToList(),
- Count = g.Count()
- })
- .ToList();
- var groupNotFillEdFeeData1 = new
- {
- msgTips = $"今天有{groupNotFilledFeeDataAll.Count()}个团组费用未填写",
- Data = groupNotFilledFeeDataAll,
- };
- #endregion
- return Ok(JsonView(new { groupNotFillEdFeeData = groupNotFillEdFeeData1, dailyPaymentData = dailyPaymentData }));
- }
- else if (currUserInfo.Role.Equals("计调"))
- {
- #region 计调
-
- return Ok(JsonView(false, "国交部-->计调岗位消息提示正在开发中......"));
- #endregion
- }
- else if (currUserInfo.Role.Equals("机票"))
- {
- #region 机票
-
- var airTicket_unAuditDailyFeeData = unAuditDailyFeeData.Where(x => x.CreateUserId == currUserInfo.UserId).ToList();
- var dailyPaymentData = new
- {
- msgTips = $"本年有{airTicket_unAuditDailyFeeData.Count()}条未审核日常付款申请条",
- Data = new
- {
- uId = currUserInfo.UserId,
- name = currUserInfo.UserName,
- msgTips = $"本年有{airTicket_unAuditDailyFeeData.Count()}条未审核日常付款申请条",
- userTourGuideData = airTicket_unAuditDailyFeeData,
- Count = airTicket_unAuditDailyFeeData.Count()
- }
- };
- var airTicket_groupNotFilledData = groupNotFilledFeeData
- .Where(x => x.groupType == 85)
- .GroupBy(x => x.diId)
- .Select(g => new
- {
- uId = g.Key,
- name = g.ToList().FirstOrDefault()?.groupName ?? "-",
- msgTips = $"-",
- airTicketFeeData = g.Select(x1 => new
- {
- x1.groupType,
- x1.groupTypeName
- }).ToList(),
- Count = g.Count()
- })
- .ToList();
- var groupNotFillEdFeeData1 = new
- {
- msgTips = $"今天有{airTicket_groupNotFilledData.Count()}个团组费用未填写",
- Data = airTicket_groupNotFilledData,
- };
- #endregion
- return Ok(JsonView(new { groupNotFillEdFeeData = groupNotFillEdFeeData1, dailyPaymentData = dailyPaymentData }));
- }
- else if (currUserInfo.Role.Equals("酒店"))
- {
- #region 酒店
-
- var hotle_unAuditDailyFeeData = unAuditDailyFeeData.Where(x => x.CreateUserId == currUserInfo.UserId).ToList();
- var dailyPaymentData = new
- {
- msgTips = $"本年有{hotle_unAuditDailyFeeData.Count()}条未审核日常付款申请条",
- Data = new
- {
- uId = currUserInfo.UserId,
- name = currUserInfo.UserName,
- msgTips = $"本年有{hotle_unAuditDailyFeeData.Count()}条未审核日常付款申请条",
- hotelFeeData = hotle_unAuditDailyFeeData,
- Count = hotle_unAuditDailyFeeData.Count()
- }
- };
- var hotel_groupNotFilledData = groupNotFilledFeeData
- .Where(x => x.groupType == 76)
- .GroupBy(x => x.diId)
- .Select(g => new
- {
- uId = g.Key,
- name = g.ToList().FirstOrDefault()?.groupName ?? "-",
- msgTips = $"-",
- hotelFeeData = g.Select(x1 => new
- {
- x1.groupType,
- x1.groupTypeName
- }).ToList(),
- Count = g.Count()
- })
- .ToList();
- var groupNotFillEdFeeData1 = new
- {
- msgTips = $"今天有{hotel_groupNotFilledData.Count()}个团组费用未填写",
- Data = hotel_groupNotFilledData,
- };
- #endregion
- return Ok(JsonView(new { groupNotFillEdFeeData = groupNotFillEdFeeData1, dailyPaymentData = dailyPaymentData }));
- }
- else if (currUserInfo.Role.Equals("签证"))
- {
- #region 签证
-
- var visa_unAuditDailyFeeData = unAuditDailyFeeData.Where(x => x.CreateUserId == currUserInfo.UserId).ToList();
- var dailyPaymentData = new
- {
- msgTips = $"本年有{visa_unAuditDailyFeeData.Count()}条未审核日常付款申请条",
- Data = new
- {
- uId = currUserInfo.UserId,
- name = currUserInfo.UserName,
- msgTips = $"本年有{visa_unAuditDailyFeeData.Count()}条未审核日常付款申请条",
- visaFeeData = visa_unAuditDailyFeeData,
- Count = visa_unAuditDailyFeeData.Count()
- }
- };
- var visa_groupNotFilledData = groupNotFilledFeeData
- .Where(x => x.groupType == 80)
- .GroupBy(x => x.diId)
- .Select(g => new
- {
- uId = g.Key,
- name = g.ToList().FirstOrDefault()?.groupName ?? "-",
- msgTips = $"-",
- airTicketFeeData = g.Select(x1 => new
- {
- x1.groupType,
- x1.groupTypeName
- }).ToList(),
- Count = g.Count()
- })
- .ToList();
- var groupNotFillEdFeeData1 = new
- {
- msgTips = $"今天有{visa_groupNotFilledData.Count()}个团组费用未填写",
- Data = visa_groupNotFilledData,
- };
- #endregion
- return Ok(JsonView(new { groupNotFillEdFeeData = groupNotFillEdFeeData1, dailyPaymentData = dailyPaymentData }));
- }
- else if (currUserInfo.Role.Equals("商邀"))
- {
- #region 商邀
-
-
- var in_unAuditDailyFeeData = unAuditDailyFeeData.Where(x => x.CreateUserId == currUserInfo.UserId).ToList();
- var dailyPaymentData = new
- {
- msgTips = $"本年有{in_unAuditDailyFeeData.Count()}条未审核日常付款申请条",
- Data = new
- {
- uId = currUserInfo.UserId,
- name = currUserInfo.UserName,
- msgTips = $"本年有{in_unAuditDailyFeeData.Count()}条未审核日常付款申请条",
- visaFeeData = in_unAuditDailyFeeData,
- Count = in_unAuditDailyFeeData.Count()
- }
- };
-
- var in_groupNotFilledData = groupNotFilledFeeData
- .Where(x => x.groupType == 81)
- .GroupBy(x => x.diId)
- .Select(g => new
- {
- uId = g.Key,
- name = g.ToList().FirstOrDefault()?.groupName ?? "-",
- msgTips = $"-",
- airTicketFeeData = g.Select(x1 => new
- {
- x1.groupType,
- x1.groupTypeName
- }).ToList(),
- Count = g.Count()
- })
- .ToList();
- var groupNotFillEdFeeData1 = new
- {
- msgTips = $"今天有{in_groupNotFilledData.Count()}个团组费用未填写",
- Data = in_groupNotFilledData,
- };
-
- var invitationData = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>()
- .LeftJoin<Sys_Users>((ioa, u) => ioa.CreateUserId == u.Id)
- .Where((ioa, u) => ioa.IsDel == 0 && ioa.CreateTime >= startDateTime && ioa.CreateTime <= endDateTime)
- .Select((ioa, u) => new
- {
-
- Area = string.Format("{0}{1}", ioa.Country, ioa.City),
- Client = ioa.UnitName,
- ioa.Contact,
- ioa.Job,
- ioa.Tel,
- ioa.CreateUserId,
- CreatleUserName = u.CnName,
- ioa.CreateTime,
- })
- .ToListAsync();
- var invitationGroups = invitationData.GroupBy(x => x.CreateUserId)
- .Select(g => new {
- uId = g.Key,
- name = g.ToList().FirstOrDefault()?.CreatleUserName ?? "-",
- msgTips = $"上月新增商邀资源共{g.Count()}条",
- userTourGuideData = g.ToList(),
- Count = g.Count()
- });
- var invitationData1 = new
- {
- msgTips = $"上月新增商邀资源共{invitationData.Count}条",
- Data = invitationGroups,
- };
- #endregion
- return Ok(JsonView(new { groupNotFillEdFeeData = groupNotFillEdFeeData1, dailyPaymentData = dailyPaymentData, invitationData = invitationData }));
- }
- else if (currUserInfo.Role.Equals("OP"))
- {
- #region OP
-
-
- var in_unAuditDailyFeeData = unAuditDailyFeeData.Where(x => x.CreateUserId == currUserInfo.UserId).ToList();
- var dailyPaymentData = new
- {
- msgTips = $"本年有{in_unAuditDailyFeeData.Count()}条未审核日常付款申请条",
- Data = new
- {
- uId = currUserInfo.UserId,
- name = currUserInfo.UserName,
- msgTips = $"本年有{in_unAuditDailyFeeData.Count()}条未审核日常付款申请条",
- visaFeeData = in_unAuditDailyFeeData,
- Count = in_unAuditDailyFeeData.Count()
- }
- };
-
- var in_groupNotFilledData = groupNotFilledFeeData
- .Where(x => x.groupType == 79)
- .GroupBy(x => x.diId)
- .Select(g => new
- {
- uId = g.Key,
- name = g.ToList().FirstOrDefault()?.groupName ?? "-",
- msgTips = $"-",
- airTicketFeeData = g.Select(x1 => new
- {
- x1.groupType,
- x1.groupTypeName
- }).ToList(),
- Count = g.Count()
- })
- .ToList();
- var groupNotFillEdFeeData1 = new
- {
- msgTips = $"今天有{in_groupNotFilledData.Count()}个团组费用未填写",
- Data = in_groupNotFilledData,
- };
- #region op地接导游
-
- var opTourGuideData = await _sqlSugar.Queryable<Res_LocalGuideData>()
- .LeftJoin<Sys_Users>((lgd, u) => lgd.CreateUserId == u.Id)
- .Where((lgd, u) => lgd.IsDel == 0 && lgd.CreateTime >= startDateTime && lgd.CreateTime <= endDateTime)
- .Select((lgd, u) => new
- {
- Area = lgd.UnitArea,
- Client = lgd.UnitName,
- lgd.Contact,
- Job = "",
- Tel = lgd.ContactTel,
- lgd.CreateUserId,
- CreatleUserName = u.CnName,
- lgd.CreateTime,
- })
- .ToListAsync();
- foreach (var item in opTourGuideData) EncryptionProcessor.DecryptProperties(item);
- var opTourGuideDataGroups = opTourGuideData.GroupBy(x => x.CreateUserId)
- .Select(g => new {
- uId = g.Key,
- name = g.ToList().FirstOrDefault()?.CreatleUserName ?? "-",
- msgTips = $"上月新增OP地接导游资源共{g.Count()}条",
- userTourGuideData = g.ToList(),
- Count = g.Count()
- });
- var opTourGuideData1 = new
- {
- msgTips = $"上月新增OP地接导游资源共{opTourGuideData.Count}条",
- Data = opTourGuideDataGroups,
- };
- #endregion
- #region op车数据
-
- var opCarData = await _sqlSugar.Queryable<Res_CarData>()
- .LeftJoin<Sys_Users>((cd, u) => cd.CreateUserId == u.Id)
- .Where((cd, u) => cd.IsDel == 0 && cd.CreateTime >= startDateTime && cd.CreateTime <= endDateTime)
- .Select((cd, u) => new
- {
- Area = cd.UnitArea,
- Client = cd.UnitName,
- cd.Contact,
- Job = "",
- Tel = cd.ContactTel,
- cd.CreateUserId,
- CreatleUserName = u.CnName,
- cd.CreateTime,
- })
- .ToListAsync();
- var opCarDataGroups = opCarData.GroupBy(x => x.CreateUserId)
- .Select(g => new {
- uId = g.Key,
- name = g.ToList().FirstOrDefault()?.CreatleUserName ?? "-",
- msgTips = $"上月新增OP地接车资源共{g.Count()}条",
- userTourGuideData = g.ToList(),
- Count = g.Count()
- });
- var opCarData1 = new
- {
- msgTips = $"上月新增OP地接车资源共{opCarData.Count}条",
- Data = opCarDataGroups,
- };
- #endregion
- #endregion
- return Ok(JsonView(new
- {
- groupNotFillEdFeeData = groupNotFillEdFeeData1,
- dailyPaymentData = dailyPaymentData,
- CarData = opCarData1,
- TourGuideData = opTourGuideData
- }));
- }
- return Ok(JsonView(false, "国交部消息提示正在开发中......"));
- }
- else if (department.Equals("财务部"))
- {
- #region 团组收款数据
- var groupCollectionData = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
- .LeftJoin<Sys_Users>((fr, u) => fr.CreateUserId == u.Id)
- .LeftJoin<Grp_DelegationInfo>((fr, u, di) => fr.Diid == di.Id)
- .LeftJoin<Sys_SetData>((fr, u, di, sd) => fr.Currency == sd.Id)
- .Where((fr, u, di, sd) => fr.IsDel == 0 && fr.CreateTime >= startDateTime && fr.CreateTime <= endDateTime)
- .Select((fr, u, di, sd) => new
- {
- fr.PriceName,
- fr.Price,
- fr.Count,
- fr.Unit,
- fr.ItemSumPrice,
- Currency = sd.Name,
- GroupName = di.TeamName,
- fr.CreateUserId,
- CreateUserName = u.CnName,
- fr.CreateTime,
- })
- .ToListAsync();
- var groupCollectionGroups = groupCollectionData.GroupBy(x => x.CreateUserId)
- .Select(g => new
- {
- uId = g.Key,
- name = g.ToList().FirstOrDefault()?.CreateUserName ?? "-",
- msgTips = $"上月累计团组收款共{g.Count()}条",
- userTourGuideData = g.ToList(),
- Count = g.Count()
- });
- var groupCollectionData1 = new
- {
- msgTips = $"上月累计团组收款共{groupCollectionData.Count}条",
- Data = groupCollectionGroups,
- };
-
- #endregion
- #region 日付申请未审核数据
- var dailyPaymentData = await _sqlSugar.Queryable<Fin_DailyFeePayment>()
- .LeftJoin<Sys_Users>((dfp, u) => dfp.CreateUserId == u.Id)
- .Where(dfp => dfp.IsDel == 0 &&
- dfp.MAudit == 0 &&
- dfp.CreateTime >= currStartDate &&
- dfp.CreateTime <= currEntDate
- )
- .OrderBy(dfp => dfp.CreateTime, OrderByType.Desc)
-
- .Select((dfp, u) => new
- {
- id = dfp.Id,
- amountName = dfp.Instructions,
- amount = dfp.SumPrice,
- fAuditStatus = dfp.FAudit == 1 ? "审核通过" :
- dfp.FAudit == 2 ? "审核未通过" : "未审核",
- fAuditDate = dfp.FAuditDate,
- dfp.CreateUserId,
- CreateUserName = u.CnName,
- dfp.CreateTime
- })
- .ToListAsync();
- var dailyPaymentGroups = dailyPaymentData.GroupBy(x => x.CreateUserId)
- .Select(g => new
- {
- uId = g.Key,
- name = g.ToList().FirstOrDefault()?.CreateUserName ?? "-",
- msgTips = $"本年有{g.Count()}条未审核日常付款申请条",
- userTourGuideData = g.ToList(),
- Count = g.Count()
- });
- var dailyPaymentData1 = new
- {
- msgTips = $"本年有{dailyPaymentData.Count()}条未审核日常付款申请条",
- Data = dailyPaymentGroups,
- };
- #endregion
- return Ok(JsonView(new { groupCollectionData = groupCollectionData1, dailyPaymentData = dailyPaymentData1 }));
- }
- return Ok(JsonView(false,"其余部门消息提示正在开发者中......"));
- }
- return Ok(JsonView(false));
- }
- #endregion
- }
- }
|