Commit 9e75dc21 authored by liudong1993's avatar liudong1993

Merge branch 'master' of http://gitlab.oytour.com/Kui2/education

parents 37f468dd 57786fad
......@@ -15,12 +15,16 @@ namespace Edu.Common.Data
public static List<WordsItem> GetXlsWordsData(string filePath)
{
List<WordsItem> xlsItems = new List<WordsItem>();
var dt = Common.Plugin.NPOIHelper.ImportExcelToDatatable(filePath, 0, 0, true);
if (dt != null && dt.Rows.Count > 0)
var ds = Common.Plugin.NPOIHelper.ExcelToDataSet(filePath);
if (ds != null && ds.Tables.Count > 0)
{
foreach (DataRow item in dt.Rows)
for (var i = 0; i < ds.Tables.Count; i++)
{
xlsItems.Add(DataRowToModel(item));
var dataRow = ds.Tables[i].Rows;
for (var j = 0; j < ds.Tables[i].Rows.Count; j++)
{
xlsItems.Add(DataRowToModel((i+1),ds.Tables[i].Rows[j]));
}
}
}
return xlsItems;
......@@ -29,21 +33,73 @@ namespace Edu.Common.Data
/// <summary>
/// DataRow转实体
/// </summary>
/// <param name="tableName"></param>
/// <param name="dr"></param>
/// <returns></returns>
private static WordsItem DataRowToModel(DataRow dr)
private static WordsItem DataRowToModel(int ChapterId, DataRow dr)
{
WordsItem model = new WordsItem();
model.ChapterId = ChapterId;
if (dr != null)
{
if (dr.Table.Columns.Contains("品詞名") && !string.IsNullOrEmpty(dr["品詞名"].ToString()))
{
model.WordType = dr["品詞名"].ToString();
}
if (dr.Table.Columns.Contains("語彙・表現") && !string.IsNullOrEmpty(dr["語彙・表現"].ToString()))
{
model.WordContent = dr["語彙・表現"].ToString();
}
if (dr.Table.Columns.Contains("声调") && !string.IsNullOrEmpty(dr["声调"].ToString()))
{
model.WordTone = dr["声调"].ToString();
}
if (dr.Table.Columns.Contains("日文书写") && !string.IsNullOrEmpty(dr["日文书写"].ToString()))
{
model.WordWrite = dr["日文书写"].ToString();
}
if (dr.Table.Columns.Contains("中文意思") && !string.IsNullOrEmpty(dr["中文意思"].ToString()))
{
model.ChineseMean = dr["中文意思"].ToString();
}
}
return model;
}
}
/// <summary>
/// 单词项
/// </summary>
public class WordsItem
{
/// <summary>
/// 章节编号
/// </summary>
public int ChapterId { get; set; }
/// <summary>
/// 单词类型(名词、动词、形容词等)
/// </summary>
public string WordType { get; set; }
/// <summary>
/// 单词内容
/// </summary>
public string WordContent { get; set; }
/// <summary>
/// 单词声调
/// </summary>
public string WordTone { get; set; }
/// <summary>
/// 单词书写
/// </summary>
public string WordWrite { get; set; }
/// <summary>
/// 中文意思
/// </summary>
public string ChineseMean { get; set; }
}
}
......@@ -586,6 +586,45 @@ namespace Edu.Common.Plugin
return table;
}
/// <summary>
/// Excel转DataSet
/// </summary>
/// <param name="excelPath"></param>
/// <returns></returns>
public static DataSet ExcelToDataSet(string excelPath)
{
int sheetCount;
return ExcelToDataSet(excelPath, true, out sheetCount);
}
/// <summary>
/// Excel转DataSet
/// </summary>
/// <param name="excelPath"></param>
/// <param name="firstRowAsHeader"></param>
/// <param name="sheetCount"></param>
/// <returns></returns>
static DataSet ExcelToDataSet(string excelPath, bool firstRowAsHeader, out int sheetCount)
{
using (DataSet ds = new DataSet())
{
using (FileStream fileStream = new FileStream(excelPath, FileMode.Open, FileAccess.Read))
{
HSSFWorkbook workbook = new HSSFWorkbook(fileStream);
HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(workbook);
sheetCount = workbook.NumberOfSheets;
for (int i = 0; i < sheetCount; ++i)
{
HSSFSheet sheet = workbook.GetSheetAt(i) as HSSFSheet;
DataTable dt = ImportDataTable(sheet, 0, firstRowAsHeader);
dt.TableName = workbook.GetSheetName(i);
ds.Tables.Add(dt);
}
return ds;
}
}
}
#endregion
/// <summary>
......
......@@ -2,12 +2,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Edu.Model.Entity.Course
{
/// <summary>
/// 课程章节单词实体类
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Course_Words
{
/// <summary>
......@@ -50,6 +53,11 @@ namespace Edu.Model.Entity.Course
/// </summary>
public string ChineseMean { get; set; }
/// <summary>
/// 文件路径
/// </summary>
public string FileUrl { get; set; }
/// <summary>
/// 状态
/// </summary>
......
......@@ -10,6 +10,9 @@ namespace Edu.Model.ViewModel.Course
/// </summary>
public class RB_Course_Words_Extend : RB_Course_Words
{
/// <summary>
/// 课程编号
/// </summary>
public string QCourseIds { get; set; }
}
}
......@@ -145,6 +145,11 @@ namespace Edu.Module.Course
/// </summary>
private readonly Repository.Mall.RB_Goods_SpecificationPriceRepository goods_SpecificationPriceRepository = new Repository.Mall.RB_Goods_SpecificationPriceRepository();
/// <summary>
/// 课程单词仓储层对象
/// </summary>
private readonly RB_Course_WordsRepository course_WordsRepository = new RB_Course_WordsRepository();
#region 课程管理
public List<RB_Course_ViewModel> GetAllCourseChapterCountModule(int groupId, int courseId)
......@@ -481,6 +486,11 @@ namespace Edu.Module.Course
return chapterRepository.GetChapterListRepository(query);
}
/// <summary>
/// 导入课程章节到新课程
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<ChapterTree_ViewModel> SetImportChapterModule(RB_Course_Chapter_ViewModel query)
{
var result = GetChapterTreeListModule(query);
......@@ -652,6 +662,11 @@ namespace Edu.Module.Course
return resultList;
}
/// <summary>
/// 批量导入课程章节信息
/// </summary>
/// <param name="courseId"></param>
/// <returns></returns>
public bool SetBatchAllChapterCurrentHoursModule(int courseId)
{
RB_Course_Chapter_ViewModel query = new RB_Course_Chapter_ViewModel()
......@@ -712,8 +727,6 @@ namespace Edu.Module.Course
}
}
});
return chapterRepository.SetBatchCurrentHoursRepository(list);
}
......@@ -807,7 +820,6 @@ namespace Edu.Module.Course
}
}
/// <summary>
/// 获取章节实体类
/// </summary>
......@@ -841,7 +853,6 @@ namespace Edu.Module.Course
public bool BatchRemoveChapterModule(RB_Course_Chapter_ViewModel model)
{
var flag = chapterRepository.DeleteBatchChpterRepository(model);
SetBatchAllChapterCurrentHoursModule(model.CourseId);
return flag;
}
......@@ -896,8 +907,6 @@ namespace Edu.Module.Course
public bool SetBatchChapterNoModule(List<RB_Course_Chapter_ViewModel> chapters)
{
var flag = chapterRepository.SetBatchUpdateChapterNoRepository(chapters);
//SetBatchAllChapterCurrentHoursModule(chapters[0].CourseId);
return flag;
}
......@@ -1611,7 +1620,6 @@ namespace Edu.Module.Course
public List<RB_Class_Time_UnKnowUser_ViewModel> GetUnKnowUserByClassTimeModule(int classId)
{
var list = unKnowRepository.GetUnKnowUsersByClassIdRepository(classId);
return list;
}
......@@ -1714,6 +1722,7 @@ namespace Edu.Module.Course
demodel.GoodsPageType ??= GoodsPageTypeEnum.All;
demodel.TenantId = Convert.ToInt32(Config.JHTenantId);
demodel.MallBaseId = Convert.ToInt32(Config.JHMallBaseId);
#region 商品规格信息
demodel.SpecificationList = new List<RB_Goods_Specification_Extend>();
demodel.SpecificationPriceList = new List<RB_Goods_SpecificationPrice_Extend>();
......@@ -1762,7 +1771,6 @@ namespace Edu.Module.Course
demodel.SpecificationList.Add(modelSpecification);
#endregion
if (demodel.Id == 0)//已存在,更新
{
demodel.Status = 0;
......@@ -1772,7 +1780,6 @@ namespace Edu.Module.Course
if (goodsId > 0)
{
//插入分类
foreach (var item in model.CategoryList)
{
......@@ -1793,7 +1800,8 @@ namespace Edu.Module.Course
else
{
//修改
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
Dictionary<string, object> keyValues = new Dictionary<string, object>()
{
{ nameof(RB_Goods.Name),demodel.Name},
{ nameof(RB_Goods.CarouselImage),demodel.CarouselImage},
{ nameof(RB_Goods.VideoAddress),demodel.VideoAddress},
......@@ -1861,18 +1869,22 @@ namespace Edu.Module.Course
{ nameof(RB_Goods.GoodsUrl),demodel.GoodsUrl },
{ nameof(RB_Goods.goodsLogo),demodel.goodsLogo },
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
List<WhereHelper> wheres = new List<WhereHelper>()
{
new WhereHelper()
{
FiledName=nameof(RB_Goods.Id),
FiledValue=demodel.Id,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
new WhereHelper()
{
FiledName=nameof(RB_Goods.TenantId),
FiledValue=demodel.TenantId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
new WhereHelper()
{
FiledName=nameof(RB_Goods.MallBaseId),
FiledValue=demodel.MallBaseId,
OperatorEnum=OperatorEnum.Equal
......@@ -1900,7 +1912,6 @@ namespace Edu.Module.Course
}
#endregion
#region 修改分类
var clist = MallGoodsCategoryRepository.GetList(new RB_Goods_Category_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var insertList = model.CategoryList.Where(x => !clist.Select(y => y.CategoryId).Contains(x.CategoryId)).ToList();
......@@ -2062,7 +2073,6 @@ namespace Edu.Module.Course
}
#endregion
return goodsId;
}
......@@ -2075,7 +2085,6 @@ namespace Edu.Module.Course
public bool UpdateMallGoodsPrice(RB_Course_ViewModel courseModel, List<RB_Course_Preferential_Extend> list)
{
bool flag = false;
if (courseModel.MallGoodsId > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
......@@ -2165,7 +2174,6 @@ namespace Edu.Module.Course
}
}
}
return flag;
}
......
......@@ -29,6 +29,16 @@ namespace Edu.Module.Course
return list;
}
/// <summary>
/// 批量添加课程单词
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public bool BatchInsertCourseWordsModule(List<RB_Course_Words_Extend> list)
{
return course_WordsRepository.BatchInsertCourseWordsRepository(list);
}
/// <summary>
/// 新增修改课程单词
/// </summary>
......@@ -47,6 +57,7 @@ namespace Edu.Module.Course
{nameof(RB_Course_Words_Extend.WordTone),model.WordTone },
{nameof(RB_Course_Words_Extend.WordWrite),model.WordWrite },
{nameof(RB_Course_Words_Extend.ChineseMean),model.ChineseMean },
{nameof(RB_Course_Words_Extend.FileUrl),model.FileUrl },
{nameof(RB_Course_Words_Extend.UpdateBy),model.UpdateBy },
{nameof(RB_Course_Words_Extend.UpdateTime),model.UpdateTime },
};
......
......@@ -437,6 +437,29 @@ namespace Edu.Module.User
extModel.StuPurposeName = learningGoalsRepository.GetLearningGoalsExtEntityRepository(extModel.StuPurpose)?.Name ?? "";
extModel.StuChannelName = channelRepository.GetChannelExtEntityRepository(extModel.StuChannel)?.Name ?? "";
extModel.StuNeedsName = needsRepository.GetNeedsExtEntityRepository(extModel.StuNeeds)?.Name ?? "";
if (extModel.CustomerId > 0)
{
extModel.CustomerName = customerRepository.GetEntity(extModel.CustomerId)?.CustomerName ?? "";
}
if (extModel.StuSourceId>0)
{
if (extModel.CreateType == StuCreateTypeEnum.CustomerInput)
{
extModel.StuSourceIdName = customerRepository.GetEntity(extModel.StuSourceId)?.CustomerName ?? "";
}
else if (extModel.CreateType == StuCreateTypeEnum.EmployeeInput)
{
extModel.StuSourceIdName = accountModule.GetEmployeeInfo(extModel.StuSourceId)?.EmployeeName ?? "";
}
else if (extModel.CreateType == StuCreateTypeEnum.InternalIntroduction)
{
extModel.StuSourceIdName = accountModule.GetEmployeeInfo(extModel.StuSourceId)?.EmployeeName ?? "";
}
else if (extModel.CreateType == StuCreateTypeEnum.TransIntroduction)
{
extModel.StuSourceIdName = studentRepository.GetEntity(extModel.StuSourceId)?.StuName ?? "";
}
}
}
return extModel;
}
......
......@@ -37,8 +37,37 @@ WHERE 1=1
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Course_Words_Extend.CourseId), query.CourseId);
}
if (!string.IsNullOrEmpty(query.QCourseIds))
{
builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Course_Words_Extend.CourseId), query.QCourseIds);
}
}
return Get<RB_Course_Words_Extend>(builder.ToString()).ToList();
}
/// <summary>
/// 批量添加课程单词
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public bool BatchInsertCourseWordsRepository(List<RB_Course_Words_Extend> list)
{
bool flag = true;
if (list != null && list.Count > 0)
{
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(" VALUES ");
string tempStr = "";
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}') ";
}
builder.Append(tempStr.TrimStart(','));
flag = base.Execute(builder.ToString()) > 0;
}
return flag;
}
}
}
......@@ -582,10 +582,19 @@ namespace Edu.WebApi.Controllers.Course
#region 课程章节管理
/// <summary>
/// 导入课程章节到新课程
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetImportCourseChapter()
{
var query = Common.Plugin.JsonHelper.DeserializeObject<RB_Course_Chapter_ViewModel>(RequestParm.Msg.ToString());
var query = new RB_Course_Chapter_ViewModel()
{
CourseIds = base.ParmJObj.GetStringValue("CourseIds"),
NewCourseId = base.ParmJObj.GetInt("NewCourseId"),
MaxLength = base.ParmJObj.GetInt("MaxLength")
};
query.Group_Id = base.UserInfo.Group_Id;
query.School_Id = base.UserInfo.School_Id;
query.CreateBy = base.UserInfo.Id;
......
using Edu.Common.API;
using Edu.Common.Plugin;
using Edu.Model.ViewModel.Course;
using Edu.Module.Course;
using Edu.WebApi.Filter;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
......@@ -16,6 +19,11 @@ namespace Edu.WebApi.Controllers.Course
[EnableCors("AllowCors")]
public class CourseWordsController : BaseController
{
/// <summary>
/// 课程单词处理类对象
/// </summary>
private readonly CourseWordsModule courseWordsModule = new CourseWordsModule();
/// <summary>
/// 导入Excel单词
/// </summary>
......@@ -24,7 +32,109 @@ namespace Edu.WebApi.Controllers.Course
{
var userInfo = base.GetUserInfo(Uid);
var dataList = Common.Data.CourseWordsHelper.GetXlsWordsData(filePath);
return ApiResult.Success(data: dataList);
List<RB_Course_Words_Extend> result = new List<RB_Course_Words_Extend>();
if (dataList != null && dataList.Count > 0)
{
foreach (var item in dataList)
{
var model = new RB_Course_Words_Extend()
{
Id = 0,
CourseId = CourseId,
ChapterId = item.ChapterId,
WordType = item.WordType,
WordContent = item.WordContent,
WordTone = item.WordTone,
WordWrite = item.WordWrite,
ChineseMean = item.ChineseMean,
Status = Common.Enum.DateStateEnum.Normal,
Group_Id = userInfo.Group_Id,
CreateBy = userInfo.Id,
CreateTime = DateTime.Now,
UpdateBy = userInfo.Id,
UpdateTime = DateTime.Now
};
if (!string.IsNullOrEmpty(model.WordContent))
{
result.Add(model);
}
}
}
bool flag = false;
if (result != null && result.Count > 0)
{
flag = courseWordsModule.BatchInsertCourseWordsModule(result);
}
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 获取课程单词列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetCourseWordsList()
{
var query = new RB_Course_Words_Extend()
{
CourseId = base.ParmJObj.GetInt("CourseId"),
ChapterId = base.ParmJObj.GetInt("ChapterId"),
};
query.Group_Id = base.UserInfo.Group_Id;
var list = courseWordsModule.GetCourseWordsListModule(query);
return ApiResult.Success(data: list);
}
/// <summary>
/// 添加修改课程单词
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetCourseWords()
{
var extModel = new RB_Course_Words_Extend()
{
Id = base.ParmJObj.GetInt("Id"),
CourseId = base.ParmJObj.GetInt("CourseId"),
ChapterId = base.ParmJObj.GetInt("ChapterId"),
WordType = base.ParmJObj.GetStringValue("WordType"),
WordContent = base.ParmJObj.GetStringValue("WordContent"),
WordTone = base.ParmJObj.GetStringValue("WordTone"),
WordWrite = base.ParmJObj.GetStringValue("WordWrite"),
ChineseMean = base.ParmJObj.GetStringValue("ChineseMean"),
FileUrl = base.ParmJObj.GetStringValue("FileUrl"),
};
extModel.CreateTime = DateTime.Now;
extModel.CreateBy = UserInfo.Id;
extModel.UpdateBy = UserInfo.Id;
extModel.UpdateTime = DateTime.Now;
extModel.Group_Id = this.UserInfo.Group_Id;
bool flag = courseWordsModule.SetCourseWordsModule(extModel);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 根据编号获取单词详情
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetCourseWords()
{
var Id = base.ParmJObj.GetInt("Id", 0);
var extModel = courseWordsModule.GetCourseWordsModule(Id);
return ApiResult.Success(data: extModel);
}
/// <summary>
/// 根据编号删除单词
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult RemoveCourseWords()
{
var Id = base.ParmJObj.GetInt("Id", 0);
var flag = courseWordsModule.RemoveCourseWordsModule(Id);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
}
}
\ No newline at end of file
......@@ -1223,6 +1223,7 @@ namespace Edu.WebApi.Controllers.User
extModel.PlatformName,
AssistList = extModel?.AssistList ?? new List<RB_Student_Assist_Extend>(),
extModel.StuSourceId,
extModel.StuSourceIdName,
extModel.QQ,
extModel.WeChatNo,
extModel.StuType,
......@@ -1230,6 +1231,7 @@ namespace Edu.WebApi.Controllers.User
extModel.StuNeeds,
extModel.StuNeedsName,
extModel.StuRealMobile,
extModel.CustomerName,
};
return ApiResult.Success(data: obj);
}
......
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