This commit is contained in:
余宇波 2025-07-03 20:00:21 +08:00
parent b8c92f9ee5
commit 6ffade6e6d
4 changed files with 170 additions and 5 deletions

View File

@ -0,0 +1,100 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyCode.Project.Domain.Message.Response.KingDee
{
public class ErrorResponse
{
/// <summary>
///
/// </summary>
public Result Result { get; set; }
}
public class ErrorsItem
{
/// <summary>
///
/// </summary>
public string FieldName { get; set; }
/// <summary>
/// 报错内容
/// </summary>
public string Message { get; set; }
/// <summary>
///
/// </summary>
public int DIndex { get; set; }
}
public class ResponseStatus
{
/// <summary>
///
/// </summary>
public int ErrorCode { get; set; }
/// <summary>
///
/// </summary>
public string IsSuccess { get; set; }
/// <summary>
///
/// </summary>
public List<ErrorsItem> Errors { get; set; }
/// <summary>
///
/// </summary>
public List<string> SuccessEntitys { get; set; }
/// <summary>
///
/// </summary>
public List<string> SuccessMessages { get; set; }
/// <summary>
///
/// </summary>
public int MsgCode { get; set; }
}
public class ConvertResponseStatus
{
/// <summary>
///
/// </summary>
public string IsSuccess { get; set; }
/// <summary>
///
/// </summary>
public List<string> Errors { get; set; }
/// <summary>
///
/// </summary>
public List<string> SuccessEntitys { get; set; }
/// <summary>
///
/// </summary>
public List<string> SuccessMessages { get; set; }
/// <summary>
///
/// </summary>
public int MsgCode { get; set; }
}
public class Result
{
/// <summary>
///
/// </summary>
public ResponseStatus ResponseStatus { get; set; }
/// <summary>
///
/// </summary>
public ConvertResponseStatus ConvertResponseStatus { get; set; }
}
}

View File

@ -144,6 +144,7 @@
<Compile Include="Message\Response\EnterpriseWechat\WechatSysParameter.cs" />
<Compile Include="Message\Response\InvoiceOrder\InvoiceOrderPageList.cs" />
<Compile Include="Message\Response\InvoiceOrder\TiaoMaResp.cs" />
<Compile Include="Message\Response\KingDee\ErrorResponse.cs" />
<Compile Include="Message\Response\PurchaseOrder\KingDeePurchaseOrderRespon.cs" />
<Compile Include="Message\Response\PurchaseOrder\PurchaseOrderPageList.cs" />
<Compile Include="Message\Response\User\AccountPageList.cs" />

View File

