You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
157 lines
5.9 KiB
157 lines
5.9 KiB
5 months ago
|
using MESClassLibrary.BLL.Log;
|
||
|
using MESClassLibrary.EFModel;
|
||
|
using MESClassLibrary.Model;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Reflection;
|
||
|
using System.Text;
|
||
|
using System.Threading.Tasks;
|
||
|
|
||
|
namespace MESClassLibrary.BLL.Stock
|
||
|
{
|
||
|
public class StockInBLL
|
||
|
{
|
||
|
BBMPTEntities dbe = new BBMPTEntities();
|
||
|
BasicBLL<tb_StockIn> db = new BasicBLL<tb_StockIn>();
|
||
|
BasicBLL<tb_InspectResult> Resultdb = new BasicBLL<tb_InspectResult>();
|
||
|
/// <summary>
|
||
|
/// 查询信息
|
||
|
/// </summary>
|
||
|
/// <returns></returns>
|
||
|
public string SearchInfo(string page, string pagesize, string StartTime, string EndTime, string workClass, string color, string productInfo)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string jsonStr = "[]";
|
||
|
int total = 0;//总行数
|
||
|
//List<tb_StockIn> list = db.SearchAllInfo();
|
||
|
|
||
|
DateTime start = Convert.ToDateTime(StartTime);
|
||
|
DateTime end = Convert.ToDateTime(EndTime);
|
||
|
|
||
|
List<tb_StockIn> list = dbe.tb_StockIn.Where(p => p.createTime >= start && p.createTime <= end && "1".Equals(p.pass)).ToList();
|
||
|
|
||
|
//list = list.Where(p => p.createTime >= start && p.createTime <= end && "1".Equals(p.pass)).ToList();
|
||
|
|
||
|
List<string> barcodeList = list.Select(m => m.barcode).ToList();
|
||
|
|
||
|
var resultList = dbe.tb_InspectResult.Where(p => barcodeList.Contains(p.barcode) && p.inspectResult.Contains("合格")).ToList();
|
||
|
|
||
|
|
||
|
if (!String.IsNullOrEmpty(workClass))
|
||
|
{
|
||
|
resultList = resultList.Where(p => p.workClass.Contains(workClass)).ToList();
|
||
|
}
|
||
|
|
||
|
if (!String.IsNullOrEmpty(color))
|
||
|
{
|
||
|
resultList = resultList.Where(p => p.productInfo.Contains(color)).ToList();
|
||
|
}
|
||
|
|
||
|
if (!String.IsNullOrEmpty(productInfo))
|
||
|
{
|
||
|
resultList = resultList.Where(p => p.productInfo.Contains(productInfo)).ToList();
|
||
|
}
|
||
|
|
||
|
list = list.Where(p => resultList.Select(m => m.barcode).ToList().Contains(p.barcode)).ToList();
|
||
|
|
||
|
if (list.Count > 0)
|
||
|
{
|
||
|
total = list.Count;
|
||
|
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
|
||
|
list = list.OrderByDescending(p => p.createTime).Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
|
||
|
List<StockInModel> StockInList = new List<StockInModel>();
|
||
|
foreach (var item in list)
|
||
|
{
|
||
|
StockInModel dm = Tool.Mapper<StockInModel, tb_StockIn>(item);
|
||
|
var info = resultList.FirstOrDefault(p => p.barcode == item.barcode);
|
||
|
if (info != null)
|
||
|
{
|
||
|
dm.workClass = info.workClass;
|
||
|
dm.productInfo = info.productInfo;
|
||
|
}
|
||
|
StockInList.Add(dm);
|
||
|
}
|
||
|
|
||
|
JsonDataModel<StockInModel> md = new JsonDataModel<StockInModel>();
|
||
|
md.total = total.ToString();
|
||
|
md.rows = StockInList;
|
||
|
jsonStr = JSONTools.ScriptSerialize(md);
|
||
|
}
|
||
|
return jsonStr;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return "";
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 查询信息
|
||
|
/// </summary>
|
||
|
/// <returns></returns>
|
||
|
public List<StockInModel> SearchInfoAll(string StartTime, string EndTime, string workClass, string color, string productInfo)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
List<tb_StockIn> list = db.SearchAllInfo();
|
||
|
|
||
|
DateTime start = Convert.ToDateTime(StartTime);
|
||
|
DateTime end = Convert.ToDateTime(EndTime);
|
||
|
|
||
|
list = list.Where(p => p.createTime >= start && p.createTime <= end && "1".Equals(p.pass)).ToList();
|
||
|
|
||
|
List<string> barcodeList = list.Select(m => m.barcode).ToList();
|
||
|
|
||
|
var resultList = dbe.tb_InspectResult.Where(p => barcodeList.Contains(p.barcode) && p.inspectResult.Contains("合格")).ToList();
|
||
|
|
||
|
|
||
|
if (!String.IsNullOrEmpty(workClass))
|
||
|
{
|
||
|
resultList = resultList.Where(p => p.workClass.Contains(workClass)).ToList();
|
||
|
}
|
||
|
|
||
|
if (!String.IsNullOrEmpty(color))
|
||
|
{
|
||
|
resultList = resultList.Where(p => p.productInfo.Contains(color)).ToList();
|
||
|
}
|
||
|
|
||
|
if (!String.IsNullOrEmpty(productInfo))
|
||
|
{
|
||
|
resultList = resultList.Where(p => p.productInfo.Contains(productInfo)).ToList();
|
||
|
}
|
||
|
|
||
|
list = list.Where(p => resultList.Select(m => m.barcode).ToList().Contains(p.barcode)).ToList();
|
||
|
|
||
|
List<StockInModel> StockInList = new List<StockInModel>();
|
||
|
if (list.Count > 0)
|
||
|
{
|
||
|
foreach (var item in list)
|
||
|
{
|
||
|
StockInModel dm = Tool.Mapper<StockInModel, tb_StockIn>(item);
|
||
|
var info = resultList.FirstOrDefault(p => p.barcode == item.barcode);
|
||
|
if (info != null)
|
||
|
{
|
||
|
dm.workClass = info.workClass;
|
||
|
dm.productInfo = info.productInfo;
|
||
|
}
|
||
|
StockInList.Add(dm);
|
||
|
}
|
||
|
}
|
||
|
return StockInList;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|