Merge branch 'master' of http://47.104.102.122:3000/lpf/SGGL_SeDin_New
This commit is contained in:
commit
6be8d160e0
Binary file not shown.
|
|
@ -77,7 +77,7 @@
|
|||
},
|
||||
{
|
||||
"$type": "Bookmark",
|
||||
"Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}"
|
||||
"Name": "ST:128:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1446,6 +1446,28 @@ namespace BLL
|
|||
return response.Content;
|
||||
}
|
||||
|
||||
public static string RequestPost(string Baseurl, Dictionary<string ,string> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据星期几返回值
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -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系统
|
||||
/// </summary>
|
||||
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<object>();
|
||||
if (contractModel!=null)
|
||||
{
|
||||
// 获取所有附件文件
|
||||
var files = new List<object>();
|
||||
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<JObject>(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<string, string> headers = new Dictionary<string, string>();
|
||||
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<JObject>(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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16599,7 +16599,7 @@
|
|||
</COMReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@
|
|||
<f:Button ID="btnNew" Text="新增" Icon="Add" EnablePostBack="false" Hidden="true"
|
||||
runat="server">
|
||||
</f:Button>
|
||||
<f:Button ID="Button1" Text="推送" Icon="Add" runat="server" OnClick="Button1_Click">
|
||||
</f:Button>
|
||||
<f:button id="Button1" text="推送" icon="Add" runat="server" onclick="Button1_Click">
|
||||
</f:button>
|
||||
<f:Button ID="btnOut" OnClick="btnOut_Click" runat="server" Text="导出" Icon="FolderUp"
|
||||
EnableAjax="false" DisableControlBeforePostBack="false">
|
||||
</f:Button>
|
||||
|
|
|
|||
|
|
@ -348,7 +348,15 @@ 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);
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert.ShowInTop(messaage, MessageBoxIcon.Warning);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -582,6 +582,8 @@
|
|||
// refreshWhenExist: 添加选项卡时,如果选项卡已经存在,是否刷新内部IFrame
|
||||
// iconFont: 选项卡图标字体
|
||||
function addExampleTab(tabOptions) {
|
||||
debugger;
|
||||
|
||||
if (typeof (tabOptions) === 'string') {
|
||||
tabOptions = {
|
||||
id: arguments[0],
|
||||
|
|
|
|||
Loading…
Reference in New Issue