243 lines
8.7 KiB
C#
243 lines
8.7 KiB
C#
using System;
|
|
using SqlSugar;
|
|
using Infrastructure.Attribute;
|
|
using Infrastructure.Extensions;
|
|
using DOAN.Model;
|
|
using DOAN.Model.Dto;
|
|
using DOAN.Model.MES.base_;
|
|
using DOAN.Model.MES.base_.Dto;
|
|
using DOAN.Repository;
|
|
using DOAN.Service.MES.base_.IService;
|
|
|
|
using System.Linq;
|
|
using Microsoft.IdentityModel.Tokens;
|
|
using Mapster;
|
|
using System.Xml.Linq;
|
|
using static Org.BouncyCastle.Crypto.Engines.SM2Engine;
|
|
using Infrastructure.Model;
|
|
using Aliyun.OSS;
|
|
|
|
|
|
namespace DOAN.Service.MES.base_
|
|
{
|
|
/// <summary>
|
|
/// 物料清单Service业务层处理
|
|
/// </summary>
|
|
//[AppService(ServiceType = typeof(IBaseMaterialBOMService), ServiceLifetime = LifeTime.Transient)]
|
|
//public class BaseMaterialBOMService : BaseService<BaseMaterialList>, IBaseMaterialBOMService
|
|
//{
|
|
// /// <summary>
|
|
// /// 查询物料清单列表
|
|
// /// </summary>
|
|
// /// <param name="parm"></param>
|
|
// /// <returns></returns>
|
|
// public PagedInfo<BaseMaterialListDto> GetList(BaseMaterialListQueryDto2 parm)
|
|
// {
|
|
// int[] nodes = null;
|
|
|
|
// if (parm.Type == 1)
|
|
// {
|
|
// nodes = FindLeafNodes(Context.Queryable<BaseMaterialType>().ToList(), 6).Select(it => it.Id).ToArray();
|
|
// }
|
|
// else if (parm.Type == 2)
|
|
// {
|
|
|
|
// nodes = FindLeafNodes(Context.Queryable<BaseMaterialType>().ToList(), 5).Select(it => it.Id).ToArray();
|
|
|
|
// }
|
|
// var predicate = Expressionable.Create<BaseMaterialList>();
|
|
|
|
// var response = Queryable()
|
|
// .Where(it => nodes.Contains(it.FkTypeId.Value))
|
|
// .Where(predicate.ToExpression())
|
|
// .ToPage<BaseMaterialList, BaseMaterialListDto>(parm);
|
|
|
|
// return response;
|
|
// }
|
|
|
|
|
|
// /// <summary>
|
|
// /// 获取详情
|
|
// /// </summary>
|
|
// /// <param name="Id"></param>
|
|
// /// <returns></returns>
|
|
// public BaseMaterialList GetInfo(string Id)
|
|
// {
|
|
// var response = Queryable()
|
|
// .Where(x => x.Id == Id)
|
|
// .First();
|
|
|
|
// return response;
|
|
// }
|
|
|
|
// /// <summary>
|
|
// /// 添加物料清单
|
|
// /// </summary>
|
|
// /// <param name="model"></param>
|
|
// /// <returns></returns>
|
|
// public BaseMaterialList AddBaseMaterialList(BaseMaterialList model)
|
|
// {
|
|
// return Context.Insertable(model).ExecuteReturnEntity();
|
|
// }
|
|
|
|
// /// <summary>
|
|
// /// 修改物料清单
|
|
// /// </summary>
|
|
// /// <param name="model"></param>
|
|
// /// <returns></returns>
|
|
// public int UpdateBaseMaterialList(BaseMaterialList model)
|
|
// {
|
|
// //var response = Update(w => w.Id == model.Id, it => new BaseMaterialList()
|
|
// //{
|
|
// // Name = model.Name,
|
|
// // Code = model.Code,
|
|
// // Customer code = model.Customer code,
|
|
// // Color = model.Color,
|
|
// // Specification = model.Specification,
|
|
// // Unit = model.Unit,
|
|
// // Description = model.Description,
|
|
// // ExpirationUnit = model.ExpirationUnit,
|
|
// // ExpirationDate = model.ExpirationDate,
|
|
// // ShelfLifeWarningDays = model.ShelfLifeWarningDays,
|
|
// // IsShelfLife = model.IsShelfLife,
|
|
// // StartTime = model.StartTime,
|
|
// // StopTime = model.StopTime,
|
|
// // BarCode = model.BarCode,
|
|
// // IsBatch = model.IsBatch,
|
|
// // CreatedBy = model.CreatedBy,
|
|
// // CreatedTime = model.CreatedTime,
|
|
// // UpdatedBy = model.UpdatedBy,
|
|
// // UpdatedTime = model.UpdatedTime,
|
|
// //});
|
|
// //return response;
|
|
// return Update(model, true);
|
|
// }
|
|
|
|
// /// <summary>
|
|
// /// 获取bom结构
|
|
// /// </summary>
|
|
// /// <param name="id"></param>
|
|
// /// <returns></returns>
|
|
// public List<BaseMaterialListDto2> Achieve_BOM(string id)
|
|
// {
|
|
// var query1 = Context.Queryable<BaseMaterialBom>().Where(it => it.FkParentId == id);
|
|
// return Context.Queryable(query1).LeftJoin<BaseMaterialList>((q, m) => q.FkId == m.Id)
|
|
// .InnerJoin<BaseMaterialType>((q, m, t) => m.FkTypeId == t.Id)
|
|
// .Select((q, m, t) => new BaseMaterialListDto2()
|
|
// {
|
|
// Type_Name = t.Name,
|
|
// Type_Code = t.Code,
|
|
// }, true)
|
|
// .ToList()
|
|
// .Adapt<List<BaseMaterialListDto2>>()
|
|
// ;
|
|
|
|
|
|
|
|
// }
|
|
|
|
// /// <summary>
|
|
// /// 删除绑定关系
|
|
// /// </summary>
|
|
// /// <param name="id"></param>
|
|
// /// <returns></returns>
|
|
// public int DeleteBOMBind(string id, string parent_id)
|
|
// {
|
|
// return Context.Deleteable<BaseMaterialBom>().Where(it => it.FkId == id)
|
|
// .Where(it => it.FkParentId == parent_id)
|
|
// .ExecuteCommand();
|
|
// }
|
|
// /// <summary>
|
|
// /// 增加绑定关系
|
|
// /// </summary>
|
|
// /// <param name="id"></param>
|
|
// /// <returns></returns>
|
|
// public int ADDBOMBind(string id, string parent_id)
|
|
// {
|
|
// BaseMaterialBom bom = new BaseMaterialBom();
|
|
// bom.FkId = id;
|
|
// bom.FkParentId = parent_id;
|
|
// bom.CreatedTime = DateTime.Now;
|
|
// return Context.Insertable(bom).ExecuteCommand();
|
|
// }
|
|
|
|
|
|
// /// <summary>
|
|
// /// 获取未绑定的BOM结构
|
|
// /// </summary>
|
|
// /// <param name="id"></param>
|
|
// /// <returns></returns>
|
|
// public PagedInfo<BaseMaterialListDto2> Achieve_BOM_no_bind(BaseMaterialListQueryDto3 query)
|
|
// {
|
|
// // 成品id 的Bom结构
|
|
// string[] binded_array = Context.Queryable<BaseMaterialBom>().Where(it => it.FkParentId == query.Id).Select(it => it.FkId).ToArray();
|
|
|
|
// //在原材料和半成品中 选择
|
|
// List<BaseMaterialType> typeList = Context.Queryable<BaseMaterialType>().ToList();
|
|
// int[] leaf = FindLeafNodes(typeList, 1).Select(it => it.Id).ToArray();
|
|
// int[] leaf2 = FindLeafNodes(typeList, 5).Select(it => it.Id).ToArray();
|
|
// int[] leaf3 = leaf.Concat(leaf2).ToArray();
|
|
// var predicate = Expressionable.Create<BaseMaterialList>()
|
|
// .AndIF(!string.IsNullOrEmpty(query.Name), it => it.Name.Contains(query.Name))
|
|
// .AndIF(!string.IsNullOrEmpty(query.Code), it => it.Name.Contains(query.Code))
|
|
// .AndIF(!string.IsNullOrEmpty(query.CustomerCode), it => it.Name.Contains(query.CustomerCode))
|
|
// ;
|
|
|
|
// var qua = Context.Queryable<BaseMaterialList>().Where(it => !binded_array.Contains(it.Id))
|
|
// .Where(predicate.ToExpression())
|
|
// .Where(it => leaf3.Contains(it.FkTypeId.Value));
|
|
// return Context.Queryable(qua).InnerJoin<BaseMaterialType>((q, t) => q.FkTypeId == t.Id)
|
|
// .Select((q, t) => new BaseMaterialListDto2()
|
|
// {
|
|
// Type_Name = t.Name,
|
|
// Type_Code = t.Code,
|
|
// }, true).ToPage<BaseMaterialListDto2, BaseMaterialListDto2>(query);
|
|
|
|
|
|
// }
|
|
|
|
// public static List<BaseMaterialType> FindLeafNodes(List<BaseMaterialType> nodes, int ancestorId)
|
|
// {
|
|
// List<BaseMaterialType> leafNodes = new List<BaseMaterialType>();
|
|
|
|
// void FindLeaves(int currentId)
|
|
// {
|
|
// // 查找当前ID的直接子节点
|
|
// var children = nodes.Where(n => n.ParentId == currentId).ToList();
|
|
|
|
// // 如果没有子节点,说明是叶子节点
|
|
// if (!children.Any())
|
|
// {
|
|
// leafNodes.Add(nodes.FirstOrDefault(n => n.Id == currentId));
|
|
// }
|
|
// else
|
|
// {
|
|
// // 对每个子节点递归调用FindLeaves
|
|
// foreach (var child in children)
|
|
// {
|
|
// FindLeaves(child.Id);
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// // 从指定的祖先节点开始查找
|
|
// FindLeaves(ancestorId);
|
|
|
|
// return leafNodes;
|
|
// }
|
|
|
|
// /// <summary>
|
|
// /// bom视图
|
|
// /// </summary>
|
|
// /// <param name="id"></param>
|
|
// /// <returns></returns>
|
|
// public BaseParseNode ShowBOMView(string id)
|
|
// {
|
|
// //TODO 获取成品id的一级子集 bom
|
|
|
|
// return null;
|
|
// }
|
|
|
|
//}
|
|
}
|