| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- using Microsoft.EntityFrameworkCore;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Dynamic.Core;
- using System.Threading.Tasks;
- using Volo.Abp.Application.Dtos;
- using Volo.Abp.Domain.Repositories;
- using Business.Models;
- using Microsoft.AspNetCore.Authorization;
- using Business.Permissions;
- using XCZ;
- using Business.ResourceExamineManagement.Dto;
- using Bussiness.Model.MES.IC;
- using AutoMapper.Internal.Mappers;
- using Business.Core.Utilities;
- using Hangfire.Storage.Monitoring;
- using Business.BookManagement.Dto;
- using Volo.Abp.ObjectMapping;
- namespace Business.ResourceExamineManagement
- {
- public class ResourceExamineAppService : IResourceExamineAppService
- {
- private IRepository<ic_item,long> _ic_item;
- private IRepository<ic_bom, long> _ic_bom;
- private IRepository<ic_bom_child, long> _ic_bom_child;
- public ResourceExamineAppService(
- IRepository<ic_item, long> icitem,
- IRepository<ic_bom, long> icbom,
- IRepository<ic_bom_child, long> icbomchild
- )
- {
- _ic_item = icitem;
- _ic_bom = icbom;
- _ic_bom_child = icbomchild;
- }
- /// <summary>
- /// 资源检查
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- /// <exception cref="NotImplementedException"></exception>
- public async Task<PschedDto> ReceiveResult(SeorderentryDto input)
- {
- //throw new NotImplementedException();
- long orderid=0;
- long BomId=0;
- int Quantity=0;
- await BomPretreatmentAsync(orderid, BomId, Quantity);
- }
- /// <summary>
- /// BOM预处理
- /// </summary>
- /// <param name="orderid">订单行id</param>
- /// <param name="BomId">Bom主键</param>
- /// <param name="Quantity">需要数量</param>
- public async Task BomPretreatmentAsync(long? orderid,long? BomId, int Quantity)
- {
- if (orderid == null)
- {
- //throw new bu
- }
- if (BomId == null)
- {
- //throw new bu
- }
- var help = new SnowFlake(1, 1);
- var id = help.NextId();
- var level = 0;
- var bomlist = (await _ic_bom.GetQueryableAsync()).ToList();
- var bomchildlist = (await _ic_bom_child.GetQueryableAsync()).ToList();
- var icitemlist = (await _ic_item.GetQueryableAsync()).ToList();
- //GetBomListAsync();
- }
- public void GetBomList(List<ic_bom> bomlist, List<ic_bom_child> bomchildlist, List<ic_item> icitemlist, long bomId, List<BomChildExamineDto> returnlist, long? parent_id, int le)
- {
- int level = le++;//初始化定义level层级
- var help = new SnowFlake(1, 1);
- var bom = bomlist.WhereIf(true, s => s.bom_id == bomId).FirstOrDefault();
- if (bom == null)
- {
- }
- var dto = new BomChildExamineDto();
- dto.level = level;
- dto.bom_id = bomId;
- dto.id = help.NextId();
- dto.parent_id = parent_id;
- dto.item_id = bom.icitem_id;
- dto.item_name = bom.item_name;
- dto.item_code = bom.item_number;
- //var bdto = ObjectMapper.Map<ic_bom,BomChildExamineDto>(bom);
- returnlist.Add(dto);
- var childlist = bomchildlist.WhereIf(true, a => a.bom_id == bom.bom_id).ToList();
- foreach (var c in childlist)
- {
- var icitem = icitemlist.WhereIf(true, a => a.icitem_id == c.icitem_id).FirstOrDefault();
- //如果此明细查的到BOM信息,则代表此child是一个子BOM。
- if (c.is_bom == 1)
- {
- var childBom = bomlist.WhereIf(true, a => a.icitem_id == c.icitem_id).FirstOrDefault();
- if (childBom != null)
- {
- GetBomList(bomlist, bomchildlist, icitemlist, childBom.bom_id, returnlist, dto.id, level);
- }
- }
- else {
- if (icitem != null)
- {
- var childDto = new BomChildExamineDto();
- childDto.level = level++;
- childDto.bom_id = bomId;
- childDto.id = help.NextId();
- childDto.parent_id = parent_id;
- childDto.item_id = icitem.icitem_id;
- childDto.item_name = icitem.name;
- childDto.item_code = icitem.number;
- returnlist.Add(childDto);
- }
- }
- }
-
- }
- }
- }
|