This commit is contained in:
tongfei
2023-11-06 16:56:42 +08:00
16 changed files with 907 additions and 23 deletions

View File

@@ -6,6 +6,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WMS.Web.Core.Dto;
using WMS.Web.Core.Dto.Erp.OutStock;
using WMS.Web.Core.Dto.Erp.Purchase;
using WMS.Web.Core.Dto.Login;
using WMS.Web.Core.Internal.Results;
@@ -20,7 +21,7 @@ namespace WMS.Web.Domain.Services
/// <summary>
/// 出库任务
/// </summary>
public class OutStockTaskService: IOutStockTaskService
public class OutStockTaskService : IOutStockTaskService
{
private readonly IMapper _mapper;
private readonly IErpService _erpService;
@@ -85,20 +86,150 @@ namespace WMS.Web.Domain.Services
return Result.ReSuccess();
}
/// <summary>
/// erp数据转化wms 执行数据库操作
/// </summary>
/// <param name="erp_list"></param>
/// <param name="isTransaction"></param>
/// <returns></returns>
public async Task<Result> SsynDate(List<ErpDeliveryNoticeOutStockResultDto> erp_list, bool isTransaction)
{
//2.通过单据编号找到wms系统现有的任务单并修改
var erp_removeList = new List<ErpDeliveryNoticeOutStockResultDto>();
var SourceBillNo_list = erp_list.GroupBy(x => x.SourceBillNo).Select(x => x.Key).ToList();
var data_list = await _outStockTaskRepositories.GetListBySourceBillNo(SourceBillNo_list);
if (data_list.Count != 0)
{
//2.1提取出wms任务单明细信息
foreach (var e in erp_list)
{
//代表单据已经存在 那么就对单据进行修改
var data = data_list.FirstOrDefault(f => f.SourceBillNo == e.SourceBillNo);
var detail = data.Details.FirstOrDefault(w => w.MaterialId == e.MaterialId);
//存在就修改,没有就添加
if (detail != null)
detail.AccruedQty = e.AccruedQty;
else
data.Details.Add(_mapper.Map<OutStockTaskDetails>(e));
erp_removeList.Add(e);
}
//2.2.提交修改
var isSuccess = await _outStockTaskRepositories.EditEntityList(data_list, isTransaction);
if (!isSuccess)
return Result.ReFailure(ResultCodes.DateWriteError);
//2.3剔除:已修改的单据
foreach (var item in erp_removeList)
erp_list.Remove(item);
//3.wms任务单的来源单据编号不存在于erp中那么就新增
if (erp_list.Count != 0)
{
var add_entitys = new List<OutStockTask>();
var billNos = erp_list.GroupBy(x => x.SourceBillNo).Select(x => x.Key).ToList();
foreach (var item in billNos)
{
var e = erp_list.FirstOrDefault(f => f.SourceBillNo == item);
var dto = new OutStockTask();
dto.SourceBillNo = e.SourceBillNo;
dto.Create((OutStockType)e.Type, e.SourceBillNo, e.DeliveryOrgId, e.ReceiptCustomerId, (DateTime)e.CreateTime);
//找到当前对应来源单据编号的集合数据
var current_erp_details = erp_list.Where(x => x.SourceBillNo == item).ToList();
//给到dto的实体明细中
dto.Details = _mapper.Map<List<OutStockTaskDetails>>(current_erp_details);
add_entitys.Add(dto);
}
//3.1提交新增
isSuccess = await _outStockTaskRepositories.AddRange(add_entitys, isTransaction);
if (!isSuccess)
return Result.ReFailure(ResultCodes.DateWriteError);
}
}
return Result.ReSuccess();
}
/// <summary>
/// 发货通知单同步数据
/// </summary>
/// <param name="isTransaction"></param>
/// <returns></returns>
public async Task<Result> SsynDeliveryNoticeOutStock(bool isTransaction)
public async Task<Result> SsynDeliveryNoticeOutStock(bool isTransaction, List<string> sourceBillNos = null)
{
//1.获取金蝶数据:采购订单数据
var erp_result = await _erpService.BillQueryForPurchaseInStock();
var erp_result = await _erpService.BillQueryForDeliveryNoticeOutStock(sourceBillNos);
if (!erp_result.IsSuccess)
return Result.ReFailure(erp_result.Message, erp_result.Status);
var erp_list = erp_result.Data;
return Result.ReSuccess();
return await this.SsynDate(erp_result.Data.ToList(), isTransaction);
}
/// <summary>
/// 直接调拨
/// </summary>
/// <param name="isTransaction"></param>
/// <param name="sourceBillNos"></param>
/// <returns></returns>
public async Task<Result> BillQueryForTransferDirectOutStock(bool isTransaction, List<string> sourceBillNos = null)
{
var erp_result = await _erpService.BillQueryForTransferDirectOutStock(sourceBillNos);
if (!erp_result.IsSuccess)
return Result.ReFailure(erp_result.Message, erp_result.Status);
return await this.SsynDate(erp_result.Data.ToList(), isTransaction);
}
/// <summary>
/// 分布式调出
/// </summary>
/// <param name="isTransaction"></param>
/// <param name="sourceBillNos"></param>
/// <returns></returns>
public async Task<Result> BillQueryForTransferOutOutStock(bool isTransaction, List<string> sourceBillNos = null)
{
var erp_result = await _erpService.BillQueryForTransferOutOutStock(sourceBillNos);
if (!erp_result.IsSuccess)
return Result.ReFailure(erp_result.Message, erp_result.Status);
return await this.SsynDate(erp_result.Data.ToList(), isTransaction);
}
/// <summary>
/// 组装拆卸单
/// </summary>
/// <param name="isTransaction"></param>
/// <param name="sourceBillNos"></param>
/// <returns></returns>
public async Task<Result> BillQueryForAssembledAppOutStock(bool isTransaction, List<string> sourceBillNos = null)
{
List<ErpDeliveryNoticeOutStockResultDto> list = new List<ErpDeliveryNoticeOutStockResultDto>();
var erp_result = await _erpService.BillQueryForAssembledAppOutStock_Dassembly(sourceBillNos);
if (!erp_result.IsSuccess)
return Result.ReFailure(erp_result.Message, erp_result.Status);
list.AddRange(erp_result.Data);
var erp_result_a = await _erpService.BillQueryForAssembledAppOutStock_Assembly(sourceBillNos);
if (!erp_result_a.IsSuccess)
return Result.ReFailure(erp_result_a.Message, erp_result_a.Status);
list.AddRange(erp_result_a.Data);
return await this.SsynDate(list, isTransaction);
}
/// <summary>
/// 其他入库单
/// </summary>
/// <param name="isTransaction"></param>
/// <param name="sourceBillNos"></param>
/// <returns></returns>
public async Task<Result> BillQueryForMisDeliveryOutStock(bool isTransaction, List<string> sourceBillNos = null)
{
var erp_result = await _erpService.BillQueryForMisDeliveryOutStock(sourceBillNos);
if (!erp_result.IsSuccess)
return Result.ReFailure(erp_result.Message, erp_result.Status);
return await this.SsynDate(erp_result.Data.ToList(), isTransaction);
}
}
}

