| | |
| | | |
| | | |
| | | /// <summary> |
| | | /// NG包下线 |
| | | /// NG包下线-扫描包号 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// NG包下线-扫描件号 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [ApiDescriptionSettings(Name = "SetNG")] |
| | | [Description("WmsOperationTask/SetNG")] |
| | | [UnitOfWork] |
| | | public async Task SetNG(SetNGInput input) |
| | | { |
| | | if (input == null) |
| | | { |
| | | throw Oops.Oh("参数不能为空"); |
| | | } |
| | | if (string.IsNullOrEmpty(input.Upi)) |
| | | { |
| | | throw Oops.Oh("部件条码不能为空"); |
| | | } |
| | | //if (string.IsNullOrEmpty(input.Reason)) |
| | | //{ |
| | | // throw Oops.Oh("原因不能为空"); |
| | | //} |
| | | |
| | | var singleUpi = await _mesBatchOrderUpiRep.AsQueryable().Where(x => x.UPI == input.Upi).FirstAsync(); |
| | | if (singleUpi == null) |
| | | { |
| | | throw Oops.Oh($"没有找到部件条码{input.Upi}的数据"); |
| | | } |
| | | var packageCode = singleUpi.PackageCode; |
| | | var singlePackage = await _mesPackageGatherRep.AsQueryable().Where(x => x.PackageCode == packageCode).FirstAsync(); |
| | | if (singlePackage == null) |
| | | { |
| | | throw Oops.Oh($"没有找到包号{packageCode}的汇总数据"); |
| | | } |
| | | |
| | | singlePackage.UpiFlag = UpiFlagEnum.NG; |
| | | singlePackage.UpdateTime = DateTime.Now; |
| | | |
| | | var upiLineQueueList = await _mes_Upi_LineQueueRep.AsQueryable().Where(x => x.PackageCode == packageCode).ToListAsync(); |
| | | if (upiLineQueueList?.Count > 0) |
| | | { |
| | | await _mes_Upi_LineQueueRep.DeleteAsync(upiLineQueueList); |
| | | } |
| | | |
| | | var upiList = await _mesBatchOrderUpiRep.AsQueryable().Where(x => x.PackageCode == packageCode).ToListAsync(); |
| | | if (upiList == null) |
| | | { |
| | | throw Oops.Oh($"没有找到包号{packageCode}的板件数据"); |
| | | } |
| | | foreach (var item in upiList) |
| | | { |
| | | item.UpiFlag = UpiFlagEnum.NG; |
| | | item.UpdateTime = DateTime.Now; |
| | | |
| | | WmsRecordUpiProcess wmsRecordUpi = new WmsRecordUpiProcess(); |
| | | wmsRecordUpi = item.Adapt<WmsRecordUpiProcess>(); |
| | | wmsRecordUpi.CreateTime = DateTime.Now; |
| | | wmsRecordUpi.Location = ""; |
| | | wmsRecordUpi.OperRemark = "标记NG"; |
| | | await _wmsRecordUpiProcessRep.InsertAsync(wmsRecordUpi); |
| | | } |
| | | |
| | | |
| | | WmsRecordPackageProcess wmsRecordPackage = new WmsRecordPackageProcess(); |
| | | wmsRecordPackage = singlePackage.Adapt<WmsRecordPackageProcess>(); |
| | | wmsRecordPackage.Location = ""; |
| | | wmsRecordPackage.OperRemark = "标记NG"; |
| | | await _wmsRecordPackageProcessRep.InsertAsync(wmsRecordPackage); |
| | | |
| | | |
| | | await _mesPackageGatherRep.UpdateAsync(singlePackage); |
| | | await _mesBatchOrderUpiRep.UpdateRangeAsync(upiList); |
| | | |
| | | } |
| | | |
| | | } |
| | | |