第三方接口失败次数超过10次的只在空闲时调用
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using System.Text.RegularExpressions;
|
||||
using Aop.Api.Domain;
|
||||
using JNPF;
|
||||
using JNPF.Common.Const;
|
||||
@@ -712,7 +713,11 @@ namespace Tnb.ProductionMgr
|
||||
public async Task<string> SendThirdApi(string thirdNmaes)
|
||||
{
|
||||
string[] thirdNameArr = thirdNmaes.Split("-");
|
||||
List<ThirdWebapiRecord> records = await _db.Queryable<ThirdWebapiRecord>().Where(x => thirdNameArr.Contains(x.third_name) && x.status == "0" && x.is_send == 1).ToListAsync();
|
||||
List<ThirdWebapiRecord> records = await _db.Queryable<ThirdWebapiRecord>().Where(x => thirdNameArr.Contains(x.third_name) && x.status == "0" && x.is_send == 1 && x.error_count<10).ToListAsync();
|
||||
if (records.IsEmpty())
|
||||
{
|
||||
records = await _db.Queryable<ThirdWebapiRecord>().Where(x => thirdNameArr.Contains(x.third_name) && x.status == "0" && x.is_send == 1).ToListAsync();
|
||||
}
|
||||
DateTime now = DateTime.Now;
|
||||
Stopwatch stopwatch = null;
|
||||
string response = "";
|
||||
@@ -766,6 +771,7 @@ namespace Tnb.ProductionMgr
|
||||
.SetColumns(x => x.response_code == thirdResult.Code)
|
||||
.SetColumns(x => x.last_send_time == now)
|
||||
.SetColumns(x => x.response_time == elapsedMilliseconds)
|
||||
.SetColumns(x => x.error_count == x.error_count + 1)
|
||||
.Where(x=>x.id==record.id)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
@@ -993,6 +999,41 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
foreach (ErpBdMaterial erpBdMaterial in list)
|
||||
{
|
||||
string categoryId = "[\"CGJCJ\"]";
|
||||
if (erpBdMaterial.CODE.StartsWith("0401"))
|
||||
{
|
||||
string str = "";
|
||||
if (erpBdMaterial.MATERIALSPEC.Contains("*"))
|
||||
{
|
||||
str = erpBdMaterial.MATERIALSPEC;
|
||||
}else if (erpBdMaterial.NAME.Contains("*"))
|
||||
{
|
||||
str = erpBdMaterial.NAME;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(str))
|
||||
{
|
||||
MatchCollection mts = Regex.Matches(str, @"[0-9]|[\*]|[\.]");
|
||||
string tempStr = string.Join(String.Empty, mts.Select(x => x.Value).ToList());
|
||||
string[] strArr = tempStr.Split("*");
|
||||
if (strArr.Length <= 2)
|
||||
{
|
||||
categoryId = "[\"CGJCJ\"]";
|
||||
}else if (decimal.Parse(strArr[2]) > 600)
|
||||
{
|
||||
categoryId = "[\"CGJCJ\"]";
|
||||
}
|
||||
else
|
||||
{
|
||||
categoryId = "[\"DGJCJ\"]";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if (erpExtendFields.All(x => x.cmaterialoid != erpBdMaterial.ID))
|
||||
{
|
||||
string unitId = erpExtendFields.Find(x => x.cunitid == erpBdMaterial.PK_MEASDOC)?.table_id ?? "";
|
||||
@@ -1016,7 +1057,7 @@ namespace Tnb.ProductionMgr
|
||||
org_id = WmsWareHouseConst.AdministratorOrgId,
|
||||
material_specification = erpBdMaterial.MATERIALSPEC,
|
||||
material_standard = erpBdMaterial.MATERIALTYPE,
|
||||
category_id = "[\"CGJCJ\"]",
|
||||
category_id = categoryId,
|
||||
unit_id = unitId,
|
||||
state = "1",
|
||||
create_time = DateTime.Now
|
||||
@@ -1062,6 +1103,7 @@ namespace Tnb.ProductionMgr
|
||||
int updateRow = await _db.Updateable<BasMaterial>()
|
||||
.SetColumns(x => x.name == erpBdMaterial.NAME)
|
||||
.SetColumns(x => x.code == erpBdMaterial.CODE)
|
||||
.SetColumns(x=>x.category_id == categoryId)
|
||||
.SetColumns(x => x.material_specification == erpBdMaterial.MATERIALSPEC)
|
||||
.SetColumns(x => x.material_standard == erpBdMaterial.MATERIALTYPE)
|
||||
.SetColumns(x => x.unit_id == unitId)
|
||||
|
||||
Reference in New Issue
Block a user