IDP质量设计图纸管理
This commit is contained in:
+313
-39
@@ -1,4 +1,5 @@
|
||||
using Apache.NMS.ActiveMQ.Commands;
|
||||
using Aspose.Words.Lists;
|
||||
using Microsoft.SqlServer.Dts.Runtime;
|
||||
using Model;
|
||||
using Newtonsoft.Json;
|
||||
@@ -8,20 +9,39 @@ using SgManager.AI;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Policy;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.Text;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// IDP平台接口服务
|
||||
/// </summary>
|
||||
public static class IDPDataService
|
||||
{
|
||||
/// <summary>
|
||||
/// 测试环境api地址
|
||||
/// </summary>
|
||||
private static readonly string IDPApiUrl = "http://10.5.6.151:8100/";
|
||||
///// <summary>
|
||||
///// 正式环境api地址
|
||||
///// </summary>
|
||||
//private static readonly string IDPApiUrl = "https://idp.cwcec.com/";
|
||||
private static readonly string IDPApiUrl = SysConstSetService.WuHuanIDPPath;
|
||||
////private static readonly string publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQChnc2YD0YzJPx6QTh+/n7XzjR1ugFzrsmPolJhpCfWMKrSGbT7iX/Kgcm1AI+T95K4Jzv3KS42QTecZ1ziJ4Rr9Luzw+9ZCSjMZgrmAUbY5IeBaA6GzaSk8UWHZ4n5PL+GUGq+2f+COL7+KCS2AxEpaqDZVrJrIfg/UektdgNyzwIDAQAB";
|
||||
//private static readonly string IDPApiUrl = SysConstSetService.WuHuanIDPPath;
|
||||
|
||||
#region 接口授权认证
|
||||
|
||||
/// <summary>
|
||||
/// 加密公钥
|
||||
/// </summary>
|
||||
private static readonly string publicKey = "<RSAKeyValue><Modulus>g1sk7Xtc1TJouHdY4+FAe5atGCu2n17NhoKVDV57pki1IL+9+S7BY4gxAjmMkUU2/cbCCdbPoUJLBrCBCjX7yI3UJW6FZwQWkn3kVoeulLEwdPCIq/GUjMXaWf3Iaaad5wBUFbfXAzv15VN6z48Nt1IY/O8YEzhIpuZdtEgDdos=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";
|
||||
//private static readonly string publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQChnc2YD0YzJPx6QTh+/n7XzjR1ugFzrsmPolJhpCfWMKrSGbT7iX/Kgcm1AI+T95K4Jzv3KS42QTecZ1ziJ4Rr9Luzw+9ZCSjMZgrmAUbY5IeBaA6GzaSk8UWHZ4n5PL+GUGq+2f+COL7+KCS2AxEpaqDZVrJrIfg/UektdgNyzwIDAQAB";
|
||||
|
||||
/// <summary>
|
||||
/// 第三方加密认证接口
|
||||
@@ -30,48 +50,60 @@ namespace BLL
|
||||
/// <returns></returns>
|
||||
public static SessionItem GetAuthenticationSession()
|
||||
{
|
||||
//// 创建RSA加密服务提供者
|
||||
////using (RSA rsa = RSA.Create())
|
||||
//using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider())
|
||||
//{
|
||||
//// 获取公钥false表示只导出公钥
|
||||
//string publicKey = rsa.ToXmlString(false);
|
||||
//// 获取私钥true表示导出公钥和私钥
|
||||
//string privateKey = rsa.ToXmlString(true);
|
||||
|
||||
SessionItem session = new SessionItem();
|
||||
|
||||
////用户名加密
|
||||
//string encryptedUsername = EncryptData("dataviewer", publicKey);
|
||||
////密码加密
|
||||
//string encryptedPassword = EncryptData("a3365$!", publicKey);
|
||||
|
||||
//用户名加密后的密文
|
||||
string encryptedUsername = "k0N0tx/hfRPY0v2lq1G8eH6hCO+UiMqlSZi1PD6bhGf4YpP/koJq5hfMsDSzdn3dZjzExrwyrjFWp/1jZLde0+gRbQ0D7tzm0R5D6AmriodD2cJvrEiwtDy7SeGNloSaNmpTEMuycpuueiOeGhMkKnTwWfRkEw73lxEpTmaahq4=";
|
||||
//密码加密后的密文
|
||||
string encryptedPassword = "HLLroiNJJzyTWJt9td1xgChbVzyQkoxWCGGXqdwI2cvlUF/A30FAPaInszSwEhNRQlJZZ01EODElemkgv36DMF+XGwfDi0BfIq9jKG+/+wq0TVOHNhiu2NPzpn5Ji2X3yXIXpH1zv6XEtkvx/qiLToZYfRQCufsl5vH1cZxk2fQ=";
|
||||
|
||||
string url = $"{IDPApiUrl}UAMS/authEncrypt";
|
||||
string contenttype = "application/json;charset=utf-8";
|
||||
var body = new
|
||||
try
|
||||
{
|
||||
encryptedUsername = encryptedUsername,
|
||||
encryptedPassword = encryptedPassword
|
||||
};
|
||||
//// 创建RSA加密服务提供者
|
||||
////using (RSA rsa = RSA.Create())
|
||||
//using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider())
|
||||
//{
|
||||
//// 获取公钥false表示只导出公钥
|
||||
//string publicKey = rsa.ToXmlString(false);
|
||||
//// 获取私钥true表示导出公钥和私钥
|
||||
//string privateKey = rsa.ToXmlString(true);
|
||||
|
||||
string pushContent = JsonConvert.SerializeObject(body);
|
||||
//var returndata = BLL.APIGetHttpService.OutsideHttp(url, "POST", null, null, pushContent);
|
||||
string strJosn = APIGetHttpService.Http(url, "POST", contenttype, null, pushContent);
|
||||
JObject obj = JObject.Parse(strJosn);
|
||||
if (!string.IsNullOrEmpty(strJosn))
|
||||
|
||||
////用户名加密
|
||||
//string encryptedUsername = EncryptData("dataviewer", publicKey);
|
||||
////密码加密
|
||||
//string encryptedPassword = EncryptData("a3365$!", publicKey);
|
||||
|
||||
//用户名加密后的密文
|
||||
string encryptedUsername = "k0N0tx/hfRPY0v2lq1G8eH6hCO+UiMqlSZi1PD6bhGf4YpP/koJq5hfMsDSzdn3dZjzExrwyrjFWp/1jZLde0+gRbQ0D7tzm0R5D6AmriodD2cJvrEiwtDy7SeGNloSaNmpTEMuycpuueiOeGhMkKnTwWfRkEw73lxEpTmaahq4=";
|
||||
//密码加密后的密文
|
||||
string encryptedPassword = "HLLroiNJJzyTWJt9td1xgChbVzyQkoxWCGGXqdwI2cvlUF/A30FAPaInszSwEhNRQlJZZ01EODElemkgv36DMF+XGwfDi0BfIq9jKG+/+wq0TVOHNhiu2NPzpn5Ji2X3yXIXpH1zv6XEtkvx/qiLToZYfRQCufsl5vH1cZxk2fQ=";
|
||||
|
||||
string url = $"{IDPApiUrl}UAMS/authEncrypt";
|
||||
//string url = $"http://10.5.6.151:8100/UAMS/authEncrypt";
|
||||
string contenttype = "application/json;charset=utf-8";
|
||||
var body = new
|
||||
{
|
||||
encryptedUsername = encryptedUsername,
|
||||
encryptedPassword = encryptedPassword
|
||||
};
|
||||
|
||||
string pushContent = JsonConvert.SerializeObject(body);
|
||||
string strJosn = APIGetHttpService.Http(url, "POST", contenttype, null, pushContent);
|
||||
//string strJosn = HttpHelper.Post(url, null, pushContent);
|
||||
JObject obj = JObject.Parse(strJosn);
|
||||
if (!string.IsNullOrEmpty(strJosn))
|
||||
{
|
||||
string value = obj["value"].ToString();
|
||||
string name = obj["name"].ToString();
|
||||
session.value = value;
|
||||
session.name = name;
|
||||
}
|
||||
//}
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
string value = obj["value"].ToString();
|
||||
string name = obj["name"].ToString();
|
||||
session.value = value;
|
||||
session.name = name;
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
}
|
||||
return session;
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -100,6 +132,245 @@ namespace BLL
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 质量管理设计图纸
|
||||
|
||||
#region IDP
|
||||
|
||||
/// <summary>
|
||||
/// 质量管理设计图纸
|
||||
/// </summary>
|
||||
/// <param name="projectId">项目Id</param>
|
||||
/// <param name="startDate">获取指定日期之后到现在的异动数据</param>
|
||||
public static void GetIDPProjectDesignDrawingData(string projectId = "", string startDate = "")
|
||||
{
|
||||
try
|
||||
{
|
||||
//五环主数据项目Code
|
||||
string projectCode = string.Empty;
|
||||
if (!string.IsNullOrWhiteSpace(projectId))
|
||||
{//根据施工平台项目Id获取主数据项目Code
|
||||
var getPro = ProjectService.GetProjectByProjectId(projectId);
|
||||
projectCode = getPro.ProjectCode;
|
||||
}
|
||||
|
||||
string timeStampStr = string.Empty;
|
||||
if (!string.IsNullOrWhiteSpace(startDate))
|
||||
{
|
||||
string format = "yyyy-MM-dd";
|
||||
DateTimeOffset dateTimeOffset = DateTimeOffset.ParseExact(startDate, format, CultureInfo.InvariantCulture);
|
||||
long timeStamp = Funs.GetDateTimeStamp(dateTimeOffset, 13);
|
||||
timeStampStr = timeStamp.ToString();
|
||||
}
|
||||
|
||||
var session = GetAuthenticationSession();
|
||||
//ErrLogInfo.WriteLog($"【Session】name:{session.name};value:{session.value}");
|
||||
Hashtable newToken = new Hashtable { { "Cookie", $"{session.name}={session.value}" } };
|
||||
|
||||
List<IDP_DesignDrawing> listAdd = new List<IDP_DesignDrawing>();
|
||||
List<IDP_DesignDrawing> listModify = new List<IDP_DesignDrawing>();
|
||||
|
||||
int pageSize = 1000;//一次性最多返回1000条数据
|
||||
int maxPageNum = 100;
|
||||
List<string> idpFileIds = DesignDrawingService.GetIDPDesignDrawingFileId();
|
||||
List<IDP_DesignDrawing> idpFiles = DesignDrawingService.GetIDPDesignDrawingFile();
|
||||
for (int pageNum = 1; pageNum < 100000; pageNum++)
|
||||
{
|
||||
if (pageNum > maxPageNum) { break; }
|
||||
string url = $"{IDPApiUrl}EDC/third/workitems?pageNum={pageNum}&pageSize={pageSize}";
|
||||
if (!string.IsNullOrWhiteSpace(timeStampStr)) { url = $"{url}&lastTimestamp={timeStampStr}"; }
|
||||
if (!string.IsNullOrWhiteSpace(projectCode)) { url = $"{url}&projectCode={projectCode}"; }
|
||||
|
||||
var returndata = BLL.APIGetHttpService.OutsideHttp(url, "GET", null, newToken, null);
|
||||
if (!string.IsNullOrEmpty(returndata))
|
||||
{
|
||||
IDPDesignDrawingResponseData responseData = IDPDesignDrawingResponseData.FromJson(returndata);
|
||||
maxPageNum = responseData.page.pages;
|
||||
foreach (var item in responseData.page.results)
|
||||
{
|
||||
IDP_DesignDrawing newItem = new IDP_DesignDrawing();
|
||||
if (!string.IsNullOrWhiteSpace(projectId))
|
||||
{
|
||||
newItem.ProjectId = projectId;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(item.projectCode))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var getProject = ProjectService.GetProjectByProjectCode(item.projectCode);
|
||||
if (getProject == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
newItem.ProjectId = getProject.ProjectId;
|
||||
}
|
||||
newItem.IdpfileId = item.fileId;
|
||||
newItem.StockId = item.stockId;
|
||||
newItem.ThirdId = item.thirdId;
|
||||
newItem.ProjectCode = item.projectCode;
|
||||
newItem.DisplayProjectName = item.displayProjectName;
|
||||
newItem.ProjectDeviceProcedureSubjectCode = item.projectDeviceProcedureSubjectCode;
|
||||
newItem.WbsFullPath = item.wbsFullPath;
|
||||
newItem.FormatFileName = item.formatFileName;
|
||||
newItem.FileVersion = item.fileVersion;
|
||||
newItem.MajorNo = item.majorNo;
|
||||
newItem.Status = item.status;
|
||||
newItem.DesignUserName = item.designUserName;
|
||||
newItem.JiaoheUserName = item.jiaoheUserName;
|
||||
newItem.ShenheUserName = item.shenheUserName;
|
||||
newItem.ShendingUserName = item.shendingUserName;
|
||||
newItem.MajorResponsibleUserName = item.majorResponsibleUserName;
|
||||
newItem.ClassificationLevelInProject = item.classificationLevelInProject;
|
||||
newItem.UpdateTime = item.updateTime;
|
||||
newItem.Remark = item.remark;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(item.fileId) && idpFileIds.Contains(item.fileId))
|
||||
{//编辑
|
||||
newItem.Id = idpFiles.Where(x => x.IdpfileId == item.fileId).FirstOrDefault().Id;
|
||||
listModify.Add(newItem);
|
||||
}
|
||||
else
|
||||
{//新增
|
||||
newItem.Id = SQLHelper.GetNewID(typeof(IDP_DesignDrawing));
|
||||
listAdd.Add(newItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (listAdd.Any())
|
||||
{
|
||||
AddIDP_DesignDrawing(listAdd);
|
||||
}
|
||||
if (listModify.Any())
|
||||
{
|
||||
ModifyIDP_DesignDrawing(listModify);
|
||||
}
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量插入数据
|
||||
/// </summary>
|
||||
/// <param name="list"></param>
|
||||
public static void AddIDP_DesignDrawing(List<Model.IDP_DesignDrawing> list)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
db.IDP_DesignDrawing.InsertAllOnSubmit(list);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新数据
|
||||
/// </summary>
|
||||
/// <param name="list"></param>
|
||||
public static void ModifyIDP_DesignDrawing(List<Model.IDP_DesignDrawing> list)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
foreach (var obj in list)
|
||||
{
|
||||
IDP_DesignDrawing newItem = db.IDP_DesignDrawing.FirstOrDefault(x => x.Id == obj.Id);
|
||||
if (newItem != null)
|
||||
{
|
||||
newItem.StockId = obj.StockId;
|
||||
newItem.ThirdId = obj.ThirdId;
|
||||
newItem.ProjectId = obj.ProjectId;
|
||||
newItem.ProjectCode = obj.ProjectCode;
|
||||
newItem.DisplayProjectName = obj.DisplayProjectName;
|
||||
newItem.ProjectDeviceProcedureSubjectCode = obj.ProjectDeviceProcedureSubjectCode;
|
||||
newItem.WbsFullPath = obj.WbsFullPath;
|
||||
newItem.FormatFileName = obj.FormatFileName;
|
||||
newItem.FileVersion = obj.FileVersion;
|
||||
newItem.MajorNo = obj.MajorNo;
|
||||
newItem.Status = obj.Status;
|
||||
newItem.DesignUserName = obj.DesignUserName;
|
||||
newItem.JiaoheUserName = obj.JiaoheUserName;
|
||||
newItem.ShenheUserName = obj.ShenheUserName;
|
||||
newItem.ShendingUserName = obj.ShendingUserName;
|
||||
newItem.MajorResponsibleUserName = obj.MajorResponsibleUserName;
|
||||
newItem.ClassificationLevelInProject = obj.ClassificationLevelInProject;
|
||||
newItem.UpdateTime = obj.UpdateTime;
|
||||
newItem.Remark = obj.Remark;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 数字档案馆
|
||||
|
||||
/// <summary>
|
||||
/// 接收保存数据
|
||||
/// </summary>
|
||||
/// <param name="newItem"></param>
|
||||
public static string SaveDesignDrawingData(OADesignDrawingData newItems)
|
||||
{
|
||||
try
|
||||
{
|
||||
string message = string.Empty;
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
foreach (var item in newItems.DataItems)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(item.RdpId))
|
||||
{
|
||||
IDP_DesignDrawing newItem = db.IDP_DesignDrawing.FirstOrDefault(x => x.StockId == item.RdpId);
|
||||
if (newItem != null)
|
||||
{
|
||||
newItem.RdpId = item.RdpId;
|
||||
newItem.Fileid = item.fileid;
|
||||
newItem.Upfileid = item.upfileid;
|
||||
newItem.Maintitle = item.maintitle;
|
||||
newItem.Doc_no = item.doc_no;
|
||||
newItem.Bc = item.bc;
|
||||
newItem.Archnumber = item.archnumber;
|
||||
newItem.Sendtime = item.sendtime;
|
||||
newItem.Printtime = item.printtime;
|
||||
newItem.Ifmail = item.ifmail;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region 试车工作包
|
||||
|
||||
/// <summary>
|
||||
/// 获取工作包结构化数据
|
||||
@@ -114,6 +385,9 @@ namespace BLL
|
||||
//string url = $"{IDPApiUrl}/OSS/projects/{projectId}/wbs/{wbsCode}/workitems/{workitemCode}/objects/latest";
|
||||
string url = $"{IDPApiUrl}/OSS/projects/9100168/wbs/000000/workitems/CP2100/objects/latest";
|
||||
|
||||
|
||||
//测试环境接口地址
|
||||
var testApiUrl = "http://10.5.6.151:8100/OSS/projects/9100168/wbs/000000/workitems/CP2100/objects/latest";
|
||||
try
|
||||
{
|
||||
var session = GetAuthenticationSession();
|
||||
@@ -131,7 +405,6 @@ namespace BLL
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -153,6 +426,7 @@ namespace BLL
|
||||
//}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user