Commit df9ea776 authored by 罗超's avatar 罗超

调整章节内容

parent 8d8aee29
...@@ -17,6 +17,8 @@ namespace Edu.Common.Plugin ...@@ -17,6 +17,8 @@ namespace Edu.Common.Plugin
/// </summary> /// </summary>
public class WordHelper public class WordHelper
{ {
/// <summary> /// <summary>
/// Spire.Doc解析Word /// Spire.Doc解析Word
/// </summary> /// </summary>
......
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace Edu.Common.Plugin
{
public class WordToNumHelper
{
/// <summary>
/// 阿拉伯数字转换成中文数字
/// </summary>
/// <param name="x"></param>
/// <returns></returns>
public string NumToChinese(string x)
{
string[] pArrayNum = { "零", "一", "二", "三", "四", "五", "六", "七", "八", "九" };
//为数字位数建立一个位数组
string[] pArrayDigit = { "", "十", "百", "千" };
//为数字单位建立一个单位数组
string[] pArrayUnits = { "", "万", "亿", "万亿" };
var pStrReturnValue = ""; //返回值
var finger = 0; //字符位置指针
var pIntM = x.Length % 4; //取模
int pIntK;
if (pIntM > 0)
pIntK = x.Length / 4 + 1;
else
pIntK = x.Length / 4;
//外层循环,四位一组,每组最后加上单位: ",万亿,",",亿,",",万,"
for (var i = pIntK; i > 0; i--)
{
var pIntL = 4;
if (i == pIntK && pIntM != 0)
pIntL = pIntM;
//得到一组四位数
var four = x.Substring(finger, pIntL);
var P_int_l = four.Length;
//内层循环在该组中的每一位数上循环
for (int j = 0; j < P_int_l; j++)
{
//处理组中的每一位数加上所在的位
int n = Convert.ToInt32(four.Substring(j, 1));
if (n == 0)
{
if (j < P_int_l - 1 && Convert.ToInt32(four.Substring(j + 1, 1)) > 0 && !pStrReturnValue.EndsWith(pArrayNum[n]))
pStrReturnValue += pArrayNum[n];
}
else
{
if (!(n == 1 && (pStrReturnValue.EndsWith(pArrayNum[0]) | pStrReturnValue.Length == 0) && j == P_int_l - 2))
pStrReturnValue += pArrayNum[n];
pStrReturnValue += pArrayDigit[P_int_l - j - 1];
}
}
finger += pIntL;
//每组最后加上一个单位:",万,",",亿," 等
if (i < pIntK) //如果不是最高位的一组
{
if (Convert.ToInt32(four) != 0)
//如果所有4位不全是0则加上单位",万,",",亿,"等
pStrReturnValue += pArrayUnits[i - 1];
}
else
{
//处理最高位的一组,最后必须加上单位
pStrReturnValue += pArrayUnits[i - 1];
}
}
return pStrReturnValue;
}
/// <summary>
/// 将中文数字替换为阿拉伯数字
/// </summary>
/// <param name="word"></param>
/// <returns></returns>
public static string WordToNumber(string word)
{
string e = "([零一二三四五六七八九十百千万亿])+";
MatchCollection mc = Regex.Matches(word, e);
foreach(Match m in mc)
{
word = word.Replace(m.Value, Word2Number(m.Value));
}
return word;
}
private static string Word2Number(string w)
{
if (w == "")
return w;
string e = "零一二三四五六七八九";
string[] ew = new string[] { "十", "百", "千" };
string ewJoin = "十百千";
string[] ej = new string[] { "万", "亿" };
string rss = "^([" + e + ewJoin + "]+" + ej[1] + ")?([" + e
+ ewJoin + "]+" + ej[0] + ")?([" + e + ewJoin + "]+)?$";
string[] mcollect = Regex.Split(w, rss);
if (mcollect.Length < 4)
return w;
return (
Convert.ToInt64(foh(mcollect[1])) * 100000000 +
Convert.ToInt64(foh(mcollect[2])) * 10000 +
Convert.ToInt64(foh(mcollect[3]))
).ToString();
}
private static int foh(string str)
{
string e = "零一二三四五六七八九";
string[] ew = new string[] { "十", "百", "千" };
string[] ej = new string[] { "万", "亿" };
int a = 0;
if (str.IndexOf(ew[0]) == 0)
a = 10;
str = Regex.Replace(str, e[0].ToString(), "");
if (Regex.IsMatch(str, "([" + e + "])$"))
{
a += e.IndexOf(Regex.Match(str, "([" + e + "])$").Value[0]);
}
if (Regex.IsMatch(str, "([" + e + "])" + ew[0]))
{
a += e.IndexOf(Regex.Match(str, "([" + e + "])" + ew[0]).Value[0]) * 10;
}
if (Regex.IsMatch(str, "([" + e + "])" + ew[1]))
{
a += e.IndexOf(Regex.Match(str, "([" + e + "])" + ew[1]).Value[0]) * 100;
}
if (Regex.IsMatch(str, "([" + e + "])" + ew[2]))
{
a += e.IndexOf(Regex.Match(str, "([" + e + "])" + ew[2]).Value[0]) * 1000;
}
return a;
}
}
}
...@@ -105,12 +105,12 @@ namespace Edu.Model.Entity.Course ...@@ -105,12 +105,12 @@ namespace Edu.Model.Entity.Course
/// <summary> /// <summary>
/// 学习课时 /// 学习课时
/// </summary> /// </summary>
public int StudyHours { get; set; } public double StudyHours { get; set; }
/// <summary> /// <summary>
/// 学习分钟 /// 学习分钟
/// </summary> /// </summary>
public int StudyMinutes { get; set; } public double StudyMinutes { get; set; }
/// <summary> /// <summary>
/// 教学重点 /// 教学重点
...@@ -130,6 +130,6 @@ namespace Edu.Model.Entity.Course ...@@ -130,6 +130,6 @@ namespace Edu.Model.Entity.Course
/// <summary> /// <summary>
/// 当前课时(累加计算) /// 当前课时(累加计算)
/// </summary> /// </summary>
public int CurrentHours { get; set; } public double CurrentHours { get; set; }
} }
} }
...@@ -55,12 +55,12 @@ namespace Edu.Model.ViewModel.Course ...@@ -55,12 +55,12 @@ namespace Edu.Model.ViewModel.Course
/// <summary> /// <summary>
/// 学习课时 /// 学习课时
/// </summary> /// </summary>
public int StudyHours { get; set; } public double StudyHours { get; set; }
/// <summary> /// <summary>
/// 学习分钟 /// 学习分钟
/// </summary> /// </summary>
public int StudyMinutes { get; set; } public double StudyMinutes { get; set; }
/// <summary> /// <summary>
/// 教学重点 /// 教学重点
...@@ -85,6 +85,7 @@ namespace Edu.Model.ViewModel.Course ...@@ -85,6 +85,7 @@ namespace Edu.Model.ViewModel.Course
/// <summary> /// <summary>
/// 当前课时(累加计算) /// 当前课时(累加计算)
/// </summary> /// </summary>
public int CurrentHours { get; set; } public double CurrentHours { get; set; }
}
}
} }
...@@ -78,6 +78,10 @@ namespace Edu.Model.ViewModel.Course ...@@ -78,6 +78,10 @@ namespace Edu.Model.ViewModel.Course
/// </summary> /// </summary>
public List<RB_Class_LessonPlan_ViewModel> LessonPlanList { get; set; } public List<RB_Class_LessonPlan_ViewModel> LessonPlanList { get; set; }
public RB_Course_Chapter_ViewModel Chapter { get; set; }
public string CourseName { get; set; }
#region 展示无逻辑 #region 展示无逻辑
/// <summary> /// <summary>
......
...@@ -17,5 +17,19 @@ namespace Edu.Model.ViewModel.Course ...@@ -17,5 +17,19 @@ namespace Edu.Model.ViewModel.Course
/// 序列号 /// 序列号
/// </summary> /// </summary>
public int SerialNumber { get; set; } public int SerialNumber { get; set; }
/// <summary>
/// 当前单元最大序号
/// </summary>
public int MaxLength { get; set; }
/// <summary>
/// 新的课程编号
/// </summary>
public int NewCourseId { get; set; }
public string CourseName { get; set; }
} }
} }
...@@ -140,5 +140,16 @@ namespace Edu.Model.ViewModel.Course ...@@ -140,5 +140,16 @@ namespace Edu.Model.ViewModel.Course
/// 随机条数 /// 随机条数
/// </summary> /// </summary>
public int RandNum { get; set; } public int RandNum { get; set; }
/// <summary>
/// 单元数量
/// </summary>
public int UnitCount { get; set; }
/// <summary>
/// 章节数量
/// </summary>
public int ChapterCount { get; set; }
} }
} }
\ No newline at end of file
...@@ -2687,10 +2687,20 @@ namespace Edu.Module.Course ...@@ -2687,10 +2687,20 @@ namespace Edu.Module.Course
} }
/// <summary> /// <summary>
/// 更新历史班号 /// 查询指定计划的上课课时
/// </summary> /// </summary>
/// <param name="planId"></param>
/// <returns></returns> /// <returns></returns>
public bool UpdateHistoryClassNo() public double GetCurrentPlanStudyHoursRepository(int planId)
{
return class_PlanRepository.GetCurrentPlanStudyHoursRepository(planId);
}
/// <summary>
/// 更新历史班号
/// </summary>
/// <returns></returns>
public bool UpdateHistoryClassNo()
{ {
var list = classRepository.GetClassListRepository(new RB_Class_ViewModel() { Group_Id = 100000 }); var list = classRepository.GetClassListRepository(new RB_Class_ViewModel() { Group_Id = 100000 });
list = list.OrderBy(x => x.OpenTime).ThenBy(x => x.ClassId).ToList(); list = list.OrderBy(x => x.OpenTime).ThenBy(x => x.ClassId).ToList();
......
...@@ -7,8 +7,10 @@ using Edu.Model.ViewModel.User; ...@@ -7,8 +7,10 @@ using Edu.Model.ViewModel.User;
using Edu.Repository.Course; using Edu.Repository.Course;
using Edu.Repository.Question; using Edu.Repository.Question;
using Edu.Repository.User; using Edu.Repository.User;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions;
using VT.FW.DB; using VT.FW.DB;
namespace Edu.Module.Course namespace Edu.Module.Course
...@@ -105,6 +107,11 @@ namespace Edu.Module.Course ...@@ -105,6 +107,11 @@ namespace Edu.Module.Course
#region 课程管理 #region 课程管理
public List<RB_Course_ViewModel> GetAllCourseChapterCountModule(int groupId,int courseId)
{
return courseRepository.GetCourseAllChapterCount(groupId, courseId) ??new List<RB_Course_ViewModel>();
}
/// <summary> /// <summary>
/// 获取课程列表 /// 获取课程列表
/// </summary> /// </summary>
...@@ -463,6 +470,88 @@ namespace Edu.Module.Course ...@@ -463,6 +470,88 @@ namespace Edu.Module.Course
return chapterRepository.GetChapterListRepository(query); return chapterRepository.GetChapterListRepository(query);
} }
public List<ChapterTree_ViewModel> SetImportChapterModule(RB_Course_Chapter_ViewModel query)
{
var result = GetChapterTreeListModule(query);
int maxLength = query.MaxLength;
string[] ids = query.CourseIds.Split(',', System.StringSplitOptions.RemoveEmptyEntries);
foreach (var item in ids)
{
var temp = result.Where(x => x.CourseId.ToString().Equals(item)).ToList();
var array = new List<ChapterTree_ViewModel>();
temp.ForEach(x => {
maxLength++;
x.ChapterNo = maxLength.ToString();
x.ChapterName = FormatNum(x.ChapterName, maxLength);
int pid = GenernalNewChapterNode(x, query);
x.ChapterId = pid;
x.ChildList = x.ChildList != null && x.ChildList.Count > 0 ? ReChangeChapterNo(x.ChildList, maxLength,pid,query) : new List<ChapterTree_ViewModel>();
});
}
SetBatchAllChapterCurrentHoursModule(query.NewCourseId);
return result;
}
public List<ChapterTree_ViewModel> ReChangeChapterNo(List<ChapterTree_ViewModel> list,int parentNo,int parentId, RB_Course_Chapter_ViewModel query)
{
list.ForEach(x =>
{
var oldNo = x.ChapterNo.Split('.');
oldNo[0] = parentNo.ToString();
x.ChapterNo = string.Join(".", oldNo);
x.ChapterName = FormatNum(x.ChapterName, parentNo);
x.ParentId = parentId;
int pid = GenernalNewChapterNode(x, query);
x.ChapterId = pid;
x.ChildList = ReChangeChapterNo(x.ChildList, parentNo, pid, query);
});
return list;
}
public int GenernalNewChapterNode(ChapterTree_ViewModel model, RB_Course_Chapter_ViewModel query)
{
RB_Course_Chapter_ViewModel newModel = new RB_Course_Chapter_ViewModel() {
ChapterContent=model.ChapterContent,
ChapterId=0,
ChapterName=model.ChapterName,
ChapterNo=model.ChapterNo,
CourseId= query.NewCourseId,
CourseRate=model.CourseRate,
CreateBy= query.CreateBy,
CreateTime=DateTime.Now,
CurrentHours=model.CurrentHours,
Group_Id=query.Group_Id,
Objectives=model.Objectives,
OpenStatus=model.OpenStatus,
ParentId=model.ParentId,
Requirement=model.Requirement,
School_Id=query.School_Id,
Status=DateStateEnum.Normal,
StudyHours=model.StudyHours,
StudyMinutes=model.StudyMinutes
};
SetChapterModule(newModel);
return newModel.ChapterId;
}
/// <summary>
/// 重新生成单元标题序号
/// </summary>
/// <returns></returns>
public string FormatNum(string name,int length)
{
Regex regex = new Regex(@"(?<=第)(.*?)(?=单|次|课|章|节)");
string temp = regex.Match(name).Value;
if (!string.IsNullOrEmpty(temp))
{
var newTemp = new WordToNumHelper().NumToChinese(length.ToString());
name = name.Replace(temp,newTemp);
}
return name;
}
/// <summary> /// <summary>
/// 获取课程章节树形列表 /// 获取课程章节树形列表
/// </summary> /// </summary>
...@@ -471,10 +560,19 @@ namespace Edu.Module.Course ...@@ -471,10 +560,19 @@ namespace Edu.Module.Course
public List<ChapterTree_ViewModel> GetChapterTreeListModule(RB_Course_Chapter_ViewModel query) public List<ChapterTree_ViewModel> GetChapterTreeListModule(RB_Course_Chapter_ViewModel query)
{ {
var list = GetChapterListModule(query); var list = GetChapterListModule(query);
list.ForEach(x =>
{
x.SerialNumber = int.Parse(x.ChapterNo.Replace(".", ""));
});
List<ChapterTree_ViewModel> treeList = GetChapterChild(list, 0); List<ChapterTree_ViewModel> treeList = GetChapterChild(list, 0);
return treeList; return treeList;
} }
public RB_Course_Chapter_ViewModel GetMatchHoursChapterModule(int courseId,double currentHours)
{
return chapterRepository.GetMatchHoursChapterRepository(courseId,currentHours);
}
/// <summary> /// <summary>
/// 递归遍历所有章节 /// 递归遍历所有章节
/// </summary> /// </summary>
...@@ -485,12 +583,12 @@ namespace Edu.Module.Course ...@@ -485,12 +583,12 @@ namespace Edu.Module.Course
{ {
List<ChapterTree_ViewModel> resultList = new List<ChapterTree_ViewModel>(); List<ChapterTree_ViewModel> resultList = new List<ChapterTree_ViewModel>();
//获取下级节点 //获取下级节点
var subList = sourceList?.Where(qItem => qItem.ParentId == parentId).OrderBy(qitem =>qitem.SortNum).ToList(); var subList = sourceList?.Where(qItem => qItem.ParentId == parentId).OrderBy(qitem =>qitem.SerialNumber).ToList();
//如果存在下级节点 //如果存在下级节点
if (subList != null && subList.Count > 0) if (subList != null && subList.Count > 0)
{ {
foreach (var childItem in subList) foreach (var childItem in subList)
{ {
var childModel = new ChapterTree_ViewModel() var childModel = new ChapterTree_ViewModel()
{ {
ChapterId = childItem.ChapterId, ChapterId = childItem.ChapterId,
...@@ -517,6 +615,70 @@ namespace Edu.Module.Course ...@@ -517,6 +615,70 @@ namespace Edu.Module.Course
return resultList; return resultList;
} }
public bool SetBatchAllChapterCurrentHoursModule(int courseId)
{
RB_Course_Chapter_ViewModel query = new RB_Course_Chapter_ViewModel()
{
CourseId = courseId
};
var result = GetChapterTreeListModule(query);
List<RB_Course_Chapter_ViewModel> list = new List<RB_Course_Chapter_ViewModel>();
var currentHours = 0.00;
result.ForEach(x => {
if (x.ChildList != null && x.ChildList.Count > 0)
{
list.Add(new RB_Course_Chapter_ViewModel()
{
ChapterId = x.ChapterId,
CurrentHours = -1.00
});
x.ChildList.ForEach(y =>
{
if (y.StudyHours > 0)
{
list.Add(new RB_Course_Chapter_ViewModel()
{
ChapterId = y.ChapterId,
CurrentHours = currentHours
});
currentHours += y.StudyHours;
}
else
{
list.Add(new RB_Course_Chapter_ViewModel()
{
ChapterId = y.ChapterId,
CurrentHours = -1.00
});
}
});
}
else
{
if (x.StudyHours > 0)
{
list.Add(new RB_Course_Chapter_ViewModel()
{
ChapterId = x.ChapterId,
CurrentHours = currentHours
});
currentHours += x.StudyHours;
}
else
{
list.Add(new RB_Course_Chapter_ViewModel()
{
ChapterId = x.ChapterId,
CurrentHours = -1
});
}
}
});
return chapterRepository.SetBatchCurrentHoursRepository(list);
}
/// <summary> /// <summary>
/// 新增修改课程章节 /// 新增修改课程章节
/// </summary> /// </summary>
...@@ -526,7 +688,7 @@ namespace Edu.Module.Course ...@@ -526,7 +688,7 @@ namespace Edu.Module.Course
bool flag; bool flag;
if (model.StudyMinutes > 0) if (model.StudyMinutes > 0)
{ {
model.StudyHours = model.StudyMinutes / class_ConfigRepository.GetBasicMinutesRepository(model.Group_Id); model.StudyHours = model.StudyMinutes / Convert.ToDouble(class_ConfigRepository.GetBasicMinutesRepository(model.Group_Id));
} }
if (model.ChapterId > 0) if (model.ChapterId > 0)
{ {
...@@ -550,6 +712,7 @@ namespace Edu.Module.Course ...@@ -550,6 +712,7 @@ namespace Edu.Module.Course
model.ChapterId = newId; model.ChapterId = newId;
flag = newId > 0; flag = newId > 0;
} }
SetBatchAllChapterCurrentHoursModule(model.CourseId);
return flag; return flag;
} }
...@@ -639,7 +802,10 @@ namespace Edu.Module.Course ...@@ -639,7 +802,10 @@ namespace Edu.Module.Course
/// <returns></returns> /// <returns></returns>
public bool BatchRemoveChapterModule(RB_Course_Chapter_ViewModel model) public bool BatchRemoveChapterModule(RB_Course_Chapter_ViewModel model)
{ {
return chapterRepository.DeleteBatchChpterRepository(model); var flag = chapterRepository.DeleteBatchChpterRepository(model);
SetBatchAllChapterCurrentHoursModule(model.CourseId);
return flag;
} }
/// <summary> /// <summary>
...@@ -690,8 +856,11 @@ namespace Edu.Module.Course ...@@ -690,8 +856,11 @@ namespace Edu.Module.Course
/// <param name="chapters"></param> /// <param name="chapters"></param>
/// <returns></returns> /// <returns></returns>
public bool SetBatchChapterNoModule(List<RB_Course_Chapter_ViewModel> chapters) public bool SetBatchChapterNoModule(List<RB_Course_Chapter_ViewModel> chapters)
{ {
return chapterRepository.SetBatchUpdateChapterNoRepository(chapters); var flag = chapterRepository.SetBatchUpdateChapterNoRepository(chapters);
//SetBatchAllChapterCurrentHoursModule(chapters[0].CourseId);
return flag;
} }
/// <summary> /// <summary>
......
...@@ -535,5 +535,24 @@ GROUP BY A.ClassPlanId,A.ClassId ,A.ClassDate,A.ClassRoomId,A.CompleteProgress ...@@ -535,5 +535,24 @@ GROUP BY A.ClassPlanId,A.ClassId ,A.ClassDate,A.ClassRoomId,A.CompleteProgress
", where.ToString()); ", where.ToString());
return Get<RB_Class_Plan_ViewModel>(builder.ToString()).ToList(); return Get<RB_Class_Plan_ViewModel>(builder.ToString()).ToList();
} }
/// <summary>
/// 查询指定计划的上课课时
/// </summary>
/// <param name="planId"></param>
/// <returns></returns>
public double GetCurrentPlanStudyHoursRepository(int planId)
{
string sql = @"select
(select SUM(timestampdiff(MINUTE, Concat(SUBSTRING_INDEX(d.ClassDate, ' ', 1), ' ', c.StartTime), Concat(SUBSTRING_INDEX(d.ClassDate, ' ', 1), ' ', c.EndTime))) / 45
from rb_class_time c left
join rb_class_plan d on c.ClassPlanId = d.ClassPlanId
where d.ClassDate < b.ClassDate and c.ClassId = b.ClassId)
from rb_class_plan b where b.ClassPlanId = "+planId+" and b.`Status`= 0";
object obj = ExecuteScalar(sql);
return Convert.IsDBNull(obj)?-1:Convert.ToDouble(obj);
}
} }
} }
\ No newline at end of file
...@@ -53,6 +53,7 @@ WHERE 1=1 ...@@ -53,6 +53,7 @@ WHERE 1=1
if (!string.IsNullOrEmpty(query.Saleplat)) if (!string.IsNullOrEmpty(query.Saleplat))
{ {
var salePlatList = Common.ConvertHelper.StringToList(query.Saleplat); var salePlatList = Common.ConvertHelper.StringToList(query.Saleplat);
string str = ""; string str = "";
if (salePlatList != null && salePlatList.Count > 0) if (salePlatList != null && salePlatList.Count > 0)
{ {
...@@ -143,5 +144,17 @@ WHERE 1=1 ...@@ -143,5 +144,17 @@ WHERE 1=1
} }
return GetPage<RB_Course_ViewModel>(pageIndex, pageSize, out rowsCount, builder.ToString(), parameters).ToList(); return GetPage<RB_Course_ViewModel>(pageIndex, pageSize, out rowsCount, builder.ToString(), parameters).ToList();
} }
/// <summary>
/// 查询所有正常课程的章节信息
/// </summary>
/// <returns></returns>
public List<RB_Course_ViewModel> GetCourseAllChapterCount(int groupId,int courseId)
{
StringBuilder sql = new StringBuilder("select CourseId,CourseName,(select Count(0) from rb_course_chapter b where b.CourseId=a.CourseId and ParentId=0 and b.`Status`=0) as UnitCount,(select Count(0) from rb_course_chapter b where b.CourseId=a.CourseId and ParentId>0 and b.`Status`=0) as ChapterCount from rb_course a where Status=0");
sql.AppendFormat(" AND a.{0}={1} ", nameof(RB_Course_ViewModel.Group_Id), groupId);
sql.AppendFormat(" AND a.{0}<>{1} ", nameof(RB_Course_ViewModel.CourseId), courseId);
return Get<RB_Course_ViewModel>(sql.ToString()).ToList();
}
} }
} }
...@@ -44,7 +44,7 @@ namespace Edu.Repository.Course ...@@ -44,7 +44,7 @@ namespace Edu.Repository.Course
builder.AppendFormat(" AND {0} IN({1}) ", nameof(RB_Course_Chapter_ViewModel.CourseId), query.CourseIds); builder.AppendFormat(" AND {0} IN({1}) ", nameof(RB_Course_Chapter_ViewModel.CourseId), query.CourseIds);
} }
} }
builder.AppendFormat(" ORDER BY {0} ",nameof(RB_Course_Chapter_ViewModel.ChapterNo)); //builder.AppendFormat(" ORDER BY {0} ",nameof(RB_Course_Chapter_ViewModel.ChapterNo));
return Get<RB_Course_Chapter_ViewModel>(builder.ToString(), parameters).ToList(); return Get<RB_Course_Chapter_ViewModel>(builder.ToString(), parameters).ToList();
} }
...@@ -67,6 +67,18 @@ namespace Edu.Repository.Course ...@@ -67,6 +67,18 @@ namespace Edu.Repository.Course
return Execute(builder.ToString()) > 0; return Execute(builder.ToString()) > 0;
} }
public bool SetBatchCurrentHoursRepository(List<RB_Course_Chapter_ViewModel> param)
{
StringBuilder builder = new StringBuilder();
builder.Append("INSERT INTO rb_course_chapter (ChapterId, CurrentHours) VALUES");
param.ForEach(x => {
builder.Append($"({x.ChapterId},'{x.CurrentHours}'),");
});
builder = builder.Remove(builder.Length - 1, 1);
builder.Append("ON DUPLICATE KEY UPDATE CurrentHours=VALUES(CurrentHours);");
return Execute(builder.ToString()) > 0;
}
/// <summary> /// <summary>
/// 批量更新课程等级 /// 批量更新课程等级
/// </summary> /// </summary>
...@@ -98,5 +110,27 @@ namespace Edu.Repository.Course ...@@ -98,5 +110,27 @@ namespace Edu.Repository.Course
return Execute(builder.ToString()) > 0; return Execute(builder.ToString()) > 0;
} }
/// <summary>
/// 查询符合的课程章节
/// </summary>
/// <param name="courseId"></param>
/// <param name="currentHours"></param>
/// <returns></returns>
public RB_Course_Chapter_ViewModel GetMatchHoursChapterRepository(int courseId, double currentHours)
{
var parameters = new DynamicParameters();
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT *
FROM rb_course_chapter
WHERE 1=1
");
builder.AppendFormat(" AND {0}={1}", nameof(RB_Course_Chapter_ViewModel.Status), EnumHelper.ToInt(DateStateEnum.Normal));
builder.AppendFormat(" AND {0}={1}", nameof(RB_Course_Chapter_ViewModel.CourseId), courseId);
builder.AppendFormat(" AND {0}<={1}", nameof(RB_Course_Chapter_ViewModel.CurrentHours), currentHours);
builder.AppendFormat(" ORDER BY {0} Desc",nameof(RB_Course_Chapter_ViewModel.CurrentHours));
return Get<RB_Course_Chapter_ViewModel>(builder.ToString(), parameters).ToList().FirstOrDefault();
}
} }
} }
...@@ -1400,6 +1400,26 @@ namespace Edu.WebApi.Controllers.Course ...@@ -1400,6 +1400,26 @@ namespace Edu.WebApi.Controllers.Course
new RB_Class_LessonPlan_ViewModel { CourseName = "理解篇", LessonPlanDetailsList = new List<RB_Class_LessonPlanDetails_ViewModel>(), LessonPlanProjectsList = new List<RB_Class_LessonPlanProjects_ViewModel>() } new RB_Class_LessonPlan_ViewModel { CourseName = "理解篇", LessonPlanDetailsList = new List<RB_Class_LessonPlanDetails_ViewModel>(), LessonPlanProjectsList = new List<RB_Class_LessonPlanProjects_ViewModel>() }
}; };
} }
#region 追加章节信息
var hours = classModule.GetCurrentPlanStudyHoursRepository(model.ClassPlanId);
if (hours != -1)
{
var classObj=classModule.GetClassModule(model.ClassId);
var courseOjb = new CourseModule().GetCourseModule(classObj.CouseId);
var chapter = new CourseModule().GetMatchHoursChapterModule(classObj.CouseId,hours);
if (chapter != null && chapter.ChapterId > 0)
{
chapter.CourseName = courseOjb.CourseName;
model.Chapter = chapter;
}
}
#endregion
return ApiResult.Success("", model); return ApiResult.Success("", model);
} }
......
...@@ -158,6 +158,20 @@ namespace Edu.WebApi.Controllers.Course ...@@ -158,6 +158,20 @@ namespace Edu.WebApi.Controllers.Course
#region 课程管理 #region 课程管理
[HttpPost]
public ApiResult GetAllCourseChapterCount()
{
int groupId = base.UserInfo.Group_Id;
int courseId = base.ParmJObj.GetInt("CourseId", 0);
var list = courseModule.GetAllCourseChapterCountModule(groupId, courseId);
return ApiResult.Success(data: list.Where(x=>x.UnitCount>0).Select(x => new {
x.CourseId,
x.CourseName,
x.UnitCount,
x.ChapterCount
}));
}
/// <summary> /// <summary>
/// 获取课程分页列表 /// 获取课程分页列表
/// </summary> /// </summary>
...@@ -193,6 +207,8 @@ namespace Edu.WebApi.Controllers.Course ...@@ -193,6 +207,8 @@ namespace Edu.WebApi.Controllers.Course
return ApiResult.Success(data: pageModel); return ApiResult.Success(data: pageModel);
} }
/// <summary> /// <summary>
/// 获取课程列表 /// 获取课程列表
/// </summary> /// </summary>
...@@ -413,6 +429,21 @@ namespace Edu.WebApi.Controllers.Course ...@@ -413,6 +429,21 @@ namespace Edu.WebApi.Controllers.Course
#region 课程章节管理 #region 课程章节管理
[HttpPost]
public ApiResult SetImportCourseChapter()
{
var query = Common.Plugin.JsonHelper.DeserializeObject<RB_Course_Chapter_ViewModel>(RequestParm.Msg.ToString());
query.Group_Id = base.UserInfo.Group_Id;
query.School_Id = base.UserInfo.School_Id;
query.CreateBy = base.UserInfo.Id;
var q=courseModule.SetImportChapterModule(query);
if (q!=null && q.Count > 0)
{
return ApiResult.Success();
}
return ApiResult.Failed();
}
/// <summary> /// <summary>
/// 添加修改课程章节 /// 添加修改课程章节
/// </summary> /// </summary>
......
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