调整物料编码
This commit is contained in:
@@ -890,7 +890,36 @@ namespace WMS.Web.Domain.Services.Public
|
||||
return Result<ErpMaterialDto>.ReSuccess(mater);
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// erp:基础数据-物料信息
|
||||
/// </summary>
|
||||
/// <param name="number"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result<ErpMaterialDto>> BillQueryForMaterial(string number)
|
||||
{
|
||||
//1.获取缓存中的物料数据
|
||||
var materials = _memoryCache.Get<List<ErpMaterialDto>>(_erpOptions.cache_materail_key);
|
||||
if (materials == null || materials.Count == 0)
|
||||
return Result<ErpMaterialDto>.ReSuccess(null);
|
||||
//2.通过ID取当前物料列表中的
|
||||
var mater = materials.Where(x => x.MaterialNumber == number).FirstOrDefault();
|
||||
if (mater == null)
|
||||
{
|
||||
//2.1没有的话:去金蝶取
|
||||
mater = await this.BillQueryForMaterialByNumber(number);
|
||||
if (mater != null)
|
||||
{
|
||||
//把取到的数据放集合中并重新给缓存
|
||||
materials.Add(mater);
|
||||
_memoryCache.Set(_erpOptions.cache_materail_key, materials, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(DateTimeUtil.GetTotalMinutesTimeSpan())));
|
||||
return Result<ErpMaterialDto>.ReSuccess(mater);
|
||||
|
||||
}
|
||||
else
|
||||
return Result<ErpMaterialDto>.ReSuccess(null);
|
||||
}
|
||||
return Result<ErpMaterialDto>.ReSuccess(mater);
|
||||
}
|
||||
/// <summary>
|
||||
/// erp:基础数据-物料-分页查询
|
||||
/// </summary>
|
||||
@@ -1042,6 +1071,74 @@ namespace WMS.Web.Domain.Services.Public
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// erp:基础数据-物料-number查询
|
||||
/// </summary>
|
||||
/// <param name="number"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<ErpMaterialDto> BillQueryForMaterialByNumber(string number)
|
||||
{
|
||||
//2.先登录金蝶-拿到token
|
||||
var token_result = await this.Init();
|
||||
if (!token_result.IsSuccess)
|
||||
return null;
|
||||
|
||||
//3.获取金蝶物料:拼接参数和条件
|
||||
var query = new ErpBillQueryDto(token_result.Data);
|
||||
var param = new ErpBillQueryParamDto(FormIdParam.BD_MATERIAL.ToString());
|
||||
param.FieldKeys = "FMATERIALID,FName,FNumber,FSpecification,FBaseUnitId,FBaseUnitId.FName,FBaseUnitId.FNumber,FBARCODE";
|
||||
param.Limit = 10000;
|
||||
|
||||
//查询条件:备注其中的条件值以金蝶的值为准!!!
|
||||
//1.审核状态:已审核
|
||||
//2.禁用状态:A否,B是
|
||||
//3.使用组织:只查询“深圳市元创时代科技有限公司”这个组织;组织ID=100008--固定值查询(测试端和正式是一样的)---按ID查询就不需要固定组织条件了
|
||||
param.FilterString = "FDocumentStatus='C' and FForbidStatus='A'";
|
||||
param.OrderString = "FCreateDate ASC";
|
||||
|
||||
//根据物料ID查询
|
||||
param.FilterString = param.FilterString + $" and FNumber={number}";
|
||||
|
||||
//4.循环拿金蝶数据
|
||||
var erp_materials_list = new List<ErpMaterialDto>();
|
||||
|
||||
//4.2.参数json化
|
||||
query.Data = JsonConvert.SerializeObject(param);
|
||||
var json = JsonConvert.SerializeObject(query);
|
||||
|
||||
var error_josn = "";
|
||||
try
|
||||
{
|
||||
//4.3.请求查询接口并返回数据
|
||||
var result_json = await _client.ExecuteBillQueryAsync(json);
|
||||
error_josn = result_json;
|
||||
var result = JsonConvert.DeserializeObject<List<List<string>>>(result_json);
|
||||
//4.5.拼装
|
||||
foreach (var item in result)
|
||||
{
|
||||
var lis = new ErpMaterialDto();
|
||||
lis.MaterialId = Convert.ToInt32(item[0]);
|
||||
lis.MaterialName = item[1];
|
||||
lis.MaterialNumber = item[2];
|
||||
lis.Specifications = item[3];
|
||||
lis.BaseUnitId = Convert.ToInt32(item[4]);
|
||||
lis.BaseUnitName = item[5];
|
||||
lis.BaseUnitNumber = item[6];
|
||||
lis.BarCode = item[7];
|
||||
erp_materials_list.Add(lis);
|
||||
}
|
||||
if (erp_materials_list.Count == 0)
|
||||
return null;
|
||||
else
|
||||
return erp_materials_list.FirstOrDefault();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
_logger.LogInformation("物料拉取按Number->错误的Json:" + error_josn);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2392,8 +2489,10 @@ namespace WMS.Web.Domain.Services.Public
|
||||
return ResultList<ErpInventoryDto>.ReFailure(ResultCodes.Erp_Inventory_Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user