20230606新增费用申请页面、项目列表按活跃度排序
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
using System;
|
||||
using Microsoft.SqlServer.Dts.Runtime;
|
||||
using Model;
|
||||
using NPOI.SS.UserModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BLL
|
||||
@@ -21,13 +25,26 @@ namespace BLL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据项目Id,单位Id和月份获取安全费用管理
|
||||
/// 获取 已支付的HSE费用
|
||||
/// </summary>
|
||||
/// <param name="costManageId"></param>
|
||||
/// <param name="ProjectId"></param>
|
||||
/// <param name="UnitId"></param>
|
||||
/// <returns></returns>
|
||||
public static Model.CostGoods_CostManage GetCostManageByUnitIdAndDate(string projectId, string unidId, DateTime date)
|
||||
public static decimal GetSumHSECost(string ProjectId, string UnitId, string costManageId )
|
||||
{
|
||||
return Funs.DB.CostGoods_CostManage.FirstOrDefault(e => e.CostManageId == projectId && e.UnitId == unidId && e.CostManageDate.Value.Year == date.Year && e.CostManageDate.Value.Month == date.Month);
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
decimal sumCost = 0;
|
||||
var getData = from x in db.CostGoods_CostManage
|
||||
where x.ProjectId == ProjectId && x.UnitId == UnitId && x.States == Const.State_2 && x.CostManageId != costManageId
|
||||
select x;
|
||||
if (getData.Count() > 0)
|
||||
{
|
||||
sumCost = getData.Sum(x => x.SumMoney ?? 0);
|
||||
}
|
||||
|
||||
return sumCost;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -36,26 +53,32 @@ namespace BLL
|
||||
/// <param name="costManage"></param>
|
||||
public static void AddCostManage(Model.CostGoods_CostManage costManage)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.CostGoods_CostManage newCostManage = new Model.CostGoods_CostManage
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
CostManageId = costManage.CostManageId,
|
||||
ProjectId = costManage.ProjectId,
|
||||
CostManageCode = costManage.CostManageCode,
|
||||
CostManageName = costManage.CostManageName,
|
||||
UnitId = costManage.UnitId,
|
||||
ContractNum = costManage.ContractNum,
|
||||
CostManageDate = costManage.CostManageDate,
|
||||
Opinion = costManage.Opinion,
|
||||
SubCN = costManage.SubCN,
|
||||
SubHSE = costManage.SubHSE,
|
||||
SubProject = costManage.SubProject,
|
||||
States = costManage.States,
|
||||
CompileMan = costManage.CompileMan,
|
||||
CompileDate = costManage.CompileDate
|
||||
};
|
||||
db.CostGoods_CostManage.InsertOnSubmit(newCostManage);
|
||||
db.SubmitChanges();
|
||||
Model.CostGoods_CostManage newCostManage = new Model.CostGoods_CostManage
|
||||
{
|
||||
CostManageId = costManage.CostManageId,
|
||||
ProjectId = costManage.ProjectId,
|
||||
CostManageCode = costManage.CostManageCode,
|
||||
CostManageName = costManage.CostManageName,
|
||||
UnitId = costManage.UnitId,
|
||||
ContractNum = costManage.ContractNum,
|
||||
CostManageDate = costManage.CostManageDate,
|
||||
Opinion = costManage.Opinion,
|
||||
SubCN = costManage.SubCN,
|
||||
SubHSE = costManage.SubHSE,
|
||||
SubProject = costManage.SubProject,
|
||||
States = costManage.States,
|
||||
CompileMan = costManage.CompileMan,
|
||||
CompileDate = costManage.CompileDate
|
||||
};
|
||||
|
||||
db.CostGoods_CostManage.InsertOnSubmit(newCostManage);
|
||||
db.SubmitChanges();
|
||||
|
||||
AddCostManageFlowOperate(newCostManage);
|
||||
}
|
||||
|
||||
CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(Const.ProjectCostManageMenuId, costManage.ProjectId, null, costManage.CostManageId, costManage.CompileDate);
|
||||
}
|
||||
|
||||
@@ -65,24 +88,25 @@ namespace BLL
|
||||
/// <param name="costManage"></param>
|
||||
public static void UpdateCostManage(Model.CostGoods_CostManage costManage)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.CostGoods_CostManage newCostManage = db.CostGoods_CostManage.FirstOrDefault(e => e.CostManageId == costManage.CostManageId);
|
||||
if (newCostManage != null)
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
//newCostManage.ProjectId = costManage.ProjectId;
|
||||
newCostManage.CostManageCode = costManage.CostManageCode;
|
||||
newCostManage.CostManageName = costManage.CostManageName;
|
||||
newCostManage.UnitId = costManage.UnitId;
|
||||
newCostManage.ContractNum = costManage.ContractNum;
|
||||
newCostManage.CostManageDate = costManage.CostManageDate;
|
||||
newCostManage.Opinion = costManage.Opinion;
|
||||
newCostManage.SubCN = costManage.SubCN;
|
||||
newCostManage.SubHSE = costManage.SubHSE;
|
||||
newCostManage.SubProject = costManage.SubProject;
|
||||
newCostManage.States = costManage.States;
|
||||
newCostManage.CompileMan = costManage.CompileMan;
|
||||
newCostManage.CompileDate = costManage.CompileDate;
|
||||
db.SubmitChanges();
|
||||
Model.CostGoods_CostManage newCostManage = db.CostGoods_CostManage.FirstOrDefault(e => e.CostManageId == costManage.CostManageId);
|
||||
if (newCostManage != null)
|
||||
{
|
||||
//newCostManage.ProjectId = costManage.ProjectId;
|
||||
newCostManage.CostManageName = costManage.CostManageName;
|
||||
newCostManage.UnitId = costManage.UnitId;
|
||||
newCostManage.ContractNum = costManage.ContractNum;
|
||||
newCostManage.CostManageDate = costManage.CostManageDate;
|
||||
newCostManage.Opinion = costManage.Opinion;
|
||||
newCostManage.SubCN = costManage.SubCN;
|
||||
newCostManage.SubHSE = costManage.SubHSE;
|
||||
newCostManage.SubProject = costManage.SubProject;
|
||||
newCostManage.States = costManage.States;
|
||||
newCostManage.CompileMan = costManage.CompileMan;
|
||||
newCostManage.CompileDate = costManage.CompileDate;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,16 +116,254 @@ namespace BLL
|
||||
/// <param name="costManageId"></param>
|
||||
public static void DeleteCostManageById(string costManageId)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.CostGoods_CostManage costManage = db.CostGoods_CostManage.FirstOrDefault(e => e.CostManageId == costManageId);
|
||||
if (costManage != null)
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
CodeRecordsService.DeleteCodeRecordsByDataId(costManageId);//删除编号
|
||||
ProjectDataFlowSetService.DeleteFlowSetByDataId(costManageId);//删除流程
|
||||
CommonService.DeleteFlowOperateByID(costManageId); //删除审核流程
|
||||
CommonService.DeleteAttachFileById(costManageId);//删除附件
|
||||
db.CostGoods_CostManage.DeleteOnSubmit(costManage);
|
||||
db.SubmitChanges();
|
||||
var costManage = db.CostGoods_CostManage.FirstOrDefault(e => e.CostManageId == costManageId);
|
||||
if (costManage != null)
|
||||
{
|
||||
deleteCostManageFlowOperate(costManageId);
|
||||
CommonService.DeleteAttachFileById(costManageId);//删除附件
|
||||
db.CostGoods_CostManage.DeleteOnSubmit(costManage);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按照明细取当前单据总费用
|
||||
/// </summary>
|
||||
/// <param name="costManageId"></param>
|
||||
public static void UpdateSumMoney(string costManageId)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var costManage = db.CostGoods_CostManage.FirstOrDefault(e => e.CostManageId == costManageId);
|
||||
if (costManage != null)
|
||||
{
|
||||
decimal sumC = 0;
|
||||
var getItems = db.CostGoods_CostManageItem.Where(x => x.CostManageId == costManageId);
|
||||
if (getItems.Count() > 0)
|
||||
{
|
||||
sumC = getItems.Sum(x => x.PriceMoney ?? 0);
|
||||
}
|
||||
costManage.SumMoney = sumC;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据主表ID获取审核列表
|
||||
/// </summary>
|
||||
/// <param name="costManageId"></param>
|
||||
/// <returns></returns>
|
||||
public static List<Model.CostGoods_CostManageFlowOperate> getCostManageFlowOperateList(string costManageId)
|
||||
{
|
||||
return (from x in Funs.DB.CostGoods_CostManageFlowOperate
|
||||
where x.CostManageId == costManageId
|
||||
orderby x.SortIndex
|
||||
select x).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前步骤审核人
|
||||
/// </summary>
|
||||
/// <param name="costManageId"></param>
|
||||
/// <returns></returns>
|
||||
public static Model.CostGoods_CostManageFlowOperate getNowCostManageFlowOperateList(string costManageId)
|
||||
{
|
||||
var getAllNoClose = Funs.DB.CostGoods_CostManageFlowOperate.Where(x => x.CostManageId == costManageId && (x.IsClosed == null || x.IsClosed == false));
|
||||
if (getAllNoClose.Count() > 0)
|
||||
{
|
||||
var minSortIndex = getAllNoClose.Min(x => x.SortIndex) ?? 0;
|
||||
return getAllNoClose.FirstOrDefault(x => x.SortIndex == minSortIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取下一步审核人
|
||||
/// </summary>
|
||||
/// <param name="costManageId"></param>
|
||||
/// <returns></returns>
|
||||
public static Model.CostGoods_CostManageFlowOperate getNextCostManageFlowOperateList(string costManageId,string operaterId)
|
||||
{
|
||||
int minSortIndex = 1;
|
||||
var getAllNoClose = Funs.DB.CostGoods_CostManageFlowOperate.Where(x => x.CostManageId == costManageId && (x.IsClosed == null || x.IsClosed == false));
|
||||
if (getAllNoClose.Count() > 0)
|
||||
{
|
||||
var getFlowOperate = getAllNoClose.Where(x => x.OperaterId == operaterId);
|
||||
if (getFlowOperate.Count() > 0)
|
||||
{
|
||||
minSortIndex = (getFlowOperate.Min(x => x.SortIndex) ?? 0) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
minSortIndex = getAllNoClose.Min(x => x.SortIndex) ?? 1;
|
||||
}
|
||||
|
||||
return getAllNoClose.FirstOrDefault(x => x.SortIndex == minSortIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据新增费用申请表 自动生成审核流程表
|
||||
/// </summary>
|
||||
public static void AddCostManageFlowOperate(Model.CostGoods_CostManage costManage)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
List<Model.CostGoods_CostManageFlowOperate> flowList = new List<CostGoods_CostManageFlowOperate>();
|
||||
/// 施工单位
|
||||
if (ProjectUnitService.GetProjectUnitTypeByProjectIdUnitId(costManage.ProjectId, costManage.UnitId))
|
||||
{
|
||||
string cUnitId = Const.UnitId_SEDIN;
|
||||
var getUnit = db.Project_ProjectUnit.FirstOrDefault(x => x.ProjectId == costManage.ProjectId && x.UnitType == Const.ProjectUnitType_1);
|
||||
if (getUnit != null && !string.IsNullOrEmpty(getUnit.UnitId))
|
||||
{
|
||||
cUnitId = getUnit.UnitId;
|
||||
}
|
||||
|
||||
//// 分包单位项目经理审批、总包单位HSE经理审核、总包单位项目控制经理审核、总包单位项目经理审批
|
||||
var Flow1 = new CostGoods_CostManageFlowOperate()
|
||||
{
|
||||
FlowOperateId = SQLHelper.GetNewID(),
|
||||
CostManageId = costManage.CostManageId,
|
||||
AuditFlowName = "分包单位项目经理审批",
|
||||
SortIndex = 1,
|
||||
UnitId = costManage.UnitId,
|
||||
IsClosed = false,
|
||||
};
|
||||
flowList.Add(Flow1);
|
||||
|
||||
var Flow2 = new CostGoods_CostManageFlowOperate()
|
||||
{
|
||||
FlowOperateId = SQLHelper.GetNewID(),
|
||||
CostManageId = costManage.CostManageId,
|
||||
AuditFlowName = "总包单位HSE经理审核",
|
||||
SortIndex = 2,
|
||||
UnitId = cUnitId,
|
||||
IsClosed = false,
|
||||
};
|
||||
flowList.Add(Flow2);
|
||||
|
||||
var Flow3 = new CostGoods_CostManageFlowOperate()
|
||||
{
|
||||
FlowOperateId = SQLHelper.GetNewID(),
|
||||
CostManageId = costManage.CostManageId,
|
||||
AuditFlowName = "总包单位项目控制经理审核",
|
||||
SortIndex = 3,
|
||||
UnitId = cUnitId,
|
||||
IsClosed = false,
|
||||
};
|
||||
flowList.Add(Flow3);
|
||||
|
||||
var Flow4 = new CostGoods_CostManageFlowOperate()
|
||||
{
|
||||
FlowOperateId = SQLHelper.GetNewID(),
|
||||
CostManageId = costManage.CostManageId,
|
||||
AuditFlowName = "总包单位项目经理审批",
|
||||
SortIndex = 4,
|
||||
UnitId = cUnitId,
|
||||
IsClosed = false,
|
||||
};
|
||||
flowList.Add(Flow4);
|
||||
|
||||
}
|
||||
else ///非施工单位
|
||||
{
|
||||
////安全工程师发起、安全经理审核、项目经理批准
|
||||
var Flow1 = new CostGoods_CostManageFlowOperate()
|
||||
{
|
||||
FlowOperateId = SQLHelper.GetNewID(),
|
||||
CostManageId = costManage.CostManageId,
|
||||
AuditFlowName = "安全经理审核",
|
||||
SortIndex = 1,
|
||||
UnitId = costManage.UnitId,
|
||||
IsClosed = false,
|
||||
};
|
||||
flowList.Add(Flow1);
|
||||
|
||||
var Flow2 = new CostGoods_CostManageFlowOperate()
|
||||
{
|
||||
FlowOperateId = SQLHelper.GetNewID(),
|
||||
CostManageId = costManage.CostManageId,
|
||||
AuditFlowName = "项目经理批准",
|
||||
SortIndex = 2,
|
||||
UnitId = costManage.UnitId,
|
||||
IsClosed = false,
|
||||
};
|
||||
|
||||
flowList.Add(Flow2);
|
||||
}
|
||||
|
||||
if (flowList.Count() > 0)
|
||||
{
|
||||
db.CostGoods_CostManageFlowOperate.InsertAllOnSubmit(flowList);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 审核意见更新
|
||||
/// </summary>
|
||||
/// <param name="flow"></param>
|
||||
public static void updateCostManageFlowOperate(Model.CostGoods_CostManageFlowOperate flow)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var getData = db.CostGoods_CostManageFlowOperate.FirstOrDefault(x => x.FlowOperateId == flow.FlowOperateId);
|
||||
if (getData != null)
|
||||
{
|
||||
getData.OperaterId = flow.OperaterId;
|
||||
getData.OperaterTime = flow.OperaterTime;
|
||||
getData.IsAgree = flow.IsAgree;
|
||||
getData.Opinion = flow.Opinion;
|
||||
getData.IsClosed = flow.IsClosed;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 所以关闭步骤 打开
|
||||
/// </summary>
|
||||
/// <param name="flow"></param>
|
||||
public static void updateOpenCostManageFlowOperate(string costManageId)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var getDatas = db.CostGoods_CostManageFlowOperate.Where(x => x.CostManageId == costManageId && x.IsClosed==true);
|
||||
foreach ( var item in getDatas)
|
||||
{
|
||||
item.IsClosed= false;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="costMangeId"></param>
|
||||
public static void deleteCostManageFlowOperate(string costManageId)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var getData = db.CostGoods_CostManageFlowOperate.Where(x => x.CostManageId == costManageId);
|
||||
if (getData.Count() > 0)
|
||||
{
|
||||
db.CostGoods_CostManageFlowOperate.DeleteAllOnSubmit(getData);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user