This commit is contained in:
2025-10-27 20:25:26 +08:00
56 changed files with 1662 additions and 817 deletions
+83 -19
View File
@@ -6,30 +6,96 @@ using System.Linq;
namespace BLL
{
public class APIPackagingManageService
{
public static List<Model.PackagingManageDetailItem> GetPackagingManageList(string projectId)
public static List<Model.PackagingManageDetailItem> GetPackagingManageList(PackagingManageInput filter, int pageIndex, int pageSize, out int totalCount)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var q = (from x in db.HJGL_PackagingManage
join n in db.Base_Project on x.ProjectId equals n.ProjectId
join m in db.Person_Persons on x.ReceiveMan equals m.PersonId into tt
from t in tt.DefaultIfEmpty()
where x.ProjectId == projectId
// base join query to include project and receive person
var baseQuery = from x in db.HJGL_PackagingManage
join n in db.Base_Project on x.ProjectId equals n.ProjectId
join m in db.Person_Persons on x.ReceiveMan equals m.PersonId into tt
from t in tt.DefaultIfEmpty()
select new { x, n, t };
if (filter != null)
{
if (!string.IsNullOrEmpty(filter.PackagingManageId))
{
baseQuery = baseQuery.Where(z => z.x.PackagingManageId == filter.PackagingManageId);
}
if (!string.IsNullOrEmpty(filter.PackagingCode))
{
baseQuery = baseQuery.Where(z => z.x.PackagingCode.Contains(filter.PackagingCode));
}
if (!string.IsNullOrEmpty(filter.ProjectId))
{
baseQuery = baseQuery.Where(z => z.x.ProjectId == filter.ProjectId);
}
if (!string.IsNullOrEmpty(filter.ProjectName))
{
baseQuery = baseQuery.Where(z => z.n.ProjectName.Contains(filter.ProjectName));
}
if (!string.IsNullOrEmpty(filter.ContactName))
{
baseQuery = baseQuery.Where(z => z.x.ContactName.Contains(filter.ContactName));
}
if (!string.IsNullOrEmpty(filter.ContactPhone))
{
baseQuery = baseQuery.Where(z => z.x.ContactPhone.Contains(filter.ContactPhone));
}
if (!string.IsNullOrEmpty(filter.StackingPosition))
{
baseQuery = baseQuery.Where(z => z.x.StackingPosition.Contains(filter.StackingPosition));
}
if (filter.State != null)
{
baseQuery = baseQuery.Where(z => z.x.State == filter.State);
}
if (!string.IsNullOrEmpty(filter.ReceiveMan))
{
baseQuery = baseQuery.Where(z => z.x.ReceiveMan == filter.ReceiveMan || (z.t != null && z.t.PersonName.Contains(filter.ReceiveMan)));
}
if (!string.IsNullOrEmpty(filter.ReceiveDate))
{
DateTime dt;
if (DateTime.TryParse(filter.ReceiveDate, out dt))
{
var start = dt.Date;
var end = start.AddDays(1);
baseQuery = baseQuery.Where(z => z.x.ReceiveDate != null && z.x.ReceiveDate >= start && z.x.ReceiveDate < end);
}
}
if (!string.IsNullOrEmpty(filter.TrainNumberId))
{
baseQuery = baseQuery.Where(z => z.x.TrainNumber != null && z.x.TrainNumber.Contains(filter.TrainNumberId));
}
}
baseQuery = baseQuery.OrderByDescending(z => (z.x.ReceiveDate ?? DateTime.MinValue)).ThenBy(z => z.x.PackagingCode);
var q = (from z in baseQuery
select new PackagingManageDetailItem
{
PackagingManageId = x.PackagingManageId,
PackagingCode = x.PackagingCode,
ProjectName = n.ProjectName,
ContactName = x.ContactName,
ContactPhone = x.ContactPhone,
StackingPosition = x.StackingPosition,
State = x.State,
ReceiveMan = t.PersonName,
ReceiveDate = string.Format("{0:g}", x.ReceiveDate),
TrainNumber = x.TrainNumber,
PackagingManageId = z.x.PackagingManageId,
PackagingCode = z.x.PackagingCode,
ProjectName = z.n.ProjectName,
ContactName = z.x.ContactName,
ContactPhone = z.x.ContactPhone,
StackingPosition = z.x.StackingPosition,
State = z.x.State,
ReceiveMan = z.t.PersonName,
ReceiveDate = string.Format("{0:g}", z.x.ReceiveDate),
TrainNumber = z.x.TrainNumber,
}).Distinct();
return q.ToList();
totalCount = q.Count();
if (pageIndex <=0) pageIndex =1;
if (pageSize <=0) pageSize =20;
return q.Skip((pageIndex -1) * pageSize).Take(pageSize).ToList();
}
}
@@ -190,8 +256,6 @@ namespace BLL
}
}
}
public static string GetNewPackagingCode(string projectId)
{
return HJGLPackagingmanageService.GetNewPackagingCode(projectId);
@@ -1,5 +1,8 @@
using EmitMapper;
using FineUIPro;
using MiniExcelLibs;
using Model;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
@@ -190,5 +193,96 @@ namespace BLL
}
public static ResponeData ImportData( string path, string projectid)
{
var responeData = new ResponeData();
try
{
List<BaseMaterialcolorDataIn> temeplateDtoIns = MiniExcel.Query<BaseMaterialcolorDataIn>(path, startCell: "A1").ToList();
if (temeplateDtoIns == null || temeplateDtoIns.Count ==0)
{
responeData.code =0;
responeData.message = "导入数据为空!";
return responeData;
}
// 提取材质编码并验证非空
var materialCodes = new List<string>();
foreach (var row in temeplateDtoIns)
{
var code = (row.MaterialCode ?? string.Empty).Trim();
if (string.IsNullOrWhiteSpace(code))
{
responeData.code =0;
responeData.message = "导入数据中材质列不能为空!";
return responeData;
}
materialCodes.Add(code);
}
var materialCodeList = materialCodes.Distinct().ToList();
// 从数据库验证这些材质编码是否存在
var existMaterials = (from m in Funs.DB.Base_Material
where materialCodeList.Contains(m.MaterialCode)
select new { m.MaterialCode, m.MaterialId }).ToList();
var existCodes = existMaterials.Select(x => x.MaterialCode).ToList();
var notExist = materialCodeList.Except(existCodes).ToList();
if (notExist.Count >0)
{
responeData.code =0;
responeData.message = string.Join(",", notExist) + " 材质不存在!";
return responeData;
}
// 插入数据
foreach (var row in temeplateDtoIns)
{
var code = (row.MaterialCode ?? string.Empty).Trim();
var mat = existMaterials.FirstOrDefault(x => x.MaterialCode == code);
if (mat == null)
{
responeData.code =0;
responeData.message = code + " 材质不存在!";
return responeData;
}
var colorName = string.IsNullOrWhiteSpace(row.ColorName) ? "—" : row.ColorName.Trim();
var colorCardNo = string.IsNullOrWhiteSpace(row.ColorCardNo) ? "—" : row.ColorCardNo.Trim();
var rgb = string.IsNullOrWhiteSpace(row.RGB) ? null : row.RGB.Trim();
var remark = string.IsNullOrWhiteSpace(row.Remark) ? null : row.Remark.Trim();
Model.Base_MaterialColor table = new Model.Base_MaterialColor
{
MaterialColorId = BLL.SQLHelper.GetNewID(typeof(Model.Base_MaterialColor)),
UnitId = string.Empty,
ProjectId = projectid,
MaterialId = mat.MaterialId,
ColorName = colorName,
ColorCardNo = colorCardNo,
RGB = rgb,
Remark = remark
};
Funs.DB.Base_MaterialColor.InsertOnSubmit(table);
}
Funs.DB.SubmitChanges();
responeData.code =1;
responeData.message = "导入成功!";
responeData.data = temeplateDtoIns.Count;
return responeData;
}
catch (Exception ex)
{
responeData.code =0;
responeData.message = "导入失败:" + ex.ToString();
return responeData;
}
}
}
}
@@ -35,7 +35,12 @@ namespace BLL
{ "预制散件" ,(int)TypeInt.},
{ "其他材料" ,(int)TypeInt.},
};
public static Dictionary<string, int> CategoryIntMap = new Dictionary<string, int>
{
{ "打捆" ,(int)CategoryInt.},
{ "装箱" ,(int)CategoryInt.},
{ "散装" ,(int)CategoryInt.},
};
#endregion Fields
#region Enums
@@ -46,6 +51,12 @@ namespace BLL
= 20,
= 30,
}
public enum CategoryInt : int
{
= 10,
= 20,
= 30,
}
#endregion Enums
@@ -73,6 +84,7 @@ namespace BLL
TrainNumber = newtable.TrainNumber,
TrainNumberId = newtable.TrainNumberId,
TypeInt = newtable.TypeInt,
CategoryInt = newtable.CategoryInt,
CompileMan = newtable.CompileMan,
CompileDate = newtable.CompileDate
};
@@ -227,7 +239,9 @@ namespace BLL
StackingPosition = x.StackingPosition,
State = x.State,
TypeInt = x.TypeInt,
CategoryInt = x.CategoryInt,
TypeString = GetTypeString(x.TypeInt),
CategoryString = GetCategoryString(x.CategoryInt),
ReceiveMan = train.ContactName,//t.PersonName,
ReceiveDate = x.ReceiveDate.HasValue ? string.Format("{0:g}", x.ReceiveDate) : "",
PlanStartDate = GetMinPlanStartDate(x.PackagingManageId),
@@ -261,7 +275,10 @@ namespace BLL
{
return TypeIntMap.FirstOrDefault(c => c.Value == TypeInt).Key;
}
public static string GetCategoryString(int? CategoryInt)
{
return CategoryIntMap.FirstOrDefault(c => c.Value == CategoryInt).Key;
}
/// <summary>
/// 管线下拉框
/// </summary>
@@ -313,6 +330,7 @@ namespace BLL
table.TrainNumber = newtable.TrainNumber;
table.TrainNumberId = newtable.TrainNumberId;
table.TypeInt = newtable.TypeInt;
table.CategoryInt = newtable.CategoryInt;
db1.SubmitChanges();
}
}
@@ -344,6 +362,9 @@ namespace BLL
public string TrainNumberOld { get; set; }
public int? TypeInt { get; set; }
public string TypeString { get; set; }
public int? CategoryInt { get; set; }
public string CategoryString { get; set; }
#endregion Properties
}
@@ -1,19 +1,11 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
namespace BLL
{
public static class TrainNumberManageService
{
/// <summary>
/// 记录数
/// </summary>
public static int Count
{
get;
set;
}
{
private static IQueryable<Model.HJGL_TrainNumberManage> GetByQueryModle(Model.HJGL_TrainNumberManage table)
{
var q = from x in Funs.DB.HJGL_TrainNumberManage select x;
@@ -71,11 +63,11 @@ namespace BLL
return GetByQueryModle(table).ToList();
}
public static (List<Model.HJGL_TrainNumberManage> Data, int Total) GetListByQueryModle(Model.HJGL_TrainNumberManage table, int pageIndex = 0, int pageSize = 20)
public static (List<Model.HJGL_TrainNumberManage> Data, int Total) GetListByQueryModle(Model.HJGL_TrainNumberManage table, int pageIndex = 1, int pageSize = 20)
{
var baseQuery = GetByQueryModle(table);
var pagedData = baseQuery
.Skip((pageIndex) * pageSize)
.Skip((pageIndex-1) * pageSize)
.Take(pageSize)
.ToList();
@@ -94,10 +86,10 @@ namespace BLL
public static string GetNewTrainNumber(string ProjectId)
{
var q = from x in Funs.DB.HJGL_TrainNumberManage
where x.ProjectId == ProjectId
where x.ProjectId == ProjectId
select x.TrainNumber;
var max = q.Count();
var NewTrainNumber = (max + 1).ToString().PadLeft(2, '0');
var NewTrainNumber = string.Format("{0:yyyyMMdd}", DateTime.Now)+"-"+(max + 1).ToString().PadLeft(3, '0');
return NewTrainNumber;
}
@@ -353,13 +353,15 @@ namespace BLL
dt.Columns.Add("PipelineCode");
dt.Columns.Add("ManterialCode");
dt.Columns.Add("Specification");
dt.Columns.Add("MaterialColor");
for (int i = 0; i < tb.Rows.Count; i++)
{
var newRows = dt.NewRow();
newRows["PipelineCode"] = tb.Rows[i]["PipelineCode"].ToString();
newRows["ManterialCode"] = getMaterialCodeByPipelineId(tb.Rows[i]["PipelineId"].ToString());
newRows["ManterialCode"] = getMaterialCodeByPipelineId(tb.Rows[i]["PipelineId"].ToString(),out string MaterialColor);
newRows["Specification"] = getSpecificationByPipelineId(tb.Rows[i]["PipelineId"].ToString());
newRows["MaterialColor"] = MaterialColor;
dt.Rows.Add(newRows);
}
@@ -878,18 +880,47 @@ namespace BLL
#region
public static string getMaterialCodeByPipelineId(string pipelineId)
public static string getMaterialCodeByPipelineId(string pipelineId, out string materialColor)
{
string materialCode = string.Empty;
materialColor = string.Empty;
if (!string.IsNullOrEmpty(pipelineId))
{
var weldjoint = (from x in Funs.DB.HJGL_WeldJoint
join y in Funs.DB.Base_Material on x.Material1Id equals y.MaterialId
join z in Funs.DB.Base_Material on x.Material2Id equals z.MaterialId
where x.PipelineId == pipelineId
select new { MaterialCode1 = y.MaterialCode, MaterialCode2 = z.MaterialCode }).FirstOrDefault();
select new
{
MaterialId1 = y.MaterialId,
MaterialCode1 = y.MaterialCode,
MaterialId2 = z.MaterialId,
MaterialCode2 = z.MaterialCode,
x.ProjectId,
}).FirstOrDefault();
if (weldjoint != null)
{
if (!string.IsNullOrEmpty(weldjoint.MaterialId1))
{
var projectSet = Project_SysSetService.GetSysSetBySetId("11", weldjoint.ProjectId);
Model.BaseMaterialcolorOutput queryModel = new Model.BaseMaterialcolorOutput();
queryModel.ProjectId = weldjoint.ProjectId;
queryModel.MaterialId = weldjoint.MaterialId1;
var material1 = BLL.BaseMaterialcolorService.GetListByQueryModle(queryModel).FirstOrDefault();
if (material1 != null)
{
if (projectSet != null && projectSet.SetValue == "1")
{
materialColor = material1.ColorName;
}
else
{
materialColor= material1.ColorCardNo;
}
}
}
if (!string.IsNullOrEmpty(weldjoint.MaterialCode1) && !string.IsNullOrEmpty(weldjoint.MaterialCode2))
{
materialCode = weldjoint.MaterialCode1 + "/" + weldjoint.MaterialCode2;
@@ -908,8 +939,7 @@ namespace BLL
}
}
return materialCode;
}
}
public static string getSpecificationByPipelineId(string pipelineId)
{
string spcificaation = string.Empty;
@@ -497,6 +497,7 @@ namespace BLL
Model.SGGLDB db = Funs.DB;
var q = (from x in db.HJGL_Pipeline_Component
join y in db.HJGL_Pipeline on x.PipelineId equals y.PipelineId
orderby y.PipelineCode,x.PipelineComponentCode
where y.ProjectId.Contains(projectId) && x.State.Equals(State1) &&
(string.IsNullOrEmpty(pipelineCode) || y.PipelineCode.Contains(pipelineCode)) &&
(string.IsNullOrEmpty(pipelineComponentCode) || x.PipelineComponentCode.Contains(pipelineComponentCode)) &&