第三方接口失败次数超过10次的只在空闲时调用
This commit is contained in:
@@ -78,5 +78,10 @@ namespace Tnb.BasicData.Entities
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 错误次数
|
||||
/// </summary>
|
||||
public int error_count { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -145,6 +145,7 @@ namespace Tnb.ProductionMgr
|
||||
.LeftJoin<EqpEquipment>((a,b,c,d,e,f)=>e.equip_id==f.id)
|
||||
.LeftJoin<PrdMoTask>((a,b,c,d,e,f,g)=>e.mo_task_id==g.id)
|
||||
.Where((a, b, c) => a.material_id == materialId)
|
||||
.OrderBy((a,b)=>b.mold_code)
|
||||
.Select((a, b, c,d,e,f,g) => new Tnb.ProductionMgr.Entities.Dto.MoldListOutput
|
||||
{
|
||||
mold_id = b.id,
|
||||
@@ -171,6 +172,7 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
List<EquipmentListOutput> items = await _db.Queryable<ToolMoldsEquipment>().InnerJoin<EqpEquipment>((a, b) => a.equipment_id == b.id)
|
||||
.Where((a, b) => a.mold_id == moldId)
|
||||
.OrderBy((a,b)=>b.code)
|
||||
.Select((a, b) => new Entities.Dto.EquipmentListOutput
|
||||
{
|
||||
eqp_id = b.id,
|
||||
@@ -1361,9 +1363,12 @@ namespace Tnb.ProductionMgr
|
||||
});
|
||||
}
|
||||
|
||||
if (insertRecordDs.Count>0)
|
||||
{
|
||||
await db.Insertable(toolMoldMaintainRecordH).ExecuteCommandAsync();
|
||||
await db.Insertable(insertRecordDs).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2478,18 +2483,18 @@ namespace Tnb.ProductionMgr
|
||||
//来源erp需要调接口
|
||||
if (prdMo.mo_source == "1")
|
||||
{
|
||||
List<DictionaryDataEntity> unitDatas = await db.Queryable<DictionaryTypeEntity>()
|
||||
.LeftJoin<DictionaryDataEntity>((x, y) => x.Id == y.DictionaryTypeId)
|
||||
.Where((x, y) => x.EnCode == DictConst.MeasurementUnit && y.EnCode==report.unit_id)
|
||||
.Select((x, y) => y)
|
||||
.ToListAsync();
|
||||
// List<DictionaryDataEntity> unitDatas = await db.Queryable<DictionaryTypeEntity>()
|
||||
// .LeftJoin<DictionaryDataEntity>((x, y) => x.Id == y.DictionaryTypeId)
|
||||
// .Where((x, y) => x.EnCode == DictConst.MeasurementUnit && y.EnCode==report.unit_id)
|
||||
// .Select((x, y) => y)
|
||||
// .ToListAsync();
|
||||
|
||||
List<string> erpExtendIds = new List<string>();
|
||||
erpExtendIds.Add(_userManager.UserId);
|
||||
erpExtendIds.Add(WmsWareHouseConst.AdministratorOrgId);
|
||||
erpExtendIds.Add(report.material_id);
|
||||
erpExtendIds.Add(report.unit_id);
|
||||
erpExtendIds.AddRange(unitDatas.Select(x => x.Id).ToList());
|
||||
// erpExtendIds.AddRange(unitDatas.Select(x => x.Id).ToList());
|
||||
|
||||
List<ErpExtendField> erpExtendFields = await _db.Queryable<ErpExtendField>().Where(x=>erpExtendIds.Contains(x.table_id)).ToListAsync();
|
||||
string erpCreateId = erpExtendFields.Find(x=>x.table_id==_userManager.UserId)?.user_id ?? "";
|
||||
@@ -2530,8 +2535,8 @@ namespace Tnb.ProductionMgr
|
||||
["cbmoid"] = prdMo.erp_mo_pk,
|
||||
// ["cbunitid"] = erpExtendFields.Find(x=>x.table_id==report.unit_id)?.cunitid ?? "",
|
||||
// ["cbastunitid"] = erpExtendFields.Find(x=>x.table_id==report.unit_id)?.cunitid ?? "",
|
||||
["cbunitid"] = erpExtendFields.Find(x => x.table_id == (unitDatas.Find(x => x.EnCode == report.unit_id)?.Id ?? ""))?.cunitid ?? "",
|
||||
["cbastunitid"] = erpExtendFields.Find(x => x.table_id == (unitDatas.Find(x => x.EnCode == report.unit_id)?.Id ?? ""))?.cunitid ?? "",
|
||||
["cbunitid"] = erpExtendFields.Find(x => x.table_id == report.unit_id)?.cunitid ?? "",
|
||||
["cbastunitid"] = erpExtendFields.Find(x => x.table_id == report.unit_id)?.cunitid ?? "",
|
||||
["nbplanwrnum"] = report.reported_qty,
|
||||
["nbwrnum"] = report.reported_qty,
|
||||
["tbendtime"] = nowStr,
|
||||
|
||||
@@ -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