2023-10-19
This commit is contained in:
@@ -17,6 +17,10 @@ namespace BLL
|
||||
return Funs.DB.PHTGL_Quantity.FirstOrDefault(x => x.Id == Id);
|
||||
}
|
||||
|
||||
public static PHTGL_Quantity GetPHTGL_QuantityByNumBer(string serialNumber,string marjor)
|
||||
{
|
||||
return Funs.DB.PHTGL_Quantity.FirstOrDefault(x => x.SerialNumber == serialNumber && x.Major==marjor);
|
||||
}
|
||||
|
||||
public static void AddPHTGL_Quantity(PHTGL_Quantity newtable)
|
||||
{
|
||||
@@ -132,10 +136,24 @@ namespace BLL
|
||||
public static ResponeData ImportData(string path, string majortype)
|
||||
{
|
||||
var responeData = new ResponeData();
|
||||
List<PHTGL_QuantityDtoIn> rows;
|
||||
List<PHTGL_QuantityDtoIn> rows= new List<PHTGL_QuantityDtoIn>();
|
||||
List<dynamic> remarkQuery=new List<dynamic>();
|
||||
string Major = "";
|
||||
try
|
||||
{
|
||||
rows = MiniExcel.Query<PHTGL_QuantityDtoIn>(path).ToList();
|
||||
var sheetNames = MiniExcel.GetSheetNames(path);
|
||||
foreach (var item in sheetNames)
|
||||
{
|
||||
if (item=="编制说明")
|
||||
{
|
||||
remarkQuery = MiniExcel.Query(path, sheetName: item).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
rows = MiniExcel.Query<PHTGL_QuantityDtoIn>(path, sheetName: item).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -154,17 +172,46 @@ namespace BLL
|
||||
return responeData;
|
||||
}
|
||||
|
||||
Major = GetMajorItems().Where(x => x.Text == majortype).Select(x => x.Value).FirstOrDefault() ??
|
||||
"";
|
||||
List<Model.Sys_Const> consts=new List<Model.Sys_Const>();
|
||||
int SortIndex = 0;
|
||||
foreach (var item in remarkQuery)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Major)) break;
|
||||
Model.Sys_Const model = new Model.Sys_Const()
|
||||
{
|
||||
ID = SQLHelper.GetNewID(),
|
||||
ConstValue = item.A?.ToString(),
|
||||
SortIndex = SortIndex,
|
||||
GroupId = "工程量清单-"+ Major
|
||||
};
|
||||
consts.Add(model);
|
||||
SortIndex++;
|
||||
}
|
||||
|
||||
var old = ConstValue.drpConstItemList("工程量清单-" + Major);
|
||||
if (old.Count>0)
|
||||
{
|
||||
Funs.DB.Sys_Const.DeleteAllOnSubmit(old);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
;
|
||||
Funs.DB.Sys_Const.InsertAllOnSubmit(consts);
|
||||
Funs.DB.SubmitChanges();
|
||||
foreach (var item in modeList)
|
||||
{
|
||||
item.Major = GetMajorItems().Where(x => x.Text == majortype).Select(x => x.Value).FirstOrDefault() ??
|
||||
"";
|
||||
if (string.IsNullOrEmpty(item.Major)) break;
|
||||
item.Major = Major;
|
||||
if (string.IsNullOrEmpty(Major)) break;
|
||||
if (string .IsNullOrEmpty(item.ProjectName)) continue;
|
||||
if (item.ProjectName== "项目名称") continue;
|
||||
var queryPhtglQuantity = new PHTGL_Quantity
|
||||
{
|
||||
Major = item.Major,
|
||||
SubProject = item.SubProject,
|
||||
SubItemProject = item.SubItemProject,
|
||||
ProjectCode = item.ProjectCode,
|
||||
ProjectName = item.ProjectName,
|
||||
IsTemplate = true
|
||||
};
|
||||
var resultModel = GetPHTGL_QuantityByModle(queryPhtglQuantity);
|
||||
@@ -256,17 +303,19 @@ namespace BLL
|
||||
|
||||
public static ListItem[] GetMajorItems()
|
||||
{
|
||||
var list = new ListItem[10];
|
||||
var list = new ListItem[12];
|
||||
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", "消防工程");
|
||||
list[5] = new ListItem("5.1", "电气工程");
|
||||
list[6] = new ListItem("5.2", "仪表工程");
|
||||
list[7] = new ListItem("5.3", "电信工程");
|
||||
list[8] = new ListItem("6", "水暖安装工程");
|
||||
list[9] = new ListItem("7", "防腐绝热工程");
|
||||
list[10] = new ListItem("8", "无损检测工程");
|
||||
list[11] = new ListItem("9", "消防工程");
|
||||
|
||||
return list;
|
||||
}
|
||||
@@ -305,12 +354,14 @@ namespace BLL
|
||||
(string.IsNullOrEmpty(table.Remarks) || x.Remarks.Contains(table.Remarks)) &&
|
||||
x.IsTemplate == table.IsTemplate &&
|
||||
(string.IsNullOrEmpty(table.ParentId) || x.ParentId.Contains(table.ParentId))
|
||||
|
||||
select new { x ,IntSerialNumber= Funs.GetNewIntOrZero(x.SerialNumber.Replace(".", ""))
|
||||
}
|
||||
|
||||
select x;
|
||||
//select new { x ,IntSerialNumber= Funs.GetNewIntOrZero(x.SerialNumber.Replace(".", ""))
|
||||
// }
|
||||
|
||||
;
|
||||
var model = q.ToList().OrderBy(x => x.IntSerialNumber).Select(itemx => itemx.x).ToList();
|
||||
//var model = q.ToList().OrderBy(x => x.IntSerialNumber).Select(itemx => itemx.x).ToList();
|
||||
var model = q.ToList().OrderBy(x => x.SerialNumber, new CustomComparer()).ToList();
|
||||
return model;
|
||||
}
|
||||
|
||||
@@ -350,9 +401,61 @@ namespace BLL
|
||||
};
|
||||
}
|
||||
|
||||
public static void CheckSubProjectName(List<PHTGL_Quantity> list)
|
||||
{
|
||||
foreach (var item in list)
|
||||
{
|
||||
var SubProject = "";
|
||||
var SubItemProject = "";
|
||||
var SerialNumberArry = item.SerialNumber?.Split('.');
|
||||
if (SerialNumberArry.Length==2)
|
||||
{
|
||||
item.SubProject = GetPHTGL_QuantityByNumBer(SerialNumberArry[0], item.Major).ProjectName;
|
||||
UpdatePHTGL_Quantity(item);
|
||||
|
||||
}
|
||||
else if (SerialNumberArry.Length == 3)
|
||||
{
|
||||
item.SubProject = GetPHTGL_QuantityByNumBer(SerialNumberArry[0], item.Major).ProjectName;
|
||||
item.SubItemProject= GetPHTGL_QuantityByNumBer(SerialNumberArry[0]+"."+ SerialNumberArry[1], item.Major).ProjectName;
|
||||
UpdatePHTGL_Quantity(item);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
public class CustomComparer : IComparer<string>
|
||||
{
|
||||
public int Compare(string x, string y)
|
||||
{
|
||||
if (string.IsNullOrEmpty(x)||string.IsNullOrEmpty(y))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
var xParts = x.Split('.');
|
||||
var yParts = y.Split('.');
|
||||
|
||||
for (int i = 0; i < Math.Min(xParts.Length, yParts.Length); i++)
|
||||
{
|
||||
int xNumber, yNumber;
|
||||
if (int.TryParse(xParts[i], out xNumber) && int.TryParse(yParts[i], out yNumber))
|
||||
{
|
||||
if (xNumber != yNumber)
|
||||
{
|
||||
return xNumber.CompareTo(yNumber);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return x.CompareTo(y);
|
||||
}
|
||||
}
|
||||
|
||||
return xParts.Length.CompareTo(yParts.Length);
|
||||
}
|
||||
}
|
||||
public class PHTGL_QuantityDtoIn
|
||||
{
|
||||
[ExcelColumnIndex("A")] public string SerialNumber { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user