599 lines
23 KiB
C#
599 lines
23 KiB
C#
using JetBrains.Annotations;
|
||
using Microsoft.AspNetCore.Authorization;
|
||
using Microsoft.AspNetCore.Mvc;
|
||
using Microsoft.Extensions.Logging;
|
||
using NUglify.Helpers;
|
||
using Seyounth.Auto.Hs.Runtime.Plc;
|
||
using Seyounth.Auto.Hs.Runtime.Printer;
|
||
using Syc.Abp.Application.Contracts;
|
||
using Syc.Basic.Web.WMS.Dto;
|
||
using Syc.Basic.Web.WMS.Entitys;
|
||
using Syc.Basic.Web.WMS.IService;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Linq.Dynamic.Core;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
using Volo.Abp.DependencyInjection;
|
||
using Volo.Abp.Domain.Repositories;
|
||
|
||
namespace Syc.Basic.Web.WMS.Service
|
||
{
|
||
[AllowAnonymous]
|
||
public class BoxService : ApiService, IBoxService, ITransientDependency
|
||
{
|
||
private readonly IRepository<Box> boxRepository;
|
||
private readonly IRepository<Produce> produceRepository;
|
||
private readonly IRepository<Silk> silkRepository;
|
||
private readonly IPlcService plcService;
|
||
private readonly ILogger<BoxService> logger;
|
||
private readonly IPrinterService printerService;
|
||
private readonly IRepository<AutoLabel> autoRepository;
|
||
private readonly IRepository<Values> valueRepository;
|
||
|
||
public BoxService(IRepository<Box> boxRepository, IRepository<Produce> produceRepository, IRepository<Silk> silkRepository, IPlcService plcService, ILogger<BoxService> logger, IPrinterService printerService, IRepository<AutoLabel> autoRepository,IRepository<Values> valueRepository)
|
||
{
|
||
this.boxRepository = boxRepository;
|
||
this.produceRepository = produceRepository;
|
||
this.silkRepository = silkRepository;
|
||
this.plcService = plcService;
|
||
this.logger = logger;
|
||
this.printerService = printerService;
|
||
this.autoRepository = autoRepository;
|
||
this.valueRepository = valueRepository;
|
||
}
|
||
/// <summary>
|
||
/// 查询纸箱
|
||
/// </summary>
|
||
/// <param name="input"></param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public async Task<PageOutput<BoxDto>> GetBoxList(BoxInput input)
|
||
{
|
||
var boxlist = await boxRepository.GetQueryableAsync();
|
||
boxlist = boxlist.Where(x => x.IsDelete == 0);
|
||
if (input.Lot_No != null)
|
||
boxlist = boxlist.Where(x => x.Lot_No.Contains(input.Lot_No));
|
||
if (input.Spec != null)
|
||
boxlist = boxlist.Where(x => x.Spec.Contains(input.Spec));
|
||
if (input.Type != null)
|
||
boxlist = boxlist.Where(x => x.Type.Contains(input.Type));
|
||
if (input.Color != null)
|
||
{
|
||
if (input.Color == "无")
|
||
boxlist = boxlist.Where(x => x.Color == input.Color||x.Color==null);
|
||
else
|
||
boxlist = boxlist.Where(x => x.Color == input.Color);
|
||
}
|
||
if (input.Chang != null)
|
||
boxlist = boxlist.Where(x => x.Length.Contains(input.Chang));
|
||
if (input.Qty >0)
|
||
boxlist = boxlist.Where(x => x.Qty == input.Qty);
|
||
if (input.Start_Time != null && input.End_Time != null)
|
||
boxlist = boxlist.Where(x => x.Dom_Time >= DateTime.Parse(input.Start_Time) && x.Dom_Time <= DateTime.Parse(input.End_Time));
|
||
|
||
var result = boxlist.OrderByDescending(x => x.Id).PageResult(input.Page, input.PageSize);
|
||
var data = result.Queryable.Select(e => new BoxDto()
|
||
{
|
||
Length = e.Length,
|
||
Net_Weight = e.Net_Weight,
|
||
Qty = e.Qty,
|
||
Id = e.Id,
|
||
Code = e.Code,
|
||
Dom_Time = DateTime.Parse(e.Dom_Time.ToString()).ToString("yyyy-MM-dd HH:mm:ss"),
|
||
DataType = e.DataType,
|
||
Mark = e.Mark,
|
||
Color = e.Color,
|
||
Create_Time = e.Create_Time,
|
||
Exp_Time = DateTime.Parse(e.Exp_Time.ToString()).ToString("yyyy-MM-dd HH:mm:ss"),
|
||
Lot_No = e.Lot_No,
|
||
Spec = e.Spec,
|
||
Gross_Weight = e.Gross_Weight,
|
||
Type = e.Type
|
||
}).ToList();
|
||
|
||
PageOutput<BoxDto> pageOutput = new PageOutput<BoxDto>();
|
||
pageOutput.Total = boxlist.Count();
|
||
pageOutput.Data = data;
|
||
pageOutput.PageIndex = input.Page;
|
||
pageOutput.PageSize = input.PageSize;
|
||
return pageOutput;
|
||
}
|
||
/// <summary>
|
||
/// 查询数量纸箱
|
||
/// </summary>
|
||
/// <param name="input"></param>
|
||
/// <returns></returns>
|
||
[HttpGet]
|
||
public async Task<List<BoxDto>> GetBoxByNum()
|
||
{
|
||
var produce = await produceRepository.FirstOrDefaultAsync(x => x.IfUse == 1);
|
||
if (produce == null)
|
||
throw Oops.Oh("没有生产设置");
|
||
//var silks = await silkRepository.GetListAsync(x=>x.Status==1||x.Status==0);
|
||
var boxlist = await boxRepository.GetQueryableAsync();
|
||
boxlist = boxlist.Where(x => x.IsDelete == 0 && x.Spec == produce.Spec && x.Type == produce.Type && x.Lot_No == produce.Lot_No);
|
||
|
||
var data = boxlist.Where(x => x.DataType == 0).Select(e => new BoxDto()
|
||
{
|
||
Net_Weight = e.Net_Weight,
|
||
Id = e.Id,
|
||
Code = e.Code,
|
||
DataType = e.DataType,
|
||
Mark = e.Mark
|
||
}).ToList();
|
||
|
||
return data.OrderByDescending(x => x.Id).Take(15).ToList();
|
||
}
|
||
/// <summary>
|
||
/// 添加纸箱
|
||
/// </summary>
|
||
/// <param name="input"></param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public async Task InsertBox(BoxDto input)
|
||
{
|
||
var values = await valueRepository.FirstOrDefaultAsync(x => x.Type == 0 && x.IsDelete == 0 && x.IfUse == 1);
|
||
var keys = values.Key1.Split(',');
|
||
|
||
var produce = await produceRepository.FirstOrDefaultAsync(x => x.IfUse == 1);
|
||
var silksQuery = await silkRepository.GetQueryableAsync();
|
||
var silks = silksQuery.Where(x => x.IsDelete == 0 && x.Status == (int)SilkStatus.手动添加称重).OrderBy(x => x.Id).Take((int)produce.Qty).ToList();
|
||
|
||
if (produce == null)
|
||
throw Oops.Oh("没有生产设置");
|
||
|
||
if (silks.Count < produce.Qty)
|
||
{
|
||
logger.LogWarning($"没有{produce.Qty}条{produce.Type}的单品的信息,只有{silks.Count}条,无法创建码垛信息");
|
||
throw Oops.Oh($"没有{produce.Qty}条{produce.Type}的单品的信息,只有{silks.Count}条,无法创建码垛信息");
|
||
//return;
|
||
}
|
||
|
||
var netWeight = silks.Sum(x => x.Net_Weight);
|
||
var weight = silks.Average(x => x.Net_Weight);
|
||
|
||
var date = DateOnly.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
|
||
var autolabel = await autoRepository.FirstOrDefaultAsync(x => x.Date == date && x.Type == (int)AutoLabelType.成箱码垛流水号);
|
||
var timestr = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||
|
||
if (autolabel == null)
|
||
{
|
||
autolabel = await autoRepository.InsertAsync(new AutoLabel()
|
||
{
|
||
Date = date,
|
||
Sort = 0,
|
||
Mark = timestr,
|
||
Type = (int)AutoLabelType.成箱码垛流水号
|
||
}, true);
|
||
|
||
}
|
||
autolabel.Sort += 1;
|
||
logger.LogInformation("手动添加成箱信息" + timestr + autolabel.Sort.ToString().PadLeft(4, '0'));
|
||
await autoRepository.UpdateAsync(autolabel);
|
||
|
||
var box = new Box()
|
||
{
|
||
Dom_Time = DateTime.Now,
|
||
Exp_Time = produce.Exp_Time,
|
||
Qty = produce.Qty,
|
||
Length = produce.Length,
|
||
Lot_No = produce.Lot_No,
|
||
Code = timestr + autolabel.Sort.ToString().PadLeft(4, '0'),
|
||
Net_Weight = netWeight,
|
||
Spec = produce.Spec,
|
||
Color = keys[int.Parse(values.Value)],
|
||
Create_Time = DateTime.Now,
|
||
Type = produce.Type,
|
||
IsUse = true,
|
||
IsDelete = 0,
|
||
DataType = (int)BoxDataType.手动装箱,
|
||
Mark = "已经手动添加装箱信息"
|
||
};
|
||
|
||
var entity = await boxRepository.InsertAsync(box, true);
|
||
|
||
logger.LogInformation($"已手动添加装箱信息,装箱编号:{box.Code},包含单品数量:{silks.Count}");
|
||
|
||
List<Silk> list = new List<Silk>();
|
||
foreach (var silk in silks)
|
||
{
|
||
silk.Status = (int)SilkStatus.已手动装箱;
|
||
silk.BoxId = entity.Id;
|
||
silk.Status_Details = "已手动装箱";
|
||
list.Add(silk);
|
||
}
|
||
|
||
await silkRepository.UpdateManyAsync(list);
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 添加纸箱
|
||
/// </summary>
|
||
/// <param name="input"></param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public async Task AddInsertBox(BoxDto input)
|
||
{
|
||
var date = DateOnly.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
|
||
var autolabel = await autoRepository.FirstOrDefaultAsync(x => x.Date == date && x.Type == (int)AutoLabelType.成箱码垛流水号);
|
||
var timestr = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||
|
||
if (autolabel == null)
|
||
{
|
||
autolabel = await autoRepository.InsertAsync(new AutoLabel()
|
||
{
|
||
Date = date,
|
||
Sort = 0,
|
||
Mark = timestr,
|
||
Type = (int)AutoLabelType.成箱码垛流水号
|
||
}, true);
|
||
|
||
}
|
||
autolabel.Sort += 1;
|
||
logger.LogInformation("手动添加成箱信息" + timestr + autolabel.Sort.ToString().PadLeft(4, '0'));
|
||
await autoRepository.UpdateAsync(autolabel);
|
||
|
||
var box = new Box()
|
||
{
|
||
Dom_Time = DateTime.Now,
|
||
Exp_Time = DateTime.Parse(input.Exp_Time),
|
||
Qty = input.Qty,
|
||
Length = input.Length,
|
||
Lot_No = input.Lot_No,
|
||
Code = timestr + autolabel.Sort.ToString().PadLeft(4, '0'),
|
||
Net_Weight = input.Net_Weight,
|
||
Spec = input.Spec,
|
||
Color = input.Color,
|
||
Create_Time = DateTime.Now,
|
||
Type = input.Type,
|
||
IsUse = true,
|
||
IsDelete = 0,
|
||
DataType = (int)BoxDataType.手动成箱未包含单品信息,
|
||
Mark = "手动添加的成箱信息数据库未绑定单品信息"
|
||
};
|
||
|
||
var entity = await boxRepository.InsertAsync(box, true);
|
||
|
||
logger.LogInformation($"手动添加的成箱信息未绑定单品信息:{box.Code},未含单品数量");
|
||
|
||
BarTenderHelper.BoxPrint(box);
|
||
logger.LogInformation($"打印条码{box.Code},成箱标签打印成功");
|
||
}
|
||
|
||
/// <summary>
|
||
/// 打印纸箱
|
||
/// </summary>
|
||
/// <param name="input"></param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public async Task PrintBox(DelInput input)
|
||
{
|
||
var box = await boxRepository.FirstOrDefaultAsync(x => x.Id == input.id);
|
||
|
||
BarTenderHelper.BoxPrint(box);
|
||
logger.LogInformation($"打印条码{box.Code},成箱标签打印成功");
|
||
//throw Oops.Oh("成箱标签打印成功");
|
||
|
||
|
||
}
|
||
/// <summary>
|
||
/// 修改纸箱
|
||
/// </summary>
|
||
/// <param name="input"></param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public async Task UpdateBox(BoxDto input)
|
||
{
|
||
var box = await boxRepository.FirstOrDefaultAsync(x => x.Id == input.Id);
|
||
|
||
box.Spec = input.Spec;
|
||
box.Length = input.Length;
|
||
//box.Code = input.Code;
|
||
box.Lot_No = input.Lot_No;
|
||
box.Color = input.Color;
|
||
box.Net_Weight = input.Net_Weight;
|
||
box.Dom_Time = DateTime.Now;
|
||
box.Type = input.Type;
|
||
box.Qty = input.Qty;
|
||
box.Exp_Time = string.IsNullOrWhiteSpace(input.Exp_Time) ? null : Convert.ToDateTime(input.Exp_Time);
|
||
await boxRepository.UpdateAsync(box);
|
||
}
|
||
/// <summary>
|
||
/// 删除纸箱
|
||
/// </summary>
|
||
/// <param name="input"></param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public async Task DeleteBox(DelInput input)
|
||
{
|
||
var box = await boxRepository.FirstOrDefaultAsync(x => x.Id == input.id);
|
||
if (box == null)
|
||
throw Oops.Oh("删除失败,数据为空");
|
||
box.IsDelete = 1;
|
||
await boxRepository.UpdateAsync(box);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 批量删除纸箱
|
||
/// </summary>
|
||
/// <param name="input"></param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public async Task DeletesBoxs(DelInput input)
|
||
{
|
||
var boxs = await boxRepository.GetListAsync(x => input.ids.Contains(x.Id));
|
||
if (boxs.Count == 0)
|
||
throw Oops.Oh("删除失败,数据为空");
|
||
for (var i = 0; i < boxs.Count; i++)
|
||
{
|
||
boxs[i].IsDelete = 1;
|
||
}
|
||
await boxRepository.UpdateManyAsync(boxs);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 设置热缩机温度
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public async Task SetTemperature(ByIdInput<short> input)
|
||
{
|
||
await plcService.SetTemperatureAsync(input.Id);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 复位
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpGet]
|
||
public async Task ClearData()
|
||
{
|
||
await plcService.ClearData();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 设置热缩机温度
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public async Task<int> GetTemperature()
|
||
{
|
||
return await plcService.GetTemperatureAsync();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 整箱码垛打印标签
|
||
/// </summary>
|
||
/// <param name="input"></param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public async Task BoxsPalletPrint(FullPalletInput input)
|
||
{
|
||
var produce = await produceRepository.FirstOrDefaultAsync(x => x.IfUse == 1);
|
||
var boxQuery = await boxRepository.GetQueryableAsync();
|
||
var boxs = boxQuery.Where(x => x.DataType == 0 && x.IsDelete == 0).OrderBy(x => x.Id).Take(input.Num).ToList();
|
||
|
||
if (produce == null)
|
||
throw Oops.Oh("没有生产设置");
|
||
|
||
if (boxs.Count < input.Num)
|
||
{
|
||
logger.LogWarning($"没有{input.Num}条{produce.Type}的整箱的信息,只有{boxs.Count}条,无法创建码垛信息");
|
||
throw Oops.Oh($"没有{input.Num}条{produce.Type}的整箱的信息,只有{boxs.Count}条,无法创建码垛信息");
|
||
//return;
|
||
}
|
||
|
||
#region 生成自定义Code
|
||
var netWeight = boxs.Sum(x => x.Net_Weight);
|
||
|
||
var date = DateOnly.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
|
||
var autolabel = await autoRepository.FirstOrDefaultAsync(x => x.Date == date && x.Type == (int)AutoLabelType.成箱码垛流水号);
|
||
var timestr = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||
|
||
if (autolabel == null)
|
||
{
|
||
autolabel = await autoRepository.InsertAsync(new AutoLabel()
|
||
{
|
||
Date = date,
|
||
Sort = 0,
|
||
Mark = timestr,
|
||
Type = (int)AutoLabelType.成箱码垛流水号
|
||
}, true);
|
||
|
||
}
|
||
autolabel.Sort += 1;
|
||
logger.LogInformation("整箱码垛生成Code" + timestr + autolabel.Sort.ToString().PadLeft(4, '0'));
|
||
await autoRepository.UpdateAsync(autolabel);
|
||
#endregion
|
||
|
||
var box = new Box()
|
||
{
|
||
Dom_Time = DateTime.Now,
|
||
Type = produce.Type,
|
||
Exp_Time = produce.Exp_Time,
|
||
Qty = input.Num,
|
||
Length = produce.Length,
|
||
Lot_No = produce.Lot_No,
|
||
//Code = Guid.NewGuid().ToString().Substring(9, 18),
|
||
Code = timestr + autolabel.Sort.ToString().PadLeft(4, '0'),
|
||
Net_Weight = netWeight,
|
||
Spec = produce.Spec,
|
||
IsUse = true,
|
||
IsDelete = 0,
|
||
DataType = (int)BoxDataType.成箱码垛,
|
||
Create_Time = DateTime.Now,
|
||
Mark = "整箱手动码垛,码垛整箱数量" + input.Num
|
||
};
|
||
|
||
var Box = await boxRepository.InsertAsync(box, true);
|
||
logger.LogInformation($"已添加码垛信息,码垛编号:{box.Code},包含整箱数量:{boxs.Count}");
|
||
|
||
List<Box> list = new List<Box>();
|
||
foreach (var item in boxs)
|
||
{
|
||
item.DataType = (int)BoxDataType.已码垛;
|
||
item.Mark = "已码垛到编号" + Box.Code + "中,码垛数据编号ID" + Box.Id;
|
||
list.Add(item);
|
||
}
|
||
|
||
await boxRepository.UpdateManyAsync(list);
|
||
|
||
#region 打印标签
|
||
//打印标签
|
||
BarTenderHelper.BoxPrint(box);
|
||
logger.LogInformation($"打印条码{box.Code},成箱码垛标签打印成功");
|
||
//throw Oops.Oh("成箱码垛标签打印成功");
|
||
#endregion
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 单品码垛打印标签
|
||
/// </summary>
|
||
/// <param name="input"></param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public async Task SilksPalletPrint(FullPalletInput input)
|
||
{
|
||
var produce = await produceRepository.FirstOrDefaultAsync(x => x.IfUse == 1);
|
||
var silksQuery = await silkRepository.GetQueryableAsync();
|
||
var silks = silksQuery.Where(x => x.IsDelete == 0 && x.Status == (int)SilkStatus.已称重).OrderBy(x => x.Id).Take(input.Num).ToList();
|
||
|
||
if (produce == null)
|
||
throw Oops.Oh("没有生产设置");
|
||
|
||
if (silks.Count < input.Num)
|
||
{
|
||
logger.LogWarning($"没有{input.Num}条{produce.Type}的单品的信息,只有{silks.Count}条,无法创建码垛信息");
|
||
throw Oops.Oh($"没有{input.Num}条{produce.Type}的单品的信息,只有{silks.Count}条,无法创建码垛信息");
|
||
//return;
|
||
}
|
||
|
||
var netWeight = silks.Sum(x => x.Net_Weight);
|
||
var weight = silks.Average(x => x.Net_Weight);
|
||
|
||
#region 自动生成成箱码垛流水号
|
||
var date = DateOnly.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
|
||
var autolabel = await autoRepository.FirstOrDefaultAsync(x => x.Date == date && x.Type == (int)AutoLabelType.成箱码垛流水号);
|
||
var timestr = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||
|
||
if (autolabel == null)
|
||
{
|
||
autolabel = await autoRepository.InsertAsync(new AutoLabel()
|
||
{
|
||
Date = date,
|
||
Sort = 0,
|
||
Mark = timestr,
|
||
Type = (int)AutoLabelType.成箱码垛流水号
|
||
}, true);
|
||
|
||
}
|
||
autolabel.Sort += 1;
|
||
logger.LogInformation("丝锭码垛生成Code" + timestr + autolabel.Sort.ToString().PadLeft(4, '0'));
|
||
await autoRepository.UpdateAsync(autolabel);
|
||
#endregion
|
||
|
||
var box = new Box()
|
||
{
|
||
Dom_Time = DateTime.Now,
|
||
Type = produce.Type,
|
||
Exp_Time = produce.Exp_Time,
|
||
Qty = input.Num,
|
||
Length = produce.Length,
|
||
Lot_No = produce.Lot_No,
|
||
//Code = Guid.NewGuid().ToString().Substring(9, 18),
|
||
Code = timestr + autolabel.Sort.ToString().PadLeft(4, '0'),
|
||
Net_Weight = netWeight,
|
||
Spec = produce.Spec,
|
||
IsUse = true,
|
||
IsDelete = 0,
|
||
DataType = (int)BoxDataType.单品码垛,
|
||
Create_Time = DateTime.Now,
|
||
Mark = "单品手动码垛,码垛单品数量" + input.Num
|
||
};
|
||
|
||
var Box = await boxRepository.InsertAsync(box, true);
|
||
logger.LogInformation($"已添加码垛信息,码垛编号:{box.Code},包含单品数量:{silks.Count}");
|
||
|
||
List<Silk> list = new List<Silk>();
|
||
foreach (var silk in silks)
|
||
{
|
||
silk.Status = 3;
|
||
silk.BoxId = Box.Id;
|
||
silk.Status_Details = "已码垛";
|
||
list.Add(silk);
|
||
}
|
||
|
||
await silkRepository.UpdateManyAsync(list);
|
||
|
||
#region 打印标签
|
||
//打印标签
|
||
BarTenderHelper.BoxPrint(box);
|
||
logger.LogInformation($"打印条码{box.Code},丝锭码垛标签打印成功");
|
||
//throw Oops.Oh("丝锭码垛标签打印成功");
|
||
#endregion
|
||
}
|
||
|
||
/// <summary>
|
||
/// 求总
|
||
/// </summary>
|
||
/// <param name="input"></param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public async Task<object> Sum(SumInput input)
|
||
{
|
||
var boxlist = await boxRepository.GetQueryableAsync();
|
||
boxlist = boxlist.Where(x => x.IsDelete == 0);
|
||
|
||
if (input.Spec != null)
|
||
boxlist = boxlist.Where(x => x.Spec.Contains(input.Spec));
|
||
if (input.Name != null)
|
||
boxlist = boxlist.Where(x => x.Type.Contains(input.Name));
|
||
|
||
if (input.Lot_No != null)
|
||
boxlist = boxlist.Where(x => x.Lot_No.Contains(input.Lot_No));
|
||
if (input.Value != null)
|
||
{
|
||
if(input.Value=="无")
|
||
boxlist = boxlist.Where(x => x.Color == input.Value||x.Color==null);
|
||
else
|
||
boxlist = boxlist.Where(x => x.Color == input.Value);
|
||
}
|
||
|
||
if (input.Chang != null)
|
||
boxlist = boxlist.Where(x => x.Length.Contains(input.Chang));
|
||
if (input.Qty > 0)
|
||
boxlist = boxlist.Where(x => x.Qty == input.Qty);
|
||
if (input.Start_Time != null && input.End_Time != null)
|
||
boxlist = boxlist.Where(x => x.Dom_Time >= DateTime.Parse(input.Start_Time) && x.Dom_Time <= DateTime.Parse(input.End_Time));
|
||
|
||
//1:求颜色总数
|
||
if (input.Type == 1)
|
||
{
|
||
|
||
if (boxlist.Count() == 0)
|
||
throw Oops.Oh("求和失败,数据为空");
|
||
|
||
int sum = boxlist.Count();
|
||
return sum;
|
||
}
|
||
//2:求重量总和
|
||
else
|
||
{
|
||
if (boxlist.Count() == 0)
|
||
throw Oops.Oh("求和失败,数据为空");
|
||
|
||
double sum = 0;
|
||
foreach (var box in boxlist)
|
||
{
|
||
|
||
sum += (double)box.Net_Weight;
|
||
}
|
||
return Math.Round(sum, 2);
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|