2023-08-25
This commit is contained in:
@@ -0,0 +1,327 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using EmitMapper;
|
||||
using FineUIPro;
|
||||
using MiniExcelLibs;
|
||||
using MiniExcelLibs.Attributes;
|
||||
using Model;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public static class PHTGL_ContractTrackService
|
||||
{
|
||||
#region 获取列表
|
||||
|
||||
/// <summary>
|
||||
/// 记录数
|
||||
/// </summary>
|
||||
public static int Count { get; set; }
|
||||
|
||||
public static List<PHTGL_ContractTrack> GetPHTGL_ContractTrackByModle(PHTGL_ContractTrack table)
|
||||
{
|
||||
var q = from x in Funs.DB.PHTGL_ContractTrack
|
||||
where
|
||||
(string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) &&
|
||||
(string.IsNullOrEmpty(table.ContractNum) || x.ContractNum.Contains(table.ContractNum)) &&
|
||||
(string.IsNullOrEmpty(table.MainItemCode) || x.MainItemCode.Contains(table.MainItemCode)) &&
|
||||
(string.IsNullOrEmpty(table.MainItemName) || x.MainItemName.Contains(table.MainItemName)) &&
|
||||
(string.IsNullOrEmpty(table.MajorName) || x.MajorName.Contains(table.MajorName)) &&
|
||||
(string.IsNullOrEmpty(table.MajorCode) || x.MajorCode.Contains(table.MajorCode)) &&
|
||||
(string.IsNullOrEmpty(table.SubProject) || x.SubProject.Contains(table.SubProject)) &&
|
||||
(string.IsNullOrEmpty(table.SubItemProject) ||
|
||||
x.SubItemProject.Contains(table.SubItemProject)) &&
|
||||
(string.IsNullOrEmpty(table.ProjectCode) || x.ProjectCode.Contains(table.ProjectCode)) &&
|
||||
(string.IsNullOrEmpty(table.ProjectName) || x.ProjectName.Contains(table.ProjectName)) &&
|
||||
(string.IsNullOrEmpty(table.ProjectDescription) ||
|
||||
x.ProjectDescription.Contains(table.ProjectDescription)) &&
|
||||
(string.IsNullOrEmpty(table.UnitOfMeasurement) ||
|
||||
x.UnitOfMeasurement.Contains(table.UnitOfMeasurement)) &&
|
||||
(string.IsNullOrEmpty(table.Quantity) || x.Quantity.Contains(table.Quantity)) &&
|
||||
(string.IsNullOrEmpty(table.TotalCostFixedComprehensiveUnitPrice) ||
|
||||
x.TotalCostFixedComprehensiveUnitPrice.Contains(table.TotalCostFixedComprehensiveUnitPrice)) &&
|
||||
(string.IsNullOrEmpty(table.MainMaterialCost) ||
|
||||
x.MainMaterialCost.Contains(table.MainMaterialCost)) &&
|
||||
(string.IsNullOrEmpty(table.TotalPrice) || x.TotalPrice.Contains(table.TotalPrice)) &&
|
||||
(string.IsNullOrEmpty(table.CalculationRule) ||
|
||||
x.CalculationRule.Contains(table.CalculationRule)) &&
|
||||
(string.IsNullOrEmpty(table.WorkContent) || x.WorkContent.Contains(table.WorkContent)) &&
|
||||
(string.IsNullOrEmpty(table.Remarks) || x.Remarks.Contains(table.Remarks)) &&
|
||||
(string.IsNullOrEmpty(table.ConstructionSubcontractor) ||
|
||||
x.ConstructionSubcontractor.Contains(table.ConstructionSubcontractor)) &&
|
||||
(string.IsNullOrEmpty(table.ContractWeight) ||
|
||||
x.ContractWeight.Contains(table.ContractWeight)) &&
|
||||
(string.IsNullOrEmpty(table.MaterialSupplier) ||
|
||||
x.MaterialSupplier.Contains(table.MaterialSupplier)) &&
|
||||
(string.IsNullOrEmpty(table.EstimatedQuantity) ||
|
||||
x.EstimatedQuantity.Contains(table.EstimatedQuantity)) &&
|
||||
(string.IsNullOrEmpty(table.SettledQuantity) ||
|
||||
x.SettledQuantity.Contains(table.SettledQuantity)) &&
|
||||
(string.IsNullOrEmpty(table.ContractId) ||
|
||||
x.ContractId.Contains(table.ContractId))
|
||||
select x
|
||||
;
|
||||
|
||||
return q.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取分页列表
|
||||
/// </summary>
|
||||
/// <param name="table"></param>
|
||||
/// <param name="grid1"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable GetListData(PHTGL_ContractTrack table, Grid grid1)
|
||||
{
|
||||
var q = GetPHTGL_ContractTrackByModle(table);
|
||||
Count = q.Count();
|
||||
if (Count == 0) return null;
|
||||
q = q.Skip(grid1.PageSize * grid1.PageIndex).Take(grid1.PageSize).ToList();
|
||||
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
||||
return from x in q
|
||||
select new
|
||||
{
|
||||
x.Id,
|
||||
x.ContractNum,
|
||||
x.MainItemCode,
|
||||
x.MainItemName,
|
||||
x.MajorName,
|
||||
x.MajorCode,
|
||||
x.SubProject,
|
||||
x.SubItemProject,
|
||||
x.ProjectCode,
|
||||
x.ProjectName,
|
||||
x.ProjectDescription,
|
||||
x.UnitOfMeasurement,
|
||||
x.Quantity,
|
||||
x.TotalCostFixedComprehensiveUnitPrice,
|
||||
x.MainMaterialCost,
|
||||
x.TotalPrice,
|
||||
x.CalculationRule,
|
||||
x.WorkContent,
|
||||
x.Remarks,
|
||||
x.ConstructionSubcontractor,
|
||||
x.ContractWeight,
|
||||
x.MaterialSupplier,
|
||||
x.IsWithinGeneralContractScope,
|
||||
x.EstimatedQuantity,
|
||||
x.EstimatedAmount,
|
||||
x.SettledQuantity,
|
||||
x.SettledAmount,
|
||||
x.ContractId
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public static PHTGL_ContractTrack GetPHTGL_ContractTrackById(string id)
|
||||
{
|
||||
return Funs.DB.PHTGL_ContractTrack.FirstOrDefault(x => x.Id == id);
|
||||
}
|
||||
|
||||
|
||||
public static void AddPHTGL_ContractTrack(PHTGL_ContractTrack newtable)
|
||||
{
|
||||
var table = new PHTGL_ContractTrack
|
||||
{
|
||||
Id = newtable.Id,
|
||||
ContractNum = newtable.ContractNum,
|
||||
MainItemCode = newtable.MainItemCode,
|
||||
MainItemName = newtable.MainItemName,
|
||||
MajorName = newtable.MajorName,
|
||||
MajorCode = newtable.MajorCode,
|
||||
SubProject = newtable.SubProject,
|
||||
SubItemProject = newtable.SubItemProject,
|
||||
ProjectCode = newtable.ProjectCode,
|
||||
ProjectName = newtable.ProjectName,
|
||||
ProjectDescription = newtable.ProjectDescription,
|
||||
UnitOfMeasurement = newtable.UnitOfMeasurement,
|
||||
Quantity = newtable.Quantity,
|
||||
TotalCostFixedComprehensiveUnitPrice = newtable.TotalCostFixedComprehensiveUnitPrice,
|
||||
MainMaterialCost = newtable.MainMaterialCost,
|
||||
TotalPrice = newtable.TotalPrice,
|
||||
CalculationRule = newtable.CalculationRule,
|
||||
WorkContent = newtable.WorkContent,
|
||||
Remarks = newtable.Remarks,
|
||||
ConstructionSubcontractor = newtable.ConstructionSubcontractor,
|
||||
ContractWeight = newtable.ContractWeight,
|
||||
MaterialSupplier = newtable.MaterialSupplier,
|
||||
IsWithinGeneralContractScope = newtable.IsWithinGeneralContractScope,
|
||||
EstimatedQuantity = newtable.EstimatedQuantity,
|
||||
EstimatedAmount = newtable.EstimatedAmount,
|
||||
SettledQuantity = newtable.SettledQuantity,
|
||||
SettledAmount = newtable.SettledAmount,
|
||||
ContractId = newtable.ContractId,
|
||||
ProjectId = newtable.ProjectId,
|
||||
};
|
||||
Funs.DB.PHTGL_ContractTrack.InsertOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
|
||||
public static void UpdatePHTGL_ContractTrack(PHTGL_ContractTrack newtable)
|
||||
{
|
||||
var table = Funs.DB.PHTGL_ContractTrack.FirstOrDefault(x => x.Id == newtable.Id);
|
||||
if (table != null)
|
||||
{
|
||||
table.Id = newtable.Id;
|
||||
table.ContractNum = newtable.ContractNum;
|
||||
table.MainItemCode = newtable.MainItemCode;
|
||||
table.MainItemName = newtable.MainItemName;
|
||||
table.MajorName = newtable.MajorName;
|
||||
table.MajorCode = newtable.MajorCode;
|
||||
table.SubProject = newtable.SubProject;
|
||||
table.SubItemProject = newtable.SubItemProject;
|
||||
table.ProjectCode = newtable.ProjectCode;
|
||||
table.ProjectName = newtable.ProjectName;
|
||||
table.ProjectDescription = newtable.ProjectDescription;
|
||||
table.UnitOfMeasurement = newtable.UnitOfMeasurement;
|
||||
table.Quantity = newtable.Quantity;
|
||||
table.TotalCostFixedComprehensiveUnitPrice = newtable.TotalCostFixedComprehensiveUnitPrice;
|
||||
table.MainMaterialCost = newtable.MainMaterialCost;
|
||||
table.TotalPrice = newtable.TotalPrice;
|
||||
table.CalculationRule = newtable.CalculationRule;
|
||||
table.WorkContent = newtable.WorkContent;
|
||||
table.Remarks = newtable.Remarks;
|
||||
table.ConstructionSubcontractor = newtable.ConstructionSubcontractor;
|
||||
table.ContractWeight = newtable.ContractWeight;
|
||||
table.MaterialSupplier = newtable.MaterialSupplier;
|
||||
table.IsWithinGeneralContractScope = newtable.IsWithinGeneralContractScope;
|
||||
table.EstimatedQuantity = newtable.EstimatedQuantity;
|
||||
table.EstimatedAmount = newtable.EstimatedAmount;
|
||||
table.SettledQuantity = newtable.SettledQuantity;
|
||||
table.SettledAmount = newtable.SettledAmount;
|
||||
table.ContractId=newtable.ContractId;
|
||||
table.ProjectId=newtable.ProjectId;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeletePHTGL_ContractTrackById(string id)
|
||||
{
|
||||
var table = Funs.DB.PHTGL_ContractTrack.FirstOrDefault(x => x.Id == id);
|
||||
if (table != null)
|
||||
{
|
||||
Funs.DB.PHTGL_ContractTrack.DeleteOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static ResponeData ImportData(string path, string contractid, string projectid)
|
||||
{
|
||||
var responeData = new ResponeData();
|
||||
List<PHTGL_ContractTrackDtoIn> rows;
|
||||
try
|
||||
{
|
||||
rows = MiniExcel.Query<PHTGL_ContractTrackDtoIn>(path).ToList();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "模板错误";
|
||||
return responeData;
|
||||
}
|
||||
|
||||
var mapper =
|
||||
ObjectMapperManager.DefaultInstance.GetMapper<List<PHTGL_ContractTrackDtoIn>, List<PHTGL_ContractTrack>>();
|
||||
var modeList = mapper.Map(rows);
|
||||
if (modeList.Count == 0)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "没有数据";
|
||||
return responeData;
|
||||
}
|
||||
|
||||
foreach (var item in modeList)
|
||||
{
|
||||
item.ContractId = contractid;
|
||||
item.ProjectId = projectid;
|
||||
var phtglContractTrack = new PHTGL_ContractTrack
|
||||
{
|
||||
ProjectCode = item.ProjectCode,
|
||||
ContractId = contractid,
|
||||
ProjectId = projectid,
|
||||
};
|
||||
var resultModel = GetPHTGL_ContractTrackByModle(phtglContractTrack);
|
||||
if (resultModel.Any())
|
||||
{
|
||||
item.Id = resultModel[0].Id;
|
||||
UpdatePHTGL_ContractTrack(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.Id = SQLHelper.GetNewID();
|
||||
AddPHTGL_ContractTrack(item);
|
||||
}
|
||||
}
|
||||
|
||||
return responeData;
|
||||
}
|
||||
|
||||
}
|
||||
public class PHTGL_ContractTrackDtoIn
|
||||
{
|
||||
/// <summary>
|
||||
/// 主项号
|
||||
/// </summary>
|
||||
[ExcelColumnIndex("B")] public string MainItemCode { get; set; }
|
||||
/// <summary>
|
||||
/// 主项名称
|
||||
/// </summary>
|
||||
[ExcelColumnIndex("C")] public string MainItemName { get; set; }
|
||||
/// <summary>
|
||||
/// 专业代码
|
||||
/// </summary>
|
||||
[ExcelColumnIndex("D")] public string MajorCode { get; set; }
|
||||
/// <summary>
|
||||
/// 专业工程名称
|
||||
/// </summary>
|
||||
[ExcelColumnIndex("E")] public string MajorName { get; set; }
|
||||
/// <summary>
|
||||
/// 项目编码
|
||||
/// </summary>
|
||||
[ExcelColumnIndex("F")] public string ProjectCode { get; set; }
|
||||
/// <summary>
|
||||
/// 项目名称
|
||||
/// </summary>
|
||||
[ExcelColumnIndex("G")] public string ProjectName { get; set; }
|
||||
/// <summary>
|
||||
/// 项目特征描述
|
||||
/// </summary>
|
||||
[ExcelColumnIndex("H")] public string ProjectDescription { get; set; }
|
||||
/// <summary>
|
||||
/// 计量单位
|
||||
/// </summary>
|
||||
[ExcelColumnIndex("I")] public string UnitOfMeasurement { get; set; }
|
||||
/// <summary>
|
||||
/// 工程量
|
||||
/// </summary>
|
||||
[ExcelColumnIndex("J")] public string Quantity { get; set; }
|
||||
/// <summary>
|
||||
/// 全费用固定综合单价
|
||||
/// </summary>
|
||||
[ExcelColumnIndex("K")] public string TotalCostFixedComprehensiveUnitPrice { get; set; }
|
||||
/// <summary>
|
||||
/// 其中:主材费
|
||||
/// </summary>
|
||||
[ExcelColumnIndex("L")] public string MainMaterialCost { get; set; }
|
||||
/// <summary>
|
||||
/// 合价/元
|
||||
/// </summary>
|
||||
[ExcelColumnIndex("M")] public string TotalPrice { get; set; }
|
||||
/// <summary>
|
||||
/// 计算规则
|
||||
/// </summary>
|
||||
[ExcelColumnIndex("N")] public string CalculationRule { get; set; }
|
||||
/// <summary>
|
||||
/// 工作内容
|
||||
/// </summary>
|
||||
[ExcelColumnIndex("O")] public string WorkContent { get; set; }
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
[ExcelColumnIndex("P")] public string Remarks { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user