| | |
| | | |
| | | return await ExecuteWithinTransactionAsync(async () => |
| | | { |
| | | // 幂等写入:检查临时表是否已有该托盘记录,无则写入 |
| | | var existingTemp = SqlSugarClient.Queryable<Dt_SplitTemp>() |
| | | .Where(t => t.PalletCode == stock.SourcePalletNo) |
| | | .First(); |
| | | if (existingTemp == null) |
| | | { |
| | | // 查询该托盘当前所有电芯,存入临时表 |
| | | var sourceStockForTemp = StockInfoService.Repository.QueryFirst(s => s.PalletCode == stock.SourcePalletNo); |
| | | if (sourceStockForTemp != null) |
| | | { |
| | | var allDetails = StockInfoDetailService.Repository.QueryData(d => d.StockId == sourceStockForTemp.Id); |
| | | if (allDetails != null && allDetails.Any()) |
| | | { |
| | | var sfcListJson = JsonConvert.SerializeObject(allDetails.Select(d => d.SerialNumber).ToList()); |
| | | await SqlSugarClient.Insertable(new Dt_SplitTemp |
| | | { |
| | | PalletCode = stock.SourcePalletNo, |
| | | SfcList = sfcListJson, |
| | | CreateTime = DateTime.Now |
| | | }).ExecuteCommandAsync(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | var sourceStock = await StockInfoService.Repository.QueryDataNavFirstAsync(s => s.PalletCode == stock.SourcePalletNo); |
| | | if (sourceStock == null) return content.Error("源托盘不存在"); |
| | | |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据托盘号查询库存明细数量 |
| | | /// </summary> |
| | | /// <param name="palletCode">托盘号</param> |
| | | /// <returns>库存明细数量</returns> |
| | | public async Task<WebResponseContent> GetStockDetailCountByPalletCodeAsync(string palletCode) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | if (string.IsNullOrWhiteSpace(palletCode)) |
| | | return content.Error("托盘号不能为空"); |
| | | |
| | | var stockInfo = StockInfoService.Repository.QueryFirst(s => s.PalletCode == palletCode); |
| | | if (stockInfo == null) |
| | | return content.Error("托盘不存在"); |
| | | |
| | | var count = await StockInfoDetailService.Repository.Db.Queryable<Dt_StockInfoDetail>() |
| | | .CountAsync(d => d.StockId == stockInfo.Id); |
| | | return content.OK("查询成功", new { PalletCode = palletCode, DetailCount = count }); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据设备名称和托盘号解析MES设备配置 |
| | | /// </summary> |
| | | /// <param name="deviceName">设备名称</param> |