diff --git a/BasicData/Tnb.BasicData.Entities/Entity/ThirdWebapiRecord.cs b/BasicData/Tnb.BasicData.Entities/Entity/ThirdWebapiRecord.cs index f806cb28..aaa99bdc 100644 --- a/BasicData/Tnb.BasicData.Entities/Entity/ThirdWebapiRecord.cs +++ b/BasicData/Tnb.BasicData.Entities/Entity/ThirdWebapiRecord.cs @@ -78,5 +78,10 @@ namespace Tnb.BasicData.Entities /// 备注 /// public string remark { get; set; } + + /// + /// 错误次数 + /// + public int error_count { get; set; } } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index a880cd8f..3cb1f938 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -145,6 +145,7 @@ namespace Tnb.ProductionMgr .LeftJoin((a,b,c,d,e,f)=>e.equip_id==f.id) .LeftJoin((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 items = await _db.Queryable().InnerJoin((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,8 +1363,11 @@ namespace Tnb.ProductionMgr }); } - await db.Insertable(toolMoldMaintainRecordH).ExecuteCommandAsync(); - await db.Insertable(insertRecordDs).ExecuteCommandAsync(); + if (insertRecordDs.Count>0) + { + await db.Insertable(toolMoldMaintainRecordH).ExecuteCommandAsync(); + await db.Insertable(insertRecordDs).ExecuteCommandAsync(); + } } } @@ -2477,18 +2482,18 @@ namespace Tnb.ProductionMgr //来源erp需要调接口 if (prdMo.mo_source == "1") { - List unitDatas = await db.Queryable() - .LeftJoin((x, y) => x.Id == y.DictionaryTypeId) - .Where((x, y) => x.EnCode == DictConst.MeasurementUnit && y.EnCode==report.unit_id) - .Select((x, y) => y) - .ToListAsync(); + // List unitDatas = await db.Queryable() + // .LeftJoin((x, y) => x.Id == y.DictionaryTypeId) + // .Where((x, y) => x.EnCode == DictConst.MeasurementUnit && y.EnCode==report.unit_id) + // .Select((x, y) => y) + // .ToListAsync(); List erpExtendIds = new List(); 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 erpExtendFields = await _db.Queryable().Where(x=>erpExtendIds.Contains(x.table_id)).ToListAsync(); string erpCreateId = erpExtendFields.Find(x=>x.table_id==_userManager.UserId)?.user_id ?? ""; @@ -2529,8 +2534,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, diff --git a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs index 9fd8f8d0..81f498cb 100644 --- a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs @@ -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 SendThirdApi(string thirdNmaes) { string[] thirdNameArr = thirdNmaes.Split("-"); - List records = await _db.Queryable().Where(x => thirdNameArr.Contains(x.third_name) && x.status == "0" && x.is_send == 1).ToListAsync(); + List records = await _db.Queryable().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().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() .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)