提交
This commit is contained in:
@@ -6,6 +6,7 @@ using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Service.mes.wms.IService;
|
||||
using ZR.Model.MES.wms.Dto;
|
||||
using ZR.Model.MES.wms;
|
||||
using Aliyun.OSS;
|
||||
|
||||
//创建时间:2024-04-17
|
||||
namespace ZR.Admin.WebApi.Controllers
|
||||
@@ -26,6 +27,21 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
{
|
||||
_WmFgentryInspectService = WmFgentryInspectService;
|
||||
}
|
||||
/// <summary>
|
||||
/// 把包装数据转换为检验数据
|
||||
/// </summary>
|
||||
/// <param name="workorder"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("transform")]
|
||||
public IActionResult Transform(string workorder)
|
||||
{
|
||||
if(string.IsNullOrEmpty(workorder) == null)
|
||||
{
|
||||
return SUCCESS(workorder);
|
||||
}
|
||||
var response = _WmFgentryInspectService.TransformData(workorder);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询成品入库检验列表
|
||||
@@ -186,5 +202,8 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,8 @@ namespace ZR.Service.mes.wms.IService
|
||||
/// </summary>
|
||||
public interface IWmFgentryInspectService : IBaseService<WmFgentryInspect>
|
||||
{
|
||||
|
||||
int TransformData(string workorder);
|
||||
PagedInfo<WmFgentryInspectDto> GetList(WmFgentryInspectQueryDto parm);
|
||||
PagedInfo<WmFgentryInspect_parentDto> GetList_first(WmFgentryInspectQueryDto parm);
|
||||
PagedInfo<WmFgentryInspectDto> GetList_second(WmFgentryInspectQueryDto parm);
|
||||
|
||||
@@ -11,6 +11,8 @@ using ZR.Service.mes.wms.IService;
|
||||
using ZR.Model.MES.wms;
|
||||
using ZR.Model.MES.wms.Dto;
|
||||
using Mapster;
|
||||
using System.Reflection.PortableExecutable;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
|
||||
namespace ZR.Service.mes.wms
|
||||
{
|
||||
@@ -20,6 +22,43 @@ namespace ZR.Service.mes.wms
|
||||
[AppService(ServiceType = typeof(IWmFgentryInspectService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class WmFgentryInspectService : BaseService<WmFgentryInspect>, IWmFgentryInspectService
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 把包装数据转换为检验数据
|
||||
/// </summary>
|
||||
/// <param name="workorder"></param>
|
||||
/// <returns></returns>
|
||||
public int TransformData(string workorder)
|
||||
{
|
||||
int sum = 0;
|
||||
|
||||
var inpects = Context.Queryable<WmPackingrecord>()
|
||||
.Where(it => it.WorkOrderNum == workorder)
|
||||
.GroupBy(it => it.PackingCode)
|
||||
.Select(it => new WmFgentryInspect()
|
||||
{
|
||||
Workorder = SqlFunc.AggregateMax(it.WorkOrderNum),
|
||||
Packcode = it.PackingCode,
|
||||
Machine = SqlFunc.AggregateMax(it.Machine),
|
||||
ProductionNum = SqlFunc.AggregateCount(it),
|
||||
Partnumber = SqlFunc.AggregateMax(it.PartNum),
|
||||
Bfilled = SqlFunc.ToInt32(SqlFunc.AggregateMax(it.BFilled)),
|
||||
Result = 0,
|
||||
Bitwm = 0,
|
||||
CreatedBy = " ",
|
||||
CreatedTime = DateTime.Now,
|
||||
}).ToList();
|
||||
|
||||
|
||||
var x = Context.Storageable(inpects)
|
||||
.WhereColumns(it => it.Packcode)
|
||||
.ToStorage();
|
||||
sum= x.AsInsertable.ExecuteCommand();//不存在插入
|
||||
x.AsUpdateable.ExecuteCommand();//存在更新
|
||||
|
||||
return sum;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 查询成品入库检验列表
|
||||
/// </summary>
|
||||
@@ -47,30 +86,30 @@ namespace ZR.Service.mes.wms
|
||||
.AndIF(!string.IsNullOrEmpty(parm.Workorder), it => it.Workorder.Contains(parm.Workorder))
|
||||
.AndIF(!string.IsNullOrEmpty(parm.Packcode), it => it.Packcode.Contains(parm.Packcode))
|
||||
.AndIF(!string.IsNullOrEmpty(parm.Partnumber), it => it.Partnumber.Contains(parm.Partnumber))
|
||||
.AndIF(parm.starttime!=null&&parm.starttime>new DateTime(1999,1,1), it => it.CreatedTime>parm.starttime)
|
||||
.AndIF(parm.endtime!=null&&parm.endtime>new DateTime(1999,1,1), it => it.CreatedTime<parm.endtime)
|
||||
.AndIF(parm.starttime != null && parm.starttime > new DateTime(1999, 1, 1), it => it.CreatedTime > parm.starttime)
|
||||
.AndIF(parm.endtime != null && parm.endtime > new DateTime(1999, 1, 1), it => it.CreatedTime < parm.endtime)
|
||||
;
|
||||
|
||||
|
||||
|
||||
List<WmFgentryInspect_parentDto> inspects = Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.Where(it=>it.Bitwm==0)
|
||||
.Where(it => it.Bitwm == 0)
|
||||
.GroupBy(it => it.Workorder)
|
||||
.Select(it => new WmFgentryInspect_parentDto()
|
||||
{
|
||||
Workorder = it.Workorder,
|
||||
ProductionNum = SqlFunc.AggregateSum(it.ProductionNum ?? 0),
|
||||
// Result= SqlFunc.AggregateSum(it.Result??0),
|
||||
// Result= SqlFunc.AggregateSum(it.Result??0),
|
||||
Partnumber = SqlFunc.AggregateMax(it.Partnumber)
|
||||
}).ToList();
|
||||
|
||||
foreach (var inspect in inspects)
|
||||
{
|
||||
inspect.Result_good=Queryable().Where(it=>it.Workorder==inspect.Workorder).Where(it=>it.Result==1).Count();
|
||||
inspect.Result_bad=Queryable().Where(it=>it.Workorder==inspect.Workorder).Where(it=>it.Result==2).Count();
|
||||
inspect.Result_null=Queryable().Where(it=>it.Workorder==inspect.Workorder).Where(it=>it.Result==0|| it.Result==null).Count();
|
||||
inspect.Result_good = Queryable().Where(it => it.Workorder == inspect.Workorder).Where(it => it.Result == 1).Count();
|
||||
inspect.Result_bad = Queryable().Where(it => it.Workorder == inspect.Workorder).Where(it => it.Result == 2).Count();
|
||||
inspect.Result_null = Queryable().Where(it => it.Workorder == inspect.Workorder).Where(it => it.Result == 0 || it.Result == null).Count();
|
||||
}
|
||||
|
||||
|
||||
|
||||
int totalPages = (int)Math.Ceiling((double)inspects.Count / parm.PageSize);
|
||||
|
||||
@@ -81,7 +120,7 @@ namespace ZR.Service.mes.wms
|
||||
PageSize = parm.PageSize,
|
||||
PageIndex = parm.PageNum,
|
||||
TotalPage = totalPages,
|
||||
Result= pageProducts
|
||||
Result = pageProducts
|
||||
};
|
||||
|
||||
return response;
|
||||
@@ -160,17 +199,17 @@ namespace ZR.Service.mes.wms
|
||||
/// </summary>
|
||||
/// <param name="packcode_select"></param>
|
||||
/// <returns></returns>
|
||||
public int BatchQualified(string[] packcode_select,string updateby)
|
||||
public int BatchQualified(string[] packcode_select, string updateby)
|
||||
{
|
||||
int sum = 0;
|
||||
foreach (string packcode in packcode_select)
|
||||
{
|
||||
sum= sum+ Context.Updateable<WmFgentryInspect>()
|
||||
.Where(it=>it.Packcode == packcode)
|
||||
.SetColumns(it=>it.Result==1)
|
||||
sum = sum + Context.Updateable<WmFgentryInspect>()
|
||||
.Where(it => it.Packcode == packcode)
|
||||
.SetColumns(it => it.Result == 1)
|
||||
.ExecuteCommand();
|
||||
}
|
||||
return sum;
|
||||
return sum;
|
||||
|
||||
}
|
||||
|
||||
@@ -180,12 +219,12 @@ namespace ZR.Service.mes.wms
|
||||
/// <param name="workorder_selected"></param>
|
||||
/// <param name="updateby"></param>
|
||||
/// <returns></returns>
|
||||
public int SetAllQualified(string workorder_selected, string updateby)
|
||||
public int SetAllQualified(string workorder_selected, string updateby)
|
||||
{
|
||||
return Context.Updateable<WmFgentryInspect>()
|
||||
.SetColumns(it=>it.Result==1)
|
||||
.Where(it=>it.Workorder==workorder_selected)
|
||||
.ExecuteCommand();
|
||||
return Context.Updateable<WmFgentryInspect>()
|
||||
.SetColumns(it => it.Result == 1)
|
||||
.Where(it => it.Workorder == workorder_selected)
|
||||
.ExecuteCommand();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user