208 lines
7.3 KiB
C#
208 lines
7.3 KiB
C#
using Infrastructure.Attribute;
|
||
using Infrastructure.Extensions;
|
||
using Infrastructure.Model;
|
||
using MiniExcelLibs;
|
||
using RIZO.Model.Mes.Dto.WorkOrderInfo;
|
||
using RIZO.Model.Mes.WorkOrderInfo;
|
||
using RIZO.Repository;
|
||
using RIZO.Service.Mes.IMesService.WorkOrderInfo;
|
||
|
||
namespace RIZO.Service.Mes.WorkOrderInfo
|
||
{
|
||
/// <summary>
|
||
/// 产品检验记录表Service业务层处理
|
||
/// </summary>
|
||
[AppService(ServiceType = typeof(IProductInspectionService), ServiceLifetime = LifeTime.Transient)]
|
||
public class ProductInspectionService : BaseService<ProductInspection>, IProductInspectionService
|
||
{
|
||
/// <summary>
|
||
/// 查询产品检验记录表列表
|
||
/// </summary>
|
||
/// <param name="parm"></param>
|
||
/// <returns></returns>
|
||
public PagedInfo<ProductInspectionDto> GetList(ProductInspectionQueryDto parm)
|
||
{
|
||
var predicate = QueryExp(parm);
|
||
|
||
var response = Queryable()
|
||
.Where(predicate.ToExpression())
|
||
.ToPage<ProductInspection, ProductInspectionDto>(parm);
|
||
|
||
return response;
|
||
}
|
||
|
||
public PagedInfo<ProductInspectionDto> GetListExport(ProductInspectionQueryDto parm)
|
||
{
|
||
var predicate = QueryExp(parm);
|
||
|
||
var response = Queryable()
|
||
.Where(predicate.ToExpression())
|
||
.ToPage<ProductInspection, ProductInspectionDto>(parm);
|
||
|
||
return response;
|
||
}
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 获取详情
|
||
/// </summary>
|
||
/// <param name="Id"></param>
|
||
/// <returns></returns>
|
||
public ProductInspection GetInfo(long Id)
|
||
{
|
||
var response = Queryable()
|
||
.Where(x => x.Id == Id)
|
||
.First();
|
||
|
||
return response;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 添加产品检验记录表
|
||
/// </summary>
|
||
/// <param name="model"></param>
|
||
/// <returns></returns>
|
||
public ProductInspection AddProductInspection(ProductInspection model)
|
||
{
|
||
return Insertable(model).ExecuteReturnEntity();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 修改产品检验记录表
|
||
/// </summary>
|
||
/// <param name="model"></param>
|
||
/// <returns></returns>
|
||
public int UpdateProductInspection(ProductInspection model)
|
||
{
|
||
return Update(model, true);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询导出表达式
|
||
/// </summary>
|
||
/// <param name="parm"></param>
|
||
/// <returns></returns>
|
||
private static Expressionable<ProductInspection> QueryExp(ProductInspectionQueryDto parm)
|
||
{
|
||
var predicate = Expressionable.Create<ProductInspection>();
|
||
|
||
return predicate;
|
||
}
|
||
|
||
private static Expressionable<ProductInspection> QueryExpExport(ProductInspectionQueryDto parm)
|
||
{
|
||
var predicate = Expressionable.Create<ProductInspection>();
|
||
if (parm.StartTime != null && parm.StartTime.ToString().Length > 0)
|
||
{
|
||
predicate.And(it => it.CreateTime >= parm.StartTime);
|
||
}
|
||
if (parm.EndTime != null && parm.EndTime.ToString().Length > 0)
|
||
{
|
||
predicate.And(it => it.CreateTime < parm.EndTime);
|
||
}
|
||
return predicate;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 4.Excel导入物料清单
|
||
/// </summary>
|
||
/// <param name="stream"></param>
|
||
/// <param name="userId"></param>
|
||
/// <param name="userName"></param>
|
||
/// <returns></returns>
|
||
public ApiResult Import(Stream stream, string userId, string userName)
|
||
{
|
||
//int code = 200;
|
||
//string strMessage = "";
|
||
//try
|
||
//{
|
||
// // 参数校验
|
||
// if (string.IsNullOrWhiteSpace(userId))
|
||
// {
|
||
// code = 400;
|
||
// strMessage = "创建人ID不可为空!";
|
||
// return new ApiResult(code, strMessage);
|
||
// }
|
||
// if (stream == null || stream.Length == 0)
|
||
// {
|
||
// code = 400;
|
||
// strMessage = "导入的Excel流不能为空!";
|
||
// return new ApiResult(code, strMessage);
|
||
// }
|
||
// if (stream.CanSeek)
|
||
// {
|
||
// stream.Position = 0;
|
||
// }
|
||
|
||
// // 解析Excel
|
||
|
||
// List<MaterialInfoImport> resultList = stream.Query<MaterialInfoImport>().ToList();
|
||
// List<MaterialInfo> materialInfos = new List<MaterialInfo>();
|
||
|
||
// List<string> materialCodeList = new List<string>();
|
||
// for (int i = 1; i < resultList.Count; i++)
|
||
// {
|
||
// var import = resultList[i];
|
||
// // 物料编码去重
|
||
// if (!materialInfos.Any(p => p.MaterialCode == import.MaterialCode))
|
||
// {
|
||
// MaterialInfo material = new MaterialInfo
|
||
// {
|
||
// MaterialCode = import.MaterialCode,
|
||
// MaterialName = import.MaterialName,
|
||
// MaterialModel = import.MaterialModel,
|
||
// MaterialType = import.MaterialType,
|
||
// Parameter = import.Parameter,
|
||
// Brand = import.Brand,
|
||
// Supplier = import.Supplier,
|
||
// DeviceId = import.DeviceId,
|
||
// Feature = import.Feature,
|
||
// Remark = import.Remark,
|
||
// ProcessCode = import.ProcessCode,
|
||
// ProcessName = import.ProcessName,
|
||
// DelFlag = "0",
|
||
// CreateId = userId,
|
||
// CreateName = userName,
|
||
// CreateTime = DateTime.Now,
|
||
// UpdateId = userId,
|
||
// UpdateName = userName,
|
||
// UpdateTime = DateTime.Now
|
||
// };
|
||
// materialInfos.Add(material);
|
||
// materialCodeList.Add(import.MaterialCode);
|
||
// }
|
||
// }
|
||
|
||
|
||
// // 先删除相同编码的旧数据
|
||
// if (materialCodeList.Any())
|
||
// {
|
||
// var delCount = Deleteable().Where(it => materialCodeList.Contains(it.MaterialCode))
|
||
// .ExecuteCommand();
|
||
// }
|
||
|
||
// // 插入新数据
|
||
// int iResult = Insert(materialInfos);
|
||
// if (iResult > 0)
|
||
// {
|
||
// code = 200;
|
||
// strMessage = "导入成功!";
|
||
// }
|
||
// else
|
||
// {
|
||
// code = 400;
|
||
// strMessage = "导入失败!";
|
||
// }
|
||
//}
|
||
//catch (Exception ex)
|
||
//{
|
||
// code = 500;
|
||
// strMessage = "发生错误!" + ex.ToString();
|
||
//}
|
||
//return new ApiResult(code, strMessage);
|
||
return null;
|
||
}
|
||
|
||
}
|
||
} |