| | |
| | | using Mapster; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using Microsoft.EntityFrameworkCore; |
| | | using SharpYaml; |
| | | using System.Linq.Dynamic.Core; |
| | | |
| | | namespace iWare.Wms.Application |
| | |
| | | //[Route("api")] |
| | | [ApiDescriptionSettings("自己的业务", Name = "WorkPieceOutbound", Order = 100)] |
| | | [Route("api/[Controller]")] |
| | | [DisableOpLog] |
| | | public class WorkPieceOutboundService : IWorkPieceOutboundService, IDynamicApiController, ITransient |
| | | { |
| | | private readonly IRepository<WorkPieceOutbound,MasterDbContextLocator> _workPieceOutboundRep; |
| | | |
| | | private readonly IRepository<WorkPieceOutbound, MasterDbContextLocator> _workPieceOutboundRep; |
| | | private readonly IRepository<WorkPieceInfo, MasterDbContextLocator> _workPieceInfoRep; |
| | | private readonly IRepository<WorkPieceOutboundRecord, MasterDbContextLocator> _workPieceOutboundRecordRep; |
| | | |
| | | public WorkPieceOutboundService( |
| | | IRepository<WorkPieceOutbound,MasterDbContextLocator> workPieceOutboundRep |
| | | IRepository<WorkPieceOutboundRecord, MasterDbContextLocator> workPieceOutboundRecordRep, |
| | | IRepository<WorkPieceInfo, MasterDbContextLocator> workPieceInfoRep, |
| | | IRepository<WorkPieceOutbound, MasterDbContextLocator> workPieceOutboundRep |
| | | ) |
| | | { |
| | | _workPieceOutboundRecordRep = workPieceOutboundRecordRep; |
| | | _workPieceInfoRep = workPieceInfoRep; |
| | | _workPieceOutboundRep = workPieceOutboundRep; |
| | | } |
| | | |
| | |
| | | var workPieceOutbounds = await _workPieceOutboundRep.DetachedEntities |
| | | .Where(!string.IsNullOrEmpty(input.WorkPieceID), u => u.WorkPieceID.Contains(input.WorkPieceID)) |
| | | .Where(!string.IsNullOrEmpty(input.OP80NewCode), u => u.OP80NewCode.Contains(input.OP80NewCode)) |
| | | .Where(!string.IsNullOrEmpty(input.WorkPieceOutboundUserName), u => u.WorkPieceOutboundUserName.Contains(input.WorkPieceOutboundUserName)) |
| | | .Where(!string.IsNullOrEmpty(input.StartTimeBeginTime.ToString()), u => u.WorkPieceOutboundTime >= input.StartTimeBeginTime) |
| | | .Where(!string.IsNullOrEmpty(input.StartTimeEndTime.ToString()), u => u.WorkPieceOutboundTime <= input.StartTimeEndTime) |
| | | .OrderBy(PageInputOrder.OrderBuilder<WorkPieceOutboundSearch>(input)) |
| | |
| | | .ToADPagedListAsync(input.PageNo, input.PageSize); |
| | | return workPieceOutbounds; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 分页查询工件出库历史信息 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | [HttpGet("pageForRecord")] |
| | | public async Task<PageResult<WorkPieceOutboundRecord>> PageForRecord([FromQuery] WorkPieceOutboundSearch input) |
| | | { |
| | | var workPieceOutbounds = await _workPieceOutboundRecordRep.DetachedEntities |
| | | .Where(!string.IsNullOrEmpty(input.WorkPieceID), u => u.WorkPieceID.Contains(input.WorkPieceID)) |
| | | .Where(!string.IsNullOrEmpty(input.OP80NewCode), u => u.OP80NewCode.Contains(input.OP80NewCode)) |
| | | .Where(!string.IsNullOrEmpty(input.WorkPieceOutboundUserName), u => u.CreatedUserName.Contains(input.WorkPieceOutboundUserName)) |
| | | .Where(!string.IsNullOrEmpty(input.StartTimeBeginTime.ToString()), u => u.CreatedTime >= input.StartTimeBeginTime) |
| | | .Where(!string.IsNullOrEmpty(input.StartTimeEndTime.ToString()), u => u.CreatedTime <= input.StartTimeEndTime) |
| | | .OrderBy(PageInputOrder.OrderBuilder<WorkPieceOutboundSearch>(input)) |
| | | .ProjectToType<WorkPieceOutboundRecord>() |
| | | .ToADPagedListAsync(input.PageNo, input.PageSize); |
| | | return workPieceOutbounds; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 增加工件出库信息 |
| | |
| | | if (!isExist) throw Oops.Oh(ErrorCode.D3000); |
| | | |
| | | var workPieceOutbound = input.Adapt<WorkPieceOutbound>(); |
| | | await _workPieceOutboundRep.UpdateAsync(workPieceOutbound,ignoreNullValues:true); |
| | | await _workPieceOutboundRep.UpdateAsync(workPieceOutbound, ignoreNullValues: true); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | [HttpPost("revoke")] |
| | | [UnitOfWork] |
| | | public async Task Revoke(List<DeleteWorkPieceOutboundInput> input) |
| | | { |
| | | foreach (var item in input) { |
| | | foreach (var item in input) |
| | | { |
| | | var workPieceOutbound = await _workPieceOutboundRep.FirstOrDefaultAsync(u => u.Id == item.Id); |
| | | if (workPieceOutbound == null) |
| | | { |
| | | throw Oops.Oh("工件出库信息不存在"); |
| | | throw Oops.Oh("工件入库信息不存在"); |
| | | } |
| | | workPieceOutbound.IsDeleted = true; |
| | | workPieceOutbound.Remark = workPieceOutbound.Remark??""+"撤销发货"; |
| | | await _workPieceOutboundRep.UpdateAsync(workPieceOutbound); |
| | | //workPieceOutbound.IsDeleted = true; |
| | | //workPieceOutbound.Remark = workPieceOutbound.Remark ?? "" + "撤销入库"; |
| | | //await _workPieceOutboundRep.UpdateAsync(workPieceOutbound); |
| | | await _workPieceOutboundRep.DeleteAsync(workPieceOutbound); |
| | | |
| | | var outBoundLog = new WorkPieceOutboundRecord |
| | | { |
| | | OperationType = OutboundOperationType.撤销入库.ToString(), |
| | | WorkPieceID = workPieceOutbound?.WorkPieceID, |
| | | OP80NewCode = workPieceOutbound?.OP80NewCode, |
| | | |
| | | CreatedUserId = CurrentUserInfo.UserId, |
| | | CreatedUserName = CurrentUserInfo.Name, |
| | | |
| | | // CarNo = itemModel.CarNo, |
| | | Remark = "撤销入库", |
| | | |
| | | }; |
| | | await _workPieceOutboundRecordRep.InsertAsync(outBoundLog); |
| | | |
| | | var workPiece = await _workPieceInfoRep.FirstOrDefaultAsync(u => u.WorkPieceID == workPieceOutbound.WorkPieceID); |
| | | if (workPiece != null) |
| | | { |
| | | workPiece.OutPerson = CurrentUserInfo.Name; |
| | | workPiece.OutRemark = "撤销入库"; |
| | | workPiece.OutTime = DateTime.Now; |
| | | workPiece.IsOut = false; |
| | | |
| | | await _workPieceInfoRep.UpdateAsync(workPiece); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |