郑州市第一人民医院

Sys_User_AccountRepository.cs 53KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272
  1. using MadRunFabric.Common;
  2. using MadRunFabric.Common.Options;
  3. using Microsoft.Extensions.Logging;
  4. using Microsoft.Extensions.Options;
  5. using MongoDB.Driver;
  6. using SignTokenApi.IRepositories;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using MadRunFabirc.Model;
  11. using MadRunFabric.Model;
  12. namespace SignTokenApi.Repositories
  13. {
  14. public class Sys_User_AccountRepository : BaseRepository<Sys_User_Account, string>, ISys_User_AccountRepository
  15. {
  16. protected readonly ILogger<BaseRepository<Sys_User_Account, string>> _logger;
  17. protected readonly IMongoCollection<Sys_Department> _collection_sysdepartment;
  18. protected readonly IMongoCollection<Sys_Role_Info> _collection_sysroleinfo;
  19. protected readonly IMongoCollection<Sys_DictionaryValue> _collection_sys_dictionaryvalue;
  20. protected readonly IMongoCollection<Pro_Project_Info> _collection_proprojectinfo;
  21. protected readonly IMongoCollection<Sys_Post_Info> _collection_syspostinfo;
  22. public Sys_User_AccountRepository(IOptions<MongodbOptions> settings, ILogger<BaseRepository<Sys_User_Account, string>> logger) : base(settings, logger)
  23. {
  24. _collection_sysdepartment = _context.GetCollection<Sys_Department>();
  25. _collection_sysroleinfo = _context.GetCollection<Sys_Role_Info>();
  26. _collection_sys_dictionaryvalue = _context.GetCollection<Sys_DictionaryValue>();
  27. _collection_proprojectinfo = _context.GetCollection<Pro_Project_Info>();
  28. _collection_syspostinfo = _context.GetCollection<Sys_Post_Info>();
  29. _logger = logger;
  30. }
  31. /// <summary>
  32. /// Linq 关联查询 分页
  33. /// </summary>
  34. /// <param name="keyword"></param>
  35. /// <param name="provincecode"></param>
  36. /// <param name="citycode"></param>
  37. /// <param name="projectid"></param>
  38. /// <param name="protype"></param>
  39. /// <param name="systemid"></param>
  40. /// <param name="pageIndex"></param>
  41. /// <param name="pageSize"></param>
  42. /// <param name="recordCount"></param>
  43. /// <returns></returns>
  44. public IEnumerable<object> GetListsByPage(string keyword, string deptid, string roleid, string projectid, int type, string allprojectrole, int pageindex, int pagesize, out int recordCount)
  45. {
  46. //关联查询
  47. var query =
  48. from usa in _collection.AsQueryable()
  49. join dept in _collection_sysdepartment.AsQueryable() on usa.dept_id equals dept.id into deptinfo
  50. join role in _collection_sysroleinfo.AsQueryable() on usa.role_id equals role.id into roleinfo
  51. where usa.delete_flag == false && usa.type != 2
  52. orderby usa.create_time descending
  53. select new
  54. {
  55. usa.id,
  56. usa.username,
  57. usa.usercode,
  58. usa.type,
  59. usa.password,
  60. usa.sex,
  61. usa.see_flag,
  62. usa.birthday,
  63. usa.call_type,
  64. usa.dept_id,
  65. //dept_name = deptinfo.Count() > 0 ? deptinfo.First().departmenname : null,
  66. usa.extensionnumber,
  67. usa.@group,
  68. usa.head_img,
  69. usa.head_small_img,
  70. usa.homephone,
  71. usa.mail,
  72. usa.mobile,
  73. usa.qq,
  74. usa.remark,
  75. usa.role_id,
  76. role_name = roleinfo.Count() > 0 ? roleinfo.First().role_name : null,
  77. role_code = roleinfo.Count() > 0 ? roleinfo.First().role_code : null,
  78. usa.seat_flag,
  79. usa.seat_level,
  80. usa.seat_right,
  81. usa.weixin,
  82. usa.weixin_img,
  83. usa.weixin_name,
  84. usa.sina,
  85. usa.team_id,
  86. usa.telephone,
  87. usa.idcard,
  88. usa.idcardno,
  89. usa.certificate,
  90. usa.entrytime,
  91. usa.transfertime,
  92. usa.quittime,
  93. usa.postlist,
  94. usa.projectlist
  95. };
  96. #region 查询条件
  97. if (!string.IsNullOrEmpty(keyword))
  98. query = query.Where(s => s.usercode.Contains(keyword) || s.username.Contains(keyword) || s.mobile.Contains(keyword) || s.telephone.Contains(keyword));
  99. if (type != -1)
  100. query = query.Where(it => it.type.Equals(type));
  101. if (!string.IsNullOrEmpty(deptid))
  102. query = query.Where(it => it.dept_id.Equals(deptid));
  103. if (!string.IsNullOrEmpty(roleid))
  104. query = query.Where(it => it.role_id.Equals(roleid));
  105. if (!string.IsNullOrEmpty(projectid))
  106. query = query.Where(it => it.projectlist.Contains(projectid));
  107. #endregion
  108. recordCount = query.Count();
  109. var list = query.Skip((pageindex - 1) * pagesize).Take(pagesize);
  110. //var userpostlist_query = from post in _collection_syspostinfo.AsQueryable() where post.isdelete == 0 select post;
  111. var userprolist_query = from pro in _collection_proprojectinfo.AsQueryable() where pro.isdelete == 0 select pro;
  112. var querys = list.ToList().Select(p =>
  113. {
  114. //var userpostlist = (from post in _collection_syspostinfo.AsQueryable() where p.postlist.Contains(post.id) && post.isdelete == 0 select post).ToList();
  115. //var userprolist = (from pro in _collection_proprojectinfo.AsQueryable() where p.projectlist.Contains(pro.id) && pro.isdelete == 0 select pro).ToList();
  116. //var userpostlist = userpostlist_query.Where(x=>p.postlist.Contains(x.id)).ToList();
  117. var userprolist = userprolist_query.Where(x=>p.projectlist.Contains(x.id)).ToList();
  118. int isallproject = 0;
  119. if (allprojectrole.Split("|").Contains(p.role_code))
  120. {
  121. isallproject = 1;
  122. }
  123. //string postname = string.Join(',', userpostlist.Select(q => q.postname).ToList());
  124. string postname = string.Join(',', p.postlist.ToList());
  125. string projectname = string.Empty;
  126. if (isallproject == 0)
  127. {
  128. projectname = string.Join(',', userprolist.Select(q => q.project_name).ToList());
  129. }
  130. return new
  131. {
  132. p.id,
  133. p.username,
  134. p.usercode,
  135. p.type,
  136. //p.password,
  137. p.sex,
  138. p.see_flag,
  139. p.birthday,
  140. p.call_type,
  141. p.dept_id,
  142. // p.dept_name,
  143. p.extensionnumber,
  144. p.@group,
  145. p.head_img,
  146. p.head_small_img,
  147. p.homephone,
  148. p.mail,
  149. p.mobile,
  150. p.qq,
  151. p.remark,
  152. p.role_id,
  153. p.role_name,
  154. p.role_code,
  155. isallproject,
  156. p.seat_flag,
  157. p.seat_level,
  158. p.seat_right,
  159. p.weixin,
  160. p.weixin_img,
  161. p.weixin_name,
  162. p.sina,
  163. p.team_id,
  164. p.telephone,
  165. p.idcard,
  166. p.idcardno,
  167. p.certificate,
  168. p.entrytime,
  169. p.transfertime,
  170. p.quittime,
  171. p.postlist,
  172. postname ,
  173. p.projectlist,
  174. projectname
  175. };
  176. });
  177. return querys;
  178. }
  179. /// <summary>
  180. /// Linq 关联查询 - App
  181. /// </summary>
  182. /// <param name="keyword"></param>
  183. /// <param name="provincecode"></param>
  184. /// <param name="citycode"></param>
  185. /// <param name="projectid"></param>
  186. /// <param name="protype"></param>
  187. /// <param name="systemid"></param>
  188. /// <param name="pageIndex"></param>
  189. /// <param name="pageSize"></param>
  190. /// <param name="recordCount"></param>
  191. /// <returns></returns>
  192. public IEnumerable<object> GetAppLists(string keyword, string deptid, string roleid, string projectid, int type, string allprojectrole)
  193. {
  194. //关联查询
  195. var query =
  196. from usa in _collection.AsQueryable()
  197. join dept in _collection_sysdepartment.AsQueryable() on usa.dept_id equals dept.id into deptinfo
  198. join role in _collection_sysroleinfo.AsQueryable() on usa.role_id equals role.id into roleinfo
  199. where usa.delete_flag == false && usa.type != 2
  200. orderby usa.create_time descending
  201. select new
  202. {
  203. usa.id,
  204. usa.username,
  205. usa.usercode,
  206. usa.type,
  207. usa.password,
  208. usa.sex,
  209. usa.see_flag,
  210. usa.birthday,
  211. usa.call_type,
  212. usa.dept_id,
  213. //dept_name = deptinfo.Count() > 0 ? deptinfo.First().departmenname : null,
  214. usa.extensionnumber,
  215. usa.@group,
  216. usa.head_img,
  217. usa.head_small_img,
  218. usa.homephone,
  219. usa.mail,
  220. usa.mobile,
  221. usa.qq,
  222. usa.remark,
  223. usa.role_id,
  224. role_name = roleinfo.Count() > 0 ? roleinfo.First().role_name : null,
  225. role_code = roleinfo.Count() > 0 ? roleinfo.First().role_code : null,
  226. usa.seat_flag,
  227. usa.seat_level,
  228. usa.seat_right,
  229. usa.weixin,
  230. usa.weixin_img,
  231. usa.weixin_name,
  232. usa.sina,
  233. usa.team_id,
  234. usa.telephone,
  235. usa.idcard,
  236. usa.idcardno,
  237. usa.certificate,
  238. usa.entrytime,
  239. usa.transfertime,
  240. usa.quittime,
  241. usa.postlist,
  242. usa.projectlist
  243. };
  244. #region 查询条件
  245. if (!string.IsNullOrEmpty(keyword))
  246. query = query.Where(s => s.usercode.Contains(keyword) || s.username.Contains(keyword) || s.mobile.Contains(keyword) || s.telephone.Contains(keyword));
  247. if (type != -1)
  248. query = query.Where(it => it.type.Equals(type));
  249. if (!string.IsNullOrEmpty(deptid))
  250. query = query.Where(it => it.dept_id.Equals(deptid));
  251. if (!string.IsNullOrEmpty(roleid))
  252. query = query.Where(it => it.role_id.Equals(roleid));
  253. if (!string.IsNullOrEmpty(projectid))
  254. query = query.Where(it => it.projectlist.Contains(projectid));
  255. #endregion
  256. var querys = query.ToList().Select(p =>
  257. {
  258. //var userpostlist = (from post in _collection_syspostinfo.AsQueryable() where p.postlist.Contains(post.id) && post.isdelete == 0 select post).ToList();
  259. var userprolist = (from pro in _collection_proprojectinfo.AsQueryable() where p.projectlist.Contains(pro.id) && pro.isdelete == 0 select pro).ToList();
  260. int isallproject = 0;
  261. if (allprojectrole.Split("|").Contains(p.role_code))
  262. {
  263. isallproject = 1;
  264. }
  265. string postname = string.Join(',', p.postlist.ToList());
  266. string projectname = string.Empty;
  267. if (isallproject == 0)
  268. {
  269. projectname = string.Join(',', userprolist.Select(q => q.project_name).ToList());
  270. }
  271. return new
  272. {
  273. p.id,
  274. p.username,
  275. p.usercode,
  276. p.type,
  277. //p.password,
  278. p.sex,
  279. p.see_flag,
  280. p.birthday,
  281. p.call_type,
  282. p.dept_id,
  283. //p.dept_name,
  284. p.extensionnumber,
  285. p.@group,
  286. p.head_img,
  287. p.head_small_img,
  288. p.homephone,
  289. p.mail,
  290. p.mobile,
  291. p.qq,
  292. p.remark,
  293. p.role_id,
  294. p.role_name,
  295. p.role_code,
  296. isallproject,
  297. p.seat_flag,
  298. p.seat_level,
  299. p.seat_right,
  300. p.weixin,
  301. p.weixin_img,
  302. p.weixin_name,
  303. p.sina,
  304. p.team_id,
  305. p.telephone,
  306. p.idcard,
  307. p.idcardno,
  308. p.certificate,
  309. p.entrytime,
  310. p.transfertime,
  311. p.quittime,
  312. p.postlist,
  313. postname,
  314. p.projectlist,
  315. projectname
  316. };
  317. });
  318. return querys;
  319. }
  320. /// <summary>
  321. /// Linq 关联查询详情
  322. /// </summary>
  323. /// <param name="id"></param>
  324. /// <returns></returns>
  325. public object GetDetails(string id)
  326. {
  327. //关联查询
  328. var query =
  329. from usa in _collection.AsQueryable()
  330. join dept in _collection_sysdepartment.AsQueryable() on usa.dept_id equals dept.id into deptinfo
  331. join role in _collection_sysroleinfo.AsQueryable() on usa.role_id equals role.id into roleinfo
  332. where usa.delete_flag == false && usa.id == id
  333. orderby usa.create_time descending
  334. select new
  335. {
  336. usa.id,
  337. usa.username,
  338. usa.usercode,
  339. usa.type,
  340. usa.password,
  341. usa.sex,
  342. usa.see_flag,
  343. usa.birthday,
  344. usa.call_type,
  345. usa.dept_id,
  346. //dept_name = deptinfo.Count() > 0 ? deptinfo.First().departmenname : null,
  347. usa.extensionnumber,
  348. usa.@group,
  349. usa.head_img,
  350. usa.head_small_img,
  351. usa.homephone,
  352. usa.mail,
  353. usa.mobile,
  354. usa.qq,
  355. usa.remark,
  356. usa.role_id,
  357. role_name = roleinfo.Count() > 0 ? roleinfo.First().role_name : null,
  358. role_code = roleinfo.Count() > 0 ? roleinfo.First().role_code : null,
  359. usa.seat_flag,
  360. usa.seat_level,
  361. usa.seat_right,
  362. usa.sina,
  363. usa.team_id,
  364. usa.telephone,
  365. usa.idcard,
  366. usa.idcardno,
  367. usa.certificate,
  368. usa.entrytime,
  369. usa.transfertime,
  370. usa.quittime,
  371. usa.postlist,
  372. usa.projectlist
  373. };
  374. //var query_syspostinfo = from post in _collection_syspostinfo.AsQueryable() where post.isdelete == 0 select post;
  375. var query_proprojectinfo = from pro in _collection_proprojectinfo.AsQueryable() where pro.isdelete == 0 select pro;
  376. var userinfo = query.FirstOrDefault();
  377. if (userinfo != null)
  378. {
  379. //var userpostlist = query_syspostinfo.Where(x => userinfo.postlist.Contains(x.id));
  380. var userprolist = query_proprojectinfo.Where(x => userinfo.projectlist.Contains(x.id));
  381. var postnames = string.Join(',', userinfo.postlist.ToList());
  382. var model = new
  383. {
  384. id = userinfo.id,
  385. username = userinfo.username,
  386. usercode = userinfo.usercode,
  387. type = userinfo.type,
  388. password = userinfo.password,
  389. sex = userinfo.sex,
  390. see_flag = userinfo.see_flag,
  391. birthday = userinfo.birthday,
  392. call_type = userinfo.call_type,
  393. dept_id = userinfo.dept_id,
  394. //dept_name = userinfo.dept_name,
  395. extensionnumber = userinfo.extensionnumber,
  396. @group = userinfo.@group,
  397. head_img = userinfo.head_img,
  398. head_small_img = userinfo.head_small_img,
  399. homephone = userinfo.homephone,
  400. mail = userinfo.mail,
  401. mobile = userinfo.mobile,
  402. qq = userinfo.qq,
  403. remark = userinfo.remark,
  404. role_id = userinfo.role_id,
  405. role_name = userinfo.role_name,
  406. role_code = userinfo.role_code,
  407. seat_flag = userinfo.seat_flag,
  408. seat_level = userinfo.seat_level,
  409. seat_right = userinfo.seat_right,
  410. sina = userinfo.sina,
  411. team_id = userinfo.team_id,
  412. telephone = userinfo.telephone,
  413. idcard = userinfo.idcard,
  414. idcardno = userinfo.idcardno,
  415. certificate = userinfo.certificate,
  416. entrytime = userinfo.entrytime,
  417. transfertime = userinfo.transfertime,
  418. quittime = userinfo.quittime,
  419. postlist = userinfo.postlist,
  420. //postname = string.Join(',', userpostlist.Select(q => q.postname).ToList()),
  421. postname = postnames,
  422. projectlist = userinfo.projectlist,
  423. projectname = string.Join(',', userprolist.Select(q => q.project_name).ToList())
  424. };
  425. return model;
  426. }
  427. return null;
  428. }
  429. /// <summary>
  430. /// Linq 关联查询详情
  431. /// </summary>
  432. /// <param name="id"></param>
  433. /// <returns></returns>
  434. public object GetUserInfo(string usercode, string allprojectrole)
  435. {
  436. //关联查询
  437. var querys =
  438. from usa in _collection.AsQueryable()
  439. join dept in _collection_sysdepartment.AsQueryable() on usa.dept_id equals dept.id into deptinfo
  440. join role in _collection_sysroleinfo.AsQueryable() on usa.role_id equals role.id into roleinfo
  441. where usa.delete_flag == false && usa.usercode == usercode
  442. orderby usa.create_time descending
  443. select new
  444. {
  445. usa.id,
  446. usa.username,
  447. usa.usercode,
  448. usa.type,
  449. usa.password,
  450. usa.sex,
  451. usa.see_flag,
  452. usa.birthday,
  453. usa.call_type,
  454. usa.dept_id,
  455. //dept_name = deptinfo.Count() > 0 ? deptinfo.First().departmenname : null,
  456. usa.extensionnumber,
  457. usa.@group,
  458. usa.head_img,
  459. usa.head_small_img,
  460. usa.homephone,
  461. usa.mail,
  462. usa.mobile,
  463. usa.qq,
  464. usa.remark,
  465. usa.role_id,
  466. role_name = roleinfo.Count() > 0 ? roleinfo.First().role_name : null,
  467. role_code = roleinfo.Count() > 0 ? roleinfo.First().role_code : null,
  468. usa.seat_flag,
  469. usa.seat_level,
  470. usa.seat_right,
  471. usa.weixin,
  472. usa.weixin_img,
  473. usa.weixin_name,
  474. usa.sina,
  475. usa.team_id,
  476. usa.telephone,
  477. usa.idcard,
  478. usa.idcardno,
  479. usa.certificate,
  480. usa.entrytime,
  481. usa.transfertime,
  482. usa.quittime,
  483. usa.postlist,
  484. usa.projectlist
  485. };
  486. // var query_syspostinfo = from post in _collection_syspostinfo.AsQueryable() where post.isdelete == 0 select post;
  487. var query_proprojectinfo = from pro in _collection_proprojectinfo.AsQueryable() where pro.isdelete == 0 select pro;
  488. var userinfo = querys.FirstOrDefault();
  489. if (userinfo != null)
  490. {
  491. //var userpostlist = query_syspostinfo.Where(x => userinfo.postlist.Contains(x.id));
  492. var userprolist = query_proprojectinfo.Where(x => userinfo.projectlist.Contains(x.id));
  493. var postnames = string.Join(',', userinfo.postlist.ToList());
  494. int level = 0;
  495. switch (userinfo.role_code)
  496. {
  497. case "YWYG": level = 1; break;
  498. case "YWZG": level = 2; break;
  499. case "YWFJL": level = 3; break;
  500. case "YWJL": level = 4; break;
  501. case "YWZJ": level = 5; break;
  502. case "CJGL": level = 6; break;
  503. case "XTWH": level = 7; break;
  504. }
  505. int isallproject = 0;
  506. if (allprojectrole.Split("|").Contains(userinfo.role_code) || userinfo.type == 2)
  507. {
  508. isallproject = 1;
  509. }
  510. var model = new
  511. {
  512. id = userinfo.id,
  513. username = userinfo.username,
  514. usercode = userinfo.usercode,
  515. type = userinfo.type,
  516. //p.password,
  517. sex = userinfo.sex,
  518. see_flag = userinfo.see_flag,
  519. birthday = userinfo.birthday,
  520. call_type = userinfo.call_type,
  521. dept_id = userinfo.dept_id,
  522. //dept_name = userinfo.dept_name,
  523. extensionnumber = userinfo.extensionnumber,
  524. @group = userinfo.@group,
  525. head_img = userinfo.head_img,
  526. head_small_img = userinfo.head_small_img,
  527. homephone = userinfo.homephone,
  528. mail = userinfo.mail,
  529. mobile = userinfo.mobile,
  530. qq = userinfo.qq,
  531. remark = userinfo.remark,
  532. role_id = userinfo.role_id,
  533. role_name = userinfo.role_name,
  534. role_code = userinfo.role_code,
  535. level = level,
  536. isallproject = isallproject,
  537. seat_flag = userinfo.seat_flag,
  538. seat_level = userinfo.seat_level,
  539. seat_right = userinfo.seat_right,
  540. weixin = userinfo.weixin,
  541. weixin_img = userinfo.weixin_img,
  542. weixin_name = userinfo.weixin_name,
  543. sina = userinfo.sina,
  544. team_id = userinfo.team_id,
  545. telephone = userinfo.telephone,
  546. idcard = userinfo.idcard,
  547. idcardno = userinfo.idcardno,
  548. certificate = userinfo.certificate,
  549. entrytime = userinfo.entrytime,
  550. transfertime = userinfo.transfertime,
  551. quittime = userinfo.quittime,
  552. postlist = userinfo.postlist,
  553. //postname = string.Join(',', userpostlist.Select(q => q.postname).ToList()),
  554. postname = postnames,
  555. projectlist = userinfo.projectlist,
  556. projectname = string.Join(',', userprolist.Select(q => q.project_name).ToList())
  557. };
  558. return model;
  559. }
  560. return null;
  561. }
  562. /// <summary>
  563. /// 列表 - 根据项目id,权限code获取列表
  564. /// </summary>
  565. /// <param name="projectid"></param>
  566. /// <param name="rolecode"></param>
  567. /// <returns></returns>
  568. public IEnumerable<object> GetProjectUser(string projectid, string rolecode)
  569. {
  570. //关联查询
  571. var query =
  572. from usa in _collection.AsQueryable()
  573. //join dept in _collection_sysdepartment.AsQueryable() on usa.dept_id equals dept.id into deptinfo
  574. join role in _collection_sysroleinfo.AsQueryable() on usa.role_id equals role.id into roleinfo
  575. where usa.delete_flag == false && usa.type != 2
  576. orderby usa.create_time descending
  577. select new
  578. {
  579. usa.id,
  580. usa.username,
  581. usa.usercode,
  582. //usa.type,
  583. //usa.password,
  584. //usa.sex,
  585. //usa.see_flag,
  586. //usa.birthday,
  587. //usa.call_type,
  588. //usa.dept_id,
  589. //dept_name = deptinfo.Count() > 0 ? deptinfo.First().departmenname : null,
  590. //usa.extensionnumber,
  591. //usa.@group,
  592. //usa.head_img,
  593. //usa.head_small_img,
  594. //usa.homephone,
  595. //usa.mail,
  596. //usa.mobile,
  597. //usa.qq,
  598. //usa.remark,
  599. //usa.role_id,
  600. role_name = roleinfo.Count() > 0 ? roleinfo.First().role_name : null,
  601. role_code = roleinfo.Count() > 0 ? roleinfo.First().role_code : null,
  602. //usa.seat_flag,
  603. //usa.seat_level,
  604. //usa.seat_right,
  605. //usa.weixin,
  606. //usa.weixin_img,
  607. //usa.weixin_name,
  608. //usa.sina,
  609. //usa.team_id,
  610. //usa.telephone,
  611. //usa.idcard,
  612. //usa.idcardno,
  613. //usa.certificate,
  614. //usa.entrytime,
  615. //usa.transfertime,
  616. //usa.quittime,
  617. //usa.postlist,
  618. usa.projectlist
  619. };
  620. #region 查询条件
  621. //if (!string.IsNullOrEmpty(rolecode))
  622. // query = query.Where(it => it.role_code.Equals(rolecode));
  623. if (!string.IsNullOrEmpty(rolecode))
  624. {
  625. List<string> list_rolecode = new List<string>(rolecode.Split(','));
  626. query = query.Where(it => list_rolecode.Contains(it.role_code));
  627. }
  628. if (!string.IsNullOrEmpty(projectid))
  629. query = query.Where(it => it.projectlist.Contains(projectid));
  630. #endregion
  631. return query;
  632. }
  633. //华谊售后系统使用
  634. /// <summary>
  635. /// Linq 关联查询 分页
  636. /// </summary>
  637. /// <param name="keyword"></param>
  638. /// <param name="provincecode"></param>
  639. /// <param name="citycode"></param>
  640. /// <param name="projectid"></param>
  641. /// <param name="protype"></param>
  642. /// <param name="systemid"></param>
  643. /// <param name="pageIndex"></param>
  644. /// <param name="pageSize"></param>
  645. /// <param name="recordCount"></param>
  646. /// <returns></returns>
  647. public IEnumerable<object> HyGetListsByPage(string keyword, string deptid, string roleid, string projectid, int type, string allprojectrole, int pageindex, int pagesize, out int recordCount)
  648. {
  649. //关联查询
  650. var query =
  651. from usa in _collection.AsQueryable()
  652. join dept in _collection_sys_dictionaryvalue.AsQueryable() on usa.dept_id equals dept.id into deptinfo
  653. join role in _collection_sysroleinfo.AsQueryable() on usa.role_id equals role.id into roleinfo
  654. where usa.delete_flag == false && usa.type != 2
  655. orderby usa.create_time descending
  656. select new
  657. {
  658. usa.id,
  659. usa.username,
  660. usa.usercode,
  661. usa.type,
  662. usa.password,
  663. usa.sex,
  664. usa.see_flag,
  665. usa.birthday,
  666. usa.call_type,
  667. usa.dept_id,
  668. //dept_name = deptinfo.Count() > 0 ? deptinfo.First().name : null,
  669. usa.extensionnumber,
  670. usa.@group,
  671. usa.head_img,
  672. usa.head_small_img,
  673. usa.homephone,
  674. usa.mail,
  675. usa.mobile,
  676. usa.qq,
  677. usa.remark,
  678. usa.role_id,
  679. role_name = roleinfo.Count() > 0 ? roleinfo.First().role_name : null,
  680. role_code = roleinfo.Count() > 0 ? roleinfo.First().role_code : null,
  681. usa.seat_flag,
  682. usa.seat_level,
  683. usa.seat_right,
  684. usa.weixin,
  685. usa.weixin_img,
  686. usa.weixin_name,
  687. usa.sina,
  688. usa.team_id,
  689. usa.telephone,
  690. usa.idcard,
  691. usa.idcardno,
  692. usa.certificate,
  693. usa.entrytime,
  694. usa.transfertime,
  695. usa.quittime,
  696. usa.postlist,
  697. usa.projectlist,
  698. usa.create_user ,
  699. usa.create_time
  700. };
  701. #region 查询条件
  702. if (!string.IsNullOrEmpty(keyword))
  703. query = query.Where(s => s.usercode.Contains(keyword) || s.username.Contains(keyword) || s.mobile.Contains(keyword) || s.telephone.Contains(keyword));
  704. if (type != -1)
  705. query = query.Where(it => it.type.Equals(type));
  706. if (!string.IsNullOrEmpty(deptid))
  707. query = query.Where(it => it.dept_id.Equals(deptid));
  708. if (!string.IsNullOrEmpty(roleid))
  709. query = query.Where(it => it.role_id.Equals(roleid));
  710. if (!string.IsNullOrEmpty(projectid))
  711. query = query.Where(it => it.projectlist.Contains(projectid));
  712. #endregion
  713. recordCount = query.Count();
  714. var list = query.Skip((pageindex - 1) * pagesize).Take(pagesize);
  715. var userpostlist_query = from post in _collection_syspostinfo.AsQueryable() where post.isdelete == 0 select post;
  716. var userprolist_query = from pro in _collection_proprojectinfo.AsQueryable() where pro.isdelete == 0 select pro;
  717. var querys = list.ToList().Select(p =>
  718. {
  719. //var userpostlist = (from post in _collection_syspostinfo.AsQueryable() where p.postlist.Contains(post.id) && post.isdelete == 0 select post).ToList();
  720. //var userprolist = (from pro in _collection_proprojectinfo.AsQueryable() where p.projectlist.Contains(pro.id) && pro.isdelete == 0 select pro).ToList();
  721. //var userpostlist = userpostlist_query.Where(x => p.postlist.Contains(x.id)).ToList();
  722. var userprolist = userprolist_query.Where(x => p.projectlist.Contains(x.id)).ToList();
  723. int isallproject = 0;
  724. if (allprojectrole.Split("|").Contains(p.role_code))
  725. {
  726. isallproject = 1;
  727. }
  728. string postname = string.Join(',', p.postlist.ToList());
  729. string projectname = string.Empty;
  730. if (isallproject == 0)
  731. {
  732. projectname = string.Join(',', userprolist.Select(q => q.project_name).ToList());
  733. }
  734. return new
  735. {
  736. p.id,
  737. p.username,
  738. p.usercode,
  739. p.type,
  740. //p.password,
  741. p.sex,
  742. p.see_flag,
  743. p.birthday,
  744. p.call_type,
  745. p.dept_id,
  746. //p.dept_name,
  747. p.extensionnumber,
  748. p.@group,
  749. p.head_img,
  750. p.head_small_img,
  751. p.homephone,
  752. p.mail,
  753. p.mobile,
  754. p.qq,
  755. p.remark,
  756. p.role_id,
  757. p.role_name,
  758. p.role_code,
  759. isallproject,
  760. p.seat_flag,
  761. p.seat_level,
  762. p.seat_right,
  763. p.weixin,
  764. p.weixin_img,
  765. p.weixin_name,
  766. p.sina,
  767. p.team_id,
  768. p.telephone,
  769. p.idcard,
  770. p.idcardno,
  771. p.certificate,
  772. p.entrytime,
  773. p.transfertime,
  774. p.quittime,
  775. p.postlist,
  776. postname,
  777. p.projectlist,
  778. projectname,
  779. p.create_user,
  780. p.create_time
  781. };
  782. });
  783. return querys;
  784. }
  785. /// <summary>
  786. /// Linq 关联查询 - App
  787. /// </summary>
  788. /// <param name="keyword"></param>
  789. /// <param name="provincecode"></param>
  790. /// <param name="citycode"></param>
  791. /// <param name="projectid"></param>
  792. /// <param name="protype"></param>
  793. /// <param name="systemid"></param>
  794. /// <param name="pageIndex"></param>
  795. /// <param name="pageSize"></param>
  796. /// <param name="recordCount"></param>
  797. /// <returns></returns>
  798. public IEnumerable<object> HyGetAppLists(string keyword, string deptid, string roleid, string projectid, int type, string allprojectrole)
  799. {
  800. //关联查询
  801. var query =
  802. from usa in _collection.AsQueryable()
  803. join dept in _collection_sys_dictionaryvalue.AsQueryable() on usa.dept_id equals dept.id into deptinfo
  804. join role in _collection_sysroleinfo.AsQueryable() on usa.role_id equals role.id into roleinfo
  805. where usa.delete_flag == false && usa.type != 2
  806. orderby usa.create_time descending
  807. select new
  808. {
  809. usa.id,
  810. usa.username,
  811. usa.usercode,
  812. usa.type,
  813. usa.password,
  814. usa.sex,
  815. usa.see_flag,
  816. usa.birthday,
  817. usa.call_type,
  818. usa.dept_id,
  819. dept_name = usa.dept_id,// deptinfo.Count() > 0 ? deptinfo.First().name : null,
  820. usa.extensionnumber,
  821. usa.@group,
  822. usa.head_img,
  823. usa.head_small_img,
  824. usa.homephone,
  825. usa.mail,
  826. usa.mobile,
  827. usa.qq,
  828. usa.remark,
  829. usa.role_id,
  830. role_name = roleinfo.Count() > 0 ? roleinfo.First().role_name : null,
  831. role_code = roleinfo.Count() > 0 ? roleinfo.First().role_code : null,
  832. usa.seat_flag,
  833. usa.seat_level,
  834. usa.seat_right,
  835. usa.weixin,
  836. usa.weixin_img,
  837. usa.weixin_name,
  838. usa.sina,
  839. usa.team_id,
  840. usa.telephone,
  841. usa.idcard,
  842. usa.idcardno,
  843. usa.certificate,
  844. usa.entrytime,
  845. usa.transfertime,
  846. usa.quittime,
  847. usa.postlist,
  848. usa.projectlist,
  849. usa.create_user,
  850. usa.create_time
  851. };
  852. #region 查询条件
  853. if (!string.IsNullOrEmpty(keyword))
  854. query = query.Where(s => s.usercode.Contains(keyword) || s.username.Contains(keyword) || s.mobile.Contains(keyword) || s.telephone.Contains(keyword));
  855. if (type != -1)
  856. query = query.Where(it => it.type.Equals(type));
  857. if (!string.IsNullOrEmpty(deptid))
  858. query = query.Where(it => it.dept_id.Equals(deptid));
  859. if (!string.IsNullOrEmpty(roleid))
  860. query = query.Where(it => it.role_id.Equals(roleid));
  861. if (!string.IsNullOrEmpty(projectid))
  862. query = query.Where(it => it.projectlist.Contains(projectid));
  863. #endregion
  864. var querys = query.ToList().Select(p =>
  865. {
  866. //var userpostlist = (from post in _collection_syspostinfo.AsQueryable() where p.postlist.Contains(post.id) && post.isdelete == 0 select post).ToList();
  867. var userprolist = (from pro in _collection_proprojectinfo.AsQueryable() where p.projectlist.Contains(pro.id) && pro.isdelete == 0 select pro).ToList();
  868. int isallproject = 0;
  869. if (allprojectrole.Split("|").Contains(p.role_code))
  870. {
  871. isallproject = 1;
  872. }
  873. string postname = string.Join(',', p.postlist.ToList());
  874. string projectname = string.Empty;
  875. if (isallproject == 0)
  876. {
  877. projectname = string.Join(',', userprolist.Select(q => q.project_name).ToList());
  878. }
  879. return new
  880. {
  881. p.id,
  882. p.username,
  883. p.usercode,
  884. p.type,
  885. //p.password,
  886. p.sex,
  887. p.see_flag,
  888. p.birthday,
  889. p.call_type,
  890. p.dept_id,
  891. p.dept_name,
  892. p.extensionnumber,
  893. p.@group,
  894. p.head_img,
  895. p.head_small_img,
  896. p.homephone,
  897. p.mail,
  898. p.mobile,
  899. p.qq,
  900. p.remark,
  901. p.role_id,
  902. p.role_name,
  903. p.role_code,
  904. isallproject,
  905. p.seat_flag,
  906. p.seat_level,
  907. p.seat_right,
  908. p.weixin,
  909. p.weixin_img,
  910. p.weixin_name,
  911. p.sina,
  912. p.team_id,
  913. p.telephone,
  914. p.idcard,
  915. p.idcardno,
  916. p.certificate,
  917. p.entrytime,
  918. p.transfertime,
  919. p.quittime,
  920. p.postlist,
  921. postname,
  922. p.projectlist,
  923. projectname,
  924. p.create_user,
  925. p.create_time
  926. };
  927. });
  928. return querys;
  929. }
  930. /// <summary>
  931. /// Linq 关联查询详情
  932. /// </summary>
  933. /// <param name="id"></param>
  934. /// <returns></returns>
  935. public object HyGetDetails(string id)
  936. {
  937. //关联查询
  938. var query =
  939. from usa in _collection.AsQueryable()
  940. join dept in _collection_sys_dictionaryvalue.AsQueryable() on usa.dept_id equals dept.id into deptinfo
  941. join role in _collection_sysroleinfo.AsQueryable() on usa.role_id equals role.id into roleinfo
  942. where usa.delete_flag == false && usa.id == id
  943. orderby usa.create_time descending
  944. select new
  945. {
  946. usa.id,
  947. usa.username,
  948. usa.usercode,
  949. usa.type,
  950. usa.password,
  951. usa.sex,
  952. usa.see_flag,
  953. usa.birthday,
  954. usa.call_type,
  955. usa.dept_id,
  956. dept_name = usa.dept_id,
  957. //deptinfo.Count() > 0 ? deptinfo.First().name : null,
  958. usa.extensionnumber,
  959. usa.@group,
  960. usa.head_img,
  961. usa.head_small_img,
  962. usa.homephone,
  963. usa.mail,
  964. usa.mobile,
  965. usa.qq,
  966. usa.remark,
  967. usa.role_id,
  968. role_name = roleinfo.Count() > 0 ? roleinfo.First().role_name : null,
  969. role_code = roleinfo.Count() > 0 ? roleinfo.First().role_code : null,
  970. usa.seat_flag,
  971. usa.seat_level,
  972. usa.seat_right,
  973. usa.sina,
  974. usa.team_id,
  975. usa.telephone,
  976. usa.idcard,
  977. usa.idcardno,
  978. usa.certificate,
  979. usa.entrytime,
  980. usa.transfertime,
  981. usa.quittime,
  982. usa.postlist,
  983. usa.projectlist,
  984. usa.create_user,
  985. usa.create_time
  986. };
  987. //var query_syspostinfo = from post in _collection_syspostinfo.AsQueryable() where post.isdelete == 0 select post;
  988. var query_proprojectinfo = from pro in _collection_proprojectinfo.AsQueryable() where pro.isdelete == 0 select pro;
  989. var userinfo = query.FirstOrDefault();
  990. if (userinfo != null)
  991. {
  992. //var userpostlist = userinfo.postlist==null?;
  993. string postname = string.Join(',', userinfo.postlist.ToList());
  994. var userprolist = query_proprojectinfo.Where(x => userinfo.projectlist.Contains(x.id));
  995. var model = new
  996. {
  997. id = userinfo.id,
  998. username = userinfo.username,
  999. usercode = userinfo.usercode,
  1000. type = userinfo.type,
  1001. password = userinfo.password,
  1002. sex = userinfo.sex,
  1003. see_flag = userinfo.see_flag,
  1004. birthday = userinfo.birthday,
  1005. call_type = userinfo.call_type,
  1006. dept_id = userinfo.dept_id,
  1007. dept_name = userinfo.dept_name,
  1008. extensionnumber = userinfo.extensionnumber,
  1009. @group = userinfo.@group,
  1010. head_img = userinfo.head_img,
  1011. head_small_img = userinfo.head_small_img,
  1012. homephone = userinfo.homephone,
  1013. mail = userinfo.mail,
  1014. mobile = userinfo.mobile,
  1015. qq = userinfo.qq,
  1016. remark = userinfo.remark,
  1017. role_id = userinfo.role_id,
  1018. role_name = userinfo.role_name,
  1019. role_code = userinfo.role_code,
  1020. seat_flag = userinfo.seat_flag,
  1021. seat_level = userinfo.seat_level,
  1022. seat_right = userinfo.seat_right,
  1023. sina = userinfo.sina,
  1024. team_id = userinfo.team_id,
  1025. telephone = userinfo.telephone,
  1026. idcard = userinfo.idcard,
  1027. idcardno = userinfo.idcardno,
  1028. certificate = userinfo.certificate,
  1029. entrytime = userinfo.entrytime,
  1030. transfertime = userinfo.transfertime,
  1031. quittime = userinfo.quittime,
  1032. postlist = userinfo.postlist,
  1033. postname = postname,
  1034. projectlist = userinfo.projectlist,
  1035. projectname = string.Join(',', userprolist.Select(q => q.project_name).ToList()),
  1036. create_user = userinfo.create_user,
  1037. create_time = userinfo.create_time
  1038. };
  1039. return model;
  1040. }
  1041. return null;
  1042. }
  1043. /// <summary>
  1044. /// Linq 关联查询详情
  1045. /// </summary>
  1046. /// <param name="id"></param>
  1047. /// <returns></returns>
  1048. public object HyGetUserInfo(string usercode, string allprojectrole)
  1049. {
  1050. //关联查询
  1051. var querys =
  1052. from usa in _collection.AsQueryable()
  1053. join dept in _collection_sys_dictionaryvalue.AsQueryable() on usa.dept_id equals dept.id into deptinfo
  1054. join role in _collection_sysroleinfo.AsQueryable() on usa.role_id equals role.id into roleinfo
  1055. where usa.delete_flag == false && usa.usercode == usercode
  1056. orderby usa.create_time descending
  1057. select new
  1058. {
  1059. usa.id,
  1060. usa.username,
  1061. usa.usercode,
  1062. usa.type,
  1063. usa.password,
  1064. usa.sex,
  1065. usa.see_flag,
  1066. usa.birthday,
  1067. usa.call_type,
  1068. usa.dept_id,
  1069. dept_name = usa.dept_id,
  1070. //deptinfo.Count() > 0 ? deptinfo.First().name : null,
  1071. usa.extensionnumber,
  1072. usa.@group,
  1073. usa.head_img,
  1074. usa.head_small_img,
  1075. usa.homephone,
  1076. usa.mail,
  1077. usa.mobile,
  1078. usa.qq,
  1079. usa.remark,
  1080. usa.role_id,
  1081. role_name = roleinfo.Count() > 0 ? roleinfo.First().role_name : null,
  1082. role_code = roleinfo.Count() > 0 ? roleinfo.First().role_code : null,
  1083. usa.seat_flag,
  1084. usa.seat_level,
  1085. usa.seat_right,
  1086. usa.weixin,
  1087. usa.weixin_img,
  1088. usa.weixin_name,
  1089. usa.sina,
  1090. usa.team_id,
  1091. usa.telephone,
  1092. usa.idcard,
  1093. usa.idcardno,
  1094. usa.certificate,
  1095. usa.entrytime,
  1096. usa.transfertime,
  1097. usa.quittime,
  1098. usa.postlist,
  1099. usa.projectlist,
  1100. usa.create_user,
  1101. usa.create_time
  1102. };
  1103. //var query_syspostinfo = from post in _collection_syspostinfo.AsQueryable() where post.isdelete == 0 select post;
  1104. var query_proprojectinfo = from pro in _collection_proprojectinfo.AsQueryable() where pro.isdelete == 0 select pro;
  1105. var userinfo = querys.FirstOrDefault();
  1106. if (userinfo != null)
  1107. {
  1108. string postname = string.Join(',', userinfo.postlist.ToList());
  1109. //var userpostlist = query_syspostinfo.Where(x => userinfo.postlist.Contains(x.id));
  1110. var userprolist = query_proprojectinfo.Where(x => userinfo.projectlist.Contains(x.id));
  1111. int level = 0;
  1112. switch (userinfo.role_code)
  1113. {
  1114. case "YWYG": level = 1; break;
  1115. case "YWZG": level = 2; break;
  1116. case "YWFJL": level = 3; break;
  1117. case "YWJL": level = 4; break;
  1118. case "YWZJ": level = 5; break;
  1119. case "CJGL": level = 6; break;
  1120. case "XTWH": level = 7; break;
  1121. }
  1122. int isallproject = 0;
  1123. if (allprojectrole.Split("|").Contains(userinfo.role_code) || userinfo.type == 2)
  1124. {
  1125. isallproject = 1;
  1126. }
  1127. var model = new
  1128. {
  1129. id = userinfo.id,
  1130. username = userinfo.username,
  1131. usercode = userinfo.usercode,
  1132. type = userinfo.type,
  1133. //p.password,
  1134. sex = userinfo.sex,
  1135. see_flag = userinfo.see_flag,
  1136. birthday = userinfo.birthday,
  1137. call_type = userinfo.call_type,
  1138. dept_id = userinfo.dept_id,
  1139. dept_name = userinfo.dept_name,
  1140. extensionnumber = userinfo.extensionnumber,
  1141. @group = userinfo.@group,
  1142. head_img = userinfo.head_img,
  1143. head_small_img = userinfo.head_small_img,
  1144. homephone = userinfo.homephone,
  1145. mail = userinfo.mail,
  1146. mobile = userinfo.mobile,
  1147. qq = userinfo.qq,
  1148. remark = userinfo.remark,
  1149. role_id = userinfo.role_id,
  1150. role_name = userinfo.role_name,
  1151. role_code = userinfo.role_code,
  1152. level = level,
  1153. isallproject = isallproject,
  1154. seat_flag = userinfo.seat_flag,
  1155. seat_level = userinfo.seat_level,
  1156. seat_right = userinfo.seat_right,
  1157. weixin = userinfo.weixin,
  1158. weixin_img = userinfo.weixin_img,
  1159. weixin_name = userinfo.weixin_name,
  1160. sina = userinfo.sina,
  1161. team_id = userinfo.team_id,
  1162. telephone = userinfo.telephone,
  1163. idcard = userinfo.idcard,
  1164. idcardno = userinfo.idcardno,
  1165. certificate = userinfo.certificate,
  1166. entrytime = userinfo.entrytime,
  1167. transfertime = userinfo.transfertime,
  1168. quittime = userinfo.quittime,
  1169. postlist = userinfo.postlist,
  1170. postname = postname,
  1171. projectlist = userinfo.projectlist,
  1172. projectname = string.Join(',', userprolist.Select(q => q.project_name).ToList()),
  1173. create_user = userinfo.create_user,
  1174. create_time = userinfo.create_time
  1175. };
  1176. return model;
  1177. }
  1178. return null;
  1179. }
  1180. /// <summary>
  1181. /// 列表 - 根据项目id,权限code获取列表
  1182. /// </summary>
  1183. /// <param name="projectid"></param>
  1184. /// <param name="rolecode"></param>
  1185. /// <returns></returns>
  1186. public IEnumerable<object> HyGetProjectUser(string projectid, string rolecode)
  1187. {
  1188. //关联查询
  1189. var query =
  1190. from usa in _collection.AsQueryable()
  1191. //join dept in _collection_sysdepartment.AsQueryable() on usa.dept_id equals dept.id into deptinfo
  1192. join role in _collection_sysroleinfo.AsQueryable() on usa.role_id equals role.id into roleinfo
  1193. where usa.delete_flag == false && usa.type != 2
  1194. orderby usa.create_time descending
  1195. select new
  1196. {
  1197. usa.id,
  1198. usa.username,
  1199. usa.usercode,
  1200. role_name = roleinfo.Count() > 0 ? roleinfo.First().role_name : null,
  1201. role_code = roleinfo.Count() > 0 ? roleinfo.First().role_code : null,
  1202. usa.projectlist
  1203. };
  1204. #region 查询条件
  1205. //if (!string.IsNullOrEmpty(rolecode))
  1206. // query = query.Where(it => it.role_code.Equals(rolecode));
  1207. if (!string.IsNullOrEmpty(rolecode))
  1208. {
  1209. List<string> list_rolecode = new List<string>(rolecode.Split(','));
  1210. query = query.Where(it => list_rolecode.Contains(it.role_code));
  1211. }
  1212. if (!string.IsNullOrEmpty(projectid))
  1213. query = query.Where(it => it.projectlist.Contains(projectid));
  1214. #endregion
  1215. return query;
  1216. }
  1217. }
  1218. }