1
This commit is contained in:
parent
caee66b131
commit
15bc3b22fb
@ -58,6 +58,16 @@ namespace ZR.Model.MES.wms.Dto
|
||||
|
||||
public DateTime? UpdatedTime { get; set; }
|
||||
}
|
||||
|
||||
public class WmOneTimeInventoryTableDto
|
||||
{
|
||||
public int Total { get; set; }
|
||||
public int StocktakingTotal { get; set; }
|
||||
public int QuantitySum { get; set; }
|
||||
public int RealQuantitySum { get; set; }
|
||||
public List<WmOneTimeInventoryDto> Result { get; set; }
|
||||
}
|
||||
|
||||
// 一次合格(产成品)导出
|
||||
[SugarTable("wm_one_time_record", "一次合格表")]
|
||||
public class WmOneTimeInventoryExportDto
|
||||
|
||||
@ -61,6 +61,16 @@ namespace ZR.Model.MES.wms.Dto
|
||||
|
||||
public DateTime? UpdatedTime { get; set; }
|
||||
}
|
||||
|
||||
public class WmPolishInventoryTableDto
|
||||
{
|
||||
public int Total { get; set; }
|
||||
public int StocktakingTotal { get; set; }
|
||||
public int QuantitySum { get; set; }
|
||||
public int RealQuantitySum { get; set; }
|
||||
public List<WmPolishInventoryDto> Result { get; set; }
|
||||
}
|
||||
|
||||
[SugarTable("wm_polish_inventory", "抛光表")]
|
||||
public class WmPolishInventoryExportDto
|
||||
{
|
||||
@ -69,11 +79,12 @@ namespace ZR.Model.MES.wms.Dto
|
||||
public string 颜色 { get; set; }
|
||||
public string 规格 { get; set; }
|
||||
public string 描述 { get; set; }
|
||||
|
||||
[SugarColumn(ColumnName = "quantity")]
|
||||
public int 盘点数 { get; set; } = 0;
|
||||
public int 现有库存 { get; set; } = 0;
|
||||
|
||||
[SugarColumn(ColumnName = "CREATED_TIME")]
|
||||
public DateTime? 盘点时间 { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1314,7 +1314,10 @@ namespace ZR.Service.mes.qc
|
||||
var predicateParkingSensor = Expressionable
|
||||
.Create<QcQualityStatisticsFirst>()
|
||||
.And(it => ParkingSensorPartNumberList.Contains(it.FinishedPartNumber))
|
||||
.AndIF(!string.IsNullOrEmpty(query.Partnumber), it => it.FinishedPartNumber == query.Partnumber)
|
||||
.AndIF(
|
||||
!string.IsNullOrEmpty(query.Partnumber),
|
||||
it => it.FinishedPartNumber == query.Partnumber
|
||||
)
|
||||
.And(it => it.StartTime >= boardData.OneTimeStockTime)
|
||||
.ToExpression();
|
||||
// 倒车雷达
|
||||
@ -1408,6 +1411,12 @@ namespace ZR.Service.mes.qc
|
||||
{
|
||||
foreach (var partNumber in partNumbers)
|
||||
{
|
||||
startTime =
|
||||
Context
|
||||
.Queryable<WmPolishInventory>()
|
||||
.Where(it => it.Partnumber == partNumber)
|
||||
.Select(it => it.UpdatedTime)
|
||||
.First() ?? startTime;
|
||||
// 盘点数
|
||||
int polishWarehouseTotal =
|
||||
Context
|
||||
@ -1475,6 +1484,12 @@ namespace ZR.Service.mes.qc
|
||||
{
|
||||
foreach (var partNumber in partNumbers)
|
||||
{
|
||||
startTime =
|
||||
Context
|
||||
.Queryable<WmOneTimeInventory>()
|
||||
.Where(it => it.Partnumber == partNumber)
|
||||
.Select(it => it.UpdatedTime)
|
||||
.First() ?? startTime;
|
||||
// 基本值
|
||||
int oneTimeWarehouseTotal =
|
||||
Context
|
||||
@ -1497,7 +1512,7 @@ namespace ZR.Service.mes.qc
|
||||
.Where(ParkingSensorPartNumberCheck.ToExpression())
|
||||
.Select(it => it.Partnumber)
|
||||
.ToList();
|
||||
/* var predicateParkingSensor = Expressionable
|
||||
/* var predicateParkingSensor = Expressionable
|
||||
.Create<QcQualityStatisticsFirst>()
|
||||
.And(it => ParkingSensorPartNumberList.Contains(it.FinishedPartNumber))
|
||||
.And(it => it.FinishedPartNumber == partNumber)
|
||||
@ -1513,11 +1528,12 @@ namespace ZR.Service.mes.qc
|
||||
int productQualifiedTotal =
|
||||
Context
|
||||
.Queryable<QcQualityStatisticsFirst>()
|
||||
.Where(it => !ParkingSensorPartNumberList.Contains(it.FinishedPartNumber))
|
||||
.Where(it =>
|
||||
!ParkingSensorPartNumberList.Contains(it.FinishedPartNumber)
|
||||
)
|
||||
.Where(it => it.FinishedPartNumber == partNumber)
|
||||
.Where(it => it.StartTime >= startTime)
|
||||
.Sum(it => it.QualifiedNumber)
|
||||
?? 0;
|
||||
.Sum(it => it.QualifiedNumber) ?? 0;
|
||||
productQualifiedTotal = productQualifiedTotal / 3;
|
||||
// 抛光合格
|
||||
int polishQualifiedTotal =
|
||||
|
||||
@ -9,7 +9,7 @@ namespace ZR.Service.mes.wms.IService
|
||||
/// </summary>
|
||||
public interface IWmOneTimeInventoryService : IBaseService<WmOneTimeInventory>
|
||||
{
|
||||
PagedInfo<WmOneTimeInventoryDto> GetList(WmOneTimeInventoryQueryDto parm);
|
||||
WmOneTimeInventoryTableDto GetList(WmOneTimeInventoryQueryDto parm);
|
||||
|
||||
/// <summary>
|
||||
/// 一次合格导出
|
||||
|
||||
@ -10,7 +10,7 @@ namespace ZR.Service.mes.wms.IService
|
||||
/// </summary>
|
||||
public interface IWmPolishInventoryService : IBaseService<WmPolishInventory>
|
||||
{
|
||||
PagedInfo<WmPolishInventoryDto> GetList(WmPolishInventoryQueryDto parm);
|
||||
WmPolishInventoryTableDto GetList(WmPolishInventoryQueryDto parm);
|
||||
|
||||
/// <summary>
|
||||
/// 获取导出数据
|
||||
|
||||
@ -28,9 +28,85 @@ namespace ZR.Service.mes.wms
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<WmOneTimeInventoryDto> GetList(WmOneTimeInventoryQueryDto parm)
|
||||
public WmOneTimeInventoryTableDto GetList(WmOneTimeInventoryQueryDto parm)
|
||||
{
|
||||
List<string> partnumberByDescription = new();
|
||||
var list = Context
|
||||
.Queryable<WmMaterial>()
|
||||
.LeftJoin<WmOneTimeInventory>((m, p) => m.Partnumber == p.Partnumber)
|
||||
.Distinct()
|
||||
.WhereIF(
|
||||
!string.IsNullOrEmpty(parm.Description),
|
||||
(m, p) => m.Description.Contains(parm.Description)
|
||||
)
|
||||
.WhereIF(
|
||||
!string.IsNullOrEmpty(parm.Partnumber),
|
||||
(m, p) => m.Partnumber.Contains(parm.Partnumber)
|
||||
)
|
||||
.Where((m, p) => m.Status == 1)
|
||||
.Where((m, p) => m.Type == 1)
|
||||
.WhereIF(parm.Status > -1, (m, p) => p.Status == parm.Status)
|
||||
.WhereIF(parm.Type > 0, (m, p) => p.Type == parm.Type)
|
||||
.OrderBy((m, p) => m.Description)
|
||||
.Select(
|
||||
(m, p) =>
|
||||
new WmOneTimeInventoryDto
|
||||
{
|
||||
RealQuantity = 0,
|
||||
Color = m.Color,
|
||||
Specification = m.Specification,
|
||||
Description = m.Description,
|
||||
Id = p.Id,
|
||||
BlankNum = p.BlankNum,
|
||||
Partnumber = p.Partnumber,
|
||||
Quantity = p.Quantity,
|
||||
MaxNum = p.MaxNum,
|
||||
MinNum = p.MinNum,
|
||||
WarnNum = p.WarnNum,
|
||||
Type = p.Type,
|
||||
Status = p.Status,
|
||||
Remark = p.Remark,
|
||||
CreatedBy = p.CreatedBy,
|
||||
CreatedTime = p.CreatedTime,
|
||||
UpdatedBy = p.UpdatedBy,
|
||||
UpdatedTime = p.UpdatedTime,
|
||||
}
|
||||
)
|
||||
.ToList();
|
||||
foreach (WmOneTimeInventoryDto item in list)
|
||||
{
|
||||
// 获取实际库存
|
||||
List<string> partnumbers = new()
|
||||
{
|
||||
item.Partnumber
|
||||
};
|
||||
Dictionary<string, int> dict = GetBatchOneTimeRealPartNum(partnumbers);
|
||||
item.RealQuantity = dict.TryGetValue(item.Partnumber, out int value) ? value : 0;
|
||||
}
|
||||
|
||||
list = list.Where(it => it.RealQuantity != 0 || it.Quantity != 0)
|
||||
.Where(it => !string.IsNullOrEmpty(it.Partnumber))
|
||||
.DistinctBy(it => it.Partnumber)
|
||||
.ToList();
|
||||
|
||||
int total = list.Count;
|
||||
// 仓库总盘点零件数
|
||||
int StocktakingTotal =
|
||||
Context.Queryable<WmOneTimeInventory>().Sum(it => it.Quantity) ?? 0;
|
||||
// 仓库当前查询盘点零件数
|
||||
int QuantitySum = list.Sum(it => it.Quantity) ?? 0;
|
||||
// 仓库当前查询实际零件数
|
||||
int RealQuantitySum = list.Sum(it => it.RealQuantity);
|
||||
WmOneTimeInventoryTableDto response = new()
|
||||
{
|
||||
Total = total,
|
||||
StocktakingTotal = StocktakingTotal,
|
||||
QuantitySum = QuantitySum,
|
||||
RealQuantitySum = RealQuantitySum,
|
||||
Result = list.Skip((parm.PageNum - 1) * parm.PageSize).Take(parm.PageSize).ToList(),
|
||||
};
|
||||
return response;
|
||||
|
||||
/*List<string> partnumberByDescription = new();
|
||||
if (parm != null && !string.IsNullOrEmpty(parm.Description))
|
||||
{
|
||||
partnumberByDescription = Context
|
||||
@ -84,7 +160,7 @@ namespace ZR.Service.mes.wms
|
||||
item.RealQuantity = dict.TryGetValue(item.Partnumber, out int value) ? value : 0;
|
||||
}
|
||||
}
|
||||
return response;
|
||||
return response;*/
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -498,7 +574,8 @@ namespace ZR.Service.mes.wms
|
||||
try
|
||||
{
|
||||
// 盘点时间
|
||||
DateTime? checkTime = Context
|
||||
DateTime? checkTime =
|
||||
Context
|
||||
.Queryable<WmOneTimeInventory>()
|
||||
.Where(it => it.Status == 1)
|
||||
.Select(it => it.CreatedTime)
|
||||
@ -522,7 +599,8 @@ namespace ZR.Service.mes.wms
|
||||
/// <returns></returns>
|
||||
public (string, object, object) ImportExcel(List<WmOneTimeInventoryExportDto> importList)
|
||||
{
|
||||
List<WmOneTimeInventory> wmOneTimeInventorylist = importList.Select(it => new WmOneTimeInventory
|
||||
List<WmOneTimeInventory> wmOneTimeInventorylist = importList
|
||||
.Select(it => new WmOneTimeInventory
|
||||
{
|
||||
Id = SnowFlakeSingle.Instance.NextId().ToString(),
|
||||
Type = 1,
|
||||
@ -535,27 +613,31 @@ namespace ZR.Service.mes.wms
|
||||
CreatedTime = it.盘点时间 ?? DateTime.Now.ToLocalTime(),
|
||||
Partnumber = it.零件号,
|
||||
Quantity = it.盘点数
|
||||
}).ToList();
|
||||
var x = Context.Storageable(wmOneTimeInventorylist)
|
||||
})
|
||||
.ToList();
|
||||
var x = Context
|
||||
.Storageable(wmOneTimeInventorylist)
|
||||
.SplitError(x => x.Item.Partnumber.IsEmpty(), "零件号不能为空")
|
||||
.SplitError(x => x.Item.Quantity.IsEmpty(), "盘点数不能为空")
|
||||
.SplitUpdate(it => it.Any()) // 数据库存在更新
|
||||
.SplitDelete(it => it.Item.Quantity == 0) //盘点数为0的不导入
|
||||
.SplitInsert(it => true) // 其余插入
|
||||
.WhereColumns(it => it.Partnumber)//如果不是主键可以这样实现(多字段it=>new{it.x1,it.x2})
|
||||
.WhereColumns(it => it.Partnumber) //如果不是主键可以这样实现(多字段it=>new{it.x1,it.x2})
|
||||
.ToStorage();
|
||||
|
||||
// 清空全部
|
||||
var result = x.AsInsertable.ExecuteCommand();//不存在则插入;
|
||||
var result2 = x.AsUpdateable.IgnoreColumns(it => new { it.Id }).ExecuteCommand();//存在则修改;
|
||||
var result = x.AsInsertable.ExecuteCommand(); //不存在则插入;
|
||||
var result2 = x.AsUpdateable.IgnoreColumns(it => new { it.Id }).ExecuteCommand(); //存在则修改;
|
||||
var result3 = x.AsDeleteable.ExecuteCommand(); //盘点数为0的删除;
|
||||
string msg = string.Format(" 插入{0} 更新{1} 错误数据{2} 不计算数据{3} 删除数据{4} 总共{5}",
|
||||
string msg = string.Format(
|
||||
" 插入{0} 更新{1} 错误数据{2} 不计算数据{3} 删除数据{4} 总共{5}",
|
||||
x.InsertList.Count,
|
||||
x.UpdateList.Count,
|
||||
x.ErrorList.Count,
|
||||
x.IgnoreList.Count,
|
||||
x.DeleteList.Count,
|
||||
x.TotalList.Count);
|
||||
x.TotalList.Count
|
||||
);
|
||||
//输出统计
|
||||
Console.WriteLine(msg);
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Aliyun.OSS;
|
||||
@ -7,6 +8,7 @@ using Infrastructure.Attribute;
|
||||
using Infrastructure.Extensions;
|
||||
using JinianNet.JNTemplate;
|
||||
using Microsoft.AspNetCore.DataProtection.KeyManagement;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using SqlSugar;
|
||||
using ZR.Common;
|
||||
@ -38,16 +40,93 @@ namespace ZR.Service.mes.wms
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<WmPolishInventoryDto> GetList(WmPolishInventoryQueryDto parm)
|
||||
public WmPolishInventoryTableDto GetList(WmPolishInventoryQueryDto parm)
|
||||
{
|
||||
List<string> partnumberByDescription = new();
|
||||
var list = Context
|
||||
.Queryable<WmMaterial>()
|
||||
.LeftJoin<WmPolishInventory>((m, p) => m.Partnumber == p.Partnumber)
|
||||
.Distinct()
|
||||
//.GroupBy((m, p) => p.Partnumber)
|
||||
.WhereIF(
|
||||
!string.IsNullOrEmpty(parm.Description),
|
||||
(m, p) => m.Description.Contains(parm.Description)
|
||||
)
|
||||
.WhereIF(
|
||||
!string.IsNullOrEmpty(parm.Partnumber),
|
||||
(m, p) => m.Partnumber.Contains(parm.Partnumber)
|
||||
)
|
||||
.Where((m, p) => m.Status == 1)
|
||||
.Where((m, p) => m.Type == 1)
|
||||
.WhereIF(parm.Status > -1, (m, p) => p.Status == parm.Status)
|
||||
.WhereIF(parm.Type > 0, (m, p) => p.Type == parm.Type)
|
||||
.OrderBy((m, p) => m.Description)
|
||||
.Select(
|
||||
(m, p) =>
|
||||
new WmPolishInventoryDto
|
||||
{
|
||||
RealQuantity = 0,
|
||||
Color = m.Color,
|
||||
Specification = m.Specification,
|
||||
Description = m.Description,
|
||||
Id = p.Id,
|
||||
BlankNum = p.BlankNum,
|
||||
Partnumber = p.Partnumber,
|
||||
Quantity = p.Quantity,
|
||||
MaxNum = p.MaxNum,
|
||||
MinNum = p.MinNum,
|
||||
WarnNum = p.WarnNum,
|
||||
Type = p.Type,
|
||||
Status = p.Status,
|
||||
Remark = p.Remark,
|
||||
CreatedBy = p.CreatedBy,
|
||||
CreatedTime = p.CreatedTime,
|
||||
UpdatedBy = p.UpdatedBy,
|
||||
UpdatedTime = p.UpdatedTime,
|
||||
}
|
||||
)
|
||||
.ToList();
|
||||
foreach (WmPolishInventoryDto item in list)
|
||||
{
|
||||
// 获取实际库存
|
||||
List<string> partnumbers = new()
|
||||
{
|
||||
item.Partnumber
|
||||
};
|
||||
Dictionary<string, int> dict = GetBatchPolishRealPartNum(partnumbers);
|
||||
item.RealQuantity = dict.TryGetValue(item.Partnumber, out int value) ? value : 0;
|
||||
}
|
||||
|
||||
list = list.Where(it => it.RealQuantity != 0 || it.Quantity != 0)
|
||||
.Where(it => !string.IsNullOrEmpty(it.Partnumber))
|
||||
.DistinctBy(it => it.Partnumber)
|
||||
.ToList();
|
||||
|
||||
int total = list.Count;
|
||||
// 仓库总盘点零件数
|
||||
int StocktakingTotal =
|
||||
Context.Queryable<WmPolishInventory>().Sum(it => it.Quantity) ?? 0;
|
||||
// 仓库当前查询盘点零件数
|
||||
int QuantitySum = list.Sum(it => it.Quantity) ?? 0;
|
||||
// 仓库当前查询实际零件数
|
||||
int RealQuantitySum = list.Sum(it => it.RealQuantity);
|
||||
WmPolishInventoryTableDto response = new()
|
||||
{
|
||||
Total = total,
|
||||
StocktakingTotal = StocktakingTotal,
|
||||
QuantitySum = QuantitySum,
|
||||
RealQuantitySum = RealQuantitySum,
|
||||
Result = list.Skip((parm.PageNum - 1)* parm.PageSize).Take(parm.PageSize).ToList(),
|
||||
};
|
||||
return response;
|
||||
|
||||
//TODO 历史查询
|
||||
/*List<string> partnumberByDescription = new();
|
||||
if (parm != null && !string.IsNullOrEmpty(parm.Description))
|
||||
{
|
||||
partnumberByDescription = Context
|
||||
.Queryable<WmMaterial>()
|
||||
.Where(it => it.Description.Contains(parm.Description))
|
||||
.Select(it => it.Partnumber)
|
||||
|
||||
.ToList();
|
||||
}
|
||||
var predicate = Expressionable
|
||||
@ -89,14 +168,13 @@ namespace ZR.Service.mes.wms
|
||||
? material.Description
|
||||
: material.ProductName;
|
||||
// 获取实际库存
|
||||
|
||||
List<string> partnumbers = new List<string>();
|
||||
partnumbers.Add(item.Partnumber);
|
||||
Dictionary<string, int> dict = GetBatchPolishRealPartNum(partnumbers);
|
||||
item.RealQuantity = dict.TryGetValue(item.Partnumber, out int value)? value : 0;
|
||||
}
|
||||
}
|
||||
return response;
|
||||
return response;*/
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -576,7 +654,8 @@ namespace ZR.Service.mes.wms
|
||||
try
|
||||
{
|
||||
// 盘点时间
|
||||
DateTime? checkTime = Context
|
||||
DateTime? checkTime =
|
||||
Context
|
||||
.Queryable<WmPolishInventory>()
|
||||
.Where(it => it.Status == 1)
|
||||
.Select(it => it.CreatedTime)
|
||||
@ -599,7 +678,9 @@ namespace ZR.Service.mes.wms
|
||||
/// <returns></returns>
|
||||
public (string, object, object) ImportExcel(List<WmPolishInventoryExportDto> importList)
|
||||
{
|
||||
List<WmPolishInventory> wmPolishInventorylist = importList.Select(it => new WmPolishInventory {
|
||||
List<WmPolishInventory> wmPolishInventorylist = importList
|
||||
.Select(it => new WmPolishInventory
|
||||
{
|
||||
Id = SnowFlakeSingle.Instance.NextId().ToString(),
|
||||
Type = 1,
|
||||
Status = 1,
|
||||
@ -611,27 +692,31 @@ namespace ZR.Service.mes.wms
|
||||
CreatedTime = it.盘点时间 ?? DateTime.Now.ToLocalTime(),
|
||||
Partnumber = it.零件号,
|
||||
Quantity = it.盘点数
|
||||
}).ToList();
|
||||
var x = Context.Storageable(wmPolishInventorylist)
|
||||
})
|
||||
.ToList();
|
||||
var x = Context
|
||||
.Storageable(wmPolishInventorylist)
|
||||
.SplitError(x => x.Item.Partnumber.IsEmpty(), "零件号不能为空")
|
||||
.SplitError(x => x.Item.Quantity.IsEmpty(), "盘点数不能为空")
|
||||
.SplitUpdate(it => it.Any()) // 数据库存在更新
|
||||
.SplitDelete(it => it.Item.Quantity == 0) //盘点数为0的不导入
|
||||
.SplitInsert(it => true) // 其余插入
|
||||
.WhereColumns(it => it.Partnumber)//如果不是主键可以这样实现(多字段it=>new{it.x1,it.x2})
|
||||
.WhereColumns(it => it.Partnumber) //如果不是主键可以这样实现(多字段it=>new{it.x1,it.x2})
|
||||
.ToStorage();
|
||||
|
||||
// 清空全部
|
||||
var result = x.AsInsertable.ExecuteCommand();//不存在则插入;
|
||||
var result2 = x.AsUpdateable.IgnoreColumns(it => new { it.Id }).ExecuteCommand();//存在则修改;
|
||||
var result = x.AsInsertable.ExecuteCommand(); //不存在则插入;
|
||||
var result2 = x.AsUpdateable.IgnoreColumns(it => new { it.Id }).ExecuteCommand(); //存在则修改;
|
||||
var result3 = x.AsDeleteable.ExecuteCommand(); //盘点数为0的删除;
|
||||
string msg = string.Format(" 插入{0} 更新{1} 错误数据{2} 不计算数据{3} 删除数据{4} 总共{5}",
|
||||
string msg = string.Format(
|
||||
" 插入{0} 更新{1} 错误数据{2} 不计算数据{3} 删除数据{4} 总共{5}",
|
||||
x.InsertList.Count,
|
||||
x.UpdateList.Count,
|
||||
x.ErrorList.Count,
|
||||
x.IgnoreList.Count,
|
||||
x.DeleteList.Count,
|
||||
x.TotalList.Count);
|
||||
x.TotalList.Count
|
||||
);
|
||||
//输出统计
|
||||
Console.WriteLine(msg);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user