erp调整
This commit is contained in:
@@ -56,15 +56,16 @@ namespace WMS.Web.Api.Controllers
|
||||
[Route("hj")]
|
||||
public async Task<string> TestHJ()
|
||||
{
|
||||
OperateRequest dto = new OperateRequest();
|
||||
dto.Ids.Add(65);
|
||||
await _outStockService.Sync(dto, null);
|
||||
// List<ErpCustomerDto> list = null;
|
||||
//var b= list.FirstOrDefault(f => f.Id == 123);
|
||||
//var entity=await _takeStockRepositories.GetEntityList(new List<int>() {2 });
|
||||
//var r= await _takeStockService.Loss_Profit(entity.First());
|
||||
//var list = await GetList();
|
||||
//var c = await _erpService.BillQueryForAssembledAppOutStock_Assembly(new List<string>() { "ZZCX003061" }, DateTime.Now.AddDays(-10));
|
||||
// OperateRequest dto = new OperateRequest();
|
||||
// dto.Ids.Add(65);
|
||||
//await _outStockService.Sync(dto, null);
|
||||
// List<ErpCustomerDto> list = null;
|
||||
//var b= list.FirstOrDefault(f => f.Id == 123);
|
||||
//var entity=await _takeStockRepositories.GetEntityList(new List<int>() {2 });
|
||||
//var r= await _takeStockService.Loss_Profit(entity.First());
|
||||
//var list = await GetList();
|
||||
var c = await _erpService.BillQueryForSalOutStock("12709885");
|
||||
//var c = await _erpService.BillQueryForAssembledAppOutStock_Assembly(new List<string>() { "ZZCX003061" }, DateTime.Now.AddDays(-10));
|
||||
//var bc2 = await _erpService.BillQueryForDeliveryNoticeOutStock(new List<string>() { "FHTZD8022232" }, DateTime.Now.AddDays(-10));
|
||||
//var bc = await _erpService.BillQueryForTransferOutOutStock(null, DateTime.Now.AddDays(-10));
|
||||
//var b=await _erpService.BillQueryForAssembledAppOutStock_Assembly(null, DateTime.Now.AddDays(-1));
|
||||
|
||||
@@ -765,11 +765,6 @@
|
||||
业务对象表单Id(必录)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.Erp.ErpPushDto.Numbers">
|
||||
<summary>
|
||||
业务对象表单Id(必录)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.Erp.ErpPushDto.DetailsId">
|
||||
<summary>
|
||||
分录内码集合,逗号分隔(分录下推时必录) 注(按分录下推时,单据内码和编码不需要填,否则按整单下推)
|
||||
@@ -783,7 +778,12 @@
|
||||
<member name="P:WMS.Web.Core.Dto.Erp.ErpPushDto.IsEnableDefaultRule">
|
||||
<summary>
|
||||
是否启用默认转换规则,布尔类型,默认false(非必录)
|
||||
开启后则不需要填 RuleId
|
||||
false 需要穿 RuleId true 不需要传RuleId
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.Erp.ErpPushDto.RuleId">
|
||||
<summary>
|
||||
转换规则内码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Core.Dto.Erp.ErpSave`1">
|
||||
|
||||
@@ -12,10 +12,10 @@ namespace WMS.Web.Core.Dto.Erp
|
||||
{
|
||||
public ErpPushDto() { }
|
||||
|
||||
public ErpPushDto(string formId,string number,List<int> detailIds,string targetFormId)
|
||||
public ErpPushDto(string formId,List<int> detailIds,string targetFormId)
|
||||
{
|
||||
this.FormId = formId;
|
||||
this.Numbers.Add(number);
|
||||
//this.Numbers.Add(number);
|
||||
this.DetailsId = detailIds.ToString();
|
||||
this.TargetFormId = targetFormId;
|
||||
}
|
||||
@@ -25,11 +25,11 @@ namespace WMS.Web.Core.Dto.Erp
|
||||
/// </summary>
|
||||
[JsonProperty("FormId")]
|
||||
public string FormId { get; set; }
|
||||
/// <summary>
|
||||
/// 业务对象表单Id(必录)
|
||||
/// </summary>
|
||||
[JsonProperty("Numbers")]
|
||||
public List<string> Numbers { get; set; }
|
||||
///// <summary>
|
||||
///// 业务对象表单Id(必录)
|
||||
///// </summary>
|
||||
//[JsonProperty("Numbers")]
|
||||
//public List<string> Numbers { get; set; }
|
||||
/// <summary>
|
||||
/// 分录内码集合,逗号分隔(分录下推时必录) 注(按分录下推时,单据内码和编码不需要填,否则按整单下推)
|
||||
/// </summary>
|
||||
@@ -42,10 +42,15 @@ namespace WMS.Web.Core.Dto.Erp
|
||||
public string TargetFormId { get; set; }
|
||||
/// <summary>
|
||||
/// 是否启用默认转换规则,布尔类型,默认false(非必录)
|
||||
/// 开启后则不需要填 RuleId
|
||||
/// false 需要穿 RuleId true 不需要传RuleId
|
||||
/// </summary>
|
||||
[JsonProperty("IsEnableDefaultRule")]
|
||||
public bool IsEnableDefaultRule { get; set; } = true;
|
||||
|
||||
public bool IsEnableDefaultRule { get; set; } = false;
|
||||
/// <summary>
|
||||
/// 转换规则内码
|
||||
/// </summary>
|
||||
[JsonProperty("RuleId")]
|
||||
public string RuleId { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,6 +91,8 @@ namespace WMS.Web.Domain.IService.Public
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<ResultList<ErpDeliveryNoticeOutStockResultDto>> BillQueryForMisDeliveryOutStock(List<string> sourceBillNos = null, DateTime? beginTime = null);
|
||||
|
||||
Task<ResultList<ErpDeliveryNoticeOutStockResultDto>> BillQueryForSalOutStock(string id);
|
||||
/// <summary>
|
||||
/// erp:单据查询-物料集合
|
||||
/// </summary>
|
||||
@@ -141,6 +143,6 @@ namespace WMS.Web.Domain.IService.Public
|
||||
//删除
|
||||
Task<Result> Delete(ErpOperateDto dto, string formId);
|
||||
//下推
|
||||
Task<Result> Push(ErpPushDto dto);
|
||||
Task<Result<string>> Push(ErpPushDto dto);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,17 +228,18 @@ namespace WMS.Web.Domain.Services
|
||||
var erp_details = entity.Details.SelectMany(s => s.ErpDetails).Select(s => s.Erp_DetailId).ToList();
|
||||
var erpDto = new ErpPushDto()
|
||||
{
|
||||
RuleId = "DeliveryNotice-OutStock",//转换规则内码 发货通知单下推销售出库单
|
||||
FormId = FormIdParam.SAL_DELIVERYNOTICE.ToString(),
|
||||
Numbers = new List<string>() { s },
|
||||
//Numbers = new List<string>() { s },
|
||||
TargetFormId = FormIdParam.SAL_OUTSTOCK.ToString(),
|
||||
DetailsId = string.Join(",", erp_details)
|
||||
};
|
||||
//下推金蝶
|
||||
var res = await this.Push(erpDto);
|
||||
if (res.IsSuccess)
|
||||
entity.SyncSuccess(s, loginInfo.UserInfo.StaffId);
|
||||
entity.SyncSuccess(s, loginInfo?.UserInfo?.StaffId ?? 0);
|
||||
else
|
||||
entity.SyncFail(res.Message, loginInfo.UserInfo.StaffId, SyncStatus.Fail);
|
||||
entity.SyncFail(res.Message, loginInfo?.UserInfo?.StaffId ?? 0, SyncStatus.Fail);
|
||||
}
|
||||
//entity.SuccessSync = entity.SuccessSyncFail.Count() > 0 ? false : true;
|
||||
//最好一条一条执行,否则执行失败 但是金蝶那边又同步成功 就会造成数据比价乱
|
||||
@@ -255,6 +256,8 @@ namespace WMS.Web.Domain.Services
|
||||
private async Task<Result> Push(ErpPushDto dto)
|
||||
{
|
||||
var res = await _erpService.Push(dto);
|
||||
var id = res.Data;
|
||||
//{"Id":12709885,"Number":"XSCKD10629570","DIndex":0}
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1461,24 +1461,36 @@ namespace WMS.Web.Domain.Services.Public
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> Push(ErpPushDto dto)
|
||||
public async Task<Result<string>> Push(ErpPushDto dto)
|
||||
{
|
||||
var token_result = await this.Init();
|
||||
if (!token_result.IsSuccess)
|
||||
return token_result;
|
||||
var query = new ErpBillQueryDto(token_result.Data, dto.FormId);
|
||||
query.Data = JsonConvert.SerializeObject(dto);
|
||||
//下推
|
||||
var result_json = await _client.PushAsync(JsonConvert.SerializeObject(query));
|
||||
try
|
||||
{
|
||||
var token_result = await this.Init();
|
||||
if (!token_result.IsSuccess)
|
||||
return token_result;
|
||||
var query = new ErpBillQueryDto(token_result.Data, dto.FormId);
|
||||
query.Data = JsonConvert.SerializeObject(dto);
|
||||
//下推
|
||||
string json = JsonConvert.SerializeObject(query);
|
||||
var result_json = await _client.PushAsync(json);
|
||||
|
||||
JObject jobject = (JObject)JsonConvert.DeserializeObject(result_json);
|
||||
var isSuccess = jobject["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToLower();
|
||||
JObject jobject = (JObject)JsonConvert.DeserializeObject(result_json);
|
||||
var isSuccess = jobject["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToLower();
|
||||
|
||||
if (jobject["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToLower() == "true")
|
||||
return Result.ReSuccess();
|
||||
if (jobject["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToLower() == "true")
|
||||
{
|
||||
//保存成功后返回Id 后续操作根据Id操作
|
||||
string id = jobject["Result"]["ResponseStatus"]["SuccessEntitys"][0]["Id"].ToString();
|
||||
return Result<string>.ReSuccess(id);
|
||||
}
|
||||
|
||||
var msg = jobject["Result"]["ResponseStatus"]["Errors"][0]["Message"].ToString();
|
||||
return Result.ReFailure(msg, 10002);
|
||||
var msg = jobject["Result"]["ResponseStatus"]["Errors"][0]["Message"].ToString();
|
||||
return Result<string>.ReFailure(msg, 10002);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Result<string>.ReFailure(ex.ToString(), 10002);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -2038,6 +2050,62 @@ namespace WMS.Web.Domain.Services.Public
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ResultList<ErpDeliveryNoticeOutStockResultDto>> BillQueryForSalOutStock(string id)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var stocks = await _basicsRepositories.GetUcStockAsync(ManagementSystemCode.GLXT0004.ToString(), "", _appOptions.CompanyId);
|
||||
if (stocks.Count == 0)
|
||||
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(ResultCodes.ErpStockNoData);
|
||||
//1.先登录金蝶-拿到token
|
||||
var token_result = await this.Init();
|
||||
if (!token_result.IsSuccess)
|
||||
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(token_result);
|
||||
|
||||
|
||||
//3.获取金蝶采购订单:拼接参数和条件
|
||||
var query = new ErpBillQueryDto(token_result.Data);
|
||||
var param = new ErpBillQueryParamDto(FormIdParam.SAL_OUTSTOCK.ToString());
|
||||
param.FieldKeys = "FID,FEntity_FENTRYID,FMaterialID,FMustQty,FRealQty,FStockID.FNumber";
|
||||
param.Limit = 10000;
|
||||
param.FilterString = $"FID={id}";
|
||||
|
||||
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.StockCode = 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;
|
||||
// lis.Erp_DetailId = Convert.ToInt32(item[10]);
|
||||
// lis.OrgCode = item[11];
|
||||
// erp_list.Add(lis);
|
||||
//}
|
||||
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReSuccess(erp_list);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(ResultCodes.Erp_BillQuery_Error);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,7 +235,8 @@ namespace WMS.Web.Repositories
|
||||
public async Task<List<OutStock>> GetEntityList(List<int> ids)
|
||||
{
|
||||
var res = await _context.OutStock
|
||||
.Include(s => s.Details).ThenInclude(s => s.ErpDetails)
|
||||
.Include(s => s.Details)
|
||||
.ThenInclude(s => s.ErpDetails)
|
||||
.Where(f => ids.Contains(f.Id))
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user