From b004037b4d8dbd0b796cc4a102b88b7ec367a451 Mon Sep 17 00:00:00 2001 From: fei550 <1420031550@qq.com> Date: Thu, 3 Jul 2025 18:42:35 +0800 Subject: [PATCH] 1 --- .vs/SGGL_SeDin_New/v17/.wsuo | Bin 74752 -> 73216 bytes .../v17/DocumentLayout.backup.json | 32 ++--- SGGL/BLL/Common/ConstValue.cs | 5 + SGGL/BLL/HSSE/CostGoods/CostManageService.cs | 130 ++++++++++++------ SGGL/FineUIPro.Web/FineUIPro.Web.csproj | 2 +- SGGL/Model/HSSE/PuApiOutput.cs | 61 ++++++++ SGGL/Model/Model.csproj | 1 + 7 files changed, 168 insertions(+), 63 deletions(-) create mode 100644 SGGL/Model/HSSE/PuApiOutput.cs diff --git a/.vs/SGGL_SeDin_New/v17/.wsuo b/.vs/SGGL_SeDin_New/v17/.wsuo index 2b6a9900abb81318654938ff248b0207d9fb8e8d..7f5969003285703035b592ad9f8fad2b4e7e50b7 100644 GIT binary patch delta 1319 zcma)5T}YE*6yEv#Hm80w=TFJpO1G8E9Bs>=WmBvP*$@7JT@)edq`D{xnI;xu5+q`w zJE0I1_7xIQV0%j?%!b}b7it&XL{}Ar5nas-i?s9VR-b0z3uo{7ea~~w^Q~iA>=+k& zt03iB^-q9oysytxKe=_V;VU)?op2c!gc+Smr&6h`B+GPApKgT%xDaDGVIfy4i6Ih7 zirhRck@O6bSQ3rG|BGT~vX|)ILbpAl^O|_l)B372w7lO|66_T{rXo^!l%GP?~o2X6|I~CUD1QS4S~({2VjK$Z{OKV{j+dl4QM?P?+PQ0*ql^>-o)a7-iuR$ z6aD&19f*{&N0EkM@~&)<&&ns@#pq9-!!m<|`BN%k!)_7;j9wi$s3=P2YN4?br`*K> z)09qSqo7Igs-}{RcoqARRv}`!DHr{Q8f}^)frSkc$lJwW!8B+&Cs91=qhzFxE@r_E z7zkOwhUYD|fjJ8}M$FK$&ZWLa$v69|_p(xJ2>LEb0UIIBjXW29lKE{_AaNRukqF1H zE+Ip}#ly#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ConstText(string constText) + { + return Funs.DB.Sys_Const.FirstOrDefault(e => e.ConstText == constText); + } public static void DeleteConstValueBygroupId(string groupId) { var q = Funs.DB.Sys_Const.Where(x => x.GroupId == groupId); diff --git a/SGGL/BLL/HSSE/CostGoods/CostManageService.cs b/SGGL/BLL/HSSE/CostGoods/CostManageService.cs index 5ba8d146..660ee615 100644 --- a/SGGL/BLL/HSSE/CostGoods/CostManageService.cs +++ b/SGGL/BLL/HSSE/CostGoods/CostManageService.cs @@ -386,28 +386,17 @@ namespace BLL select x; var projectModel=ProjectService.GetProjectByProjectId(projectId); var contractModel = CostManageService.GetCostManageById(costManageId); - decimal totalAmount = costData.Sum(x => x.SumMoney ?? 0); + //decimal totalAmount = costData.Sum(x => x.SumMoney ?? 0); var files = new List(); if (contractModel!=null) - { - var fileDetails = GetBase64FilesWithDetails(contractModel.CostManageId); - if (fileDetails != null && fileDetails.Count > 0) + { + var url = ConstValue.GetConstByConstText("PU_PUSH_URL")?.ConstValue; + if (string.IsNullOrEmpty(url)) { - files.AddRange(fileDetails); + message = "未配置推送接口地址"; + return message; + } - - // 构建请求体 - var requestBody = new - { - projectNumber = projectModel.ProjectCode, - contractNo = contractNum, - amountHSE = totalAmount.ToString(), - files = files - }; - var jsonBody = JsonConvert.SerializeObject(requestBody); - - // 调用HSE接口推送数据 - var url = "http://172.29.60.33:9037"; var requestGetTokenUrl = url + "/auth/getToken"; string requestGetTokenBody = "{\"username\": \"coadmin\",\"password\": \"coadminPu@2025\"}"; var response = Funs.RequestPost(requestGetTokenUrl, "", requestGetTokenBody); @@ -425,10 +414,55 @@ namespace BLL { message = "获取Pu系统Token失败,Token为空"; return message; - } + } Dictionary headers = new Dictionary(); headers.Add("Authorization", "Bearer " + accessToken); + #region 先获取当前费用是否已经推送过 + var getRequestUrl = url + "/pu_api/payCraftAmountToHSE/get"; + var getRequestbody= $"{{\"projectNumber\":\"{projectModel.ProjectCode}\",\"contractNo\":\"{contractNum}\"}}"; + APICommonService.SaveSysHttpLog("PU_GetPuPayCraftAmount", getRequestUrl, getRequestbody, "Requset"); + var getResponse = Funs.RequestPost(getRequestUrl, headers, getRequestbody); + APICommonService.SaveSysHttpLog("PU_GetPuPayCraftAmount", getRequestUrl, getResponse, "Response"); + var getResponseStr = JsonConvert.DeserializeObject(getResponse); + if (getResponseStr == null) + { + message = "推送数据到HSE系统失败"; + return message; + } + else if (getResponseStr["code"]?.ToString() != "200") + { + message = getResponseStr["message"]?.ToString(); + return message; + } + var getResponseOutput = JsonConvert.DeserializeObject>(getResponseStr["data"]?.ToString()) ; + if (getResponseOutput.Any() && getResponseOutput.Count(x=>x.itemNo== costManageId)>0) + { + message = "当前费用已推送,无需重复推送!"; + return message; + } + + #endregion + + #region 推送数据至Pu var requestUrl = url + "/pu_api/payCraftAmountToHSE/add"; + // 构建请求体 + var fileDetails = GetBase64FilesWithDetails(contractModel.CostManageId); + if (fileDetails != null && fileDetails.Count > 0) + { + files.AddRange(fileDetails); + } + List puAddApiInputs = new List() + { + new PuAddApiInput() + { + projectNumber = projectModel.ProjectCode, + itemId= costManageId, + contractNo = contractNum, + amountHSE = contractModel.SumMoney.ToString(), + files = files + } + }; + var jsonBody = JsonConvert.SerializeObject(puAddApiInputs); APICommonService.SaveSysHttpLog("PU_AddPuPayCraftAmount", requestUrl, jsonBody, "Requset"); var responseHSE = Funs.RequestPost(requestUrl, headers, jsonBody); var responseHSEStr = JsonConvert.DeserializeObject(responseHSE); @@ -438,16 +472,23 @@ namespace BLL message = "推送数据到HSE系统失败"; return message; } + else if ( string.IsNullOrEmpty(responseHSEStr["code"]?.ToString())) + { + message = responseHSE; + return message; + } else if (responseHSEStr["code"]?.ToString() != "200") { message = responseHSEStr["message"]?.ToString(); return message; } - else + else { message = ""; return message; } + #endregion + } return message; @@ -459,7 +500,6 @@ namespace BLL return "推送数据失败"; } } - /// /// 获取Base64编码的附件文件 /// @@ -468,37 +508,39 @@ namespace BLL var result = new List(); // 获取费用管理信息 var costManage = GetCostManageById(costManageId); - // 获取附件文件 - var attachments = AttachFileService.getFileUrl(costManageId); + var costItem = BLL.CostManageItemService.GetCostManageItemByCostManageId(costManageId); + foreach (var item in costItem) + { // 获取附件文件 + var attachments = AttachFileService.getFileUrl(item.CostManageItemId); - if (!string.IsNullOrEmpty(attachments)) - { - string[] filePaths = attachments.Split(','); - foreach (var filePath in filePaths) + if (!string.IsNullOrEmpty(attachments)) { - string fullPath = Funs.RootPath + filePath; - if (File.Exists(fullPath)) + string[] filePaths = attachments.Split(','); + foreach (var filePath in filePaths) { - FileInfo file = new FileInfo(fullPath); - byte[] fileBytes = File.ReadAllBytes(fullPath); - string base64Content = Convert.ToBase64String(fileBytes); - - result.Add(new Model.PuPayCraftAmountFileInput + string fullPath = Funs.RootPath + filePath; + if (File.Exists(fullPath)) { - 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}");*/ + 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 = item?.PriceMoney?.ToString() ?? "0", + date = costManage?.CompileDate?.ToString("yyyy-MM-dd") ?? DateTime.Now.ToString("yyyy-MM-dd") + }); + + continue;//只取第一个文件 + } } } } + + return result; } diff --git a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj index 028f77fb..1f8781f0 100644 --- a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj +++ b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj @@ -16785,7 +16785,7 @@ - + diff --git a/SGGL/Model/HSSE/PuApiOutput.cs b/SGGL/Model/HSSE/PuApiOutput.cs new file mode 100644 index 00000000..567b13da --- /dev/null +++ b/SGGL/Model/HSSE/PuApiOutput.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model +{ + public class PuGetApiOutput + { + /// + /// 合同号 + /// + public string contractNo { get; set; } + + /// + /// 项目号 + /// + public string projectNumber { get; set; } + + /// + /// 主键 + /// + public string itemNo { get; set; } + + /// + /// 本次申请费用 + /// + public string amountHSE { get; set; } + } + public class PuAddApiInput + { + /// + /// 合同号 + /// + public string contractNo { get; set; } + + /// + /// 项目号 + /// + public string projectNumber { get; set; } + + /// + /// 主键 + /// + public string itemId { get; set; } + + /// + /// 本次申请费用 + /// + public string amountHSE { get; set; } + + /// + /// Gets or sets the files. + /// + /// + /// The files. + /// + public List files { get; set; } + } +} diff --git a/SGGL/Model/Model.csproj b/SGGL/Model/Model.csproj index 7a6ac86c..75f89168 100644 --- a/SGGL/Model/Model.csproj +++ b/SGGL/Model/Model.csproj @@ -245,6 +245,7 @@ +