Commit 5ae79b5b authored by 吴春's avatar 吴春

提交老师问卷调查信息

parent 7c8605d3
......@@ -109,6 +109,9 @@ namespace Edu.Common
}
}
/// <summary>
/// JWT加密秘钥
/// </summary>
......@@ -133,6 +136,18 @@ namespace Edu.Common
}
/// <summary>
/// 教育前端url地址
/// </summary>
public static string EducationUrl
{
get
{
return ReadConfigKey("EducationUrl");
}
}
/// <summary>
/// 阿里云oss域名
/// </summary>
......
......@@ -16,6 +16,7 @@
<PackageReference Include="RabbitMQ.Client" Version="5.1.2" />
<PackageReference Include="Spire.Doc" Version="8.12.14" />
<PackageReference Include="System.Security.Cryptography.Cng" Version="5.0.0" />
<PackageReference Include="ThoughtWorks.QRCode" Version="1.1.0" />
</ItemGroup>
<ItemGroup>
......
using Edu.Common.Plugin;
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Common.Enum.Survey
{
/// <summary>
/// 意见调查类型枚举
/// </summary>
public enum SurveyTypeEnum
{
/// <summary>
/// 打分
/// </summary>
[EnumField("打分")]
Score = 1,
/// <summary>
/// 单选
/// </summary>
[EnumField("单选")]
TheRadio = 2,
/// <summary>
/// 多选
/// </summary>
[EnumField("多选")]
MultiSelect = 3,
/// <summary>
/// 文本
/// </summary>
[EnumField("文本")]
TheText = 4,
}
}
using System;
using System.Collections.Generic;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing;
using System.IO;
using System.Text;
using ThoughtWorks.QRCode.Codec;
namespace Edu.Common.Plugin
{
public class QRCodeHelper
{
#region 二维码生成
/// <summary>
/// 批量生成二维码图片
/// </summary>
public static bool Create_CodeImages(string path, int imgSize, string savePath, System.Drawing.Imaging.ImageFormat imageFormat)
{
try
{
//生成图片
Bitmap image = Create_ImgCode(path, imgSize);
//保存图片
SaveImg(savePath, image, imageFormat);
return true;
}
catch (Exception ex)
{
LogHelper.Write(ex, "Create_CodeImages");
return false;
}
}
/// <summary>
/// 保存图片
/// </summary>
/// <param name="strPath">保存路径</param>
/// <param name="imgData">图片</param>
/// <param name="image">图片格式</param>
public static void SaveImg(string strPath, Bitmap imgData, System.Drawing.Imaging.ImageFormat image)
{
string DirectoryPath = Path.GetDirectoryName(strPath);
//保存图片到目录
if (!Directory.Exists(DirectoryPath))
{
//当前目录不存在,则创建
Directory.CreateDirectory(DirectoryPath);
}
//文件名称
imgData.Save(strPath, image);
}
/// <summary>
/// 生成二维码图片
/// </summary>
/// <param name="codeNumber">要生成二维码的字符串</param>
/// <param name="size">大小尺寸</param>
/// <returns>二维码图片</returns>
public static Bitmap Create_ImgCode(string codeNumber, int size)
{
//创建二维码生成类
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder
{
//设置编码模式
QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE,
//设置编码测量度
QRCodeScale = size,
//设置编码版本
QRCodeVersion = 0,
//设置编码错误纠正
QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M
};
//生成二维码图片
System.Drawing.Bitmap image = qrCodeEncoder.Encode(codeNumber);
return image;
}
#endregion
#region base64生成
/// <summary>
/// 根据路径生成base64图片
/// </summary>
/// <param name="path"></param>
/// <param name="imgSize"></param>
/// <param name="LogoPath"></param>
/// <returns></returns>
public static string Create_ImagesForBase64(string path, int imgSize, string LogoPath)
{
try
{
//生成图片
Bitmap image = Create_ImgCode(path, imgSize);
if (string.IsNullOrWhiteSpace(LogoPath))
{
//保存图片
return bitmapToBase64(image, System.Drawing.Imaging.ImageFormat.Png);
}
else
{
//logo
Bitmap bmp1 = ReadImageFile(LogoPath);
ImageUtility util = new ImageUtility();
Bitmap finalImage = util.MergeQrImg(image, bmp1);
//保存图片
return bitmapToBase64(finalImage, System.Drawing.Imaging.ImageFormat.Png);
}
}
catch (Exception ex)
{
LogHelper.Write(ex, string.Format("Create_ImagesForBase64:path:{0},imgSize:{1},LogoPath:{2}", path, imgSize, LogoPath));
return "";
}
}
/// <summary>
/// bitmap转 base64
/// </summary>
/// <param name="bmp1"></param>
/// <param name="imageFormat"></param>
/// <returns></returns>
public static string bitmapToBase64(Bitmap bmp1, System.Drawing.Imaging.ImageFormat imageFormat)
{
string UserPhoto = "";
try
{
using (MemoryStream ms1 = new MemoryStream())
{
bmp1.Save(ms1, imageFormat);
byte[] arr1 = ms1.ToArray();
UserPhoto = Convert.ToBase64String(arr1);
}
}
catch (Exception ex)
{
UserPhoto = "";
LogHelper.Write(ex, string.Format("bitmapToBase64:"));
}
return UserPhoto;
}
/// <summary>
/// 将图片转为base64
/// </summary>
/// <param name="Path"></param>
/// <returns></returns>
public static string ImageToBase64(string Path)
{
Bitmap bmp1 = ReadImageFile(Path);
string UserPhoto = "";
using (MemoryStream ms1 = new MemoryStream())
{
bmp1.Save(ms1, System.Drawing.Imaging.ImageFormat.Png);
byte[] arr1 = ms1.ToArray();
UserPhoto = Convert.ToBase64String(arr1);
}
return UserPhoto;
}
/// <summary>
/// 通过FileStream 来打开文件,这样就可以实现不锁定Image文件,到时可以让多用户同时访问Image文件
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public static Bitmap ReadImageFile(string path)
{
System.Net.WebRequest myrequest = System.Net.WebRequest.Create(path);
System.Net.WebResponse myresponse = myrequest.GetResponse();
Stream imgstream = myresponse.GetResponseStream();
System.Drawing.Image result = System.Drawing.Image.FromStream(imgstream);
Bitmap bit = new Bitmap(result);
return bit;
}
/// <summary>
/// 获取
/// </summary>
/// <param name="imgstream"></param>
/// <returns></returns>
public static string ReadImageForStream(Stream imgstream)
{
System.Drawing.Image result = System.Drawing.Image.FromStream(imgstream);
Bitmap bit = new Bitmap(result);
return bitmapToBase64(bit, System.Drawing.Imaging.ImageFormat.Png);
}
#endregion
/// <summary>
/// 生成二维码
/// </summary>
/// <param name="Text">内容</param>
/// <param name="logopath">Logo地址</param>
/// <returns></returns>
public static string GetQrCode(string Text, string logopath = "")
{
QRCodeEncoder qRCodeEncoder = new QRCodeEncoder
{
QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE,//设置二维码编码格式
QRCodeScale = 4,//设置编码测量度
QRCodeVersion = 7,//设置编码版本
QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M//设置错误校验
};
Bitmap image = qRCodeEncoder.Encode(Text, Encoding.UTF8);
//生成logo
Bitmap logo = null;
if (logopath != "" && !string.IsNullOrEmpty(logopath))
{
logo = new Bitmap(logopath);
}
if (logopath != "" && !string.IsNullOrEmpty(logopath) && logo != null)
{
ImageUtility util = new ImageUtility();
Bitmap finalImage = util.MergeQrImg(image, logo);
MemoryStream tempMs = new MemoryStream();
finalImage.Save(tempMs, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] tempArr = new byte[tempMs.Length];
tempMs.Position = 0;
tempMs.Read(tempArr, 0, (int)tempMs.Length);
tempMs.Close();
return Convert.ToBase64String(tempArr);
}
MemoryStream ms = new MemoryStream();
image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] arr = new byte[ms.Length];
ms.Position = 0;
ms.Read(arr, 0, (int)ms.Length);
ms.Close();
return Convert.ToBase64String(arr);
}
/// <summary>
/// 生成二维码
/// </summary>
/// <param name="Text">内容</param>
/// <param name="logopath">Logo地址</param>
/// <returns></returns>
public static string GetQrCode2(string Text, string logopath = "")
{
QRCodeEncoder qRCodeEncoder = new QRCodeEncoder
{
QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE,//设置二维码编码格式
QRCodeScale = 4,//设置编码测量度
QRCodeVersion = 0,//设置编码版本
QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M,//设置错误校验
};
Bitmap image = qRCodeEncoder.Encode(Text, System.Text.Encoding.UTF8);
//生成logo
Bitmap logo = null;
if (logopath != "" && !string.IsNullOrEmpty(logopath))
{
logo = new Bitmap(logopath);
}
if (logopath != "" && !string.IsNullOrEmpty(logopath) && logo != null)
{
ImageUtility util = new ImageUtility();
Bitmap finalImage = util.MergeQrImg(image, logo);
MemoryStream tempMs = new MemoryStream();
finalImage.Save(tempMs, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] tempArr = new byte[tempMs.Length];
tempMs.Position = 0;
tempMs.Read(tempArr, 0, (int)tempMs.Length);
tempMs.Close();
return Convert.ToBase64String(tempArr);
}
MemoryStream ms = new MemoryStream();
image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] arr = new byte[ms.Length];
ms.Position = 0;
ms.Read(arr, 0, (int)ms.Length);
ms.Close();
return Convert.ToBase64String(arr);
}
}
/// <summary>
/// Image处理
/// </summary>
public class ImageUtility
{
#region 合并用户QR图片和用户头像
/// <summary>
/// 合并用户QR图片和用户头像
/// </summary>
/// <param name="qrImg">QR图片</param>
/// <param name="headerImg">用户头像</param>
/// <param name="n"></param>
/// <returns></returns>
public Bitmap MergeQrImg(Bitmap qrImg, Bitmap headerImg, double n = 0.33)
{
int margin = 3;
float dpix = qrImg.HorizontalResolution;
float dpiy = qrImg.VerticalResolution;
var _newWidth = (10 * qrImg.Width - 36 * margin) * 1.0f / 36;
var _headerImg = ZoomPic(headerImg, _newWidth / headerImg.Width);
//处理头像
int newImgWidth = _headerImg.Width + margin;
Bitmap headerBgImg = new Bitmap(newImgWidth, newImgWidth);
headerBgImg.MakeTransparent();
Graphics g = Graphics.FromImage(headerBgImg);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.Clear(Color.Transparent);
Pen p = new Pen(new SolidBrush(Color.White));
Rectangle rect = new Rectangle(0, 0, newImgWidth - 1, newImgWidth - 1);
using (GraphicsPath path = CreateRoundedRectanglePath(rect, 1))
{
g.DrawPath(p, path);
g.FillPath(new SolidBrush(Color.White), path);
}
//画头像
Bitmap img1 = new Bitmap(_headerImg.Width, _headerImg.Width);
Graphics g1 = Graphics.FromImage(img1);
g1.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g1.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g1.Clear(Color.Transparent);
Pen p1 = new Pen(new SolidBrush(Color.Gray));
Rectangle rect1 = new Rectangle(0, 0, _headerImg.Width - 1, _headerImg.Width - 1);
using (GraphicsPath path1 = CreateRoundedRectanglePath(rect1, 1))
{
g1.DrawPath(p1, path1);
TextureBrush brush = new TextureBrush(_headerImg);
g1.FillPath(brush, path1);
}
g1.Dispose();
PointF center = new PointF((newImgWidth - _headerImg.Width) / 2, (newImgWidth - _headerImg.Height) / 2);
g.DrawImage(img1, center.X, center.Y, _headerImg.Width, _headerImg.Height);
g.Dispose();
Bitmap backgroudImg = new Bitmap(qrImg.Width, qrImg.Height);
backgroudImg.MakeTransparent();
backgroudImg.SetResolution(dpix, dpiy);
headerBgImg.SetResolution(dpix, dpiy);
Graphics g2 = Graphics.FromImage(backgroudImg);
g2.Clear(Color.Transparent);
g2.DrawImage(qrImg, 0, 0);
PointF center2 = new PointF((qrImg.Width - headerBgImg.Width) / 2, (qrImg.Height - headerBgImg.Height) / 2);
g2.DrawImage(headerBgImg, center2);
g2.Dispose();
return backgroudImg;
}
#endregion
#region 图形处理
/// <summary>
/// 创建圆角矩形
/// </summary>
/// <param name="rect">区域</param>
/// <param name="cornerRadius">圆角角度</param>
/// <returns></returns>
private GraphicsPath CreateRoundedRectanglePath(Rectangle rect, int cornerRadius)
{
//下午重新整理下,圆角矩形
GraphicsPath roundedRect = new GraphicsPath();
roundedRect.AddArc(rect.X, rect.Y, cornerRadius * 2, cornerRadius * 2, 180, 90);
roundedRect.AddLine(rect.X + cornerRadius, rect.Y, rect.Right - cornerRadius * 2, rect.Y);
roundedRect.AddArc(rect.X + rect.Width - cornerRadius * 2, rect.Y, cornerRadius * 2, cornerRadius * 2, 270, 90);
roundedRect.AddLine(rect.Right, rect.Y + cornerRadius * 2, rect.Right, rect.Y + rect.Height - cornerRadius * 2);
roundedRect.AddArc(rect.X + rect.Width - cornerRadius * 2, rect.Y + rect.Height - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 0, 90);
roundedRect.AddLine(rect.Right - cornerRadius * 2, rect.Bottom, rect.X + cornerRadius * 2, rect.Bottom);
roundedRect.AddArc(rect.X, rect.Bottom - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 90, 90);
roundedRect.AddLine(rect.X, rect.Bottom - cornerRadius * 2, rect.X, rect.Y + cornerRadius * 2);
roundedRect.CloseFigure();
return roundedRect;
}
/// <summary>
/// 图片按比例缩放
/// </summary>
private Image ZoomPic(Image initImage, double n)
{
//缩略图宽、高计算
double newWidth = initImage.Width;
double newHeight = initImage.Height;
newWidth = n * initImage.Width;
newHeight = n * initImage.Height;
//生成新图
//新建一个bmp图片
System.Drawing.Image newImage = new System.Drawing.Bitmap((int)newWidth, (int)newHeight);
//新建一个画板
System.Drawing.Graphics newG = System.Drawing.Graphics.FromImage(newImage);
//设置质量
newG.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
newG.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
//置背景色
newG.Clear(Color.Transparent);
//画图
newG.DrawImage(initImage, new System.Drawing.Rectangle(0, 0, newImage.Width, newImage.Height), new System.Drawing.Rectangle(0, 0, initImage.Width, initImage.Height), System.Drawing.GraphicsUnit.Pixel);
newG.Dispose();
return newImage;
}
/// <summary>
/// 创建缩略图
/// </summary>
/// <param name="b"></param>
/// <param name="destHeight"></param>
/// <param name="destWidth"></param>
/// <returns></returns>
public static Bitmap GetThumbnail(Bitmap b, int destHeight, int destWidth)
{
System.Drawing.Image imgSource = b;
System.Drawing.Imaging.ImageFormat thisFormat = imgSource.RawFormat;
int sW = 0, sH = 0;
// 按比例缩放
int sWidth = imgSource.Width;
int sHeight = imgSource.Height;
if (sHeight > destHeight || sWidth > destWidth)
{
if ((sWidth * destHeight) > (sHeight * destWidth))
{
sW = destWidth;
sH = (destWidth * sHeight) / sWidth;
}
else
{
sH = destHeight;
sW = (sWidth * destHeight) / sHeight;
}
}
else
{
sW = sWidth;
sH = sHeight;
}
Bitmap outBmp = new Bitmap(destWidth, destHeight);
Graphics g = Graphics.FromImage(outBmp);
g.Clear(Color.Transparent);
// 设置画布的描绘质量
g.CompositingQuality = CompositingQuality.HighQuality;
g.SmoothingMode = SmoothingMode.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.DrawImage(imgSource, new Rectangle((destWidth - sW) / 2, (destHeight - sH) / 2, sW, sH), 0, 0, imgSource.Width, imgSource.Height, GraphicsUnit.Pixel);
g.Dispose();
// 以下代码为保存图片时,设置压缩质量
EncoderParameters encoderParams = new EncoderParameters();
long[] quality = new long[1];
quality[0] = 100;
EncoderParameter encoderParam = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, quality);
encoderParams.Param[0] = encoderParam;
imgSource.Dispose();
return outBmp;
}
#endregion
}
}
using Edu.Common.Enum;
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Edu.Model.Entity.Survey
{
/// <summary>
/// 学生意见信息表
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class Rb_Education_StudentSurvey
{
/// <summary>
/// 编号
/// </summary>
public int ID { get; set; }
/// <summary>
/// 学生id
/// </summary>
public int StudentId { get; set; }
/// <summary>
/// 老师id
/// </summary>
public int TeacherId { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime? CreateDate { get; set; }
/// <summary>
/// 删除
/// </summary>
public DateStateEnum State { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Edu.Model.Entity.Survey
{
/// <summary>
/// 学生意见信息选项表
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class Rb_Education_StudentSurveyDetails
{
/// <summary>
/// 编号
/// </summary>
public int ID { get; set; }
/// <summary>
/// 学生调查id
/// </summary>
public int StudentSurveyId { get; set; }
/// <summary>
/// 意见id
/// </summary>
public int? SurveyId { get; set; }
/// <summary>
/// 意见选项ids
/// </summary>
public string SurveyOptionIds { get; set; }
/// <summary>
/// 文本内容
/// </summary>
public string TextContent { get; set; }
/// <summary>
/// 分数
/// </summary>
public int ScoreNum { get; set; }
}
}
using Edu.Common.Enum;
using Edu.Common.Enum.Survey;
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Edu.Model.Entity.Survey
{
/// <summary>
/// 学生意见调查信息表
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class Rb_Education_Survey
{
/// <summary>
/// 编号
/// </summary>
public int ID { get; set; }
/// <summary>
///意见调查类型
/// </summary>
public SurveyTypeEnum? SurveyType { get; set; }
/// <summary>
/// 标题
/// </summary>
public string Title { get; set; }
/// <summary>
/// 排序
/// </summary>
public int Sort { get; set; }
/// <summary>
/// 是否显示(前台)
/// </summary>
public int IsShow { get; set; }
/// <summary>
/// 删除
/// </summary>
public DateStateEnum State { get; set; }
/// <summary>
/// 公司
/// </summary>
public int? RB_Branch_Id
{
get;
set;
}
/// <summary>
/// 集团
/// </summary>
public int? RB_Group_Id
{
get;
set;
}
/// <summary>
/// 创建人
/// </summary>
public int? CreateBy
{
get;
set;
}
/// <summary>
/// 创建时间
/// </summary>
public DateTime? CreateDate
{
get;
set;
}
/// <summary>
/// 修改人
/// </summary>
public int? UpdateBy
{
get;
set;
}
/// <summary>
/// 修改时间
/// </summary>
public DateTime? UpdateDate
{
get;
set;
}
}
}
using Edu.Common.Enum;
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Edu.Model.Entity.Survey
{
/// <summary>
/// 意见调查选项信息表
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class Rb_Education_SurveyOptions
{
/// <summary>
/// 编号
/// </summary>
public int ID { get; set; }
/// <summary>
/// 调查表id
/// </summary>
public int SurveyID { get; set; }
/// <summary>
/// 选项名称
/// </summary>
public string OptionsName { get; set; }
/// <summary>
/// 删除
/// </summary>
public DateStateEnum State { get; set; }
/// <summary>
/// 排序
/// </summary>
public int Sort { get; set; }
}
}
......@@ -28,6 +28,11 @@ namespace Edu.Model.ViewModel.DataStatistics
/// </summary>
public string StuTel { get; set; }
/// <summary>
/// 二维码图片信息
/// </summary>
public string QrCodeUrl { get; set; }
/// <summary>
/// 学员真实电话
/// </summary>
......@@ -61,7 +66,7 @@ namespace Edu.Model.ViewModel.DataStatistics
/// <summary>
/// 初报级别
/// </summary>
public string CourseRateName { get; set; }
public string CourseRateName { get; set; }
......
using Edu.Model.Entity.Survey;
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Model.ViewModel.Survey
{
/// <summary>
/// 学生意见信息扩展表
/// </summary>
public class Rb_Education_StudentSurvey_ViewModel : Rb_Education_StudentSurvey
{
/// <summary>
/// 选项详情
/// </summary>
public List<Rb_Education_SurveyOptions_ViewModel> GuestSurveyDetailsList { get; set; }
/// <summary>
/// 旅客选项
/// </summary>
public List<Rb_Education_StudentSurveyDetails> SurveyOptionsList { get; set; }
/// <summary>
/// 1-有评分,-1无评分
/// </summary>
public int IsScore { get; set; }
/// <summary>
/// 分数
/// </summary>
public decimal ScoreNum { get; set; }
/// <summary>
/// 条数
/// </summary>
public int ScoreCount { get; set; }
/// <summary>
/// 填写开始日期
/// </summary>
public string QStartDate { get; set; }
/// <summary>
/// 填写结束日期
/// </summary>
public string QEndDate { get; set; }
/// <summary>
/// 老师名称
/// </summary>
public string TeacherName { get; set; }
/// <summary>
/// 学生名称
/// </summary>
public string StudentName { get; set; }
}
}
using Edu.Model.Entity.Survey;
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Model.ViewModel.Survey
{
/// <summary>
/// 意见调查表选项扩展表
/// </summary>
public class Rb_Education_SurveyOptions_ViewModel : Rb_Education_SurveyOptions
{
/// <summary>
/// 单选多选(多选和单选(1))
/// </summary>
public string IsCheck { get; set; }
}
}
using Edu.Model.Entity.Survey;
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Model.ViewModel.Survey
{
/// <summary>
/// 学生意见调查信息扩展表
/// </summary>
public class Rb_Education_Survey_ViewModel : Rb_Education_Survey
{
/// <summary>
/// 选项
/// </summary>
public List<Rb_Education_SurveyOptions_ViewModel> SurveyOptionsList { get; set; }
/// <summary>
/// 分数
/// </summary>
public int ScoreNum { get; set; }
/// <summary>
/// 文本内容
/// </summary>
public string TextContent { get; set; }
/// <summary>
/// 学生id
/// </summary>
public int StudentId { get; set; }
/// <summary>
/// 选项信息
/// </summary>
public List<int> CheckInfo { get; set; }
}
}
using Edu.Common.Enum.Survey;
using Edu.Common.Plugin;
using Edu.Model.CacheModel;
using Edu.Model.Entity.Survey;
using Edu.Model.ViewModel.Survey;
using Edu.Model.ViewModel.User;
using Edu.Repository.Survey;
using Edu.Repository.User;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VT.FW.DB;
namespace Edu.Module.Public
{
/// <summary>
/// 意见调查处理实体类
/// </summary>
public class SurveyModule
{
/// <summary>
/// 调查选项
/// </summary>
private Rb_Education_SurveyRepository respository = new Rb_Education_SurveyRepository();
/// <summary>
/// 学生信息
/// </summary>
private RB_StudentRepository studentRepository = new RB_StudentRepository();
/// <summary>
/// 老师信息
/// </summary>
private RB_TeacherRepository teacherRepository = new RB_TeacherRepository();
/// <summary>
/// 调查
/// </summary>
private Rb_Education_SurveyOptionsRepository surveyOptionsRepository = new Rb_Education_SurveyOptionsRepository();
/// <summary>
/// 学生调查信息
/// </summary>
private Rb_Education_StudentSurveyRepository guestSurveyRepository = new Rb_Education_StudentSurveyRepository();
/// <summary>
/// 学生调查选项信息
/// </summary>
private Rb_Education_StudentSurveyDetailsRepository guestSurveyDetailsRepository = new Rb_Education_StudentSurveyDetailsRepository();
#region 意见调查基础信息
/// <summary>
/// 分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="where"></param>
/// <returns></returns>
public List<Rb_Education_Survey_ViewModel> GetPageList(int pageIndex, int pageSize, out long rowsCount, Rb_Education_Survey where)
{
return respository.GetPageList(pageIndex, pageSize, out rowsCount, where);
}
/// <summary>
/// 获取实体
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public Rb_Education_Survey GetEntity(int id)
{
return respository.GetEntity(id);
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="where"></param>
/// <returns></returns>
public List<Rb_Education_SurveyOptions_ViewModel> GetSurveyOptionsList(Rb_Education_SurveyOptions where)
{
return surveyOptionsRepository.GetList(where);
}
public bool SetSurvey(Rb_Education_Survey_ViewModel model)
{
var trans = respository.DbTransaction;
try
{
int surveyId = 0;
if (model.ID > 0)
{
surveyId = model.ID;
IDictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(Rb_Education_Survey.Title),model.Title},
{ nameof(Rb_Education_Survey.IsShow),model.IsShow},
{ nameof(Rb_Education_Survey.Sort),model.Sort},
{ nameof(Rb_Education_Survey.SurveyType),(int)model.SurveyType},
{ nameof(Rb_Education_Survey.UpdateBy),model.UpdateBy},
{ nameof(Rb_Education_Survey.UpdateDate),model.UpdateDate},
};
List<WhereHelper> where = new List<WhereHelper>()
{
new WhereHelper ()
{
FiledName=nameof(Rb_Education_Survey.ID),
FiledValue=model.ID,
OperatorEnum= OperatorEnum.Equal
}
};
var flag = respository.Update(fileds, where, trans);
//查询之前的选项
var surveyOptionsList = surveyOptionsRepository.GetList(new Rb_Education_SurveyOptions { SurveyID = surveyId });
//删除之前有现在没有的
List<string> surveyOptionsExcept = new List<string>();
if (surveyOptionsList != null && surveyOptionsList.Any() && model.SurveyOptionsList != null && model.SurveyOptionsList.Any())
{
//差集
surveyOptionsExcept = surveyOptionsList.Select(x => x.ID.ToString()).Except(model.SurveyOptionsList.Select(x => x.ID.ToString())).ToList();
}
else if (model.SurveyOptionsList == null || !model.SurveyOptionsList.Any())
{
flag = surveyOptionsRepository.DeleteBatch(surveyOptionsList, trans);
}
foreach (var item in surveyOptionsList.Where(x => surveyOptionsExcept.Contains(x.ID.ToString())))
{
flag = surveyOptionsRepository.Delete(item, trans) > 0;
}
}
else
{
surveyId = respository.Insert(model, trans);
}
if (model.SurveyType != SurveyTypeEnum.Score && model.SurveyType != SurveyTypeEnum.TheText)//新增选项
{
foreach (var item in model.SurveyOptionsList)
{
if (item.ID == 0)
{
item.SurveyID = surveyId;
surveyOptionsRepository.Insert(item, trans);
}
else
{
surveyOptionsRepository.Update(item, trans);
}
}
}
respository.DBSession.Commit();
return true;
}
catch (Exception ex)
{
LogHelper.Write(ex, "SetSurvey");
respository.DBSession.Rollback("SetSurvey");
return false;
}
}
/// <summary>
/// 删除调查信息
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool DelSurvey(Rb_Education_Survey_ViewModel model)
{
var trans = respository.DbTransaction;
try
{
if (model.ID > 0)
{
IDictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(Rb_Education_Survey.State),(int)Common.Enum.DateStateEnum.Delete},
};
List<WhereHelper> where = new List<WhereHelper>()
{
new WhereHelper ()
{
FiledName=nameof(Rb_Education_Survey.ID),
FiledValue=model.ID,
OperatorEnum= OperatorEnum.Equal
}
};
var flag = respository.Update(fileds, where, trans);
if (model.SurveyOptionsList != null && model.SurveyOptionsList.Any())
{
model.SurveyOptionsList.ForEach(x => x.State = Common.Enum.DateStateEnum.Delete);
flag = surveyOptionsRepository.UpdateBatch(model.SurveyOptionsList, trans);
}
}
respository.DBSession.Commit();
return true;
}
catch (Exception ex)
{
LogHelper.Write(ex, "DelSurvey");
respository.DBSession.Rollback("DelSurvey");
return false;
}
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="SurveyIDs"></param>
/// <returns></returns>
public List<Rb_Education_SurveyOptions_ViewModel> GetList(string SurveyIDs)
{
return surveyOptionsRepository.GetList(SurveyIDs);
}
#endregion
#region 旅客意见信息
/// <summary>
/// 获取实体
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public Rb_Education_StudentSurvey GetGuestSurveyEntity(int id)
{
return guestSurveyRepository.GetEntity(id);
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="SurveyIDs"></param>
/// <returns></returns>
public List<Rb_Education_Survey_ViewModel> GetSurveyList(string SurveyIDs)
{
return respository.GetList(SurveyIDs);
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="where"></param>
/// <returns></returns>
public List<Rb_Education_Survey_ViewModel> GetAllList(Rb_Education_Survey_ViewModel where)
{
var List = respository.GetList(where);
if (List != null && List.Any())
{
var surveyOptionsList = surveyOptionsRepository.GetList(string.Join(",", List.Select(x => x.ID)));
foreach (var item in List)
{
item.SurveyOptionsList = new List<Rb_Education_SurveyOptions_ViewModel>();
item.SurveyOptionsList = surveyOptionsList.Where(x => x.SurveyID == item.ID).OrderBy(x => x.Sort).ToList();
item.SurveyOptionsList.ForEach(x => x.IsCheck = "0");
}
}
else
{
List = new List<Rb_Education_Survey_ViewModel>();
}
return List;
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="where"></param>
/// <returns></returns>
public List<Rb_Education_StudentSurveyDetails> GetGuestSurveyDetailsList(Rb_Education_StudentSurveyDetails where)
{
return guestSurveyDetailsRepository.GetList(where);
}
/// <summary>
/// 新增学生调查信息
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int SetStudentSurvey(Rb_Education_StudentSurvey_ViewModel model)
{
var trans = guestSurveyRepository.DbTransaction;
int surveyId = 0;
try
{
surveyId = guestSurveyRepository.Insert(model, trans);
foreach (var item in model.SurveyOptionsList)
{
if (item.ID == 0)
{
item.StudentSurveyId = surveyId;
guestSurveyDetailsRepository.Insert(item, trans);
}
else
{
guestSurveyDetailsRepository.Update(item, trans);
}
}
guestSurveyRepository.DBSession.Commit();
return surveyId;
}
catch (Exception ex)
{
LogHelper.Write(ex, "SetStudentSurvey");
guestSurveyRepository.DBSession.Rollback("SetStudentSurvey");
return 0;
}
}
/// <summary>
/// 新增学生调查信息
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool SetBbatchStudentSurvey(List<Rb_Education_StudentSurvey_ViewModel> list)
{
var trans = guestSurveyRepository.DbTransaction;
int surveyId = 0;
try
{
foreach (var itemModel in list)
{
surveyId = guestSurveyRepository.Insert(itemModel, trans);
foreach (var item in itemModel.SurveyOptionsList)
{
if (item.ID == 0)
{
item.StudentSurveyId = surveyId;
guestSurveyDetailsRepository.Insert(item, trans);
}
else
{
guestSurveyDetailsRepository.Update(item, trans);
}
}
}
guestSurveyRepository.DBSession.Commit();
return true;
}
catch (Exception ex)
{
LogHelper.Write(ex, "SetBbatchStudentSurvey");
guestSurveyRepository.DBSession.Rollback("SetBbatchStudentSurvey");
return false;
}
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="where"></param>
/// <returns></returns>
public List<Rb_Education_StudentSurvey_ViewModel> GetGuestSurveyList(Rb_Education_StudentSurvey_ViewModel where)
{
return guestSurveyRepository.GetTravelGuestSurveyListRepository(where);
}
/// <summary>
/// 分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="where"></param>
/// <returns></returns>
public List<Rb_Education_StudentSurvey_ViewModel> GetTravelSurveyPageModule(int pageIndex, int pageSize, out long rowsCount, Rb_Education_StudentSurvey_ViewModel where)
{
var list = guestSurveyRepository.GetTravelSurveyPageRepository(pageIndex, pageSize, out rowsCount, where);
if (list != null && list.Any())
{
List<RB_Student_ViewModel> studentList = new List<RB_Student_ViewModel>();
var studentIds = string.Join(",", list.Select(x => x.StudentId).Distinct());
if (!string.IsNullOrWhiteSpace(studentIds))
{
//查询出学生信息
studentList = studentRepository.GetStudentListByStuIdsRepository(new RB_Student_ViewModel { StuIds = studentIds });
}
var teacherIds = string.Join(",", list.Select(x => x.TeacherId).Distinct());
List<RB_Teacher_ViewModel> teacherList = new List<RB_Teacher_ViewModel>();
if (!string.IsNullOrWhiteSpace(teacherIds))
{
//查询出老师信息
teacherList = teacherRepository.GetTeacherByTeacherIdsList(teacherIds);
}
foreach (var item in list)
{
item.TeacherName = teacherList?.FirstOrDefault(x => x.TId == item.TeacherId)?.TeacherName ?? "";
item.StudentName = studentList?.FirstOrDefault(x => x.StuId == item.StudentId)?.StuName ?? "";
}
}
return list;
}
#endregion
}
}
......@@ -408,6 +408,7 @@ namespace Edu.Module.User
}),
IsShowFollowAll = false,
NewLesson = NewLesson,
QrCodeUrl = "",
};
RList.Add(followModel);
}
......
using Edu.Model.Entity.Survey;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Edu.Repository.Survey
{
/// <summary>
/// 学生意见调查选项仓储类
/// </summary>
public class Rb_Education_StudentSurveyDetailsRepository : BaseRepository<Rb_Education_StudentSurveyDetails>
{
/// <summary>
/// 表名称
/// </summary>
public string TableName { get { return nameof(Rb_Education_StudentSurveyDetails); } }
/// <summary>
/// 获取列表
/// </summary>
/// <param name="where"></param>
/// <returns></returns>
public List<Rb_Education_StudentSurveyDetails> GetList(Rb_Education_StudentSurveyDetails where)
{
StringBuilder sb = new StringBuilder();
sb.Append($@"SELECT * from {TableName} where 1=1");
if (where != null)
{
if (where.SurveyId > 0)
{
sb.AppendFormat(" and SurveyId={0}", where.SurveyId);
}
if (where.StudentSurveyId > 0)
{
sb.AppendFormat(" and StudentSurveyId={0}", where.StudentSurveyId);
}
}
return Get<Rb_Education_StudentSurveyDetails>(sb.ToString()).ToList();
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="GuestSurveyIds"></param>
/// <returns></returns>
public List<Rb_Education_StudentSurveyDetails> GetEducationStudentSurveyDetailsListRepository(string StudentSurveyIds)
{
StringBuilder sb = new StringBuilder();
sb.Append($@"SELECT * from {TableName} where 1=1");
if (!string.IsNullOrWhiteSpace(StudentSurveyIds))
{
sb.AppendFormat(" and StudentSurveyId in({0})", StudentSurveyIds);
}
return Get<Rb_Education_StudentSurveyDetails>(sb.ToString()).ToList();
}
}
}
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_StudentSurveyRepository : BaseRepository<Rb_Education_StudentSurvey>
{
/// <summary>
/// 表名称
/// </summary>
public string TableName { get { return nameof(Rb_Education_StudentSurvey); } }
/// <summary>
/// 获取旅客意见调查列表
/// </summary>
/// <param name="where"></param>
/// <returns></returns>
public List<Rb_Education_StudentSurvey_ViewModel> GetTravelGuestSurveyListRepository(Rb_Education_StudentSurvey_ViewModel where)
{
StringBuilder sb = new StringBuilder();
sb.Append($@"SELECT * FROM {TableName} WHERE state=0");
if (where != null)
{
if (where.StudentId > 0)
{
sb.AppendFormat(" and StudentId={0}", where.StudentId);
}
if (where.TeacherId > 0)
{
sb.AppendFormat(" and TeacherId={0}", where.TeacherId);
}
}
return Get<Rb_Education_StudentSurvey_ViewModel>(sb.ToString()).ToList();
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="where"></param>
/// <returns></returns>
public List<Rb_Education_StudentSurvey_ViewModel> GetListInfo(Rb_Education_StudentSurvey_ViewModel where)
{
StringBuilder sb = new StringBuilder();
sb.Append($@"
SELECT a.*,IFNULL(c.ScoreNum,0) AS ScoreNum,IFNULL(c.ScoreCount,0) AS ScoreCount
FROM {TableName} AS a
LEFT JOIN (SELECT StudentSurveyId,SUM(ScoreNum) as ScoreNum,COUNT(GuestSurveyId) as ScoreCount FROM Rb_Education_StudentSurveyDetails WHERE ScoreNum>0 GROUP BY StudentSurveyId ) as c ON a.ID=c.StudentSurveyId
WHERE a.state=0");
if (where != null)
{
if (where.StudentId > 0)
{
sb.AppendFormat(" and a.StudentId={0}", where.StudentId);
}
if (where.TeacherId > 0)
{
sb.AppendFormat(" and a.TeacherId={0}", where.TeacherId);
}
}
return Get<Rb_Education_StudentSurvey_ViewModel>(sb.ToString()).ToList();
}
/// <summary>
/// 分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="where"></param>
/// <returns></returns>
public List<Rb_Education_StudentSurvey_ViewModel> GetTravelSurveyPageRepository(int pageIndex, int pageSize, out long rowsCount, Rb_Education_StudentSurvey_ViewModel where)
{
var parameters = new DynamicParameters();
StringBuilder sb = new StringBuilder();
sb.Append($@"
SELECT a.*,IFNULL(c.ScoreNum,0) AS ScoreNum,IFNULL(c.ScoreCount,0) AS ScoreCount
FROM {TableName} AS a
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");
if (where != null)
{
if (where.StudentId > 0)
{
sb.AppendFormat(" and a.StudentId={0}", where.StudentId);
}
if (where.TeacherId > 0)
{
sb.AppendFormat(" and a.TeacherId={0}", where.TeacherId);
}
if (!string.IsNullOrEmpty(where.QStartDate))
{
sb.AppendFormat(" AND A.CreateDate>='{0}' ", where.QStartDate);
}
if (!string.IsNullOrEmpty(where.QEndDate))
{
sb.AppendFormat(" AND A.CreateDate<='{0} 23:59:59' ", where.QEndDate);
}
}
sb.AppendFormat(" ORDER BY A.CreateDate ASC ");
return GetPage<Rb_Education_StudentSurvey_ViewModel>(pageIndex, pageSize, out rowsCount, sb.ToString(), parameters).ToList();
}
}
}
using Edu.Model.Entity.Survey;
using Edu.Model.ViewModel.Survey;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Edu.Repository.Survey
{
/// <summary>
/// 意见调查基础选项仓储类
/// </summary>
public class Rb_Education_SurveyOptionsRepository : BaseRepository<Rb_Education_SurveyOptions>
{
/// <summary>
/// 表名称
/// </summary>
public string TableName { get { return nameof(Rb_Education_SurveyOptions); } }
/// <summary>
/// 获取列表
/// </summary>
/// <param name="where"></param>
/// <returns></returns>
public List<Rb_Education_SurveyOptions_ViewModel> GetList(Rb_Education_SurveyOptions where)
{
StringBuilder sb = new StringBuilder();
sb.Append($@"SELECT * from Rb_Education_SurveyOptions where state=0");
if (where != null)
{
if (where.SurveyID > 0)
{
sb.AppendFormat(" and SurveyID={0}", where.SurveyID);
}
}
sb.Append($" ORDER BY {nameof(Rb_Education_SurveyOptions.Sort)} ASC");
return Get<Rb_Education_SurveyOptions_ViewModel>(sb.ToString()).ToList();
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="SurveyIDs"></param>
/// <returns></returns>
public List<Rb_Education_SurveyOptions_ViewModel> GetList(string SurveyIDs)
{
StringBuilder sb = new StringBuilder();
sb.Append($@"SELECT * from Rb_Education_SurveyOptions where state=0");
if (!string.IsNullOrWhiteSpace(SurveyIDs))
{
sb.AppendFormat(" and SurveyID in({0})", SurveyIDs);
}
sb.Append($" ORDER BY {nameof(Rb_Education_SurveyOptions.Sort)} ASC");
return Get<Rb_Education_SurveyOptions_ViewModel>(sb.ToString()).ToList();
}
}
}
using Edu.Model.Entity.Survey;
using Edu.Model.ViewModel.Survey;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Edu.Repository.Survey
{
/// <summary>
/// 意见调查基础信息仓储类
/// </summary>
public class Rb_Education_SurveyRepository : BaseRepository<Rb_Education_Survey>
{
/// <summary>
/// 表名称
/// </summary>
public string TableName { get { return nameof(Rb_Education_Survey); } }
/// <summary>
/// 获取列表
/// </summary>
/// <param name="where"></param>
/// <returns></returns>
public List<Rb_Education_Survey_ViewModel> GetList(Rb_Education_Survey where)
{
StringBuilder sb = new StringBuilder();
sb.Append($@"SELECT * from Rb_Education_Survey where state=0");
if (where != null)
{
if (where.RB_Group_Id > 0)
{
sb.AppendFormat(" and RB_Group_Id={0}", where.RB_Group_Id);
}
if (where.IsShow > 0)
{
sb.AppendFormat(" and IsShow={0}", where.IsShow);
}
if (!string.IsNullOrWhiteSpace(where.Title))
{
sb.AppendFormat(" and Title like'%{0}%'", where.Title);
}
if (where.SurveyType.HasValue && (int)where.SurveyType > 0)
{
sb.AppendFormat(" and SurveyType={0}", (int)where.SurveyType);
}
}
sb.Append($" ORDER BY {nameof(Rb_Education_Survey.Sort)} ASC");
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.Append($@"SELECT * from Rb_Education_Survey where state=0");
if (!string.IsNullOrWhiteSpace(SurveyIDs))
{
sb.AppendFormat(" and ID in({0})", SurveyIDs);
}
sb.Append($" ORDER BY {nameof(Rb_Education_Survey.Sort)} ASC");
return Get<Rb_Education_Survey_ViewModel>(sb.ToString()).ToList();
}
/// <summary>
/// 意见调查表配置项分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="where"></param>
/// <returns></returns>
public List<Rb_Education_Survey_ViewModel> GetPageList(int pageIndex, int pageSize, out long rowsCount, Rb_Education_Survey where)
{
StringBuilder sb = new StringBuilder();
sb.Append($@"SELECT * from Rb_Education_Survey where state=0");
if (where != null)
{
if (where.IsShow > -1)
{
sb.AppendFormat(" and IsShow={0}", where.IsShow);
}
if (where.SurveyType.HasValue && (int)where.SurveyType > 0)
{
sb.AppendFormat(" and SurveyType={0}", (int)where.SurveyType);
}
if (!string.IsNullOrWhiteSpace(where.Title))
{
sb.AppendFormat(" and Title like'%{0}%'", where.Title);
}
}
sb.Append($" ORDER BY {nameof(Rb_Education_Survey.Sort)} ASC");
return GetPage<Rb_Education_Survey_ViewModel>(pageIndex, pageSize, out rowsCount, sb.ToString()).ToList();
}
}
}
......@@ -1457,5 +1457,89 @@ where e.ClassScrollType=2 and c.OrderState=1
return GetPage<RB_Student_ViewModel>(pageIndex, pageSize, out rowsCount, builder.ToString(), parameters).ToList();
}
/// <summary>
/// 获取学生列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Student_ViewModel> GetStudentListByStuIdsRepository(RB_Student_ViewModel query)
{
var parameters = new DynamicParameters();
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT t.*
FROM rb_student AS t
WHERE 1=1
");
// builder.AppendFormat(" AND t.{0}={1} ", nameof(RB_Student_ViewModel.Status), (int)DateStateEnum.Normal);
if (query != null)
{
if (query.Group_Id > 0)
{
builder.AppendFormat(" AND t.{0}={1} ", nameof(RB_Student_ViewModel.Group_Id), query.Group_Id);
}
if (!string.IsNullOrWhiteSpace(query.StuName))
{
builder.AppendFormat(" AND t.{0} LIKE @StuName ", nameof(RB_Student_ViewModel.StuName));
parameters.Add("StuName", "%" + query.StuName.Trim() + "%");
}
if (!string.IsNullOrWhiteSpace(query.StuTel))
{
builder.AppendFormat(" AND t.{0} LIKE @StuTel ", nameof(RB_Student_ViewModel.StuTel));
parameters.Add("StuTel", "%" + query.StuTel.Trim() + "%");
}
if (query.ProviceId > 0)
{
builder.AppendFormat(" AND t.{0}={1} ", nameof(RB_Student_ViewModel.ProviceId), query.ProviceId);
}
if (query.CityId > 0)
{
builder.AppendFormat(" AND t.{0}={1} ", nameof(RB_Student_ViewModel.CityId), query.CityId);
}
if (query.AreaId > 0)
{
builder.AppendFormat(" AND t.{0}={1} ", nameof(RB_Student_ViewModel.AreaId), query.AreaId);
}
if (query.CustomerId > 0)
{
builder.AppendFormat(" AND t.{0}={1} ", nameof(RB_Student_ViewModel.CustomerId), query.CustomerId);
}
if (query.StuId > 0)
{
builder.AppendFormat(" AND t.{0}={1} ", nameof(RB_Student_ViewModel.StuId), query.StuId);
}
if (!string.IsNullOrEmpty(query.StuIds))
{
builder.AppendFormat(" AND t.{0} in({1}) ", nameof(RB_Student_ViewModel.StuId), query.StuIds);
}
if (query.StuStage > 0)
{
builder.AppendFormat(" AND t.{0}={1} ", nameof(RB_Student_ViewModel.StuStage), (int)query.StuStage);
}
if (query.CreateBy > 0)
{
builder.AppendFormat(" AND t.{0}={1} ", nameof(RB_Student_ViewModel.CreateBy), query.CreateBy);
}
if (!string.IsNullOrEmpty(query.QCreateBys))
{
builder.AppendFormat(@" AND (t.CreateBy IN({0}) OR t.StuId IN(SELECT StuId FROM rb_student_assist WHERE AssistId IN({0}) AND `Status`= 0) ) ", query.QCreateBys);
}
if (!string.IsNullOrEmpty(query.StartTime))
{
builder.AppendFormat(" AND t.{0}>='{1}' ", nameof(RB_Student_ViewModel.CreateTime), query.StartTime);
}
if (!string.IsNullOrEmpty(query.EndTime))
{
builder.AppendFormat(" AND t.{0}<='{1} 23:59:59' ", nameof(RB_Student_ViewModel.CreateTime), query.EndTime);
}
}
var stuList = Get<RB_Student_ViewModel>(builder.ToString(), parameters).ToList();
return stuList;
}
}
}
\ No newline at end of file
......@@ -252,5 +252,25 @@ WHERE 1=1
return Get<RB_Teacher_ViewModel>(builder.ToString(), parameters).ToList();
}
/// <summary>
/// 获取教师账户
/// </summary>
/// <param name="teacherIds"></param>
/// <returns></returns>
public List<RB_Teacher_ViewModel> GetTeacherByTeacherIdsList(string teacherIds)
{
var parameters = new DynamicParameters();
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT t.*
FROM rb_teacher AS t
WHERE 1=1
");
builder.AppendFormat(" AND t.{0} IN({1}) ", nameof(RB_Teacher_ViewModel.TId), teacherIds);
return Get<RB_Teacher_ViewModel>(builder.ToString(), parameters).ToList();
}
}
}
\ No newline at end of file
using Aliyun.OSS.Util;
using Edu.Common.API;
using Edu.Common.Enum;
using Edu.Common.Enum.Course;
using Edu.Common.Enum.Survey;
using Edu.Common.Plugin;
using Edu.Model.CacheModel;
using Edu.Model.Entity.Survey;
using Edu.Model.ViewModel.Survey;
using Edu.Module.Customer;
using Edu.Module.Public;
using Edu.Module.System;
using Edu.WebApi.Filter;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Spire.Pdf.Exporting.XPS.Schema;
using System;
using System.Collections.Generic;
using System.Linq;
using VT.FW.DB.DapperExtensions;
namespace Edu.WebApi.Controllers.Public
{
[Route("api/[controller]/[action]")]
[ApiExceptionFilter]
[ApiController]
[EnableCors("AllowCors")]
public class SurveyController : BaseController
{
/// <summary>
/// 意见调查处理对象
/// </summary>
private readonly SurveyModule module = AOP.AOPHelper.CreateAOPObject<SurveyModule>();
#region 意见调查信息
/// <summary>
/// 获取分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetPageList()
{
ResultPageModel pmodel = JsonConvert.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
Rb_Education_Survey_ViewModel model = new Rb_Education_Survey_ViewModel
{
Title = base.ParmJObj.GetStringValue("Title"),
SurveyType = (SurveyTypeEnum)base.ParmJObj.GetInt("SurveyType"),
IsShow = base.ParmJObj.GetInt("IsShow"),
};
UserInfo userInfo = base.UserInfo;
var data = module.GetPageList(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();
pmodel.Count = int.Parse(count.ToString());
pmodel.PageData = list;
return ApiResult.Success("", pmodel);
}
/// <summary>
/// 通过id获取信息
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public ApiResult GetSurvey()
{
int SurveyID = base.ParmJObj.GetInt("SurveyID");
Rb_Education_Survey_ViewModel model = module.GetEntity(SurveyID).RefMapperTo<Rb_Education_Survey_ViewModel>();
if (model != null)
{
model.SurveyOptionsList = new List<Rb_Education_SurveyOptions_ViewModel>();
model.SurveyOptionsList = module.GetSurveyOptionsList(new Rb_Education_SurveyOptions_ViewModel { SurveyID = model.ID });
return ApiResult.Success("请求成功!", model);
}
return ApiResult.Failed("未找到此调查信息!");
}
/// <summary>
/// 通过id删除意见调查表信息
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public ApiResult DelSurvey()
{
int SurveyID = base.ParmJObj.GetInt("SurveyID");
Rb_Education_Survey_ViewModel model = module.GetEntity(SurveyID).RefMapperTo<Rb_Education_Survey_ViewModel>();
if (model != null)
{
if (model.State == Common.Enum.DateStateEnum.Delete)
{
return ApiResult.Failed("已删除请勿重复删除!");
}
model.SurveyOptionsList = new List<Rb_Education_SurveyOptions_ViewModel>();
model.SurveyOptionsList = module.GetSurveyOptionsList(new Rb_Education_SurveyOptions_ViewModel { SurveyID = model.ID });
bool result = module.DelSurvey(model);
return ApiResult.Success("删除成功!");
}
return ApiResult.Failed("未找到此调查信息!");
}
/// <summary>
/// 添加修改调查信息
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public virtual ApiResult SetSurvey()
{
UserInfo userInfo = base.UserInfo;
Rb_Education_Survey_ViewModel model = new Rb_Education_Survey_ViewModel()
{
ID = base.ParmJObj.GetInt("ID", 0),
Title = base.ParmJObj.GetStringValue("Title"),
SurveyType = (SurveyTypeEnum)base.ParmJObj.GetInt("SurveyType"),
Sort = base.ParmJObj.GetInt("Sort", 0),
IsShow = base.ParmJObj.GetInt("IsShow"),
SurveyOptionsList = new List<Rb_Education_SurveyOptions_ViewModel>(),
};
string surveyOptionsListStr = base.ParmJObj.GetStringValue("SurveyOptionsList");
if (!string.IsNullOrWhiteSpace(surveyOptionsListStr))
{
JArray logosurveyOptionsListArray = JArray.Parse(surveyOptionsListStr);
if (logosurveyOptionsListArray != null && logosurveyOptionsListArray.Count > 0)
{
foreach (var jItem in logosurveyOptionsListArray)
{
JObject jobj = JObject.Parse(JsonHelper.Serialize(jItem));
var surveyOptionsModel = new Rb_Education_SurveyOptions_ViewModel();
surveyOptionsModel.ID = jobj.GetInt("ID", 0);
surveyOptionsModel.OptionsName = jobj.GetStringValue("OptionsName");
surveyOptionsModel.Sort = jobj.GetInt("Sort", 0);
surveyOptionsModel.State = Common.Enum.DateStateEnum.Normal;
surveyOptionsModel.SurveyID = model.ID;
model.SurveyOptionsList.Add(surveyOptionsModel);
}
}
}
if (string.IsNullOrEmpty(model.Title))
{
return ApiResult.Failed("请填写名称!");
}
if (model.SurveyType == SurveyTypeEnum.MultiSelect || model.SurveyType == SurveyTypeEnum.TheRadio)
{
if (model.SurveyOptionsList == null || !model.SurveyOptionsList.Any())
{
return ApiResult.Failed("请填写选项!");
}
else
{
model.SurveyOptionsList.ForEach(x => x.State = Common.Enum.DateStateEnum.Normal);
}
}
if (model.ID == 0)
{
model.RB_Branch_Id = userInfo.School_Id;
model.RB_Group_Id = userInfo.Group_Id;
model.CreateBy = userInfo.Id;
model.CreateDate = DateTime.Now;
}
model.UpdateBy = userInfo.Id;
model.UpdateDate = DateTime.Now;
model.State = Common.Enum.DateStateEnum.Normal;
bool flag = module.SetSurvey(model);
if (flag)
return ApiResult.Success();
else
return ApiResult.Failed("请求失败!");
}
/// <summary>
/// 获取调查类型枚举列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public virtual ApiResult GetSurveyTypeEnumList()
{
var list = EnumHelper.EnumToList(typeof(SurveyTypeEnum));
return ApiResult.Success("", list);
}
#endregion
#region 学生填写的意见调查信息 后台
/// <summary>
/// 通过id获取信息
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public virtual ApiResult GetGuestSurvey()
{
int SurveyID = base.ParmJObj.GetInt("SurveyID");
Rb_Education_StudentSurvey_ViewModel model = module.GetGuestSurveyEntity(SurveyID).RefMapperTo<Rb_Education_StudentSurvey_ViewModel>();
if (model != null)
{
model.SurveyOptionsList = new List<Model.Entity.Survey.Rb_Education_StudentSurveyDetails>();
model.SurveyOptionsList = module.GetGuestSurveyDetailsList(new Rb_Education_StudentSurveyDetails { StudentSurveyId = SurveyID });
//调查问卷信息
var surverList = module.GetSurveyList(string.Join(",", model.SurveyOptionsList.Select(x => x.SurveyId)));
var surveyOptionsList = module.GetList(string.Join(",", model.SurveyOptionsList.Select(x => x.SurveyId)));
foreach (var item in surverList)
{
item.SurveyOptionsList = new List<Rb_Education_SurveyOptions_ViewModel>();
item.SurveyOptionsList = surveyOptionsList.Where(x => x.SurveyID == item.ID).OrderBy(x => x.Sort).ToList();
item.CheckInfo = new List<int>();
if (item.SurveyType == SurveyTypeEnum.MultiSelect || item.SurveyType == SurveyTypeEnum.TheRadio)
{
foreach (var surveyOptionsItem in item.SurveyOptionsList)
{
var surverOptionsIds = model.SurveyOptionsList.FirstOrDefault(x => x.SurveyId == item.ID);
if (surverOptionsIds != null && !string.IsNullOrWhiteSpace(surverOptionsIds.SurveyOptionIds))
{
foreach (var OptionId in surverOptionsIds.SurveyOptionIds.Split(','))
{
if (OptionId == surveyOptionsItem.ID.ToString())
{
if (item.SurveyType == SurveyTypeEnum.MultiSelect)
{
item.CheckInfo.Add(surveyOptionsItem.ID);
item.ScoreNum = 0;
//surveyOptionsItem.IsCheck = "1";
}
else if (item.SurveyType == SurveyTypeEnum.TheRadio)
{
item.ScoreNum = surveyOptionsItem.ID;
}
}
}
}
item.TextContent = "";
}
}
else if (item.SurveyType == SurveyTypeEnum.Score)
{
var surverOptionsIds = model.SurveyOptionsList.FirstOrDefault(x => x.SurveyId == item.ID);
item.ScoreNum = surverOptionsIds.ScoreNum;
item.TextContent = "";
}
else
{
var surverOptionsIds = model.SurveyOptionsList.FirstOrDefault(x => x.SurveyId == item.ID);
item.TextContent = surverOptionsIds.TextContent;
item.ScoreNum = 0;
}
}
return ApiResult.Success("请求成功!", surverList);
}
return ApiResult.Failed("未找到调查信息!");
}
/// <summary>
/// 意见调查分页列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public ApiResult GetStudentSurveyPage()
{
UserInfo userInfo = base.UserInfo;
ResultPageModel pmodel = JsonConvert.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
Rb_Education_StudentSurvey_ViewModel model = new Rb_Education_StudentSurvey_ViewModel()
{
TeacherId = base.ParmJObj.GetInt("TeacherId"),
StudentId = base.ParmJObj.GetInt("StudentId")
};
var data = module.GetTravelSurveyPageModule(pmodel.PageIndex, pmodel.PageSize, out long count, model);
List<object> dataList = new List<object>();
foreach (var item in data)
{
dataList.Add(new
{
CreateDate = item.CreateDate.HasValue ? item.CreateDate.Value.ToString("yyyy-MM-dd") : "",
TeacherName = item?.TeacherName ?? "",
StudentName = item?.StudentName ?? "",
ScoreNum = item?.ScoreNum ?? 0,
ScoreCount = item?.ScoreCount ?? 0,
ID = item?.ID ?? 0,
});
}
pmodel.Count = int.Parse(count.ToString());
pmodel.PageData = dataList;
return ApiResult.Success("", pmodel);
}
#endregion
#region 生成二维码分享给学生填写意见调查信息
/// <summary>
/// WebApi返回图片
/// </summary>
[HttpPost]
[HttpGet]
public ApiResult GetQrCodeImage()
{
UserInfo userInfo = base.UserInfo;
string pUrl = base.ParmJObj.GetStringValue("pUrl");
int StudentId = base.ParmJObj.GetInt("StudentId");
string stuName = base.ParmJObj.GetStringValue("StuName");
//注意签到js需要添加对应参数(plug/index.js使用到 clientConfirm地方)
string newStr = pUrl + "?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;
return ApiResult.Success("", Common.Plugin.QRCodeHelper.GetQrCode(nUrl));
}
#endregion
#region 学生填写意见调查信息 前端
/// <summary>
/// 获取游客调查问题列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[HttpGet]
[AllowAnonymous]
public ApiResult GetSurveyShowList()
{
Rb_Education_Survey_ViewModel model = new Rb_Education_Survey_ViewModel
{
RB_Group_Id = base.ParmJObj.GetInt("RB_Group_Id", 0),
IsShow = 1,
};
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();
return ApiResult.Success("", obj);
}
/// <summary>
/// 新增旅客意见调查信息
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[HttpGet]
[AllowAnonymous]
public ApiResult SetEducationSurvey()
{
List<Rb_Education_Survey_ViewModel> modelSurvey = new List<Rb_Education_Survey_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);
if (model.TeacherId == 0)
{
return ApiResult.ParamIsNull("请选择老师");
}
//if (model.StudentId == 0)
//{
// return ApiResult.ParamIsNull();
//}
string surveyListStr = base.ParmJObj.GetStringValue("SurveyList");
if (!string.IsNullOrWhiteSpace(surveyListStr))
{
JArray surveyListArray = JArray.Parse(surveyListStr);
if (surveyListArray != null && surveyListArray.Count > 0)
{
foreach (var jItem in surveyListArray)
{
JObject jobj = JObject.Parse(JsonHelper.Serialize(jItem));
var surveyModel = new Rb_Education_Survey_ViewModel();
surveyModel.ID = jobj.GetInt("ID", 0);
surveyModel.Title = jobj.GetStringValue("Title");
surveyModel.TextContent = jobj.GetStringValue("TextContent");
surveyModel.ScoreNum = jobj.GetInt("ScoreNum", 0);
surveyModel.SurveyType = (SurveyTypeEnum)jobj.GetInt("SurveyType");
surveyModel.Sort = jobj.GetInt("Sort", 0);
surveyModel.IsShow = jobj.GetInt("IsShow");
surveyModel.SurveyOptionsList = new List<Rb_Education_SurveyOptions_ViewModel>();
var checkInfoStr = jobj.GetStringValue("CheckInfo");
surveyModel.CheckInfo = new List<int>();
if (!string.IsNullOrWhiteSpace(checkInfoStr))
{
surveyModel.CheckInfo = JsonHelper.DeserializeObject<List<int>>(checkInfoStr);
}
modelSurvey.Add(surveyModel);
}
}
}
model.CreateDate = System.DateTime.Now;
model.ID = 0;
model.State = DateStateEnum.Normal;
var scoreList = modelSurvey.Where(x => x.SurveyType == SurveyTypeEnum.Score);
if (scoreList != null && scoreList.Any())
{
model.ScoreNum = Convert.ToDecimal(scoreList.Sum(x => x.ScoreNum)) / Convert.ToDecimal(scoreList.Count());
}
else
{
model.ScoreNum = 0;
}
model.SurveyOptionsList = new List<Rb_Education_StudentSurveyDetails>();
foreach (var item in modelSurvey)
{
Rb_Education_StudentSurveyDetails modelSurveyOptions = new Rb_Education_StudentSurveyDetails
{
ID = 0,
SurveyId = item.ID
};
if (item.SurveyType == SurveyTypeEnum.MultiSelect)
{
modelSurveyOptions.ScoreNum = 0;
//if (item.CheckInfo == null || !item.CheckInfo.Any())
//{
// return ApiResult.Failed(item.Title + "您还未选择");
//}
modelSurveyOptions.SurveyOptionIds = string.Join(",", item.CheckInfo.Select(x => x));
}
else if (item.SurveyType == SurveyTypeEnum.Score)
{
//if (item.ScoreNum == 0)
//{
// return ApiResult.Failed(item.Title + "您还未打分");
//}
modelSurveyOptions.ScoreNum = item.ScoreNum;
}
else if (item.SurveyType == SurveyTypeEnum.TheRadio)
{
//if (item.ScoreNum == 0)
//{
// return ApiResult.Failed(item.Title + "您还未选择");
//}
modelSurveyOptions.SurveyOptionIds = item.ScoreNum.ToString();
modelSurveyOptions.ScoreNum = 0;
}
else
{
modelSurveyOptions.TextContent = item.TextContent;
modelSurveyOptions.ScoreNum = 0;
}
model.SurveyOptionsList.Add(modelSurveyOptions);
}
int flag = module.SetStudentSurvey(model);
if (flag > 0)
{
return ApiResult.Success();
}
else
return ApiResult.Failed("请求失败!");
}
#endregion
}
}
......@@ -430,6 +430,25 @@ namespace Edu.WebApi.Controllers.User
return ApiResult.Success(data: list);
}
/// <summary>
/// 获取讲师列表2024-07-02 add by:w 学生问卷调查老师信息
/// </summary>
/// <returns></returns>
[HttpPost]
[HttpGet]
[AllowAnonymous]
public ApiResult GetTeacherListByGroupId()
{
var query = new RB_Teacher_ViewModel()
{
Group_Id = base.ParmJObj.GetInt("RB_Group_Id")
};
var list = teacherModule.GetTeacherListModule(query);
return ApiResult.Success(data: list);
}
/// <summary>
/// 添加修改讲师
/// </summary>
......
......@@ -30,6 +30,7 @@
"ViewFileSiteUrl": "https://viitto-1301420277.cos.ap-chengdu.myqcloud.com",
"ErpViewFileSiteUrl": "http://imgfile.oytour.com",
"ErpUrl": "http://localhost:8181/#",
"EducationUrl": "http://localhost:8181/",
"WorkAPPDomain": "http://m.kookaku.com/pages",
"Mongo": "mongodb://47.96.23.199:27017",
"MongoDBName": "Edu",
......
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