From e16a2dfe37dce003a4ed470b674ad8ed6a23b6cf Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Wed, 17 Jul 2024 17:22:31 +0800 Subject: [PATCH 1/2] bug --- .../Tnb.ProductionMgr/PrdMoTaskService.cs | 34 +++++++-------- .../ProductionReportRecordService.cs | 42 ++++++++++--------- .../Tnb.ProductionMgr/TimeWorkService.cs | 16 ++++++- .../Consts/WmsWareHouseConst.cs | 4 -- .../Tnb.WarehouseMgr/WareHouseService.cs | 4 +- .../WmsMaterialTransferService.cs | 4 +- 6 files changed, 58 insertions(+), 46 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 822847eb..67cc6407 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -1724,7 +1724,7 @@ namespace Tnb.ProductionMgr // } // report.warehouse_id = WmsWareHouseConst.WAREHOUSE_JXK_ID; - report.warehouse_id = WmsWareHouseConst.WAREHOUSE_SLDMJC_ID; + report.warehouse_id = WmsWareHouseConst.WAREHOUSE_DMJC_ID; Dictionary worklineWarehouseDic = new Dictionary() { [WmsWareHouseConst.XUELUGUAN1XIAN] = "ZZ-01-02", @@ -2129,22 +2129,22 @@ namespace Tnb.ProductionMgr // throw Oops.Bah(x2ServerResult.Msg); // } - Dictionary dicCommand4 = new(StringComparer.OrdinalIgnoreCase) - { - ["DevName"] = "外包装箱码垛线", - ["token"] = _eleCtlCfg.token, - ["TagName"] = dic2[prdMoTask.workline_id], - ["Value"] = "0", - }; - - Log.Information($"清除提报码垛数参数:{JsonConvert.SerializeObject(dicCommand4)}"); - string responseresult2 = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand4); - Log.Information($"清除提报码垛数成返回结果:{responseresult2}"); - X2ServerResult x2ServerResult2 = JsonConvert.DeserializeObject(responseresult2); - if (x2ServerResult2.Result != X2ServerResult.Ok) - { - throw Oops.Bah(x2ServerResult2.Msg); - } + // Dictionary dicCommand4 = new(StringComparer.OrdinalIgnoreCase) + // { + // ["DevName"] = "外包装箱码垛线", + // ["token"] = _eleCtlCfg.token, + // ["TagName"] = dic2[prdMoTask.workline_id], + // ["Value"] = "0", + // }; + // + // Log.Information($"清除提报码垛数参数:{JsonConvert.SerializeObject(dicCommand4)}"); + // string responseresult2 = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand4); + // Log.Information($"清除提报码垛数返回结果:{responseresult2}"); + // X2ServerResult x2ServerResult2 = JsonConvert.DeserializeObject(responseresult2); + // if (x2ServerResult2.Result != X2ServerResult.Ok) + // { + // throw Oops.Bah(x2ServerResult2.Msg); + // } } if (basMaterial.category_id.Contains("ZSJ") || basMaterial.category_id.Contains("DGJCJ")) diff --git a/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs b/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs index 770a91cc..d6083aef 100644 --- a/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs @@ -13,6 +13,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using SqlSugar; using Tnb.BasicData; +using Tnb.BasicData.Entities; using Tnb.ProductionMgr.Entities; using Tnb.ProductionMgr.Entities.Dto; using Tnb.ProductionMgr.Interfaces; @@ -89,27 +90,28 @@ namespace Tnb.ProductionMgr } } ISqlSugarClient db = _repository.AsSugarClient(); - SqlSugarPagedList result = await db.Queryable() - .LeftJoin((a, b) => a.mo_task_type == b.Id) - .LeftJoin((a, b, c) => a.status == c.EnCode) - .LeftJoin((a, b, c, d) => a.mo_task_id == d.id) + SqlSugarPagedList result = await db.Queryable() + .LeftJoin((a,b)=>a.mo_id==b.id) + .LeftJoin((a, b,c) => b.mo_type == c.Id) + .LeftJoin((a, b, c,d) => a.mo_task_status == d.EnCode && d.DictionaryTypeId==DictConst.PrdTaskStatusTypeId) + .LeftJoin((a,b,c,d,e)=>a.material_id==e.id) .WhereIF(!string.IsNullOrEmpty(moTaskCode), (a, b, c) => a.mo_task_code.Contains(moTaskCode)) - .Select((a, b, c, d) => new ReportRecordListOutput + .Select((a, b, c, d,e) => new ReportRecordListOutput { id = a.id, - masterial_code = a.masterial_code, - mo_code = a.mo_code, - masterial_name = a.masterial_name, + masterial_code = e.code, + mo_code = b.mo_code, + masterial_name = e.name, mo_task_code = a.mo_task_code, mo_task_id = a.mo_task_code, - mo_task_id_id = a.mo_task_id, - mo_task_type = b.FullName, - plan_end_date = a.plan_end_date == null ? "" : a.plan_end_date.Value.ToString("yyyy-mm-dd"), - plan_start_date = a.plan_start_date == null ? "" : a.plan_start_date.Value.ToString("yyyy-mm-dd"), - plan_qty = d.scheduled_qty, + mo_task_id_id = a.id, + mo_task_type = c.FullName, + plan_end_date = a.estimated_end_date == null ? "" : a.estimated_end_date.Value.ToString("yyyy-mm-dd"), + plan_start_date = a.estimated_start_date == null ? "" : a.estimated_start_date.Value.ToString("yyyy-mm-dd"), + plan_qty = a.scheduled_qty, reported_work_qty = a.reported_work_qty, - completed_qty = SqlFunc.IsNull(d.reported_work_qty, 0) + SqlFunc.IsNull(d.scrap_qty, 0), - status = c.FullName, + completed_qty = SqlFunc.IsNull(a.reported_work_qty, 0) + SqlFunc.IsNull(a.scrap_qty, 0), + status = d.FullName, tablefield107 = SqlFunc.Subqueryable() .LeftJoin((x, y) => x.create_id == y.Id) .Where(x => x.mo_task_code == a.mo_task_code).ToList((x, y) => new ReportRecordListChildrenOutput @@ -149,11 +151,11 @@ namespace Tnb.ProductionMgr _ = await db.Insertable(prdReports).ExecuteCommandAsync(); - int? sum = prdReports.Sum(x => x.reported_qty); - _ = await db.Updateable() - .SetColumns(x => x.completed_qty == x.completed_qty + sum) - .SetColumns(x => x.reported_work_qty == x.reported_work_qty + sum) - .Where(x => x.id == input.data["id"].ToString()).ExecuteCommandAsync(); + // int? sum = prdReports.Sum(x => x.reported_qty); + // _ = await db.Updateable() + // .SetColumns(x => x.completed_qty == x.completed_qty + sum) + // .SetColumns(x => x.reported_work_qty == x.reported_work_qty + sum) + // .Where(x => x.id == input.data["id"].ToString()).ExecuteCommandAsync(); }); diff --git a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs index 51079787..8956602b 100644 --- a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs @@ -513,7 +513,10 @@ namespace Tnb.ProductionMgr return msg; } - + /// + /// 自动提报 + /// + /// [HttpGet] [AllowAnonymous] public async Task AutoPrdReport() @@ -655,6 +658,17 @@ namespace Tnb.ProductionMgr return "true"; } + + /// + /// 同步基础数据 + /// + /// + [HttpGet] + [AllowAnonymous] + public async Task SyncBaseData() + { + return "true"; + } } } \ No newline at end of file diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs index da13a785..8b3242dc 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs @@ -27,10 +27,6 @@ /// public const string WAREHOUSE_ZCC_ID = "33780009364245"; /// - /// 四楼待灭菌仓 - /// - public const string WAREHOUSE_SLDMJC_ID = "35412479754517"; - /// /// 四楼解析库 /// public const string WAREHOUSE_JXK_ID = "26103367464997"; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 2fa300cd..651104eb 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -2396,8 +2396,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.erp_line_pk ?? "", - ["cgeneralhid"] = wmsMaterialTransfer.erp_pk ?? "", + ["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, diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs index 17e3d2d4..5ff9d083 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs @@ -678,8 +678,8 @@ namespace Tnb.WarehouseMgr ["corpoid"] = erpOrg.corpoid, ["corpvid"] = erpOrg.corpvid, ["crowno"] = (dList.FindIndex(x=>x.id==wmsMaterialTransferd.id)+1) * 10, - ["csourcebillbid"] = wmsMaterialTransferd.erp_line_pk ?? "", - ["csourcebillhid"] = wmsMaterialTransfer.erp_pk ?? "", + ["csourcebillbid"] = wmsMaterialTransferd.erp_line_pk, + ["csourcebillhid"] = wmsMaterialTransfer.erp_pk, ["cunitid"] = erpExtendFields.Find(x=>x.table_id==unitData.Id)?.cunitid ?? "", ["cvendorid"] = "", ["cvendorvid"] = "", From d8a9562ffa1d72c5ffd8e1c0fc3b247f086fb9b4 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Thu, 18 Jul 2024 08:40:24 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/ErpBdMaterial.cs | 22 +++++ .../Extensions/ConfigureSqlSugarExtensions.cs | 20 +++++ .../Options/ConnectionStringsOptions.cs | 2 + system/Tnb.Systems/Common/TestService.cs | 84 ++++++++++++++++++- 4 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpBdMaterial.cs diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpBdMaterial.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpBdMaterial.cs new file mode 100644 index 00000000..04eb9407 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpBdMaterial.cs @@ -0,0 +1,22 @@ +using JNPF.Common.Contracts; +using SqlSugar; + +namespace Tnb.ProductionMgr.Entities.Entity +{ + [SugarTable("ERP_BD_MATERIAL")] + public class ErpBdMaterial: BaseEntity + { + public string CODE { get; set; } + public string PK_ORG { get; set; } + public string NAME { get; set; } + public string MATERIALSPEC { get; set; } + public string MATERIALTYPE { get; set; } + public string PK_MEASDOC { get; set; } + public string MEASRATE { get; set; } + public string FMEASDOC { get; set; } + public string VID { get; set; } + public string MEANAME { get; set; } + public string FMEANAME { get; set; } + public string AID { get; set; } + } +} \ No newline at end of file diff --git a/apihost/Tnb.API.Entry/Extensions/ConfigureSqlSugarExtensions.cs b/apihost/Tnb.API.Entry/Extensions/ConfigureSqlSugarExtensions.cs index 2204c17e..77a29dcf 100644 --- a/apihost/Tnb.API.Entry/Extensions/ConfigureSqlSugarExtensions.cs +++ b/apihost/Tnb.API.Entry/Extensions/ConfigureSqlSugarExtensions.cs @@ -33,6 +33,26 @@ public static class ConfigureSqlSugarExtensions }, }); + foreach (var item in conn.ConfigList) + { + connectConfigList.Add(new ConnectionConfig + { + ConnectionString = item.connectionStr, + DbType = item.dbType, + IsAutoCloseConnection = true, + ConfigId = item.ServiceName, + InitKeyType = InitKeyType.Attribute, + MoreSettings = new ConnMoreSettings() + { + IsAutoRemoveDataCache = true, // 自动清理缓存 + IsAutoToUpper = false, + //PgSqlIsAutoToLower = false, + DisableNvarchar = true + }, + }); + + } + services.AddSqlSugar(connectConfigList, client => { //connectConfigList.ForEach(config => diff --git a/common/Tnb.SqlSugar/Options/ConnectionStringsOptions.cs b/common/Tnb.SqlSugar/Options/ConnectionStringsOptions.cs index 90bba155..233fb5e8 100644 --- a/common/Tnb.SqlSugar/Options/ConnectionStringsOptions.cs +++ b/common/Tnb.SqlSugar/Options/ConnectionStringsOptions.cs @@ -48,4 +48,6 @@ public sealed class ConnectionStringsOptions : IConfigurableOptions public string DefaultConnection { get; set; } public string ConnectString { get { return string.Format(DefaultConnection, Host, Port, DBName, UserName, Password); } } + + public List ConfigList { get; set; } } \ No newline at end of file diff --git a/system/Tnb.Systems/Common/TestService.cs b/system/Tnb.Systems/Common/TestService.cs index 048e0cb9..f5efec4a 100644 --- a/system/Tnb.Systems/Common/TestService.cs +++ b/system/Tnb.Systems/Common/TestService.cs @@ -11,6 +11,7 @@ using JNPF.Systems.Entitys.Permission; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; using Npgsql.TypeHandlers; using SqlSugar; using Tnb.ProductionMgr.Entities.Entity; @@ -93,7 +94,9 @@ public class TestService : IDynamicApiController, ITransient [AllowAnonymous] public string test1() { - return "测试成功"; + var mysqlDb = _sugar.GetConnection("erpdb"); + List list = mysqlDb.Queryable().ToList(); + return JsonConvert.SerializeObject(list); } [HttpGet] @@ -150,4 +153,83 @@ public class TestService : IDynamicApiController, ITransient public string name { get; set; } } + [SugarTable("bas_factory_config")] + public partial class BasFactoryConfig2 : BaseEntity + { + public BasFactoryConfig2() + { + id = SnowflakeIdHelper.NextId(); + } + + /// + /// 名称 + /// + public string name { get; set; } = string.Empty; + + /// + /// key + /// + public string code { get; set; } = string.Empty; + + /// + /// 值 + /// + public string value { get; set; } = string.Empty; + + /// + /// 是否启用 + /// + public int enabled { get; set; } + + /// + /// 备注 + /// + public string? remark { get; set; } + + /// + /// 创建用户 + /// + public string? create_id { get; set; } + + /// + /// 创建时间 + /// + public DateTime? create_time { get; set; } + + /// + /// 修改用户 + /// + public string? modify_id { get; set; } + + /// + /// 修改时间 + /// + public DateTime? modify_time { get; set; } + + /// + /// 所属组织 + /// + public string? org_id { get; set; } + + /// + /// 排序 + /// + public long? ordinal { get; set; } + + /// + /// 是否系统 + /// + public int? is_system { get; set; } + + /// + /// 流程任务Id + /// + public string? f_flowtaskid { get; set; } + + /// + /// 流程引擎Id + /// + public string? f_flowid { get; set; } + } + }