Commit 971ee6f4 authored by 黄奎's avatar 黄奎

页面修改

parent 04b0d22a
...@@ -21,6 +21,7 @@ using VT.FW.DB; ...@@ -21,6 +21,7 @@ using VT.FW.DB;
using Edu.Repository.Grade; using Edu.Repository.Grade;
using Edu.Common.Enum.Question; using Edu.Common.Enum.Question;
using System.Threading.Tasks; using System.Threading.Tasks;
using Edu.Model.Entity.Course;
namespace Edu.Module.Course namespace Edu.Module.Course
{ {
...@@ -1068,129 +1069,82 @@ namespace Edu.Module.Course ...@@ -1068,129 +1069,82 @@ namespace Edu.Module.Course
return flag; return flag;
} }
/// <summary> /// <summary>
/// 重新更新课程章节 /// 重新更新课程单词URL
/// </summary> /// </summary>
public void RunCourseChapterModule() public void RunWordsUrlModule(List<RB_Course_Chapter_ViewModel> n5CourseList, List<RB_Course_Chapter_ViewModel> n4CourseList, List<RB_Course_Chapter_ViewModel> n3CourseList)
{ {
var courseList = chapterRepository.GetCourseChapterListExtRepository(); var wordsList = course_WordsRepository.GetCourseWordsListRepository(new RB_Course_Words_Extend() {CourseId=1 });
if (courseList != null && courseList.Count > 0) var n5WordsList = wordsList.Where(qitem => qitem.ChapterId < 43).ToList();
int n5ChapterId = 6;
var tempN5Words = n5WordsList.GroupBy(qitem => new { qitem.ChapterId }).OrderBy(qitem=>qitem.Key.ChapterId).Select(qitem => new { qitem.Key.ChapterId });
foreach (var item in tempN5Words)
{ {
var tempCourseList = courseList.Where(qitem => qitem.CourseId == 58 || qitem.CourseId == 10); var tempList = n5WordsList.Where(qitem => qitem.ChapterId == item.ChapterId).ToList();
foreach (var item in tempCourseList) foreach (var subItem in tempList)
{ {
List<RB_Course_Chapter_ViewModel> result = new List<RB_Course_Chapter_ViewModel>(); subItem.CourseId = n5CourseList.FirstOrDefault().CourseId;
var chapterQuery = new RB_Course_Chapter_ViewModel() { CourseId = item.CourseId }; subItem.ChapterId = n5ChapterId;
var sourceList = GetChapterListModule(chapterQuery,isQueryWords:true); }
var treeList= GetChapterTreeListModule(chapterQuery); n5ChapterId++;
if (treeList != null && treeList.Count>0) }
{
foreach (var tItem in treeList)
{
var rootModel= sourceList.Where(qitem => qitem.ChapterId == tItem.ChapterId).FirstOrDefault();
if (tItem.ChildList == null || (tItem.ChildList != null && tItem.ChildList.Count == 0))
{
var rootModel1 = JsonHelper.DeserializeObject<RB_Course_Chapter_ViewModel>(JsonHelper.Serialize(rootModel));
rootModel1.ChapterName += "(1)";
rootModel1.StudyHours = 2;
rootModel1.StudyMinutes = 90;
result.Add(rootModel1);
var rootModel2 = JsonHelper.DeserializeObject<RB_Course_Chapter_ViewModel>(JsonHelper.Serialize(rootModel));
rootModel2.ChapterName += "(2)";
rootModel2.StudyHours = 2;
rootModel2.StudyMinutes = 90;
rootModel.WordsList = new List<RB_Course_Words_Extend>();
result.Add(rootModel2);
}
else
{
var tempList = new List<RB_Course_Chapter_ViewModel>();
GetCourseChildList(tItem, sourceList,tempList);
if (tempList != null)
{
result.AddRange(tempList);
}
}
}
}
if (result != null && result.Count > 0) if (n5CourseList != null && n5CourseList.Count > 0)
{ {
int index = 1; chapterRepository.SetBatchInsertCourseChapterRepository(n5CourseList);
List<RB_Course_Words_Extend> wordsList = new List<RB_Course_Words_Extend>(); }
foreach (var sItem in result) if (n5WordsList != null && n5WordsList.Count > 0)
{ {
sItem.ChapterId = 0; course_WordsRepository.BatchInsertCourseWordsRepository(n5WordsList);
sItem.SortNum = index; }
sItem.ChapterNo = index.ToString();
string pattern = @"第[一二三四五六七八九十]次课";
string newStr = Regex.Replace(sItem.ChapterName, pattern, "");
string newTitle = string.Format("第{0}次课", new WordToNumHelper().NumToChinese(index.ToString())) + " " + newStr.Trim();
sItem.ChapterName = newTitle;
var n4WordsList = wordsList.Where(qitem => qitem.ChapterId >= 43 && qitem.ChapterId<79).ToList();
var tempN4Words = n4WordsList.GroupBy(qitem => new { qitem.ChapterId }).OrderBy(qitem => qitem.Key.ChapterId).Select(qitem => new { qitem.Key.ChapterId });
int n4ChapterId = 1;
foreach (var item in tempN4Words)
{
var tempList = n4WordsList.Where(qitem => qitem.ChapterId == item.ChapterId).ToList();
foreach (var subItem in tempList)
{
subItem.CourseId = n4CourseList.FirstOrDefault().CourseId;
subItem.ChapterId = n4ChapterId;
}
n4ChapterId++;
}
foreach (var subItem in sItem.WordsList) if (n4CourseList != null && n4CourseList.Count > 0)
{ {
subItem.Id = 0; chapterRepository.SetBatchInsertCourseChapterRepository(n4CourseList);
subItem.ChapterId = index; }
} if (n4WordsList != null && n4WordsList.Count > 0)
if (sItem.WordsList != null && sItem.WordsList.Count > 0) {
{ course_WordsRepository.BatchInsertCourseWordsRepository(n4WordsList);
wordsList.AddRange(sItem.WordsList); }
}
index++; var n3WordsList = wordsList.Where(qitem => qitem.ChapterId >= 79).ToList();
} var tempN3Words = n3WordsList.GroupBy(qitem => new { qitem.ChapterId }).OrderBy(qitem => qitem.Key.ChapterId).Select(qitem => new { qitem.Key.ChapterId });
//chapterRepository.DeleteByCourseIdRepository(item.CourseId); int n3ChapterId = 1;
//course_WordsRepository.DeleteWordsByCourseIdRepository(item.CourseId); foreach (var item in tempN3Words)
{
//chapterRepository.SetBatchInsertCourseChapterRepository(result); var tempList = n3WordsList.Where(qitem => qitem.ChapterId == item.ChapterId).ToList();
//if (wordsList != null && wordsList.Count > 0) foreach (var subItem in tempList)
//{ {
// course_WordsRepository.BatchInsertCourseWordsRepository(wordsList); subItem.CourseId = n3CourseList.FirstOrDefault().CourseId;
//} subItem.ChapterId = n3ChapterId;
}
string str = Common.Plugin.JsonHelper.Serialize(result);
} }
n3ChapterId++;
} }
}
/// <summary> if (n3CourseList != null && n3CourseList.Count > 0)
/// 重新更新课程单词URL
/// </summary>
public void RunWordsUrlModule()
{
var list = course_WordsRepository.GetCourseWordsListRepository(new RB_Course_Words_Extend() { }).Where(qitem => string.IsNullOrEmpty(qitem.FileUrl)).ToList();
string newPath = @"G:\WebFile\EduSystem\CourseWords";
var fileList = Common.Plugin.FileHelper.GetFileList(newPath);
if (list != null && list.Count > 0 && fileList != null && fileList.Count > 0)
{ {
//Task.Run(() => chapterRepository.SetBatchInsertCourseChapterRepository(n3CourseList);
//{ }
Dictionary<string, object> fileds = new Dictionary<string, object>(); if (n3WordsList != null && n3WordsList.Count > 0)
foreach (var item in list.Where(qitem => string.IsNullOrEmpty(qitem.FileUrl))) {
{ course_WordsRepository.BatchInsertCourseWordsRepository(n3WordsList);
if (string.IsNullOrEmpty(item.FileUrl))
{
var tempWords = fileList.Where(qitem => (qitem.FileName.ToLower() ==
item.WordContent.ToLower()
.Replace("(", "(")
.Replace(")", ")")
.Replace("~", "〜")
.Replace("。","")
.Replace(@"\n","") + ".mp3")
)?.FirstOrDefault();
if (tempWords != null)
{
fileds.Clear();
string newFileUrl = @"/EduSystem/CourseWords/" + tempWords.FileName;
fileds.Add(nameof(RB_Course_Words_Extend.FileUrl), newFileUrl);
bool flag = course_WordsRepository.Update(fileds, new WhereHelper(nameof(RB_Course_Words_Extend.Id), item.Id));
}
}
}
//});
} }
string str = "";
} }
/// <summary> /// <summary>
......
...@@ -107,12 +107,12 @@ WHERE 1=1 ...@@ -107,12 +107,12 @@ WHERE 1=1
if (list != null && list.Count > 0) if (list != null && list.Count > 0)
{ {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.AppendFormat(" INSERT INTO RB_Course_Words(CourseId,ChapterId,WordType,WordContent,WordTone,WordWrite,ChineseMean,Status,Group_Id,CreateBy,CreateTime,UpdateBy,UpdateTime) "); builder.AppendFormat(" INSERT INTO RB_Course_Words(CourseId,ChapterId,WordType,WordContent,WordTone,WordWrite,ChineseMean,Status,Group_Id,CreateBy,CreateTime,UpdateBy,UpdateTime,FileUrl) ");
builder.AppendFormat(" VALUES "); builder.AppendFormat(" VALUES ");
string tempStr = ""; string tempStr = "";
foreach (var item in list) foreach (var item in list)
{ {
tempStr += $",({item.CourseId},{item.ChapterId},'{item.WordType}','{item.WordContent}','{item.WordTone}','{item.WordWrite}','{item.ChineseMean}',0,{item.Group_Id},{item.CreateBy},'{item.CreateTime}',{item.UpdateBy},'{item.UpdateTime}') "; tempStr += $",({item.CourseId},{item.ChapterId},'{item.WordType}','{item.WordContent}','{item.WordTone}','{item.WordWrite}','{item.ChineseMean}',0,{item.Group_Id},{item.CreateBy},'{item.CreateTime}',{item.UpdateBy},'{item.UpdateTime}','{item.FileUrl}') ";
} }
builder.Append(tempStr.TrimStart(',')); builder.Append(tempStr.TrimStart(','));
flag = base.Execute(builder.ToString()) > 0; flag = base.Execute(builder.ToString()) > 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