| | |
| | | private readonly SqlSugarRepository<WmsRecordUpiProcess> _wmsRecordUpiProcessRep; |
| | | private readonly SqlSugarRepository<WmsRecordPackageProcess> _wmsRecordPackageProcessRep; |
| | | private readonly SqlSugarRepository<Mes_Upi_LineQueue> _mes_Upi_LineQueueRep; |
| | | private readonly SqlSugarRepository<Mes_Package_LineQueue> _mes_Package_LineQueueRep; |
| | | private readonly SqlSugarRepository<WmsRecordUpiNg> _wmsRecordUpiNgRep; |
| | | private readonly WmsCommonnQueryService _wmsCommonnQueryService; |
| | | |
| | |
| | | , SqlSugarRepository<WmsRecordPackageProcess> wmsRecordPackageProcessRep |
| | | , SqlSugarRepository<WmsRecordUpiNg> wmsRecordUpiNgRep |
| | | , WmsCommonnQueryService wmsCommonnQueryService |
| | | , SqlSugarRepository<Mes_Package_LineQueue> mes_Package_LineQueueRep |
| | | ) |
| | | { |
| | | _mes_Package_LineQueueRep = mes_Package_LineQueueRep; |
| | | _wmsCommonnQueryService = wmsCommonnQueryService; |
| | | _wmsRecordUpiNgRep = wmsRecordUpiNgRep; |
| | | _sysConfigRep = sysConfigRep; |
| | |
| | | quan.OperReason = "人工强制待出库"; |
| | | } |
| | | updateQuanList.AddRange(quanList); |
| | | |
| | | var packageObj = await _mesPackageGatherRep.GetFirstAsync(x => x.PackageCode == item); |
| | | packageObj.UpiFlag = UpiFlagEnum.NG; |
| | | packageObj.UpiStatus = UpiStatusEnum.已下线; |
| | | await _mesPackageGatherRep.UpdateAsync(packageObj); |
| | | |
| | | |
| | | //下线更新 订单表数据 _mesOrderGatherRep |
| | | await UpdateOrderGather(packageObj, true); |
| | | |
| | | foreach (var quan in quanList) |
| | | { |
| | | //清理 队列表 |
| | | var removeUpiList = await _mes_Upi_LineQueueRep.AsQueryable().Where(x => x.Upi == quan.Upi).ToListAsync(); |
| | | if (removeUpiList?.Count > 0) |
| | | { |
| | | await _mes_Upi_LineQueueRep.DeleteAsync(removeUpiList); |
| | | } |
| | | |
| | | var removePackageList = await _mes_Package_LineQueueRep.AsQueryable().Where(x => x.PackageCode == quan.PackageCode).ToListAsync(); |
| | | if (removePackageList?.Count > 0) |
| | | { |
| | | await _mes_Package_LineQueueRep.DeleteAsync(removePackageList); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //模式判断 |
| | |
| | | quan.OperReason = "人工齐包出库"; |
| | | } |
| | | updateQuanList.AddRange(quanList); |
| | | |
| | | var packageObj = await _mesPackageGatherRep.GetFirstAsync(x => x.PackageCode == item); |
| | | packageObj.UpiStatus = UpiStatusEnum.已齐包; |
| | | packageObj.IsQiBao = true; |
| | | await _mesPackageGatherRep.UpdateAsync(packageObj); |
| | | } |
| | | |
| | | //模式判断 |
| | |
| | | |
| | | var setValue = ""; |
| | | var _QiTaoReuslt = ""; |
| | | var other_orderList = await _mesPackageGatherRep.AsQueryable().Where(x => x.Info5 == package.Info5 && x.PackageCode != input.PackageCode).ToListAsync(); |
| | | var num = other_orderList.Where(x => x.UpiStatus == UpiStatusEnum.初始 || x.UpiStatus == UpiStatusEnum.不齐包).Count(); |
| | | if (num > 0) |
| | | |
| | | bool isNeedQueryQiTao = true; |
| | | var order = await _mesOrderGatherRep.AsQueryable().Where(x => x.Info5 == package.Info5).FirstAsync(); |
| | | if (order == null) |
| | | { |
| | | //不齐套 |
| | | setValue = $"{input.PackageCode}|不齐套|" + curUserName; |
| | | _QiTaoReuslt = "不齐套"; |
| | | |
| | | } |
| | | else |
| | | { |
| | | setValue = $"{input.PackageCode}|齐套|" + curUserName; |
| | | _QiTaoReuslt = "齐套"; |
| | | if (order.IsKitting != null) |
| | | { |
| | | _QiTaoReuslt = (bool)order.IsKitting ? "齐套" : "不齐套"; |
| | | isNeedQueryQiTao = false; |
| | | } |
| | | } |
| | | if (isNeedQueryQiTao) |
| | | { |
| | | var other_orderList = await _mesPackageGatherRep.AsQueryable().Where(x => x.Info5 == package.Info5 && x.PackageCode != input.PackageCode).ToListAsync(); |
| | | var num = other_orderList.Where(x => x.UpiStatus == UpiStatusEnum.初始).Count(); |
| | | if (num > 0) |
| | | { |
| | | //不齐套 |
| | | _QiTaoReuslt = "不齐套"; |
| | | } |
| | | else |
| | | { |
| | | _QiTaoReuslt = "齐套"; |
| | | } |
| | | } |
| | | setValue = $"{input.PackageCode}|{_QiTaoReuslt}|" + curUserName; |
| | | |
| | | if (package.UpiStatus == UpiStatusEnum.已下线) |
| | | { |
| | | throw Oops.Oh($"包已下线,齐套结果[{_QiTaoReuslt}]"); |
| | | } |
| | | |
| | | if (order == null) |
| | | { |
| | | Mes_Order_Gather newOrder = new Mes_Order_Gather() |
| | | { |
| | | Info5 = package.Info5, |
| | | IsKitting = _QiTaoReuslt == "齐套" ? true : false, |
| | | PlanNo = package.PlanNo, |
| | | OrderId = package.OrderId |
| | | }; |
| | | await _mesOrderGatherRep.InsertAsync(newOrder); |
| | | } |
| | | else |
| | | { |
| | | order.IsKitting = _QiTaoReuslt == "齐套" ? true : false; |
| | | await _mesOrderGatherRep.UpdateAsync(order); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | /// <summary> |
| | | /// NG包下线-扫描包号 |
| | | /// NG包下线或 正常包 下线 -扫描包号 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | |
| | | //{ |
| | | // throw Oops.Oh("原因不能为空"); |
| | | //} |
| | | string _OperRemark = "正常人工下线"; |
| | | UpiFlagEnum upiFlagEnum = UpiFlagEnum.正常; |
| | | if (input.IsNG) |
| | | { |
| | | upiFlagEnum = UpiFlagEnum.NG; |
| | | _OperRemark = "NG下线"; |
| | | } |
| | | |
| | | var singlePackage = await _mesPackageGatherRep.AsQueryable().Where(x => x.PackageCode == input.PackageCode).FirstAsync(); |
| | | if (singlePackage == null) |
| | |
| | | throw Oops.Oh($"没有找到包号{input.PackageCode}的汇总数据"); |
| | | } |
| | | |
| | | singlePackage.UpiFlag = UpiFlagEnum.NG; |
| | | if (singlePackage.UpiStatus == UpiStatusEnum.已下线) |
| | | { |
| | | throw Oops.Oh($"包号{input.PackageCode}已经下线"); |
| | | } |
| | | |
| | | singlePackage.UpiFlag = upiFlagEnum; |
| | | singlePackage.UpdateTime = DateTime.Now; |
| | | singlePackage.UpiStatus = UpiStatusEnum.已下线; |
| | | singlePackage.AreaCode = AreaCodeEnum.下线区域; |
| | |
| | | wmsRecordUpi.CreateTime = DateTime.Now; |
| | | wmsRecordUpi.CreateUserName = _cretaorName; |
| | | wmsRecordUpi.Location = ""; |
| | | wmsRecordUpi.OperRemark = "NG下线"; |
| | | wmsRecordUpi.OperRemark = _OperRemark; |
| | | await _wmsRecordUpiProcessRep.InsertAsync(wmsRecordUpi); |
| | | |
| | | WmsRecordUpiNg wmsRecordUpiNg = new WmsRecordUpiNg(); |
| | |
| | | wmsRecordUpiNg.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wmsRecordUpiNg.CreateTime = DateTime.Now; |
| | | wmsRecordUpiNg.CreateUserName = _cretaorName; |
| | | wmsRecordUpiNg.OperRemark = "NG下线"; |
| | | wmsRecordUpiNg.OperRemark = _OperRemark; |
| | | await _wmsRecordUpiNgRep.InsertAsync(wmsRecordUpiNg); |
| | | |
| | | |
| | | |
| | | //清理 队列表 |
| | | var removeUpiList = await _mes_Upi_LineQueueRep.AsQueryable().Where(x => x.Upi == item.UPI).ToListAsync(); |
| | | if (removeUpiList?.Count > 0) |
| | | { |
| | | await _mes_Upi_LineQueueRep.DeleteAsync(removeUpiList); |
| | | } |
| | | |
| | | var removePackageList = await _mes_Package_LineQueueRep.AsQueryable().Where(x => x.PackageCode == item.PackageCode).ToListAsync(); |
| | | if (removePackageList?.Count > 0) |
| | | { |
| | | await _mes_Package_LineQueueRep.DeleteAsync(removePackageList); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | //下线更新 订单表数据 _mesOrderGatherRep |
| | | await UpdateOrderGather(singlePackage, input.IsNG); |
| | | |
| | | |
| | | WmsRecordPackageProcess wmsRecordPackage = new WmsRecordPackageProcess(); |
| | | wmsRecordPackage = singlePackage.Adapt<WmsRecordPackageProcess>(); |
| | | wmsRecordPackage.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wmsRecordPackage.Location = ""; |
| | | wmsRecordPackage.OperRemark = "NG下线"; |
| | | wmsRecordPackage.OperRemark = _OperRemark; |
| | | wmsRecordPackage.CreateTime = DateTime.Now; |
| | | wmsRecordPackage.CreateUserName = _cretaorName; |
| | | await _wmsRecordPackageProcessRep.InsertAsync(wmsRecordPackage); |
| | |
| | | await _mesPackageGatherRep.UpdateAsync(singlePackage); |
| | | await _mesBatchOrderUpiRep.UpdateRangeAsync(upiList); |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 下线更新 订单表数据 |
| | | /// </summary> |
| | | /// <param name="singlePackage"></param> |
| | | /// <returns></returns> |
| | | private async Task UpdateOrderGather(Mes_Package_Gather singlePackage, bool isNG) |
| | | { |
| | | //下线更新 订单表数据 _mesOrderGatherRep |
| | | bool isAdd = false; |
| | | var order = await _mesOrderGatherRep.AsQueryable().Where(x => x.Info5 == singlePackage.Info5).FirstAsync(); |
| | | if (order == null) |
| | | { |
| | | isAdd = true; |
| | | order = new Mes_Order_Gather() |
| | | { |
| | | Info5 = singlePackage.Info5, |
| | | OrderId = singlePackage.OrderId, |
| | | PlanNo = singlePackage.PlanNo, |
| | | }; |
| | | } |
| | | var packageList = await _mesPackageGatherRep.AsQueryable().Where(x => x.Info5 == singlePackage.Info5).ToListAsync(); |
| | | order.PackageNum = packageList.Count(); |
| | | order.UnLinePackageNum = packageList.Where(x => x.UpiStatus == UpiStatusEnum.已下线).Count() + 1; |
| | | |
| | | order.NgPackageNum = packageList.Where(x => x.UpiStatus == UpiStatusEnum.已下线 && x.UpiFlag == UpiFlagEnum.NG).Count(); |
| | | if (isNG) |
| | | { |
| | | order.NgPackageNum = order.NgPackageNum + 1; |
| | | } |
| | | |
| | | order.NoUnLinePackageNum = order.PackageNum - order.UnLinePackageNum; |
| | | |
| | | order.AllPackageArea = packageList.Sum(x => Convert.ToDecimal(x.Info13)); |
| | | order.ScanPackageArea = packageList.Where(x => x.UpiStatus == UpiStatusEnum.已下线 && x.UpiFlag == (int)UpiFlagEnum.正常).Sum(x => Convert.ToDecimal(x.Info13)); |
| | | if (isNG == false) |
| | | { |
| | | order.ScanPackageArea = order.ScanPackageArea + Convert.ToDecimal(singlePackage.Info13); |
| | | } |
| | | |
| | | order.NoScanPackageArea = order.AllPackageArea - order.ScanPackageArea; |
| | | if (isAdd) |
| | | { |
| | | await _mesOrderGatherRep.InsertAsync(order); |
| | | } |
| | | else |
| | | { |
| | | await _mesOrderGatherRep.UpdateAsync(order); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 扫码记录清除 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [ApiDescriptionSettings(Name = "PartClear")] |
| | | [Description("WmsOperationTask/PartClear")] |
| | | public async Task PartClear() |
| | | { |
| | | //模式判断 |
| | | var client = await WCFServiceHelper.GetWCFService_SAPCC_Client(_sysConfigRep); |
| | | var res = await client.WriteStation_PartClearAsync(); |
| | | if (res.result == false) |
| | | { |
| | | throw Oops.Oh(res.resMsg); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |