Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

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