2022-09-05 16:36:31 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
|
|
namespace BLL
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 措施费用使用计划
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static class ExpenseService
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据主键获取措施费用使用计划
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="expenseId"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static Model.CostGoods_Expense GetExpenseById(string expenseId)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Funs.DB.CostGoods_Expense.FirstOrDefault(e => e.ExpenseId == expenseId);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-29 09:09:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据主键获取措施费用使用计划
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="expenseId"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static List<Model.CostGoods_Expense> GetExpenseList(string projectId, string unitId, int? year)
|
|
|
|
|
|
{
|
|
|
|
|
|
var getData = from x in Funs.DB.CostGoods_Expense
|
|
|
|
|
|
where x.ProjectId == projectId
|
|
|
|
|
|
select x;
|
|
|
|
|
|
if (!string.IsNullOrEmpty(unitId) && unitId != Const._Null)
|
|
|
|
|
|
{
|
2025-10-10 14:33:21 +08:00
|
|
|
|
getData = getData.Where(x => x.UnitId == unitId);
|
2023-05-29 09:09:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (year.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
getData = getData.Where(x => x.Year == year);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return getData.OrderBy(x => x.SortIndex).ToList();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-05 16:36:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据时间获取当期单位Id集合
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="startTime"></param>
|
|
|
|
|
|
/// <param name="endTime"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static List<string> GetUnitIdsByTime(DateTime startTime, DateTime endTime, string projectId)
|
|
|
|
|
|
{
|
|
|
|
|
|
return (from x in Funs.DB.CostGoods_Expense
|
|
|
|
|
|
join y in Funs.DB.Sys_FlowOperate
|
|
|
|
|
|
on x.ExpenseId equals y.DataId
|
|
|
|
|
|
where x.States == BLL.Const.State_2 && x.ProjectId == projectId && y.State == BLL.Const.State_2 && y.OperaterTime >= startTime && y.OperaterTime < endTime
|
|
|
|
|
|
select x.UnitId).Distinct().ToList();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 添加措施费用使用计划
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="expense"></param>
|
|
|
|
|
|
public static void AddExpense(Model.CostGoods_Expense expense)
|
|
|
|
|
|
{
|
|
|
|
|
|
Model.SGGLDB db = Funs.DB;
|
|
|
|
|
|
Model.CostGoods_Expense newExpense = new Model.CostGoods_Expense
|
|
|
|
|
|
{
|
|
|
|
|
|
ExpenseId = expense.ExpenseId,
|
|
|
|
|
|
ProjectId = expense.ProjectId,
|
|
|
|
|
|
ExpenseCode = expense.ExpenseCode,
|
|
|
|
|
|
UnitId = expense.UnitId,
|
2025-10-10 14:33:21 +08:00
|
|
|
|
ReportDate = expense.ReportDate,
|
2022-09-05 16:36:31 +08:00
|
|
|
|
CreateDate = expense.CreateDate,
|
|
|
|
|
|
States = expense.States,
|
2025-10-10 14:33:21 +08:00
|
|
|
|
CompileMan = expense.CompileMan,
|
2022-09-05 16:36:31 +08:00
|
|
|
|
CompileDate = expense.CompileDate,
|
2023-05-29 09:09:30 +08:00
|
|
|
|
SortIndex = expense.SortIndex,
|
|
|
|
|
|
Year = expense.Year,
|
2022-09-05 16:36:31 +08:00
|
|
|
|
};
|
|
|
|
|
|
db.CostGoods_Expense.InsertOnSubmit(newExpense);
|
|
|
|
|
|
db.SubmitChanges();
|
2023-05-29 09:09:30 +08:00
|
|
|
|
|
2022-09-05 16:36:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 修改措施费用使用计划
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="expense"></param>
|
|
|
|
|
|
public static void UpdateExpense(Model.CostGoods_Expense expense)
|
|
|
|
|
|
{
|
|
|
|
|
|
Model.SGGLDB db = Funs.DB;
|
|
|
|
|
|
Model.CostGoods_Expense newExpense = db.CostGoods_Expense.FirstOrDefault(e => e.ExpenseId == expense.ExpenseId);
|
|
|
|
|
|
if (newExpense != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
//newExpense.ProjectId = expense.ProjectId;
|
|
|
|
|
|
newExpense.ExpenseCode = expense.ExpenseCode;
|
2025-10-10 14:33:21 +08:00
|
|
|
|
newExpense.UnitId = expense.UnitId;
|
2022-09-05 16:36:31 +08:00
|
|
|
|
newExpense.States = expense.States;
|
|
|
|
|
|
newExpense.Months = expense.Months;
|
|
|
|
|
|
newExpense.ReportDate = expense.ReportDate;
|
|
|
|
|
|
newExpense.PlanCostA = expense.PlanCostA;
|
|
|
|
|
|
newExpense.PlanCostB = expense.PlanCostB;
|
|
|
|
|
|
newExpense.CompileDate = expense.CompileDate;
|
2023-05-29 09:09:30 +08:00
|
|
|
|
newExpense.CompileMan = expense.CompileMan;
|
2022-09-05 16:36:31 +08:00
|
|
|
|
//newExpense.CheckMan = expense.CheckMan;
|
2023-05-29 09:09:30 +08:00
|
|
|
|
//newExpense.CheckDate = expense.CheckDate;
|
2022-09-05 16:36:31 +08:00
|
|
|
|
//newExpense.ApproveMan = expense.ApproveMan;
|
2023-05-29 09:09:30 +08:00
|
|
|
|
// newExpense.ApproveDate = expense.ApproveDate;
|
|
|
|
|
|
newExpense.SortIndex = expense.SortIndex;
|
|
|
|
|
|
newExpense.Year = expense.Year;
|
2022-09-05 16:36:31 +08:00
|
|
|
|
db.SubmitChanges();
|
2023-05-29 09:09:30 +08:00
|
|
|
|
|
2022-09-05 16:36:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据主键删除措施费用使用计划
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="expenseId"></param>
|
|
|
|
|
|
public static void DeleteExpenseById(string expenseId)
|
|
|
|
|
|
{
|
|
|
|
|
|
Model.SGGLDB db = Funs.DB;
|
|
|
|
|
|
Model.CostGoods_Expense expense = db.CostGoods_Expense.FirstOrDefault(e => e.ExpenseId == expenseId);
|
|
|
|
|
|
if (expense != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
BLL.CodeRecordsService.DeleteCodeRecordsByDataId(expenseId);
|
|
|
|
|
|
BLL.CommonService.DeleteAttachFileById(expenseId);
|
|
|
|
|
|
////删除审核流程表
|
|
|
|
|
|
BLL.CommonService.DeleteFlowOperateByID(expenseId);
|
|
|
|
|
|
db.CostGoods_Expense.DeleteOnSubmit(expense);
|
|
|
|
|
|
db.SubmitChanges();
|
2023-05-29 09:09:30 +08:00
|
|
|
|
|
|
|
|
|
|
if (expense.Year.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetSumYearExpense(expense.ProjectId, expense.Year.Value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 当前合计数
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="projectId"></param>
|
|
|
|
|
|
/// <param name="Year"></param>
|
2025-10-10 14:33:21 +08:00
|
|
|
|
public static void SetSumYearExpense(string projectId, int Year)
|
2023-05-29 09:09:30 +08:00
|
|
|
|
{
|
2025-10-10 14:33:21 +08:00
|
|
|
|
var getYearEx = Funs.DB.CostGoods_Expense.FirstOrDefault(x => x.ProjectId == projectId && x.Year == Year && x.UnitId == null);
|
2023-05-29 09:09:30 +08:00
|
|
|
|
if (getYearEx != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Funs.DB.CostGoods_Expense.DeleteOnSubmit(getYearEx);
|
|
|
|
|
|
Funs.DB.SubmitChanges();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-10 14:33:21 +08:00
|
|
|
|
var getALLEx = from x in Funs.DB.CostGoods_Expense where x.ProjectId == projectId && x.Year == Year && x.UnitId != null select x;
|
2023-05-29 09:09:30 +08:00
|
|
|
|
if (getALLEx.Count() > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
Model.CostGoods_Expense newExpense = new Model.CostGoods_Expense
|
|
|
|
|
|
{
|
|
|
|
|
|
ExpenseId = SQLHelper.GetNewID(),
|
|
|
|
|
|
ProjectId = projectId,
|
|
|
|
|
|
UnitId = null,
|
|
|
|
|
|
CreateDate = DateTime.Now,
|
|
|
|
|
|
Months = DateTime.Now,
|
|
|
|
|
|
ReportDate = DateTime.Now,
|
|
|
|
|
|
CompileDate = DateTime.Now,
|
|
|
|
|
|
CheckDate = DateTime.Now,
|
|
|
|
|
|
ApproveDate = DateTime.Now,
|
|
|
|
|
|
SortIndex = 0,
|
|
|
|
|
|
Year = Year,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-01-07 19:00:48 +08:00
|
|
|
|
var db1 = Funs.DB;
|
|
|
|
|
|
db1.CostGoods_Expense.InsertOnSubmit(newExpense);
|
|
|
|
|
|
db1.SubmitChanges();
|
2022-09-05 16:36:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|