You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

880 lines
32 KiB

  1. using Dapper;
  2. using Learun.DataBase.Repository;
  3. using Learun.Util;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Linq;
  8. using System.Text;
  9. using Learun.Application.Base.AuthorizeModule;
  10. using Learun.Application.Organization;
  11. using System.Reflection;
  12. using Learun.Application.Base.SystemModule;
  13. using Learun.Application.TwoDevelopment.LogisticsManagement;
  14. namespace Learun.Application.TwoDevelopment.EducationalAdministration
  15. {
  16. /// <summary>
  17. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  18. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  19. /// 创 建:超级管理员
  20. /// 日 期:2019-02-21 16:53
  21. /// 描 述:学生学籍
  22. /// </summary>
  23. public class StuInfoBasicService : RepositoryFactory
  24. {
  25. #region 获取数据
  26. /// <summary>
  27. /// 获取页面显示列表数据
  28. /// <summary>
  29. /// <param name="queryJson">查询参数</param>
  30. /// <returns></returns>
  31. public IEnumerable<StuInfoBasicEntity> GetPageList(Pagination pagination, string queryJson)
  32. {
  33. try
  34. {
  35. var strSql = new StringBuilder();
  36. strSql.Append("SELECT t.* ");
  37. strSql.Append(" FROM StuInfoBasic t ");
  38. strSql.Append(" WHERE 1=1 ");
  39. var queryParam = queryJson.ToJObject();
  40. // 虚拟参数
  41. var dp = new DynamicParameters(new { });
  42. if (!queryParam["StuNo"].IsEmpty())
  43. {
  44. dp.Add("StuNo", queryParam["StuNo"].ToString(), DbType.String);
  45. strSql.Append(" AND t.StuNo = @StuNo ");
  46. }
  47. if (!queryParam["StuName"].IsEmpty())
  48. {
  49. dp.Add("StuName", "%" + queryParam["StuName"].ToString() + "%", DbType.String);
  50. strSql.Append(" AND t.StuName Like @StuName ");
  51. }
  52. if (!queryParam["DeptNo"].IsEmpty())
  53. {
  54. dp.Add("DeptNo", "" + queryParam["DeptNo"].ToString() + "", DbType.String);
  55. strSql.Append(" AND t.DeptNo=@DeptNo ");
  56. }
  57. if (!queryParam["MajorNo"].IsEmpty())
  58. {
  59. dp.Add("MajorNo", "" + queryParam["MajorNo"].ToString() + "", DbType.String);
  60. strSql.Append(" AND t.MajorNo=@MajorNo ");
  61. }
  62. if (!queryParam["ClassNo"].IsEmpty())
  63. {
  64. dp.Add("ClassNo", "" + queryParam["ClassNo"].ToString() + "", DbType.String);
  65. strSql.Append(" AND t.ClassNo=@ClassNo ");
  66. }
  67. if (!queryParam["Grade"].IsEmpty())
  68. {
  69. dp.Add("Grade", "" + queryParam["Grade"].ToString() + "", DbType.String);
  70. strSql.Append(" AND t.Grade=@Grade ");
  71. }
  72. if (!queryParam["FinishSchoolMark"].IsEmpty())
  73. {
  74. dp.Add("FinishSchoolMark", "" + queryParam["FinishSchoolMark"].ToString() + "", DbType.String);
  75. if (queryParam["FinishSchoolMark"].ToString() == "0")
  76. {
  77. strSql.Append(" AND (t.FinishSchoolMark is null or t.FinishSchoolMark='0') ");
  78. }
  79. else
  80. {
  81. strSql.Append(" AND t.FinishSchoolMark=@FinishSchoolMark ");
  82. }
  83. }
  84. if (!queryParam["Remark"].IsEmpty())
  85. {
  86. dp.Add("Remark", "%" + queryParam["Remark"].ToString() + "%", DbType.String);
  87. strSql.Append(" AND t.Remark Like @Remark ");
  88. }
  89. return this.BaseRepository("CollegeMIS").FindList<StuInfoBasicEntity>(strSql.ToString(), dp, pagination);
  90. }
  91. catch (Exception ex)
  92. {
  93. if (ex is ExceptionEx)
  94. {
  95. throw;
  96. }
  97. else
  98. {
  99. throw ExceptionEx.ThrowServiceException(ex);
  100. }
  101. }
  102. }
  103. internal List<string> GetSaveClassStudents(string account)
  104. {
  105. try
  106. {
  107. var classNO = this.BaseRepository("CollegeMIS").FindEntity<StuInfoBasicEntity>(a => a.StuNo == account).ClassNo;
  108. return this.BaseRepository("CollegeMIS").FindList<StuInfoBasicEntity>(a => a.ClassNo == classNO).Select(a => a.StuNo).ToList();
  109. }
  110. catch (Exception ex)
  111. {
  112. if (ex is ExceptionEx)
  113. {
  114. throw;
  115. }
  116. else
  117. {
  118. throw ExceptionEx.ThrowServiceException(ex);
  119. }
  120. }
  121. }
  122. internal bool GetAny()
  123. {
  124. try
  125. {
  126. return this.BaseRepository("CollegeMIS").FindList<StuInfoBasicEntity>().ToList().Count > 0 ? true : false;
  127. }
  128. catch (Exception ex)
  129. {
  130. if (ex is ExceptionEx)
  131. {
  132. throw;
  133. }
  134. else
  135. {
  136. throw ExceptionEx.ThrowServiceException(ex);
  137. }
  138. }
  139. }
  140. internal StuInfoBasicEntity GetStuInfoBasicEntityByStuNo(string enCode)
  141. {
  142. try
  143. {
  144. var data = this.BaseRepository("CollegeMIS").FindEntity<StuInfoBasicEntity>(a => a.StuNo == enCode);
  145. if (data != null && (data.Photo != null && data.Photo != ""))
  146. {
  147. var url = this.BaseRepository().FindEntity<AnnexesFileEntity>(a => a.F_FolderId == data.Photo)?.F_FilePath;
  148. if (!string.IsNullOrEmpty(url))
  149. {
  150. url = "/" + url.Substring(url.IndexOf("Resource"));
  151. data.Photo = url;
  152. }
  153. }
  154. return data;
  155. }
  156. catch (Exception ex)
  157. {
  158. if (ex is ExceptionEx)
  159. {
  160. throw;
  161. }
  162. else
  163. {
  164. throw ExceptionEx.ThrowServiceException(ex);
  165. }
  166. }
  167. }
  168. public StuInfoBasicEntity GetStuInfoBasicEntityByStuName(string name)
  169. {
  170. try
  171. {
  172. return this.BaseRepository("CollegeMIS").FindEntity<StuInfoBasicEntity>(a => a.StuName == name);
  173. }
  174. catch (Exception ex)
  175. {
  176. if (ex is ExceptionEx)
  177. {
  178. throw;
  179. }
  180. else
  181. {
  182. throw ExceptionEx.ThrowServiceException(ex);
  183. }
  184. }
  185. }
  186. /// <summary>
  187. /// 获取StuInfoBasic表实体数据
  188. /// <param name="keyValue">主键</param>
  189. /// <summary>
  190. /// <returns></returns>
  191. public StuInfoBasicEntity GetStuInfoBasicEntity(string keyValue)
  192. {
  193. try
  194. {
  195. return this.BaseRepository("CollegeMIS").FindEntity<StuInfoBasicEntity>(keyValue);
  196. }
  197. catch (Exception ex)
  198. {
  199. if (ex is ExceptionEx)
  200. {
  201. throw;
  202. }
  203. else
  204. {
  205. throw ExceptionEx.ThrowServiceException(ex);
  206. }
  207. }
  208. }
  209. /// <summary>
  210. /// 获取准许毕业的学生的专业
  211. /// <summary>
  212. /// <returns></returns>
  213. public List<CdMajorEntity> GetMajorInfoWithGraduation()
  214. {
  215. try
  216. {
  217. var stuInfo = this.BaseRepository("CollegeMIS")
  218. .FindList<StuInfoBasicEntity>(a => a.FinishSchoolMark == "1").ToList();
  219. var majorNoList = stuInfo.GroupBy(a => a.MajorNo).Select(a => a.Key).ToList();
  220. var majorList = this.BaseRepository("CollegeMIS")
  221. .FindList<CdMajorEntity>(a => majorNoList.Contains(a.MajorNo)).ToList();
  222. return majorList;
  223. }
  224. catch (Exception ex)
  225. {
  226. if (ex is ExceptionEx)
  227. {
  228. throw;
  229. }
  230. else
  231. {
  232. throw ExceptionEx.ThrowServiceException(ex);
  233. }
  234. }
  235. }
  236. /// <summary>
  237. /// 获取StuInfoBasic表实体数据
  238. /// <param name="keyValue">主键</param>
  239. /// <summary>
  240. /// <returns></returns>
  241. public void CreateGraduateNoByMajor(string CityCode, string SchoolCode, string MajorList)
  242. {
  243. try
  244. {
  245. var year = DateTime.Now.Year.ToString().Substring(2, 2);
  246. var firstStr = year + CityCode + SchoolCode;
  247. //获取最大的序号
  248. var DiplomaNoList = this.BaseRepository("CollegeMIS")
  249. .FindList<StuInfoBasicEntity>(a => a.DiplomaNo.Contains(firstStr)).Select(a => a.DiplomaNo.Substring(a.DiplomaNo.Length - 4, 4).ToInt()).ToList();
  250. var orderNo = 1;
  251. if (DiplomaNoList.Count() > 0)
  252. {
  253. var MaxDiplomaNo = DiplomaNoList.Max(a => a);
  254. orderNo = MaxDiplomaNo + 1;
  255. }
  256. var ListMajorNo = MajorList.Split(',').ToList();
  257. foreach (var MajorNo in ListMajorNo)
  258. {
  259. var stuList = this.BaseRepository("CollegeMIS")
  260. .FindList<StuInfoBasicEntity>(a => a.MajorNo == MajorNo)
  261. .Where(a => a.DiplomaNo == null || a.DiplomaNo == "");
  262. if (stuList.Count() > 0)
  263. {
  264. foreach (var stuInfo in stuList)
  265. {
  266. stuInfo.DiplomaNo = firstStr + orderNo.ToString().PadLeft(4, '0');
  267. this.BaseRepository("CollegeMIS").Update(stuInfo);
  268. orderNo++;
  269. }
  270. }
  271. }
  272. }
  273. catch (Exception ex)
  274. {
  275. if (ex is ExceptionEx)
  276. {
  277. throw;
  278. }
  279. else
  280. {
  281. throw ExceptionEx.ThrowServiceException(ex);
  282. }
  283. }
  284. }
  285. /// <summary>
  286. /// 获取StuInfoBasic表实体数据
  287. /// <param name="keyValue">主键</param>
  288. /// <summary>
  289. /// <returns></returns>
  290. public StuInfoBasicEntity GetStuNoByAccount(string keyValue)
  291. {
  292. try
  293. {
  294. return this.BaseRepository("CollegeMIS").FindEntity<StuInfoBasicEntity>(a => a.StuNo == keyValue);
  295. }
  296. catch (Exception ex)
  297. {
  298. if (ex is ExceptionEx)
  299. {
  300. throw;
  301. }
  302. else
  303. {
  304. throw ExceptionEx.ThrowServiceException(ex);
  305. }
  306. }
  307. }
  308. /// <summary>
  309. /// 获取树形数据
  310. /// </summary>
  311. /// <returns></returns>
  312. public DataTable GetSqlTree()
  313. {
  314. try
  315. {
  316. var ClassDiredctorNo = LoginUserInfo.Get().account;
  317. return this.BaseRepository("CollegeMIS").FindTable($" SELECT * FROM dbo.ClassInfo where ClassDiredctorNo='{ClassDiredctorNo}' or ClassTutorNo='{ClassDiredctorNo}'");
  318. }
  319. catch (Exception ex)
  320. {
  321. if (ex is ExceptionEx)
  322. {
  323. throw;
  324. }
  325. else
  326. {
  327. throw ExceptionEx.ThrowServiceException(ex);
  328. }
  329. }
  330. }
  331. #endregion
  332. #region 提交数据
  333. /// <summary>
  334. /// 审核全部
  335. /// </summary>
  336. public void CheckAll()
  337. {
  338. try
  339. {
  340. this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoBasic set CheckMark=1");
  341. }
  342. catch (Exception ex)
  343. {
  344. if (ex is ExceptionEx)
  345. {
  346. throw;
  347. }
  348. else
  349. {
  350. throw ExceptionEx.ThrowServiceException(ex);
  351. }
  352. }
  353. }
  354. /// <summary>
  355. /// 准许毕业操作
  356. /// </summary>
  357. public void AllowGraduate(string stuNo, string status)
  358. {
  359. try
  360. {
  361. var list = stuNo.Split(',').ToList().Select(a => "'" + a + "'");
  362. var stulist = string.Join(",", list);
  363. this.BaseRepository("CollegeMIS").ExecuteBySql($"UPDATE dbo.StuInfoBasic SET FinishSchoolMark ='{status}' WHERE StuNo in({stulist})");
  364. }
  365. catch (Exception ex)
  366. {
  367. if (ex is ExceptionEx)
  368. {
  369. throw;
  370. }
  371. else
  372. {
  373. throw ExceptionEx.ThrowServiceException(ex);
  374. }
  375. }
  376. }
  377. public void SynPhoto()
  378. {
  379. try
  380. {
  381. var stuList = this.BaseRepository("CollegeMIS").FindList<StuInfoBasicEntity>()
  382. .ToList();
  383. var url = AppDomain.CurrentDomain.BaseDirectory;
  384. foreach (var stuInfo in stuList)
  385. {
  386. //照片不为空
  387. if (!string.IsNullOrEmpty(stuInfo.Photo))
  388. {
  389. var annex = this.BaseRepository()
  390. .FindEntity<AnnexesFileEntity>(a => a.F_FolderId == stuInfo.Photo);
  391. if (annex == null)
  392. {
  393. var annexEntity = new AnnexesFileEntity()
  394. {
  395. F_Id = Guid.NewGuid().ToString(),
  396. F_FileName = stuInfo.IdentityCardNo + ".jpg",
  397. F_FilePath = $"{url}/Resource/UserPhoto/{stuInfo.IdentityCardNo}.jpg",
  398. F_FolderId = stuInfo.Photo
  399. };
  400. this.BaseRepository().Insert(annexEntity);
  401. }
  402. else
  403. {
  404. annex.F_FileName = stuInfo.IdentityCardNo + ".jpg";
  405. annex.F_FilePath = $"{url}/Resource/UserPhoto/{stuInfo.IdentityCardNo}.jpg";
  406. this.BaseRepository().Update(annex);
  407. }
  408. }
  409. else
  410. {
  411. stuInfo.Photo = Guid.NewGuid().ToString();
  412. var annexEntity = new AnnexesFileEntity()
  413. {
  414. F_Id = Guid.NewGuid().ToString(),
  415. F_FileName = stuInfo.IdentityCardNo + ".jpg",
  416. F_FilePath = $"{url}/Resource/UserPhoto/{stuInfo.IdentityCardNo}.jpg",
  417. F_FolderId = stuInfo.Photo
  418. };
  419. annexEntity.Create();
  420. this.BaseRepository("CollegeMIS").Update(stuInfo);
  421. this.BaseRepository().Insert(annexEntity);
  422. }
  423. }
  424. }
  425. catch (Exception ex)
  426. {
  427. if (ex is ExceptionEx)
  428. {
  429. throw;
  430. }
  431. else
  432. {
  433. throw ExceptionEx.ThrowServiceException(ex);
  434. }
  435. }
  436. }
  437. /// <summary>
  438. /// 删除实体数据
  439. /// <param name="keyValue">主键</param>
  440. /// <summary>
  441. /// <returns></returns>
  442. public void DeleteEntity(string keyValue)
  443. {
  444. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  445. try
  446. {
  447. //单个删除
  448. //this.BaseRepository("CollegeMIS").Delete<StuInfoBasicEntity>(t => t.StuId == keyValue);
  449. //多个删除
  450. var keyValueArr = keyValue.Split(',');
  451. foreach (var item in keyValueArr)
  452. {
  453. db.Delete<StuInfoBasicEntity>(t => t.StuId == item);
  454. }
  455. db.Commit();
  456. }
  457. catch (Exception ex)
  458. {
  459. db.Rollback();
  460. if (ex is ExceptionEx)
  461. {
  462. throw;
  463. }
  464. else
  465. {
  466. throw ExceptionEx.ThrowServiceException(ex);
  467. }
  468. }
  469. }
  470. /// <summary>
  471. /// 领取毕业证
  472. /// <param name="keyValue">主键</param>
  473. /// <summary>
  474. /// <returns></returns>
  475. public void GetCard(string keyValue)
  476. {
  477. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  478. try
  479. {
  480. var keyValueArr = keyValue.Split(',');
  481. foreach (var item in keyValueArr)
  482. {
  483. var sql = $"UPDATE dbo.StuInfoBasic SET FinishSchoolMark='2',FinishSchoolDate=GETDATE() WHERE StuId='{item}'";
  484. db.ExecuteBySql(sql);
  485. }
  486. db.Commit();
  487. }
  488. catch (Exception ex)
  489. {
  490. db.Rollback();
  491. if (ex is ExceptionEx)
  492. {
  493. throw;
  494. }
  495. else
  496. {
  497. throw ExceptionEx.ThrowServiceException(ex);
  498. }
  499. }
  500. }
  501. /// <summary>
  502. /// 毕业生归档
  503. /// <summary>
  504. /// <returns></returns>
  505. public void StuStore()
  506. {
  507. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  508. var adb = this.BaseRepository().BeginTrans();
  509. try
  510. {
  511. //归档前提为已经领取毕业证的学生
  512. var stuInfos = db
  513. .FindList<StuInfoBasicEntity>(a => a.FinishSchoolMark == "2");
  514. foreach (var item in stuInfos)
  515. {
  516. var StuInfoType = typeof(StuInfoBasicEntity);
  517. var PropertyInfoStuInfo = StuInfoType.GetProperties();
  518. var GraduateEntity = new StuInfoGraduateEntity();
  519. var typegraduate = typeof(StuInfoGraduateEntity);
  520. var PropertyInfoGraduate = typegraduate.GetProperties();
  521. foreach (var itemStuInfo in PropertyInfoStuInfo)
  522. {
  523. var objStuInfoType = itemStuInfo.GetValue(StuInfoType);
  524. foreach (var itemGraduate in PropertyInfoGraduate)
  525. {
  526. if (itemGraduate.Name == itemStuInfo.Name)
  527. {
  528. itemGraduate.SetValue(GraduateEntity, objStuInfoType, null);
  529. }
  530. }
  531. }
  532. var accountInfo = adb.FindEntity<UserEntity>(a => a.F_Account == item.StuNo);
  533. if (accountInfo != null)
  534. {
  535. //删除账户
  536. adb.Delete(accountInfo);
  537. }
  538. //清空宿舍信息
  539. var dormitory = db
  540. .FindEntity<Acc_DormitoryBuildEntity>(a => a.StudentID == item.StuId);
  541. if (dormitory != null)
  542. {
  543. dormitory.StudentID = "";
  544. dormitory.StuName = "";
  545. db.Update(dormitory);
  546. }
  547. db.Delete(item);
  548. db.Insert(GraduateEntity);
  549. }
  550. }
  551. catch (Exception ex)
  552. {
  553. db.Rollback();
  554. adb.Rollback();
  555. if (ex is ExceptionEx)
  556. {
  557. throw;
  558. }
  559. else
  560. {
  561. throw ExceptionEx.ThrowServiceException(ex);
  562. }
  563. }
  564. }
  565. /// <summary>
  566. /// 保存实体数据(新增、修改)
  567. /// <param name="keyValue">主键</param>
  568. /// <summary>
  569. /// <returns></returns>
  570. public void SaveEntity(string keyValue, StuInfoBasicEntity entity)
  571. {
  572. try
  573. {
  574. UserIBLL userIBLL = new UserBLL();
  575. if (!string.IsNullOrEmpty(keyValue))
  576. {
  577. entity.Modify(keyValue);
  578. var oldEntity = this.BaseRepository("CollegeMIS").FindEntity<StuInfoBasicEntity>(keyValue);
  579. List<StuInfoBasic_ChangeLogEntity> list = new List<StuInfoBasic_ChangeLogEntity>();
  580. var loginUser = LoginUserInfo.Get();
  581. var tableInfos = this.BaseRepository("CollegeMIS").FindTable(@"SELECT t.[name] AS 表名,c.[name] AS 字段名,cast(ep.[value]
  582. as varchar(100)) AS [字段说明]
  583. FROM sys.tables AS t
  584. INNER JOIN sys.columns
  585. AS c ON t.object_id = c.object_id
  586. LEFT JOIN sys.extended_properties AS ep
  587. ON ep.major_id = c.object_id AND ep.minor_id = c.column_id WHERE ep.class =1
  588. AND t.name='StuInfoBasic'");
  589. PropertyInfo[] properties = oldEntity.GetType().GetProperties();
  590. foreach (System.Reflection.PropertyInfo item in properties)
  591. {
  592. string name = item.Name;
  593. object oldValue = item.GetValue(oldEntity);
  594. object newValue = item.GetValue(entity);
  595. if (oldValue == null || newValue == null)
  596. {
  597. continue;
  598. }
  599. if (!oldValue.Equals(newValue))
  600. {
  601. var columnName = "";
  602. foreach (DataRow rows in tableInfos.Rows)
  603. {
  604. if (rows["字段名"].ToString() == item.Name)
  605. {
  606. columnName = rows["字段说明"].ToString();
  607. }
  608. }
  609. var changeEntity = new StuInfoBasic_ChangeLogEntity
  610. {
  611. StuID = keyValue,
  612. BeforeChange = oldValue.ToString(),
  613. AfterChange = newValue.ToString(),
  614. FieldName = columnName,
  615. UpdateBy = loginUser.userId,
  616. UpdateTime = DateTime.Now
  617. };
  618. changeEntity.Create();
  619. list.Add(changeEntity);
  620. }
  621. }
  622. if (list.Count > 0)
  623. {
  624. this.BaseRepository("CollegeMIS").Insert(list);
  625. }
  626. var annexesFileEntity = this.BaseRepository().FindEntity<AnnexesFileEntity>(a => a.F_FolderId == entity.Photo);
  627. var url = "";
  628. if (annexesFileEntity != null)
  629. {
  630. url = annexesFileEntity.F_FilePath;
  631. url = "/" + url.Substring(url.IndexOf("Resource"), url.Length - url.IndexOf("Resource"));
  632. }
  633. var baseUser = userIBLL.GetEntityByAccount(entity.StuNo);
  634. if (baseUser != null)
  635. {
  636. baseUser.F_HeadIcon = url;
  637. userIBLL.SaveEntity(baseUser.F_UserId, baseUser);
  638. }
  639. this.BaseRepository("CollegeMIS").Update(entity);
  640. }
  641. else
  642. {
  643. entity.Create();
  644. this.BaseRepository("CollegeMIS").Insert(entity);
  645. }
  646. }
  647. catch (Exception ex)
  648. {
  649. if (ex is ExceptionEx)
  650. {
  651. throw;
  652. }
  653. else
  654. {
  655. throw ExceptionEx.ThrowServiceException(ex);
  656. }
  657. }
  658. }
  659. #endregion
  660. public class TableInfo
  661. {
  662. public string TableName { get; set; }
  663. public string ColumnName { get; set; }
  664. public string ColumnDescription { get; set; }
  665. }
  666. public void GenerateAccout()
  667. {
  668. UserRelationIBLL userRelationIBLL = new UserRelationBLL();
  669. UserIBLL userIBLL = new UserBLL();
  670. try
  671. {
  672. var stuInfoBasicEntities = BaseRepository("CollegeMIS").FindList<StuInfoBasicEntity>(m => m.CheckMark != "0");
  673. var alluserlist = userIBLL.GetAllList().Where(m => m.F_Description == "学生");
  674. var roleId = Config.GetValue("GenerateStudentsRoleId");
  675. var defaultpwd = Config.GetValue("defaultpwd");
  676. //读取默认密码配置中已启用的密码
  677. var Sys_DefaultPwdConfigEntity = this.BaseRepository().FindEntity<Sys_DefaultPwdConfigEntity>(x => x.IsEnabled == true);
  678. if (Sys_DefaultPwdConfigEntity != null)
  679. {
  680. defaultpwd = Sys_DefaultPwdConfigEntity.Pwd;
  681. }
  682. var studentList = new List<UserEntity>();
  683. foreach (var tEntity in stuInfoBasicEntities)
  684. {
  685. if (alluserlist.Count(m => m.F_Account == tEntity.StuNo) > 0)
  686. {
  687. continue;
  688. }
  689. var annexesFileEntity = this.BaseRepository().FindEntity<AnnexesFileEntity>(a => a.F_FolderId == tEntity.Photo);
  690. var url = "";
  691. if (annexesFileEntity != null)
  692. {
  693. url = annexesFileEntity.F_FilePath;
  694. url = "/" + url.Substring(url.IndexOf("Resource"));
  695. }
  696. UserEntity userbase = new UserEntity();
  697. userbase.F_Account = tEntity.StuNo;
  698. userbase.F_RealName = tEntity.StuName;
  699. userbase.F_EnCode = tEntity.StuNo;
  700. userbase.F_Password = Md5Helper.Encrypt(defaultpwd, 32).ToLower();
  701. userbase.F_HeadIcon = string.IsNullOrEmpty(url) ? Config.GetValue("defaultheadimg") : url;
  702. userbase.F_Gender = tEntity.GenderNo.HasValue ? Convert.ToInt32(tEntity.GenderNo.Value) : 1;
  703. userbase.F_DeleteMark = 0;
  704. userbase.F_EnabledMark = 1;
  705. userbase.F_Mobile = tEntity.mobile;
  706. userbase.F_Description = "学生";
  707. userbase.F_CompanyId = tEntity.F_SchoolId;
  708. userbase.F_DepartmentId = tEntity.DeptNo;
  709. userbase.F_IdentityCardNo = tEntity.IdentityCardNo;
  710. userIBLL.SaveEntity(null, userbase);
  711. studentList.Add(userbase);
  712. }
  713. if (studentList.Any())
  714. {
  715. string s = studentList.Select(m => m.F_UserId).Aggregate((current, userEntity) => current + "," + userEntity);
  716. userRelationIBLL.SaveEntityList2(roleId, 1, s);
  717. }
  718. }
  719. catch (Exception ex)
  720. {
  721. if (ex is ExceptionEx)
  722. {
  723. throw;
  724. }
  725. else
  726. {
  727. throw ExceptionEx.ThrowServiceException(ex);
  728. }
  729. }
  730. }
  731. public void UpdateAccount()
  732. {
  733. try
  734. {
  735. UserIBLL userIBLL = new UserBLL();
  736. var teacherList = this.BaseRepository("CollegeMIS").FindList<StuInfoBasicEntity>();
  737. var baseTeacherList = userIBLL.GetAllList().Where(m => m.F_Description == "学生");
  738. foreach (var baseTeacher in baseTeacherList)
  739. {
  740. var num = 0;
  741. var teacher = teacherList.FirstOrDefault(a => a.StuNo == baseTeacher.F_Account);
  742. if (teacher != null)
  743. {
  744. if (baseTeacher.F_RealName != teacher.StuName)
  745. {
  746. baseTeacher.F_RealName = teacher.StuName;
  747. num++;
  748. }
  749. if (baseTeacher.F_Gender != Convert.ToInt32(teacher.GenderNo))
  750. {
  751. baseTeacher.F_Gender = Convert.ToInt32(teacher.GenderNo);
  752. num++;
  753. }
  754. if (baseTeacher.F_Mobile != teacher.mobile)
  755. {
  756. baseTeacher.F_Mobile = teacher.mobile;
  757. num++;
  758. }
  759. if (baseTeacher.F_CompanyId != teacher.F_SchoolId)
  760. {
  761. baseTeacher.F_CompanyId = teacher.F_SchoolId;
  762. num++;
  763. }
  764. if (baseTeacher.F_DepartmentId != teacher.DeptNo)
  765. {
  766. baseTeacher.F_DepartmentId = teacher.DeptNo;
  767. num++;
  768. }
  769. if (baseTeacher.F_IdentityCardNo != teacher.IdentityCardNo)
  770. {
  771. baseTeacher.F_IdentityCardNo = teacher.IdentityCardNo;
  772. num++;
  773. }
  774. if (num > 0)
  775. {
  776. userIBLL.UpdateEntity(baseTeacher);
  777. }
  778. }
  779. }
  780. }
  781. catch (Exception ex)
  782. {
  783. if (ex is ExceptionEx)
  784. {
  785. throw;
  786. }
  787. else
  788. {
  789. throw ExceptionEx.ThrowServiceException(ex);
  790. }
  791. }
  792. }
  793. public IEnumerable<StuInfoBasicEntity> GetAllList()
  794. {
  795. try
  796. {
  797. return this.BaseRepository("CollegeMIS").FindList<StuInfoBasicEntity>(m => m.CheckMark == "1");
  798. }
  799. catch (Exception ex)
  800. {
  801. if (ex is ExceptionEx)
  802. {
  803. throw;
  804. }
  805. else
  806. {
  807. throw ExceptionEx.ThrowServiceException(ex);
  808. }
  809. }
  810. }
  811. public IEnumerable<StuInfoBasicEntity> GetStuInfoByClassNo(string classNo)
  812. {
  813. try
  814. {
  815. return this.BaseRepository("CollegeMIS").FindList<StuInfoBasicEntity>(m => m.CheckMark == "1" && m.ClassNo == classNo);
  816. }
  817. catch (Exception ex)
  818. {
  819. if (ex is ExceptionEx)
  820. {
  821. throw;
  822. }
  823. else
  824. {
  825. throw ExceptionEx.ThrowServiceException(ex);
  826. }
  827. }
  828. }
  829. }
  830. }