Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

275 righe
11 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Web;
  6. using Learun.Application.Base.SystemModule;
  7. using Learun.Application.TwoDevelopment.EducationalAdministration;
  8. using Learun.Application.TwoDevelopment.LogisticsManagement;
  9. using Learun.Application.TwoDevelopment.ReceiveSendFeeManagement;
  10. using Learun.Util;
  11. using Nancy;
  12. namespace Learun.Application.WebApi.Modules
  13. {
  14. public class StuInfoFreshApi : BaseApi
  15. {
  16. public StuInfoFreshApi()
  17. : base("/StuInfoFresh")
  18. {
  19. Get["/stuInfoFreshEntity"] = GetStuInfoFreshEntity;
  20. Get["/saveStuInfoFresh"] = GetSaveStuInfoFresh;
  21. Post["/savePhoto"] = GetSavePhoto;
  22. Get["/payFeeDetail"] = GetPayFeeDetail;
  23. }
  24. private StuInfoFreshIBLL stuInfoFreshIBLL = new StuInfoFreshBLL();
  25. private CdMajorIBLL cdMajorIBLL = new CdMajorBLL();
  26. private CdDeptIBLL cdDeptIBLL = new CdDeptBLL();
  27. private ClassInfoIBLL classInfoIBLL = new ClassInfoBLL();
  28. private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();
  29. private EmpInfoIBLL empInfoIBLL = new EmpInfoBLL();
  30. private AccommodationIBLL accdormitoryIBLL = new AccommodationBLL();
  31. private FinaChargesStandardIBLL finaChargesStandardIBLL = new FinaChargesStandardBLL();
  32. /// <summary>
  33. /// 获取个人信息
  34. /// </summary>
  35. /// <param name="_"></param>
  36. /// <returns></returns>
  37. private Response GetStuInfoFreshEntity(dynamic _)
  38. {
  39. var url = Config.GetValue("defaultheadimg");
  40. var StuInfoFreshFamilyList = new List<StuInfoFreshFamilyEntity>();
  41. var StuInfoFreshEmergePeopleList = new List<StuInfoFreshEmergePeopleEntity>();
  42. var StuInfoFreshEntity = stuInfoFreshIBLL.GetStuInfoFreshEntityByStuNo(userInfo.account);
  43. if (StuInfoFreshEntity != null)
  44. {
  45. //处理数据源
  46. StuInfoFreshEntity.MajorNo = cdMajorIBLL.GetCdMajorEntityByMajorNo(StuInfoFreshEntity.MajorNo).MajorName;
  47. StuInfoFreshEntity.DeptNo = cdDeptIBLL.GetCdDeptEntityByNo(StuInfoFreshEntity.DeptNo).DeptName;
  48. var classInfoEntity = classInfoIBLL.GetClassInfoEntityByClassNo(StuInfoFreshEntity.ClassNo);
  49. if (classInfoEntity != null)
  50. {
  51. StuInfoFreshEntity.ClassNo = classInfoEntity.ClassName;
  52. StuInfoFreshEntity.ClassTutorNo = classInfoEntity.ClassTutorNo;
  53. var empInfoEntity = empInfoIBLL.GetEmpInfoEntityByEmpNo(classInfoEntity.ClassTutorNo);
  54. if (empInfoEntity != null)
  55. {
  56. StuInfoFreshEntity.ClassTutorName = empInfoEntity.EmpName;
  57. StuInfoFreshEntity.ClassTutorMobile = empInfoEntity.mobile;
  58. }
  59. }
  60. if (StuInfoFreshEntity.PayFeeStatus == "1")
  61. {
  62. StuInfoFreshEntity.PayFeeStatus = "已缴费";
  63. }
  64. else
  65. {
  66. StuInfoFreshEntity.PayFeeStatus = "未缴费";
  67. }
  68. if (StuInfoFreshEntity.CollectFileStatus == "1")
  69. {
  70. StuInfoFreshEntity.CollectFileStatus = "已提交";
  71. }
  72. else
  73. {
  74. StuInfoFreshEntity.CollectFileStatus = "未提交";
  75. }
  76. if (StuInfoFreshEntity.GetKeyStatus == "1")
  77. {
  78. StuInfoFreshEntity.GetKeyStatus = "已领取";
  79. }
  80. else
  81. {
  82. StuInfoFreshEntity.GetKeyStatus = "未领取";
  83. }
  84. //获取头像地址
  85. if (StuInfoFreshEntity.IsPhoto == true && !string.IsNullOrEmpty(StuInfoFreshEntity.Photo))
  86. {
  87. var annexesFileEntity = annexesFileIBLL.GetEntity(StuInfoFreshEntity.Photo);
  88. if (annexesFileEntity != null)
  89. {
  90. url = annexesFileEntity.F_FilePath.Substring(annexesFileEntity.F_FilePath.IndexOf("Resource"));
  91. }
  92. }
  93. StuInfoFreshEntity.DormitoryName = accdormitoryIBLL.GetDormitoryInfoByPlanStuNo(StuInfoFreshEntity.ID);
  94. //是否完善信息
  95. StuInfoFreshFamilyList = stuInfoFreshIBLL.GetStuInfoFreshFamilyList(StuInfoFreshEntity.ID).ToList();
  96. StuInfoFreshEmergePeopleList = stuInfoFreshIBLL.GetStuInfoFreshEmergePeopleList(StuInfoFreshEntity.ID).ToList();
  97. StuInfoFreshEntity.ClassTutorNo = StuInfoFreshFamilyList.Any() ? "已完善" : "未完善";
  98. }
  99. var result = new
  100. {
  101. StuInfoFreshEntity = StuInfoFreshEntity,
  102. StuInfoFreshFamilyList = StuInfoFreshFamilyList,
  103. StuInfoFreshEmergePeopleList = StuInfoFreshEmergePeopleList,
  104. Url = url
  105. };
  106. return Success(result);
  107. }
  108. /// <summary>
  109. /// 保存个人信息
  110. /// </summary>
  111. /// <param name="_"></param>
  112. /// <returns></returns>
  113. private Response GetSaveStuInfoFresh(dynamic _)
  114. {
  115. var model = this.GetReqData<StuInfoFreshModel>();
  116. var entity = stuInfoFreshIBLL.GetStuInfoFreshEntity(model.ID);
  117. entity.RegionNo = model.RegionNo;
  118. entity.FamilyAddress = model.FamilyAddress;
  119. entity.telephone = model.telephone;
  120. if (!string.IsNullOrEmpty(model.Photo))
  121. {
  122. entity.IsPhoto = true;
  123. entity.Photo = model.Photo;
  124. }
  125. else
  126. {
  127. entity.IsPhoto = false;
  128. entity.Photo = "";
  129. }
  130. stuInfoFreshIBLL.SaveEntity(entity.ID, entity, model.StuInfoFreshEmergePeopleEntities, model.StuInfoFreshFamilyEntities);
  131. return Success("保存成功");
  132. }
  133. /// <summary>
  134. /// 头像
  135. /// </summary>
  136. /// <param name="_"></param>
  137. /// <returns></returns>
  138. private Response GetSavePhoto(dynamic _)
  139. {
  140. var model = this.GetReqData<PhotoModel>();
  141. var folderId = Guid.NewGuid().ToString();
  142. string filePath = Config.GetValue("AnnexesFile");
  143. string uploadDate = DateTime.Now.ToString("yyyyMMdd");
  144. string FileEextension = ".png";
  145. string fileGuid = Guid.NewGuid().ToString();
  146. string virtualPath = string.Format("{0}/{1}/{2}/{3}{4}", filePath, userInfo.account, uploadDate, fileGuid, FileEextension);
  147. //创建文件夹
  148. string path = Path.GetDirectoryName(virtualPath);
  149. Directory.CreateDirectory(path);
  150. AnnexesFileEntity fileAnnexesEntity = new AnnexesFileEntity();
  151. if (!System.IO.File.Exists(virtualPath))
  152. {
  153. //byte[] bytes = Convert.FromBase64String(model.Base64Url.Replace("data:image/jpeg;base64,", ""));
  154. byte[] bytes = Convert.FromBase64String(model.Base64Url.Substring(model.Base64Url.IndexOf("base64,") + 7));
  155. FileInfo file = new FileInfo(virtualPath);
  156. FileStream fs = file.Create();
  157. fs.Write(bytes, 0, bytes.Length);
  158. fs.Close();
  159. //文件信息写入数据库
  160. fileAnnexesEntity.F_Id = fileGuid;
  161. fileAnnexesEntity.F_FileName = "userphoto.png";
  162. fileAnnexesEntity.F_FilePath = virtualPath;
  163. fileAnnexesEntity.F_FileSize = bytes.Length.ToString();
  164. fileAnnexesEntity.F_FileExtensions = FileEextension;
  165. fileAnnexesEntity.F_FileType = FileEextension.Replace(".", "");
  166. fileAnnexesEntity.F_CreateUserId = userInfo.userId;
  167. fileAnnexesEntity.F_CreateUserName = userInfo.realName;
  168. annexesFileIBLL.SaveEntity(folderId, fileAnnexesEntity);
  169. }
  170. var data = new
  171. {
  172. Url = virtualPath.Substring(virtualPath.IndexOf("Resource")),
  173. AnnexesFileId = fileGuid
  174. };
  175. return Success(data);
  176. }
  177. /// <summary>
  178. /// 学费查询
  179. /// </summary>
  180. /// <param name="_"></param>
  181. /// <returns></returns>
  182. private Response GetPayFeeDetail(dynamic _)
  183. {
  184. var academicAndYear = Common.GetSemesterAndYear();
  185. var FinaChargesStandardList = new List<FinaChargesStandardEntity>();
  186. var StuInfoFreshData = stuInfoFreshIBLL.GetStuInfoFreshEntityByStuNo(userInfo.account);
  187. if (StuInfoFreshData != null)
  188. {
  189. if (!string.IsNullOrEmpty(StuInfoFreshData.ClassNo) && !string.IsNullOrEmpty(StuInfoFreshData.MajorNo))
  190. {
  191. var ClassInfoEntity = classInfoIBLL.GetClassInfoEntityByClassNo(StuInfoFreshData.ClassNo);
  192. if (ClassInfoEntity != null)
  193. {
  194. FinaChargesStandardList = finaChargesStandardIBLL.GetFinaChargesStandardListByMajorNoOfNotAll(StuInfoFreshData.MajorNo, academicAndYear.AcademicYearShort, academicAndYear.Semester, ClassInfoEntity.Grade).ToList();
  195. }
  196. }
  197. }
  198. var PayFeeTotal = FinaChargesStandardList.Select(x => x.Standard).Sum();
  199. var result = new
  200. {
  201. FinaChargesStandardList = FinaChargesStandardList,
  202. PayFeeTotal = PayFeeTotal,
  203. AcademicYearNo = academicAndYear.AcademicYearShort,
  204. Semester = academicAndYear.Semester,
  205. };
  206. return Success(result);
  207. }
  208. /// <summary>
  209. /// 个人信息
  210. /// </summary>
  211. public class StuInfoFreshModel
  212. {
  213. /// <summary>
  214. /// 主键
  215. /// </summary>
  216. public string ID { get; set; }
  217. /// <summary>
  218. /// 籍贯
  219. /// </summary>
  220. public string RegionNo { get; set; }
  221. /// <summary>
  222. /// 家庭住址
  223. /// </summary>
  224. public string FamilyAddress { get; set; }
  225. /// <summary>
  226. /// 联系电话
  227. /// </summary>
  228. public string telephone { get; set; }
  229. /// <summary>
  230. /// 头像地址
  231. /// </summary>
  232. public string Photo { get; set; }
  233. /// <summary>
  234. /// 家庭成员
  235. /// </summary>
  236. public List<StuInfoFreshFamilyEntity> StuInfoFreshFamilyEntities { get; set; }
  237. /// <summary>
  238. /// 紧急联系人
  239. /// </summary>
  240. public List<StuInfoFreshEmergePeopleEntity> StuInfoFreshEmergePeopleEntities { get; set; }
  241. }
  242. public class PhotoModel
  243. {
  244. public string Base64Url { get; set; }
  245. public string account { get; set; }
  246. }
  247. }
  248. }