From 2a3a8aff11ad514b125e73bab6bbeee230c57e3e Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Thu, 5 Sep 2024 16:53:51 +0800 Subject: [PATCH 1/3] bug --- ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs | 4 ++-- ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs | 9 ++++++++- QcMgr/Tnb.QcMgr/QcCheckTaskResultService.cs | 6 ++++++ .../Tnb.WarehouseMgr/WmsSterilizationInstockHService.cs | 4 ++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 1d8c1d95..0cba0aad 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -2632,8 +2632,8 @@ namespace Tnb.ProductionMgr } catch (Exception e) { - Log.Error("提报入库任务下发失败", e); - throw new Exception("提报入库任务下发失败"); + Log.Error("提报入库任务下发失败:"+e.Message, e); + throw new Exception("提报入库任务下发失败:"+e.Message); } return "入库任务下发成功"; diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs index 0994360f..743a6227 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs @@ -8,6 +8,7 @@ using JNPF.DynamicApiController; using JNPF.FriendlyException; using JNPF.Systems.Entitys.Permission; using JNPF.Systems.Entitys.System; +using JNPF.Systems.Interfaces.Permission; using JNPF.Systems.Interfaces.System; using Mapster; using Microsoft.AspNetCore.Mvc; @@ -38,13 +39,16 @@ namespace Tnb.ProductionMgr private readonly ISqlSugarClient _db; private readonly IDictionaryDataService _dictionaryDataService; private readonly IUserManager _userManager; + private readonly IOrganizeService _organizeService; private static Dictionary> _dicWorkLine = new(); public PrdPackReportService(ISqlSugarRepository repository, IUserManager userManager, + IOrganizeService organizeService, IDictionaryDataService dictionaryDataService) { _db = repository.AsSugarClient(); _userManager = userManager; + _organizeService = organizeService; _dictionaryDataService = dictionaryDataService; } /// @@ -417,6 +421,8 @@ namespace Tnb.ProductionMgr } string userId = _userManager.UserId; + OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(_userManager.User.OrganizeId,DictConst.RegionCategoryWorklineCode); + string userWorklineId = workline?.Id ?? ""; string nowTime = DateTime.Now.ToString("HH:mm"); BasFactoryConfig config = await _db.Queryable().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.DAYNIGHTWORKTIME); Dictionary dayNightWorkTime = JsonConvert.DeserializeObject>(config.value); @@ -464,7 +470,8 @@ namespace Tnb.ProductionMgr .WhereIF(statusList.Count > 0, a => statusList.Contains(a.mo_task_status)) .WhereIF(status == "3" && start_time != null, a => a.act_end_date >= start_time) .WhereIF(status == "3" && end_time != null, a => a.act_end_date <= end_time) - .Where((a, b, c, d, e, f, g, h, j, k, l,m)=>(m.ManagerId==userId) + .WhereIF(!_userManager.IsAdministrator,(a, b, c, d, e, f, g, h, j, k, l,m)=>(m.ManagerId==userId) + || (j.mo_type==DictConst.PrdMoTypeBZ && !SqlFunc.IsNullOrEmpty(userWorklineId) && a.workline_id==userWorklineId) || (a.schedule_type==1 && a.mo_task_status==DictConst.ToBeStartedEnCode && moldUserIds.Contains(userId)) || (a.scheduling_class_type=="1" && twoDayFlag && a.dayshift_worker_id==userId) || (a.scheduling_class_type=="1" && twoNightFlag && a.nightshift_worker_id==userId) diff --git a/QcMgr/Tnb.QcMgr/QcCheckTaskResultService.cs b/QcMgr/Tnb.QcMgr/QcCheckTaskResultService.cs index 57a6ca24..c7aa2a83 100644 --- a/QcMgr/Tnb.QcMgr/QcCheckTaskResultService.cs +++ b/QcMgr/Tnb.QcMgr/QcCheckTaskResultService.cs @@ -14,6 +14,7 @@ using Tnb.BasicData.Entities; using Tnb.EquipMgr.Entities; using Tnb.ProductionMgr.Entities; using Tnb.QcMgr.Entities; +using Tnb.BasicData; namespace Tnb.QcMgr { /// @@ -99,6 +100,8 @@ namespace Tnb.QcMgr { "await", "待检" }, { "temporarily", "暂控" } }; + + PositionEntity positionEntity = await db.Queryable().Where(x=>x.Id==_userManager.User.PositionId).FirstAsync(); Dictionary? queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject>(input.queryJson) : new Dictionary(); string materialid = queryJson.ContainsKey("materialid") ? queryJson["materialid"].ToString() : ""; string checktype = queryJson.ContainsKey("checktype") ? queryJson["checktype"].ToString() : ""; @@ -117,6 +120,9 @@ namespace Tnb.QcMgr .LeftJoin((a, b, c, d, e) => a.execuser == e.Id) .LeftJoin((a,b,c,d,e,f)=>a.mo_task_code==f.mo_task_code) .LeftJoin((a,b,c,d,e,f,g)=>f.eqp_id==g.id) + .LeftJoin((a,b,c,d,e,f,g,h)=>d.OrganizeIdTree.Contains(h.Id) && h.Category == DictConst.RegionCategoryWorklineCode) + .LeftJoin((a,b,c,d,e,f,g,h,i)=>h.Id==i.OrganizeId) + .WhereIF(_userManager.LoginType=="app" && !_userManager.IsAdministrator,(a,b,c,d,e,f,g,h,i)=>i.EnCode==positionEntity.EnCode) .WhereIF(!string.IsNullOrEmpty(materialid), (a, b, c, d, e) => a.materialid == materialid) .WhereIF(!string.IsNullOrEmpty(checktype), (a, b, c, d, e) => a.checktype == checktype) .WhereIF(!string.IsNullOrEmpty(status), (a, b, c, d, e) => a.status == status) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSterilizationInstockHService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSterilizationInstockHService.cs index cd4c9543..b61eac0d 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSterilizationInstockHService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSterilizationInstockHService.cs @@ -70,6 +70,7 @@ namespace Tnb.WarehouseMgr BasLocation endLocation = await _db.Queryable().Where(r => r.id == input.wmsDistaskH.endlocation_id).FirstAsync(); string outWhid = ""; + string inWhid = ""; string outDeptid = ""; string outDeptvid = ""; string inDeptid = ""; @@ -80,6 +81,7 @@ namespace Tnb.WarehouseMgr if (endLocation.wh_id == WmsWareHouseConst.WAREHOUSE_MJC_ID) { outWhid = WmsWareHouseConst.bipwarehouseid_bz; + inWhid = WmsWareHouseConst.bipwarehouseid_mj; outDeptid = WmsWareHouseConst.sichangqushengchanbu_id; outDeptvid = WmsWareHouseConst.sichangqushengchanbu_vid; inDeptid = WmsWareHouseConst.sichangqucangku_id; @@ -91,6 +93,7 @@ namespace Tnb.WarehouseMgr else if (endLocation.wh_id == WmsWareHouseConst.WAREHOUSE_CP_ID) { outWhid = WmsWareHouseConst.bipwarehouseid_mj; + inWhid = WmsWareHouseConst.bipwarehouseid_cp; outDeptid = WmsWareHouseConst.sichangqucangku_id; outDeptvid = WmsWareHouseConst.sichangqucangku_vid; inDeptid = WmsWareHouseConst.sichangqucangku_id; @@ -145,6 +148,7 @@ namespace Tnb.WarehouseMgr erpRequestData.Add("creationtime", nowStr); erpRequestData.Add("creator", erpCreateId); erpRequestData.Add("cwarehouseid", outWhid);//先写死 + erpRequestData.Add("cotherwhid", inWhid);//先写死 erpRequestData.Add("dbilldate", wmsRawmatTransferoutstockH.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss")); erpRequestData.Add("dmakedate", nowStr); erpRequestData.Add("dshldarrivedate", nowStr); From 2c7fd13e6ba83d9dde8cc8d2b1ff7fe157c2b994 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Thu, 5 Sep 2024 17:10:12 +0800 Subject: [PATCH 2/3] bug --- .../Tnb.ProductionMgr/PrdMoTaskService.cs | 18 +++++++++--------- .../Tnb.WarehouseMgr/WmsPrdInstockHService.cs | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 0cba0aad..1b3a0a55 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -2482,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.Add(report.unit_id); + 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 ?? ""; @@ -2534,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 == 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 ?? "", ["nbplanwrnum"] = report.reported_qty, ["nbwrnum"] = report.reported_qty, ["tbendtime"] = nowStr, diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdInstockHService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdInstockHService.cs index 31e6037d..86711bb4 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdInstockHService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdInstockHService.cs @@ -358,12 +358,12 @@ namespace Tnb.WarehouseMgr List materialIds = Arrays.AsList(instock.material_id); List unitIds = allInstockDetails.Select(x => x.unit_id).Distinct().ToList(); - // List unitCodes = allInstockDetails.Select(x => x.unit_id).Distinct().ToList(); - // List unitDatas = await _db.Queryable() - // .LeftJoin((x, y) => x.Id == y.DictionaryTypeId) - // .Where((x, y) => x.EnCode == DictConst.MeasurementUnit && unitCodes.Contains(y.EnCode)) - // .Select((x, y) => y) - // .ToListAsync(); + List unitCodes = allInstockDetails.Select(x => x.unit_id).Distinct().ToList(); + List unitDatas = await _db.Queryable() + .LeftJoin((x, y) => x.Id == y.DictionaryTypeId) + .Where((x, y) => x.EnCode == DictConst.MeasurementUnit && unitCodes.Contains(y.EnCode)) + .Select((x, y) => y) + .ToListAsync(); List erpWarehouserelaHs = await _db.Queryable().Where(x=>x.id!=null).ToListAsync(); string userId = instock?.create_id ?? WmsWareHouseConst.AdministratorUserId; @@ -373,8 +373,8 @@ namespace Tnb.WarehouseMgr tableIds.Add(WmsWareHouseConst.AdministratorOrgId); tableIds.AddRange(materialIds); tableIds.Add(supplierId); - // tableIds.AddRange(unitDatas.Select(x => x.Id).ToList()); - tableIds.AddRange(unitIds); + tableIds.AddRange(unitDatas.Select(x => x.Id).ToList()); + // tableIds.AddRange(unitIds); List erpExtendFields = await _db.Queryable().Where(x => tableIds.Contains(x.table_id)).ToListAsync(); string erpCreateId = erpExtendFields.Find(x => x.table_id == userId)?.user_id ?? ""; @@ -422,7 +422,7 @@ namespace Tnb.WarehouseMgr ["crowno"] = (allInstockDetails.FindIndex(x => x.id == item.id) + 1) * 10, ["csourcebillhid"] = prdReport?.erp_pk_wr ?? "", ["csourcebillbid"] = prdReport?.erp_pk_wr_product ?? "", - ["cunitid"] = erpExtendFields.Find(x => x.table_id == item.unit_id)?.cunitid ?? "", + ["cunitid"] = erpExtendFields.Find(x => x.table_id == (unitDatas.Find(x=>x.EnCode==item.unit_id)?.Id ?? ""))?.cunitid ?? "", ["cvendorid"] = erpExtendFields.Find(x => x.table_id == supplierId)?.supplier_id ?? "", ["cvendorvid"] = erpExtendFields.Find(x => x.table_id == supplierId)?.supplier_vid ?? "", ["dbizdate"] = instock.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"), From d085ed872d610df8aa7996504f80695c10c37fd1 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Thu, 5 Sep 2024 17:24:27 +0800 Subject: [PATCH 3/3] bug --- ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs | 2 +- ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs b/ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs index cf5e9f8b..155e2e90 100644 --- a/ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs @@ -144,7 +144,7 @@ namespace Tnb.ProductionMgr item.erp_mo_pk = item.erp_mo_pk; item.erp_line_pk = item.erp_line_pk; item.erp_lineno = item.erp_lineno; - item.unit_id = unitDic?.Id ?? item.unit_id; + item.unit_id = unitDic?.EnCode ?? item.unit_id; moList.Add(item); } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs index 146506aa..45417d4d 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs @@ -138,7 +138,7 @@ namespace Tnb.ProductionMgr SqlSugarPagedList result = await db.Queryable() .LeftJoin((a, b) => a.material_id == b.id) .LeftJoin((a, b, c) => c.EnCode == DictConst.MeasurementUnit) - .LeftJoin((a, b, c, d) => c.Id == d.DictionaryTypeId && a.unit_id == d.Id) + .LeftJoin((a, b, c, d) => c.Id == d.DictionaryTypeId && a.unit_id == d.EnCode) .LeftJoin((a, b, c, d, e) => a.mo_status == e.Id) .LeftJoin((a, b, c, d, e, f) => a.mo_type == f.Id) .WhereIF(!string.IsNullOrEmpty(moCode), (a, b, c, d, e) => a.mo_code.Contains(moCode))