Browse Source

排课系统同步数据到数校

黑龙江艺术高中职
dao 6 months ago
parent
commit
8780949b8a
17 changed files with 580 additions and 3 deletions
  1. +21
    -2
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Controllers/TimeTableController.cs
  2. +1
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Views/TimeTable/IndexInEducation.cshtml
  3. +18
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Views/TimeTable/IndexInEducation.js
  4. +1
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/database.config
  5. +36
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/logs/20240527.log
  6. +1
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Mapping/Learun.Application.Mapping.csproj
  7. +22
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Mapping/PK/Pm_LessonscheduleverMap.cs
  8. +8
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Learun.Application.TwoDevelopment.csproj
  9. +12
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Pk/Pm_LessonscheduleverBLL.cs
  10. +21
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Pk/Pm_LessonscheduleverEntity.cs
  11. +8
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Pk/Pm_LessonscheduleverIBLL.cs
  12. +33
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Pk/Pm_LessonscheduleverService.cs
  13. +45
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Pk/Pm_PkData.cs
  14. +12
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Pk/Pm_PkDataBLL.cs
  15. +10
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Pk/Pm_PkDataIBLL.cs
  16. +304
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Pk/Pm_PkDataService.cs
  17. +27
    -1
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Log/LogHelper.cs

+ 21
- 2
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Controllers/TimeTableController.cs View File

@@ -10,6 +10,7 @@ using System.Threading.Tasks;
using Newtonsoft.Json;
using System.IO;
using Learun.Application.Base.SystemModule;
using Learun.Application.TwoDevelopment.Pk;

namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers
{
@@ -32,6 +33,8 @@ namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers
private LessonInfoIBLL lessonInfoIBLL = new LessonInfoBLL();
private Edu_ChangeTeacherLessonIBLL edu_ChangeTeacherLessonIBLL = new Edu_ChangeTeacherLessonBLL();
private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();
private Pm_LessonscheduleverIBLL pm_LessonscheduleverIBLL=new Pm_LessonscheduleverBLL();
private Pm_PkDataIBLL pm_PkDataIBLL = new Pm_PkDataBLL();
#region 视图功能

/// <summary>
@@ -95,7 +98,7 @@ namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers
{
return View();
}
/// <summary>
/// 课程表【教务】
/// <summary>
@@ -296,7 +299,23 @@ namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers
var data = await stuAttendanceIBLL.AttendanceApply(kqType, lessonTime, lessonDate, classRoomNo, dataJson, attenScore, attenCondition);
return Success(data);
}

/// <summary>
/// 排课同步
/// <summary>
/// <returns></returns>
[HttpPost]
[AjaxOnly]
public ActionResult PkSyncForm()
{
var bb=pm_LessonscheduleverIBLL.GetData();
if(bb!=null)
{
var bbid = bb.id;
var r=pm_PkDataIBLL.SyncPkData(bbid);
return Success(r);
}
return Fail("同步失败(未找到版本)");
}
/// <summary>
/// 教师/学生课程表
/// </summary>


+ 1
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Views/TimeTable/IndexInEducation.cshtml View File

@@ -135,6 +135,7 @@
<div class=" btn-group btn-group-sm">
<a id="lr_refresh" class="btn btn-default"><i class="fa fa-refresh"></i></a>
<a id="perBtn" class="btn btn-default"><i class="fa fa-print"></i>&nbsp;打印课程表</a>
<a id="syncBtn" class="btn btn-default"><i class="fa fa-print"></i>&nbsp;同步排课数据</a>
@*<a id="lr_import" class="btn btn-default"><i class="fa fa-plus"></i>&nbsp;导入</a>*@
<a id="lr_more" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<i class="fa fa-reorder"></i>&nbsp;<span class="lrlt">更多</span><span class="caret"></span>


+ 18
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Views/TimeTable/IndexInEducation.js View File

@@ -127,6 +127,24 @@ var bootstrap = function ($, learun) {
btn: null
});
});
//排课同步
$('#syncBtn').on('click', function () {
learun.layerConfirm('是否确认同步排课数据!', function (res) {
if (res) {
learun.postForm(top.$.rootUrl + '/PersonnelManagement/TimeTable/PkSyncForm', function () {
refreshGirdData();
});
}
});
//learun.layerForm({
// id: 'form_syncpk',
// title: '同步数据',
// url: top.$.rootUrl + '/PersonnelManagement/TimeTable/PkSyncForm',
// width: 600,
// height: 400,
// btn: null
//});
});
//$('#datesearch').lrdate({
// dfdata: [
// {


+ 1
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/database.config View File

@@ -44,6 +44,7 @@
<add name="CollegeMIS" connectionString="Server=8.141.155.183,53314;Initial Catalog=CollegeMIS_黑龙江艺术;User ID=sa;Password=bjqjkj@2014~2015!" providerName="System.Data.SqlClient" />
<add name="hangfireString" connectionString="Server=8.141.155.183,53314;Initial Catalog=Hangfire;User ID=sa;Password=bjqjkj@2014~2015!" providerName="System.Data.SqlClient" />
<add name="paikeDbString" connectionString="Data Source=8.141.155.183;port=23306;Database=cspaike;User ID=root;Password=QJKJ@bjqj@123;" providerName="MySql.Data.MySqlClient" />
<add name="pkDbString" connectionString="Data Source=8.141.155.183;port=23306;Database=pmtable;User ID=root;Password=QJKJ@bjqj@123;" providerName="MySql.Data.MySqlClient" />
<!--塔里木中间库一卡通-->
<!--<add name="TLMYKTDBString" connectionString="Data Source=orcl;Persist Security Info=True;User ID=bjqj;Password=bjqj;" providerName="System.Data.OracleClient" />-->
<add name="TLMZYMIDDLEString" connectionString="Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=TLMZYMIDDLE)));Persist Security Info=True;User ID=digitalschool;Password=digitalschool;" providerName="Oracle.ManagedDataAccess.Client" />

+ 36
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/logs/20240527.log View File

@@ -0,0 +1,36 @@
2024-05-27 14:18:19 logInfo:System.Data.Entity.Core.ProviderIncompatibleException: An error occurred accessing the database. This usually means that the connection to the database failed. Check that the connection string is correct and that the appropriate DbContext constructor is being used to specify it or find it in the application's config file. See http://go.microsoft.com/fwlink/?LinkId=386386 for information on DbContext and connections. See the inner exception for details of the failure. ---> System.Data.Entity.Core.ProviderIncompatibleException: The provider did not return a ProviderManifestToken string. ---> MySql.Data.MySqlClient.MySqlException: Authentication method 'caching_sha2_password' not supported by any of the available plugins.
在 MySql.Data.MySqlClient.Authentication.AuthenticationPluginManager.GetPlugin(String method)
在 MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.GetPlugin(String method, NativeDriver driver, Byte[] authData)
在 MySql.Data.MySqlClient.NativeDriver.Authenticate(String authMethod, Boolean reset)
在 MySql.Data.MySqlClient.NativeDriver.Open()
在 MySql.Data.MySqlClient.Driver.Open()
在 MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
在 MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
在 MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
在 MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
在 MySql.Data.MySqlClient.MySqlPool.GetConnection()
在 MySql.Data.MySqlClient.MySqlConnection.Open()
在 MySql.Data.MySqlClient.MySqlProviderServices.GetDbProviderManifestToken(DbConnection connection)
在 System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)
--- 内部异常堆栈跟踪的结尾 ---
在 System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)
在 System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection)
--- 内部异常堆栈跟踪的结尾 ---
在 System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection)
在 System.Data.Entity.Infrastructure.DefaultManifestTokenResolver.<>c__DisplayClass1.<ResolveManifestToken>b__0(Tuple`3 k)
在 System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
在 System.Data.Entity.Infrastructure.DefaultManifestTokenResolver.ResolveManifestToken(DbConnection connection)
在 System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest)
在 System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
在 System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)
在 System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input)
在 System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
在 System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
在 System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
在 System.Data.Entity.Internal.Linq.InternalSet`1.GetEnumerator()
在 System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator()
在 System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
在 System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
在 Learun.DataBase.MySqlEx.Database.FindList[T]() 位置 D:\Work\QJ\code\ds\Learun.Framework.Ultimate V7\Learun.Framework.Module\Learun.Db\Learun.DataBase.MySql\Database.cs:行号 658
在 Learun.DataBase.Repository.Repository.FindList[T]() 位置 D:\Work\QJ\code\ds\Learun.Framework.Ultimate V7\Learun.Framework.Module\Learun.Db\Learun.DataBase.Repository\Repository.cs:行号 330
在 Learun.Application.TwoDevelopment.Pk.Pm_LessonscheduleverService.GetEntity() 位置 D:\Work\QJ\code\ds\Learun.Framework.Ultimate V7\Learun.Framework.Module\Learun.Application.Module\Learun.Application.TwoDevelopment\Pk\Pm_LessonscheduleverService.cs:行号 16。

+ 1
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Mapping/Learun.Application.Mapping.csproj View File

@@ -271,6 +271,7 @@
<Compile Include="PersonnelManagement\SRProjectMap.cs" />
<Compile Include="PersonnelManagement\SRWorkMap.cs" />
<Compile Include="PersonnelManagement\StudyGuideMap.cs" />
<Compile Include="PK\Pm_LessonscheduleverMap.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="LR_Authorize\DataAuthorizeConditionMap.cs" />
<Compile Include="LR_Authorize\DataAuthorizeRelationMap.cs" />


+ 22
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Mapping/PK/Pm_LessonscheduleverMap.cs View File

@@ -0,0 +1,22 @@
using Learun.Application.TwoDevelopment.Pk;
using System.Data.Entity.ModelConfiguration;

namespace Learun.Application.Mapping.PK
{
public class Pm_LessonscheduleverMap : EntityTypeConfiguration<Pm_LessonscheduleverEntity>
{

public Pm_LessonscheduleverMap()
{
#region 表、主键
//表
this.ToTable("pm_lessonschedulever");
//主键
this.HasKey(t => t.id);
#endregion

#region 配置关系
#endregion
}
}
}

+ 8
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Learun.Application.TwoDevelopment.csproj View File

@@ -607,6 +607,14 @@
<Compile Include="PersonnelManagement\WorkStudyPositionApply\WorkStudyPositionApplyEntity.cs" />
<Compile Include="PersonnelManagement\WorkStudyPositionApply\WorkStudyPositionApplyIBLL.cs" />
<Compile Include="PersonnelManagement\WorkStudyPositionApply\WorkStudyPositionApplyService.cs" />
<Compile Include="Pk\Pm_LessonscheduleverBLL.cs" />
<Compile Include="Pk\Pm_LessonscheduleverEntity.cs" />
<Compile Include="Pk\Pm_LessonscheduleverIBLL.cs" />
<Compile Include="Pk\Pm_LessonscheduleverService.cs" />
<Compile Include="Pk\Pm_PkData.cs" />
<Compile Include="Pk\Pm_PkDataBLL.cs" />
<Compile Include="Pk\Pm_PkDataIBLL.cs" />
<Compile Include="Pk\Pm_PkDataService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StudentWork\FamilyEconomy\FamilyEconomyBLL.cs" />
<Compile Include="StudentWork\FamilyEconomy\FamilyEconomyEntity.cs" />


+ 12
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Pk/Pm_LessonscheduleverBLL.cs View File

@@ -0,0 +1,12 @@
namespace Learun.Application.TwoDevelopment.Pk
{
public class Pm_LessonscheduleverBLL : Pm_LessonscheduleverIBLL
{
protected Pm_LessonscheduleverService ser=new Pm_LessonscheduleverService();

public Pm_LessonscheduleverEntity GetData()
{
return ser.GetEntity();
}
}
}

+ 21
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Pk/Pm_LessonscheduleverEntity.cs View File

@@ -0,0 +1,21 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;

namespace Learun.Application.TwoDevelopment.Pk
{
public class Pm_LessonscheduleverEntity
{

[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("ID")]
public string id { get; set; }

[Column("LV_CREATETIME")]
public DateTime lv_createtime { get; set; }

[Column("lv_status")]
public string lv_status { get; set; }

}
}

+ 8
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Pk/Pm_LessonscheduleverIBLL.cs View File

@@ -0,0 +1,8 @@
namespace Learun.Application.TwoDevelopment.Pk
{
public interface Pm_LessonscheduleverIBLL
{

Pm_LessonscheduleverEntity GetData();
}
}

+ 33
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Pk/Pm_LessonscheduleverService.cs View File

@@ -0,0 +1,33 @@
using Learun.DataBase.Repository;
using Learun.Util;
using System;
using System.Linq;

namespace Learun.Application.TwoDevelopment.Pk
{
public class Pm_LessonscheduleverService : RepositoryFactory
{

public Pm_LessonscheduleverEntity GetEntity()
{
try
{
var db = this.BaseRepository("pkDbString");
var ls = db.FindList<Pm_LessonscheduleverEntity>().OrderByDescending(x => x.lv_createtime);
return ls.FirstOrDefault();
}
catch (Exception ex)
{
Util.Log.LogHelper.Info(ex);
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
}
}

+ 45
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Pk/Pm_PkData.cs View File

@@ -0,0 +1,45 @@
using System;

namespace Learun.Application.TwoDevelopment.Pk
{
public class Pm_PkData
{

public string planname { get; set; }

public DateTime? begin_date { get; set; }

public DateTime? end_date { get; set; }

public string gd_code { get; set; }

public string gd_name { get; set; }

public string lc_name { get; set; }

public string cu_code { get; set; }

public string cu_name { get; set; }

public string user_code { get; set; }

public string user_name { get; set; }

public string cr_code { get; set; }

public string cr_name { get; set; }

public string cc_name { get; set; }

public int? st_week { get; set; }

public int? ed_week { get; set; }

public int? ls_day { get; set; }

public int? ls_row { get; set; }



}
}

+ 12
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Pk/Pm_PkDataBLL.cs View File

@@ -0,0 +1,12 @@
namespace Learun.Application.TwoDevelopment.Pk
{
public class Pm_PkDataBLL : Pm_PkDataIBLL
{
protected Pm_PkDataService _PkDataService = new Pm_PkDataService();

public string SyncPkData(string bbid)
{
return _PkDataService.SyncPkData(bbid);
}
}
}

+ 10
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Pk/Pm_PkDataIBLL.cs View File

@@ -0,0 +1,10 @@
namespace Learun.Application.TwoDevelopment.Pk
{
public interface Pm_PkDataIBLL
{


string SyncPkData(string bbid);

}
}

+ 304
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Pk/Pm_PkDataService.cs View File

@@ -0,0 +1,304 @@

using Learun.Application.Organization;
using Learun.Application.TwoDevelopment.EducationalAdministration;
using Learun.Cache.Base;
using Learun.DataBase.Repository;
using Learun.Util;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Web.Caching;
using System;

namespace Learun.Application.TwoDevelopment.Pk
{
public class Pm_PkDataService : RepositoryFactory
{

protected ArrangeLessonTermService arrangeLessonTermService = new ArrangeLessonTermService();

public string SyncPkData(string ddid)
{
var db = this.BaseRepository("CollegeMIS").BeginTrans();
try
{
var sql = $"SELECT pm_lessonplan.name AS planname,DATE_FORMAT(pm_lessonplan.begin_date,'%Y-%m-%d') AS begin_date,DATE_FORMAT(pm_lessonplan.end_date,'%Y-%m-%d') AS end_date,pm_gradeclass.gd_code,pm_gradeclass.name AS gd_name,pm_lessonclass.name AS lc_name,pm_course.cu_code,pm_course.name AS cu_name,pm_teacher.user_code,pm_teacher.user_name,ifnull(pm_classroom.cr_code,'') as cr_code,IFNULL(pm_classroom.name,'') AS cr_name,sc_commoncode.cc_name,pm_lessonclass.st_week,pm_lessonclass.ed_week,pm_lessonschedule.ls_day+1 AS ls_day,pm_lessonschedule.ls_row+1 AS ls_row FROM pm_lessonclass JOIN pm_gradeclass ON INSTR(pm_lessonclass.gc_id,pm_gradeclass.id)>0 JOIN pm_lessonschedule ON pm_lessonschedule.lc_id=pm_lessonclass.id JOIN pm_lessonschedulever ON pm_lessonschedule.lv_id=pm_lessonschedulever.id JOIN pm_lessonplan ON pm_lessonschedulever.lp_id=pm_lessonplan.id JOIN pm_course ON pm_lessonclass.cu_id=pm_course.id JOIN sc_commoncode ON pm_lessonclass.cu_type=sc_commoncode.cc_id JOIN pm_teacher ON INSTR(pm_lessonclass.tc_id,pm_teacher.id)>0 left JOIN pm_classroom ON pm_lessonschedule.cr_id=pm_classroom.id WHERE pm_lessonschedulever.id='{ddid}'";
var ls = this.BaseRepository("pkDbString").FindList<Pm_PkData>(sql).ToList();
if (ls.Count > 0)
{
int snum = 0;
int fnum = 0;
//插入时间
var Insertdate = DateTime.Now;

IEnumerable<ArrangeLessonTermEntity> ArrangeLessonTermHistory = db.FindList<ArrangeLessonTermEntity>("select * from ArrangeLessonTerm");
var ArrangeLessonTerminsert = new List<ArrangeLessonTermEntity>();

#region 上课时间
var lessonTimes = new Dictionary<int, Tuple<string, string>>();
lessonTimes.Add(1, new Tuple<string, string>("8:30", "9:15"));
lessonTimes.Add(2, new Tuple<string, string>("9:25", "10:10"));
lessonTimes.Add(3, new Tuple<string, string>("10:20", "11:00"));
lessonTimes.Add(4, new Tuple<string, string>("11:10", "11:50"));
lessonTimes.Add(5, new Tuple<string, string>("13:30", "14:15"));
lessonTimes.Add(6, new Tuple<string, string>("14:25", "15:10"));
lessonTimes.Add(7, new Tuple<string, string>("15:20", "16:00"));
lessonTimes.Add(8, new Tuple<string, string>("16:10", "16:50"));
lessonTimes.Add(9, new Tuple<string, string>("17:00", "17:40"));
lessonTimes.Add(10, new Tuple<string, string>("17:50", "18:30"));
#endregion

var startDate = DateTime.Today;
var endDate = DateTime.Today;

#region 基础数据
var lessons = db.FindList<LessonInfoEntity>(x => x.CheckMark == true);
var classes = db.FindList<ClassInfoEntity>(x => x.CheckMark == true);
var classrooms = db.FindList<ClassroomInfoEntity>(x => x.CheckMark == true);
var empinfo = db.FindList<EmpInfoEntity>(x => x.CheckMark == true);
var CompanyEntity = BaseRepository().FindEntity<CompanyEntity>(x => x.F_EnabledMark == 1);
#endregion

// 循环遍历
foreach (var dr in ls)
{

try
{
#region 必填项空验证
if (!dr.begin_date.HasValue)
{
throw (new Exception("开始日期不能为空"));
}
if (!dr.end_date.HasValue)
{
throw (new Exception("结束日期不能为空"));
}

if (dr.gd_code.IsEmpty())
{
throw (new Exception("班级编号不能为空"));
}
if (dr.gd_name.IsEmpty())
{
throw (new Exception("班级名称不能为空"));
}
if (dr.cu_code.IsEmpty())
{
throw (new Exception("课程编号不能为空"));
}
if (dr.cu_name.IsEmpty())
{
throw (new Exception("课程名称不能为空"));
}
if (dr.user_code.IsEmpty())
{
throw (new Exception("教师编号不能为空"));
}
if (dr.user_name.IsEmpty())
{
throw (new Exception("教师名称不能为空"));
}
if (dr.cr_code.IsEmpty())
{
dr.cr_code = "jsbjc";
//throw (new Exception("教室编号不能为空"));
}
if (dr.cr_name.IsEmpty())
{
dr.cr_name = "教室不检测";
//throw (new Exception("教室名称不能为空"));
}
if (!dr.ls_row.HasValue)
{
throw (new Exception("上课节次不能为空"));
}
if (dr.cc_name.IsEmpty())
{
throw (new Exception("课程类型不能为空"));
}
if (!dr.st_week.HasValue)
{
throw (new Exception("起始周不能为空"));
}
if (!dr.ed_week.HasValue)
{
throw (new Exception("结束周不能为空"));
}
if (!dr.ls_day.HasValue)
{
throw (new Exception("上课周几不能为空"));
}
#endregion

#region 开始时间、结束时间格式判断
//var st = new TimeSpan();
//var stFlag = TimeSpan.TryParse(dr["开始时间"].ToString(), out st);
//if (!stFlag)
//{
// throw (new Exception("开始时间格式有误"));
//}
//var et = new TimeSpan();
//var etFlag = TimeSpan.TryParse(dr["结束时间"].ToString(), out et);
//if (!etFlag)
//{
// throw (new Exception("结束时间格式有误"));
//}

#endregion

#region 基础数据
var lessonEntity = lessons.FirstOrDefault(x => x.LessonName == dr.cu_name.Trim() && x.LessonNo == dr.cu_code.Trim());
if (lessonEntity == null)
throw (new Exception("查无此课程"));
var classEntity = classes.FirstOrDefault(x => x.ClassName == dr.gd_name.Trim() && x.ClassNo == dr.gd_code.Trim());
if (classEntity == null)
throw (new Exception("查无此班级"));
var classroomEntity = classrooms.FirstOrDefault(x => x.ClassroomName == dr.cr_name.Trim() && x.ClassroomNo == dr.cr_code.ToString().Trim());
if (classroomEntity == null)
throw (new Exception("查无此教室"));
var empinfoEntity = empinfo.FirstOrDefault(x => x.EmpName == dr.user_name.Trim() && x.EmpNo == dr.user_code.Trim());
if (empinfoEntity == null)
throw (new Exception("查无此教师"));
#endregion

var semesterAndYear = Common.GetSemesterAndYear(dr.begin_date.Value.ToDateString());
#region 初始化学期时间
startDate = dr.begin_date.Value;
endDate = dr.end_date.Value;
#endregion
#region 计算课程开始结束 时间
var startWeek = dr.st_week.Value;
var lessonStartDate = startDate.AddDays((startWeek - 1) * 7);
if (lessonStartDate < startDate) lessonStartDate = startDate;
var endWeek = dr.ed_week.Value;
var lessonEndDate = startDate.AddDays(endWeek * 7 - 1);
if (lessonEndDate > endDate) lessonEndDate = endDate;
#endregion

var weekType = dr.cc_name;
#region 计算真正的上课时间
var lessonWeekData = dr.ls_day.Value;
var lessonStartDateWeek = (int)lessonStartDate.DayOfWeek;
if (lessonStartDateWeek == 0) lessonStartDateWeek = 7;
var trueStartDate = lessonStartDate;
if (lessonStartDateWeek <= lessonWeekData)
{
trueStartDate = lessonStartDate.AddDays(lessonWeekData - lessonStartDateWeek);
}
else
{
trueStartDate = lessonStartDate.AddDays(7 - (lessonStartDateWeek - lessonWeekData));
}
if (weekType == "双周")
{
trueStartDate = trueStartDate.AddDays(7);
}
#endregion

var intLesson = dr.ls_row.Value;
var lessonTime = lessonTimes[intLesson];
while (true)
{
//写入要导入替换的数据
ArrangeLessonTermEntity arrangeLessonTermEntity = new ArrangeLessonTermEntity
{
ALTId = Guid.NewGuid().ToString(),
LessonDate = trueStartDate,
StartTime = TimeSpan.Parse(lessonTime.Item1).ToString(@"hh\:mm"),
EndTime = TimeSpan.Parse(lessonTime.Item2).ToString(@"hh\:mm"),
AcademicYearNo = semesterAndYear.AcademicYearShort,
Semester = semesterAndYear.Semester,
DeptNo = classEntity.DeptNo,
MajorNo = classEntity.MajorNo,
LessonNo = lessonEntity.LessonNo,
LessonName = lessonEntity.LessonName,
TeachClassNo = lessonEntity.LessonName + classEntity.ClassNo,
EmpNo = empinfoEntity.EmpNo,
EmpName = empinfoEntity.EmpName,
ClassroomNo = classroomEntity.ClassroomNo,
LessonTime = $"{dr.ls_day}{dr.ls_row}",
LessonSortNo = lessonEntity.LessonSortNo,
//默认数;
CheckMark = "1",
InsertDate = Insertdate,
IsImport = false,
F_SchoolId = CompanyEntity.F_CompanyId
};

#region 判断是否重复
if (ArrangeLessonTermHistory.Count(m => m.AcademicYearNo == arrangeLessonTermEntity.AcademicYearNo && m.Semester == arrangeLessonTermEntity.Semester
&& m.LessonNo == arrangeLessonTermEntity.LessonNo && m.LessonDate.Value.Date == arrangeLessonTermEntity.LessonDate.Value.Date
&& m.DeptNo == arrangeLessonTermEntity.DeptNo && m.MajorNo == arrangeLessonTermEntity.MajorNo
&& m.TeachClassNo == arrangeLessonTermEntity.TeachClassNo && m.EmpNo == arrangeLessonTermEntity.EmpNo
&& m.ClassroomNo == arrangeLessonTermEntity.ClassroomNo && m.LessonTime == arrangeLessonTermEntity.LessonTime
&& m.F_SchoolId == arrangeLessonTermEntity.F_SchoolId) == 0
&& ArrangeLessonTerminsert.Count(m => m.AcademicYearNo == arrangeLessonTermEntity.AcademicYearNo && m.Semester == arrangeLessonTermEntity.Semester
&& m.LessonNo == arrangeLessonTermEntity.LessonNo && m.LessonDate.Value.Date == arrangeLessonTermEntity.LessonDate.Value.Date
&& m.DeptNo == arrangeLessonTermEntity.DeptNo && m.MajorNo == arrangeLessonTermEntity.MajorNo
&& m.TeachClassNo == arrangeLessonTermEntity.TeachClassNo && m.EmpNo == arrangeLessonTermEntity.EmpNo
&& m.ClassroomNo == arrangeLessonTermEntity.ClassroomNo && m.LessonTime == arrangeLessonTermEntity.LessonTime
&& m.F_SchoolId == arrangeLessonTermEntity.F_SchoolId) == 0)
{
ArrangeLessonTerminsert.Add(arrangeLessonTermEntity);
}
else
{
//throw (new Exception("当前数据重复"));
}
#endregion

if (weekType == "全周")
{
trueStartDate = trueStartDate.AddDays(7);
}
else
{
trueStartDate = trueStartDate.AddDays(14);
}

if (trueStartDate > lessonEndDate) break;
}
snum++;

}
catch (Exception ex)
{
fnum++;

}

}

//执行导入
db.Insert(ArrangeLessonTerminsert);
db.Commit();

if (snum > 0)
{
//写入开课计划数据
arrangeLessonTermService.InsertTeachClassDataInImport(Insertdate);
}

return $"成功同步数据({snum})";//snum + "|" + fnum;
}
return "无可同步数据";
}
catch (Exception ex)
{
db.Rollback();
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}


}
}

+ 27
- 1
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Log/LogHelper.cs View File

@@ -11,7 +11,7 @@ namespace Learun.Util.Log
{
#region log
//文件路径
string path = Path.Combine(Directory.GetCurrentDirectory(), "logs");
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logs");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
@@ -27,6 +27,32 @@ namespace Learun.Util.Log
{


}
}

public static void Info(Exception ex)
{
try
{
#region log
//文件路径
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logs");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}

//文件
string fileName = Path.Combine(path, $"{DateTime.Now:yyyyMMdd}.log");
var msg = ex.Message+ex.InnerException.Message;
string message = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss} logInfo:{msg}.\r\n more:{ex.ToString()}。{Environment.NewLine}";
File.AppendAllText(fileName, message);
#endregion
}
catch
{


}
}
}


Loading…
Cancel
Save