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.
 
 
 
 
 
 

400 righe
16 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["/stuInfoFresh"] = GetStuInfoFresh;
  21. Get["/saveStuInfoFresh"] = GetSaveStuInfoFresh;
  22. Get["/saveLoan"] = GetSaveLoan;
  23. Post["/savePhoto"] = GetSavePhoto;
  24. Get["/payFeeDetail"] = GetPayFeeDetail;
  25. Get["/pageList"] = GetPageList;
  26. Get["/form"] = GetForm;
  27. Post["/save"] = SaveForm;
  28. }
  29. private StuInfoFreshIBLL stuInfoFreshIBLL = new StuInfoFreshBLL();
  30. private CdMajorIBLL cdMajorIBLL = new CdMajorBLL();
  31. private CdDeptIBLL cdDeptIBLL = new CdDeptBLL();
  32. private ClassInfoIBLL classInfoIBLL = new ClassInfoBLL();
  33. private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();
  34. private EmpInfoIBLL empInfoIBLL = new EmpInfoBLL();
  35. private AccommodationIBLL accdormitoryIBLL = new AccommodationBLL();
  36. private FinaChargesStandardIBLL finaChargesStandardIBLL = new FinaChargesStandardBLL();
  37. private ClassroomInfoIBLL classroomInfoIBLL = new ClassroomInfoBLL();
  38. /// <summary>
  39. /// 获取个人信息
  40. /// </summary>
  41. /// <param name="_"></param>
  42. /// <returns></returns>
  43. private Response GetStuInfoFreshEntity(dynamic _)
  44. {
  45. var url = Config.GetValue("defaultheadimg");
  46. var StuInfoFreshFamilyList = new List<StuInfoFreshFamilyEntity>();
  47. var StuInfoFreshEmergePeopleList = new List<StuInfoFreshEmergePeopleEntity>();
  48. var StuInfoFreshEntity = stuInfoFreshIBLL.GetStuInfoFreshEntityByStuNo(GetReqData());
  49. if (StuInfoFreshEntity != null)
  50. {
  51. //处理数据源
  52. StuInfoFreshEntity.MajorNo = cdMajorIBLL.GetCdMajorEntityByMajorNo(StuInfoFreshEntity.MajorNo)?.MajorName;
  53. var classInfoEntity = classInfoIBLL.GetClassInfoEntityByClassNo(StuInfoFreshEntity.ClassNo);
  54. if (classInfoEntity != null)
  55. {
  56. StuInfoFreshEntity.ClassNo = classInfoEntity.ClassName;
  57. if (classInfoEntity.ClassTutorNo != null)
  58. {
  59. StuInfoFreshEntity.ClassTutorNo = classInfoEntity.ClassTutorNo;
  60. var empInfoEntity = empInfoIBLL.GetEmpInfoEntityByEmpNo(classInfoEntity.ClassTutorNo);
  61. if (empInfoEntity != null)
  62. {
  63. StuInfoFreshEntity.ClassTutorName = empInfoEntity.EmpName;
  64. StuInfoFreshEntity.ClassTutorMobile = empInfoEntity.mobile;
  65. }
  66. }
  67. if (classInfoEntity.ClassDiredctorNo != null)
  68. {
  69. StuInfoFreshEntity.ClassDiredctorNo = classInfoEntity.ClassDiredctorNo;
  70. var empInfoEntity2 = empInfoIBLL.GetEmpInfoEntityByEmpNo(classInfoEntity.ClassDiredctorNo);
  71. if (empInfoEntity2 != null)
  72. {
  73. StuInfoFreshEntity.ClassDiredctorName = empInfoEntity2.EmpName;
  74. StuInfoFreshEntity.ClassDiredctorMobile = empInfoEntity2.mobile;
  75. }
  76. }
  77. if (classInfoEntity.SerialNum != null)
  78. {
  79. StuInfoFreshEntity.DefaultClassRoomNo = classInfoEntity.SerialNum;
  80. var classroomEntity = classroomInfoIBLL.GetClassroomInfoEntityByNo(classInfoEntity.SerialNum);
  81. if (classroomEntity != null)
  82. {
  83. StuInfoFreshEntity.DefaultClassRoomName = classroomEntity.ClassroomName;
  84. }
  85. }
  86. }
  87. //获取头像地址
  88. if (StuInfoFreshEntity.IsPhoto == true && !string.IsNullOrEmpty(StuInfoFreshEntity.Photo))
  89. {
  90. var annexesFileEntity = annexesFileIBLL.GetEntity(StuInfoFreshEntity.Photo);
  91. if (annexesFileEntity != null)
  92. {
  93. url = annexesFileEntity.F_FilePath.Substring(annexesFileEntity.F_FilePath.IndexOf("Resource"));
  94. }
  95. }
  96. StuInfoFreshEntity.DormitoryName = accdormitoryIBLL.GetDormitoryInfoByPlanStuNo(StuInfoFreshEntity.ID);
  97. if (StuInfoFreshEntity.IsPoor != "1")
  98. {
  99. StuInfoFreshEntity.IsPoor = "0";
  100. }
  101. if (StuInfoFreshEntity.GetKeyStatus != "1")
  102. {
  103. StuInfoFreshEntity.GetKeyStatus = "0";
  104. }
  105. if (StuInfoFreshEntity.GetCardStatus != "1")
  106. {
  107. StuInfoFreshEntity.GetCardStatus = "0";
  108. }
  109. if (StuInfoFreshEntity.OtherPayFeeStatus != "1")
  110. {
  111. StuInfoFreshEntity.OtherPayFeeStatus = "0";
  112. }
  113. if (StuInfoFreshEntity.CollectFileStatus != "1")
  114. {
  115. StuInfoFreshEntity.CollectFileStatus = "0";
  116. }
  117. //是否完善信息
  118. StuInfoFreshFamilyList = stuInfoFreshIBLL.GetStuInfoFreshFamilyList(StuInfoFreshEntity.ID).ToList();
  119. StuInfoFreshEmergePeopleList = stuInfoFreshIBLL.GetStuInfoFreshEmergePeopleList(StuInfoFreshEntity.ID).ToList();
  120. StuInfoFreshEntity.IsCompleteInfo = StuInfoFreshFamilyList.Any() ? "已完善" : "未完善";
  121. }
  122. var result = new
  123. {
  124. StuInfoFreshEntity = StuInfoFreshEntity,
  125. StuInfoFreshFamilyList = StuInfoFreshFamilyList,
  126. StuInfoFreshEmergePeopleList = StuInfoFreshEmergePeopleList,
  127. Url = url
  128. };
  129. return Success(result);
  130. }
  131. /// <summary>
  132. /// 获取个人信息
  133. /// </summary>
  134. /// <param name="_"></param>
  135. /// <returns></returns>
  136. private Response GetStuInfoFresh(dynamic _)
  137. {
  138. var StuInfoFreshEntity = stuInfoFreshIBLL.GetStuInfoFreshEntityByStuNo(userInfo.account);
  139. var result = new
  140. {
  141. StuInfoFreshEntity = StuInfoFreshEntity
  142. };
  143. return Success(result);
  144. }
  145. /// <summary>
  146. /// 保存完善个人信息
  147. /// </summary>
  148. /// <param name="_"></param>
  149. /// <returns></returns>
  150. private Response GetSaveStuInfoFresh(dynamic _)
  151. {
  152. var model = this.GetReqData<StuInfoFreshModel>();
  153. var entity = stuInfoFreshIBLL.GetStuInfoFreshEntity(model.ID);
  154. entity.RegionNo = model.RegionNo;
  155. entity.FamilyAddress = model.FamilyAddress;
  156. entity.telephone = model.telephone;
  157. if (!string.IsNullOrEmpty(model.Photo))
  158. {
  159. entity.IsPhoto = true;
  160. entity.Photo = model.Photo;
  161. }
  162. else
  163. {
  164. entity.IsPhoto = false;
  165. entity.Photo = "";
  166. }
  167. stuInfoFreshIBLL.SaveEntity(entity.ID, entity, model.StuInfoFreshEmergePeopleEntities, model.StuInfoFreshFamilyEntities);
  168. return Success("保存成功");
  169. }
  170. /// <summary>
  171. /// 保存贷款回执码
  172. /// </summary>
  173. /// <param name="_"></param>
  174. /// <returns></returns>
  175. private Response GetSaveLoan(dynamic _)
  176. {
  177. var model = this.GetReqData<StuInfoFreshModel>();
  178. var entity = stuInfoFreshIBLL.GetStuInfoFreshEntity(model.ID);
  179. entity.StudentLoan = model.StudentLoan;
  180. entity.StudentLoanStatus = model.StudentLoanStatus;
  181. stuInfoFreshIBLL.SaveEntity(entity.ID, entity);
  182. return Success("保存成功");
  183. }
  184. /// <summary>
  185. /// 头像
  186. /// </summary>
  187. /// <param name="_"></param>
  188. /// <returns></returns>
  189. private Response GetSavePhoto(dynamic _)
  190. {
  191. var model = this.GetReqData<PhotoModel>();
  192. var folderId = Guid.NewGuid().ToString();
  193. string filePath = Config.GetValue("AnnexesFile");
  194. string uploadDate = DateTime.Now.ToString("yyyyMMdd");
  195. string FileEextension = ".png";
  196. string fileGuid = Guid.NewGuid().ToString();
  197. string virtualPath = string.Format("{0}/{1}/{2}/{3}{4}", filePath, userInfo.account, uploadDate, fileGuid, FileEextension);
  198. //创建文件夹
  199. string path = Path.GetDirectoryName(virtualPath);
  200. Directory.CreateDirectory(path);
  201. AnnexesFileEntity fileAnnexesEntity = new AnnexesFileEntity();
  202. if (!System.IO.File.Exists(virtualPath))
  203. {
  204. //byte[] bytes = Convert.FromBase64String(model.Base64Url.Replace("data:image/jpeg;base64,", ""));
  205. byte[] bytes = Convert.FromBase64String(model.Base64Url.Substring(model.Base64Url.IndexOf("base64,") + 7));
  206. FileInfo file = new FileInfo(virtualPath);
  207. FileStream fs = file.Create();
  208. fs.Write(bytes, 0, bytes.Length);
  209. fs.Close();
  210. //文件信息写入数据库
  211. fileAnnexesEntity.F_Id = fileGuid;
  212. fileAnnexesEntity.F_FileName = "userphoto.png";
  213. fileAnnexesEntity.F_FilePath = virtualPath;
  214. fileAnnexesEntity.F_FileSize = bytes.Length.ToString();
  215. fileAnnexesEntity.F_FileExtensions = FileEextension;
  216. fileAnnexesEntity.F_FileType = FileEextension.Replace(".", "");
  217. fileAnnexesEntity.F_CreateUserId = userInfo.userId;
  218. fileAnnexesEntity.F_CreateUserName = userInfo.realName;
  219. annexesFileIBLL.SaveEntity(folderId, fileAnnexesEntity);
  220. }
  221. var data = new
  222. {
  223. Url = virtualPath.Substring(virtualPath.IndexOf("Resource")),
  224. AnnexesFileId = fileGuid
  225. };
  226. return Success(data);
  227. }
  228. /// <summary>
  229. /// 学费查询
  230. /// </summary>
  231. /// <param name="_"></param>
  232. /// <returns></returns>
  233. private Response GetPayFeeDetail(dynamic _)
  234. {
  235. var academicAndYear = Common.GetSemesterAndYear();
  236. var FinaChargesStandardList = new List<FinaChargesStandardEntity>();
  237. var StuInfoFreshData = stuInfoFreshIBLL.GetStuInfoFreshEntityByStuNo(userInfo.account);
  238. if (StuInfoFreshData != null)
  239. {
  240. if (!string.IsNullOrEmpty(StuInfoFreshData.ClassNo) && !string.IsNullOrEmpty(StuInfoFreshData.MajorNo))
  241. {
  242. var ClassInfoEntity = classInfoIBLL.GetClassInfoEntityByClassNo(StuInfoFreshData.ClassNo);
  243. if (ClassInfoEntity != null)
  244. {
  245. FinaChargesStandardList = finaChargesStandardIBLL.GetFinaChargesStandardListByMajorNoOfNotAll(StuInfoFreshData.MajorNo, academicAndYear.AcademicYearShort, academicAndYear.Semester, ClassInfoEntity.Grade).ToList();
  246. }
  247. }
  248. }
  249. var PayFeeTotal = FinaChargesStandardList.Select(x => x.Standard).Sum();
  250. var result = new
  251. {
  252. FinaChargesStandardList = FinaChargesStandardList,
  253. PayFeeTotal = PayFeeTotal,
  254. AcademicYearNo = academicAndYear.AcademicYearShort,
  255. Semester = academicAndYear.Semester,
  256. };
  257. return Success(result);
  258. }
  259. /// <summary>
  260. /// 根据班级查询新生列表
  261. /// <summary>
  262. /// <param name="_"></param>
  263. /// <returns></returns>
  264. public Response GetPageList(dynamic _)
  265. {
  266. ReqPageParam parameter = this.GetReqData<ReqPageParam>();
  267. var data = stuInfoFreshIBLL.GetPageList(parameter.pagination, parameter.queryJson);
  268. var jsonData = new
  269. {
  270. rows = data,
  271. total = parameter.pagination.total,
  272. page = parameter.pagination.page,
  273. records = parameter.pagination.records
  274. };
  275. return Success(jsonData);
  276. }
  277. /// <summary>
  278. /// 获取表单数据
  279. /// <summary>
  280. /// <param name="_"></param>
  281. /// <returns></returns>
  282. public Response GetForm(dynamic _)
  283. {
  284. string keyValue = this.GetReqData();
  285. var StuInfoFreshData = stuInfoFreshIBLL.GetStuInfoFreshEntity(keyValue);
  286. var jsonData = new
  287. {
  288. StuInfoFresh = StuInfoFreshData,
  289. };
  290. return Success(jsonData);
  291. }
  292. /// <summary>
  293. /// 保存实体数据(新增、修改)
  294. /// <param name="_"></param>
  295. /// <summary>
  296. /// <returns></returns>
  297. public Response SaveForm(dynamic _)
  298. {
  299. ReqFormEntity parameter = this.GetReqData<ReqFormEntity>();
  300. StuInfoFreshEntity entity = parameter.strEntity.ToObject<StuInfoFreshEntity>();
  301. stuInfoFreshIBLL.SaveEntity(parameter.keyValue, entity);
  302. return Success("保存成功!");
  303. }
  304. #region 私有类
  305. /// <summary>
  306. /// 表单实体类
  307. /// <summary>
  308. private class ReqFormEntity
  309. {
  310. public string keyValue { get; set; }
  311. public string strEntity { get; set; }
  312. }
  313. #endregion
  314. /// <summary>
  315. /// 个人信息
  316. /// </summary>
  317. public class StuInfoFreshModel
  318. {
  319. /// <summary>
  320. /// 主键
  321. /// </summary>
  322. public string ID { get; set; }
  323. /// <summary>
  324. /// 籍贯
  325. /// </summary>
  326. public string RegionNo { get; set; }
  327. /// <summary>
  328. /// 家庭住址
  329. /// </summary>
  330. public string FamilyAddress { get; set; }
  331. /// <summary>
  332. /// 联系电话
  333. /// </summary>
  334. public string telephone { get; set; }
  335. /// <summary>
  336. /// 头像地址
  337. /// </summary>
  338. public string Photo { get; set; }
  339. /// <summary>
  340. /// 贷款回执码
  341. /// </summary>
  342. public string StudentLoan { get; set; }
  343. /// <summary>
  344. /// 贷款回执码状态
  345. /// </summary>
  346. public string StudentLoanStatus { get; set; }
  347. /// <summary>
  348. /// 家庭成员
  349. /// </summary>
  350. public List<StuInfoFreshFamilyEntity> StuInfoFreshFamilyEntities { get; set; }
  351. /// <summary>
  352. /// 紧急联系人
  353. /// </summary>
  354. public List<StuInfoFreshEmergePeopleEntity> StuInfoFreshEmergePeopleEntities { get; set; }
  355. }
  356. public class PhotoModel
  357. {
  358. public string Base64Url { get; set; }
  359. public string account { get; set; }
  360. }
  361. }
  362. }