diff --git a/BasicData/Tnb.BasicData/ThirdApiRecordService.cs b/BasicData/Tnb.BasicData/ThirdApiRecordService.cs index 33ecc31a..d6bfbd27 100644 --- a/BasicData/Tnb.BasicData/ThirdApiRecordService.cs +++ b/BasicData/Tnb.BasicData/ThirdApiRecordService.cs @@ -50,7 +50,16 @@ namespace Tnb.BasicData stopwatch.Stop(); var elapsedMilliseconds = stopwatch.ElapsedMilliseconds; - ThirdResult thirdResult = JsonConvert.DeserializeObject(response); + ThirdResult thirdResult = new ThirdResult(); + try + { + thirdResult = JsonConvert.DeserializeObject(response); + } + catch (Exception e) + { + thirdResult.Code = 500; + thirdResult.msgResult = response; + } if (thirdResult.Code == 200) { await db.Updateable() diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index d74ca75b..822847eb 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -1723,16 +1723,17 @@ namespace Tnb.ProductionMgr // throw Oops.Bah("未找到对应产线"); // } - report.warehouse_id = WmsWareHouseConst.WAREHOUSE_JXK_ID; + // report.warehouse_id = WmsWareHouseConst.WAREHOUSE_JXK_ID; + report.warehouse_id = WmsWareHouseConst.WAREHOUSE_SLDMJC_ID; Dictionary worklineWarehouseDic = new Dictionary() { - [WmsWareHouseConst.XUELUGUAN1XIAN] = "ZZ-01-01", - [WmsWareHouseConst.XUELUGUAN2XIAN] = "ZZ-01-02", + [WmsWareHouseConst.XUELUGUAN1XIAN] = "ZZ-01-02", + [WmsWareHouseConst.XUELUGUAN2XIAN] = "ZZ-02-02", }; report.location_code = worklineWarehouseDic.GetOrDefault(prdMoTask.workline_id); if (string.IsNullOrEmpty(report.location_code)) { - report.location_code = "ZZ-01-01"; + report.location_code = "ZZ-01-02"; } location = await db.Queryable().SingleAsync(x=>x.location_code==report.location_code); if (location == null) diff --git a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs index 55add93a..51079787 100644 --- a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs @@ -247,6 +247,132 @@ namespace Tnb.ProductionMgr return msg; } + // [HttpGet] + // [AllowAnonymous] + // public async Task FixedPointDelivery() + // { + // string state = await _redisData.TryGetValueByKeyField("YTCS", "State"); + // if ("OK" != state) + // { + // Log.Error($"TCS没开机"); + // return "YTCS没开机"; + // } + // string stateHxja = await _redisData.TryGetValueByKeyField("hxjA", "State"); + // string stateHxjc = await _redisData.TryGetValueByKeyField("hxjC", "State"); + // List hxjList = new List(); + // if ("OK" == stateHxja) + // { + // hxjList.Add("hxjA"); + // } + // if ("OK" == stateHxjc) + // { + // hxjList.Add("hxjC"); + // } + // + // if (hxjList.IsEmpty()) + // { + // Log.Error($"hxjA,hxjC不正常"); + // return "hxjA,hxjC不正常"; + // } + // string msg = ""; + // List equipments = await _db.Queryable() + // .InnerJoin((x, y) => x.id == y.equip_type_id) + // .Where((x, y) => x.code == "ZSJ") + // .Select((x, y) => y).ToListAsync(); + // + // int? cs01Count = await _redisData.TryGetValueByKeyField("YTCS", "EmptyNo_CS01"); + // int? cs03Count = await _redisData.TryGetValueByKeyField("YTCS", "EmptyNo_CS03"); + // + // List eqpIds = equipments.Select(x => x.id).ToList(); + // List eqpDaqs = await _db.Queryable().Where(x => eqpIds.Contains(x.equip_id) && x.label_name.Contains("允许入空箱")).ToListAsync(); + // //BasFactoryConfig config = await _db.Queryable().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.DOMAIN); + // foreach (var equipment in equipments) + // { + // EqpDaq eqpDaq = eqpDaqs.FirstOrDefault(x => x.equip_id==equipment.id); + // if (eqpDaq == null) + // { + // Log.Error($"{equipment.name}没配置允许入空箱"); + // continue; + // } + // if (!hxjList.Contains(eqpDaq.equip_code)) + // { + // Log.Error($"{eqpDaq.equip_code}状态不正常"); + // continue; + // } + // if (string.IsNullOrEmpty(equipment.upmat_location_id)) + // { + // Log.Error($"{equipment.name}未配置上料库位"); + // continue; + // } + // if (await _db.Queryable().AnyAsync(x => + // x.endlocation_id == equipment.upmat_location_id && + // x.biz_type == WmsWareHouseConst.BIZTYPE_WMSDELIVERY_ID && + // (x.status == WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID + // || x.status == WmsWareHouseConst.PRETASK_BILL_STATUS_YXF_ID + // || x.status == WmsWareHouseConst.PRETASK_BILL_STATUS_START_ID + // ) + // )) + // { + // Log.Error($"{equipment.name}存在未完成的任务"); + // continue; + // } + // bool? value = await _redisData.TryGetValueByKeyField(eqpDaq.equip_code, eqpDaq.label_name); + // bool valueFlag = _redisData.Get($"{eqpDaq.equip_code}_{eqpDaq.label_name}_flag"); + // Log.Information($"机台号{eqpDaq.equip_code},标签名{eqpDaq.label_name}redis的值为{value.ToString()}"); + // + // if (value==true && !valueFlag) + // { + // bool? cs01 = await _redisData.TryGetValueByKeyField("YTCS", "AllowAgvEmptyOut_CS01"); + // bool? cs03 = await _redisData.TryGetValueByKeyField("YTCS", "AllowAgvEmptyOut_CS03"); + // string startLocationCode = cs01==true ? "ZSSSXCTU01" : cs03==true ? "ZSSSXCTU02" : ""; + // if (cs01==true && cs03==true) + // { + // string last_fixed_point_delivery = _redisData.Exists("last_fixed_point_delivery") ? _redisData.Get("last_fixed_point_delivery") : ""; + // if (string.IsNullOrEmpty(last_fixed_point_delivery)) + // { + // startLocationCode = "ZSSSXCTU01"; + // } + // else + // { + // startLocationCode = "ZSSSXCTU01ZSSSXCTU02".Replace(last_fixed_point_delivery, ""); + // } + // } + // if (startLocationCode.IsEmpty()) + // { + // Log.Error($"输送线无空载具"); + // return "输送线无空载具"; + // } + // + // BasLocation startLocation = await _db.Queryable().Where(x=>x.location_code==startLocationCode).FirstAsync(); + // CommonCreatePretaskInput postData = new CommonCreatePretaskInput(); + // postData.startlocation_id = startLocation.id; + // postData.endlocation_id = equipment.upmat_location_id; + // postData.biz_type = WmsWareHouseConst.BIZTYPE_WMSDELIVERY_ID; + // postData.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID; + // Log.Information($"【FixedPointDelivery】注塑定点配送,参数:{JsonConvert.SerializeObject(postData)}"); + // Result result = await _wareHouseService.CommonCreatePretask(postData); + // // string sendResult = HttpUtils.RequestPost($"{config.value}/api/wms/ware-house/common-create-pretask", JsonConvert.SerializeObject(postData), null); + // // string sendResult = HttpUtils.RequestPost($"http://localhost:9232/api/wms/ware-house/common-create-pretask", JsonConvert.SerializeObject(postData), null); + // // AuthResponse authResponse = JsonConvert.DeserializeObject(sendResult); + // if(result.code == HttpStatusCode.OK) + // { + // msg += $"{equipment.name}注塑定点配送成功,"; + // Log.Information($"【FixedPointDelivery】{equipment.name}注塑定点配送成功"); + // _redisData.Set($"{eqpDaq.equip_code}_{eqpDaq.label_name}_flag", true, TimeSpan.FromMinutes(20)); + // _redisData.Set($"last_fixed_point_delivery", startLocationCode); + // } + // else + // { + // msg += $"{equipment.name}注塑定点配送失败:{result.msg},"; + // Log.Error($"【FixedPointDelivery】{equipment.name}注塑定点配送失败:{result.msg}"); + // } + // + // } + // } + // + // return msg; + // } + [HttpGet] [AllowAnonymous] public async Task FixedPointDelivery() @@ -280,8 +406,8 @@ namespace Tnb.ProductionMgr .Where((x, y) => x.code == "ZSJ") .Select((x, y) => y).ToListAsync(); - int? cs01Count = await _redisData.TryGetValueByKeyField("YTCS", "EmptyNo_CS01"); - int? cs03Count = await _redisData.TryGetValueByKeyField("YTCS", "EmptyNo_CS03"); + int cs01Count = await _redisData.TryGetValueByKeyField("YTCS", "EmptyNo_CS01"); + int cs03Count = await _redisData.TryGetValueByKeyField("YTCS", "EmptyNo_CS03"); List eqpIds = equipments.Select(x => x.id).ToList(); List eqpDaqs = await _db.Queryable().Where(x => eqpIds.Contains(x.equip_id) && x.label_name.Contains("允许入空箱")).ToListAsync(); @@ -324,8 +450,9 @@ namespace Tnb.ProductionMgr { bool? cs01 = await _redisData.TryGetValueByKeyField("YTCS", "AllowAgvEmptyOut_CS01"); bool? cs03 = await _redisData.TryGetValueByKeyField("YTCS", "AllowAgvEmptyOut_CS03"); - string startLocationCode = cs01==true ? "ZSSSXCTU01" : cs03==true ? "ZSSSXCTU02" : ""; - if (cs01==true && cs03==true) + string startLocationCode = ""; + + if (cs01==true && cs03==true && cs01Count>0 && cs03Count>0) { string last_fixed_point_delivery = _redisData.Exists("last_fixed_point_delivery") ? _redisData.Get("last_fixed_point_delivery") : ""; if (string.IsNullOrEmpty(last_fixed_point_delivery)) @@ -337,6 +464,19 @@ namespace Tnb.ProductionMgr startLocationCode = "ZSSSXCTU01ZSSSXCTU02".Replace(last_fixed_point_delivery, ""); } } + else + { + if (cs01==true && cs01Count > 0) + { + startLocationCode = "ZSSSXCTU01"; + cs01Count--; + }else if (cs03==true && cs03Count > 0) + { + startLocationCode = "ZSSSXCTU02"; + cs03Count--; + } + } + if (startLocationCode.IsEmpty()) { Log.Error($"输送线无空载具"); @@ -461,7 +601,7 @@ namespace Tnb.ProductionMgr Stopwatch stopwatch = null; string response = ""; var elapsedMilliseconds = 0l; - ThirdResult thirdResult = null; + ThirdResult thirdResult = new ThirdResult(); foreach (var record in records) { now = DateTime.Now; diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs index e31bca80..fd4e5509 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs @@ -26,8 +26,10 @@ /// 暂存仓仓库ID /// public const string WAREHOUSE_ZCC_ID = "33780009364245"; - - + /// + /// 四楼待灭菌仓 + /// + public const string WAREHOUSE_SLDMJC_ID = "35412479754517"; /// /// 四楼解析库 /// diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 684c89d4..5e0b394a 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -2398,7 +2398,7 @@ namespace Tnb.WarehouseMgr List erpExtendFields = await _db.Queryable().Where(x=>ids.Contains(x.table_id)).ToListAsync(); string erpCreateId = erpExtendFields.Find(x=>x.table_id==wmsMaterialTransfer.create_id)?.user_id ?? ""; ErpExtendField erpOrg = erpExtendFields.Find(x => x.table_id == (wmsMaterialTransfer.org_id ?? WmsWareHouseConst.AdministratorOrgId)); - string nowStr = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); + string nowStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); List> requestData = new List>(); Dictionary erpRequestData = new Dictionary(); @@ -2427,8 +2427,8 @@ namespace Tnb.WarehouseMgr ["cbodytranstypecode"] = "4A-01", ["cbodywarehouseid"] = erpExtendFields.Find(x=>x.table_id==wmsMaterialTransfer.warehouse_instock)?.cotherwhid ?? "", ["cgeneralbid"] = erpExtendFields.Find(x=>x.table_id==wmsMaterialTransfer.warehouse_instock)?.cotherwhid ?? "", - ["cgeneralbid"] = item.id, - ["cgeneralhid"] = item.bill_id, + ["cgeneralbid"] = item.erp_line_pk ?? "", + ["cgeneralhid"] = wmsMaterialTransfer.erp_pk ?? "", ["cmaterialoid"] = erpExtendFields.Find(x=>x.table_id==item.material_id)?.cmaterialoid ?? "", ["cmaterialvid"] = erpExtendFields.Find(x=>x.table_id==item.material_id)?.cmaterialvid ?? "", ["corpoid"] = erpOrg.corpoid, @@ -2454,7 +2454,7 @@ namespace Tnb.WarehouseMgr thirdWebapiRecord.name = "其它入库"; thirdWebapiRecord.method = "POST"; thirdWebapiRecord.url = WmsWareHouseConst.BIP_DOMAIN+"uapws/rest/generalin/save"; - thirdWebapiRecord.request_data = JsonConvert.SerializeObject(erpRequestData); + thirdWebapiRecord.request_data = JsonConvert.SerializeObject(requestData); thirdWebapiRecord.create_time = DateTime.Now; await _db.Insertable(thirdWebapiRecord).ExecuteCommandAsync(); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs index c5ddf4e8..7b5e656d 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs @@ -829,7 +829,6 @@ namespace Tnb.WarehouseMgr ids.Add(wmsMaterialTransfer.warehouse_instock); ids.Add(wmsMaterialTransferd.material_id); ids.Add(unitData.Id); - List erpExtendFields = await _db.Queryable().Where(x=>ids.Contains(x.table_id)).ToListAsync(); ErpExtendField erpOrg = erpExtendFields.Find(x => x.table_id == (wmsMaterialTransfer.org_id ?? WmsWareHouseConst.AdministratorOrgId)); @@ -837,13 +836,13 @@ namespace Tnb.WarehouseMgr List> requestData = new List>(); Dictionary erpRequestData = new Dictionary(); - string nowStr = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); + string nowStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); erpRequestData.Add("billmaker",erpCreateId); erpRequestData.Add("cdptid","1001A1100000000JRLI1A100");// 先写死 erpRequestData.Add("cdptvid","0001A11000000007GGO8");// 先写死 erpRequestData.Add("corpoid",erpOrg.corpoid); erpRequestData.Add("corpvid",erpOrg.corpoid); - erpRequestData.Add("cothercalbodyoid",erpOrg.cdptid); + erpRequestData.Add("cothercalbodyoid",erpOrg.pk_org); erpRequestData.Add("cotherwhid",erpExtendFields.Find(x=>x.table_id==wmsMaterialTransfer.warehouse_instock)?.cotherwhid ?? ""); erpRequestData.Add("creationtime",nowStr); erpRequestData.Add("creator",erpCreateId); @@ -867,8 +866,8 @@ namespace Tnb.WarehouseMgr ["corpoid"] = erpOrg.corpoid, ["corpvid"] = erpOrg.corpvid, ["crowno"] = (dList.FindIndex(x=>x.id==wmsMaterialTransferd.id)+1) * 10, - ["csourcebillbid"] = wmsMaterialTransferd.id, - ["csourcebillhid"] = wmsMaterialTransferd.bill_id, + ["csourcebillbid"] = wmsMaterialTransferd.erp_line_pk ?? "", + ["csourcebillhid"] = wmsMaterialTransfer.erp_pk ?? "", ["cunitid"] = erpExtendFields.Find(x=>x.table_id==unitData.Id)?.cunitid ?? "", ["cvendorid"] = "", ["cvendorvid"] = "",