diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs index 45417d4d..09c14e01 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs @@ -190,7 +190,7 @@ namespace Tnb.ProductionMgr mo_status = ee.FullName, remark = aa.remark, }) - }).ToPagedListAsync(input.currentPage, int.MaxValue); + }).ToPagedListAsync(input.currentPage, input.pageSize); return PageResult.SqlSugarPageResult(result); } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 47c859c0..5da1ce77 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -1985,7 +1985,6 @@ namespace Tnb.ProductionMgr throw Oops.Bah("提报数量为正数"); } - report = input.Adapt(); report.id = SnowflakeIdHelper.NextId(); report.org_id = WmsWareHouseConst.AdministratorOrgId; @@ -2379,21 +2378,27 @@ namespace Tnb.ProductionMgr { try { - if(db==null) db = _repository.AsSugarClient(); - if(report==null) report = await db.Queryable().FirstAsync(it => it.id==input.report_id && !SqlFunc.IsNullOrEmpty(it.id)); - PrdMoTask? prdMoTask = await db.Queryable().FirstAsync(x => x.id == report.mo_task_id && !SqlFunc.IsNullOrEmpty(x.id)); + if (db == null) db = _repository.AsSugarClient(); + if (report == null) + report = await db.Queryable() + .FirstAsync(it => it.id == input.report_id && !SqlFunc.IsNullOrEmpty(it.id)); + PrdMoTask? prdMoTask = await db.Queryable() + .FirstAsync(x => x.id == report.mo_task_id && !SqlFunc.IsNullOrEmpty(x.id)); EqpEquipment equip = await db.Queryable().SingleAsync(x => x.id == prdMoTask.eqp_id); - BasMaterial basMaterial = await db.Queryable().SingleAsync(x => x.id == prdMoTask.material_id); - WmsCarryH wmsCarryH = await db.Queryable().FirstAsync(x=>x.carry_code==report.material_box_code); - BasLocation location = await db.Queryable().FirstAsync(x=>x.location_code==report.location_code); + BasMaterial basMaterial = + await db.Queryable().SingleAsync(x => x.id == prdMoTask.material_id); + WmsCarryH wmsCarryH = await db.Queryable() + .FirstAsync(x => x.carry_code == report.material_box_code); + BasLocation location = await db.Queryable() + .FirstAsync(x => x.location_code == report.location_code); PrdMo prdMo = await db.Queryable().SingleAsync(x => x.id == prdMoTask.mo_id); await db.Updateable() .SetColumns(x => x.check_result == input.check_result) .Where(x => x.id == input.report_id) .ExecuteCommandAsync(); - - + + BindCarryCodeInput bindCarryCodeInput = new BindCarryCodeInput(); bindCarryCodeInput.carry_id = wmsCarryH.id; bindCarryCodeInput.barcode = report.barcode; @@ -2407,12 +2412,13 @@ namespace Tnb.ProductionMgr bindCarryCodeInput.create_id = _userManager?.UserId ?? WmsWareHouseConst.AdministratorUserId; Log.Information($"载具绑定参数:${JsonConvert.SerializeObject(bindCarryCodeInput)}"); - Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result1 = await _wmsCarryService.BindCarryMaterial(bindCarryCodeInput); + Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result1 = + await _wmsCarryService.BindCarryMaterial(bindCarryCodeInput); if (result1.code != HttpStatusCode.OK) { throw Oops.Bah(result1.msg); } - + WmsPrdInstockInput wmsPrdInstockInput = new WmsPrdInstockInput(); wmsPrdInstockInput.prd_bill_code = prdMo.mo_code; wmsPrdInstockInput.material_id = prdMoTask.material_id; @@ -2433,7 +2439,7 @@ namespace Tnb.ProductionMgr startlocation_id = location.id, carry_id = wmsCarryH.id, }; - + if (prdMoTask.schedule_type == 1) { wmsPrdInstockInput.prdInstockCodes.Add(new WmsPrdInstockCodeInput() @@ -2462,10 +2468,11 @@ namespace Tnb.ProductionMgr }); } } - - + + Log.Information($"生产入库参数:${JsonConvert.SerializeObject(wmsPrdInstockInput)}"); - Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result2 = await _wmsPrdInstockHService.PrdInstock(wmsPrdInstockInput, db); + Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result2 = + await _wmsPrdInstockHService.PrdInstock(wmsPrdInstockInput, db); if (result2 != null) { Log.Information($"生产入库接口返回参数:${JsonConvert.SerializeObject(result2)}"); @@ -2473,98 +2480,111 @@ namespace Tnb.ProductionMgr else { Log.Information($"生产入库接口返回参数为null"); - + } + if (result2.code != HttpStatusCode.OK) { - throw Oops.Bah(result2.msg !=null ? result2.msg : "生产入库接口报错"); + throw Oops.Bah(result2.msg != null ? result2.msg : "生产入库接口报错"); } + //来源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(); - + .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 ?? ""; - ErpExtendField erpOrg = erpExtendFields.Find(x => x.table_id == (WmsWareHouseConst.AdministratorOrgId)); + 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 ?? ""; + ErpExtendField erpOrg = + erpExtendFields.Find(x => x.table_id == (WmsWareHouseConst.AdministratorOrgId)); string nowStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); - - + + List> requestData = new List>(); Dictionary erpRequestData = new Dictionary(); - erpRequestData.Add("auditer",erpCreateId); - erpRequestData.Add("billmaker",erpCreateId); - erpRequestData.Add("cdeptid","1001A1100000001JFOPQ");//部门先写死 - erpRequestData.Add("cdeptvid","0001A1100000000AOMIQ");//部门先写死 - erpRequestData.Add("taudittime",nowStr); - erpRequestData.Add("creationtime",nowStr); - erpRequestData.Add("creator",erpCreateId); - erpRequestData.Add("dbilldate",nowStr); - erpRequestData.Add("dmakedate",nowStr); - erpRequestData.Add("pk_org",erpOrg.pk_org); - erpRequestData.Add("pk_org_v",erpOrg.pk_org_v); - erpRequestData.Add("vtrantypecode","55A4-01"); - erpRequestData.Add("vtrantypeid","0001A11000000002LVX8"); - erpRequestData.Add("vdef1",null);//todo 倒冲日期 - erpRequestData.Add("vdef2",null); - erpRequestData.Add("report_id",report.id); - - + erpRequestData.Add("auditer", erpCreateId); + erpRequestData.Add("billmaker", erpCreateId); + erpRequestData.Add("cdeptid", "1001A1100000001JFOPQ"); //部门先写死 + erpRequestData.Add("cdeptvid", "0001A1100000000AOMIQ"); //部门先写死 + erpRequestData.Add("taudittime", nowStr); + erpRequestData.Add("creationtime", nowStr); + erpRequestData.Add("creator", erpCreateId); + erpRequestData.Add("dbilldate", nowStr); + erpRequestData.Add("dmakedate", nowStr); + erpRequestData.Add("pk_org", erpOrg.pk_org); + erpRequestData.Add("pk_org_v", erpOrg.pk_org_v); + erpRequestData.Add("vtrantypecode", "55A4-01"); + erpRequestData.Add("vtrantypeid", "0001A11000000002LVX8"); + erpRequestData.Add("vdef1", null); //todo 倒冲日期 + erpRequestData.Add("vdef2", null); + erpRequestData.Add("report_id", report.id); + + List> erpRequestDataDetails = new List>(); erpRequestDataDetails.Add(new Dictionary() { - ["cbdeptid"] = "1001A1100000001JFOPQ",//部门先写死 - ["cbdeptvid"] = "0001A1100000000AOMIQ",//部门先写死 - ["cbmainmaterialid"] = erpExtendFields.Find(x=>x.table_id==report.material_id)?.cmaterialoid ?? "", - ["cbmainmaterialvid"] = erpExtendFields.Find(x=>x.table_id==report.material_id)?.cmaterialvid ?? "", - ["cbmaterialid"] = erpExtendFields.Find(x=>x.table_id==report.material_id)?.cmaterialvid ?? "", - ["cbmaterialvid"] = erpExtendFields.Find(x=>x.table_id==report.material_id)?.cmaterialvid ?? "", + ["cbdeptid"] = "1001A1100000001JFOPQ", //部门先写死 + ["cbdeptvid"] = "0001A1100000000AOMIQ", //部门先写死 + ["cbmainmaterialid"] = + erpExtendFields.Find(x => x.table_id == report.material_id)?.cmaterialoid ?? "", + ["cbmainmaterialvid"] = + erpExtendFields.Find(x => x.table_id == report.material_id)?.cmaterialvid ?? "", + ["cbmaterialid"] = erpExtendFields.Find(x => x.table_id == report.material_id)?.cmaterialvid ?? + "", + ["cbmaterialvid"] = erpExtendFields.Find(x => x.table_id == report.material_id)?.cmaterialvid ?? + "", ["cbmobid"] = prdMo.erp_line_pk, ["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 == (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 ?? "", ["nbplanwrnum"] = report.reported_qty, ["nbwrnum"] = report.reported_qty, ["tbendtime"] = nowStr, - ["tbstarttime"] = prdMoTask.act_start_date!=null ? prdMoTask.act_start_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "", + ["tbstarttime"] = prdMoTask.act_start_date != null + ? prdMoTask.act_start_date.Value.ToString("yyyy-MM-dd HH:mm:ss") + : "", ["vbinbatchcode"] = report.batch, ["vbmobillcode"] = prdMo.mo_code, ["vbmorowno"] = prdMo.erp_lineno, ["vbrowno"] = prdMo.erp_lineno, - + }); - erpRequestData.Add("AggWrDtl",erpRequestDataDetails); + erpRequestData.Add("AggWrDtl", erpRequestDataDetails); requestData.Add(erpRequestData); - BasFactoryConfig config = await _db.Queryable().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.BIPURL); + BasFactoryConfig config = await _db.Queryable() + .FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.BIPURL); ThirdWebapiRecord thirdWebapiRecord = new ThirdWebapiRecord(); thirdWebapiRecord.id = SnowflakeIdHelper.NextId(); thirdWebapiRecord.third_name = WmsWareHouseConst.BIP; thirdWebapiRecord.name = "生产报告"; thirdWebapiRecord.method = "POST"; - thirdWebapiRecord.url = config.value+"uapws/rest/pwrnew/save"; - // thirdWebapiRecord.url = WmsWareHouseConst.BIP_DOMAIN+"uapws/rest/pwrnew/save"; + // thirdWebapiRecord.url = config.value + "uapws/rest/pwrnew/save"; + thirdWebapiRecord.url = WmsWareHouseConst.BIP_DOMAIN+"uapws/rest/pwrnew/save"; thirdWebapiRecord.request_data = JsonConvert.SerializeObject(erpRequestData); thirdWebapiRecord.create_time = DateTime.Now; thirdWebapiRecord.remark = $"载具编号:{report?.material_box_code ?? ""}"; await _db.Insertable(thirdWebapiRecord).ExecuteCommandAsync(); } - - + + if (prdMoTask.schedule_type == 2) { // Dictionary dicCommand2 = new(StringComparer.OrdinalIgnoreCase) @@ -2582,7 +2602,7 @@ namespace Tnb.ProductionMgr // { // throw Oops.Bah(x2ServerResult.Msg); // } - + // Dictionary dicCommand4 = new(StringComparer.OrdinalIgnoreCase) // { // ["DevName"] = "外包装箱码垛线", @@ -2601,6 +2621,20 @@ namespace Tnb.ProductionMgr // } } + // if (basMaterial.category_id.Contains("CGJCJ")) + // { + // EqpEquipment equipment = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.eqp_id); + // if (!string.IsNullOrEmpty(equipment.downmat_location_id)) + // { + // BasLocation downmatLocation = await _db.Queryable().SingleAsync(x=>x.id==equipment.downmat_location_id); + // await _db.Updateable() + // .SetColumns(x => x.location_code == downmatLocation.location_code) + // .SetColumns(x => x.location_id == downmatLocation.id) + // .Where(x => x.carry_code == report.material_box_code) + // .ExecuteCommandAsync(); + // } + // } + if (basMaterial.category_id.Contains("ZSJ") || basMaterial.category_id.Contains("DGJCJ")) { EqpEquipment equipment = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.eqp_id); diff --git a/QcMgr/Tnb.QcMgr/QcCheckTaskService.cs b/QcMgr/Tnb.QcMgr/QcCheckTaskService.cs index eb78f8e8..cbd52dc2 100644 --- a/QcMgr/Tnb.QcMgr/QcCheckTaskService.cs +++ b/QcMgr/Tnb.QcMgr/QcCheckTaskService.cs @@ -45,6 +45,7 @@ namespace Tnb.QcMgr private readonly IWmsSaleService _wmsSaleService; private readonly IWmsPurchaseService _wmsPurchaseService; private readonly IPrdMoTaskService _prdMoTaskService; + private static SemaphoreSlim prdreportSemaphore = new(1); public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); public QcCheckTaskService(ISqlSugarRepository repository, IUserManager userManager, @@ -257,6 +258,7 @@ namespace Tnb.QcMgr [HttpPost] public async Task SaveData(CheckTaskInput CheckTaskInput) { + await prdreportSemaphore.WaitAsync(); ISqlSugarClient db = _repository.AsSugarClient(); try { @@ -270,6 +272,8 @@ namespace Tnb.QcMgr { "checking", 32 }, }; QcCheckExecH QcCheckExecH = await db.Queryable().Where(p => p.id == CheckTaskInput.mainid).FirstAsync(); + if (QcCheckExecH == null) + throw Oops.Bah($"未找到质检任务:{CheckTaskInput.mainid}"); DictionaryTypeEntity DictionaryType = await db.Queryable().Where(p => p.FullName == "质检状态").FirstAsync(); DictionaryDataEntity DictionaryData = await db.Queryable().Where(p => p.DictionaryTypeId == DictionaryType.Id && p.FullName == "已完成").FirstAsync(); QcCheckExecH.checknum = CheckTaskInput.checknum; @@ -347,6 +351,19 @@ namespace Tnb.QcMgr QcCheckExecH.qty = int.Parse(CheckTaskInput.checknum) - rqty; QcCheckExecH.rqty = rqty; _ = await db.Updateable(QcCheckExecH).ExecuteCommandAsync(); + await db.Updateable() + .SetColumns(x => x.checknum == QcCheckExecH.checknum) + .SetColumns(x => x.status == QcCheckExecH.status) + .SetColumns(x => x.result == QcCheckExecH.result) + .SetColumns(x => x.execuser == QcCheckExecH.execuser) + .SetColumns(x => x.exectime == QcCheckExecH.exectime) + .SetColumns(x => x.check_type == QcCheckExecH.check_type) + .SetColumns(x => x.remark == QcCheckExecH.remark) + .SetColumns(x => x.attachment == QcCheckExecH.attachment) + .SetColumns(x => x.qty == QcCheckExecH.qty) + .SetColumns(x => x.rqty == QcCheckExecH.rqty) + .Where(x => x.id == CheckTaskInput.mainid) + .ExecuteCommandAsync(); _ = await db.Deleteable(QcCheckExecDdel).ExecuteCommandAsync(); _ = await db.Insertable(QcCheckExecDinsert).ExecuteCommandAsync(); //出厂检 @@ -450,6 +467,9 @@ namespace Tnb.QcMgr Log.Error(e.Message,e); throw Oops.Oh("执行失败:"+e.Message); } + finally{ + prdreportSemaphore.Release(); + } } /// diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdInstockHService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdInstockHService.cs index efe5aefd..398a62ca 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdInstockHService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdInstockHService.cs @@ -446,8 +446,8 @@ namespace Tnb.WarehouseMgr thirdWebapiRecord.third_name = WmsWareHouseConst.BIP; thirdWebapiRecord.name = "产成品入库"; thirdWebapiRecord.method = "POST"; - thirdWebapiRecord.url = config.value + "uapws/rest/productin/save"; - // thirdWebapiRecord.url = WmsWareHouseConst.BIP_DOMAIN + "uapws/rest/transIn/save"; + // thirdWebapiRecord.url = config.value + "uapws/rest/productin/save"; + thirdWebapiRecord.url = WmsWareHouseConst.BIP_DOMAIN + "uapws/rest/transIn/save"; thirdWebapiRecord.request_data = JsonConvert.SerializeObject(requestData); thirdWebapiRecord.create_time = DateTime.Now; thirdWebapiRecord.remark = $"载具编号:{prdReport?.material_box_code ?? ""}"; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSterilizationInstockHService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSterilizationInstockHService.cs index ddecbd8f..a9ddeccb 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSterilizationInstockHService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSterilizationInstockHService.cs @@ -180,6 +180,7 @@ namespace Tnb.WarehouseMgr ["pk_org"] = erpOrg.pk_org, ["pk_org_v"] = erpOrg.pk_org_v, ["vbatchcode"] = item.code_batch, + ["vdef19"] = item.code_batch, }); }