feat: 完善材料条码与焊接业务功能
This commit is contained in:
@@ -166,7 +166,49 @@ namespace BLL
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 焊接探伤类型,探伤比例
|
||||
#region 焊接方法、焊缝类型、探伤类型、探伤比例
|
||||
/// <summary>
|
||||
/// 获取焊接方法
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static List<Model.BaseInfoItem> GetWeldingMethod()
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var getDataLists = (from x in db.Base_WeldingMethod
|
||||
orderby x.WeldingMethodCode
|
||||
select new Model.BaseInfoItem
|
||||
{
|
||||
BaseInfoId = x.WeldingMethodId,
|
||||
BaseInfoCode = x.WeldingMethodCode,
|
||||
BaseInfoName = x.WeldingMethodName
|
||||
}
|
||||
).ToList();
|
||||
return getDataLists;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取焊缝类型
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static List<Model.BaseInfoItem> GetWeldType()
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var getDataLists = (from x in db.Base_WeldType
|
||||
orderby x.WeldTypeCode
|
||||
select new Model.BaseInfoItem
|
||||
{
|
||||
BaseInfoId = x.WeldTypeId,
|
||||
BaseInfoCode = x.WeldTypeCode,
|
||||
BaseInfoName = x.WeldTypeName
|
||||
}
|
||||
).ToList();
|
||||
return getDataLists;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取探伤类型
|
||||
/// </summary>
|
||||
|
||||
@@ -497,6 +497,7 @@ namespace BLL
|
||||
x.MaterialCode2,
|
||||
x.Number,
|
||||
w.WeldJointId,
|
||||
w.WeldJointCode,
|
||||
w.Size,
|
||||
w.WeldingDailyId
|
||||
}).ToList();
|
||||
@@ -528,16 +529,22 @@ namespace BLL
|
||||
var materialGroups = componentMaterialRows
|
||||
.Select(x => new
|
||||
{
|
||||
WeldJointId = x.WeldJointId,
|
||||
WeldJointCode = x.WeldJointCode,
|
||||
WeldJointDin = x.Size ?? 0,
|
||||
MaterialCode = GetExportMaterialCode(x.MaterialCode, x.MaterialCode2, materialCodeLibByMaterialCode),
|
||||
Quantity = x.Number ?? 0
|
||||
})
|
||||
.Where(x => !string.IsNullOrEmpty(x.MaterialCode))
|
||||
.GroupBy(x => x.MaterialCode)
|
||||
.OrderBy(x => x.Key)
|
||||
.GroupBy(x => new { x.MaterialCode, x.WeldJointId, x.WeldJointCode, x.WeldJointDin })
|
||||
.OrderBy(x => x.Key.WeldJointCode)
|
||||
.ThenBy(x => x.Key.MaterialCode)
|
||||
.Select(x => new
|
||||
{
|
||||
MaterialCode = x.Key,
|
||||
Quantity = x.Sum(y => y.Quantity)
|
||||
MaterialCode = x.Key.MaterialCode,
|
||||
Quantity = x.Sum(y => y.Quantity),
|
||||
WeldJointCode = x.Key.WeldJointCode,
|
||||
WeldJointDin = x.Key.WeldJointDin
|
||||
})
|
||||
.ToList();
|
||||
return new Tw_PartialWeldedComponentOutput
|
||||
@@ -555,6 +562,8 @@ namespace BLL
|
||||
UnweldedDin = weldJoints
|
||||
.Where(x => string.IsNullOrEmpty(x.WeldingDailyId))
|
||||
.Sum(x => x.Size ?? 0),
|
||||
WeldJointCode = string.Join("\n", materialGroups.Select(x => x.WeldJointCode)),
|
||||
WeldJointDin = string.Join("\n", materialGroups.Select(x => x.WeldJointDin.ToString())),
|
||||
MaterialCode = string.Join("\n", materialGroups.Select(x => x.MaterialCode)),
|
||||
MaterialQuantity = string.Join("\n", materialGroups.Select(x => x.Quantity.ToString()))
|
||||
};
|
||||
|
||||
@@ -174,8 +174,7 @@ namespace BLL
|
||||
}
|
||||
var result = 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 result
|
||||
|
||||
return from x in result
|
||||
select new Model.Tw_InOutMasterOutput
|
||||
{
|
||||
Id = x.Id,
|
||||
|
||||
@@ -3,11 +3,14 @@ using Model;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public static class TwInputdetailBarCodeService
|
||||
{
|
||||
private static readonly object BarCodeLock = new object();
|
||||
|
||||
public static int Count
|
||||
{
|
||||
get;
|
||||
@@ -52,18 +55,23 @@ namespace BLL
|
||||
MaterialDef = mat.MaterialDef,
|
||||
MaterialSpec = mat.MaterialSpec,
|
||||
MaterialUnit = mat.MaterialUnit,
|
||||
BarCode = x.MaterialCode
|
||||
BarCode = x.BarCode,
|
||||
Quantity = x.Quantity
|
||||
};
|
||||
|
||||
return q.ToList();
|
||||
}
|
||||
public static List<Tw_InputDetailBarCodeOutput> GetListData(string materialCode)
|
||||
{
|
||||
var q = from mat in Funs.DB.HJGL_MaterialCodeLib
|
||||
where
|
||||
mat.MaterialCode == materialCode
|
||||
var q = from detailBarCode in Funs.DB.Tw_InputDetailBarCode
|
||||
join mat in Funs.DB.HJGL_MaterialCodeLib on detailBarCode.MaterialCode equals mat.MaterialCode
|
||||
where detailBarCode.MaterialCode == materialCode
|
||||
orderby detailBarCode.BarCode
|
||||
select new Tw_InputDetailBarCodeOutput
|
||||
{
|
||||
Id = detailBarCode.Id,
|
||||
InputDetailId = detailBarCode.InputDetailId,
|
||||
InputMasterId = detailBarCode.InputMasterId,
|
||||
MaterialCode = mat.MaterialCode,
|
||||
Code = mat.Code,
|
||||
HeatNo = mat.HeatNo,
|
||||
@@ -72,7 +80,8 @@ namespace BLL
|
||||
MaterialDef = mat.MaterialDef,
|
||||
MaterialSpec = mat.MaterialSpec,
|
||||
MaterialUnit = mat.MaterialUnit,
|
||||
BarCode = mat.MaterialCode
|
||||
BarCode = detailBarCode.BarCode,
|
||||
Quantity = detailBarCode.Quantity
|
||||
};
|
||||
|
||||
return q.ToList();
|
||||
@@ -88,17 +97,65 @@ namespace BLL
|
||||
return;
|
||||
}
|
||||
|
||||
string id = SQLHelper.GetNewID();
|
||||
Tw_InputDetailBarCode table = new Tw_InputDetailBarCode
|
||||
lock (BarCodeLock)
|
||||
{
|
||||
Id = id,
|
||||
InputDetailId = inputDetail.Id,
|
||||
InputMasterId = inputMaster.Id,
|
||||
MaterialCode = inputDetail.MaterialCode,
|
||||
BarCode = BuildBarCode(inputMaster, inputDetail, id)
|
||||
};
|
||||
Funs.DB.Tw_InputDetailBarCode.InsertOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
if (IsExist(inputDetail.Id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string id = SQLHelper.GetNewID();
|
||||
bool isMeter = IsMeterMaterial(inputDetail.MaterialCode);
|
||||
Tw_InputDetailBarCode table = new Tw_InputDetailBarCode
|
||||
{
|
||||
Id = id,
|
||||
InputDetailId = inputDetail.Id,
|
||||
InputMasterId = inputMaster.Id,
|
||||
MaterialCode = inputDetail.MaterialCode,
|
||||
// 按米计量的管材由扫码后录入实际长度,其他材料每个条码固定代表1件。
|
||||
Quantity = isMeter ? (decimal?)null : 1m,
|
||||
BarCode = isMeter ? BuildNextBarCode(inputDetail.MaterialCode) : inputDetail.MaterialCode
|
||||
};
|
||||
Funs.DB.Tw_InputDetailBarCode.InsertOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 为指定管材入库明细生成下一个流水条码。
|
||||
/// </summary>
|
||||
public static string AddNextByInputDetailId(string inputDetailId)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(inputDetailId))
|
||||
{
|
||||
throw new ArgumentException("入库明细不能为空。");
|
||||
}
|
||||
|
||||
lock (BarCodeLock)
|
||||
{
|
||||
var inputDetail = Funs.DB.Tw_InputDetail.FirstOrDefault(x => x.Id == inputDetailId);
|
||||
if (inputDetail == null)
|
||||
{
|
||||
throw new InvalidOperationException("未找到入库明细。");
|
||||
}
|
||||
if (!IsMeterMaterial(inputDetail.MaterialCode))
|
||||
{
|
||||
throw new InvalidOperationException("只有单位为米的管材可以生成新条码。");
|
||||
}
|
||||
|
||||
string barCode = BuildNextBarCode(inputDetail.MaterialCode);
|
||||
Funs.DB.Tw_InputDetailBarCode.InsertOnSubmit(new Tw_InputDetailBarCode
|
||||
{
|
||||
Id = SQLHelper.GetNewID(),
|
||||
InputDetailId = inputDetail.Id,
|
||||
InputMasterId = inputDetail.InputMasterId,
|
||||
MaterialCode = inputDetail.MaterialCode,
|
||||
BarCode = barCode,
|
||||
Quantity = null
|
||||
});
|
||||
Funs.DB.SubmitChanges();
|
||||
return barCode;
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeleteByInputMasterId(string inputMasterId)
|
||||
@@ -140,7 +197,41 @@ namespace BLL
|
||||
/// </summary>
|
||||
public static string BuildBarCode(Tw_InputMaster inputMaster, Tw_InputDetail inputDetail, string barCodeDetailId)
|
||||
{
|
||||
return inputDetail == null ? string.Empty : inputDetail.MaterialCode;
|
||||
if (inputDetail == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
return IsMeterMaterial(inputDetail.MaterialCode)
|
||||
? BuildNextBarCode(inputDetail.MaterialCode)
|
||||
: inputDetail.MaterialCode;
|
||||
}
|
||||
|
||||
private static bool IsMeterMaterial(string materialCode)
|
||||
{
|
||||
string materialUnit = Funs.DB.HJGL_MaterialCodeLib
|
||||
.Where(x => x.MaterialCode == materialCode)
|
||||
.Select(x => x.MaterialUnit)
|
||||
.FirstOrDefault();
|
||||
return string.Equals((materialUnit ?? string.Empty).Trim(), "米", StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
private static string BuildNextBarCode(string materialCode)
|
||||
{
|
||||
string prefix = materialCode + "-";
|
||||
int maxSequence = 0;
|
||||
var barCodes = Funs.DB.Tw_InputDetailBarCode
|
||||
.Where(x => x.MaterialCode == materialCode && x.BarCode.StartsWith(prefix))
|
||||
.Select(x => x.BarCode)
|
||||
.ToList();
|
||||
foreach (string barCode in barCodes)
|
||||
{
|
||||
int sequence;
|
||||
if (int.TryParse(barCode.Substring(prefix.Length), out sequence) && sequence > maxSequence)
|
||||
{
|
||||
maxSequence = sequence;
|
||||
}
|
||||
}
|
||||
return prefix + (maxSequence + 1).ToString("D3");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,8 @@ namespace BLL
|
||||
PipelineComponentCode = y.PipelineComponentCode,
|
||||
MaterialName = mat.MaterialName,
|
||||
MaterialDef = mat.MaterialDef,
|
||||
MaterialUnit = mat.MaterialUnit,
|
||||
BarCodeCount = Funs.DB.Tw_InputDetailBarCode.Count(barCode => barCode.InputDetailId == x.Id),
|
||||
SortIndex = x.SortIndex
|
||||
}
|
||||
;
|
||||
@@ -74,6 +76,16 @@ namespace BLL
|
||||
return from x in q
|
||||
select x;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取按米计量的管材入库明细。
|
||||
/// </summary>
|
||||
public static List<Model.Tw_InOutDetailOutput> GetPipeListData(Model.Tw_InOutDetailOutput table)
|
||||
{
|
||||
return GetByModle(table)
|
||||
.Where(x => x.MaterialUnit != null && x.MaterialUnit.Trim() == "米")
|
||||
.ToList();
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static Model.Tw_InputDetail GetById(string Id)
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace BLL
|
||||
from unit in units.DefaultIfEmpty()
|
||||
join warehouse in Funs.DB.Base_Warehouse on x.WarehouseId equals warehouse.WarehouseId into warehouses
|
||||
from warehouse in warehouses.DefaultIfEmpty()
|
||||
orderby x.CreateDate descending
|
||||
where
|
||||
(string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) &&
|
||||
(string.IsNullOrEmpty(table.InOutPlanMasterId) || x.InOutPlanMasterId.Contains(table.InOutPlanMasterId)) &&
|
||||
|
||||
@@ -16,12 +16,13 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据材料主编码获取条码扫码所需的材料信息。
|
||||
/// 根据入库条码获取扫码所需的材料信息。
|
||||
/// </summary>
|
||||
public static Model.MaterialCodeLibBarCodeOutput GetBarCodeMaterialInfo(string materialCode)
|
||||
public static Model.MaterialCodeLibBarCodeOutput GetBarCodeMaterialInfo(string barCode)
|
||||
{
|
||||
return (from x in Funs.DB.HJGL_MaterialCodeLib
|
||||
where x.MaterialCode == materialCode
|
||||
return (from detailBarCode in Funs.DB.Tw_InputDetailBarCode
|
||||
join x in Funs.DB.HJGL_MaterialCodeLib on detailBarCode.MaterialCode equals x.MaterialCode
|
||||
where detailBarCode.BarCode == barCode
|
||||
select new Model.MaterialCodeLibBarCodeOutput
|
||||
{
|
||||
MaterialCode = x.MaterialCode,
|
||||
@@ -31,10 +32,36 @@
|
||||
MaterialName = x.MaterialName,
|
||||
MaterialDef = x.MaterialDef,
|
||||
MaterialSpec = x.MaterialSpec,
|
||||
MaterialUnit = x.MaterialUnit
|
||||
MaterialUnit = x.MaterialUnit,
|
||||
BarCode = detailBarCode.BarCode,
|
||||
Quantity = detailBarCode.Quantity
|
||||
}).FirstOrDefault();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存指定入库条码的数量,并返回更新后的扫码信息。
|
||||
/// </summary>
|
||||
public static Model.MaterialCodeLibBarCodeOutput SaveBarCodeQuantity(string barCode, decimal quantity)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(barCode))
|
||||
{
|
||||
throw new System.ArgumentException("条码不能为空。");
|
||||
}
|
||||
if (quantity <= 0m)
|
||||
{
|
||||
throw new System.ArgumentException("数量必须大于0。");
|
||||
}
|
||||
|
||||
var detailBarCode = Funs.DB.Tw_InputDetailBarCode.FirstOrDefault(x => x.BarCode == barCode);
|
||||
if (detailBarCode == null)
|
||||
{
|
||||
throw new System.InvalidOperationException("未找到对应的入库条码。");
|
||||
}
|
||||
detailBarCode.Quantity = quantity;
|
||||
Funs.DB.SubmitChanges();
|
||||
return GetBarCodeMaterialInfo(barCode);
|
||||
}
|
||||
|
||||
public static List<Model.HJGL_MaterialCodeLib> GetMaterialCodeLibList()
|
||||
{
|
||||
var q = (from x in Funs.DB.HJGL_MaterialCodeLib select x).ToList();
|
||||
|
||||
Reference in New Issue
Block a user