2023-08-23
This commit is contained in:
@@ -0,0 +1,219 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using FineUIPro;
|
||||
using MiniExcelLibs;
|
||||
using Model;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public static class PHTGL_BidProjectQuantityService
|
||||
{
|
||||
public static PHTGL_BidProjectQuantity GetPHTGL_BidProjectQuantityById(string bidProjectQuantityId)
|
||||
{
|
||||
return Funs.DB.PHTGL_BidProjectQuantity.FirstOrDefault(x => x.BidProjectQuantityId == bidProjectQuantityId);
|
||||
}
|
||||
|
||||
public static void AddPHTGL_BidProjectQuantity(PHTGL_BidProjectQuantity newtable)
|
||||
{
|
||||
var table = new PHTGL_BidProjectQuantity
|
||||
{
|
||||
BidProjectQuantityId = newtable.BidProjectQuantityId,
|
||||
LotNumber = newtable.LotNumber,
|
||||
BidProjectCode = newtable.BidProjectCode,
|
||||
IsMainProject = newtable.IsMainProject,
|
||||
ProjectId = newtable.ProjectId,
|
||||
CreatorId = newtable.CreatorId,
|
||||
CreateDate = newtable.CreateDate
|
||||
};
|
||||
Funs.DB.PHTGL_BidProjectQuantity.InsertOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
|
||||
public static void UpdatePHTGL_BidProjectQuantity(PHTGL_BidProjectQuantity newtable)
|
||||
{
|
||||
var table = Funs.DB.PHTGL_BidProjectQuantity.FirstOrDefault(x =>
|
||||
x.BidProjectQuantityId == newtable.BidProjectQuantityId);
|
||||
if (table != null)
|
||||
{
|
||||
table.BidProjectQuantityId = newtable.BidProjectQuantityId;
|
||||
table.LotNumber = newtable.LotNumber;
|
||||
table.BidProjectCode = newtable.BidProjectCode;
|
||||
table.IsMainProject = newtable.IsMainProject;
|
||||
table.ProjectId = newtable.ProjectId;
|
||||
table.CreatorId = newtable.CreatorId;
|
||||
table.CreateDate = newtable.CreateDate;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeletePHTGL_BidProjectQuantityById(string BidProjectQuantityId)
|
||||
{
|
||||
var table = Funs.DB.PHTGL_BidProjectQuantity.FirstOrDefault(x =>
|
||||
x.BidProjectQuantityId == BidProjectQuantityId);
|
||||
if (table != null)
|
||||
{
|
||||
Funs.DB.PHTGL_BidProjectQuantity.DeleteOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出招标工作量清单
|
||||
/// </summary>
|
||||
/// <param name="bidProjectQuantityId">招标工作量清单主键id</param>
|
||||
public static void ExportById(string bidProjectQuantityId)
|
||||
{
|
||||
var bidProjectQuantity = GetPHTGL_BidProjectQuantityById(bidProjectQuantityId);
|
||||
var sheets = new Dictionary<string, object>();
|
||||
var mainProjectQuantity = new PHTGL_MainProjectQuantity();
|
||||
mainProjectQuantity.QuantityId = bidProjectQuantityId;
|
||||
var mainProjectList = PHTGL_MainProjectQuantityService.GetPHTGL_MainProjectQuantityByModle(mainProjectQuantity);//获取主项
|
||||
foreach (var item in mainProjectList)
|
||||
{
|
||||
var querytable = new PHTGL_Quantity();
|
||||
querytable.IsTemplate = false;
|
||||
querytable.ParentId = item.MainProjectQuantityId;
|
||||
var tb = PHTGL_QuantityService.GetPHTGL_QuantityByModle(querytable);
|
||||
var exportmodel = (from x in tb
|
||||
select new
|
||||
{
|
||||
专业= x.Major,
|
||||
分部工程= 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,
|
||||
}).ToList();
|
||||
sheets.Add(item.MainProjectQuantityName,exportmodel);
|
||||
}
|
||||
string path = Funs.RootPath + @"File\Excel\Temp\招标工作清单-"+ bidProjectQuantity.BidProjectCode+ ".xlsx";
|
||||
path = path.Replace(".xlsx", string.Format("{0:yyyy-MM-dd-HH-mm}", DateTime.Now) + ".xlsx");
|
||||
MiniExcel.SaveAs(path, sheets);
|
||||
string fileName = "招标工作清单-" + bidProjectQuantity.BidProjectCode + ".xlsx";
|
||||
FileInfo info = new FileInfo(path);
|
||||
long fileSize = info.Length;
|
||||
System.Web.HttpContext.Current.Response.Clear();
|
||||
System.Web.HttpContext.Current.Response.ContentType = "application/x-zip-compressed";
|
||||
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
||||
System.Web.HttpContext.Current.Response.AddHeader("Content-Length", fileSize.ToString());
|
||||
System.Web.HttpContext.Current.Response.TransmitFile(path, 0, fileSize);
|
||||
System.Web.HttpContext.Current.Response.Flush();
|
||||
System.Web.HttpContext.Current.Response.Close();
|
||||
File.Delete(path);
|
||||
}
|
||||
public static void ExportByMainProjectQuantityId(string mainProjectQuantityId)
|
||||
{
|
||||
var sheets = new Dictionary<string, object>();
|
||||
var mainProjectList = PHTGL_MainProjectQuantityService.GetPHTGL_MainProjectQuantityById(mainProjectQuantityId);//获取主项
|
||||
if (mainProjectList==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var querytable = new PHTGL_Quantity();
|
||||
querytable.IsTemplate = false;
|
||||
querytable.ParentId = mainProjectQuantityId;
|
||||
var tb = PHTGL_QuantityService.GetPHTGL_QuantityByModle(querytable);
|
||||
var exportmodel = (from x in tb
|
||||
select new
|
||||
{
|
||||
专业 = x.Major,
|
||||
分部工程 = 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,
|
||||
}).ToList();
|
||||
sheets.Add(mainProjectList.MainProjectQuantityName, exportmodel);
|
||||
|
||||
string path = Funs.RootPath + @"File\Excel\Temp\招标工作清单-" + mainProjectList.MainProjectQuantityCode + ".xlsx";
|
||||
path = path.Replace(".xlsx", string.Format("{0:yyyy-MM-dd-HH-mm}", DateTime.Now) + ".xlsx");
|
||||
MiniExcel.SaveAs(path, sheets);
|
||||
string fileName = "招标工作清单-" + mainProjectList.MainProjectQuantityCode + ".xlsx";
|
||||
FileInfo info = new FileInfo(path);
|
||||
long fileSize = info.Length;
|
||||
System.Web.HttpContext.Current.Response.Clear();
|
||||
System.Web.HttpContext.Current.Response.ContentType = "application/x-zip-compressed";
|
||||
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
||||
System.Web.HttpContext.Current.Response.AddHeader("Content-Length", fileSize.ToString());
|
||||
System.Web.HttpContext.Current.Response.TransmitFile(path, 0, fileSize);
|
||||
System.Web.HttpContext.Current.Response.Flush();
|
||||
System.Web.HttpContext.Current.Response.Close();
|
||||
File.Delete(path);
|
||||
}
|
||||
|
||||
|
||||
#region 获取列表
|
||||
|
||||
/// <summary>
|
||||
/// 记录数
|
||||
/// </summary>
|
||||
public static int count { get; set; }
|
||||
|
||||
public static List<PHTGL_BidProjectQuantity> GetPHTGL_BidProjectQuantityByModle(PHTGL_BidProjectQuantity table)
|
||||
{
|
||||
var q = from x in Funs.DB.PHTGL_BidProjectQuantity
|
||||
where
|
||||
(string.IsNullOrEmpty(table.BidProjectQuantityId) ||
|
||||
x.BidProjectQuantityId.Contains(table.BidProjectQuantityId)) &&
|
||||
(string.IsNullOrEmpty(table.LotNumber) || x.LotNumber.Contains(table.LotNumber)) &&
|
||||
(string.IsNullOrEmpty(table.BidProjectCode) ||
|
||||
x.BidProjectCode.Contains(table.BidProjectCode)) &&
|
||||
(string.IsNullOrEmpty(table.ProjectId) ||
|
||||
x.ProjectId.Contains(table.ProjectId))
|
||||
&&
|
||||
(string.IsNullOrEmpty(table.CreatorId) ||
|
||||
x.CreatorId.Contains(table.CreatorId))
|
||||
select x
|
||||
;
|
||||
|
||||
return q.ToList();
|
||||
}
|
||||
|
||||
/// 获取分页列表
|
||||
/// </summary>
|
||||
/// <param name="PageIndex">页码</param>
|
||||
/// <param name="PageSize">每页数量</param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable getListData(PHTGL_BidProjectQuantity table, Grid Grid1)
|
||||
{
|
||||
var q = GetPHTGL_BidProjectQuantityByModle(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.BidProjectQuantityId,
|
||||
x.LotNumber,
|
||||
x.BidProjectCode,
|
||||
x.IsMainProject,
|
||||
x.ProjectId,
|
||||
x.CreatorId,
|
||||
x.CreateDate
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FineUIPro;
|
||||
using Model;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public static class PHTGL_MainProjectQuantityService
|
||||
{
|
||||
public static PHTGL_MainProjectQuantity GetPHTGL_MainProjectQuantityById(string MainProjectQuantityId)
|
||||
{
|
||||
return Funs.DB.PHTGL_MainProjectQuantity.FirstOrDefault(x =>
|
||||
x.MainProjectQuantityId == MainProjectQuantityId);
|
||||
}
|
||||
|
||||
|
||||
public static void AddPHTGL_MainProjectQuantity(PHTGL_MainProjectQuantity newtable)
|
||||
{
|
||||
var table = new PHTGL_MainProjectQuantity
|
||||
{
|
||||
MainProjectQuantityId = newtable.MainProjectQuantityId,
|
||||
MainProjectQuantityCode = newtable.MainProjectQuantityCode,
|
||||
MainProjectQuantityName = newtable.MainProjectQuantityName,
|
||||
QuantityId = newtable.QuantityId
|
||||
};
|
||||
Funs.DB.PHTGL_MainProjectQuantity.InsertOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
|
||||
public static void UpdatePHTGL_MainProjectQuantity(PHTGL_MainProjectQuantity newtable)
|
||||
{
|
||||
var table = Funs.DB.PHTGL_MainProjectQuantity.FirstOrDefault(x =>
|
||||
x.MainProjectQuantityId == newtable.MainProjectQuantityId);
|
||||
if (table != null)
|
||||
{
|
||||
table.MainProjectQuantityId = newtable.MainProjectQuantityId;
|
||||
table.MainProjectQuantityCode = newtable.MainProjectQuantityCode;
|
||||
table.MainProjectQuantityName = newtable.MainProjectQuantityName;
|
||||
table.QuantityId = newtable.QuantityId;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeleteById(string MainProjectQuantityId)
|
||||
{
|
||||
var table = Funs.DB.PHTGL_MainProjectQuantity.FirstOrDefault(x =>
|
||||
x.MainProjectQuantityId == MainProjectQuantityId);
|
||||
if (table != null)
|
||||
{
|
||||
Funs.DB.PHTGL_MainProjectQuantity.DeleteOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeleteByBidProjectQuantityId(string bidProjectQuantityId)
|
||||
{
|
||||
var table = Funs.DB.PHTGL_MainProjectQuantity.Where(x =>
|
||||
x.QuantityId == bidProjectQuantityId);
|
||||
if (table.Any())
|
||||
{
|
||||
foreach (var item in table)
|
||||
PHTGL_QuantityService.DeletePHTGL_QuantityByParentId(item.MainProjectQuantityId);
|
||||
Funs.DB.PHTGL_MainProjectQuantity.DeleteAllOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
#region 获取列表
|
||||
|
||||
/// <summary>
|
||||
/// 记录数
|
||||
/// </summary>
|
||||
public static int count { get; set; }
|
||||
|
||||
public static List<PHTGL_MainProjectQuantity> GetPHTGL_MainProjectQuantityByModle(
|
||||
PHTGL_MainProjectQuantity table)
|
||||
{
|
||||
var q = from x in Funs.DB.PHTGL_MainProjectQuantity
|
||||
where
|
||||
(string.IsNullOrEmpty(table.MainProjectQuantityId) ||
|
||||
x.MainProjectQuantityId.Contains(table.MainProjectQuantityId)) &&
|
||||
(string.IsNullOrEmpty(table.MainProjectQuantityCode) ||
|
||||
x.MainProjectQuantityCode.Contains(table.MainProjectQuantityCode)) &&
|
||||
(string.IsNullOrEmpty(table.MainProjectQuantityName) ||
|
||||
x.MainProjectQuantityName.Contains(table.MainProjectQuantityName)) &&
|
||||
(string.IsNullOrEmpty(table.QuantityId) || x.QuantityId.Contains(table.QuantityId))
|
||||
select x
|
||||
;
|
||||
|
||||
return q.ToList();
|
||||
}
|
||||
|
||||
/// 获取分页列表
|
||||
/// </summary>
|
||||
/// <param name="PageIndex">页码</param>
|
||||
/// <param name="PageSize">每页数量</param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable getListData(PHTGL_MainProjectQuantity table, Grid Grid1)
|
||||
{
|
||||
var q = GetPHTGL_MainProjectQuantityByModle(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.MainProjectQuantityId,
|
||||
x.MainProjectQuantityCode,
|
||||
x.MainProjectQuantityName,
|
||||
x.QuantityId
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,378 @@
|
||||
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_QuantityService
|
||||
{
|
||||
public static PHTGL_Quantity GetPHTGL_QuantityById(string Id)
|
||||
{
|
||||
return Funs.DB.PHTGL_Quantity.FirstOrDefault(x => x.Id == Id);
|
||||
}
|
||||
|
||||
|
||||
public static void AddPHTGL_Quantity(PHTGL_Quantity newtable)
|
||||
{
|
||||
var table = new PHTGL_Quantity
|
||||
{
|
||||
Id = newtable.Id,
|
||||
Major = newtable.Major,
|
||||
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,
|
||||
IsTemplate = newtable.IsTemplate,
|
||||
ParentId = newtable.ParentId
|
||||
};
|
||||
Funs.DB.PHTGL_Quantity.InsertOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
/// <summary>
|
||||
/// 通过模板增加实体
|
||||
/// </summary>
|
||||
/// <param name="newtable"></param>
|
||||
/// <param name="parentId"></param>
|
||||
public static void AddPHTGL_QuantityByTemModel(PHTGL_Quantity newtable, string parentId)
|
||||
{
|
||||
var table = new PHTGL_Quantity
|
||||
{
|
||||
Id = SQLHelper.GetNewID(),
|
||||
Major = newtable.Major,
|
||||
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,
|
||||
IsTemplate = false,
|
||||
ParentId = parentId
|
||||
};
|
||||
Funs.DB.PHTGL_Quantity.InsertOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
public static void UpdatePHTGL_Quantity(PHTGL_Quantity newtable)
|
||||
{
|
||||
var table = Funs.DB.PHTGL_Quantity.FirstOrDefault(x => x.Id == newtable.Id);
|
||||
if (table != null)
|
||||
{
|
||||
table.Id = newtable.Id;
|
||||
table.Major = newtable.Major;
|
||||
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.IsTemplate = newtable.IsTemplate;
|
||||
table.ParentId = newtable.ParentId;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeletePHTGL_QuantityById(string Id)
|
||||
{
|
||||
var table = Funs.DB.PHTGL_Quantity.FirstOrDefault(x => x.Id == Id);
|
||||
if (table != null)
|
||||
{
|
||||
Funs.DB.PHTGL_Quantity.DeleteOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeletePHTGL_QuantityByParentId(string parentId)
|
||||
{
|
||||
var table = Funs.DB.PHTGL_Quantity.Where(x => x.ParentId == parentId);
|
||||
if (table.Any())
|
||||
{
|
||||
Funs.DB.PHTGL_Quantity.DeleteAllOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导入数据
|
||||
/// </summary>
|
||||
/// <param name="path">数据文件地址</param>
|
||||
/// <param name="majortype">专业类型</param>
|
||||
/// <returns></returns>
|
||||
public static ResponeData ImportData(string path, string majortype)
|
||||
{
|
||||
var responeData = new ResponeData();
|
||||
List<PHTGL_QuantityDtoIn> rows;
|
||||
try
|
||||
{
|
||||
rows = MiniExcel.Query<PHTGL_QuantityDtoIn>(path).ToList();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "模板错误";
|
||||
return responeData;
|
||||
}
|
||||
|
||||
var mapper =
|
||||
ObjectMapperManager.DefaultInstance.GetMapper<List<PHTGL_QuantityDtoIn>, List<PHTGL_Quantity>>();
|
||||
var modeList = mapper.Map(rows);
|
||||
if (modeList.Count == 0)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "没有数据";
|
||||
return responeData;
|
||||
}
|
||||
|
||||
foreach (var item in modeList)
|
||||
{
|
||||
item.Major = GetMajorItems().Where(x => x.Text == majortype).Select(x => x.Value).FirstOrDefault() ??
|
||||
"";
|
||||
if (string.IsNullOrEmpty(item.Major)) break;
|
||||
var queryPhtglQuantity = new PHTGL_Quantity
|
||||
{
|
||||
Major = item.Major,
|
||||
SubProject = item.SubProject,
|
||||
SubItemProject = item.SubItemProject,
|
||||
ProjectCode = item.ProjectCode,
|
||||
IsTemplate = true
|
||||
};
|
||||
var resultModel = GetPHTGL_QuantityByModle(queryPhtglQuantity);
|
||||
if (resultModel.Any())
|
||||
{
|
||||
item.Id = resultModel[0].Id;
|
||||
UpdatePHTGL_Quantity(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.Id = SQLHelper.GetNewID();
|
||||
item.IsTemplate = true;
|
||||
AddPHTGL_Quantity(item);
|
||||
}
|
||||
}
|
||||
|
||||
return responeData;
|
||||
}
|
||||
|
||||
public static ResponeData ImportData(string path, string majortype, string mainProjectQuantityId)
|
||||
{
|
||||
var responeData = new ResponeData();
|
||||
List<PHTGL_QuantityDtoIn> rows;
|
||||
try
|
||||
{
|
||||
rows = MiniExcel.Query<PHTGL_QuantityDtoIn>(path).ToList();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "模板错误";
|
||||
return responeData;
|
||||
}
|
||||
|
||||
var mapper =
|
||||
ObjectMapperManager.DefaultInstance.GetMapper<List<PHTGL_QuantityDtoIn>, List<PHTGL_Quantity>>();
|
||||
var modeList = mapper.Map(rows);
|
||||
if (modeList.Count == 0)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "没有数据";
|
||||
return responeData;
|
||||
}
|
||||
|
||||
foreach (var item in modeList)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(majortype))
|
||||
{
|
||||
item.Major = GetMajorItems().Where(x => x.Text == majortype).Select(x => x.Value).FirstOrDefault() ??
|
||||
"";
|
||||
}
|
||||
if (string.IsNullOrEmpty(item.Major)) break;
|
||||
var queryPhtglQuantity = new PHTGL_Quantity
|
||||
{
|
||||
Major = item.Major,
|
||||
SubProject = item.SubProject,
|
||||
SubItemProject = item.SubItemProject,
|
||||
ProjectCode = item.ProjectCode,
|
||||
};
|
||||
if (string.IsNullOrEmpty(mainProjectQuantityId))
|
||||
{
|
||||
queryPhtglQuantity.IsTemplate = true;
|
||||
item.IsTemplate = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
queryPhtglQuantity.IsTemplate = false;
|
||||
queryPhtglQuantity.ParentId = mainProjectQuantityId;
|
||||
item.ParentId = mainProjectQuantityId;
|
||||
item.IsTemplate = false;
|
||||
}
|
||||
|
||||
var resultModel = GetPHTGL_QuantityByModle(queryPhtglQuantity);
|
||||
if (resultModel.Any())
|
||||
{
|
||||
item.Id = resultModel[0].Id;
|
||||
UpdatePHTGL_Quantity(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.Id = SQLHelper.GetNewID();
|
||||
AddPHTGL_Quantity(item);
|
||||
}
|
||||
}
|
||||
|
||||
return responeData;
|
||||
}
|
||||
|
||||
|
||||
public static ListItem[] GetMajorItems()
|
||||
{
|
||||
var list = new ListItem[10];
|
||||
list[0] = new ListItem("0", "土建工程");
|
||||
list[1] = new ListItem("1", "钢结构预制工程");
|
||||
list[2] = new ListItem("2", "工艺管道安装工程");
|
||||
list[3] = new ListItem("3", "工艺设备安装工程");
|
||||
list[4] = new ListItem("4", "非标设备现场制作安装工程");
|
||||
list[5] = new ListItem("5", "电仪安装工程");
|
||||
list[6] = new ListItem("6", "水暖安装工程");
|
||||
list[7] = new ListItem("7", "防腐绝热工程");
|
||||
list[8] = new ListItem("8", "无损检测工程");
|
||||
list[9] = new ListItem("9", "消防工程");
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
#region 获取列表
|
||||
|
||||
/// <summary>
|
||||
/// 记录数
|
||||
/// </summary>
|
||||
public static int count { get; set; }
|
||||
|
||||
public static List<PHTGL_Quantity> GetPHTGL_QuantityByModle(PHTGL_Quantity table)
|
||||
{
|
||||
var q = from x in Funs.DB.PHTGL_Quantity
|
||||
where
|
||||
(string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) &&
|
||||
(string.IsNullOrEmpty(table.Major) || x.Major.Contains(table.Major)) &&
|
||||
(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)) &&
|
||||
x.IsTemplate == table.IsTemplate &&
|
||||
(string.IsNullOrEmpty(table.ParentId) || x.ParentId.Contains(table.ParentId))
|
||||
select x
|
||||
;
|
||||
|
||||
return q.ToList();
|
||||
}
|
||||
|
||||
/// 获取分页列表
|
||||
/// </summary>
|
||||
/// <param name="PageIndex">页码</param>
|
||||
/// <param name="PageSize">每页数量</param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable getListData(PHTGL_Quantity table, Grid Grid1)
|
||||
{
|
||||
var q = GetPHTGL_QuantityByModle(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.Major,
|
||||
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.IsTemplate,
|
||||
x.ParentId
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class PHTGL_QuantityDtoIn
|
||||
{
|
||||
[ExcelColumnIndex("A")] public string Major { get; set; }
|
||||
[ExcelColumnIndex("B")] public string SubProject { get; set; }
|
||||
|
||||
[ExcelColumnIndex("C")] public string SubItemProject { get; set; }
|
||||
|
||||
[ExcelColumnIndex("D")] public string ProjectCode { get; set; }
|
||||
|
||||
[ExcelColumnIndex("E")] public string ProjectName { get; set; }
|
||||
|
||||
[ExcelColumnIndex("F")] public string ProjectDescription { get; set; }
|
||||
|
||||
[ExcelColumnIndex("G")] public string UnitOfMeasurement { get; set; }
|
||||
|
||||
[ExcelColumnIndex("H")] public string Quantity { get; set; }
|
||||
|
||||
[ExcelColumnIndex("I")] public string TotalCostFixedComprehensiveUnitPrice { get; set; }
|
||||
|
||||
[ExcelColumnIndex("J")] public string MainMaterialCost { get; set; }
|
||||
|
||||
[ExcelColumnIndex("K")] public string TotalPrice { get; set; }
|
||||
|
||||
[ExcelColumnIndex("L")] public string CalculationRule { get; set; }
|
||||
|
||||
[ExcelColumnIndex("M")] public string WorkContent { get; set; }
|
||||
|
||||
[ExcelColumnIndex("N")] public string Remarks { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user