Commit 23a1dbe4 by 陶然

优化

parent 52c920ee
......@@ -83,7 +83,7 @@ namespace Kivii.Third.Chinaerdos.Entities
/// 付款单位名称
/// </summary>
[ApiMember(Description = "付款单位名称")]
public DateTime PAYER_ORG_NAME { get; set; }
public string PAYER_ORG_NAME { get; set; }
/// <summary>
/// 付款单位地址
......
......@@ -18,7 +18,58 @@ namespace Kivii.Third.Chinaerdos.Entities
public Report OnInstanceThirdReport(Guid ThirdReportOrderKvid)
{
return new Report();
//return null;
if (ThirdReportOrderKvid == Guid.Empty) return null;
var conn = KiviiContext.GetOpenedDbConnection<ThirdReportOrder>();
var third = conn.SingleById<ThirdReportOrder>(ThirdReportOrderKvid);
if (third == null) return null;
if (third.ThirdType != typeof(ErdosOrder).FullName) return null;
if (third.Metadata == null) return null;
var order = third.Metadata.DicToObject();
var rtns = new Report();
rtns.BizId = third.SerialNumber;
rtns.BizKvid = third.Kvid;
rtns.BizType = typeof(ThirdReportOrder).FullName;
//rtns.ReportId = $"{order.BRAND_DISPLAY}{DateTime.Now:yyyyMMddHHmmss}";
//contract.OrderID = semir.DOC_NO;
//report.Type = "B";
rtns.TypeEx = "W";
rtns.TypeName = "委托送样";
//rtns.Category = "SE";
rtns.DemanderName = order.APPLY_ORG_NAME;
rtns.DemanderContactName = order.CONTACT_PERSON;
rtns.DemanderContactNumber = order.CONTACT_PHONE;
rtns.DemanderContactAddress = order.APPLY_ORG_ADDRESS;
rtns.SampleManufacturerName = order.RELATED_VENDOR_DESC;
//rtns.SampleManufacturerContactName = order.PAYER_CONTACT_PERSON;
//rtns.SampleManufacturerContactNumber = order.PAYER_CONTACT_PHONE;
//rtns.SampleManufacturerAddress = order.PAYER_ORG_ADDRESS;
rtns.PayerName = order.PAYER_ORG_NAME;
rtns.SampleName = order.SAMPLE_NAME;
rtns.SampleBrand = order.BRAND_DISPLAY;
rtns.SampleGradeSafety = order.CHECK_LEVEL_DISPLAY;
rtns.SampleGrade = order.SAMPLE_GRADE_DISPLAY;
rtns.SampleBatchNumber = order.MAT_CODE;
rtns.Metadata = new Dictionary<string, string>();
rtns.Metadata["PayerContactAddress"] = order.PAYER_ORG_ADDRESS;
rtns.Metadata["SampleDescriptionEx"] = order.MAT_F1_DISPLAY;
rtns.Remark = order.REMARK;
var details = new List<string>();
foreach (var detail in order.ITEMS)
{
details.Add($"{detail.ITEM_NAME}({detail.ITEM_STANDARD})");
}
var tasks = string.Join("、", details.ToArray());
rtns.Metadata.Add("ERemark", tasks);
return rtns;
}
public object OnPullThirdReport()
......
......@@ -6,9 +6,11 @@ using Kivii.Third.Chinaerdos.Requests;
using System;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Kivii.Third.Chinaerdos.Extensions
......@@ -96,11 +98,11 @@ namespace Kivii.Third.Chinaerdos.Extensions
}
}
internal static OrderResponse RejectOrder(this JsonHttpClient _client, string apptoken, string appsecret, string orderNo)
internal static OrderResponse RejectOrder(JsonHttpClient _client, string orderNo, string apptoken=null, string appsecret = null)
{
(_client == null).ThrowIfTrue("RejectOrder:请传入_client");
(apptoken.IsNullOrEmpty()).ThrowIfTrue("RejectOrder:请传入apptoken");
(appsecret.IsNullOrEmpty()).ThrowIfTrue("RejectOrder:请传入appsecret");
if (apptoken.IsNullOrEmpty()) apptoken = Configs._token;//.ThrowIfTrue("RejectOrder:请传入apptoken");
if (appsecret.IsNullOrEmpty()) appsecret = Configs._secret;//.ThrowIfTrue("RejectOrder:请传入appsecret");
(orderNo.IsNullOrEmpty()).ThrowIfTrue("RejectOrder:请传入orderNo");
//var client = new JsonServiceClient(baseUrl);
......@@ -377,5 +379,61 @@ namespace Kivii.Third.Chinaerdos.Extensions
}
return sign.ToString().ToUpper();
}
/// <summary>
/// 字典类型转化为对象
/// </summary>
/// <param name="dic"></param>
/// <returns></returns>
public static ErdosOrder DicToObject(this Dictionary<string, string> dic)
{
var md = new ErdosOrder();
CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
TextInfo textInfo = cultureInfo.TextInfo;
foreach (var d in dic)
{
var filed = textInfo.ToTitleCase(d.Key);
try
{
var value = d.Value;
var property = md.GetType().GetProperty(filed);
if (property == null) continue;
if (!property.PropertyType.IsGenericType)
{
switch (property.Name)
{
case "ITEMS":
property.SetValue(md, JsonSerializer.DeserializeFromString<List<ErdosOrderDetail>>(value), null);
break;
default:
property.SetValue(md, string.IsNullOrEmpty(value) ? null : Convert.ChangeType(value, property.PropertyType), null);
break;
}
}
else
{
Type genericTypeDefinition = property.PropertyType.GetGenericTypeDefinition();
switch (property.Name)
{
case "ITEMS":
property.SetValue(md, JsonSerializer.DeserializeFromString<List<ErdosOrderDetail>>(value), null);
break;
default:
//泛型Nullable<>
if (genericTypeDefinition == typeof(Nullable<>))
{
property.SetValue(md, string.IsNullOrEmpty(value) ? null : Convert.ChangeType(value, Nullable.GetUnderlyingType(property.PropertyType)), null);
}
break;
}
}
}
catch (Exception ex)
{
throw ex;
}
}
return md;
}
}
}
......@@ -58,7 +58,6 @@
<Compile Include="Jobs\OrderJob.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Requests\OrderRequest.cs" />
<Compile Include="RestfulErdos.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
......
......@@ -33,5 +33,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("5.4.2024.10210")]
[assembly: AssemblyFileVersion("5.4.2024.10210")]
[assembly: AssemblyVersion("5.4.2024.10220")]
[assembly: AssemblyFileVersion("5.4.2024.10220")]
using Kivii.Third.Chinaerdos.Entities;
using Kivii.Linq;
using Kivii.Third.Chinaerdos.Entities;
using Kivii.Third.Chinaerdos.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
......
using Kivii.Third.Chinaerdos.Entities;
using Kivii.Third.Chinaerdos.Extensions;
using Kivii.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Kivii.Third.Chinaerdos
{
public class ErdosRegect:RestfulExecution<ErdosOrder>
{
public string SerialNumber { get; set; }
public override object OnExecution(IRequest req, IResponse res)
{
var client = new JsonHttpClient(Configs._defaultUrl);
client.RejectOrder(Configs._token, Configs._secret, SerialNumber);
return base.OnExecution(req, res);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment