赛鼎焊接修改
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
using Model;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NPOI.SS.UserModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
@@ -11,7 +15,7 @@ namespace BLL
|
||||
/// </summary>
|
||||
public static class CostManageService
|
||||
{
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键获取安全费用管理
|
||||
@@ -29,12 +33,12 @@ namespace BLL
|
||||
/// <param name="ProjectId"></param>
|
||||
/// <param name="UnitId"></param>
|
||||
/// <returns></returns>
|
||||
public static decimal GetSumHSECost(string ProjectId, string UnitId, string costManageId )
|
||||
public static decimal GetSumHSECost(string ProjectId, string UnitId, string costManageId)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
decimal sumCost = 0;
|
||||
var getData = from x in db.CostGoods_CostManage
|
||||
var getData = from x in db.CostGoods_CostManage
|
||||
where x.ProjectId == ProjectId && x.UnitId == UnitId && x.States == Const.State_2 && x.CostManageId != costManageId
|
||||
select x;
|
||||
if (getData.Count() > 0)
|
||||
@@ -70,12 +74,12 @@ namespace BLL
|
||||
States = costManage.States,
|
||||
CompileMan = costManage.CompileMan,
|
||||
CompileDate = costManage.CompileDate,
|
||||
NextManId= costManage.NextManId,
|
||||
NextManId = costManage.NextManId,
|
||||
};
|
||||
|
||||
db.CostGoods_CostManage.InsertOnSubmit(newCostManage);
|
||||
db.SubmitChanges();
|
||||
|
||||
|
||||
AddCostManageFlowOperate(newCostManage);
|
||||
}
|
||||
|
||||
@@ -172,7 +176,7 @@ namespace BLL
|
||||
/// <param name="costManageId"></param>
|
||||
/// <returns></returns>
|
||||
public static Model.CostGoods_CostManageFlowOperate getNowCostManageFlowOperateList(string costManageId)
|
||||
{
|
||||
{
|
||||
var getAllNoClose = Funs.DB.CostGoods_CostManageFlowOperate.Where(x => x.CostManageId == costManageId && (x.IsClosed == null || x.IsClosed == false));
|
||||
if (getAllNoClose.Count() > 0)
|
||||
{
|
||||
@@ -190,10 +194,10 @@ namespace BLL
|
||||
/// </summary>
|
||||
/// <param name="costManageId"></param>
|
||||
/// <returns></returns>
|
||||
public static Model.CostGoods_CostManageFlowOperate getNextCostManageFlowOperateList(string costManageId,string operaterId)
|
||||
public static Model.CostGoods_CostManageFlowOperate getNextCostManageFlowOperateList(string costManageId, string operaterId)
|
||||
{
|
||||
int minSortIndex = 1;
|
||||
var getAllNoClose = Funs.DB.CostGoods_CostManageFlowOperate.Where(x => x.CostManageId == costManageId && (x.IsClosed == null || x.IsClosed == false));
|
||||
var getAllNoClose = Funs.DB.CostGoods_CostManageFlowOperate.Where(x => x.CostManageId == costManageId && (x.IsClosed == null || x.IsClosed == false));
|
||||
if (getAllNoClose.Count() > 0)
|
||||
{
|
||||
var getFlowOperate = getAllNoClose.Where(x => x.OperaterId == operaterId);
|
||||
@@ -210,7 +214,7 @@ namespace BLL
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,10 +346,10 @@ namespace BLL
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var getDatas = db.CostGoods_CostManageFlowOperate.Where(x => x.CostManageId == costManageId && x.IsClosed==true);
|
||||
foreach ( var item in getDatas)
|
||||
var getDatas = db.CostGoods_CostManageFlowOperate.Where(x => x.CostManageId == costManageId && x.IsClosed == true);
|
||||
foreach (var item in getDatas)
|
||||
{
|
||||
item.IsClosed= false;
|
||||
item.IsClosed = false;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
@@ -367,5 +371,107 @@ namespace BLL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// 推送数据到HSE系统
|
||||
/// </summary>
|
||||
public static string PushDataToHSE(string projectId, string contractNum)
|
||||
{
|
||||
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())
|
||||
{
|
||||
// 获取所有附件文件
|
||||
var files = new List<object>();
|
||||
decimal totalAmount = 0;
|
||||
|
||||
foreach (var item in costData)
|
||||
{
|
||||
var fileDetails = GetBase64FilesWithDetails(item.CostManageId);
|
||||
if (fileDetails != null && fileDetails.Count > 0)
|
||||
{
|
||||
files.AddRange(fileDetails);
|
||||
totalAmount += item.SumMoney ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
// 构建请求体
|
||||
var requestBody = new
|
||||
{
|
||||
projectId = projectId,
|
||||
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 response = Funs.RequestPost(requestGetTokenUrl, "", requestGetTokenBody);
|
||||
var responseStr = JsonConvert.DeserializeObject<JObject>(response);
|
||||
if (responseStr == null || responseStr["data"].ToString() != "200")
|
||||
{
|
||||
message = "获取Pu系统Token失败";
|
||||
|
||||
}
|
||||
string accessToken = responseStr["data"]["token"].ToString();
|
||||
var requestUrl = url + "/api/PuPayCraftAmount/AddPuPayCraftAmount";
|
||||
var responseHSE = Funs.RequestPost(requestUrl, accessToken, jsonBody);
|
||||
var responseHSEStr = JsonConvert.DeserializeObject<JObject>(responseHSE);
|
||||
if (responseHSEStr == null || responseHSEStr["data"].ToString()!= "200")
|
||||
{
|
||||
message = "推送数据到HSE系统失败";
|
||||
}
|
||||
}
|
||||
return message;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 记录错误日志
|
||||
ErrLogInfo.WriteLog(ex.Message, ex.StackTrace);
|
||||
return "推送数据失败"+ex.Message;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取Base64编码的附件文件
|
||||
/// </summary>
|
||||
public static List<object> GetBase64FilesWithDetails(string costManageId)
|
||||
{
|
||||
var result = new List<object>();
|
||||
// 获取费用管理信息
|
||||
var costManage = GetCostManageById(costManageId);
|
||||
// 获取附件文件
|
||||
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
|
||||
{
|
||||
name = file.Name,
|
||||
content = base64Content,
|
||||
thisamount = costManage?.SumMoney?.ToString() ?? "0",
|
||||
date = costManage?.CostManageDate?.ToString("yyyy-MM-dd") ?? DateTime.Now.ToString("yyyy-MM-dd")
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user