Commit 12269c0f authored by 黄奎's avatar 黄奎

1111

parent 5ae79b5b
using Edu.Common.Enum;
using System;
using VT.FW.DB;
namespace Edu.Model.Entity.Survey
{
/// <summary>
/// 学生意见调查信息主表
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Education_SurveyMain
{
/// <summary>
/// 问卷Id
/// </summary>
public int Id { get; set; }
/// <summary>
/// 问卷名称
/// </summary>
public string Title { get; set; }
/// <summary>
/// 集团编号
/// </summary>
public int Group_Id { get; set; }
/// <summary>
/// 创建人
/// </summary>
public int CreateBy { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 修改人
/// </summary>
public int UpdateBy { get; set; }
/// <summary>
/// 更新时间
/// </summary>
public DateTime UpdateTime { get; set; }
/// <summary>
/// 删除状态(0-正常,1-删除)
/// </summary>
public DateStateEnum Status { get; set; }
}
}
...@@ -38,5 +38,10 @@ namespace Edu.Model.Entity.Survey ...@@ -38,5 +38,10 @@ namespace Edu.Model.Entity.Survey
/// 删除 /// 删除
/// </summary> /// </summary>
public DateStateEnum State { get; set; } public DateStateEnum State { get; set; }
/// <summary>
/// 主表问卷Id
/// </summary>
public int MainId { get; set; }
} }
} }
...@@ -98,5 +98,10 @@ namespace Edu.Model.Entity.Survey ...@@ -98,5 +98,10 @@ namespace Edu.Model.Entity.Survey
get; get;
set; set;
} }
/// <summary>
/// 主表文件Id
/// </summary>
public int MainId { get; set; }
} }
} }
using Edu.Model.Entity.Survey;
namespace Edu.Model.ViewModel.Survey
{
/// <summary>
/// 学生意见调查信息主表扩展实体类
/// </summary>
public class RB_Education_SurveyMain_ViewModel: RB_Education_SurveyMain
{
/// <summary>
/// 题目数量
/// </summary>
public int QuestionCount { get; set; }
}
}
...@@ -10,6 +10,11 @@ namespace Edu.Model.ViewModel.Survey ...@@ -10,6 +10,11 @@ namespace Edu.Model.ViewModel.Survey
/// </summary> /// </summary>
public class Rb_Education_StudentSurvey_ViewModel : Rb_Education_StudentSurvey public class Rb_Education_StudentSurvey_ViewModel : Rb_Education_StudentSurvey
{ {
/// <summary>
/// 问卷名称
/// </summary>
public string Title { get; set; }
/// <summary> /// <summary>
/// 选项详情 /// 选项详情
/// </summary> /// </summary>
......
...@@ -10,6 +10,16 @@ namespace Edu.Model.ViewModel.Survey ...@@ -10,6 +10,16 @@ namespace Edu.Model.ViewModel.Survey
/// </summary> /// </summary>
public class Rb_Education_Survey_ViewModel : Rb_Education_Survey public class Rb_Education_Survey_ViewModel : Rb_Education_Survey
{ {
/// <summary>
/// 问卷Id
/// </summary>
public string QSurveyIDs { get; set; }
/// <summary>
/// 问卷编号
/// </summary>
public string QMainIds { get; set; }
/// <summary> /// <summary>
/// 选项 /// 选项
/// </summary> /// </summary>
......
using Edu.Common.Enum.Survey; using Edu.Common.Enum;
using Edu.Common.Enum.Survey;
using Edu.Common.Plugin; using Edu.Common.Plugin;
using Edu.Model.CacheModel;
using Edu.Model.Entity.Survey; using Edu.Model.Entity.Survey;
using Edu.Model.ViewModel.Survey; using Edu.Model.ViewModel.Survey;
using Edu.Model.ViewModel.User; using Edu.Model.ViewModel.User;
...@@ -9,7 +9,6 @@ using Edu.Repository.User; ...@@ -9,7 +9,6 @@ using Edu.Repository.User;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using VT.FW.DB; using VT.FW.DB;
namespace Edu.Module.Public namespace Edu.Module.Public
...@@ -17,40 +16,134 @@ namespace Edu.Module.Public ...@@ -17,40 +16,134 @@ namespace Edu.Module.Public
/// <summary> /// <summary>
/// 意见调查处理实体类 /// 意见调查处理实体类
/// </summary> /// </summary>
public class SurveyModule public class EduSurveyModule
{ {
/// <summary> /// <summary>
/// 调查选项 /// 意见调查主表仓储层对象
/// </summary> /// </summary>
private Rb_Education_SurveyRepository respository = new Rb_Education_SurveyRepository(); private readonly RB_Education_SurveyMainRepository _surveyMainRepository = new RB_Education_SurveyMainRepository();
/// <summary>
/// 调查选项
/// </summary>
private readonly Rb_Education_SurveyRepository respository = new Rb_Education_SurveyRepository();
/// <summary> /// <summary>
/// 学生信息 /// 学生信息
/// </summary> /// </summary>
private RB_StudentRepository studentRepository = new RB_StudentRepository(); private readonly RB_StudentRepository studentRepository = new RB_StudentRepository();
/// <summary> /// <summary>
/// 老师信息 /// 老师信息
/// </summary> /// </summary>
private RB_TeacherRepository teacherRepository = new RB_TeacherRepository(); private readonly RB_TeacherRepository teacherRepository = new RB_TeacherRepository();
/// <summary> /// <summary>
/// 调查 /// 调查
/// </summary> /// </summary>
private Rb_Education_SurveyOptionsRepository surveyOptionsRepository = new Rb_Education_SurveyOptionsRepository(); private readonly Rb_Education_SurveyOptionsRepository surveyOptionsRepository = new Rb_Education_SurveyOptionsRepository();
/// <summary> /// <summary>
/// 学生调查信息 /// 学生调查信息
/// </summary> /// </summary>
private Rb_Education_StudentSurveyRepository guestSurveyRepository = new Rb_Education_StudentSurveyRepository(); private readonly Rb_Education_StudentSurveyRepository guestSurveyRepository = new Rb_Education_StudentSurveyRepository();
/// <summary> /// <summary>
/// 学生调查选项信息 /// 学生调查选项信息
/// </summary> /// </summary>
private Rb_Education_StudentSurveyDetailsRepository guestSurveyDetailsRepository = new Rb_Education_StudentSurveyDetailsRepository(); private readonly Rb_Education_StudentSurveyDetailsRepository guestSurveyDetailsRepository = new Rb_Education_StudentSurveyDetailsRepository();
/// <summary>
/// 获取意见调查表主表分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Education_SurveyMain_ViewModel> GetEducationSurveyMainPageModule(int pageIndex, int pageSize, out long rowsCount, RB_Education_SurveyMain_ViewModel query)
{
var list= _surveyMainRepository.GetEducationSurveyMainPageRepository(pageIndex, pageSize, out rowsCount, query);
if (list != null && list.Count > 0)
{
string ids = string.Join(",", list.Select(qitem => qitem.Id));
List<Rb_Education_Survey_ViewModel> subList = new List<Rb_Education_Survey_ViewModel>();
if (!string.IsNullOrEmpty(ids))
{
subList = respository.GetEducationSurveyListRepository(new Rb_Education_Survey_ViewModel() { QMainIds = ids });
}
foreach (var item in list)
{
item.QuestionCount = subList?.Where(qitem => qitem.MainId == item.Id)?.Count() ?? 0;
}
}
return list;
}
/// <summary>
/// 获取意见调查表主表列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Education_SurveyMain_ViewModel> GetEducationSurveyMainListModule(RB_Education_SurveyMain_ViewModel query)
{
return _surveyMainRepository.GetEducationSurveyMainListRepository(query);
}
/// <summary>
/// 获取问卷详情
/// </summary>
/// <param name="MainId"></param>
/// <returns></returns>
public RB_Education_SurveyMain_ViewModel GetEducationSurveyMainModule(int MainId)
{
return _surveyMainRepository.GetEntity<RB_Education_SurveyMain_ViewModel>(MainId);
}
/// <summary>
/// 新增修改意见调查表主表信息
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool SetEducationSurveyMainModule(RB_Education_SurveyMain_ViewModel model)
{
bool flag = false;
if (model.Id > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Education_SurveyMain_ViewModel.Title),model.Title },
{nameof(RB_Education_SurveyMain_ViewModel.UpdateBy),model.UpdateBy },
{nameof(RB_Education_SurveyMain_ViewModel.UpdateTime),model.UpdateTime },
};
flag = _surveyMainRepository.Update(fileds, new WhereHelper(nameof(RB_Education_SurveyMain_ViewModel.Id), model.Id));
}
else
{
var newId = _surveyMainRepository.Insert(model);
model.Id = newId;
flag = newId > 0;
}
return flag;
}
/// <summary>
/// 删除意见调查表主表信息
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public bool RemoveEducationSurveyMainModule(int Id)
{
bool flag = false;
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Education_SurveyMain_ViewModel.Status),(int)DateStateEnum.Delete }
};
flag = _surveyMainRepository.Update(fileds, new WhereHelper(nameof(RB_Education_SurveyMain_ViewModel.Id), Id));
return flag;
}
#region 意见调查基础信息 #region 意见调查基础信息
/// <summary> /// <summary>
...@@ -61,9 +154,9 @@ namespace Edu.Module.Public ...@@ -61,9 +154,9 @@ namespace Edu.Module.Public
/// <param name="rowsCount"></param> /// <param name="rowsCount"></param>
/// <param name="where"></param> /// <param name="where"></param>
/// <returns></returns> /// <returns></returns>
public List<Rb_Education_Survey_ViewModel> GetPageList(int pageIndex, int pageSize, out long rowsCount, Rb_Education_Survey where) public List<Rb_Education_Survey_ViewModel> GetEducationSurveyPageModule(int pageIndex, int pageSize, out long rowsCount, Rb_Education_Survey where)
{ {
return respository.GetPageList(pageIndex, pageSize, out rowsCount, where); return respository.GetEducationSurveyPageRepository(pageIndex, pageSize, out rowsCount, where);
} }
...@@ -87,9 +180,13 @@ namespace Edu.Module.Public ...@@ -87,9 +180,13 @@ namespace Edu.Module.Public
return surveyOptionsRepository.GetList(where); return surveyOptionsRepository.GetList(where);
} }
public bool SetSurvey(Rb_Education_Survey_ViewModel model) /// <summary>
/// 新增修改问卷调查问题
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool SetSurveyQuestionModule(Rb_Education_Survey_ViewModel model)
{ {
var trans = respository.DbTransaction;
try try
{ {
int surveyId = 0; int surveyId = 0;
...@@ -114,7 +211,7 @@ namespace Edu.Module.Public ...@@ -114,7 +211,7 @@ namespace Edu.Module.Public
OperatorEnum= OperatorEnum.Equal OperatorEnum= OperatorEnum.Equal
} }
}; };
var flag = respository.Update(fileds, where, trans); var flag = respository.Update(fileds, where);
//查询之前的选项 //查询之前的选项
var surveyOptionsList = surveyOptionsRepository.GetList(new Rb_Education_SurveyOptions { SurveyID = surveyId }); var surveyOptionsList = surveyOptionsRepository.GetList(new Rb_Education_SurveyOptions { SurveyID = surveyId });
//删除之前有现在没有的 //删除之前有现在没有的
...@@ -126,16 +223,16 @@ namespace Edu.Module.Public ...@@ -126,16 +223,16 @@ namespace Edu.Module.Public
} }
else if (model.SurveyOptionsList == null || !model.SurveyOptionsList.Any()) else if (model.SurveyOptionsList == null || !model.SurveyOptionsList.Any())
{ {
flag = surveyOptionsRepository.DeleteBatch(surveyOptionsList, trans); flag = surveyOptionsRepository.DeleteBatch(surveyOptionsList);
} }
foreach (var item in surveyOptionsList.Where(x => surveyOptionsExcept.Contains(x.ID.ToString()))) foreach (var item in surveyOptionsList.Where(x => surveyOptionsExcept.Contains(x.ID.ToString())))
{ {
flag = surveyOptionsRepository.Delete(item, trans) > 0; flag = surveyOptionsRepository.Delete(item) > 0;
} }
} }
else else
{ {
surveyId = respository.Insert(model, trans); surveyId = respository.Insert(model);
} }
if (model.SurveyType != SurveyTypeEnum.Score && model.SurveyType != SurveyTypeEnum.TheText)//新增选项 if (model.SurveyType != SurveyTypeEnum.Score && model.SurveyType != SurveyTypeEnum.TheText)//新增选项
{ {
...@@ -144,39 +241,36 @@ namespace Edu.Module.Public ...@@ -144,39 +241,36 @@ namespace Edu.Module.Public
if (item.ID == 0) if (item.ID == 0)
{ {
item.SurveyID = surveyId; item.SurveyID = surveyId;
surveyOptionsRepository.Insert(item, trans); surveyOptionsRepository.Insert(item);
} }
else else
{ {
surveyOptionsRepository.Update(item, trans); surveyOptionsRepository.Update(item);
} }
} }
} }
respository.DBSession.Commit();
return true; return true;
} }
catch (Exception ex) catch (Exception ex)
{ {
LogHelper.Write(ex, "SetSurvey"); LogHelper.Write(ex, "SetSurveyQuestionModule");
respository.DBSession.Rollback("SetSurvey");
return false; return false;
} }
} }
/// <summary> /// <summary>
/// 删除调查信息 /// 删除问卷调查问题
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
/// <returns></returns> /// <returns></returns>
public bool DelSurvey(Rb_Education_Survey_ViewModel model) public bool DelSurveyQuestionModule(Rb_Education_Survey_ViewModel model)
{ {
var trans = respository.DbTransaction;
try try
{ {
if (model.ID > 0) if (model.ID > 0)
{ {
IDictionary<string, object> fileds = new Dictionary<string, object>() IDictionary<string, object> fileds = new Dictionary<string, object>()
{ {
{ nameof(Rb_Education_Survey.State),(int)Common.Enum.DateStateEnum.Delete}, { nameof(Rb_Education_Survey.State),(int)Common.Enum.DateStateEnum.Delete},
...@@ -190,21 +284,18 @@ namespace Edu.Module.Public ...@@ -190,21 +284,18 @@ namespace Edu.Module.Public
OperatorEnum= OperatorEnum.Equal OperatorEnum= OperatorEnum.Equal
} }
}; };
var flag = respository.Update(fileds, where, trans); var flag = respository.Update(fileds, where);
if (model.SurveyOptionsList != null && model.SurveyOptionsList.Any()) if (model.SurveyOptionsList != null && model.SurveyOptionsList.Any())
{ {
model.SurveyOptionsList.ForEach(x => x.State = Common.Enum.DateStateEnum.Delete); model.SurveyOptionsList.ForEach(x => x.State = Common.Enum.DateStateEnum.Delete);
flag = surveyOptionsRepository.UpdateBatch(model.SurveyOptionsList, trans); flag = surveyOptionsRepository.UpdateBatch(model.SurveyOptionsList);
} }
} }
respository.DBSession.Commit();
return true; return true;
} }
catch (Exception ex) catch (Exception ex)
{ {
LogHelper.Write(ex, "DelSurvey");
respository.DBSession.Rollback("DelSurvey");
return false; return false;
} }
} }
...@@ -243,7 +334,7 @@ namespace Edu.Module.Public ...@@ -243,7 +334,7 @@ namespace Edu.Module.Public
/// <returns></returns> /// <returns></returns>
public List<Rb_Education_Survey_ViewModel> GetSurveyList(string SurveyIDs) public List<Rb_Education_Survey_ViewModel> GetSurveyList(string SurveyIDs)
{ {
return respository.GetList(SurveyIDs); return respository.GetEducationSurveyListRepository(new Rb_Education_Survey_ViewModel() { QSurveyIDs = SurveyIDs });
} }
/// <summary> /// <summary>
...@@ -253,7 +344,7 @@ namespace Edu.Module.Public ...@@ -253,7 +344,7 @@ namespace Edu.Module.Public
/// <returns></returns> /// <returns></returns>
public List<Rb_Education_Survey_ViewModel> GetAllList(Rb_Education_Survey_ViewModel where) public List<Rb_Education_Survey_ViewModel> GetAllList(Rb_Education_Survey_ViewModel where)
{ {
var List = respository.GetList(where); var List = respository.GetEducationSurveyListRepository(where);
if (List != null && List.Any()) if (List != null && List.Any())
{ {
var surveyOptionsList = surveyOptionsRepository.GetList(string.Join(",", List.Select(x => x.ID))); var surveyOptionsList = surveyOptionsRepository.GetList(string.Join(",", List.Select(x => x.ID)));
...@@ -289,31 +380,26 @@ namespace Edu.Module.Public ...@@ -289,31 +380,26 @@ namespace Edu.Module.Public
/// <returns></returns> /// <returns></returns>
public int SetStudentSurvey(Rb_Education_StudentSurvey_ViewModel model) public int SetStudentSurvey(Rb_Education_StudentSurvey_ViewModel model)
{ {
var trans = guestSurveyRepository.DbTransaction;
int surveyId = 0; int surveyId = 0;
try try
{ {
surveyId = guestSurveyRepository.Insert(model);
surveyId = guestSurveyRepository.Insert(model, trans);
foreach (var item in model.SurveyOptionsList) foreach (var item in model.SurveyOptionsList)
{ {
if (item.ID == 0) if (item.ID == 0)
{ {
item.StudentSurveyId = surveyId; item.StudentSurveyId = surveyId;
guestSurveyDetailsRepository.Insert(item, trans); guestSurveyDetailsRepository.Insert(item);
} }
else else
{ {
guestSurveyDetailsRepository.Update(item, trans); guestSurveyDetailsRepository.Update(item);
} }
} }
guestSurveyRepository.DBSession.Commit();
return surveyId; return surveyId;
} }
catch (Exception ex) catch (Exception ex)
{ {
LogHelper.Write(ex, "SetStudentSurvey");
guestSurveyRepository.DBSession.Rollback("SetStudentSurvey");
return 0; return 0;
} }
} }
...@@ -405,6 +491,5 @@ namespace Edu.Module.Public ...@@ -405,6 +491,5 @@ namespace Edu.Module.Public
return list; return list;
} }
#endregion #endregion
} }
} }
using Edu.Common.Enum;
using Edu.Model.Entity.Survey;
using Edu.Model.ViewModel.Survey;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VT.FW.DB.Dapper;
namespace Edu.Repository.Survey
{
/// <summary>
/// 学生意见调查信息主表仓储层
/// </summary>
public class RB_Education_SurveyMainRepository:BaseRepository<RB_Education_SurveyMain>
{
/// <summary>
/// 获取意见调查表主表分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Education_SurveyMain_ViewModel> GetEducationSurveyMainPageRepository(int pageIndex, int pageSize, out long rowsCount, RB_Education_SurveyMain_ViewModel query)
{
DynamicParameters parameters = new DynamicParameters();
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@" SELECT A.* FROM RB_Education_SurveyMain AS A WHERE 1=1 ");
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Education_SurveyMain_ViewModel.Status), (int)DateStateEnum.Normal);
if (query != null)
{
if (query.Group_Id > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Education_SurveyMain_ViewModel.Group_Id), query.Group_Id);
}
if (!string.IsNullOrEmpty(query.Title))
{
builder.AppendFormat(" AND A.{0} LIKE @Title ", nameof(RB_Education_SurveyMain_ViewModel.Title));
parameters.Add("@Title", "%" + query.Title.Trim() + "%");
}
}
builder.AppendFormat(" ORDER BY A.Id DESC ");
return GetPage<RB_Education_SurveyMain_ViewModel>(pageIndex, pageSize, out rowsCount, builder.ToString(), parameters).ToList();
}
/// <summary>
/// 获取意见调查表主表列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Education_SurveyMain_ViewModel> GetEducationSurveyMainListRepository(RB_Education_SurveyMain_ViewModel query)
{
DynamicParameters parameters = new DynamicParameters();
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@" SELECT A.* FROM RB_Education_SurveyMain AS A WHERE 1=1 ");
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Education_SurveyMain_ViewModel.Status), (int)DateStateEnum.Normal);
if (query != null)
{
if (query.Group_Id > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Education_SurveyMain_ViewModel.Group_Id), query.Group_Id);
}
if (!string.IsNullOrEmpty(query.Title))
{
builder.AppendFormat(" AND A.{0} LIKE @Title ", nameof(RB_Education_SurveyMain_ViewModel.Title));
parameters.Add("@Title", "%" + query.Title.Trim() + "%");
}
}
builder.AppendFormat(" ORDER BY A.Id DESC ");
return Get<RB_Education_SurveyMain_ViewModel>(builder.ToString(), parameters).ToList();
}
}
}
...@@ -85,8 +85,9 @@ WHERE a.state=0"); ...@@ -85,8 +85,9 @@ WHERE a.state=0");
var parameters = new DynamicParameters(); var parameters = new DynamicParameters();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.Append($@" sb.Append($@"
SELECT a.*,IFNULL(c.ScoreNum,0) AS ScoreNum,IFNULL(c.ScoreCount,0) AS ScoreCount SELECT a.*,IFNULL(B.Title,'') AS Title,IFNULL(c.ScoreNum,0) AS ScoreNum,IFNULL(c.ScoreCount,0) AS ScoreCount
FROM {TableName} AS a FROM {TableName} AS a
LEFT JOIN rb_education_surveymain AS B ON A.MainId=B.Id
LEFT JOIN (SELECT StudentSurveyId,SUM(ScoreNum) as ScoreNum,COUNT(StudentSurveyId) as ScoreCount FROM Rb_Education_StudentSurveyDetails WHERE ScoreNum>0 GROUP BY StudentSurveyId ) as c ON a.ID=c.StudentSurveyId LEFT JOIN (SELECT StudentSurveyId,SUM(ScoreNum) as ScoreNum,COUNT(StudentSurveyId) as ScoreCount FROM Rb_Education_StudentSurveyDetails WHERE ScoreNum>0 GROUP BY StudentSurveyId ) as c ON a.ID=c.StudentSurveyId
WHERE a.state=0"); WHERE a.state=0");
if (where != null) if (where != null)
...@@ -108,8 +109,12 @@ WHERE a.state=0"); ...@@ -108,8 +109,12 @@ WHERE a.state=0");
{ {
sb.AppendFormat(" AND A.CreateDate<='{0} 23:59:59' ", where.QEndDate); sb.AppendFormat(" AND A.CreateDate<='{0} 23:59:59' ", where.QEndDate);
} }
if (where.MainId > 0)
{
sb.AppendFormat(" and a.MainId={0}", where.MainId);
}
} }
sb.AppendFormat(" ORDER BY A.CreateDate ASC "); sb.AppendFormat(" ORDER BY A.CreateDate DESC ");
return GetPage<Rb_Education_StudentSurvey_ViewModel>(pageIndex, pageSize, out rowsCount, sb.ToString(), parameters).ToList(); return GetPage<Rb_Education_StudentSurvey_ViewModel>(pageIndex, pageSize, out rowsCount, sb.ToString(), parameters).ToList();
} }
......
...@@ -4,6 +4,7 @@ using System; ...@@ -4,6 +4,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using VT.FW.DB.Dapper;
namespace Edu.Repository.Survey namespace Edu.Repository.Survey
{ {
...@@ -12,62 +13,53 @@ namespace Edu.Repository.Survey ...@@ -12,62 +13,53 @@ namespace Edu.Repository.Survey
/// </summary> /// </summary>
public class Rb_Education_SurveyRepository : BaseRepository<Rb_Education_Survey> public class Rb_Education_SurveyRepository : BaseRepository<Rb_Education_Survey>
{ {
/// <summary>
/// 表名称
/// </summary>
public string TableName { get { return nameof(Rb_Education_Survey); } }
/// <summary> /// <summary>
/// 获取列表 /// 获取列表
/// </summary> /// </summary>
/// <param name="where"></param> /// <param name="where"></param>
/// <returns></returns> /// <returns></returns>
public List<Rb_Education_Survey_ViewModel> GetList(Rb_Education_Survey where) public List<Rb_Education_Survey_ViewModel> GetEducationSurveyListRepository(Rb_Education_Survey_ViewModel where)
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.Append($@"SELECT * from Rb_Education_Survey where state=0"); DynamicParameters parameters = new DynamicParameters();
sb.Append($@"SELECT * FROM Rb_Education_Survey WHERE state=0");
if (where != null) if (where != null)
{ {
if (where.RB_Group_Id > 0) if (where.RB_Group_Id > 0)
{ {
sb.AppendFormat(" and RB_Group_Id={0}", where.RB_Group_Id); sb.AppendFormat(" AND RB_Group_Id={0}", where.RB_Group_Id);
} }
if (where.IsShow > 0) if (where.IsShow > 0)
{ {
sb.AppendFormat(" and IsShow={0}", where.IsShow); sb.AppendFormat(" AND IsShow={0}", where.IsShow);
} }
if (!string.IsNullOrWhiteSpace(where.Title)) if (!string.IsNullOrWhiteSpace(where.Title))
{ {
sb.AppendFormat(" and Title like'%{0}%'", where.Title); sb.AppendFormat(" AND Title LIKE @Title");
parameters.Add("@Title", "%" + where.Title + "%");
} }
if (where.SurveyType.HasValue && (int)where.SurveyType > 0) if (where.SurveyType.HasValue && (int)where.SurveyType > 0)
{ {
sb.AppendFormat(" and SurveyType={0}", (int)where.SurveyType); sb.AppendFormat(" AND SurveyType={0}", (int)where.SurveyType);
} }
if (!string.IsNullOrWhiteSpace(where.QSurveyIDs))
{
sb.AppendFormat(" AND ID in({0})", where.QSurveyIDs);
} }
sb.Append($" ORDER BY {nameof(Rb_Education_Survey.Sort)} ASC"); if (!string.IsNullOrEmpty(where.QMainIds))
return Get<Rb_Education_Survey_ViewModel>(sb.ToString()).ToList();
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="SurveyIDs"></param>
/// <returns></returns>
public List<Rb_Education_Survey_ViewModel> GetList(string SurveyIDs)
{ {
StringBuilder sb = new StringBuilder(); sb.AppendFormat(" AND MainId in({0})", where.QMainIds);
sb.Append($@"SELECT * from Rb_Education_Survey where state=0"); }
if (where.MainId > 0)
if (!string.IsNullOrWhiteSpace(SurveyIDs))
{ {
sb.AppendFormat(" and ID in({0})", SurveyIDs); sb.AppendFormat(" AND MainId in({0})", where.MainId);
}
} }
sb.Append($" ORDER BY {nameof(Rb_Education_Survey.Sort)} ASC"); sb.Append($" ORDER BY {nameof(Rb_Education_Survey.Sort)} ASC");
return Get<Rb_Education_Survey_ViewModel>(sb.ToString()).ToList(); return Get<Rb_Education_Survey_ViewModel>(sb.ToString(), parameters).ToList();
} }
/// <summary> /// <summary>
/// 意见调查表配置项分页列表 /// 意见调查表配置项分页列表
/// </summary> /// </summary>
...@@ -76,28 +68,33 @@ namespace Edu.Repository.Survey ...@@ -76,28 +68,33 @@ namespace Edu.Repository.Survey
/// <param name="rowsCount"></param> /// <param name="rowsCount"></param>
/// <param name="where"></param> /// <param name="where"></param>
/// <returns></returns> /// <returns></returns>
public List<Rb_Education_Survey_ViewModel> GetPageList(int pageIndex, int pageSize, out long rowsCount, Rb_Education_Survey where) public List<Rb_Education_Survey_ViewModel> GetEducationSurveyPageRepository(int pageIndex, int pageSize, out long rowsCount, Rb_Education_Survey where)
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.Append($@"SELECT * from Rb_Education_Survey where state=0"); DynamicParameters parameters = new DynamicParameters();
sb.Append($@"SELECT A.* FROM Rb_Education_Survey AS A WHERE A.state=0");
if (where != null) if (where != null)
{ {
if (where.IsShow > -1) if (where.IsShow > -1)
{ {
sb.AppendFormat(" and IsShow={0}", where.IsShow); sb.AppendFormat(" AND A.IsShow={0}", where.IsShow);
} }
if (where.SurveyType.HasValue && (int)where.SurveyType > 0) if (where.SurveyType.HasValue && (int)where.SurveyType > 0)
{ {
sb.AppendFormat(" and SurveyType={0}", (int)where.SurveyType); sb.AppendFormat(" AND A.SurveyType={0}", (int)where.SurveyType);
} }
if (!string.IsNullOrWhiteSpace(where.Title)) if (!string.IsNullOrWhiteSpace(where.Title))
{ {
sb.AppendFormat(" and Title like'%{0}%'", where.Title); sb.AppendFormat(" AND A.Title LIKE @Title");
parameters.Add("@Title", "%" + where.Title + "%");
}
if (where.MainId > 0)
{
sb.AppendFormat(" AND A.MainId={0} ", where.MainId);
} }
} }
sb.Append($" ORDER BY {nameof(Rb_Education_Survey.Sort)} ASC"); sb.Append($" ORDER BY {nameof(Rb_Education_Survey.Sort)} ASC");
return GetPage<Rb_Education_Survey_ViewModel>(pageIndex, pageSize, out rowsCount, sb.ToString()).ToList(); return GetPage<Rb_Education_Survey_ViewModel>(pageIndex, pageSize, out rowsCount, sb.ToString(), parameters).ToList();
} }
} }
} }
...@@ -14,7 +14,7 @@ namespace Edu.ThirdCore.Message ...@@ -14,7 +14,7 @@ namespace Edu.ThirdCore.Message
/// </summary> /// </summary>
public class MessageCore public class MessageCore
{ {
private static bool IsFinish = true; //private static bool IsFinish = true;
public static void Init() public static void Init()
{ {
//while (QueueHelper.Queue.Count == 0 || !IsFinish) //while (QueueHelper.Queue.Count == 0 || !IsFinish)
...@@ -47,7 +47,7 @@ namespace Edu.ThirdCore.Message ...@@ -47,7 +47,7 @@ namespace Edu.ThirdCore.Message
{ {
Console.WriteLine(ex.Message); Console.WriteLine(ex.Message);
} }
IsFinish = true; //IsFinish = true;
} }
private static void SendSMS(JObject obj) private static void SendSMS(JObject obj)
...@@ -99,6 +99,10 @@ namespace Edu.ThirdCore.Message ...@@ -99,6 +99,10 @@ namespace Edu.ThirdCore.Message
/// <param name="phoneNumber"></param> /// <param name="phoneNumber"></param>
/// <param name="SendDate"></param> /// <param name="SendDate"></param>
/// <param name="BizId"></param> /// <param name="BizId"></param>
/// <param name="Domain"></param>
/// <param name="AccessKeyId"></param>
/// <param name="AccessKeySecret"></param>
/// <param name="RegionId"></param>
/// <returns></returns> /// <returns></returns>
public static string SendSMSStatus(string phoneNumber, string SendDate, string BizId, string Domain, string AccessKeyId, string AccessKeySecret, string RegionId) public static string SendSMSStatus(string phoneNumber, string SendDate, string BizId, string Domain, string AccessKeyId, string AccessKeySecret, string RegionId)
{ {
......
...@@ -865,7 +865,7 @@ namespace Edu.WebApi.Controllers.Course ...@@ -865,7 +865,7 @@ namespace Edu.WebApi.Controllers.Course
public ApiResult SetAdminScrollAppointment_V3() public ApiResult SetAdminScrollAppointment_V3()
{ {
var userInfo = base.UserInfo; var userInfo = base.UserInfo;
RB_Scroll_Appointment_ViewModel demodel = new RB_Scroll_Appointment_ViewModel() RB_Scroll_Appointment_ViewModel demodel = new RB_Scroll_Appointment_ViewModel
{ {
CourseId = base.ParmJObj.GetInt("CourseId"), CourseId = base.ParmJObj.GetInt("CourseId"),
CourseGradeNo = base.ParmJObj.GetInt("CourseGradeNo"), CourseGradeNo = base.ParmJObj.GetInt("CourseGradeNo"),
...@@ -874,13 +874,13 @@ namespace Edu.WebApi.Controllers.Course ...@@ -874,13 +874,13 @@ namespace Edu.WebApi.Controllers.Course
ShiftSort = base.ParmJObj.GetStringValue("ShiftSort"), ShiftSort = base.ParmJObj.GetStringValue("ShiftSort"),
TeacherId = base.ParmJObj.GetInt("TeacherId"), TeacherId = base.ParmJObj.GetInt("TeacherId"),
ChapterNo = base.ParmJObj.GetInt("ChapterNo"), ChapterNo = base.ParmJObj.GetInt("ChapterNo"),
}; State = CourseAppointStateEnum.WaitSure,
demodel.State = CourseAppointStateEnum.WaitSure; Status = 0,
demodel.Status = 0; Group_Id = userInfo.Group_Id,
demodel.Group_Id = userInfo.Group_Id; CreateBy = userInfo.Id,
demodel.CreateBy = userInfo.Id;
demodel.UpdateBy = userInfo.Id; UpdateBy = userInfo.Id
};
string chooseStuListStr = base.ParmJObj.GetStringValue("ChooseStuList"); string chooseStuListStr = base.ParmJObj.GetStringValue("ChooseStuList");
...@@ -1361,7 +1361,7 @@ namespace Edu.WebApi.Controllers.Course ...@@ -1361,7 +1361,7 @@ namespace Edu.WebApi.Controllers.Course
List<RB_Scroll_Appointment_ViewModel> AppointList = new List<RB_Scroll_Appointment_ViewModel>(); List<RB_Scroll_Appointment_ViewModel> AppointList = new List<RB_Scroll_Appointment_ViewModel>();
List<RB_Scroll_SkipCourse_ViewModel> SkipList = new List<RB_Scroll_SkipCourse_ViewModel>(); List<RB_Scroll_SkipCourse_ViewModel> SkipList = new List<RB_Scroll_SkipCourse_ViewModel>();
var list = scrollClassModule.GetStuLearnChapterList_V2(demodel, out orderList, out orderGuestList, out AppointList, out SkipList); var list = scrollClassModule.GetStuLearnChapterList_V2(demodel, out orderList, out orderGuestList, out AppointList, out SkipList);
string excelName = "学员消课.xls";
foreach (var itemStu in list) foreach (var itemStu in list)
{ {
var tempOrderList = orderList.Where(x => x.OrderId == itemStu.OrderId); var tempOrderList = orderList.Where(x => x.OrderId == itemStu.OrderId);
...@@ -1457,17 +1457,16 @@ namespace Edu.WebApi.Controllers.Course ...@@ -1457,17 +1457,16 @@ namespace Edu.WebApi.Controllers.Course
public ApiResult GetStuLearnChapterStatic() public ApiResult GetStuLearnChapterStatic()
{ {
var userInfo = base.UserInfo; var userInfo = base.UserInfo;
StuCourseQuery demodel = new StuCourseQuery() StuCourseQuery demodel = new StuCourseQuery
{ {
TeacherAccountId = base.ParmJObj.GetInt("TeacherAccountId"), TeacherAccountId = base.ParmJObj.GetInt("TeacherAccountId"),
CourseId = base.ParmJObj.GetInt("CourseId"), CourseId = base.ParmJObj.GetInt("CourseId"),
CourseRate = (CourseRateEnum)base.ParmJObj.GetInt("CourseRate"), CourseRate = (CourseRateEnum)base.ParmJObj.GetInt("CourseRate"),
Student_Id = base.ParmJObj.GetInt("Student_Id"), Student_Id = base.ParmJObj.GetInt("Student_Id"),
GuestState = (GuestStateEnum)base.ParmJObj.GetInt("GuestState") GuestState = (GuestStateEnum)base.ParmJObj.GetInt("GuestState"),
Group_Id = userInfo.Group_Id
}; };
demodel.Group_Id = userInfo.Group_Id;
var list = scrollClassModule.GetStuLearnChapterStaticModule(demodel, out int MaxLength); var list = scrollClassModule.GetStuLearnChapterStaticModule(demodel, out int MaxLength);
return ApiResult.Success("", new return ApiResult.Success("", new
{ {
...@@ -1486,7 +1485,7 @@ namespace Edu.WebApi.Controllers.Course ...@@ -1486,7 +1485,7 @@ namespace Edu.WebApi.Controllers.Course
public FileContentResult DownLoadStuLearnChapterStatic() public FileContentResult DownLoadStuLearnChapterStatic()
{ {
var userInfo = base.UserInfo; var userInfo = base.UserInfo;
StuCourseQuery demodel = new StuCourseQuery() StuCourseQuery demodel = new StuCourseQuery
{ {
TeacherAccountId = base.ParmJObj.GetInt("TeacherAccountId"), TeacherAccountId = base.ParmJObj.GetInt("TeacherAccountId"),
CourseId = base.ParmJObj.GetInt("CourseId"), CourseId = base.ParmJObj.GetInt("CourseId"),
...@@ -1494,10 +1493,9 @@ namespace Edu.WebApi.Controllers.Course ...@@ -1494,10 +1493,9 @@ namespace Edu.WebApi.Controllers.Course
Student_Id = base.ParmJObj.GetInt("Student_Id"), Student_Id = base.ParmJObj.GetInt("Student_Id"),
GuestState = (GuestStateEnum)base.ParmJObj.GetInt("GuestState"), GuestState = (GuestStateEnum)base.ParmJObj.GetInt("GuestState"),
StuName = base.ParmJObj.GetStringValue("StuName"), StuName = base.ParmJObj.GetStringValue("StuName"),
ClassScrollType = base.ParmJObj.GetInt("ClassScrollType", 0) ClassScrollType = base.ParmJObj.GetInt("ClassScrollType", 0),
Group_Id = userInfo.Group_Id
}; };
demodel.Group_Id = userInfo.Group_Id;
var list = scrollClassModule.GetStuLearnChapterStaticModule(demodel, out int MaxLength); var list = scrollClassModule.GetStuLearnChapterStaticModule(demodel, out int MaxLength);
string excelName = "学员消课.xls"; string excelName = "学员消课.xls";
......
using Aliyun.OSS.Util; using Edu.Common.API;
using Edu.Common.API;
using Edu.Common.Enum; using Edu.Common.Enum;
using Edu.Common.Enum.Course;
using Edu.Common.Enum.Survey; using Edu.Common.Enum.Survey;
using Edu.Common.Plugin; using Edu.Common.Plugin;
using Edu.Model.CacheModel; using Edu.Model.CacheModel;
using Edu.Model.Entity.Survey; using Edu.Model.Entity.Survey;
using Edu.Model.ViewModel.Survey; using Edu.Model.ViewModel.Survey;
using Edu.Module.Customer;
using Edu.Module.Public; using Edu.Module.Public;
using Edu.Module.System;
using Edu.WebApi.Filter; using Edu.WebApi.Filter;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Spire.Pdf.Exporting.XPS.Schema; using NPOI.SS.Formula.Functions;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using VT.FW.DB.DapperExtensions;
namespace Edu.WebApi.Controllers.Public namespace Edu.WebApi.Controllers.Public
{ {
...@@ -28,21 +23,125 @@ namespace Edu.WebApi.Controllers.Public ...@@ -28,21 +23,125 @@ namespace Edu.WebApi.Controllers.Public
[ApiExceptionFilter] [ApiExceptionFilter]
[ApiController] [ApiController]
[EnableCors("AllowCors")] [EnableCors("AllowCors")]
public class SurveyController : BaseController public class EduSurveyController : BaseController
{ {
/// <summary> /// <summary>
/// 意见调查处理对象 /// 意见调查处理对象
/// </summary> /// </summary>
private readonly SurveyModule module = AOP.AOPHelper.CreateAOPObject<SurveyModule>(); private readonly EduSurveyModule module = AOP.AOPHelper.CreateAOPObject<EduSurveyModule>();
/// <summary>
/// 获取学生意见调查主表分页
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetEducationSurveyMainPage()
{
ResultPageModel pmodel = JsonConvert.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
var query = new RB_Education_SurveyMain_ViewModel()
{
Title = base.ParmJObj.GetStringValue("Title"),
};
List<object> list = new List<object>();
var dataList = module.GetEducationSurveyMainPageModule(pmodel.PageIndex, pmodel.PageSize, out long rowsCount, query);
foreach (var item in dataList)
{
string CreateByName = "";
if (item.CreateBy > 0)
{
CreateByName = base.GetUserInfo(item.CreateBy)?.AccountName ?? "";
}
list.Add(new
{
item.Id,
item.Title,
item.QuestionCount,
CreateByName,
CreateTime = Common.ConvertHelper.FormatTime(item.CreateTime),
UpdateTime = Common.ConvertHelper.FormatTime(item.UpdateTime),
});
}
pmodel.Count = int.Parse(rowsCount.ToString());
pmodel.PageData = list;
return ApiResult.Success("", pmodel);
}
/// <summary>
/// 获取学生意见调查主表列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetEducationSurveyMainList()
{
var query = new RB_Education_SurveyMain_ViewModel()
{
Title = base.ParmJObj.GetStringValue("Title"),
};
List<object> list = new List<object>();
var dataList = module.GetEducationSurveyMainListModule(query);
foreach (var item in dataList)
{
string CreateByName = "";
if (item.CreateBy > 0)
{
CreateByName = base.GetUserInfo(item.CreateBy)?.AccountName ?? "";
}
list.Add(new
{
item.Id,
item.Title,
item.QuestionCount,
CreateByName,
CreateTime = Common.ConvertHelper.FormatTime(item.CreateTime),
UpdateTime = Common.ConvertHelper.FormatTime(item.UpdateTime),
});
}
return ApiResult.Success("", list);
}
/// <summary>
/// 新增修改意见调查表主表信息
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetEducationSurveyMain()
{
UserInfo userInfo = base.UserInfo;
RB_Education_SurveyMain_ViewModel model = new RB_Education_SurveyMain_ViewModel
{
Id = base.ParmJObj.GetInt("Id"),
Title = base.ParmJObj.GetStringValue("Title"),
Status = DateStateEnum.Normal,
CreateBy = userInfo.Id,
CreateTime = DateTime.Now,
UpdateBy = userInfo.Id,
UpdateTime = DateTime.Now,
Group_Id = userInfo.Group_Id
};
bool flag = module.SetEducationSurveyMainModule(model);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 根据Id删除意见调查表主表信息
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult RemoveEducationSurveyMain()
{
int Id = base.ParmJObj.GetInt("Id");
var flag = module.RemoveEducationSurveyMainModule(Id);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
#region 意见调查信息 #region 意见调查信息
/// <summary> /// <summary>
/// 获取分页列表 /// 获取问卷问题分页列表
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public ApiResult GetPageList() public ApiResult GetSurveyQuestionPage()
{ {
ResultPageModel pmodel = JsonConvert.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString()); ResultPageModel pmodel = JsonConvert.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
Rb_Education_Survey_ViewModel model = new Rb_Education_Survey_ViewModel Rb_Education_Survey_ViewModel model = new Rb_Education_Survey_ViewModel
...@@ -50,34 +149,30 @@ namespace Edu.WebApi.Controllers.Public ...@@ -50,34 +149,30 @@ namespace Edu.WebApi.Controllers.Public
Title = base.ParmJObj.GetStringValue("Title"), Title = base.ParmJObj.GetStringValue("Title"),
SurveyType = (SurveyTypeEnum)base.ParmJObj.GetInt("SurveyType"), SurveyType = (SurveyTypeEnum)base.ParmJObj.GetInt("SurveyType"),
IsShow = base.ParmJObj.GetInt("IsShow"), IsShow = base.ParmJObj.GetInt("IsShow"),
MainId = base.ParmJObj.GetInt("MainId")
}; };
UserInfo userInfo = base.UserInfo; UserInfo userInfo = base.UserInfo;
var data = module.GetPageList(pmodel.PageIndex, pmodel.PageSize, out long count, model); var data = module.GetEducationSurveyPageModule(pmodel.PageIndex, pmodel.PageSize, out long count, model);
var list = data.Select(x => new { x.ID, x.SurveyType, x.Title, x.IsShow, x.Sort, SurveyTypeStr = EnumHelper.ToName(x.SurveyType) }).ToList(); var list = data.Select(x => new { x.ID, x.SurveyType, x.Title, x.IsShow, x.Sort, SurveyTypeStr = EnumHelper.ToName(x.SurveyType) }).ToList();
pmodel.Count = int.Parse(count.ToString()); pmodel.Count = int.Parse(count.ToString());
pmodel.PageData = list; pmodel.PageData = list;
return ApiResult.Success("", pmodel); return ApiResult.Success("", pmodel);
} }
/// <summary> /// <summary>
/// 通过id获取信息 /// 通过id获取问卷问题详情
/// </summary> /// </summary>
/// <param name="request"></param> /// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public ApiResult GetSurvey() public ApiResult GetSurveyQuestion()
{ {
int SurveyID = base.ParmJObj.GetInt("SurveyID"); int SurveyID = base.ParmJObj.GetInt("SurveyID");
Rb_Education_Survey_ViewModel model = module.GetEntity(SurveyID).RefMapperTo<Rb_Education_Survey_ViewModel>(); Rb_Education_Survey_ViewModel model = module.GetEntity(SurveyID).RefMapperTo<Rb_Education_Survey_ViewModel>();
if (model != null) if (model != null)
{ {
model.SurveyOptionsList = new List<Rb_Education_SurveyOptions_ViewModel>(); model.SurveyOptionsList = new List<Rb_Education_SurveyOptions_ViewModel>();
model.SurveyOptionsList = module.GetSurveyOptionsList(new Rb_Education_SurveyOptions_ViewModel { SurveyID = model.ID }); model.SurveyOptionsList = module.GetSurveyOptionsList(new Rb_Education_SurveyOptions_ViewModel { SurveyID = model.ID });
return ApiResult.Success("请求成功!", model); return ApiResult.Success("请求成功!", model);
} }
return ApiResult.Failed("未找到此调查信息!"); return ApiResult.Failed("未找到此调查信息!");
...@@ -90,7 +185,7 @@ namespace Edu.WebApi.Controllers.Public ...@@ -90,7 +185,7 @@ namespace Edu.WebApi.Controllers.Public
/// <param name="request"></param> /// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public ApiResult DelSurvey() public ApiResult DelSurveyQuestion()
{ {
int SurveyID = base.ParmJObj.GetInt("SurveyID"); int SurveyID = base.ParmJObj.GetInt("SurveyID");
Rb_Education_Survey_ViewModel model = module.GetEntity(SurveyID).RefMapperTo<Rb_Education_Survey_ViewModel>(); Rb_Education_Survey_ViewModel model = module.GetEntity(SurveyID).RefMapperTo<Rb_Education_Survey_ViewModel>();
...@@ -103,19 +198,19 @@ namespace Edu.WebApi.Controllers.Public ...@@ -103,19 +198,19 @@ namespace Edu.WebApi.Controllers.Public
model.SurveyOptionsList = new List<Rb_Education_SurveyOptions_ViewModel>(); model.SurveyOptionsList = new List<Rb_Education_SurveyOptions_ViewModel>();
model.SurveyOptionsList = module.GetSurveyOptionsList(new Rb_Education_SurveyOptions_ViewModel { SurveyID = model.ID }); model.SurveyOptionsList = module.GetSurveyOptionsList(new Rb_Education_SurveyOptions_ViewModel { SurveyID = model.ID });
bool result = module.DelSurvey(model); bool result = module.DelSurveyQuestionModule(model);
return ApiResult.Success("删除成功!"); return ApiResult.Success("删除成功!");
} }
return ApiResult.Failed("未找到此调查信息!"); return ApiResult.Failed("未找到此调查信息!");
} }
/// <summary> /// <summary>
/// 添加修改调查信息 /// 添加修改问卷问题
/// </summary> /// </summary>
/// <param name="request"></param> /// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public virtual ApiResult SetSurvey() public virtual ApiResult SetSurveyQuestion()
{ {
UserInfo userInfo = base.UserInfo; UserInfo userInfo = base.UserInfo;
Rb_Education_Survey_ViewModel model = new Rb_Education_Survey_ViewModel() Rb_Education_Survey_ViewModel model = new Rb_Education_Survey_ViewModel()
...@@ -126,6 +221,7 @@ namespace Edu.WebApi.Controllers.Public ...@@ -126,6 +221,7 @@ namespace Edu.WebApi.Controllers.Public
Sort = base.ParmJObj.GetInt("Sort", 0), Sort = base.ParmJObj.GetInt("Sort", 0),
IsShow = base.ParmJObj.GetInt("IsShow"), IsShow = base.ParmJObj.GetInt("IsShow"),
SurveyOptionsList = new List<Rb_Education_SurveyOptions_ViewModel>(), SurveyOptionsList = new List<Rb_Education_SurveyOptions_ViewModel>(),
MainId = base.ParmJObj.GetInt("MainId"),
}; };
string surveyOptionsListStr = base.ParmJObj.GetStringValue("SurveyOptionsList"); string surveyOptionsListStr = base.ParmJObj.GetStringValue("SurveyOptionsList");
if (!string.IsNullOrWhiteSpace(surveyOptionsListStr)) if (!string.IsNullOrWhiteSpace(surveyOptionsListStr))
...@@ -136,12 +232,14 @@ namespace Edu.WebApi.Controllers.Public ...@@ -136,12 +232,14 @@ namespace Edu.WebApi.Controllers.Public
foreach (var jItem in logosurveyOptionsListArray) foreach (var jItem in logosurveyOptionsListArray)
{ {
JObject jobj = JObject.Parse(JsonHelper.Serialize(jItem)); JObject jobj = JObject.Parse(JsonHelper.Serialize(jItem));
var surveyOptionsModel = new Rb_Education_SurveyOptions_ViewModel(); var surveyOptionsModel = new Rb_Education_SurveyOptions_ViewModel
surveyOptionsModel.ID = jobj.GetInt("ID", 0); {
surveyOptionsModel.OptionsName = jobj.GetStringValue("OptionsName"); ID = jobj.GetInt("ID", 0),
surveyOptionsModel.Sort = jobj.GetInt("Sort", 0); OptionsName = jobj.GetStringValue("OptionsName"),
surveyOptionsModel.State = Common.Enum.DateStateEnum.Normal; Sort = jobj.GetInt("Sort", 0),
surveyOptionsModel.SurveyID = model.ID; State = Common.Enum.DateStateEnum.Normal,
SurveyID = model.ID
};
model.SurveyOptionsList.Add(surveyOptionsModel); model.SurveyOptionsList.Add(surveyOptionsModel);
} }
} }
...@@ -172,11 +270,8 @@ namespace Edu.WebApi.Controllers.Public ...@@ -172,11 +270,8 @@ namespace Edu.WebApi.Controllers.Public
model.UpdateBy = userInfo.Id; model.UpdateBy = userInfo.Id;
model.UpdateDate = DateTime.Now; model.UpdateDate = DateTime.Now;
model.State = Common.Enum.DateStateEnum.Normal; model.State = Common.Enum.DateStateEnum.Normal;
bool flag = module.SetSurvey(model); bool flag = module.SetSurveyQuestionModule(model);
if (flag) return flag ? ApiResult.Success() : ApiResult.Failed(message: "请求失败!");
return ApiResult.Success();
else
return ApiResult.Failed("请求失败!");
} }
/// <summary> /// <summary>
...@@ -208,6 +303,7 @@ namespace Edu.WebApi.Controllers.Public ...@@ -208,6 +303,7 @@ namespace Edu.WebApi.Controllers.Public
Rb_Education_StudentSurvey_ViewModel model = module.GetGuestSurveyEntity(SurveyID).RefMapperTo<Rb_Education_StudentSurvey_ViewModel>(); Rb_Education_StudentSurvey_ViewModel model = module.GetGuestSurveyEntity(SurveyID).RefMapperTo<Rb_Education_StudentSurvey_ViewModel>();
if (model != null) if (model != null)
{ {
var mainModel = module.GetEducationSurveyMainModule(model.MainId);
model.SurveyOptionsList = new List<Model.Entity.Survey.Rb_Education_StudentSurveyDetails>(); model.SurveyOptionsList = new List<Model.Entity.Survey.Rb_Education_StudentSurveyDetails>();
model.SurveyOptionsList = module.GetGuestSurveyDetailsList(new Rb_Education_StudentSurveyDetails { StudentSurveyId = SurveyID }); model.SurveyOptionsList = module.GetGuestSurveyDetailsList(new Rb_Education_StudentSurveyDetails { StudentSurveyId = SurveyID });
//调查问卷信息 //调查问卷信息
...@@ -234,7 +330,6 @@ namespace Edu.WebApi.Controllers.Public ...@@ -234,7 +330,6 @@ namespace Edu.WebApi.Controllers.Public
{ {
item.CheckInfo.Add(surveyOptionsItem.ID); item.CheckInfo.Add(surveyOptionsItem.ID);
item.ScoreNum = 0; item.ScoreNum = 0;
//surveyOptionsItem.IsCheck = "1";
} }
else if (item.SurveyType == SurveyTypeEnum.TheRadio) else if (item.SurveyType == SurveyTypeEnum.TheRadio)
{ {
...@@ -262,7 +357,12 @@ namespace Edu.WebApi.Controllers.Public ...@@ -262,7 +357,12 @@ namespace Edu.WebApi.Controllers.Public
} }
} }
return ApiResult.Success("请求成功!", surverList); var obj = new
{
Title = mainModel?.Title ?? "",
surverList
};
return ApiResult.Success("请求成功!", obj);
} }
return ApiResult.Failed("未找到调查信息!"); return ApiResult.Failed("未找到调查信息!");
} }
...@@ -281,7 +381,8 @@ namespace Edu.WebApi.Controllers.Public ...@@ -281,7 +381,8 @@ namespace Edu.WebApi.Controllers.Public
Rb_Education_StudentSurvey_ViewModel model = new Rb_Education_StudentSurvey_ViewModel() Rb_Education_StudentSurvey_ViewModel model = new Rb_Education_StudentSurvey_ViewModel()
{ {
TeacherId = base.ParmJObj.GetInt("TeacherId"), TeacherId = base.ParmJObj.GetInt("TeacherId"),
StudentId = base.ParmJObj.GetInt("StudentId") StudentId = base.ParmJObj.GetInt("StudentId"),
MainId = base.ParmJObj.GetInt("MainId"),
}; };
var data = module.GetTravelSurveyPageModule(pmodel.PageIndex, pmodel.PageSize, out long count, model); var data = module.GetTravelSurveyPageModule(pmodel.PageIndex, pmodel.PageSize, out long count, model);
List<object> dataList = new List<object>(); List<object> dataList = new List<object>();
...@@ -289,12 +390,13 @@ namespace Edu.WebApi.Controllers.Public ...@@ -289,12 +390,13 @@ namespace Edu.WebApi.Controllers.Public
{ {
dataList.Add(new dataList.Add(new
{ {
CreateDate = item.CreateDate.HasValue ? item.CreateDate.Value.ToString("yyyy-MM-dd") : "", CreateDate = Common.ConvertHelper.FormatTime(item.CreateDate),
TeacherName = item?.TeacherName ?? "", TeacherName = item?.TeacherName ?? "",
StudentName = item?.StudentName ?? "", StudentName = item?.StudentName ?? "",
ScoreNum = item?.ScoreNum ?? 0, ScoreNum = item?.ScoreNum ?? 0,
ScoreCount = item?.ScoreCount ?? 0, ScoreCount = item?.ScoreCount ?? 0,
ID = item?.ID ?? 0, ID = item?.ID ?? 0,
item.Title,
}); });
} }
pmodel.Count = int.Parse(count.ToString()); pmodel.Count = int.Parse(count.ToString());
...@@ -317,12 +419,11 @@ namespace Edu.WebApi.Controllers.Public ...@@ -317,12 +419,11 @@ namespace Edu.WebApi.Controllers.Public
string pUrl = base.ParmJObj.GetStringValue("pUrl"); string pUrl = base.ParmJObj.GetStringValue("pUrl");
int StudentId = base.ParmJObj.GetInt("StudentId"); int StudentId = base.ParmJObj.GetInt("StudentId");
string stuName = base.ParmJObj.GetStringValue("StuName"); string stuName = base.ParmJObj.GetStringValue("StuName");
int MainId = base.ParmJObj.GetInt("MainId");//问卷Id
//注意签到js需要添加对应参数(plug/index.js使用到 clientConfirm地方) //注意签到js需要添加对应参数(plug/index.js使用到 clientConfirm地方)
string newStr = pUrl + "?StuId=" + StudentId + "&Group_Id=" + userInfo.Group_Id + (!string.IsNullOrWhiteSpace(stuName) ? ("&StuName=" + StringHelper.UrlDecode(stuName)) : ""); string newStr = pUrl + "?MainId=" + MainId + "&StuId=" + StudentId + "&Group_Id=" + userInfo.Group_Id + (!string.IsNullOrWhiteSpace(stuName) ? ("&StuName=" + StringHelper.UrlDecode(stuName)) : "");
Common.Plugin.LogHelper.Write("GetQrCodeImage::" + newStr);
string nUrl = Common.Config.EducationUrl + newStr; string nUrl = Common.Config.EducationUrl + newStr;
Common.Plugin.LogHelper.WriteInfo("GetQrCodeImage::" + nUrl);
return ApiResult.Success("", Common.Plugin.QRCodeHelper.GetQrCode(nUrl)); return ApiResult.Success("", Common.Plugin.QRCodeHelper.GetQrCode(nUrl));
} }
...@@ -344,6 +445,7 @@ namespace Edu.WebApi.Controllers.Public ...@@ -344,6 +445,7 @@ namespace Edu.WebApi.Controllers.Public
{ {
RB_Group_Id = base.ParmJObj.GetInt("RB_Group_Id", 0), RB_Group_Id = base.ParmJObj.GetInt("RB_Group_Id", 0),
IsShow = 1, IsShow = 1,
MainId = base.ParmJObj.GetInt("MainId"),
}; };
var list = module.GetAllList(model); var list = module.GetAllList(model);
var obj = list.Select(x => new { x.ID, SurveyType = (int)x.SurveyType, CheckInfo = new List<int>(), x.Title, x.Sort, SurveyTypeStr = EnumHelper.ToName(x.SurveyType), x.SurveyOptionsList, ScoreNum = 0, TextContent = "" }).ToList(); var obj = list.Select(x => new { x.ID, SurveyType = (int)x.SurveyType, CheckInfo = new List<int>(), x.Title, x.Sort, SurveyTypeStr = EnumHelper.ToName(x.SurveyType), x.SurveyOptionsList, ScoreNum = 0, TextContent = "" }).ToList();
...@@ -359,20 +461,20 @@ namespace Edu.WebApi.Controllers.Public ...@@ -359,20 +461,20 @@ namespace Edu.WebApi.Controllers.Public
[HttpPost] [HttpPost]
[HttpGet] [HttpGet]
[AllowAnonymous] [AllowAnonymous]
public ApiResult SetEducationSurvey() public ApiResult SetStuEducationSurvey()
{ {
List<Rb_Education_Survey_ViewModel> modelSurvey = new List<Rb_Education_Survey_ViewModel>(); List<Rb_Education_Survey_ViewModel> modelSurvey = new List<Rb_Education_Survey_ViewModel>();
Rb_Education_StudentSurvey_ViewModel model = new Rb_Education_StudentSurvey_ViewModel(); Rb_Education_StudentSurvey_ViewModel model = new Rb_Education_StudentSurvey_ViewModel
model.TeacherId = base.ParmJObj.GetInt("TeacherId", 0); {
model.StudentId = base.ParmJObj.GetInt("StudentId", 0); TeacherId = base.ParmJObj.GetInt("TeacherId", 0),
StudentId = base.ParmJObj.GetInt("StudentId", 0),
MainId = base.ParmJObj.GetInt("MainId"),
};
if (model.TeacherId == 0) if (model.TeacherId == 0)
{ {
return ApiResult.ParamIsNull("请选择老师"); return ApiResult.ParamIsNull("请选择老师");
} }
//if (model.StudentId == 0)
//{
// return ApiResult.ParamIsNull();
//}
string surveyListStr = base.ParmJObj.GetStringValue("SurveyList"); string surveyListStr = base.ParmJObj.GetStringValue("SurveyList");
if (!string.IsNullOrWhiteSpace(surveyListStr)) if (!string.IsNullOrWhiteSpace(surveyListStr))
{ {
...@@ -382,15 +484,17 @@ namespace Edu.WebApi.Controllers.Public ...@@ -382,15 +484,17 @@ namespace Edu.WebApi.Controllers.Public
foreach (var jItem in surveyListArray) foreach (var jItem in surveyListArray)
{ {
JObject jobj = JObject.Parse(JsonHelper.Serialize(jItem)); JObject jobj = JObject.Parse(JsonHelper.Serialize(jItem));
var surveyModel = new Rb_Education_Survey_ViewModel(); var surveyModel = new Rb_Education_Survey_ViewModel
surveyModel.ID = jobj.GetInt("ID", 0); {
surveyModel.Title = jobj.GetStringValue("Title"); ID = jobj.GetInt("ID", 0),
surveyModel.TextContent = jobj.GetStringValue("TextContent"); Title = jobj.GetStringValue("Title"),
surveyModel.ScoreNum = jobj.GetInt("ScoreNum", 0); TextContent = jobj.GetStringValue("TextContent"),
surveyModel.SurveyType = (SurveyTypeEnum)jobj.GetInt("SurveyType"); ScoreNum = jobj.GetInt("ScoreNum", 0),
surveyModel.Sort = jobj.GetInt("Sort", 0); SurveyType = (SurveyTypeEnum)jobj.GetInt("SurveyType"),
surveyModel.IsShow = jobj.GetInt("IsShow"); Sort = jobj.GetInt("Sort", 0),
surveyModel.SurveyOptionsList = new List<Rb_Education_SurveyOptions_ViewModel>(); IsShow = jobj.GetInt("IsShow"),
SurveyOptionsList = new List<Rb_Education_SurveyOptions_ViewModel>()
};
var checkInfoStr = jobj.GetStringValue("CheckInfo"); var checkInfoStr = jobj.GetStringValue("CheckInfo");
surveyModel.CheckInfo = new List<int>(); surveyModel.CheckInfo = new List<int>();
if (!string.IsNullOrWhiteSpace(checkInfoStr)) if (!string.IsNullOrWhiteSpace(checkInfoStr))
...@@ -425,27 +529,14 @@ namespace Edu.WebApi.Controllers.Public ...@@ -425,27 +529,14 @@ namespace Edu.WebApi.Controllers.Public
if (item.SurveyType == SurveyTypeEnum.MultiSelect) if (item.SurveyType == SurveyTypeEnum.MultiSelect)
{ {
modelSurveyOptions.ScoreNum = 0; modelSurveyOptions.ScoreNum = 0;
//if (item.CheckInfo == null || !item.CheckInfo.Any())
//{
// return ApiResult.Failed(item.Title + "您还未选择");
//}
modelSurveyOptions.SurveyOptionIds = string.Join(",", item.CheckInfo.Select(x => x)); modelSurveyOptions.SurveyOptionIds = string.Join(",", item.CheckInfo.Select(x => x));
} }
else if (item.SurveyType == SurveyTypeEnum.Score) else if (item.SurveyType == SurveyTypeEnum.Score)
{ {
//if (item.ScoreNum == 0)
//{
// return ApiResult.Failed(item.Title + "您还未打分");
//}
modelSurveyOptions.ScoreNum = item.ScoreNum; modelSurveyOptions.ScoreNum = item.ScoreNum;
} }
else if (item.SurveyType == SurveyTypeEnum.TheRadio) else if (item.SurveyType == SurveyTypeEnum.TheRadio)
{ {
//if (item.ScoreNum == 0)
//{
// return ApiResult.Failed(item.Title + "您还未选择");
//}
modelSurveyOptions.SurveyOptionIds = item.ScoreNum.ToString(); modelSurveyOptions.SurveyOptionIds = item.ScoreNum.ToString();
modelSurveyOptions.ScoreNum = 0; modelSurveyOptions.ScoreNum = 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment