Commit 2db27087 authored by liudong1993's avatar liudong1993

绩效定时器

parent efd9bc57
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
namespace Edu.Education.Common
{
/// <summary>
/// 全局配置
/// </summary>
public class Config
{
/// <summary>
/// 获取配置文件的值
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static string GetAppSetting(string key)
{
try
{
string value = ConfigurationManager.AppSettings[key].ToString();
return value ?? "";
}
catch (Exception)
{
return "";
}
}
}
}
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath></OutputPath>
<DocumentationFile></DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Compile Remove="ProjectInstaller.cs" />
<Compile Remove="ProjectInstaller.Designer.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Remove="ProjectInstaller.resx" />
</ItemGroup>
<ItemGroup>
<None Remove="appsettings.Development.json" />
<None Remove="appsettings.json" />
</ItemGroup>
<ItemGroup>
<Content Include="appsettings.Development.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Quartz" Version="3.2.3" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Edu.Module.Course\Edu.Module.Course.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="EducationTimerServer.cs">
<SubType>Component</SubType>
</Compile>
<Compile Update="EducationTimerServer.Designer.cs">
<DependentUpon>EducationTimerServer.cs</DependentUpon>
</Compile>
</ItemGroup>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_LastSelectedProfileId>E:\LDWork\LiuDongWork\OnLineItem\Education\Edu.EducationCore\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
</PropertyGroup>
</Project>
\ No newline at end of file
namespace Edu.Education
{
partial class EducationTimerServer
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.ServiceName = "EducationTimerServer";
}
#endregion
}
}
using Edu.Education.Helper;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
namespace Edu.Education
{
partial class EducationTimerServer : ServiceBase
{
public EducationTimerServer()
{
InitializeComponent();
}
/// <summary>
/// 在此处添加代码以启动服务。
/// </summary>
/// <param name="args"></param>
protected override void OnStart(string[] args)
{
new QuarzHelper().TeachingPerfTimer().GetAwaiter().GetResult();
}
/// <summary>
/// 在此处添加代码以执行停止服务所需的关闭操作。
/// </summary>
protected override void OnStop()
{
}
}
}
using System;
using System.Configuration;
using System.IO;
using System.Threading.Tasks;
namespace Edu.Education.Helper
{
/// <summary>
/// 日志帮助类
/// </summary>
public class LogHelper
{
private static string logDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log/error");
private static string infoLogDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log/info");
private static string requestLogDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log/request");
private static object objError = new object();
private static object objInfo = new object();
private static object objRequest = new object();
/// <summary>
/// 构造函数
/// </summary>
static LogHelper()
{
if (!Directory.Exists(logDir))
Directory.CreateDirectory(logDir);
if (!Directory.Exists(infoLogDir))
Directory.CreateDirectory(infoLogDir);
if (!Directory.Exists(requestLogDir))
Directory.CreateDirectory(requestLogDir);
}
/// <summary>
/// 写日志(异常日志)
/// </summary>
/// <param name="ex">异常内容</param>
public static void Write(Exception ex)
{
Write(ex, "");
}
/// <summary>
/// 写日志(异常日志)
/// </summary>
/// <param name="msg">信息</param>
public static void Write(string msg)
{
Write(null, msg);
}
/// <summary>
/// 写日志(异常日志)
/// </summary>
/// <param name="exception">异常信息</param>
/// <param name="otherMsg">其他信息</param>
public static void Write(Exception exception, string otherMsg)
{
Task.Run(() => WriteLog(exception, otherMsg, LogEnum.Error));
}
/// <summary>
/// 打印信息(记录信息)
/// </summary>
/// <param name="msg">信息</param>
public static void WriteInfo(string msg)
{
Task.Run(() => WriteLog(null, msg, LogEnum.Info));
}
/// <summary>
/// 写日志
/// </summary>
/// <param name="exception">异常信息</param>
/// <param name="otherMsg">其他信息</param>
/// <param name="logType">日志类型</param>
private static void WriteLog(Exception exception, string otherMsg, LogEnum logType)
{
string str = "";
try
{
str += string.Format(@"
DateTime:{0}", DateTime.Now.ToString());
if (exception != null)
{
if (exception.InnerException != null)
{
exception = exception.InnerException;
}
str += string.Format(@"
Message:{0}
StackTrace:
{1}
Source:{2}
"
, exception.Message
, exception.StackTrace
, exception.Source
);
}
str += string.Format(@"
ExtMessage:{0}", otherMsg);
string filePath = "";
object lockObj = new object();
switch (logType)
{
case LogEnum.Error:
filePath = Path.Combine(logDir, DateTime.Now.ToString("yyyyMMdd") + ".txt");
lockObj = objError;
break;
case LogEnum.Info:
filePath = Path.Combine(infoLogDir, DateTime.Now.ToString("yyyyMMdd") + ".txt");
lockObj = objInfo;
break;
case LogEnum.Request:
filePath = Path.Combine(requestLogDir, DateTime.Now.ToString("yyyyMMdd") + ".txt");
lockObj = objRequest;
break;
}
lock (lockObj)
{
StreamWriter sw = new StreamWriter(filePath, true);
sw.WriteLine(str);
sw.Close();
}
}
catch
{
}
}
}
/// <summary>
/// 日志枚举
/// </summary>
public enum LogEnum
{
/// <summary>
/// 错误日志
/// </summary>
Error = 1,
/// <summary>
/// 信息记录
/// </summary>
Info = 2,
/// <summary>
/// 接口请求
/// </summary>
Request = 3
}
}
using System;
using System.Text;
using Newtonsoft.Json;
using System.IO;
using Quartz;
using Quartz.Impl;
using System.Collections.Specialized;
using System.Threading.Tasks;
using Edu.Module.Course;
namespace Edu.Education.Helper
{
/// <summary>
/// 定时器
/// </summary>
public class QuarzHelper
{
/// <summary>
/// 定时执行教师绩效生成
/// </summary>
/// <returns></returns>
public async Task TeachingPerfTimer()
{
string cronExpression = "0 0 */1 * * ?"; //每天凌晨1点
NameValueCollection props = new NameValueCollection
{
{ "quartz.serializer.type", "binary" }
};
StdSchedulerFactory factory = new StdSchedulerFactory(props);
IScheduler scheduler = await factory.GetScheduler();
await scheduler.Start();
IJobDetail job = JobBuilder.Create<CreateTeachingPerf>()
.WithIdentity("job1", "group1")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger1", "group1")
.StartNow()
.WithSimpleSchedule(x => x
.WithIntervalInHours(2)
.RepeatForever())
.Build();
//ICronTrigger trigger = (ICronTrigger)TriggerBuilder.Create()
// .WithIdentity("trigger1", "group1")
// .WithCronSchedule(cronExpression)
// .Build();
await scheduler.ScheduleJob(job, trigger);
}
}
/// <summary>
/// 教师绩效生成
/// </summary>
public class CreateTeachingPerf : IJob
{
/// <summary>
/// 这里是作业调度每次定时执行方法
/// </summary>
/// <param name="context"></param>
public Task Execute(IJobExecutionContext context)
{
try
{
LogHelper.Write("进来了");
TeachingRewardsModule teachingRewardsModule = new TeachingRewardsModule();
var glist = teachingRewardsModule.GetGroupList();
foreach (var item in glist)
{
//查询该集团下 所有的班级
var clist = teachingRewardsModule.GetTeachingPerfClassList(item.GId);
foreach (var qitem in clist)
{
try
{
string msg = teachingRewardsModule.SetTeachingPerfCreate(0, qitem);
if (msg != null)
{
LogHelper.Write("CreateTeachingPerf【" + qitem.ClassId + "】:" + msg);
}
}
catch (Exception ex)
{
LogHelper.Write(ex, "CreateTeachingPerf【" + qitem.ClassId + "】");
}
}
}
}
catch (Exception ex)
{
LogHelper.Write(ex, "CreateTeachingPerf");
}
return null;
}
}
}
using Edu.Education;
using Edu.Education.Helper;
using System;
using System.ServiceProcess;
namespace Edu.EducationCore
{
class Program
{
static void Main(string[] args)
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new EducationTimerServer(),
};
ServiceBase.Run(ServicesToRun);
//new QuarzHelper().TeachingPerfTimer().GetAwaiter().GetResult();
//Console.WriteLine("好了");
//Console.ReadKey();
}
}
}
namespace Mall.Education
{
partial class ProjectInstaller
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();
//
// serviceProcessInstaller1
//
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
this.serviceProcessInstaller1.Password = null;
this.serviceProcessInstaller1.Username = null;
//
// serviceInstaller1
//
this.serviceInstaller1.Description = "EducationTimerServer服务";
this.serviceInstaller1.ServiceName = "EducationTimerServer";
this.serviceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
//
// ProjectInstaller
//
this.Installers.AddRange(new System.Configuration.Install.Installer[] {
this.serviceProcessInstaller1,
this.serviceInstaller1});
}
#endregion
private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1;
private System.ServiceProcess.ServiceInstaller serviceInstaller1;
}
}
\ No newline at end of file
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;
using System.Threading.Tasks;
namespace Mall.Education
{
[RunInstaller(true)]
public partial class ProjectInstaller : System.Configuration.Install.Installer
{
public ProjectInstaller()
{
InitializeComponent();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="serviceProcessInstaller1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="serviceInstaller1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>208, 17</value>
</metadata>
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<TargetFramework>netcoreapp3.0</TargetFramework>
<PublishDir>bin\Release\netcoreapp3.0\publish\</PublishDir>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
</PropertyGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>
\ No newline at end of file
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
{
"ConnectionStrings": {
"DefaultConnection": "server=192.168.1.214;user id=reborn;password=Reborn@2018;database=reborn_edu;CharSet=utf8mb4; Convert Zero Datetime=true; ",
"DefaultConnectionPName": "MySql.Data.MySqlClient",
"FinanceConnection": "server=192.168.1.214;user id=reborn;password=Reborn@2018;database=reborn_finance;CharSet=utf8mb4; Convert Zero Datetime=true; ",
"FinanceConnectionPName": "MySql.Data.MySqlClient"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"JwtSecretKey": "@VIITTOREBORN*2018",
"JwtExpirTime": 2592000,
"IsSendMsg": 2,
"AllowedHosts": "*",
"OpenValidation": "False",
"UploadSiteUrl": "http://192.168.1.214:8120",
"ViewFileSiteUrl": "https://viitto-1301420277.cos.ap-chengdu.myqcloud.com",
"ErpViewFileSiteUrl": "http://imgfile.oytour.com",
"Mongo": "mongodb://47.96.25.130:27017",
"MongoDBName": "Edu",
"FinanceKey": "FinanceMallInsertToERPViitto2020",
"PaymentFinanceApi": "http://192.168.1.13:8083/api/Mall/InsertFinanceBatchForMallOut",
"TeachingBonusTemplete": 141,
"BonusCostTypeId": 540,
"RabbitMqConfig": {
"HostName": "47.96.25.130",
"VirtualHost": "/",
"Port": 5672,
"UserName": "guest",
"Password": "viitto2019"
},
"RedisSetting": {
"RedisServer": "47.96.23.199",
"RedisPort": "6379",
"RedisPwd": "Viitto2018"
},
"VirtualDirectory": "WebFile",
//Ƿϻ
"IsOnline": false
}
\ No newline at end of file
...@@ -90,6 +90,10 @@ namespace Edu.Module.Course ...@@ -90,6 +90,10 @@ namespace Edu.Module.Course
/// 教师绩效备注 /// 教师绩效备注
/// </summary> /// </summary>
private readonly RB_Teaching_PerfRemarkRepository teaching_PerfRemarkRepository = new RB_Teaching_PerfRemarkRepository(); private readonly RB_Teaching_PerfRemarkRepository teaching_PerfRemarkRepository = new RB_Teaching_PerfRemarkRepository();
/// <summary>
/// 集团
/// </summary>
private readonly RB_GroupRepository groupRepository = new RB_GroupRepository();
#region 教务配置 #region 教务配置
...@@ -960,9 +964,15 @@ namespace Edu.Module.Course ...@@ -960,9 +964,15 @@ namespace Edu.Module.Course
/// </summary> /// </summary>
/// <param name="classId"></param> /// <param name="classId"></param>
/// <returns></returns> /// <returns></returns>
public string SetTeachingPerfCreate(int classId) public string SetTeachingPerfCreate(int classId,RB_Class_ViewModel classModel = null)
{ {
var classModel = classRepository.GetEntity(classId); if (classModel == null)
{
classModel = classRepository.GetEntity<RB_Class_ViewModel>(classId);
}
else {
classId = classModel.ClassId;
}
if (classModel.Status == DateStateEnum.Delete) { return "班级不存在"; } if (classModel.Status == DateStateEnum.Delete) { return "班级不存在"; }
if (classModel.ClassStatus != ClassStatusEnum.EndClass) { return "班级状态不正确"; } if (classModel.ClassStatus != ClassStatusEnum.EndClass) { return "班级状态不正确"; }
...@@ -1112,6 +1122,23 @@ namespace Edu.Module.Course ...@@ -1112,6 +1122,23 @@ namespace Edu.Module.Course
return ""; return "";
} }
/// <summary>
/// 获取集团列表
/// </summary>
/// <returns></returns>
public List<RB_Group_ViewModel> GetGroupList() {
return groupRepository.GetGroupListRepository(new RB_Group_ViewModel() { });
}
/// <summary>
/// 获取可生成绩效的班级
/// </summary>
/// <param name="GroupId"></param>
/// <returns></returns>
public List<RB_Class_ViewModel> GetTeachingPerfClassList(int GroupId) {
return classRepository.GetTeachingPerfClassList(GroupId);
}
/// <summary> /// <summary>
/// 绩效制单 /// 绩效制单
/// </summary> /// </summary>
...@@ -1120,9 +1147,109 @@ namespace Edu.Module.Course ...@@ -1120,9 +1147,109 @@ namespace Edu.Module.Course
/// <param name="currencyId"></param> /// <param name="currencyId"></param>
/// <param name="userInfo"></param> /// <param name="userInfo"></param>
/// <returns></returns> /// <returns></returns>
public string SetTeachingPerfFinance(int perfId, int isPublic, int currencyId, UserInfo userInfo) public string SetTeachingPerfFinance(int perfId, int IsPublic, int CurrencyId, UserInfo userInfo)
{ {
throw new NotImplementedException(); var tmodel = teaching_PerfRepository.GetEntity(perfId);
if (tmodel == null) { return "教师绩效不存在"; }
if (tmodel.PerfState != PerfStateEnum.Confirmed) { return "未确认无法制单"; }
string msg = "";
var teacherModel = teacherRepository.GetTeacherList(tmodel.TeacherId.ToString()).FirstOrDefault();
if (teacherModel == null)
{
return "教师不存在";
}
#region 新增财务单据
//银行账户
var clientModel = clientBankAccountRepository.GetList(new RB_ClientBankAccount_Extend() { RB_Group_Id = userInfo.Group_Id, Type = Common.Enum.Finance.ClientTypeEnum.Employee, ObjIdStr = teacherModel.AccountId.ToString() }).FirstOrDefault();
if (clientModel == null) {
return "教师未添加账户信息";
}
var detailList = new List<object>
{
new
{
CostTypeId = Config.ReadConfigKey("BonusCostTypeId"),
Number = tmodel.ClassHours,
OriginalMoney = tmodel.UnitPrice,
tmodel.UnitPrice,
Remark = "满班率:" + tmodel.FullClassRate + ",平均上课率:" + tmodel.AvgCheckRate + ",累计课时:" + tmodel.ClassHours
}
};
string Remark = teacherModel.TeacherName + "教师绩效";
var financeObj = new
{
IsPublic,
ClientType = (int)Common.Enum.Finance.ClientTypeEnum.Employee,
ClientID = clientModel.ID,
CurrencyId,
WBMoney = tmodel.Money,
PayDate = DateTime.Now.ToString("yyyy-MM-dd"),
TemplateId = Config.ReadConfigKey("TeachingBonusTemplete"),
OrderSource = 17,
OtherType = 27,
ReFinanceId = perfId,
Remark,
detailList,
CreateBy = userInfo.Id,
RB_Branch_Id = teacherModel.School_Id,
RB_Depart_Id = teacherModel.Dept_Id,
RB_Group_Id = userInfo.Group_Id,
RB_CreateByName = userInfo.AccountName,
RB_DepartName = teacherModel.DeptName,
RB_BranchName = teacherModel.SName,
RB_GroupName = userInfo.GroupName,
FinanceType = 2
};
string sign = EncryptionHelper.AesEncrypt(JsonHelper.Serialize(financeObj), Config.ReadConfigKey("FinanceKey"));
var resultInfo = new
{
msg = sign
};
string apiResult = HttpHelper.HttpPost(Config.ReadConfigKey("PaymentFinanceApi"), JsonHelper.Serialize(resultInfo), "");
JObject parmsJob = JObject.Parse(apiResult);
string resultCode = parmsJob.GetStringValue("resultCode");
int frid = parmsJob.GetInt("data", 0);
if (resultCode == "1" && frid > 0)
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Teaching_Perf_ViewModel.FinanceId),frid}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Teaching_Perf_ViewModel.Id),
FiledValue=frid,
OperatorEnum=OperatorEnum.Equal
}
};
bool flag = teaching_PerfRepository.Update(keyValues, wheres);
if (flag)
{
//记录日志
changeLogRepository.Insert(new Model.Entity.Log.RB_User_ChangeLog()
{
Id = 0,
Type = 1,
CreateBy = userInfo.Id,
CreateTime = DateTime.Now,
Group_Id = userInfo.Group_Id,
LogContent = "生成教师绩效财务单据【" + tmodel.Id + "】",
School_Id = userInfo.School_Id,
SourceId = 0
});
}
}
else
{
string message = parmsJob.GetStringValue("message");
LogHelper.Write("SetTeachingBonusFinance:" + message);
msg += (teacherModel.TeacherName) + "创建财务单据失败;";
}
#endregion
return msg;
} }
#endregion #endregion
......
...@@ -298,5 +298,18 @@ FROM ( ...@@ -298,5 +298,18 @@ FROM (
", qClassTypeIds); ", qClassTypeIds);
return Get<ClassTypeStatic_ViewModel>(builder.ToString()).ToList(); return Get<ClassTypeStatic_ViewModel>(builder.ToString()).ToList();
} }
/// <summary>
/// 获取教师列表
/// </summary>
/// <param name="GroupId"></param>
/// <returns></returns>
public List<RB_Class_ViewModel> GetTeachingPerfClassList(int GroupId) {
string sql = $@"SELECT c.* FROM rb_class c
LEFT JOIN rb_teaching_perf t on (c.ClassId = t.ClassId AND t.`Status`=0)
WHERE c.`Status`=0 and c.Group_Id ={GroupId} and c.ClassStatus =3 and c.EndClassDate <='2030-12-16' AND t.Id IS NULL";
return Get<RB_Class_ViewModel>(sql).ToList();
}
} }
} }
...@@ -41,7 +41,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Edu.Module.Log", "Edu.Modul ...@@ -41,7 +41,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Edu.Module.Log", "Edu.Modul
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Edu.ThirdCore", "Edu.ThirdCore\Edu.ThirdCore.csproj", "{5F76907A-7181-4FC5-B224-52CDD5B90359}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Edu.ThirdCore", "Edu.ThirdCore\Edu.ThirdCore.csproj", "{5F76907A-7181-4FC5-B224-52CDD5B90359}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Edu.Module.Finance", "Edu.Module.Finance\Edu.Module.Finance.csproj", "{A737D901-5EC5-4593-867A-899482FAA67A}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Edu.Module.Finance", "Edu.Module.Finance\Edu.Module.Finance.csproj", "{A737D901-5EC5-4593-867A-899482FAA67A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SystemSerivce", "SystemSerivce", "{5B0BC66C-B15F-4174-8966-0968C61F816F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Edu.EducationCore", "Edu.EducationCore\Edu.EducationCore.csproj", "{FF7B1BD4-0F06-4D22-91EB-9140E65A87AE}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
...@@ -105,6 +109,10 @@ Global ...@@ -105,6 +109,10 @@ Global
{A737D901-5EC5-4593-867A-899482FAA67A}.Debug|Any CPU.Build.0 = Debug|Any CPU {A737D901-5EC5-4593-867A-899482FAA67A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A737D901-5EC5-4593-867A-899482FAA67A}.Release|Any CPU.ActiveCfg = Release|Any CPU {A737D901-5EC5-4593-867A-899482FAA67A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A737D901-5EC5-4593-867A-899482FAA67A}.Release|Any CPU.Build.0 = Release|Any CPU {A737D901-5EC5-4593-867A-899482FAA67A}.Release|Any CPU.Build.0 = Release|Any CPU
{FF7B1BD4-0F06-4D22-91EB-9140E65A87AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FF7B1BD4-0F06-4D22-91EB-9140E65A87AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FF7B1BD4-0F06-4D22-91EB-9140E65A87AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FF7B1BD4-0F06-4D22-91EB-9140E65A87AE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
...@@ -123,6 +131,7 @@ Global ...@@ -123,6 +131,7 @@ Global
{809E4C87-97F6-4DCB-9232-9C70ECEF2655} = {7AC0A4EC-3215-4FF2-96DC-DE8325ED6915} {809E4C87-97F6-4DCB-9232-9C70ECEF2655} = {7AC0A4EC-3215-4FF2-96DC-DE8325ED6915}
{5F76907A-7181-4FC5-B224-52CDD5B90359} = {52C9E4CB-A475-4232-95A3-4508B6592AC7} {5F76907A-7181-4FC5-B224-52CDD5B90359} = {52C9E4CB-A475-4232-95A3-4508B6592AC7}
{A737D901-5EC5-4593-867A-899482FAA67A} = {7AC0A4EC-3215-4FF2-96DC-DE8325ED6915} {A737D901-5EC5-4593-867A-899482FAA67A} = {7AC0A4EC-3215-4FF2-96DC-DE8325ED6915}
{FF7B1BD4-0F06-4D22-91EB-9140E65A87AE} = {5B0BC66C-B15F-4174-8966-0968C61F816F}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8763B446-FAB1-46BF-9743-F2628533241B} SolutionGuid = {8763B446-FAB1-46BF-9743-F2628533241B}
......
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