From d7469c1bc95a53d528f5e3253709ce2f1c49ac5d Mon Sep 17 00:00:00 2001 From: fei550 <1420031550@qq.com> Date: Tue, 17 Jun 2025 09:21:36 +0800 Subject: [PATCH 1/3] 1 --- .vs/SGGL_SeDin_New/v17/.wsuo | Bin 74752 -> 74752 bytes .vs/SGGL_SeDin_New/v17/DocumentLayout.json | 2 +- .../HSSE/CostGoods/CostManage.aspx | 4 ++-- SGGL/FineUIPro.Web/indexProject.aspx | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.vs/SGGL_SeDin_New/v17/.wsuo b/.vs/SGGL_SeDin_New/v17/.wsuo index 0d938fb0fac99d09557367a015087a6edc1d3728..6382df2c8691b7361151bf8966e6a1636516e255 100644 GIT binary patch delta 973 zcma)4&ubGw6wXXGzjU|8ByDJ$N(r(4psPt{lWdB%qCr%|ZPZ?*hjh0=EEKflpgq*k zgCgY6WV|Xk|AC!=f5i4^^}Qr3X;JXOxBKRsw{PC}%{F^Vv#0DWljz6l zG!52P-R(EuraCrWZ916d3(3BWRpX~<8GtdaW( z2mzM{oCX+x6krd4`xxWH{2YI#B->AwNp(oXM~V)yl7CQ`W&&FRBmh_2)p%qPk|n?d zEMzpWN`jwm9{f`bcSDIMVJOGZ`dzUzgeM23;mDpG9N8NezrjE`CjgkE9DIB6M-K3j zb~X8*a?tc6a>n{{A~L|cG$-9Lm2_eiH3(&%FL*b+5wkRcXM5-NSr^$;Ba`34E+o{DC5!b1>Me(~k{p79!Nhj4iB7?gr@Ca|$ySag%Gc5u2XQ+5Y#fGw9yY0{9 z%TB3OHf+6|X9eA0WmC6{Wm~T^hpm|oGg!`+n@%ktzw9z1Ho~Gt#a5VquEk``zC`pL zuonNjhhPip6|!-OREqbL8gB6@TdRgNF;byve^mzMy)S agYL+~UFsLxlrJ7k@%L|oa`x4acfSE&hG-!G delta 915 zcma)4%Wl&^6wQo1PTblhty3D&mPJ%TkZLIplSDvEAX!ie;fBWsp*AK?6&6T-aFi>sfT(}C7~T3@d={x0qVtVTAf<)r>nGwbKIL=N18NNP5U#pj>Ku}Bc$Gk-RKM diff --git a/.vs/SGGL_SeDin_New/v17/DocumentLayout.json b/.vs/SGGL_SeDin_New/v17/DocumentLayout.json index 4a8a0ea7..290e6c8a 100644 --- a/.vs/SGGL_SeDin_New/v17/DocumentLayout.json +++ b/.vs/SGGL_SeDin_New/v17/DocumentLayout.json @@ -77,7 +77,7 @@ }, { "$type": "Bookmark", - "Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}" + "Name": "ST:128:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}" } ] } diff --git a/SGGL/FineUIPro.Web/HSSE/CostGoods/CostManage.aspx b/SGGL/FineUIPro.Web/HSSE/CostGoods/CostManage.aspx index 798ec89a..d1691c40 100644 --- a/SGGL/FineUIPro.Web/HSSE/CostGoods/CostManage.aspx +++ b/SGGL/FineUIPro.Web/HSSE/CostGoods/CostManage.aspx @@ -32,8 +32,8 @@ - - + + diff --git a/SGGL/FineUIPro.Web/indexProject.aspx b/SGGL/FineUIPro.Web/indexProject.aspx index 040c0e39..a3e8ba58 100644 --- a/SGGL/FineUIPro.Web/indexProject.aspx +++ b/SGGL/FineUIPro.Web/indexProject.aspx @@ -582,6 +582,8 @@ // refreshWhenExist: 添加选项卡时,如果选项卡已经存在,是否刷新内部IFrame // iconFont: 选项卡图标字体 function addExampleTab(tabOptions) { + debugger; + if (typeof (tabOptions) === 'string') { tabOptions = { id: arguments[0], From 6f5bf5da0356fa1e77e3b0f7c59a5a4d71f02a09 Mon Sep 17 00:00:00 2001 From: fei550 <1420031550@qq.com> Date: Tue, 17 Jun 2025 10:25:36 +0800 Subject: [PATCH 2/3] 1 --- SGGL/FineUIPro.Web/FineUIPro.Web.csproj | 2 +- SGGL/FineUIPro.Web/HSSE/CostGoods/CostManage.aspx.cs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj index c3f28f23..b54734ff 100644 --- a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj +++ b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj @@ -16591,7 +16591,7 @@ - + diff --git a/SGGL/FineUIPro.Web/HSSE/CostGoods/CostManage.aspx.cs b/SGGL/FineUIPro.Web/HSSE/CostGoods/CostManage.aspx.cs index 03c9f175..d2d9feea 100644 --- a/SGGL/FineUIPro.Web/HSSE/CostGoods/CostManage.aspx.cs +++ b/SGGL/FineUIPro.Web/HSSE/CostGoods/CostManage.aspx.cs @@ -349,6 +349,14 @@ namespace FineUIPro.Web.HSSE.CostGoods else { string messaage = CostManageService.PushDataToHSE(this.CurrUser.LoginProjectId, costManage.ContractNum); + if (string.IsNullOrEmpty(messaage)) + { + Alert.ShowInTop("推送成功!", MessageBoxIcon.Success); + } + else + { + Alert.ShowInTop(messaage, MessageBoxIcon.Warning); + } } From ded4928aa96be75436bc361a4c7ecb79001a7497 Mon Sep 17 00:00:00 2001 From: fei550 <1420031550@qq.com> Date: Wed, 18 Jun 2025 10:38:46 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=B4=B9=E7=94=A8=E6=8E=A5=E5=8F=A3PU?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SGGL/BLL/Common/Funs.cs | 22 ++++ SGGL/BLL/HSSE/CostGoods/CostManageService.cs | 123 +++++++++++------- .../HSSE/CostGoods/CostManage.aspx.cs | 2 +- 3 files changed, 99 insertions(+), 48 deletions(-) diff --git a/SGGL/BLL/Common/Funs.cs b/SGGL/BLL/Common/Funs.cs index 06a92c99..ac8c7aa8 100644 --- a/SGGL/BLL/Common/Funs.cs +++ b/SGGL/BLL/Common/Funs.cs @@ -1446,6 +1446,28 @@ namespace BLL return response.Content; } + public static string RequestPost(string Baseurl, Dictionary Token, string JsonBody) + { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + + var client = new RestClient(Baseurl); + client.Timeout = -1; + var request = new RestRequest(Method.POST); + foreach (var item in Token) + { + request.AddHeader(item.Key, item.Value); + } + request.AddHeader("ClientId", SysConstSetService.ClientId); + request.AddHeader("OperationCode", Baseurl.Substring(Baseurl.LastIndexOf("/", StringComparison.Ordinal) + 1)); + if (!string.IsNullOrEmpty(JsonBody)) + { + request.AddJsonBody(JsonBody); + } + + IRestResponse response = client.Execute(request); + return response.Content; + } + /// /// ڼֵ /// diff --git a/SGGL/BLL/HSSE/CostGoods/CostManageService.cs b/SGGL/BLL/HSSE/CostGoods/CostManageService.cs index fab4c19f..f0f9faef 100644 --- a/SGGL/BLL/HSSE/CostGoods/CostManageService.cs +++ b/SGGL/BLL/HSSE/CostGoods/CostManageService.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Numerics; +using WIA; namespace BLL { @@ -373,74 +374,89 @@ namespace BLL } - /// 推送数据到HSE系统 - /// - public static string PushDataToHSE(string projectId, string contractNum) + public static string PushDataToHSE(string projectId, string contractNum,string costManageId) { try { string message = ""; // 查询当前合同所有审核通过的数据 var costData = from x in Funs.DB.CostGoods_CostManage - where x.ProjectId == projectId && x.ContractNum == contractNum && x.States == Const.State_2 - orderby x.CostManageDate descending - select x; - - if (costData.Any()) + where x.ProjectId == projectId && x.ContractNum == contractNum && x.States == Const.State_2 + orderby x.CostManageDate descending + select x; + var projectModel=ProjectService.GetProjectByProjectId(projectId); + var contractModel = CostManageService.GetCostManageById(costManageId); + decimal totalAmount = costData.Sum(x => x.SumMoney ?? 0); + var files = new List(); + if (contractModel!=null) { - // 获取所有附件文件 - var files = new List(); - decimal totalAmount = 0; - - foreach (var item in costData) + var fileDetails = GetBase64FilesWithDetails(contractModel.CostManageId); + if (fileDetails != null && fileDetails.Count > 0) { - var fileDetails = GetBase64FilesWithDetails(item.CostManageId); - if (fileDetails != null && fileDetails.Count > 0) - { - files.AddRange(fileDetails); - totalAmount += item.SumMoney ?? 0; - } + files.AddRange(fileDetails); } // 构建请求体 - var requestBody = new + var requestBody = new { - projectId = projectId, + projectNumber = projectModel.ProjectCode, contractNo = contractNum, amountHSE = totalAmount.ToString(), files = files }; var jsonBody = JsonConvert.SerializeObject(requestBody); + // 调用HSE接口推送数据 - // TODO: 实现实际的HSE接口调用逻辑 - var url="http://172.29.60.33:8080"; - var requestGetTokenUrl = url + "/api/Token/GetToken"; - string requestGetTokenBody = "{\r\n\r\n\"username\": \"coadmin\",\r\n\r\n\"password\": \"coadminPu@2025\"\r\n\r\n}"; + var url = "http://172.29.60.33:8080"; + var requestGetTokenUrl = url + "/auth/getToken"; + string requestGetTokenBody = "{\"username\": \"coadmin\",\"password\": \"coadminPu@2025\"}"; var response = Funs.RequestPost(requestGetTokenUrl, "", requestGetTokenBody); var responseStr = JsonConvert.DeserializeObject(response); - if (responseStr == null || responseStr["data"].ToString() != "200") + APICommonService.SaveSysHttpLog("PU_Token", requestGetTokenUrl, response); + + if (responseStr == null || responseStr["code"]?.ToString() != "200" || responseStr["data"] == null) { message = "获取Pu系统Token失败"; + return message; + } - } - string accessToken = responseStr["data"]["token"].ToString(); - var requestUrl = url + "/api/PuPayCraftAmount/AddPuPayCraftAmount"; - var responseHSE = Funs.RequestPost(requestUrl, accessToken, jsonBody); + string accessToken = responseStr["data"]["token"]?.ToString(); + if (string.IsNullOrEmpty(accessToken)) + { + message = "获取Pu系统Token失败,Token为空"; + return message; + } + Dictionary headers = new Dictionary(); + headers.Add("Authorization", "Bearer " + accessToken); + var requestUrl = url + "/pu_api/payCraftAmountToHSE/add"; + APICommonService.SaveSysHttpLog("PU_AddPuPayCraftAmount", requestUrl, jsonBody, "Requset"); + var responseHSE = Funs.RequestPost(requestUrl, headers, jsonBody); var responseHSEStr = JsonConvert.DeserializeObject(responseHSE); - if (responseHSEStr == null || responseHSEStr["data"].ToString()!= "200") + APICommonService.SaveSysHttpLog("PU_AddPuPayCraftAmount", requestUrl, responseHSE, "Response"); + if (responseHSEStr == null) { message = "推送数据到HSE系统失败"; + return message; + } + else if (responseHSEStr["code"]?.ToString() != "200") + { + message = responseHSEStr["message"]?.ToString(); + return message; + } + else + { + message = ""; + return message; } } - return message; + return message; } catch (Exception ex) { // 记录错误日志 ErrLogInfo.WriteLog(ex.Message, ex.StackTrace); - return "推送数据失败"+ex.Message; - + return "推送数据失败"; } } @@ -456,22 +472,35 @@ namespace BLL var attachments = AttachFileService.getFileUrl(costManageId); if (!string.IsNullOrEmpty(attachments)) - { - string filePath=Funs.RootPath+attachments.Split(',')[0]; - FileInfo file = new FileInfo(filePath); - byte[] fileBytes = File.ReadAllBytes(filePath); - string base64Content = Convert.ToBase64String(fileBytes); - - result.Add(new Model.PuPayCraftAmountFileInput + { + string[] filePaths = attachments.Split(','); + foreach (var filePath in filePaths) { - name = file.Name, - content = base64Content, - thisamount = costManage?.SumMoney?.ToString() ?? "0", - date = costManage?.CostManageDate?.ToString("yyyy-MM-dd") ?? DateTime.Now.ToString("yyyy-MM-dd") - }); + string fullPath = Funs.RootPath + filePath; + if (File.Exists(fullPath)) + { + FileInfo file = new FileInfo(fullPath); + byte[] fileBytes = File.ReadAllBytes(fullPath); + string base64Content = Convert.ToBase64String(fileBytes); + + result.Add(new Model.PuPayCraftAmountFileInput + { + name = file.Name, + content = base64Content, + thisamount = costManage?.SumMoney?.ToString() ?? "0", + date = costManage?.CostManageDate?.ToString("yyyy-MM-dd") ?? DateTime.Now.ToString("yyyy-MM-dd") + }); + } + else + { + /* message += $"附件文件路径 {fullPath} 不存在!"; + ErrLogInfo.WriteLog(message, $"File not found: {fullPath}");*/ + } + } } - + return result; } + } } diff --git a/SGGL/FineUIPro.Web/HSSE/CostGoods/CostManage.aspx.cs b/SGGL/FineUIPro.Web/HSSE/CostGoods/CostManage.aspx.cs index d2d9feea..2b427a92 100644 --- a/SGGL/FineUIPro.Web/HSSE/CostGoods/CostManage.aspx.cs +++ b/SGGL/FineUIPro.Web/HSSE/CostGoods/CostManage.aspx.cs @@ -348,7 +348,7 @@ namespace FineUIPro.Web.HSSE.CostGoods } else { - string messaage = CostManageService.PushDataToHSE(this.CurrUser.LoginProjectId, costManage.ContractNum); + string messaage = CostManageService.PushDataToHSE(this.CurrUser.LoginProjectId, costManage.ContractNum,costManageId); if (string.IsNullOrEmpty(messaage)) { Alert.ShowInTop("推送成功!", MessageBoxIcon.Success);