/// <summary> /// 修改学生手机号或联系人手机号,将手机号信息推送至家校互联账户 /// <para>作 者:蔡亚康 </para> /// <para>创建时间: 2019-03-21 </para> /// </summary> /// <param name="rawStudent">原学生信息</param> /// <param name="newStudent">新学生信息</param> /// <param name="rawContacts">原学生联系人信息</param> /// <param name="newContacts">新学生联系人信息</param> private static void StudentPublish(TblCstStudent rawStudent, TblCstStudent newStudent, List <TblCstStudentContact> rawContacts, List <TblCstStudentContact> newContacts) { StudentPassportChangeInDto result = new StudentPassportChangeInDto(); List <string> rawMobiles = new List <string>(); //原手机号 List <string> newMobiles = new List <string>(); //新手机号 //原手机号集合 rawMobiles.Add(rawStudent.LinkMobile); rawMobiles.AddRange(rawContacts.Select(t => t.Mobile)); rawMobiles = rawMobiles.Where(t => !string.IsNullOrEmpty(t)) .Distinct() .ToList(); //新手机号集合 newMobiles.Add(newStudent.LinkMobile); newMobiles.AddRange(newContacts.Select(t => t.Mobile)); newMobiles = newMobiles.Where(t => !string.IsNullOrEmpty(t)) .Distinct() .ToList(); result.MobileAddList = newMobiles.Except(rawMobiles).ToList(); result.MobileDeleteList = rawMobiles.Except(newMobiles).ToList(); //获取手机号在在其他学生的账户列表 TblCstStudentRepository studentRepository = new TblCstStudentRepository(); TblCstStudentContactRepository contactRepository = new TblCstStudentContactRepository(); var studentList = studentRepository.SearchByMobiles(result.MobileDeleteList); var contactList = contactRepository.SearchByMobiles(result.MobileDeleteList); //被删除的号码,在studentList,contactList 还存在,说明还不允许删除 List <string> existMobiles = new List <string>(); existMobiles.AddRange(studentList.Select(t => t.LinkMobile)); existMobiles.AddRange(contactList.Select(t => t.Mobile)); existMobiles = existMobiles.Distinct().ToList(); existMobiles.ForEach(item => { result.MobileDeleteList.Remove(item); }); // 推送至消息队列 new StudentFamilyProducerService().Publish(result); }
/// <summary> /// 根据学生电话号码获取学生信息 /// <para>作 者: Huang GaoLiang </para> /// <para>创建时间: 2019-03-08 </para> /// </summary> /// <param name="mobile">电话号码</param> /// <returns>返回学生集合</returns> internal static List <TblCstStudent> GetStudentList(string mobile) { List <TblCstStudent> studentList = new List <TblCstStudent>(); // 1、从学生表中查询符合条件的学生信息 studentList = new TblCstStudentRepository().GetStudentList(mobile); // 2、从学生联系人表中查询数据 List <long> studentIds = new TblCstStudentContactRepository().GetStudentList(mobile).Select(m => m.StudentId).ToList(); var list = new TblCstStudentRepository().GetStudentsById(studentIds); studentList.AddRange(list); studentList = studentList.Where((x, i) => studentList.FindIndex(z => z.StudentId == x.StudentId) == i).ToList(); return(studentList); }
/// <summary> /// 修改学生信息 /// <para>作 者:Huang GaoLiang </para> /// <para>创建时间: 2019-03-14 </para> /// </summary> /// <param name="studentId">学生编号</param> /// <param name="request">修改输入参数</param> /// <returns>返回修改结果受影响的行数</returns> /// <exception> /// 异常ID:1,系统不存在该学生 /// </exception> public static void Modify(long studentId, StudentRegisterRequest request) { TblCstStudentContactRepository contactRepository = new TblCstStudentContactRepository(); TblCstStudentRepository studentRepository = new TblCstStudentRepository(); // 1、根据编号查询学生信息 TblCstStudent rawStudent = studentRepository.GetCstStudentId(studentId); //原学生信息 if (rawStudent == null) { throw new BussinessException((byte)ModelType.Customer, 1); } List <TblCstStudentContact> rawContacts = contactRepository.GetByStudentId(studentId); //原学生联系人 TblCstStudent newStudent = TransExpV2 <TblCstStudent, TblCstStudent> .Trans(rawStudent); //新学生 // 2、验证 Verification(studentId, request.StudentName, request.LinkMobile); // 3、学生信息和学生联系人信息 List <TblCstStudentContact> newContacts = GetStudentContact(newStudent.StudentId, JsonConvert.SerializeObject(request.ContactPerson)); SetStudentInfo(request, newStudent); //4、数据存储操作 studentRepository.Update(newStudent); //更新学生信息 contactRepository.DeleteByStudentId(new List <long> { newStudent.StudentId }); //删除原来的学生联系人 contactRepository.Add(newContacts); //添加学生联系人 // 5、推送学生至档案库 StudentRequest s = GetStudentToAC(rawStudent); new ACService().StudentInfoToArtLibrary(s); // 6、记录操作日志 AddOperationLog(rawStudent, newStudent, request); // 7、将手机号信息推送至家校互联账户 StudentPublish(rawStudent, newStudent, rawContacts, newContacts); }