diff --git a/.vs/SGGL_SeDin_New/v17/.wsuo b/.vs/SGGL_SeDin_New/v17/.wsuo index 2b6a9900..7f596900 100644 Binary files a/.vs/SGGL_SeDin_New/v17/.wsuo and b/.vs/SGGL_SeDin_New/v17/.wsuo differ diff --git a/.vs/SGGL_SeDin_New/v17/DocumentLayout.backup.json b/.vs/SGGL_SeDin_New/v17/DocumentLayout.backup.json index 290e6c8a..4cf91a0b 100644 --- a/.vs/SGGL_SeDin_New/v17/DocumentLayout.backup.json +++ b/.vs/SGGL_SeDin_New/v17/DocumentLayout.backup.json @@ -8,21 +8,13 @@ "VerticalTabListWidth": 256, "DocumentGroups": [ { - "DockedWidth": 386, + "DockedWidth": 200, "SelectedChildIndex": -1, "Children": [ { "$type": "Bookmark", "Name": "ST:0:0:{e506b91c-c606-466a-90a9-123d1d1e12b3}" }, - { - "$type": "Bookmark", - "Name": "ST:130:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}" - }, - { - "$type": "Bookmark", - "Name": "ST:132:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}" - }, { "$type": "Bookmark", "Name": "ST:133:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}" @@ -51,14 +43,6 @@ "$type": "Bookmark", "Name": "ST:3:0:{f2bd8fb8-fc94-3dae-a733-fd993c73cc87}" }, - { - "$type": "Bookmark", - "Name": "ST:129:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}" - }, - { - "$type": "Bookmark", - "Name": "ST:131:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}" - }, { "$type": "Bookmark", "Name": "ST:0:0:{1a46fd64-28d5-434c-8eb3-17a02d419b53}" @@ -67,6 +51,18 @@ "$type": "Bookmark", "Name": "ST:0:0:{5726b0e3-1012-5233-81f9-d1fad48e7a56}" }, + { + "$type": "Bookmark", + "Name": "ST:137:0:{1fc202d4-d401-403c-9834-5b218574bb67}" + }, + { + "$type": "Bookmark", + "Name": "ST:138:0:{1fc202d4-d401-403c-9834-5b218574bb67}" + }, + { + "$type": "Bookmark", + "Name": "ST:136:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}" + }, { "$type": "Bookmark", "Name": "ST:2:0:{b9f91511-5ca5-40ec-9726-f3e3a7e534e2}" @@ -77,7 +73,7 @@ }, { "$type": "Bookmark", - "Name": "ST:128:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}" + "Name": "ST:129:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}" } ] } diff --git a/SGGL/BLL/Common/ConstValue.cs b/SGGL/BLL/Common/ConstValue.cs index e316b5ee..955c41a4 100644 --- a/SGGL/BLL/Common/ConstValue.cs +++ b/SGGL/BLL/Common/ConstValue.cs @@ -92,6 +92,11 @@ namespace BLL { return Funs.DB.Sys_Const.FirstOrDefault(e => e.ConstValue == constValue && e.GroupId == groupId); } + + public static Sys_Const GetConstByConstText(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 @@ +