Browse Source

线程生成缴费记录

西昌缴费二期
fzp 1 year ago
parent
commit
bc905a8835
2 changed files with 124 additions and 86 deletions
  1. +123
    -83
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ReceiveSendFeeManagement/FinaChargeStuYear/FinaChargeStuYearService.cs
  2. +1
    -3
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ReceiveSendFeeManagement/FinaChargeStuYearItem/FinaChargeStuYearItemEntity.cs

+ 123
- 83
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ReceiveSendFeeManagement/FinaChargeStuYear/FinaChargeStuYearService.cs View File

@@ -223,45 +223,20 @@ namespace Learun.Application.TwoDevelopment.ReceiveSendFeeManagement
public IEnumerable<FinaChargesStandardEntity> finaChargesStandardList { get; set; }
public IEnumerable<FinaChargesStandardEntity> finaChargesStandardListGroup { get; set; }
public FinaChargeStudentEntity stuitem { get; set; }
public UserInfo userInfo { get; set; }
}

private Thread thread = null;
public void SaveGenerateByCondition(FinaChargeStuYearEntity entity)
{
try
{
//获取缴费学生
var stulist = BaseRepository("CollegeMIS").FindList<FinaChargeStudentEntity>(m => m.F_CheckMark == true);
//获取已有年度学生缴费记录
var oldFinaChargeStuYearList = BaseRepository("CollegeMIS").FindList<FinaChargeStuYearEntity>(m => m.FSYear == entity.FSYear);
//获取已有年度学生缴费明细记录
var oldFinaChargeStuYearItemList = BaseRepository("CollegeMIS").FindList<FinaChargeStuYearItemEntity>(m => m.FSYear == entity.FSYear);
//获取收费标准
var finaChargesStandardList = BaseRepository("CollegeMIS").FindList<FinaChargesStandardEntity>("select a.Grade,a.DeptNo,a.MajorNo,a.Standard,a.SYear,b.ChargeItemName,b.ChargeItemCode,b.ChargeItemType,b.priority from [dbo].[FinaChargesStandard] a left join [dbo].[FinaChargeItem] b on a.ChargeItemID=b.[ChargeItemID] where b.ChargeItemType=1 and a.SYear='" + entity.FSYear + "' and a.F_DeleteMark=0 and a.CheckMark=1 and b.CheckMark=1 and b.F_DeleteMark=0");
var finaChargesStandardListGroup = BaseRepository("CollegeMIS").FindList<FinaChargesStandardEntity>(@"select a.Grade,a.DeptNo,a.MajorNo,sum(isnull(a.Standard,0)) as YJAmount,a.SYear
from[dbo].[FinaChargesStandard] a left join[dbo].[FinaChargeItem] b on a.ChargeItemID = b.[ChargeItemID] where b.ChargeItemType=1 and a.SYear='" + entity.FSYear + "' and a.F_DeleteMark=0 and a.CheckMark=1 and b.CheckMark=1 and b.F_DeleteMark=0 group by a.Grade, a.DeptNo, a.MajorNo, a.SYear");
var innerDataEntity = new InnerDataEntity();
innerDataEntity.oldFinaChargeStuYearList = oldFinaChargeStuYearList;
innerDataEntity.oldFinaChargeStuYearItemList = oldFinaChargeStuYearItemList;
innerDataEntity.finaChargesStandardList = finaChargesStandardList;
innerDataEntity.finaChargesStandardListGroup = finaChargesStandardListGroup;
UserInfo userInfo = LoginUserInfo.Get();
InnerDataEntity innerDataEntity = new InnerDataEntity();
innerDataEntity.entity = entity;
//线程池优化生成速度
ThreadPool.SetMaxThreads(50, 50);
foreach (var stuitem in stulist)
{
innerDataEntity.stuitem = stuitem;
ThreadPool.QueueUserWorkItem(GeneralInner, innerDataEntity);
}
int t1 = 0;
int t2 = 0;
while (t1 < 50)
{
ThreadPool.GetAvailableThreads(out t1, out t2);
}
//更新学生缴费总表
BaseRepository("CollegeMIS").ExecuteBySql(@"update FinaChargeStudent set FSBlance=a.[FSBlance]
from (select isnull(sum([FSBlance]),0) as [FSBlance],StuNo from [FinaChargeStuYear] group by StuNo) a left join
FinaChargeStudent b on a.stuno=b.stuno");
innerDataEntity.userInfo = userInfo;
thread = new Thread(ThreadMethod);
thread.Start(innerDataEntity);
}
catch (Exception ex)
{
@@ -276,15 +251,64 @@ namespace Learun.Application.TwoDevelopment.ReceiveSendFeeManagement
}
}

public void ThreadMethod(object obj)
{
var innerDataobj = obj as InnerDataEntity;
var entity = innerDataobj.entity;
var userInfo = innerDataobj.userInfo;
//获取缴费学生
var stulist = BaseRepository("CollegeMIS").FindList<FinaChargeStudentEntity>(m => m.F_CheckMark == true);
//获取已有年度学生缴费记录
var oldFinaChargeStuYearList = BaseRepository("CollegeMIS").FindList<FinaChargeStuYearEntity>(m => m.FSYear == entity.FSYear);
//获取已有年度学生缴费明细记录
var oldFinaChargeStuYearItemList = BaseRepository("CollegeMIS").FindList<FinaChargeStuYearItemEntity>(m => m.FSYear == entity.FSYear);
//获取收费标准
var finaChargesStandardList = BaseRepository("CollegeMIS").FindList<FinaChargesStandardEntity>("select a.Grade,a.DeptNo,a.MajorNo,a.Standard,a.SYear,b.ChargeItemName,b.ChargeItemCode,b.ChargeItemType,b.priority from [dbo].[FinaChargesStandard] a left join [dbo].[FinaChargeItem] b on a.ChargeItemID=b.[ChargeItemID] where b.ChargeItemType=1 and a.SYear='" + entity.FSYear + "' and a.F_DeleteMark=0 and a.CheckMark=1 and b.CheckMark=1 and b.F_DeleteMark=0");
var finaChargesStandardListGroup = BaseRepository("CollegeMIS").FindList<FinaChargesStandardEntity>(@"select a.Grade,a.DeptNo,a.MajorNo,sum(isnull(a.Standard,0)) as YJAmount,a.SYear
from[dbo].[FinaChargesStandard] a left join[dbo].[FinaChargeItem] b on a.ChargeItemID = b.[ChargeItemID] where b.ChargeItemType=1 and a.SYear='" + entity.FSYear + "' and a.F_DeleteMark=0 and a.CheckMark=1 and b.CheckMark=1 and b.F_DeleteMark=0 group by a.Grade, a.DeptNo, a.MajorNo, a.SYear");
//线程池优化生成速度
ThreadPool.SetMaxThreads(10, 10);
foreach (var stuitem in stulist)
{
var innerDataEntity = new InnerDataEntity();
innerDataEntity.oldFinaChargeStuYearList = oldFinaChargeStuYearList;
innerDataEntity.oldFinaChargeStuYearItemList = oldFinaChargeStuYearItemList;
innerDataEntity.finaChargesStandardList = finaChargesStandardList;
innerDataEntity.finaChargesStandardListGroup = finaChargesStandardListGroup;
innerDataEntity.entity = entity;
innerDataEntity.userInfo = userInfo;
innerDataEntity.stuitem = stuitem;
ThreadPool.QueueUserWorkItem(GeneralInner, innerDataEntity);
}
int t1 = 0;
int t2 = 0;
while (t1 < 10)
{
ThreadPool.GetAvailableThreads(out t1, out t2);
}
//更新学生缴费总表
BaseRepository("CollegeMIS").ExecuteBySql(@"update FinaChargeStudent set NeedToPay=a.NeedToPay
from (select isnull(sum(NeedToPay),0) as NeedToPay,StuNo from [FinaChargeStuYear] group by StuNo) a left join
FinaChargeStudent b on a.stuno=b.stuno");
try
{
thread.Abort();
}
catch (Exception e)
{
}
}

public void GeneralInner(object innerobject)
{
var db = BaseRepository("CollegeMIS").BeginTrans();
var innerDataEntity = innerobject as InnerDataEntity;
var stuitem = innerDataEntity.stuitem;
var finaChargesStandardList = innerDataEntity.finaChargesStandardList;
var oldFinaChargeStuYearList = innerDataEntity.oldFinaChargeStuYearList;
var oldFinaChargeStuYearItemList = innerDataEntity.oldFinaChargeStuYearItemList;
var entity = innerDataEntity.entity;
var userInfo = innerDataEntity.userInfo;
var finaChargesStandardListGroup = innerDataEntity.finaChargesStandardListGroup;
try
{
@@ -297,50 +321,16 @@ namespace Learun.Application.TwoDevelopment.ReceiveSendFeeManagement
var oldFinaChargeStuYearItemListForStu = oldFinaChargeStuYearItemList.Where(m => m.FSYId == oldFinaChargeStuYearEntity.FSYId).Select(m => m.ChargeItemCode);
string oldcodeitem = string.Join(",", oldFinaChargeStuYearItemListForStu);
var needinsertchargeitem = studentchargestanderdlist.Where(m => !oldcodeitem.Contains(m.ChargeItemCode));
foreach (var finaChargesStandardEntity in needinsertchargeitem)
{
var finaChargeStuYearItem = new FinaChargeStuYearItemEntity();
finaChargeStuYearItem.Create();
finaChargeStuYearItem.FSYId = oldFinaChargeStuYearEntity.FSYId;
finaChargeStuYearItem.FSYear = entity.FSYear;
finaChargeStuYearItem.ChargeItemCode = finaChargesStandardEntity.ChargeItemCode;
finaChargeStuYearItem.ChargeItemName = finaChargesStandardEntity.ChargeItemName;
finaChargeStuYearItem.ChargeItemType = finaChargesStandardEntity.ChargeItemType;
finaChargeStuYearItem.priority = finaChargesStandardEntity.priority;
finaChargeStuYearItem.Standard = finaChargesStandardEntity.Standard;
finaChargeStuYearItem.NeedToPay = finaChargesStandardEntity.Standard;
//主表应缴金额更新
oldFinaChargeStuYearEntity.YJAmount += finaChargeStuYearItem.Standard;
oldFinaChargeStuYearEntity.NeedToPay += finaChargeStuYearItem.Standard;
db.Insert(finaChargeStuYearItem);
}
if (oldFinaChargeStuYearItemList.Where(m => m.FSYId == oldFinaChargeStuYearEntity.FSYId).Sum(m => m.SJAmount) > 0)
oldFinaChargeStuYearEntity.PayFeeStatus = 4;
else
{
oldFinaChargeStuYearEntity.PayFeeStatus = 0;
}
//年度学生缴费数据主表更新
db.Update(oldFinaChargeStuYearEntity);

}
else
{
if (studentchargestanderdlist.Count() > 0)
var db = BaseRepository("CollegeMIS").BeginTrans();
try
{
//写入学生年度缴费数据
var finaChargeStuYear = new FinaChargeStuYearEntity();
finaChargeStuYear.Create();
finaChargeStuYear.StuNo = stuitem.StuNo;
finaChargeStuYear.FSYear = entity.FSYear;
finaChargeStuYear.SJAmount = 0;
finaChargeStuYear.PayFeeStatus = 0;
//写入年度缴费明细数据
foreach (var finaChargesStandardEntity in studentchargestanderdlist)
foreach (var finaChargesStandardEntity in needinsertchargeitem)
{
var finaChargeStuYearItem = new FinaChargeStuYearItemEntity();
finaChargeStuYearItem.Create();
finaChargeStuYearItem.FSYId = finaChargeStuYear.FSYId;
finaChargeStuYearItem.F_CreateUserId = userInfo.userId;
finaChargeStuYearItem.F_CreateUserName = userInfo.realName;
finaChargeStuYearItem.FSYId = oldFinaChargeStuYearEntity.FSYId;
finaChargeStuYearItem.FSYear = entity.FSYear;
finaChargeStuYearItem.ChargeItemCode = finaChargesStandardEntity.ChargeItemCode;
finaChargeStuYearItem.ChargeItemName = finaChargesStandardEntity.ChargeItemName;
@@ -348,21 +338,73 @@ namespace Learun.Application.TwoDevelopment.ReceiveSendFeeManagement
finaChargeStuYearItem.priority = finaChargesStandardEntity.priority;
finaChargeStuYearItem.Standard = finaChargesStandardEntity.Standard;
finaChargeStuYearItem.NeedToPay = finaChargesStandardEntity.Standard;
finaChargeStuYearItem.FSBlance = 0;
//主表应缴金额更新
oldFinaChargeStuYearEntity.YJAmount += finaChargeStuYearItem.Standard;
oldFinaChargeStuYearEntity.NeedToPay += finaChargeStuYearItem.Standard;
db.Insert(finaChargeStuYearItem);
}
finaChargeStuYear.YJAmount = finaChargesStandardListGroup.FirstOrDefault(m => m.DeptNo == stuitem.DeptNo && m.MajorNo == stuitem.MajorNo && m.Grade == stuitem.Grade)?.YJAmount;
finaChargeStuYear.NeedToPay = finaChargeStuYear.YJAmount;
finaChargeStuYear.FSBlance = 0;

db.Insert(finaChargeStuYear);
if (oldFinaChargeStuYearItemList.Where(m => m.FSYId == oldFinaChargeStuYearEntity.FSYId).Sum(m => m.SJAmount) > 0)
oldFinaChargeStuYearEntity.PayFeeStatus = 4;
else
{
oldFinaChargeStuYearEntity.PayFeeStatus = 0;
}
//年度学生缴费数据主表更新
db.Update(oldFinaChargeStuYearEntity);
db.Commit();
}
catch (Exception e)
{
db.Rollback();
}
}
else
{
if (studentchargestanderdlist.Count() > 0)
{
var db = BaseRepository("CollegeMIS").BeginTrans();
try
{
//写入学生年度缴费数据
var finaChargeStuYear = new FinaChargeStuYearEntity();
finaChargeStuYear.Create();
finaChargeStuYear.StuNo = stuitem.StuNo;
finaChargeStuYear.FSYear = entity.FSYear;
finaChargeStuYear.SJAmount = 0;
finaChargeStuYear.PayFeeStatus = 0;
//写入年度缴费明细数据
foreach (var finaChargesStandardEntity in studentchargestanderdlist)
{
var finaChargeStuYearItem = new FinaChargeStuYearItemEntity();
finaChargeStuYearItem.Create();
finaChargeStuYearItem.F_CreateUserId = userInfo.userId;
finaChargeStuYearItem.F_CreateUserName = userInfo.realName;
finaChargeStuYearItem.FSYId = finaChargeStuYear.FSYId;
finaChargeStuYearItem.FSYear = entity.FSYear;
finaChargeStuYearItem.ChargeItemCode = finaChargesStandardEntity.ChargeItemCode;
finaChargeStuYearItem.ChargeItemName = finaChargesStandardEntity.ChargeItemName;
finaChargeStuYearItem.ChargeItemType = finaChargesStandardEntity.ChargeItemType;
finaChargeStuYearItem.priority = finaChargesStandardEntity.priority;
finaChargeStuYearItem.Standard = finaChargesStandardEntity.Standard;
finaChargeStuYearItem.NeedToPay = finaChargesStandardEntity.Standard;
finaChargeStuYearItem.FSBlance = 0;
db.Insert(finaChargeStuYearItem);
}
finaChargeStuYear.YJAmount = finaChargesStandardListGroup.FirstOrDefault(m => m.DeptNo == stuitem.DeptNo && m.MajorNo == stuitem.MajorNo && m.Grade == stuitem.Grade)?.YJAmount;
finaChargeStuYear.NeedToPay = finaChargeStuYear.YJAmount;
finaChargeStuYear.FSBlance = 0;
db.Insert(finaChargeStuYear);
db.Commit();
}
catch (Exception e)
{
db.Rollback();
}
}
}
db.Commit();
}
catch (Exception ex)
{
db.Rollback();
if (ex is ExceptionEx)
{
throw;
@@ -372,8 +414,6 @@ namespace Learun.Application.TwoDevelopment.ReceiveSendFeeManagement
throw ExceptionEx.ThrowServiceException(ex);
}
}

}

public IEnumerable<FinaChargeStuYearEntity> GetYearList()


+ 1
- 3
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ReceiveSendFeeManagement/FinaChargeStuYearItem/FinaChargeStuYearItemEntity.cs View File

@@ -107,14 +107,12 @@ namespace Learun.Application.TwoDevelopment.ReceiveSendFeeManagement
{
this.FSYIId = Guid.NewGuid().ToString();
this.F_CreateDate = DateTime.Now;
UserInfo userInfo = LoginUserInfo.Get();
F_DeleteMark = false;
SJAmount = 0;
PayFeeStatus = 0;
FSBlance = 0;
NeedToPay = 0;
this.F_CreateUserId = userInfo.userId;
this.F_CreateUserName = userInfo.realName;
RefundStatus = false;
}
/// <summary>


Loading…
Cancel
Save