View File

@@ -360,6 +360,7 @@ namespace WMS.Web.Domain.Services.Public
return Result.ReSuccess();
}
#region
public async Task<ResultList<ErpDeliveryNoticeOutStockResultDto>> BillQueryForDeliveryNoticeOutStock(List<string> sourceBillNos = null)
{
try
@@ -376,7 +377,7 @@ namespace WMS.Web.Domain.Services.Public
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(token_result);
//2.时间条件:可能还有其它条件
var beginTime = DateTime.Now.AddDays(-2000).ToString("yyyy-MM-dd 00:00:00");
var beginTime = DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd 00:00:00");
var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
//3.获取金蝶采购订单:拼接参数和条件
var query = new ErpBillQueryDto(token_result.Data);
@@ -421,6 +422,7 @@ namespace WMS.Web.Domain.Services.Public
lis.AccruedQty = Convert.ToDecimal(item[7]);
lis.Remark = item[8];
lis.CreateTime = Convert.ToDateTime(item[9]);
lis.Type = (int)OutStockType.Sal;
erp_list.Add(lis);
}
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReSuccess(erp_list);
@@ -430,5 +432,386 @@ namespace WMS.Web.Domain.Services.Public
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(ResultCodes.Erp_BillQuery_Error);
}
}
/// <summary>
/// 直接调拨出库
/// </summary>
/// <param name="sourceBillNos"></param>
/// <returns></returns>
public async Task<ResultList<ErpDeliveryNoticeOutStockResultDto>> BillQueryForTransferDirectOutStock(List<string> sourceBillNos = null)
{
try
{
var stocks = await _basicsRepositories.GetUcStockAsync(ManagementSystemCode.GLXT0004.ToString(), "", _appOptions.CompanyId);
if (stocks.Count == 0)
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(ResultCodes.ErpStockNoData);
var stocks_codes = stocks.Select(x => x.Id).ToList();
//1.先登录金蝶-拿到token
var token_result = await this.Init();
if (!token_result.IsSuccess)
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(token_result);
//2.时间条件:可能还有其它条件
var beginTime = DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd 00:00:00");
var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
//3.获取金蝶采购订单:拼接参数和条件
var query = new ErpBillQueryDto(token_result.Data);
var param = new ErpBillQueryParamDto(FormIdParam.STK_TransferDirect.ToString());
param.FieldKeys = "FBillNo,'',FStockOutOrgId,FStockOrgId,FMaterialID,FSrcStockId,FSrcStockLocId,FQty,FNoteEntry,FCreateDate";
param.Limit = 10;
//查询条件:备注其中的条件值以金蝶的值为准!!!
//1.创建时间在两天前和当天时间之间
//2.审核状态:已审核
//3.未出库数量>0
//4.日期>=系统上线之日
//5.仓库wms系统的仓库值---现在这个没有加,因为还单点没有和金蝶同步
param.FilterString = "FCreateDate>='" + beginTime + "' and FCreateDate<='" + endTime + "' and FDocumentStatus='C'";
//string srt = JsonConvert.SerializeObject(stocks_codes);
//param.FilterString = param.FilterString + " and FSrcStockId in (" + srt.Substring(1, srt.Length - 2) + ")";
//根据原订单号查询
if (sourceBillNos != null && sourceBillNos.Count() > 0)
{
var srt_b = JsonConvert.SerializeObject(sourceBillNos);
param.FilterString = param.FilterString + " and FBillNo in (" + srt_b.Substring(1, srt_b.Length - 2) + ")";
}
query.Data = JsonConvert.SerializeObject(param);
var json = JsonConvert.SerializeObject(query);
//4.请求查询接口
var result_json = await _client.ExecuteBillQueryAsync(json);
var result = JsonConvert.DeserializeObject<List<List<string>>>(result_json);
//5.返回数据的组装
var erp_list = new List<ErpDeliveryNoticeOutStockResultDto>();
foreach (var item in result)
{
var lis = new ErpDeliveryNoticeOutStockResultDto();
lis.SourceBillNo = item[0];
lis.SaleBillNo = item[1];
lis.DeliveryOrgId = Convert.ToInt32(item[2]);
lis.ReceiptCustomerId = Convert.ToInt32(item[3]);
lis.MaterialId = Convert.ToInt32(item[4]);
lis.StockId = Convert.ToInt32(item[5]);
lis.SubStockId = Convert.ToInt32(item[6]);
lis.AccruedQty = Convert.ToDecimal(item[7]);
lis.Remark = item[8];
lis.CreateTime = Convert.ToDateTime(item[9]);
lis.Type = (int)OutStockType.Stkdirecttransfers;
erp_list.Add(lis);
}
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReSuccess(erp_list);
}
catch (Exception ex)
{
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(ResultCodes.Erp_BillQuery_Error);
}
}
/// <summary>
/// 分布式调出
/// </summary>
/// <param name="sourceBillNos"></param>
/// <returns></returns>
public async Task<ResultList<ErpDeliveryNoticeOutStockResultDto>> BillQueryForTransferOutOutStock(List<string> sourceBillNos = null)
{
try
{
var stocks = await _basicsRepositories.GetUcStockAsync(ManagementSystemCode.GLXT0004.ToString(), "", _appOptions.CompanyId);
if (stocks.Count == 0)
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(ResultCodes.ErpStockNoData);
var stocks_codes = stocks.Select(x => x.Id).ToList();
//1.先登录金蝶-拿到token
var token_result = await this.Init();
if (!token_result.IsSuccess)
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(token_result);
//2.时间条件:可能还有其它条件
var beginTime = DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd 00:00:00");
var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
//3.获取金蝶采购订单:拼接参数和条件
var query = new ErpBillQueryDto(token_result.Data);
var param = new ErpBillQueryParamDto(FormIdParam.STK_TRANSFEROUT.ToString());
param.FieldKeys = "FBillNo,'',FStockOrgID,FStockInOrgID,FMaterialID,FSrcStockID,FSrcStockLocId,FQty,FEntryNote,FCreateDate";
param.Limit = 10;
//查询条件:备注其中的条件值以金蝶的值为准!!!
//1.创建时间在两天前和当天时间之间
//2.审核状态:已审核
//3.未出库数量>0
//4.日期>=系统上线之日
//5.仓库wms系统的仓库值---现在这个没有加,因为还单点没有和金蝶同步
param.FilterString = "FCreateDate>='" + beginTime + "' and FCreateDate<='" + endTime + "' and FDocumentStatus='C'";
//string srt = JsonConvert.SerializeObject(stocks_codes);
//param.FilterString = param.FilterString + " and FSrcStockID in (" + srt.Substring(1, srt.Length - 2) + ")";
//根据原订单号查询
if (sourceBillNos != null && sourceBillNos.Count() > 0)
{
var srt_b = JsonConvert.SerializeObject(sourceBillNos);
param.FilterString = param.FilterString + " and FBillNo in (" + srt_b.Substring(1, srt_b.Length - 2) + ")";
}
query.Data = JsonConvert.SerializeObject(param);
var json = JsonConvert.SerializeObject(query);
//4.请求查询接口
var result_json = await _client.ExecuteBillQueryAsync(json);
var result = JsonConvert.DeserializeObject<List<List<string>>>(result_json);
//5.返回数据的组装
var erp_list = new List<ErpDeliveryNoticeOutStockResultDto>();
foreach (var item in result)
{
var lis = new ErpDeliveryNoticeOutStockResultDto();
lis.SourceBillNo = item[0];
lis.SaleBillNo = item[1];
lis.DeliveryOrgId = Convert.ToInt32(item[2]);
lis.ReceiptCustomerId = Convert.ToInt32(item[3]);
lis.MaterialId = Convert.ToInt32(item[4]);
lis.StockId = Convert.ToInt32(item[5]);
lis.SubStockId = Convert.ToInt32(item[6]);
lis.AccruedQty = Convert.ToDecimal(item[7]);
lis.Remark = item[8];
lis.CreateTime = Convert.ToDateTime(item[9]);
lis.Type = (int)OutStockType.StktransferInst;
erp_list.Add(lis);
}
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReSuccess(erp_list);
}
catch (Exception ex)
{
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(ResultCodes.Erp_BillQuery_Error);
}
}
/// <summary>
/// 组装拆卸单 (拆卸 主出)
/// </summary>
/// <param name="sourceBillNos"></param>
/// <returns></returns>
public async Task<ResultList<ErpDeliveryNoticeOutStockResultDto>> BillQueryForAssembledAppOutStock_Dassembly(List<string> sourceBillNos = null)
{
try
{
var stocks = await _basicsRepositories.GetUcStockAsync(ManagementSystemCode.GLXT0004.ToString(), "", _appOptions.CompanyId);
if (stocks.Count == 0)
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(ResultCodes.ErpStockNoData);
var stocks_codes = stocks.Select(x => x.Id).ToList();
//1.先登录金蝶-拿到token
var token_result = await this.Init();
if (!token_result.IsSuccess)
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(token_result);
//2.时间条件:可能还有其它条件
var beginTime = DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd 00:00:00");
var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
//3.获取金蝶采购订单:拼接参数和条件
var query = new ErpBillQueryDto(token_result.Data);
var param = new ErpBillQueryParamDto(FormIdParam.STK_AssembledApp.ToString());
param.FieldKeys = "FBillNo,'','0','0',FMaterialID,FStockID,FStockLocId,FQty,FDescription,FCreateDate";
param.Limit = 10;
//查询条件:备注其中的条件值以金蝶的值为准!!!
//1.创建时间在两天前和当天时间之间
//2.审核状态:已审核
//3.未出库数量>0
//4.日期>=系统上线之日
//5.仓库wms系统的仓库值---现在这个没有加,因为还单点没有和金蝶同步 FBillTypeID
param.FilterString = "FCreateDate>='" + beginTime + "' and FCreateDate<='" + endTime + "' and FDocumentStatus='C' and FAffairType='Dassembly'";
//string srt = JsonConvert.SerializeObject(stocks_codes);
//param.FilterString = param.FilterString + " and FSrcStockID in (" + srt.Substring(1, srt.Length - 2) + ")";
//根据原订单号查询
if (sourceBillNos != null && sourceBillNos.Count() > 0)
{
var srt_b = JsonConvert.SerializeObject(sourceBillNos);
param.FilterString = param.FilterString + " and FBillNo in (" + srt_b.Substring(1, srt_b.Length - 2) + ")";
}
query.Data = JsonConvert.SerializeObject(param);
var json = JsonConvert.SerializeObject(query);
//4.请求查询接口
var result_json = await _client.ExecuteBillQueryAsync(json);
var result = JsonConvert.DeserializeObject<List<List<string>>>(result_json);
//5.返回数据的组装
var erp_list = new List<ErpDeliveryNoticeOutStockResultDto>();
foreach (var item in result)
{
var lis = new ErpDeliveryNoticeOutStockResultDto();
lis.SourceBillNo = item[0];
lis.SaleBillNo = item[1];
lis.DeliveryOrgId = Convert.ToInt32(item[2]);
lis.ReceiptCustomerId = Convert.ToInt32(item[3]);
lis.MaterialId = Convert.ToInt32(item[4]);
lis.StockId = Convert.ToInt32(item[5]);
lis.SubStockId = Convert.ToInt32(item[6]);
lis.AccruedQty = Convert.ToDecimal(item[7]);
lis.Remark = item[8];
lis.CreateTime = Convert.ToDateTime(item[9]);
lis.Type = (int)OutStockType.Assembled;
erp_list.Add(lis);
}
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReSuccess(erp_list);
}
catch (Exception ex)
{
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(ResultCodes.Erp_BillQuery_Error);
}
}
/// <summary>
/// 其他出库
/// </summary>
/// <param name="sourceBillNos"></param>
/// <returns></returns>
public async Task<ResultList<ErpDeliveryNoticeOutStockResultDto>> BillQueryForMisDeliveryOutStock(List<string> sourceBillNos = null)
{
try
{
var stocks = await _basicsRepositories.GetUcStockAsync(ManagementSystemCode.GLXT0004.ToString(), "", _appOptions.CompanyId);
if (stocks.Count == 0)
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(ResultCodes.ErpStockNoData);
var stocks_codes = stocks.Select(x => x.Id).ToList();
//1.先登录金蝶-拿到token
var token_result = await this.Init();
if (!token_result.IsSuccess)
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(token_result);
//2.时间条件:可能还有其它条件
var beginTime = DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd 00:00:00");
var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
//3.获取金蝶采购订单:拼接参数和条件
var query = new ErpBillQueryDto(token_result.Data);
var param = new ErpBillQueryParamDto(FormIdParam.STK_MisDelivery.ToString());
param.FieldKeys = "FBillNo,'',FStockOrgId,FPickOrgId,FMaterialId,FStockId,FStockLocId ,FQty,FEntryNote,FCreateDate";
param.Limit = 10;
//查询条件:备注其中的条件值以金蝶的值为准!!!
//1.创建时间在两天前和当天时间之间
//2.审核状态:已审核
//3.未出库数量>0
//4.日期>=系统上线之日
//5.仓库wms系统的仓库值---现在这个没有加,因为还单点没有和金蝶同步
param.FilterString = "FCreateDate>='" + beginTime + "' and FCreateDate<='" + endTime + "' and FDocumentStatus='C'";
//string srt = JsonConvert.SerializeObject(stocks_codes);
//param.FilterString = param.FilterString + " and FSrcStockID in (" + srt.Substring(1, srt.Length - 2) + ")";
//根据原订单号查询
if (sourceBillNos != null && sourceBillNos.Count() > 0)
{
var srt_b = JsonConvert.SerializeObject(sourceBillNos);
param.FilterString = param.FilterString + " and FBillNo in (" + srt_b.Substring(1, srt_b.Length - 2) + ")";
}
query.Data = JsonConvert.SerializeObject(param);
var json = JsonConvert.SerializeObject(query);
//4.请求查询接口
var result_json = await _client.ExecuteBillQueryAsync(json);
var result = JsonConvert.DeserializeObject<List<List<string>>>(result_json);
//5.返回数据的组装
var erp_list = new List<ErpDeliveryNoticeOutStockResultDto>();
foreach (var item in result)
{
var lis = new ErpDeliveryNoticeOutStockResultDto();
lis.SourceBillNo = item[0];
lis.SaleBillNo = item[1];
lis.DeliveryOrgId = Convert.ToInt32(item[2]);
lis.ReceiptCustomerId = Convert.ToInt32(item[3]);
lis.MaterialId = Convert.ToInt32(item[4]);
lis.StockId = Convert.ToInt32(item[5]);
lis.SubStockId = Convert.ToInt32(item[6]);
lis.AccruedQty = Convert.ToDecimal(item[7]);
lis.Remark = item[8];
lis.CreateTime = Convert.ToDateTime(item[9]);
lis.Type = (int)OutStockType.Miscellaneous;
erp_list.Add(lis);
}
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReSuccess(erp_list);
}
catch (Exception ex)
{
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(ResultCodes.Erp_BillQuery_Error);
}
}
/// <summary>
/// 组装拆卸单 (组装 子出)
/// </summary>
/// <param name="sourceBillNos"></param>
/// <returns></returns>
public async Task<ResultList<ErpDeliveryNoticeOutStockResultDto>> BillQueryForAssembledAppOutStock_Assembly(List<string> sourceBillNos = null)
{
try
{
var stocks = await _basicsRepositories.GetUcStockAsync(ManagementSystemCode.GLXT0004.ToString(), "", _appOptions.CompanyId);
if (stocks.Count == 0)
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(ResultCodes.ErpStockNoData);
var stocks_codes = stocks.Select(x => x.Id).ToList();
//1.先登录金蝶-拿到token
var token_result = await this.Init();
if (!token_result.IsSuccess)
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(token_result);
//2.时间条件:可能还有其它条件
var beginTime = DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd 00:00:00");
var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
//3.获取金蝶采购订单:拼接参数和条件
var query = new ErpBillQueryDto(token_result.Data);
var param = new ErpBillQueryParamDto(FormIdParam.STK_AssembledApp.ToString());
param.FieldKeys = "FBillNo,'',FSubProOwnerIdH,FOwnerIdHead,FMaterialIDSETY,FStockIDSETY,FStockLocIdSETY,FQtySETY,FDescriptionSETY,FCreateDate";
param.Limit = 10;
//查询条件:备注其中的条件值以金蝶的值为准!!!
//1.创建时间在两天前和当天时间之间
//2.审核状态:已审核
//3.未出库数量>0
//4.日期>=系统上线之日
//5.仓库wms系统的仓库值---现在这个没有加,因为还单点没有和金蝶同步 FBillTypeID
param.FilterString = "FCreateDate>='" + beginTime + "' and FCreateDate<='" + endTime + "' and FDocumentStatus='C' and FAffairType='Assembly'";
//string srt = JsonConvert.SerializeObject(stocks_codes);
//param.FilterString = param.FilterString + " and FSrcStockID in (" + srt.Substring(1, srt.Length - 2) + ")";
//根据原订单号查询
if (sourceBillNos != null && sourceBillNos.Count() > 0)
{
var srt_b = JsonConvert.SerializeObject(sourceBillNos);
param.FilterString = param.FilterString + " and FBillNo in (" + srt_b.Substring(1, srt_b.Length - 2) + ")";
}
query.Data = JsonConvert.SerializeObject(param);
var json = JsonConvert.SerializeObject(query);
//4.请求查询接口
var result_json = await _client.ExecuteBillQueryAsync(json);
var result = JsonConvert.DeserializeObject<List<List<string>>>(result_json);
//5.返回数据的组装
var erp_list = new List<ErpDeliveryNoticeOutStockResultDto>();
foreach (var item in result)
{
var lis = new ErpDeliveryNoticeOutStockResultDto();
lis.SourceBillNo = item[0];
lis.SaleBillNo = item[1];
lis.DeliveryOrgId = Convert.ToInt32(item[2]);
lis.ReceiptCustomerId = Convert.ToInt32(item[3]);
lis.MaterialId = Convert.ToInt32(item[4]);
lis.StockId = Convert.ToInt32(item[5]);
lis.SubStockId = Convert.ToInt32(item[6]);
lis.AccruedQty = Convert.ToDecimal(item[7]);
lis.Remark = item[8];
lis.CreateTime = Convert.ToDateTime(item[9]);
lis.Type = (int)OutStockType.Assembled;
erp_list.Add(lis);
}
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReSuccess(erp_list);
}
catch (Exception ex)
{
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(ResultCodes.Erp_BillQuery_Error);
}
}
#endregion
}
}