@ -3,6 +3,7 @@ using Kingdee.CDP.WebApi.SDK.DataEntify;
using MyCode.Project.Domain.Config;
using MyCode.Project.Domain.Message.Act.PurchaseOrder;
using MyCode.Project.Domain.Message.Request.KingDee;
using MyCode.Project.Domain.Message.Response.KingDee;
using MyCode.Project.Infrastructure.Common;
using MyCode.Project.Infrastructure.Exceptions;
using MyCode.Project.Infrastructure.WebPost;
@ -161,7 +162,19 @@ namespace MyCode.Project.OutSideService.Implementation
{
LogHelper.Error("金蝶云接口调用失败,请检查");
LogHelper.Error(resultString);
throw new Exception("单据在云星空已锁定,请联系采购员");
string Message = "";
try
{
ErrorResponse errorResponse = JsonHelper.ToObject<ErrorResponse>(resultString);
Message = string.Join(",", errorResponse.Result.ResponseStatus.Errors.Select(t => t.Message).ToList());
}
catch (Exception ex)
{
string ds = ex.Message;
throw new Exception("2云星空接口调用失败请联系管理员,错误信息:" + resultString);
}
throw new Exception("1云星空接口调用失败请联系管理员,错误信息:" + Message);
}
//List<dynamic> result = JsonSerializer.Deserialize<List<dynamic>>(resultString);
//var total = this.GetTotal(queryParam);
@ -187,7 +200,20 @@ namespace MyCode.Project.OutSideService.Implementation
{
LogHelper.Error("金蝶云接口调用失败,请检查");
LogHelper.Error(resultString);
throw new Exception("单据在云星空已锁定,请联系采购员");
//throw new Exception("单据在云星空已锁定,请联系采购员");
string Message = "";
try
{
ErrorResponse errorResponse = JsonHelper.ToObject<ErrorResponse>(resultString);
Message = string.Join(",", errorResponse.Result.ResponseStatus.Errors.Select(t => t.Message).ToList());
}
catch (Exception ex)
{
string ds = ex.Message;
throw new Exception("2云星空接口调用失败请联系管理员,错误信息:" + resultString);
}
throw new Exception("1云星空接口调用失败请联系管理员,错误信息:" + Message);
}
var result = JsonHelper.ToObject<Dictionary<string, Dictionary<string, dynamic>>>(resultString);
var data = result["Result"]["ResponseStatus"];
@ -213,7 +239,19 @@ namespace MyCode.Project.OutSideService.Implementation
{
LogHelper.Error("金蝶云接口调用失败,请检查");
LogHelper.Error(resultString);
throw new Exception("单据在云星空已锁定,请联系采购员");
string Message = "";
try
{
ErrorResponse errorResponse = JsonHelper.ToObject<ErrorResponse>(resultString);
Message =string.Join(",", errorResponse.Result.ResponseStatus.Errors.Select(t => t.Message).ToList());
}
catch(Exception ex)
{
string ds = ex.Message;
throw new Exception("2云星空接口调用失败请联系管理员,错误信息:" + resultString);
}
throw new Exception("1云星空接口调用失败请联系管理员,错误信息:" + Message);
}
var result = JsonHelper.ToObject<dynamic>(resultString);
var data = result["Result"]["ResponseStatus"]["SuccessEntitys"];
@ -264,7 +302,19 @@ namespace MyCode.Project.OutSideService.Implementation
{
LogHelper.Error("金蝶云接口调用失败,请检查");
LogHelper.Error(result["msg"]);
throw new BaseException("金蝶云接口调用失败,请检查"+ result["msg"]);
string Message = "";
try
{
ErrorResponse errorResponse = JsonHelper.ToObject<ErrorResponse>(resultString);
Message = string.Join(",", errorResponse.Result.ResponseStatus.Errors.Select(t => t.Message).ToList());
}
catch (Exception ex)
{
string ds = ex.Message;
throw new Exception("2云星空接口调用失败请联系管理员,错误信息:" + resultString);
}
throw new Exception("1云星空接口调用失败请联系管理员,错误信息:" + Message);
}
//if (resultString.Contains("ErrorCode"))
//{
@ -306,7 +356,19 @@ namespace MyCode.Project.OutSideService.Implementation
{
LogHelper.Error("金蝶云接口调用失败,请检查");
LogHelper.Error(resultString);
throw new Exception("单据在云星空已锁定,请联系采购员");
string Message = "";
try
{
ErrorResponse errorResponse = JsonHelper.ToObject<ErrorResponse>(resultString);
Message = string.Join(",", errorResponse.Result.ResponseStatus.Errors.Select(t => t.Message).ToList());
}
catch (Exception ex)
{
string ds = ex.Message;
throw new Exception("2云星空接口调用失败请联系管理员,错误信息:" + resultString);
}
throw new Exception("1云星空接口调用失败请联系管理员,错误信息:" + Message);
}
var result = JsonHelper.ToObject<dynamic>(resultString);
var data = result["Result"]["ResponseStatus"]["SuccessEntitys"];

View File

@ -39,6 +39,7 @@ namespace MyCode.Project.WebApi.Areas.Admin.Controllers
/// <param name="pagedSearch"></param>
/// <returns></returns>
[HttpPost]
public PageResult<PurchaseOrderPageList> GetPageList(PagedSearch<PurchaseOrderPageSearch> pagedSearch)
{
return _purchaseOrderService.GetPageList(pagedSearch, this.CurrentLogin);
@ -67,6 +68,7 @@ namespace MyCode.Project.WebApi.Areas.Admin.Controllers
[HttpPost]
public void BatchSetChengNuoJiaoQi(List<UpdateTime> updateList)
{
if (this.CurrentLogin.RoleType == 1)
{
throw new BaseException("管理员只能查看数据");