This commit is contained in:
tongfei
2023-12-06 14:48:42 +08:00
5 changed files with 57 additions and 39 deletions

View File

@@ -1,12 +1,15 @@
using AutoMapper;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WMS.Web.Core.Dto;
using WMS.Web.Core.Dto.Erp;
using WMS.Web.Core.Dto.Erp.Customer;
using WMS.Web.Core.Dto.SerialNumbers;
using WMS.Web.Core.Help;
using WMS.Web.Domain.Entitys;
@@ -99,15 +102,15 @@ namespace WMS.Web.Repositories
/// <returns></returns>
public async Task<SerialNumbersResponse> Get(string serialNumber)
{
List<ErpMaterialDto> materials = new List<ErpMaterialDto>();
var materials_result = await _erpService.BillQueryForMaterial();
if (!materials_result.IsSuccess)
return null;
var materials = materials_result.Data.ToList();
if (materials_result.IsSuccess)
materials = materials_result.Data.ToList();
List<ErpCustomerDto> customers = new List<ErpCustomerDto>();
var customer_result = await _erpService.BillQueryForCustomer();
if (!customer_result.IsSuccess)
return null;
var customers = customer_result.Data.ToList();
if (customer_result.IsSuccess)
customers = customer_result.Data.ToList();
var s = await _context.SerialNumbers
.FirstOrDefaultAsync(f => serialNumber.Equals(f.SerialNumber));
@@ -121,10 +124,20 @@ namespace WMS.Web.Repositories
InStockTime = s.InStockTime.DateToStringSeconds(),
OutStockTime = s.OutStockTime.DateToStringSeconds(),
PurchaseBillNo = s.PurchaseBillNo,
SalBillNo = s.SalBillNo,
Customer = _erpBasicDataExtendService.GetCustomerName(customers, s.CustomerId),
SerialNumber = s.SerialNumber
};
if (!string.IsNullOrEmpty(s.SalBillNo))
{
Random rd = new Random();
var list = JsonConvert.DeserializeObject<List<string>>(s.SalBillNo);
if (list.Count() > 0)
{
int index = rd.Next(0, list.Count);
respone.SalBillNo = list[index];
}
}
return respone;
}