升级
This commit is contained in:
@@ -3,6 +3,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -611,5 +612,46 @@ namespace BLL
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 下载并保存文件
|
||||
/// </summary>
|
||||
/// <param name="webUrl"></param>
|
||||
/// <param name="fileUrl"></param>
|
||||
/// <returns></returns>
|
||||
public static byte[] SafeDownloadHeadImageAsync(string webUrl, string fileUrl)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(fileUrl))
|
||||
return null;
|
||||
|
||||
// 构造完整的远程文件 URL
|
||||
string fullRemoteUrl = $"{webUrl.TrimEnd('/')}/{fileUrl.TrimStart('/')}";
|
||||
|
||||
// 构造本地文件路径
|
||||
string localFilePath = Path.Combine(ConfigurationManager.AppSettings["localRoot"], fileUrl);
|
||||
|
||||
// 确保本地目录存在
|
||||
string directoryPath = Path.GetDirectoryName(localFilePath);
|
||||
if (!string.IsNullOrEmpty(directoryPath) && !Directory.Exists(directoryPath))
|
||||
{
|
||||
Directory.CreateDirectory(directoryPath);
|
||||
}
|
||||
//下载文件到本地
|
||||
using (WebClient client = new WebClient())
|
||||
{
|
||||
byte[] fileData = client.DownloadData(fullRemoteUrl);
|
||||
// 将文件数据写入本地文件
|
||||
File.WriteAllBytes(localFilePath, fileData);
|
||||
return fileData;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BLL.ErrLogInfo.WriteLog($"下载头像失败: {fileUrl}, 错误: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,544 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Model;
|
||||
using Newtonsoft.Json;
|
||||
using RestSharp;
|
||||
using System.Net;
|
||||
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// 质量巡检同步服务
|
||||
/// </summary>
|
||||
public class APICheckControlSyncService
|
||||
{
|
||||
#region 根据项目、单位获取质量巡检列表
|
||||
|
||||
/// <summary>
|
||||
/// 根据项目、单位获取质量巡检列表
|
||||
/// </summary>
|
||||
/// <param name="projectId">项目ID</param>
|
||||
/// <param name="unitId">单位ID</param>
|
||||
/// <param name="dataId">数据ID(可选,用于单条数据同步)</param>
|
||||
/// <returns>质量巡检数据列表</returns>
|
||||
public static List<Model.CheckControlSyncItem> GetCheckControlListsByProjectIdUnitIdPage(
|
||||
string projectId, string unitId, string dataId = "")
|
||||
{
|
||||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||||
{
|
||||
var list = from x in db.Check_CheckControl
|
||||
where x.ProjectId == projectId
|
||||
select x;
|
||||
|
||||
if (!string.IsNullOrEmpty(unitId))
|
||||
{
|
||||
list = list.Where(x => x.UnitId == unitId);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(dataId))
|
||||
{
|
||||
list = list.Where(x => x.CheckControlCode == dataId);
|
||||
}
|
||||
|
||||
var dataList = (from x in list
|
||||
join unit in db.Base_Unit on x.UnitId equals unit.UnitId into unitTemp
|
||||
from unit in unitTemp.DefaultIfEmpty()
|
||||
join pro in db.Base_CNProfessional on x.CNProfessionalCode equals pro.CNProfessionalId into proTemp
|
||||
from pro in proTemp.DefaultIfEmpty()
|
||||
join uw in db.WBS_UnitWork on x.UnitWorkId equals uw.UnitWorkId into uwTemp
|
||||
from uw in uwTemp.DefaultIfEmpty()
|
||||
join qqt in db.Base_QualityQuestionType on x.QuestionType equals qqt.QualityQuestionTypeId into qqtTemp
|
||||
from qqt in qqtTemp.DefaultIfEmpty()
|
||||
join u1 in db.Sys_User on x.CheckMan equals u1.UserId into u1Temp
|
||||
from u1 in u1Temp.DefaultIfEmpty()
|
||||
join u2 in db.Sys_User on x.SubmitMan equals u2.UserId into u2Temp
|
||||
from u2 in u2Temp.DefaultIfEmpty()
|
||||
join pu in db.Base_Unit on x.ProposeUnitId equals pu.UnitId into puTemp
|
||||
from pu in puTemp.DefaultIfEmpty()
|
||||
join att in db.AttachFile on x.CheckControlCode equals att.ToKeyId into attTemp
|
||||
from att in attTemp.DefaultIfEmpty()
|
||||
join attRe in db.AttachFile on x.CheckControlCode+"r" equals attRe.ToKeyId into attReTemp
|
||||
from attRe in attReTemp.DefaultIfEmpty()
|
||||
select new CheckControlSyncItem
|
||||
{
|
||||
CheckControlCode = x.CheckControlCode,
|
||||
ProjectId = x.ProjectId,
|
||||
UnitWorkId = x.UnitWorkId,
|
||||
UnitWorkName = uw.UnitWorkName,
|
||||
UnitId = x.UnitId,
|
||||
UnitName = unit.UnitName,
|
||||
CheckDate = x.CheckDate,
|
||||
CheckMan = x.CheckMan,
|
||||
CheckManName = u1.UserName,
|
||||
CheckSite = x.CheckSite,
|
||||
DocCode = x.DocCode,
|
||||
CNProfessionalCode = x.CNProfessionalCode,
|
||||
CNProfessionalName = pro.ProfessionalName,
|
||||
QuestionType = x.QuestionType,
|
||||
QuestionTypeName = qqt.QualityQuestionType,
|
||||
QuestionDef = x.QuestionDef,
|
||||
RectifyOpinion = x.RectifyOpinion,
|
||||
LimitDate = x.LimitDate,
|
||||
AttachUrl = att.AttachUrl,
|
||||
HandleWay = x.HandleWay,
|
||||
RectifyDate = x.RectifyDate,
|
||||
ReAttachUrl = attRe.AttachUrl,
|
||||
State = x.State,
|
||||
IsSubmit = x.IsSubmit,
|
||||
SubmitMan = x.SubmitMan,
|
||||
SubmitManName = u2.UserName,
|
||||
IsOK = x.IsOK,
|
||||
ProposeUnitId = x.ProposeUnitId,
|
||||
ProposeUnitName = pu.UnitName,
|
||||
SaveHandleMan = x.SaveHandleMan,
|
||||
DataSource = "1"
|
||||
}).ToList();
|
||||
|
||||
return dataList;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 拉取质量巡检数据
|
||||
|
||||
/// <summary>
|
||||
/// 拉取质量巡检数据
|
||||
/// </summary>
|
||||
/// <returns>处理结果消息</returns>
|
||||
public static string getCheckControlLists(string projectId = "")
|
||||
{
|
||||
int code = 0;
|
||||
string message = "";
|
||||
try
|
||||
{
|
||||
string CollCropCode = string.Empty;
|
||||
string unitId = string.Empty;
|
||||
var thisUnit = CommonService.GetIsThisUnit(); //当前单位
|
||||
if (thisUnit != null)
|
||||
{
|
||||
CollCropCode = thisUnit.CollCropCode; //社会统一信用代码
|
||||
unitId = thisUnit.UnitId;
|
||||
}
|
||||
|
||||
var ProjectList = (from x in Funs.DB.Base_Project
|
||||
where (x.IsDelete == null || x.IsDelete == false) &&
|
||||
x.SubjectUnit != null && x.SubjectProject != null
|
||||
select x).ToList();
|
||||
if (!string.IsNullOrEmpty(projectId))
|
||||
{
|
||||
ProjectList = ProjectList.Where(x => x.ProjectId == projectId).ToList();
|
||||
}
|
||||
if (ProjectList.Count > 0)
|
||||
{
|
||||
foreach (var project in ProjectList)
|
||||
{
|
||||
string SubjectUnitId = project.SubjectUnit; //集团的单位id
|
||||
string SubjectProjectId = project.SubjectProject; //集团的项目id
|
||||
|
||||
//获取对应单位的apiurl地址
|
||||
var Url = BLL.UnitService.getUnitApiUrlByUnitId(SubjectUnitId);
|
||||
//var Url = "http://localhost:14957/,http://localhost:8579/";
|
||||
|
||||
var ApiUrl = "";
|
||||
var WebUrl = "";
|
||||
if (!string.IsNullOrEmpty(Url))
|
||||
{
|
||||
var urls = Url.Split(',');
|
||||
ApiUrl = urls[0];
|
||||
if (urls.Length > 1)
|
||||
{
|
||||
WebUrl = urls[1];
|
||||
}
|
||||
}
|
||||
|
||||
string url = "/api/CheckControlSync/getCheckControlListByProjectIdAndCollCropCode?projectId=" +
|
||||
SubjectProjectId + "&collCropCode=" + CollCropCode;
|
||||
string baseurl = ApiUrl + url;
|
||||
string contenttype = "application/json;charset=unicode";
|
||||
var strJosn = APIGetHttpService.Http(baseurl, "GET", contenttype, null, null);
|
||||
|
||||
if (!string.IsNullOrEmpty(strJosn))
|
||||
{
|
||||
JObject obj = JObject.Parse(strJosn);
|
||||
code = Funs.GetNewIntOrZero(obj["code"].ToString());
|
||||
message = obj["message"].ToString();
|
||||
|
||||
if (code == 1)
|
||||
{
|
||||
var getData = JsonConvert.DeserializeObject<List<CheckControlSyncItem>>(obj["data"].ToString());
|
||||
if (getData.Count() > 0)
|
||||
{
|
||||
ProcessCheckControlData(getData, project.ProjectId, unitId, WebUrl, "pull");
|
||||
}
|
||||
message = "获取成功:同步质量巡检数" + getData.Count().ToString() + "条";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
message = "获取失败:" + ex.Message;
|
||||
ErrLogInfo.WriteLog("质量巡检获取!", ex);
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 推送质量巡检数据
|
||||
|
||||
/// <summary>
|
||||
/// 推送质量巡检数据
|
||||
/// </summary>
|
||||
/// <param name="projectId">项目ID</param>
|
||||
/// <param name="dataId">数据ID(可选,用于单条数据推送)</param>
|
||||
/// <returns>推送结果</returns>
|
||||
public static ReturnData pushCheckControlLists(string projectId, string dataId = "")
|
||||
{
|
||||
Model.ReturnData responeData = new Model.ReturnData();
|
||||
responeData.code = 0;
|
||||
responeData.message = string.Empty;
|
||||
var project = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectId == projectId);
|
||||
|
||||
try
|
||||
{
|
||||
if (project != null)
|
||||
{
|
||||
//获取质量巡检数据
|
||||
var items = GetCheckControlListsByProjectIdUnitIdPage(projectId, "", dataId);
|
||||
|
||||
if (items.Count() > 0)
|
||||
{
|
||||
var thisUnit = CommonService.GetIsThisUnit(); //当前单位
|
||||
var apiurl = "/api/CheckControlSync/SaveCheckControlSyncData";
|
||||
|
||||
//总包单位接口地址
|
||||
var Url = BLL.UnitService.getUnitApiUrlByUnitId(project.SubjectUnit);
|
||||
//var Url = "http://localhost:14957/";
|
||||
var ApiUrl = "";
|
||||
var WebUrl = "";
|
||||
|
||||
if (!string.IsNullOrEmpty(Url))
|
||||
{
|
||||
var urls = Url.Split(',');
|
||||
ApiUrl = urls[0];
|
||||
if (urls.Length > 1)
|
||||
{
|
||||
WebUrl = urls[1];
|
||||
}
|
||||
}
|
||||
|
||||
var pushData = new CheckControlSyncData
|
||||
{
|
||||
CollCropCode = thisUnit.CollCropCode, //分包单位社会统一信用码
|
||||
ProjectId = project.SubjectProject, //主包项目Id
|
||||
UnitDomain = Funs.SGGLUrl, //分包单位域名地址【文件存储地址】
|
||||
Items = items //质量巡检数据
|
||||
};
|
||||
|
||||
var pushContent = JsonConvert.SerializeObject(pushData);
|
||||
string baseurl = ApiUrl + apiurl;
|
||||
string contenttype = "application/json;charset=unicode";
|
||||
var returndata = APIGetHttpService.Http(baseurl, "Post", contenttype, null, pushContent);
|
||||
|
||||
if (!string.IsNullOrEmpty(returndata))
|
||||
{
|
||||
JObject obj = JObject.Parse(returndata);
|
||||
string code = obj["code"].ToString();
|
||||
string message = obj["message"].ToString();
|
||||
responeData.code = int.Parse(code);
|
||||
responeData.message = message;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "当前没有质量巡检数据";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.message = "同步到总包单位失败!";
|
||||
ErrLogInfo.WriteLog("【质量巡检】同步到总包单位失败!", ex);
|
||||
}
|
||||
|
||||
return responeData;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 接收保存质量巡检数据
|
||||
|
||||
/// <summary>
|
||||
/// 接收保存质量巡检数据
|
||||
/// </summary>
|
||||
/// <param name="items">质量巡检同步数据</param>
|
||||
/// <returns>处理结果消息</returns>
|
||||
public static string SaveCheckControlSyncData(Model.CheckControlSyncData items)
|
||||
{
|
||||
int code = 0;
|
||||
string message = "";
|
||||
try
|
||||
{
|
||||
if (items.Items.Count > 0 || items.Items.Count > 0)
|
||||
{
|
||||
var CollCropCode = items.CollCropCode; //分包单位社会统一信用码
|
||||
var ProjectId = items.ProjectId; //总包项目Id
|
||||
var UnitDomain = items.UnitDomain; //分包单位域名地址【文件存储地址】
|
||||
|
||||
var unit = Funs.DB.Base_Unit.FirstOrDefault(x => x.CollCropCode == CollCropCode); //根据CollCropCode获取单位id
|
||||
if (unit == null)
|
||||
{
|
||||
message = "总包单位不存在本单位,请登录总包系统检查维护本单位信息!";
|
||||
}
|
||||
else
|
||||
{
|
||||
//判断主包项目是否存在
|
||||
var porject = BLL.ProjectService.GetProjectByProjectId(ProjectId);
|
||||
if (porject == null)
|
||||
{
|
||||
message = "总包单位不存在本项目,请检查总包项目关联是否正确!";
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcessCheckControlData(items.Items, ProjectId, unit.UnitId, UnitDomain, "push");
|
||||
message = "数据推送成功!";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
message = "暂无质量巡检数据!";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 处理质量巡检数据的新增或更新逻辑
|
||||
|
||||
/// <summary>
|
||||
/// 处理质量巡检数据的新增或更新逻辑
|
||||
/// </summary>
|
||||
/// <param name="getData">质量巡检数据列表</param>
|
||||
/// <param name="projectId">项目id</param>
|
||||
/// <param name="unitId">单位ID</param>
|
||||
/// <param name="WebUrl">Web地址</param>
|
||||
///
|
||||
private static void ProcessCheckControlData(
|
||||
List<Model.CheckControlSyncItem> getData,
|
||||
string projectId,
|
||||
string unitId,
|
||||
string WebUrl, string type)
|
||||
{
|
||||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||||
{
|
||||
foreach (var item in getData)
|
||||
{
|
||||
Model.Check_CheckControl model = db.Check_CheckControl.FirstOrDefault(x => x.CheckControlCode == item.CheckControlCode);
|
||||
|
||||
if (model == null)
|
||||
{
|
||||
//新增
|
||||
Model.Check_CheckControl newModel = new Model.Check_CheckControl
|
||||
{
|
||||
CheckControlCode = item.CheckControlCode,
|
||||
ProjectId = projectId,
|
||||
UnitWorkId = APIDataShareSyncService.getUnitWorkId(item.UnitWorkName, projectId),
|
||||
UnitId = getUnitIdByUnitName(item.UnitName) ?? unitId,
|
||||
CheckDate = item.CheckDate,
|
||||
CheckMan = APIDataShareSyncService.getUserId(item.CheckManName),
|
||||
CheckSite = item.CheckSite,
|
||||
DocCode = item.DocCode,
|
||||
CNProfessionalCode = getCNProfessionalId(item.CNProfessionalName),
|
||||
QuestionType = getQualityQuestionTypeId(item.QuestionTypeName, projectId),
|
||||
QuestionDef = item.QuestionDef,
|
||||
RectifyOpinion = item.RectifyOpinion,
|
||||
LimitDate = item.LimitDate,
|
||||
AttachUrl = item.AttachUrl,
|
||||
HandleWay = item.HandleWay,
|
||||
RectifyDate = item.RectifyDate,
|
||||
ReAttachUrl = item.ReAttachUrl,
|
||||
State = item.State,
|
||||
IsSubmit = item.IsSubmit,
|
||||
SubmitMan = APIDataShareSyncService.getUserId(item.SubmitManName),
|
||||
IsOK = item.IsOK,
|
||||
ProposeUnitId = getUnitIdByUnitName(item.ProposeUnitName),
|
||||
SaveHandleMan = item.SaveHandleMan
|
||||
};
|
||||
if (type == "pull")
|
||||
{
|
||||
newModel.DataSource = item.DataSource;
|
||||
}
|
||||
db.Check_CheckControl.InsertOnSubmit(newModel);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
//更新
|
||||
model.ProjectId = projectId;
|
||||
model.UnitWorkId = APIDataShareSyncService.getUnitWorkId(item.UnitWorkName, projectId);
|
||||
model.UnitId = getUnitIdByUnitName(item.UnitName) ?? unitId;
|
||||
model.CheckDate = item.CheckDate;
|
||||
model.CheckMan = APIDataShareSyncService.getUserId(item.CheckManName);
|
||||
model.CheckSite = item.CheckSite;
|
||||
model.DocCode = item.DocCode;
|
||||
model.CNProfessionalCode = getCNProfessionalId(item.CNProfessionalName);
|
||||
model.QuestionType = getQualityQuestionTypeId(item.QuestionTypeName, projectId);
|
||||
model.QuestionDef = item.QuestionDef;
|
||||
model.RectifyOpinion = item.RectifyOpinion;
|
||||
model.LimitDate = item.LimitDate;
|
||||
model.AttachUrl = item.AttachUrl;
|
||||
model.HandleWay = item.HandleWay;
|
||||
model.RectifyDate = item.RectifyDate;
|
||||
model.ReAttachUrl = item.ReAttachUrl;
|
||||
model.State = item.State;
|
||||
model.IsSubmit = item.IsSubmit;
|
||||
model.SubmitMan = APIDataShareSyncService.getUserId(item.SubmitManName);
|
||||
model.IsOK = item.IsOK;
|
||||
model.ProposeUnitId = getUnitIdByUnitName(item.ProposeUnitName);
|
||||
model.SaveHandleMan = item.SaveHandleMan;
|
||||
if (type == "pull")
|
||||
{
|
||||
model.DataSource = item.DataSource;
|
||||
}
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
//处理整改前附件
|
||||
if (!string.IsNullOrEmpty(item.AttachUrl))
|
||||
{
|
||||
APIDataShareSyncService.OperationAttachFile(WebUrl, item.CheckControlCode,
|
||||
BLL.Const.CheckListMenuId, item.AttachUrl);
|
||||
}
|
||||
|
||||
//处理整改后附件
|
||||
if (!string.IsNullOrEmpty(item.ReAttachUrl))
|
||||
{
|
||||
APIDataShareSyncService.OperationAttachFile(WebUrl, item.CheckControlCode + "R",
|
||||
BLL.Const.CheckListMenuId, item.ReAttachUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 辅助映射方法
|
||||
|
||||
/// <summary>
|
||||
/// 获取质量问题类型ID(不存在则创建)
|
||||
/// </summary>
|
||||
/// <param name="questionTypeName">问题类型名称</param>
|
||||
/// <param name="projectId">项目ID</param>
|
||||
/// <returns>问题类型ID</returns>
|
||||
private static string getQualityQuestionTypeId(string questionTypeName, string projectId)
|
||||
{
|
||||
string questionTypeId = null;
|
||||
if (!string.IsNullOrEmpty(questionTypeName))
|
||||
{
|
||||
var qqt = Funs.DB.Base_QualityQuestionType.FirstOrDefault(x => x.QualityQuestionType == questionTypeName);
|
||||
if (qqt == null)
|
||||
{
|
||||
//不存在则创建
|
||||
Model.Base_QualityQuestionType newQqt = new Model.Base_QualityQuestionType
|
||||
{
|
||||
QualityQuestionTypeId = SQLHelper.GetNewID(typeof(Model.Base_QualityQuestionType)),
|
||||
QualityQuestionType = questionTypeName
|
||||
};
|
||||
QualityQuestionTypeService.AddQualityQuestionType(newQqt);
|
||||
questionTypeId = newQqt.QualityQuestionTypeId;
|
||||
}
|
||||
else
|
||||
{
|
||||
questionTypeId = qqt.QualityQuestionTypeId;
|
||||
}
|
||||
}
|
||||
return questionTypeId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取专业ID(不存在则创建)
|
||||
/// </summary>
|
||||
/// <param name="ProfessionalName"></param>
|
||||
/// <param name="projectId"></param>
|
||||
/// <returns></returns>
|
||||
private static string getCNProfessionalId(string ProfessionalName)
|
||||
{
|
||||
string Id = null;
|
||||
if (!string.IsNullOrEmpty(ProfessionalName))
|
||||
{
|
||||
var names = ProfessionalName.Split(',');
|
||||
List<string> IdList = new List<string>();
|
||||
foreach (var name in names)
|
||||
{
|
||||
var cnProfessional = Funs.DB.Base_CNProfessional.Where(x =>
|
||||
x.ProfessionalName == name).ToList();
|
||||
if (cnProfessional.Count == 0)
|
||||
{
|
||||
Model.Base_CNProfessional newCnProfessional = new Model.Base_CNProfessional
|
||||
{
|
||||
CNProfessionalId = SQLHelper.GetNewID(typeof(Model.WBS_UnitWork)),
|
||||
ProfessionalName = name,
|
||||
};
|
||||
CNProfessionalService.AddCNProfessional(newCnProfessional);
|
||||
IdList.Add(newCnProfessional.CNProfessionalId);
|
||||
}
|
||||
else
|
||||
{
|
||||
IdList.Add(cnProfessional.FirstOrDefault().CNProfessionalId);
|
||||
}
|
||||
}
|
||||
|
||||
Id = string.Join(",", IdList);
|
||||
}
|
||||
|
||||
return Id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单位ID(根据名称)
|
||||
/// </summary>
|
||||
/// <param name="unitName">单位名称</param>
|
||||
/// <returns>单位ID</returns>
|
||||
private static string getUnitIdByUnitName(string unitName)
|
||||
{
|
||||
string unitId = null;
|
||||
if (!string.IsNullOrEmpty(unitName))
|
||||
{
|
||||
var unit = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitName == unitName);
|
||||
if (unit != null)
|
||||
{
|
||||
unitId = unit.UnitId;
|
||||
}
|
||||
}
|
||||
return unitId;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,299 @@
|
||||
using Model;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// 质量会议同步服务
|
||||
/// </summary>
|
||||
public class APICqmsMeetingSyncService
|
||||
{
|
||||
|
||||
#region 分包单位推送数据到总包单位
|
||||
|
||||
/// <summary>
|
||||
/// 分包单位推送数据到总包单位
|
||||
/// </summary>
|
||||
/// <param name="projectId">项目ID</param>
|
||||
/// <param name="dataId">数据ID(可选,用于单条数据推送)</param>
|
||||
/// <returns>推送结果</returns>
|
||||
public static ReturnData PushCqmsMeetingLists(string projectId, string dataId = "")
|
||||
{
|
||||
Model.ReturnData responeData = new Model.ReturnData();
|
||||
responeData.code = 0;
|
||||
responeData.message = string.Empty;
|
||||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||||
{
|
||||
try
|
||||
{
|
||||
var project = db.Base_Project.FirstOrDefault(x => x.ProjectId == projectId);
|
||||
if (project != null)
|
||||
{
|
||||
var list = from x in db.CQMS_Meeting where x.ProjectId == projectId select x;
|
||||
if (!string.IsNullOrEmpty(dataId))
|
||||
{
|
||||
list = list.Where(x => x.MeetingId == dataId);
|
||||
}
|
||||
var dataList = (from x in list
|
||||
join unit in db.Base_Unit on x.UnitId equals unit.UnitId into unitTemp
|
||||
from unit in unitTemp.DefaultIfEmpty()
|
||||
join u1 in db.Sys_User on x.CompileMan equals u1.UserId into u1Temp
|
||||
from u1 in u1Temp.DefaultIfEmpty()
|
||||
//join u2 in db.Sys_User on x.MeetingHostMan equals u2.UserId into u2Temp
|
||||
//from u2 in u2Temp.DefaultIfEmpty()
|
||||
//join cr in db.Sys_CodeRecords on x.MeetingId equals cr.DataId into crTemp
|
||||
//from cr in crTemp.DefaultIfEmpty()
|
||||
join att in db.AttachFile on x.MeetingId equals att.ToKeyId into attTemp
|
||||
from att in attTemp.DefaultIfEmpty()
|
||||
join att1 in db.AttachFile on (x.MeetingId + "#1") equals att1.ToKeyId into att1Temp
|
||||
from att1 in att1Temp.DefaultIfEmpty()
|
||||
join att2 in db.AttachFile on (x.MeetingId + "#2") equals att2.ToKeyId into att2Temp
|
||||
from att2 in att2Temp.DefaultIfEmpty()
|
||||
select new CqmsMeetingSyncItem
|
||||
{
|
||||
MeetingId = x.MeetingId,
|
||||
MeetingCode = x.MeetingCode,
|
||||
MeetingName = x.MeetingName,
|
||||
ProjectId = x.ProjectId,
|
||||
UnitId = x.UnitId,
|
||||
UnitName = unit.UnitName,
|
||||
MeetingDate = x.MeetingDate,
|
||||
MeetingHours = x.MeetingHours,
|
||||
MeetingPlace = x.MeetingPlace,
|
||||
MeetingHostManId = x.MeetingHostManId,
|
||||
MeetingHostMan = x.MeetingHostMan,
|
||||
//MeetingHostManName = u2.UserName,
|
||||
MeetingHostManOther = x.MeetingHostManOther,
|
||||
AttentPersonNum = x.AttentPersonNum,
|
||||
AttentPerson = x.AttentPerson,
|
||||
AttentPersonIds = x.AttentPersonIds,
|
||||
MeetingContents = x.MeetingContents,
|
||||
CompileMan = x.CompileMan,
|
||||
CompileManName = u1.UserName,
|
||||
CompileDate = x.CompileDate,
|
||||
States = x.States,
|
||||
AttachFileId = att.AttachFileId,
|
||||
ToKeyId = att.ToKeyId,
|
||||
AttachSource = att.AttachSource,
|
||||
AttachUrl = att.AttachUrl,
|
||||
AttachFileId1 = att1.AttachFileId,
|
||||
ToKeyId1 = att1.ToKeyId,
|
||||
AttachSource1 = att1.AttachSource,
|
||||
AttachUrl1 = att1.AttachUrl,
|
||||
AttachFileId2 = att2.AttachFileId,
|
||||
ToKeyId2 = att2.ToKeyId,
|
||||
AttachSource2 = att2.AttachSource,
|
||||
AttachUrl2 = att2.AttachUrl,
|
||||
}).ToList();
|
||||
|
||||
if (dataList.Count() > 0)
|
||||
{
|
||||
var thisUnit = CommonService.GetIsThisUnit(); //当前单位
|
||||
var apiurl = "/api/CqmsMeetingSync/SaveCqmsMeetingSyncData";
|
||||
|
||||
//总包单位接口地址
|
||||
string ApiUrl = project.SubjectUnitApiUrl;
|
||||
string WebUrl = project.SubjectUnitWebUrl;
|
||||
var pushData = new CqmsMeetingSyncData
|
||||
{
|
||||
CollCropCode = thisUnit.CollCropCode,//分包单位社会统一信用码
|
||||
UnitId = thisUnit.UnitId,//分包单位Id
|
||||
UnitName = thisUnit.UnitName,//分包单位名称
|
||||
ShortUnitName = thisUnit.ShortUnitName,//分包单位简称
|
||||
UnitDomain = Funs.SGGLUrl,//分包单位域名地址【文件存储地址】
|
||||
SubjectUnit = project.SubjectUnit,//主包单位Id
|
||||
SubjectProject = project.SubjectProject,//主包项目Id
|
||||
Items = dataList//会议数据
|
||||
};
|
||||
|
||||
var pushContent = JsonConvert.SerializeObject(pushData);
|
||||
string baseurl = ApiUrl + apiurl;
|
||||
string contenttype = "application/json;charset=unicode";
|
||||
var returndata = APIGetHttpService.Http(baseurl, "Post", contenttype, null, pushContent);
|
||||
|
||||
if (!string.IsNullOrEmpty(returndata))
|
||||
{
|
||||
// ErrLogInfo.WriteLog($"【质量会议返回结果】接口地址:{baseurl};{returndata}");
|
||||
JObject obj = JObject.Parse(returndata);
|
||||
string code = obj["code"].ToString();
|
||||
string message = obj["message"].ToString();
|
||||
responeData.code = int.Parse(code);
|
||||
responeData.message = message;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "当前没有质量会议数据";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.message = "同步到总包单位失败!";
|
||||
ErrLogInfo.WriteLog("【质量会议】同步到总包单位失败!", ex);
|
||||
}
|
||||
}
|
||||
return responeData;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 总包单位接收分包单位推送数据
|
||||
|
||||
/// <summary>
|
||||
/// 接收保存质量会议数据
|
||||
/// </summary>
|
||||
/// <param name="data">质量会议同步数据</param>
|
||||
/// <returns>处理结果消息</returns>
|
||||
public static string SaveCqmsMeetingSyncData(Model.CqmsMeetingSyncData data)
|
||||
{
|
||||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||||
{
|
||||
string result = string.Empty;
|
||||
|
||||
if (data.Items.Count > 0)
|
||||
{
|
||||
var CollCropCode = data.CollCropCode; //分包单位社会统一信用码
|
||||
var ProjectId = data.SubjectProject; //总包项目Id
|
||||
var UnitDomain = data.UnitDomain; //分包单位域名地址【文件存储地址】
|
||||
|
||||
//1、判断分包单位是否存在
|
||||
var unit = UnitService.getUnitByCollCropCodeUnitName(CollCropCode, data.UnitName);
|
||||
if (unit == null)
|
||||
{
|
||||
result = "总包单位不存在本单位,请登录总包系统检查维护本单位信息!";
|
||||
}
|
||||
else
|
||||
{
|
||||
//判断主包项目是否存在
|
||||
var porject = BLL.ProjectService.GetProjectByProjectId(ProjectId);
|
||||
if (porject == null)
|
||||
{
|
||||
result = "总包单位不存在本项目,请检查总包项目关联是否正确!";
|
||||
}
|
||||
else
|
||||
{
|
||||
int succ = 0;
|
||||
foreach (var item in data.Items)
|
||||
{
|
||||
try
|
||||
{
|
||||
Model.CQMS_Meeting model = db.CQMS_Meeting.FirstOrDefault(x => x.MeetingId == item.MeetingId);
|
||||
|
||||
if (model != null)
|
||||
{
|
||||
//更新
|
||||
model.ProjectId = ProjectId;
|
||||
model.UnitId = unit.UnitId;
|
||||
model.MeetingCode = item.MeetingCode;
|
||||
model.MeetingName = item.MeetingName;
|
||||
model.MeetingDate = item.MeetingDate;
|
||||
model.MeetingHours = item.MeetingHours;
|
||||
model.MeetingPlace = item.MeetingPlace;
|
||||
//model.MeetingHostManId = item.MeetingHostManId;
|
||||
model.MeetingHostMan = item.MeetingHostMan;
|
||||
model.MeetingHostManOther = item.MeetingHostManOther;
|
||||
model.AttentPersonNum = item.AttentPersonNum;
|
||||
model.AttentPerson = item.AttentPerson;
|
||||
model.AttentPersonIds = item.AttentPersonIds;
|
||||
//model.MeetingContents = meetingContents;
|
||||
//model.MeetingContents = HttpUtility.HtmlEncode(item.MeetingContents);
|
||||
model.MeetingContents = item.MeetingContents;
|
||||
//model.CompileMan = APIDataShareSyncService.getUserId(item.CompileManName);
|
||||
model.CompileDate = item.CompileDate;
|
||||
model.SourceDes = $"{(!string.IsNullOrWhiteSpace(data.ShortUnitName) ? data.ShortUnitName : data.UnitName)}#{item.CompileManName}";
|
||||
//model.States = item.States;
|
||||
model.States = BLL.Const.State_2;//分包推送过来的质量会议数据默认已完成
|
||||
db.SubmitChanges();
|
||||
|
||||
//更新会议编码
|
||||
if (!string.IsNullOrEmpty(item.MeetingCode))
|
||||
{
|
||||
var codeRecords = db.Sys_CodeRecords.FirstOrDefault(x => x.DataId == item.MeetingId);
|
||||
if (codeRecords != null)
|
||||
{
|
||||
codeRecords.Code = item.MeetingCode;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//新增
|
||||
Model.CQMS_Meeting newModel = new Model.CQMS_Meeting
|
||||
{
|
||||
MeetingId = item.MeetingId,
|
||||
UnitId = unit.UnitId,
|
||||
ProjectId = ProjectId,
|
||||
MeetingCode = item.MeetingCode,
|
||||
MeetingName = item.MeetingName,
|
||||
MeetingDate = item.MeetingDate,
|
||||
MeetingHours = item.MeetingHours,
|
||||
MeetingPlace = item.MeetingPlace,
|
||||
//MeetingHostManId = item.MeetingHostManId,
|
||||
MeetingHostMan = item.MeetingHostMan,
|
||||
MeetingHostManOther = item.MeetingHostManOther,
|
||||
AttentPersonNum = item.AttentPersonNum,
|
||||
AttentPerson = item.AttentPerson,
|
||||
AttentPersonIds = item.AttentPersonIds,
|
||||
//MeetingContents = HttpUtility.HtmlEncode(item.MeetingContents),
|
||||
MeetingContents = item.MeetingContents,
|
||||
//CompileMan = APIDataShareSyncService.getUserId(item.CompileManName),
|
||||
CompileDate = item.CompileDate,
|
||||
SourceDes = $"{(!string.IsNullOrWhiteSpace(data.ShortUnitName) ? data.ShortUnitName : data.UnitName)}#{item.CompileManName}",
|
||||
//States = item.States
|
||||
States = BLL.Const.State_2//分包推送过来的质量会议数据默认已完成
|
||||
};
|
||||
|
||||
db.CQMS_Meeting.InsertOnSubmit(newModel);
|
||||
db.SubmitChanges();
|
||||
|
||||
//保存会议编码
|
||||
if (!string.IsNullOrEmpty(item.MeetingCode))
|
||||
{
|
||||
Model.Sys_CodeRecords codeRecords = new Model.Sys_CodeRecords
|
||||
{
|
||||
CodeRecordId = SQLHelper.GetNewID(typeof(Model.Sys_CodeRecords)),
|
||||
DataId = item.MeetingId,
|
||||
Code = item.MeetingCode
|
||||
};
|
||||
db.Sys_CodeRecords.InsertOnSubmit(codeRecords);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
succ++;
|
||||
//附件处理:内容附件
|
||||
BLL.FileInsertService.SaveAttachFileRecords(data.UnitDomain, item.AttachFileId, item.ToKeyId, item.AttachSource, item.AttachUrl);
|
||||
//附件处理:签到表
|
||||
BLL.FileInsertService.SaveAttachFileRecords(data.UnitDomain, item.AttachFileId1, item.ToKeyId1, item.AttachSource1, item.AttachUrl1);
|
||||
//附件处理:会议过程
|
||||
BLL.FileInsertService.SaveAttachFileRecords(data.UnitDomain, item.AttachFileId2, item.ToKeyId2, item.AttachSource2, item.AttachUrl2);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BLL.ErrLogInfo.WriteLog($"【{porject.ProjectName}】质量会议数据推送总包失败", ex.Message);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
result = $"推送成功:总数{data.Items.Count()}条,成功{succ}条";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = "暂无质量会议数据!";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,313 @@
|
||||
using Model;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// 质量计量器具同步服务
|
||||
/// </summary>
|
||||
public class APIInspectionMachineSyncService
|
||||
{
|
||||
#region 分包单位推送数据到总包单位
|
||||
|
||||
/// <summary>
|
||||
/// 分包单位推送数据到总包单位
|
||||
/// </summary>
|
||||
/// <param name="projectId">项目ID</param>
|
||||
/// <param name="dataId">数据ID(可选,用于单条数据推送)</param>
|
||||
/// <returns>推送结果</returns>
|
||||
public static ReturnData PushInspectionMachineLists(string projectId, string dataId = "")
|
||||
{
|
||||
Model.ReturnData responeData = new Model.ReturnData();
|
||||
responeData.code = 0;
|
||||
responeData.message = string.Empty;
|
||||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||||
{
|
||||
try
|
||||
{
|
||||
var project = db.Base_Project.FirstOrDefault(x => x.ProjectId == projectId);
|
||||
if (project != null)
|
||||
{
|
||||
//获取质量计量器具数据
|
||||
var list = from x in db.Comprehensive_InspectionMachine where x.ProjectId == projectId select x;
|
||||
|
||||
if (!string.IsNullOrEmpty(dataId))
|
||||
{
|
||||
list = list.Where(x => x.InspectionMachineId == dataId);
|
||||
}
|
||||
|
||||
var dataList = (from x in list
|
||||
join unit in db.Base_Unit on x.UnitId equals unit.UnitId into unitTemp
|
||||
from unit in unitTemp.DefaultIfEmpty()
|
||||
join pro in db.Base_CNProfessional on x.CNProfessionalId equals pro.CNProfessionalId into proTemp
|
||||
from pro in proTemp.DefaultIfEmpty()
|
||||
join u1 in db.Sys_User on x.CompileMan equals u1.UserId into u1Temp
|
||||
from u1 in u1Temp.DefaultIfEmpty()
|
||||
join att in db.AttachFile on x.InspectionMachineId equals att.ToKeyId into attTemp
|
||||
from att in attTemp.DefaultIfEmpty()
|
||||
select new InspectionMachineSyncItem
|
||||
{
|
||||
InspectionMachineId = x.InspectionMachineId,
|
||||
InspectionMachineCode = x.InspectionMachineCode,
|
||||
InspectionMachineName = x.InspectionMachineName,
|
||||
SpecificationModel = x.SpecificationModel,
|
||||
UnitsCount = x.UnitsCount,
|
||||
SType = x.SType,
|
||||
InspectionType = x.InspectionType,
|
||||
InspectionDate = x.InspectionDate,
|
||||
NextTestDate = x.NextTestDate,
|
||||
TestCycle = x.TestCycle,
|
||||
IsCheckOK = x.IsCheckOK,
|
||||
IsVerification = x.IsVerification,
|
||||
Status = x.Status,
|
||||
IsOnSite = x.IsOnSite,
|
||||
LeaveDate = x.LeaveDate,
|
||||
UnitId = x.UnitId,
|
||||
UnitName = unit.UnitName,
|
||||
CNProfessionalId = x.CNProfessionalId,
|
||||
CNProfessionalName = pro.ProfessionalName,
|
||||
CompileMan = x.CompileMan,
|
||||
CompileManName = u1.UserName,
|
||||
CompileDate = x.CompileDate,
|
||||
ProjectId = x.ProjectId,
|
||||
AttachFileId = att.AttachFileId,
|
||||
ToKeyId = att.ToKeyId,
|
||||
AttachSource = att.AttachSource,
|
||||
AttachUrl = att.AttachUrl,
|
||||
}).ToList();
|
||||
|
||||
if (dataList.Count() > 0)
|
||||
{
|
||||
var thisUnit = CommonService.GetIsThisUnit(); //当前单位
|
||||
var apiurl = "/api/InspectionMachineSync/SaveInspectionMachineSyncData";
|
||||
|
||||
//总包单位接口地址
|
||||
string ApiUrl = project.SubjectUnitApiUrl;
|
||||
string WebUrl = project.SubjectUnitWebUrl;
|
||||
var pushData = new InspectionMachineSyncData
|
||||
{
|
||||
CollCropCode = thisUnit.CollCropCode,//分包单位社会统一信用码
|
||||
UnitId = thisUnit.UnitId,//分包单位Id
|
||||
UnitName = thisUnit.UnitName,//分包单位名称
|
||||
ShortUnitName = thisUnit.ShortUnitName,//分包单位简称
|
||||
UnitDomain = Funs.SGGLUrl,//分包单位域名地址【文件存储地址】
|
||||
SubjectUnit = project.SubjectUnit,//主包单位Id
|
||||
SubjectProject = project.SubjectProject,//主包项目Id
|
||||
Items = dataList//质量计量器具数据
|
||||
};
|
||||
|
||||
var pushContent = JsonConvert.SerializeObject(pushData);
|
||||
string baseurl = ApiUrl + apiurl;
|
||||
string contenttype = "application/json;charset=unicode";
|
||||
var returndata = APIGetHttpService.Http(baseurl, "Post", contenttype, null, pushContent);
|
||||
|
||||
if (!string.IsNullOrEmpty(returndata))
|
||||
{
|
||||
JObject obj = JObject.Parse(returndata);
|
||||
string code = obj["code"].ToString();
|
||||
string message = obj["message"].ToString();
|
||||
responeData.code = int.Parse(code);
|
||||
responeData.message = message;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "当前没有质量计量器具数据";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.message = "同步到总包单位失败!";
|
||||
ErrLogInfo.WriteLog("【质量计量器具】同步到总包单位失败!", ex);
|
||||
}
|
||||
|
||||
}
|
||||
return responeData;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 总包单位接收分包单位推送数据
|
||||
|
||||
/// <summary>
|
||||
/// 总包单位接收分包单位推送数据
|
||||
/// </summary>
|
||||
/// <param name="items">质量计量器具同步数据</param>
|
||||
/// <returns>处理结果消息</returns>
|
||||
public static string SaveInspectionMachineSyncData(Model.InspectionMachineSyncData data)
|
||||
{
|
||||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||||
{
|
||||
string result = string.Empty;
|
||||
|
||||
if (data.Items.Count > 0 || data.Items.Count > 0)
|
||||
{
|
||||
var CollCropCode = data.CollCropCode; //分包单位社会统一信用码
|
||||
var ProjectId = data.SubjectProject; //总包项目Id
|
||||
var UnitDomain = data.UnitDomain; //分包单位域名地址【文件存储地址】
|
||||
|
||||
//1、判断分包单位是否存在
|
||||
var unit = UnitService.getUnitByCollCropCodeUnitName(CollCropCode, data.UnitName);
|
||||
if (unit == null)
|
||||
{
|
||||
result = "总包单位不存在本单位,请登录总包系统检查维护本单位信息!";
|
||||
}
|
||||
else
|
||||
{
|
||||
//判断主包项目是否存在
|
||||
var porject = BLL.ProjectService.GetProjectByProjectId(ProjectId);
|
||||
if (porject == null)
|
||||
{
|
||||
result = "总包单位不存在本项目,请检查总包项目关联是否正确!";
|
||||
}
|
||||
else
|
||||
{
|
||||
int succ = 0;
|
||||
foreach (var item in data.Items)
|
||||
{
|
||||
try
|
||||
{
|
||||
Model.Comprehensive_InspectionMachine model = db.Comprehensive_InspectionMachine.FirstOrDefault(x => x.InspectionMachineId == item.InspectionMachineId);
|
||||
if (model == null)
|
||||
{
|
||||
//新增
|
||||
Model.Comprehensive_InspectionMachine newModel = new Model.Comprehensive_InspectionMachine
|
||||
{
|
||||
ProjectId = ProjectId,
|
||||
UnitId = unit.UnitId,
|
||||
InspectionMachineId = item.InspectionMachineId,
|
||||
InspectionMachineCode = item.InspectionMachineCode,
|
||||
InspectionMachineName = item.InspectionMachineName,
|
||||
SpecificationModel = item.SpecificationModel,
|
||||
NextTestDate = item.NextTestDate,
|
||||
TestCycle = item.TestCycle,
|
||||
IsVerification = item.IsVerification,
|
||||
InspectionDate = item.InspectionDate,
|
||||
AttachUrl = item.AttachUrl,
|
||||
CNProfessionalId = getCNProfessionalId(item.CNProfessionalName),
|
||||
//CompileMan = APIDataShareSyncService.getUserId(item.CompileManName),
|
||||
CompileDate = item.CompileDate,
|
||||
IsOnSite = item.IsOnSite,
|
||||
InspectionType = item.InspectionType,
|
||||
LeaveDate = item.LeaveDate,
|
||||
UnitsCount = item.UnitsCount,
|
||||
//AuditMan = item.AuditMan,
|
||||
Status = item.Status,
|
||||
IsCheckOK = item.IsCheckOK,
|
||||
SType = item.SType,
|
||||
SourceDes = $"{(!string.IsNullOrWhiteSpace(data.ShortUnitName) ? data.ShortUnitName : data.UnitName)}#{item.CompileManName}#专业名称:{item.CNProfessionalName}",
|
||||
};
|
||||
|
||||
db.Comprehensive_InspectionMachine.InsertOnSubmit(newModel);
|
||||
db.SubmitChanges();
|
||||
|
||||
//保存编码
|
||||
if (!string.IsNullOrEmpty(item.InspectionMachineCode))
|
||||
{
|
||||
Model.Sys_CodeRecords codeRecords = new Model.Sys_CodeRecords
|
||||
{
|
||||
CodeRecordId = SQLHelper.GetNewID(typeof(Model.Sys_CodeRecords)),
|
||||
DataId = item.InspectionMachineId,
|
||||
Code = item.InspectionMachineCode
|
||||
};
|
||||
db.Sys_CodeRecords.InsertOnSubmit(codeRecords);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//更新
|
||||
model.ProjectId = ProjectId;
|
||||
model.UnitId = unit.UnitId;
|
||||
model.InspectionMachineCode = item.InspectionMachineCode;
|
||||
model.InspectionMachineName = item.InspectionMachineName;
|
||||
model.SpecificationModel = item.SpecificationModel;
|
||||
model.NextTestDate = item.NextTestDate;
|
||||
model.TestCycle = item.TestCycle;
|
||||
model.IsVerification = item.IsVerification;
|
||||
model.InspectionDate = item.InspectionDate;
|
||||
model.AttachUrl = item.AttachUrl;
|
||||
model.CNProfessionalId = getCNProfessionalId(item.CNProfessionalName);
|
||||
//model.CompileMan = APIDataShareSyncService.getUserId(item.CompileManName);
|
||||
model.CompileDate = item.CompileDate;
|
||||
model.IsOnSite = item.IsOnSite;
|
||||
model.InspectionType = item.InspectionType;
|
||||
model.LeaveDate = item.LeaveDate;
|
||||
model.UnitsCount = item.UnitsCount;
|
||||
//model.AuditMan = item.AuditMan;
|
||||
model.Status = item.Status;
|
||||
model.IsCheckOK = item.IsCheckOK;
|
||||
model.SType = item.SType;
|
||||
model.SourceDes = $"{(!string.IsNullOrWhiteSpace(data.ShortUnitName) ? data.ShortUnitName : data.UnitName)}#{item.CompileManName}#专业名称:{item.CNProfessionalName}";
|
||||
|
||||
db.SubmitChanges();
|
||||
//更新编码
|
||||
if (!string.IsNullOrEmpty(item.InspectionMachineCode))
|
||||
{
|
||||
var codeRecords = db.Sys_CodeRecords.FirstOrDefault(x => x.DataId == item.InspectionMachineId);
|
||||
if (codeRecords != null)
|
||||
{
|
||||
codeRecords.Code = item.InspectionMachineCode;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
succ++;
|
||||
//附件处理:附件
|
||||
BLL.FileInsertService.SaveAttachFileRecords(data.UnitDomain, item.AttachFileId, item.ToKeyId, item.AttachSource, item.AttachUrl);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BLL.ErrLogInfo.WriteLog($"【{porject.ProjectName}】计量器具数据推送总包失败", ex.Message);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
result = "数据推送成功!";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = "暂无质量计量器具数据!";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 辅助映射方法
|
||||
|
||||
/// <summary>
|
||||
/// 获取专业ID(根据名称)
|
||||
/// </summary>
|
||||
/// <param name="professionalName">专业名称</param>
|
||||
/// <returns>专业ID</returns>
|
||||
private static string getCNProfessionalId(string professionalName)
|
||||
{
|
||||
string professionalId = null;
|
||||
if (!string.IsNullOrEmpty(professionalName))
|
||||
{
|
||||
var pro = Funs.DB.Base_CNProfessional.FirstOrDefault(x => x.ProfessionalName == professionalName);
|
||||
if (pro != null)
|
||||
{
|
||||
professionalId = pro.CNProfessionalId;
|
||||
}
|
||||
}
|
||||
return professionalId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -13,519 +13,491 @@ using RestSharp;
|
||||
using System.Net;
|
||||
|
||||
|
||||
namespace BLL;
|
||||
|
||||
public class APICheckSpecialSyncService
|
||||
namespace BLL
|
||||
{
|
||||
#region 根据项目、单位获取专项检查列表
|
||||
|
||||
public static List<Model.CheckSpecialSyncItem> GetCheckSpecialLitsByprojectIdUnitId(string projectId,
|
||||
string unitId, string dataId = "")
|
||||
public class APICheckSpecialSyncService
|
||||
{
|
||||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||||
#region 根据项目、单位获取专项检查列表
|
||||
|
||||
public static List<Model.CheckSpecialSyncItem> GetCheckSpecialLitsByprojectIdUnitId(string projectId,
|
||||
string unitId, string dataId = "")
|
||||
{
|
||||
var list = from x in db.Check_CheckSpecial where x.ProjectId == projectId select x;
|
||||
if (!string.IsNullOrEmpty(unitId))
|
||||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||||
{
|
||||
// 通过关联明细表来筛选包含指定单位的主表数据
|
||||
var specialIdsWithUnit = (from detail in db.Check_CheckSpecialDetail
|
||||
where detail.UnitId == unitId
|
||||
select detail.CheckSpecialId).Distinct();
|
||||
|
||||
list = list.Where(x => specialIdsWithUnit.Contains(x.CheckSpecialId));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(dataId))
|
||||
{
|
||||
list = list.Where(x => x.CheckSpecialId == dataId);
|
||||
}
|
||||
|
||||
var dataList = (from x in list
|
||||
join cis in db.Technique_CheckItemSet on x.CheckItemSetId equals cis.CheckItemSetId into cisTemp
|
||||
from cis in cisTemp.DefaultIfEmpty()
|
||||
join att in db.AttachFile on x.CheckSpecialId equals att.ToKeyId into attTemp
|
||||
from att in attTemp.DefaultIfEmpty()
|
||||
select new CheckSpecialSyncItem
|
||||
var list = from x in db.Check_CheckSpecial where x.ProjectId == projectId select x;
|
||||
if (!string.IsNullOrEmpty(unitId))
|
||||
{
|
||||
CheckSpecialId = x.CheckSpecialId,
|
||||
CheckSpecialCode = x.CheckSpecialCode,
|
||||
ProjectId = x.ProjectId,
|
||||
CheckPerson = x.CheckPerson,
|
||||
CheckTime = x.CheckTime,
|
||||
ScanUrl = x.ScanUrl,
|
||||
DaySummary = x.DaySummary,
|
||||
PartInUnits = x.PartInUnits,
|
||||
PartInPersons = x.PartInPersons,
|
||||
CheckAreas = x.CheckAreas,
|
||||
States = x.States,
|
||||
CompileMan = x.CompileMan,
|
||||
CheckType = x.CheckType,
|
||||
PartInPersonIds = x.PartInPersonIds,
|
||||
PartInPersonNames = x.PartInPersonNames,
|
||||
CheckItemSetId = x.CheckItemSetId,
|
||||
CheckItemName = cis.CheckItemName,
|
||||
AttachFileId1 = att.AttachFileId,
|
||||
ToKeyId1 = att.ToKeyId,
|
||||
AttachSource1 = att.AttachSource,
|
||||
AttachUrl1 = att.AttachUrl,
|
||||
CheckSpecialDetails = GetCheckSpecialDetailLists(x.CheckSpecialId),
|
||||
}).ToList();
|
||||
// 通过关联明细表来筛选包含指定单位的主表数据
|
||||
var specialIdsWithUnit = (from detail in db.Check_CheckSpecialDetail
|
||||
where detail.UnitId == unitId
|
||||
select detail.CheckSpecialId).Distinct();
|
||||
|
||||
return dataList;
|
||||
list = list.Where(x => specialIdsWithUnit.Contains(x.CheckSpecialId));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(dataId))
|
||||
{
|
||||
list = list.Where(x => x.CheckSpecialId == dataId);
|
||||
}
|
||||
|
||||
var dataList = (from x in list
|
||||
join cis in db.Technique_CheckItemSet on x.CheckItemSetId equals cis.CheckItemSetId into cisTemp
|
||||
from cis in cisTemp.DefaultIfEmpty()
|
||||
join att in db.AttachFile on x.CheckSpecialId equals att.ToKeyId into attTemp
|
||||
from att in attTemp.DefaultIfEmpty()
|
||||
select new CheckSpecialSyncItem
|
||||
{
|
||||
CheckSpecialId = x.CheckSpecialId,
|
||||
CheckSpecialCode = x.CheckSpecialCode,
|
||||
ProjectId = x.ProjectId,
|
||||
CheckPerson = x.CheckPerson,
|
||||
CheckTime = x.CheckTime,
|
||||
ScanUrl = x.ScanUrl,
|
||||
DaySummary = x.DaySummary,
|
||||
PartInUnits = x.PartInUnits,
|
||||
PartInPersons = x.PartInPersons,
|
||||
CheckAreas = x.CheckAreas,
|
||||
States = x.States,
|
||||
CompileMan = x.CompileMan,
|
||||
CheckType = x.CheckType,
|
||||
PartInPersonIds = x.PartInPersonIds,
|
||||
PartInPersonNames = x.PartInPersonNames,
|
||||
CheckItemSetId = x.CheckItemSetId,
|
||||
CheckItemName = cis.CheckItemName,
|
||||
AttachFileId1 = att.AttachFileId,
|
||||
ToKeyId1 = att.ToKeyId,
|
||||
AttachSource1 = att.AttachSource,
|
||||
AttachUrl1 = att.AttachUrl,
|
||||
CheckSpecialDetails = GetCheckSpecialDetailLists(x.CheckSpecialId),
|
||||
}).ToList();
|
||||
|
||||
return dataList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//根据专项检查id获取专项检查明细数据
|
||||
public static List<Model.CheckSpecialDetailSyncItem> GetCheckSpecialDetailLists(string checkSpecialId)
|
||||
{
|
||||
var detailLists = (from x in Funs.DB.Check_CheckSpecialDetail
|
||||
join ht in Funs.DB.HSSE_Hazard_HazardRegisterTypes on x.CheckItem equals ht.RegisterTypesId into htTemp
|
||||
from ht in htTemp.DefaultIfEmpty()
|
||||
join uw in Funs.DB.WBS_UnitWork on x.CheckArea equals uw.UnitWorkId into uwTemp
|
||||
from uw in uwTemp.DefaultIfEmpty()
|
||||
join u1 in Funs.DB.Sys_User on x.HSEManage equals u1.UserId into u1Temp
|
||||
from u1 in u1Temp.DefaultIfEmpty()
|
||||
join att in Funs.DB.AttachFile on x.CheckSpecialDetailId equals att.ToKeyId into attTemp
|
||||
from att in attTemp.DefaultIfEmpty()
|
||||
where x.CheckSpecialId == checkSpecialId
|
||||
select new CheckSpecialDetailSyncItem
|
||||
{
|
||||
CheckSpecialDetailId = x.CheckSpecialDetailId,
|
||||
CheckSpecialId = x.CheckSpecialId,
|
||||
CheckItem = x.CheckItem,
|
||||
CheckItemName = ht.RegisterTypesName,
|
||||
CheckItemType = x.CheckItemType,
|
||||
Unqualified = x.Unqualified,
|
||||
CheckArea = x.CheckArea,
|
||||
CheckAreaName = uw.UnitWorkName,
|
||||
UnitId = x.UnitId,
|
||||
CompleteStatus = x.CompleteStatus,
|
||||
LimitedDate = x.LimitedDate,
|
||||
CompletedDate = x.CompletedDate,
|
||||
Suggestions = x.Suggestions,
|
||||
HandleStep = x.HandleStep,
|
||||
RectifyNoticeId = x.RectifyNoticeId,
|
||||
CheckContent = x.CheckContent,
|
||||
WorkArea = x.WorkArea,
|
||||
DataId = x.DataId,
|
||||
DataType = x.DataType,
|
||||
SortIndex = x.SortIndex,
|
||||
HiddenHazardType = x.HiddenHazardType,
|
||||
HSEManage = x.HSEManage,
|
||||
HSEManageName = u1.UserName,
|
||||
RiskLevel = x.RiskLevel,
|
||||
LimitDate = x.LimitDate,
|
||||
AttachUrl = x.AttachUrl,
|
||||
HandleWay = x.HandleWay,
|
||||
RectifyOpinion = x.RectifyOpinion,
|
||||
RectifyDate = x.RectifyDate,
|
||||
ReAttachUrl = x.ReAttachUrl,
|
||||
State = x.State,
|
||||
ProposeUnitId = x.ProposeUnitId,
|
||||
SaveHandleMan = x.SaveHandleMan,
|
||||
AttachFileId1 = att.AttachFileId,
|
||||
ToKeyId1 = att.ToKeyId,
|
||||
AttachSource1 = att.AttachSource,
|
||||
AttachUrl1 = att.AttachUrl,
|
||||
})
|
||||
.ToList();
|
||||
|
||||
return detailLists;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 拉取项目专项检查数据
|
||||
|
||||
public static async Task<string> getCheckSpecialLists(string projectId = "")
|
||||
{
|
||||
int code = 0;
|
||||
string message = "";
|
||||
try
|
||||
//根据专项检查id获取专项检查明细数据
|
||||
public static List<Model.CheckSpecialDetailSyncItem> GetCheckSpecialDetailLists(string checkSpecialId)
|
||||
{
|
||||
string CollCropCode = string.Empty;
|
||||
string unitId = string.Empty;
|
||||
var thisUnit = CommonService.GetIsThisUnit(); //当前单位
|
||||
if (thisUnit != null)
|
||||
{
|
||||
CollCropCode = thisUnit.CollCropCode; //社会统一信用代码
|
||||
unitId = thisUnit.UnitId;
|
||||
}
|
||||
var detailLists = (from x in Funs.DB.Check_CheckSpecialDetail
|
||||
join ht in Funs.DB.HSSE_Hazard_HazardRegisterTypes on x.CheckItem equals ht.RegisterTypesId into htTemp
|
||||
from ht in htTemp.DefaultIfEmpty()
|
||||
join uw in Funs.DB.WBS_UnitWork on x.CheckArea equals uw.UnitWorkId into uwTemp
|
||||
from uw in uwTemp.DefaultIfEmpty()
|
||||
join u1 in Funs.DB.Sys_User on x.HSEManage equals u1.UserId into u1Temp
|
||||
from u1 in u1Temp.DefaultIfEmpty()
|
||||
join att in Funs.DB.AttachFile on x.CheckSpecialDetailId equals att.ToKeyId into attTemp
|
||||
from att in attTemp.DefaultIfEmpty()
|
||||
where x.CheckSpecialId == checkSpecialId
|
||||
select new CheckSpecialDetailSyncItem
|
||||
{
|
||||
CheckSpecialDetailId = x.CheckSpecialDetailId,
|
||||
CheckSpecialId = x.CheckSpecialId,
|
||||
CheckItem = x.CheckItem,
|
||||
CheckItemName = ht.RegisterTypesName,
|
||||
CheckItemType = x.CheckItemType,
|
||||
Unqualified = x.Unqualified,
|
||||
CheckArea = x.CheckArea,
|
||||
CheckAreaName = uw.UnitWorkName,
|
||||
UnitId = x.UnitId,
|
||||
CompleteStatus = x.CompleteStatus,
|
||||
LimitedDate = x.LimitedDate,
|
||||
CompletedDate = x.CompletedDate,
|
||||
Suggestions = x.Suggestions,
|
||||
HandleStep = x.HandleStep,
|
||||
RectifyNoticeId = x.RectifyNoticeId,
|
||||
CheckContent = x.CheckContent,
|
||||
WorkArea = x.WorkArea,
|
||||
DataId = x.DataId,
|
||||
DataType = x.DataType,
|
||||
SortIndex = x.SortIndex,
|
||||
HiddenHazardType = x.HiddenHazardType,
|
||||
HSEManage = x.HSEManage,
|
||||
HSEManageName = u1.UserName,
|
||||
RiskLevel = x.RiskLevel,
|
||||
LimitDate = x.LimitDate,
|
||||
AttachUrl = x.AttachUrl,
|
||||
HandleWay = x.HandleWay,
|
||||
RectifyOpinion = x.RectifyOpinion,
|
||||
RectifyDate = x.RectifyDate,
|
||||
ReAttachUrl = x.ReAttachUrl,
|
||||
State = x.State,
|
||||
ProposeUnitId = x.ProposeUnitId,
|
||||
SaveHandleMan = x.SaveHandleMan,
|
||||
AttachFileId1 = att.AttachFileId,
|
||||
ToKeyId1 = att.ToKeyId,
|
||||
AttachSource1 = att.AttachSource,
|
||||
AttachUrl1 = att.AttachUrl,
|
||||
})
|
||||
.ToList();
|
||||
|
||||
var ProjectList = (from x in Funs.DB.Base_Project
|
||||
where (x.IsDelete == null || x.IsDelete == false) && x.SubjectUnit != null &&
|
||||
x.SubjectProject != null
|
||||
select x).ToList();
|
||||
|
||||
if (!string.IsNullOrEmpty(projectId))
|
||||
return detailLists;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 拉取项目专项检查数据
|
||||
|
||||
public static async Task<string> getCheckSpecialLists(string projectId = "")
|
||||
{
|
||||
int code = 0;
|
||||
string message = "";
|
||||
try
|
||||
{
|
||||
ProjectList = ProjectList.Where(x => x.ProjectId == projectId).ToList();
|
||||
}
|
||||
|
||||
if (ProjectList.Count > 0)
|
||||
{
|
||||
foreach (var project in ProjectList)
|
||||
string CollCropCode = string.Empty;
|
||||
string unitId = string.Empty;
|
||||
var thisUnit = CommonService.GetIsThisUnit(); //当前单位
|
||||
if (thisUnit != null)
|
||||
{
|
||||
string SubjectUnitId = project.SubjectUnit; //集团的单位id
|
||||
string SubjectProjectId = project.SubjectProject; //集团的单位id
|
||||
//获取对应单位的apiurl地址
|
||||
var Url = BLL.UnitService.getUnitApiUrlByUnitId(SubjectUnitId);
|
||||
var ApiUrl = "";
|
||||
var WebUrl = "";
|
||||
if (!string.IsNullOrEmpty(Url))
|
||||
CollCropCode = thisUnit.CollCropCode; //社会统一信用代码
|
||||
unitId = thisUnit.UnitId;
|
||||
}
|
||||
|
||||
var ProjectList = (from x in Funs.DB.Base_Project
|
||||
where (x.IsDelete == null || x.IsDelete == false) && x.SubjectUnit != null &&
|
||||
x.SubjectProject != null
|
||||
select x).ToList();
|
||||
|
||||
if (!string.IsNullOrEmpty(projectId))
|
||||
{
|
||||
ProjectList = ProjectList.Where(x => x.ProjectId == projectId).ToList();
|
||||
}
|
||||
|
||||
if (ProjectList.Count > 0)
|
||||
{
|
||||
foreach (var project in ProjectList)
|
||||
{
|
||||
var urls = Url.Split(',');
|
||||
ApiUrl = urls[0];
|
||||
if (urls.Length > 1)
|
||||
string SubjectUnitId = project.SubjectUnit; //集团的单位id
|
||||
string SubjectProjectId = project.SubjectProject; //集团的单位id
|
||||
string ApiUrl = project.SubjectUnitApiUrl;
|
||||
string WebUrl = project.SubjectUnitWebUrl;
|
||||
|
||||
// CollCropCode = "913404001520228377Y"; //三化建 测试使用
|
||||
// SubjectProjectId = "B409A8D7-48C7-486E-84C7-E3E7B2C0E5B7";//测试使用
|
||||
|
||||
string url = "/api/CheckSpecialSync/getCheckSpecialListByProjectIdAndCollCropCode?projectId=" +
|
||||
SubjectProjectId + "&collCropCode=" + CollCropCode;
|
||||
string baseurl = ApiUrl + url;
|
||||
|
||||
string contenttype = "application/json;charset=unicode";
|
||||
var strJosn = APIGetHttpService.Http(baseurl, "GET", contenttype, null, null);
|
||||
if (!string.IsNullOrEmpty(strJosn))
|
||||
{
|
||||
WebUrl = urls[1];
|
||||
}
|
||||
}
|
||||
|
||||
// CollCropCode = "913404001520228377Y"; //三化建 测试使用
|
||||
// SubjectProjectId = "B409A8D7-48C7-486E-84C7-E3E7B2C0E5B7";//测试使用
|
||||
|
||||
string url = "/api/CheckSpecialSync/getCheckSpecialListByProjectIdAndCollCropCode?projectId=" +
|
||||
SubjectProjectId + "&collCropCode=" + CollCropCode;
|
||||
string baseurl = ApiUrl + url;
|
||||
|
||||
string contenttype = "application/json;charset=unicode";
|
||||
var strJosn = APIGetHttpService.Http(baseurl, "GET", contenttype, null, null);
|
||||
if (!string.IsNullOrEmpty(strJosn))
|
||||
{
|
||||
JObject obj = JObject.Parse(strJosn);
|
||||
code = Funs.GetNewIntOrZero(obj["code"].ToString());
|
||||
message = obj["message"].ToString();
|
||||
if (code == 1)
|
||||
{
|
||||
var getData =
|
||||
JsonConvert.DeserializeObject<List<CheckSpecialSyncItem>>(obj["data"].ToString());
|
||||
if (getData.Count() > 0)
|
||||
JObject obj = JObject.Parse(strJosn);
|
||||
code = Funs.GetNewIntOrZero(obj["code"].ToString());
|
||||
message = obj["message"].ToString();
|
||||
if (code == 1)
|
||||
{
|
||||
ProcessCheckSpecialData(getData, project.ProjectId, unitId, WebUrl);
|
||||
var getData =
|
||||
JsonConvert.DeserializeObject<List<CheckSpecialSyncItem>>(obj["data"].ToString());
|
||||
if (getData.Count() > 0)
|
||||
{
|
||||
ProcessCheckSpecialData(getData, project.ProjectId, unitId, WebUrl);
|
||||
}
|
||||
|
||||
message = "获取成功:同步专项检查数" + getData.Count().ToString() + "条";
|
||||
}
|
||||
|
||||
message = "获取成功:同步专项检查数" + getData.Count().ToString() + "条";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
message = "获取失败:" + ex.Message;
|
||||
ErrLogInfo.WriteLog("专项检查获取!", ex);
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 推送专项检查数据
|
||||
|
||||
public static ReturnData pushCheckSpecialLists(string projectId, string dataId = "")
|
||||
{
|
||||
Model.ReturnData responeData = new Model.ReturnData();
|
||||
responeData.code = 0;
|
||||
responeData.message = string.Empty;
|
||||
try
|
||||
{
|
||||
var project = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectId == projectId);
|
||||
if (project != null)
|
||||
catch (Exception ex)
|
||||
{
|
||||
//获取专项检查数据
|
||||
var items = GetCheckSpecialLitsByprojectIdUnitId(projectId, "", dataId);
|
||||
//总包地址推送
|
||||
if (items.Count() > 0)
|
||||
message = "获取失败:" + ex.Message;
|
||||
ErrLogInfo.WriteLog("专项检查获取!", ex);
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 推送专项检查数据
|
||||
|
||||
public static ReturnData pushCheckSpecialLists(string projectId, string dataId = "")
|
||||
{
|
||||
Model.ReturnData responeData = new Model.ReturnData();
|
||||
responeData.code = 0;
|
||||
responeData.message = string.Empty;
|
||||
try
|
||||
{
|
||||
var project = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectId == projectId);
|
||||
if (project != null)
|
||||
{
|
||||
var thisUnit = CommonService.GetIsThisUnit(); //当前单位
|
||||
var apiurl = "/api/CheckSpecialSync/SaveCheckSpecialSyncData";
|
||||
//总包单位接口地址
|
||||
var Url = BLL.UnitService.getUnitApiUrlByUnitId(project.SubjectUnit);
|
||||
var ApiUrl = "";
|
||||
var WebUrl = "";
|
||||
if (!string.IsNullOrEmpty(Url))
|
||||
//获取专项检查数据
|
||||
var items = GetCheckSpecialLitsByprojectIdUnitId(projectId, "", dataId);
|
||||
//总包地址推送
|
||||
if (items.Count() > 0)
|
||||
{
|
||||
var urls = Url.Split(',');
|
||||
ApiUrl = urls[0];
|
||||
if (urls.Length > 1)
|
||||
var thisUnit = CommonService.GetIsThisUnit(); //当前单位
|
||||
var apiurl = "/api/CheckSpecialSync/SaveCheckSpecialSyncData";
|
||||
string ApiUrl = project.SubjectUnitApiUrl;
|
||||
string WebUrl = project.SubjectUnitWebUrl;
|
||||
|
||||
// thisUnit.CollCropCode = "913404001520228377Y";//测试使用
|
||||
// project.SubjectProject = "B409A8D7-48C7-486E-84C7-E3E7B2C0E5B7";//测试使用
|
||||
|
||||
var pushData = new CheckSpecialSyncData
|
||||
{
|
||||
WebUrl = urls[1];
|
||||
CollCropCode = thisUnit.CollCropCode, //分包单位社会统一信用码
|
||||
ProjectId = project.SubjectProject, //主包项目Id
|
||||
UnitDomain = Funs.SGGLUrl, //分包单位域名地址【文件存储地址】
|
||||
Items = items //专项检查数据
|
||||
};
|
||||
var pushContent = JsonConvert.SerializeObject(pushData);
|
||||
string baseurl = ApiUrl + apiurl;
|
||||
string contenttype = "application/json;charset=unicode";
|
||||
var returndata = APIGetHttpService.Http(baseurl, "Post", contenttype, null, pushContent);
|
||||
if (!string.IsNullOrEmpty(returndata))
|
||||
{
|
||||
JObject obj = JObject.Parse(returndata);
|
||||
string code = obj["code"].ToString();
|
||||
string message = obj["message"].ToString();
|
||||
responeData.code = int.Parse(code);
|
||||
responeData.message = message;
|
||||
}
|
||||
}
|
||||
|
||||
// thisUnit.CollCropCode = "913404001520228377Y";//测试使用
|
||||
// project.SubjectProject = "B409A8D7-48C7-486E-84C7-E3E7B2C0E5B7";//测试使用
|
||||
|
||||
var pushData = new CheckSpecialSyncData
|
||||
{
|
||||
CollCropCode = thisUnit.CollCropCode, //分包单位社会统一信用码
|
||||
ProjectId = project.SubjectProject, //主包项目Id
|
||||
UnitDomain = Funs.SGGLUrl, //分包单位域名地址【文件存储地址】
|
||||
Items = items //专项检查数据
|
||||
};
|
||||
var pushContent = JsonConvert.SerializeObject(pushData);
|
||||
string baseurl = ApiUrl + apiurl;
|
||||
string contenttype = "application/json;charset=unicode";
|
||||
var returndata = APIGetHttpService.Http(baseurl, "Post", contenttype, null, pushContent);
|
||||
if (!string.IsNullOrEmpty(returndata))
|
||||
{
|
||||
JObject obj = JObject.Parse(returndata);
|
||||
string code = obj["code"].ToString();
|
||||
string message = obj["message"].ToString();
|
||||
responeData.code = int.Parse(code);
|
||||
responeData.message = message;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "当前没有项目专项检查数据";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.message = "同步到总包单位失败!";
|
||||
ErrLogInfo.WriteLog("【项目专项检查】同步到总包单位失败!", ex);
|
||||
}
|
||||
|
||||
return responeData;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 接收保存项目专项检查数据
|
||||
|
||||
public static async Task<string> SaveCheckSpecialSyncData(Model.CheckSpecialSyncData items)
|
||||
{
|
||||
int code = 0;
|
||||
string message = "";
|
||||
try
|
||||
{
|
||||
if (items.Items.Count > 0 || items.Items.Count > 0)
|
||||
{
|
||||
//获取CollCropCode
|
||||
var CollCropCode = items.CollCropCode;
|
||||
var ProjectId = items.ProjectId;
|
||||
var UnitDomain = items.UnitDomain; //分包单位域名地址【文件存储地址】
|
||||
//根据CollCropCode获取单位id
|
||||
var unit = Funs.DB.Base_Unit.FirstOrDefault(x => x.CollCropCode == CollCropCode);
|
||||
if (unit == null)
|
||||
{
|
||||
message = "总包单位不存在本单位,请登录总包系统检查维护本单位信息!";
|
||||
}
|
||||
else
|
||||
{
|
||||
//2、判断主包项目是否存在
|
||||
var porject = BLL.ProjectService.GetProjectByProjectId(ProjectId);
|
||||
if (porject == null)
|
||||
{
|
||||
message = "总包单位不存在本项目,请检查总包项目关联是否正确!";
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcessCheckSpecialData(items.Items, ProjectId, unit.UnitId, UnitDomain);
|
||||
message = "数据推送成功!";
|
||||
responeData.code = 0;
|
||||
responeData.message = "当前没有项目专项检查数据";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Exception ex)
|
||||
{
|
||||
message = "暂无项目专项检查数据!";
|
||||
responeData.message = "同步到总包单位失败!";
|
||||
ErrLogInfo.WriteLog("【项目专项检查】同步到总包单位失败!", ex);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
|
||||
return responeData;
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#region 接收保存项目专项检查数据
|
||||
|
||||
#region 处理单项目专项检查数据的新增或更新逻辑
|
||||
|
||||
/// <summary>
|
||||
/// 处理单项目专项检查数据的新增或更新逻辑
|
||||
/// </summary>
|
||||
/// <param name="item">专项检查数据项</param>
|
||||
/// <param name="projectId">项目id</param>
|
||||
/// <param name="unitId">单位ID</param>
|
||||
/// <param name="WebUrl">Web地址</param>
|
||||
private static void ProcessCheckSpecialData(List<Model.CheckSpecialSyncItem> getData, string projectId,
|
||||
string unitId, string WebUrl)
|
||||
{
|
||||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||||
public static async Task<string> SaveCheckSpecialSyncData(Model.CheckSpecialSyncData items)
|
||||
{
|
||||
foreach (var item in getData)
|
||||
int code = 0;
|
||||
string message = "";
|
||||
try
|
||||
{
|
||||
var model = db.Check_CheckSpecial.FirstOrDefault(e => e.CheckSpecialId == item.CheckSpecialId);
|
||||
if (model == null)
|
||||
if (items.Items.Count > 0 || items.Items.Count > 0)
|
||||
{
|
||||
Model.Check_CheckSpecial newModel = new Model.Check_CheckSpecial
|
||||
//获取CollCropCode
|
||||
var CollCropCode = items.CollCropCode;
|
||||
var ProjectId = items.ProjectId;
|
||||
var UnitDomain = items.UnitDomain; //分包单位域名地址【文件存储地址】
|
||||
//根据CollCropCode获取单位id
|
||||
var unit = Funs.DB.Base_Unit.FirstOrDefault(x => x.CollCropCode == CollCropCode);
|
||||
if (unit == null)
|
||||
{
|
||||
CheckSpecialId = item.CheckSpecialId,
|
||||
CheckSpecialCode = item.CheckSpecialCode,
|
||||
ProjectId = projectId,
|
||||
CheckPerson = item.CheckPerson,
|
||||
CheckTime = item.CheckTime,
|
||||
ScanUrl = item.ScanUrl,
|
||||
DaySummary = item.DaySummary,
|
||||
PartInUnits = item.PartInUnits,
|
||||
PartInPersons = item.PartInPersons,
|
||||
CheckAreas = item.CheckAreas,
|
||||
States = item.States,
|
||||
CompileMan = item.CompileMan,
|
||||
CheckType = item.CheckType,
|
||||
PartInPersonIds = item.PartInPersonIds,
|
||||
PartInPersonNames = item.PartInPersonNames,
|
||||
CheckItemSetId = APIDataShareSyncService.getCheckItemSetId(item.CheckItemName),
|
||||
};
|
||||
|
||||
db.Check_CheckSpecial.InsertOnSubmit(newModel);
|
||||
db.SubmitChanges();
|
||||
message = "总包单位不存在本单位,请登录总包系统检查维护本单位信息!";
|
||||
}
|
||||
else
|
||||
{
|
||||
//2、判断主包项目是否存在
|
||||
var porject = BLL.ProjectService.GetProjectByProjectId(ProjectId);
|
||||
if (porject == null)
|
||||
{
|
||||
message = "总包单位不存在本项目,请检查总包项目关联是否正确!";
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcessCheckSpecialData(items.Items, ProjectId, unit.UnitId, UnitDomain);
|
||||
message = "数据推送成功!";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
model.CheckSpecialId = item.CheckSpecialId;
|
||||
model.CheckSpecialCode = item.CheckSpecialCode;
|
||||
model.ProjectId = projectId;
|
||||
model.CheckPerson = item.CheckPerson;
|
||||
model.CheckTime = item.CheckTime;
|
||||
model.ScanUrl = item.ScanUrl;
|
||||
model.DaySummary = item.DaySummary;
|
||||
model.PartInUnits = item.PartInUnits;
|
||||
model.PartInPersons = item.PartInPersons;
|
||||
model.CheckAreas = item.CheckAreas;
|
||||
model.States = item.States;
|
||||
model.CompileMan = item.CompileMan;
|
||||
model.CheckType = item.CheckType;
|
||||
model.PartInPersonIds = item.PartInPersonIds;
|
||||
model.PartInPersonNames = item.PartInPersonNames;
|
||||
model.CheckItemSetId = APIDataShareSyncService.getCheckItemSetId(item.CheckItemName);
|
||||
db.SubmitChanges();
|
||||
message = "暂无项目专项检查数据!";
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(item.AttachUrl1)) //主表附件
|
||||
{
|
||||
APIDataShareSyncService.OperationAttachFile(WebUrl, item.CheckSpecialId,
|
||||
BLL.Const.ProjectCheckSpecialMenuId, item.AttachUrl1);
|
||||
}
|
||||
|
||||
//处理专项检查明细数据
|
||||
ProcessCheckSpecialDetailData(item.CheckSpecialDetails, projectId, unitId, WebUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 处理单项目专项检查明细数据的新增或更新逻辑
|
||||
|
||||
/// <summary>
|
||||
/// 处理单项目专项检查明细数据的新增或更新逻辑
|
||||
/// </summary>
|
||||
/// <param name="item">专项检查数据项</param>
|
||||
/// <param name="projectId">项目id</param>
|
||||
/// <param name="unitId">单位ID</param>
|
||||
/// <param name="WebUrl">Web地址</param>
|
||||
private static void ProcessCheckSpecialDetailData(List<Model.CheckSpecialDetailSyncItem> getData,
|
||||
string projectId,
|
||||
string unitId, string WebUrl)
|
||||
{
|
||||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||||
{
|
||||
foreach (var item in getData)
|
||||
catch (Exception ex)
|
||||
{
|
||||
var model = db.Check_CheckSpecialDetail.FirstOrDefault(e =>
|
||||
e.CheckSpecialDetailId == item.CheckSpecialDetailId);
|
||||
if (model == null)
|
||||
throw ex;
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 处理单项目专项检查数据的新增或更新逻辑
|
||||
|
||||
/// <summary>
|
||||
/// 处理单项目专项检查数据的新增或更新逻辑
|
||||
/// </summary>
|
||||
/// <param name="item">专项检查数据项</param>
|
||||
/// <param name="projectId">项目id</param>
|
||||
/// <param name="unitId">单位ID</param>
|
||||
/// <param name="WebUrl">Web地址</param>
|
||||
private static void ProcessCheckSpecialData(List<Model.CheckSpecialSyncItem> getData, string projectId,
|
||||
string unitId, string WebUrl)
|
||||
{
|
||||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||||
{
|
||||
foreach (var item in getData)
|
||||
{
|
||||
Model.Check_CheckSpecialDetail newModel = new Model.Check_CheckSpecialDetail
|
||||
var model = db.Check_CheckSpecial.FirstOrDefault(e => e.CheckSpecialId == item.CheckSpecialId);
|
||||
if (model == null)
|
||||
{
|
||||
CheckSpecialDetailId = item.CheckSpecialDetailId,
|
||||
CheckSpecialId = item.CheckSpecialId,
|
||||
CheckItem = APIDataShareSyncService.getRegisterTypesId(item.CheckItemName),
|
||||
CheckItemType = item.CheckItemType,
|
||||
Unqualified = item.Unqualified,
|
||||
CheckArea = APIDataShareSyncService.getUnitWorkId(item.CheckAreaName, projectId),
|
||||
UnitId = unitId,
|
||||
CompleteStatus = item.CompleteStatus,
|
||||
LimitedDate = item.LimitedDate,
|
||||
CompletedDate = item.CompletedDate,
|
||||
Suggestions = item.Suggestions,
|
||||
HandleStep = item.HandleStep,
|
||||
RectifyNoticeId = item.RectifyNoticeId,
|
||||
CheckContent = item.CheckContent,
|
||||
WorkArea = item.WorkArea,
|
||||
DataId = item.DataId,
|
||||
DataType = item.DataType,
|
||||
SortIndex = item.SortIndex,
|
||||
HiddenHazardType = item.HiddenHazardType,
|
||||
HSEManage = APIDataShareSyncService.getUserId(item.HSEManageName),
|
||||
RiskLevel = item.RiskLevel,
|
||||
LimitDate = item.LimitDate,
|
||||
AttachUrl = item.AttachUrl,
|
||||
HandleWay = item.HandleWay,
|
||||
RectifyOpinion = item.RectifyOpinion,
|
||||
RectifyDate = item.RectifyDate,
|
||||
ReAttachUrl = item.ReAttachUrl,
|
||||
State = item.State,
|
||||
ProposeUnitId = item.ProposeUnitId,
|
||||
SaveHandleMan = item.SaveHandleMan,
|
||||
};
|
||||
Model.Check_CheckSpecial newModel = new Model.Check_CheckSpecial
|
||||
{
|
||||
CheckSpecialId = item.CheckSpecialId,
|
||||
CheckSpecialCode = item.CheckSpecialCode,
|
||||
ProjectId = projectId,
|
||||
CheckPerson = item.CheckPerson,
|
||||
CheckTime = item.CheckTime,
|
||||
ScanUrl = item.ScanUrl,
|
||||
DaySummary = item.DaySummary,
|
||||
PartInUnits = item.PartInUnits,
|
||||
PartInPersons = item.PartInPersons,
|
||||
CheckAreas = item.CheckAreas,
|
||||
States = item.States,
|
||||
CompileMan = item.CompileMan,
|
||||
CheckType = item.CheckType,
|
||||
PartInPersonIds = item.PartInPersonIds,
|
||||
PartInPersonNames = item.PartInPersonNames,
|
||||
CheckItemSetId = APIDataShareSyncService.getCheckItemSetId(item.CheckItemName),
|
||||
};
|
||||
|
||||
db.Check_CheckSpecialDetail.InsertOnSubmit(newModel);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
// model.CheckSpecialDetailId = item.CheckSpecialDetailId;
|
||||
model.CheckSpecialId = item.CheckSpecialId;
|
||||
model.CheckItem = APIDataShareSyncService.getRegisterTypesId(item.CheckItemName);
|
||||
model.CheckItemType = item.CheckItemType;
|
||||
model.Unqualified = item.Unqualified;
|
||||
model.CheckArea = APIDataShareSyncService.getUnitWorkId(item.CheckAreaName, projectId);
|
||||
model.UnitId = unitId;
|
||||
model.CompleteStatus = item.CompleteStatus;
|
||||
model.LimitedDate = item.LimitedDate;
|
||||
model.CompletedDate = item.CompletedDate;
|
||||
model.Suggestions = item.Suggestions;
|
||||
model.HandleStep = item.HandleStep;
|
||||
model.RectifyNoticeId = item.RectifyNoticeId;
|
||||
model.CheckContent = item.CheckContent;
|
||||
model.WorkArea = item.WorkArea;
|
||||
model.DataId = item.DataId;
|
||||
model.DataType = item.DataType;
|
||||
model.SortIndex = item.SortIndex;
|
||||
model.HiddenHazardType = item.HiddenHazardType;
|
||||
model.HSEManage = APIDataShareSyncService.getUserId(item.HSEManageName);
|
||||
model.RiskLevel = item.RiskLevel;
|
||||
model.LimitDate = item.LimitDate;
|
||||
model.AttachUrl = item.AttachUrl;
|
||||
model.HandleWay = item.HandleWay;
|
||||
model.RectifyOpinion = item.RectifyOpinion;
|
||||
model.RectifyDate = item.RectifyDate;
|
||||
model.ReAttachUrl = item.ReAttachUrl;
|
||||
model.State = item.State;
|
||||
model.ProposeUnitId = item.ProposeUnitId;
|
||||
model.SaveHandleMan = item.SaveHandleMan;
|
||||
db.Check_CheckSpecial.InsertOnSubmit(newModel);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
model.CheckSpecialId = item.CheckSpecialId;
|
||||
model.CheckSpecialCode = item.CheckSpecialCode;
|
||||
model.ProjectId = projectId;
|
||||
model.CheckPerson = item.CheckPerson;
|
||||
model.CheckTime = item.CheckTime;
|
||||
model.ScanUrl = item.ScanUrl;
|
||||
model.DaySummary = item.DaySummary;
|
||||
model.PartInUnits = item.PartInUnits;
|
||||
model.PartInPersons = item.PartInPersons;
|
||||
model.CheckAreas = item.CheckAreas;
|
||||
model.States = item.States;
|
||||
model.CompileMan = item.CompileMan;
|
||||
model.CheckType = item.CheckType;
|
||||
model.PartInPersonIds = item.PartInPersonIds;
|
||||
model.PartInPersonNames = item.PartInPersonNames;
|
||||
model.CheckItemSetId = APIDataShareSyncService.getCheckItemSetId(item.CheckItemName);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
db.SubmitChanges();
|
||||
}
|
||||
//附件处理
|
||||
BLL.FileInsertService.SaveAttachFileRecords(WebUrl, item.AttachFileId1, item.ToKeyId1, item.AttachSource1, item.AttachUrl1);
|
||||
|
||||
if (!string.IsNullOrEmpty(item.AttachUrl1)) //整改前图片
|
||||
{
|
||||
APIDataShareSyncService.OperationAttachFile(WebUrl, item.CheckSpecialDetailId,
|
||||
BLL.Const.ProjectCheckSpecialMenuId, item.AttachUrl1);
|
||||
//处理专项检查明细数据
|
||||
ProcessCheckSpecialDetailData(item.CheckSpecialDetails, projectId, unitId, WebUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region 处理单项目专项检查明细数据的新增或更新逻辑
|
||||
|
||||
/// <summary>
|
||||
/// 处理单项目专项检查明细数据的新增或更新逻辑
|
||||
/// </summary>
|
||||
/// <param name="item">专项检查数据项</param>
|
||||
/// <param name="projectId">项目id</param>
|
||||
/// <param name="unitId">单位ID</param>
|
||||
/// <param name="WebUrl">Web地址</param>
|
||||
private static void ProcessCheckSpecialDetailData(List<Model.CheckSpecialDetailSyncItem> getData,
|
||||
string projectId,
|
||||
string unitId, string WebUrl)
|
||||
{
|
||||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||||
{
|
||||
foreach (var item in getData)
|
||||
{
|
||||
var model = db.Check_CheckSpecialDetail.FirstOrDefault(e =>
|
||||
e.CheckSpecialDetailId == item.CheckSpecialDetailId);
|
||||
if (model == null)
|
||||
{
|
||||
Model.Check_CheckSpecialDetail newModel = new Model.Check_CheckSpecialDetail
|
||||
{
|
||||
CheckSpecialDetailId = item.CheckSpecialDetailId,
|
||||
CheckSpecialId = item.CheckSpecialId,
|
||||
CheckItem = APIDataShareSyncService.getRegisterTypesId(item.CheckItemName),
|
||||
CheckItemType = item.CheckItemType,
|
||||
Unqualified = item.Unqualified,
|
||||
CheckArea = APIDataShareSyncService.getUnitWorkId(item.CheckAreaName, projectId),
|
||||
UnitId = unitId,
|
||||
CompleteStatus = item.CompleteStatus,
|
||||
LimitedDate = item.LimitedDate,
|
||||
CompletedDate = item.CompletedDate,
|
||||
Suggestions = item.Suggestions,
|
||||
HandleStep = item.HandleStep,
|
||||
RectifyNoticeId = item.RectifyNoticeId,
|
||||
CheckContent = item.CheckContent,
|
||||
WorkArea = item.WorkArea,
|
||||
DataId = item.DataId,
|
||||
DataType = item.DataType,
|
||||
SortIndex = item.SortIndex,
|
||||
HiddenHazardType = item.HiddenHazardType,
|
||||
HSEManage = APIDataShareSyncService.getUserId(item.HSEManageName),
|
||||
RiskLevel = item.RiskLevel,
|
||||
LimitDate = item.LimitDate,
|
||||
AttachUrl = item.AttachUrl,
|
||||
HandleWay = item.HandleWay,
|
||||
RectifyOpinion = item.RectifyOpinion,
|
||||
RectifyDate = item.RectifyDate,
|
||||
ReAttachUrl = item.ReAttachUrl,
|
||||
State = item.State,
|
||||
ProposeUnitId = item.ProposeUnitId,
|
||||
SaveHandleMan = item.SaveHandleMan,
|
||||
};
|
||||
|
||||
db.Check_CheckSpecialDetail.InsertOnSubmit(newModel);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
// model.CheckSpecialDetailId = item.CheckSpecialDetailId;
|
||||
model.CheckSpecialId = item.CheckSpecialId;
|
||||
model.CheckItem = APIDataShareSyncService.getRegisterTypesId(item.CheckItemName);
|
||||
model.CheckItemType = item.CheckItemType;
|
||||
model.Unqualified = item.Unqualified;
|
||||
model.CheckArea = APIDataShareSyncService.getUnitWorkId(item.CheckAreaName, projectId);
|
||||
model.UnitId = unitId;
|
||||
model.CompleteStatus = item.CompleteStatus;
|
||||
model.LimitedDate = item.LimitedDate;
|
||||
model.CompletedDate = item.CompletedDate;
|
||||
model.Suggestions = item.Suggestions;
|
||||
model.HandleStep = item.HandleStep;
|
||||
model.RectifyNoticeId = item.RectifyNoticeId;
|
||||
model.CheckContent = item.CheckContent;
|
||||
model.WorkArea = item.WorkArea;
|
||||
model.DataId = item.DataId;
|
||||
model.DataType = item.DataType;
|
||||
model.SortIndex = item.SortIndex;
|
||||
model.HiddenHazardType = item.HiddenHazardType;
|
||||
model.HSEManage = APIDataShareSyncService.getUserId(item.HSEManageName);
|
||||
model.RiskLevel = item.RiskLevel;
|
||||
model.LimitDate = item.LimitDate;
|
||||
model.AttachUrl = item.AttachUrl;
|
||||
model.HandleWay = item.HandleWay;
|
||||
model.RectifyOpinion = item.RectifyOpinion;
|
||||
model.RectifyDate = item.RectifyDate;
|
||||
model.ReAttachUrl = item.ReAttachUrl;
|
||||
model.State = item.State;
|
||||
model.ProposeUnitId = item.ProposeUnitId;
|
||||
model.SaveHandleMan = item.SaveHandleMan;
|
||||
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
BLL.FileInsertService.SaveAttachFileRecords(WebUrl, item.AttachFileId1, item.ToKeyId1, item.AttachSource1, item.AttachUrl1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -13,455 +13,456 @@ using RestSharp;
|
||||
using System.Net;
|
||||
|
||||
|
||||
namespace BLL;
|
||||
|
||||
public class APIHazardRegisterSyncService
|
||||
namespace BLL
|
||||
{
|
||||
#region 根据项目、单位获取安全检查列表分页
|
||||
|
||||
public static List<Model.HazardRegisterSyncItem> GetHazardRegisterLitsByprojectIdUnitIdPage(string projectId,
|
||||
string unitId, string dataId = "")
|
||||
public class APIHazardRegisterSyncService
|
||||
{
|
||||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||||
#region 根据项目、单位获取安全检查列表分页
|
||||
|
||||
public static List<Model.HazardRegisterSyncItem> GetHazardRegisterLitsByprojectIdUnitIdPage(string projectId,
|
||||
string unitId, string dataId = "")
|
||||
{
|
||||
var list = from x in db.HSSE_Hazard_HazardRegister where x.ProjectId == projectId select x;
|
||||
if (!string.IsNullOrEmpty(unitId))
|
||||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||||
{
|
||||
list = list.Where(x => x.ResponsibleUnit == unitId);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(dataId))
|
||||
{
|
||||
list = list.Where(x => x.HazardRegisterId == dataId);
|
||||
}
|
||||
|
||||
var dataList = (from x in list
|
||||
join ht in db.HSSE_Hazard_HazardRegisterTypes on x.RegisterTypesId equals ht.RegisterTypesId into htTemp
|
||||
from ht in htTemp.DefaultIfEmpty()
|
||||
join uw in db.WBS_UnitWork on x.Place equals uw.UnitWorkId into uwTemp
|
||||
from uw in uwTemp.DefaultIfEmpty()
|
||||
join u1 in db.Sys_User on x.ResponsibleMan equals u1.UserId into u1Temp
|
||||
from u1 in u1Temp.DefaultIfEmpty()
|
||||
join u2 in db.Sys_User on x.CheckManId equals u2.UserId into u2Temp
|
||||
from u2 in u2Temp.DefaultIfEmpty()
|
||||
join u3 in db.Sys_User on x.ConfirmMan equals u3.UserId into u3Temp
|
||||
from u3 in u3Temp.DefaultIfEmpty()
|
||||
join u4 in db.Sys_User on x.ResponsibleMan2 equals u4.UserId into u4Temp
|
||||
from u4 in u4Temp.DefaultIfEmpty()
|
||||
select new HazardRegisterSyncItem
|
||||
var list = from x in db.HSSE_Hazard_HazardRegister where x.ProjectId == projectId select x;
|
||||
if (!string.IsNullOrEmpty(unitId))
|
||||
{
|
||||
HazardRegisterId = x.HazardRegisterId,
|
||||
HazardCode = x.HazardCode,
|
||||
RegisterDate = x.RegisterDate,
|
||||
RegisterDef = x.RegisterDef,
|
||||
Rectification = x.Rectification,
|
||||
Place = x.Place,
|
||||
PlaceName = uw.UnitWorkName,
|
||||
ResponsibleUnit = x.ResponsibleUnit,
|
||||
Observer = x.Observer,
|
||||
RectifiedDate = x.RectifiedDate,
|
||||
AttachUrl = x.AttachUrl,
|
||||
ProjectId = x.ProjectId,
|
||||
States = x.States,
|
||||
IsEffective = x.IsEffective,
|
||||
ResponsibleMan = x.ResponsibleMan,
|
||||
ResponsibleManName = u1.UserName,
|
||||
CheckManId = x.CheckManId,
|
||||
CheckManName = u2.UserName,
|
||||
CheckTime = x.CheckTime,
|
||||
RectificationPeriod = x.RectificationPeriod,
|
||||
ImageUrl = x.ImageUrl,
|
||||
RectificationImageUrl = x.RectificationImageUrl,
|
||||
RectificationTime = x.RectificationTime,
|
||||
ConfirmMan = x.ConfirmMan,
|
||||
ConfirmManName = u3.UserName,
|
||||
ConfirmDate = x.ConfirmDate,
|
||||
HandleIdea = x.HandleIdea,
|
||||
CutPayment = x.CutPayment,
|
||||
ProblemTypes = x.ProblemTypes,
|
||||
RegisterTypesId = x.RegisterTypesId,
|
||||
RegisterTypesName = ht.RegisterTypesName,
|
||||
CheckCycle = x.CheckCycle,
|
||||
CheckItemDetailId = x.CheckItemDetailId,
|
||||
SupCheckItemSetId = x.SupCheckItemSetId,
|
||||
CheckItemSetId = x.CheckItemSetId,
|
||||
CheckSpecialId = x.CheckSpecialId,
|
||||
InstallationId = x.InstallationId,
|
||||
SafeSupervisionId = x.SafeSupervisionId,
|
||||
ResponsibleMan2 = x.ResponsibleMan2,
|
||||
ResponsibleMan2Name = u4.UserName,
|
||||
SafeSupervisionIsOK = x.SafeSupervisionIsOK,
|
||||
GpsLocation = x.GpsLocation,
|
||||
IsWx = x.IsWx,
|
||||
DIC_ID = x.DIC_ID,
|
||||
CCManIds = x.CCManIds,
|
||||
ResultType = x.ResultType,
|
||||
ResultId = x.ResultId,
|
||||
Requirements = x.Requirements,
|
||||
Risk_Level = x.Risk_Level,
|
||||
ControlId = x.ControlId,
|
||||
DataSource = "1",
|
||||
}).ToList();
|
||||
list = list.Where(x => x.ResponsibleUnit == unitId);
|
||||
}
|
||||
|
||||
return dataList;
|
||||
if (!string.IsNullOrEmpty(dataId))
|
||||
{
|
||||
list = list.Where(x => x.HazardRegisterId == dataId);
|
||||
}
|
||||
|
||||
var dataList = (from x in list
|
||||
join ht in db.HSSE_Hazard_HazardRegisterTypes on x.RegisterTypesId equals ht.RegisterTypesId into htTemp
|
||||
from ht in htTemp.DefaultIfEmpty()
|
||||
join uw in db.WBS_UnitWork on x.Place equals uw.UnitWorkId into uwTemp
|
||||
from uw in uwTemp.DefaultIfEmpty()
|
||||
join u1 in db.Sys_User on x.ResponsibleMan equals u1.UserId into u1Temp
|
||||
from u1 in u1Temp.DefaultIfEmpty()
|
||||
join u2 in db.Sys_User on x.CheckManId equals u2.UserId into u2Temp
|
||||
from u2 in u2Temp.DefaultIfEmpty()
|
||||
join u3 in db.Sys_User on x.ConfirmMan equals u3.UserId into u3Temp
|
||||
from u3 in u3Temp.DefaultIfEmpty()
|
||||
join u4 in db.Sys_User on x.ResponsibleMan2 equals u4.UserId into u4Temp
|
||||
from u4 in u4Temp.DefaultIfEmpty()
|
||||
join att1 in db.AttachFile on x.HazardRegisterId equals att1.ToKeyId into att1Temp
|
||||
from att1 in att1Temp.DefaultIfEmpty()
|
||||
join att2 in db.AttachFile on (x.HazardRegisterId + "-R") equals att2.ToKeyId into att2Temp
|
||||
from att2 in att2Temp.DefaultIfEmpty()
|
||||
select new HazardRegisterSyncItem
|
||||
{
|
||||
HazardRegisterId = x.HazardRegisterId,
|
||||
HazardCode = x.HazardCode,
|
||||
RegisterDate = x.RegisterDate,
|
||||
RegisterDef = x.RegisterDef,
|
||||
Rectification = x.Rectification,
|
||||
Place = x.Place,
|
||||
PlaceName = uw.UnitWorkName,
|
||||
ResponsibleUnit = x.ResponsibleUnit,
|
||||
Observer = x.Observer,
|
||||
RectifiedDate = x.RectifiedDate,
|
||||
AttachUrl = x.AttachUrl,
|
||||
ProjectId = x.ProjectId,
|
||||
States = x.States,
|
||||
IsEffective = x.IsEffective,
|
||||
ResponsibleMan = x.ResponsibleMan,
|
||||
ResponsibleManName = u1.UserName,
|
||||
CheckManId = x.CheckManId,
|
||||
CheckManName = u2.UserName,
|
||||
CheckTime = x.CheckTime,
|
||||
RectificationPeriod = x.RectificationPeriod,
|
||||
ImageUrl = x.ImageUrl,
|
||||
RectificationImageUrl = x.RectificationImageUrl,
|
||||
RectificationTime = x.RectificationTime,
|
||||
ConfirmMan = x.ConfirmMan,
|
||||
ConfirmManName = u3.UserName,
|
||||
ConfirmDate = x.ConfirmDate,
|
||||
HandleIdea = x.HandleIdea,
|
||||
CutPayment = x.CutPayment,
|
||||
ProblemTypes = x.ProblemTypes,
|
||||
RegisterTypesId = x.RegisterTypesId,
|
||||
RegisterTypesName = ht.RegisterTypesName,
|
||||
CheckCycle = x.CheckCycle,
|
||||
CheckItemDetailId = x.CheckItemDetailId,
|
||||
SupCheckItemSetId = x.SupCheckItemSetId,
|
||||
CheckItemSetId = x.CheckItemSetId,
|
||||
CheckSpecialId = x.CheckSpecialId,
|
||||
InstallationId = x.InstallationId,
|
||||
SafeSupervisionId = x.SafeSupervisionId,
|
||||
ResponsibleMan2 = x.ResponsibleMan2,
|
||||
ResponsibleMan2Name = u4.UserName,
|
||||
SafeSupervisionIsOK = x.SafeSupervisionIsOK,
|
||||
GpsLocation = x.GpsLocation,
|
||||
IsWx = x.IsWx,
|
||||
DIC_ID = x.DIC_ID,
|
||||
CCManIds = x.CCManIds,
|
||||
ResultType = x.ResultType,
|
||||
ResultId = x.ResultId,
|
||||
Requirements = x.Requirements,
|
||||
Risk_Level = x.Risk_Level,
|
||||
ControlId = x.ControlId,
|
||||
AttachFileId1 = att1.AttachFileId,
|
||||
ToKeyId1 = att1.ToKeyId,
|
||||
AttachSource1 = att1.AttachSource,
|
||||
AttachUrl1 = att1.AttachUrl,
|
||||
AttachFileId2 = att2.AttachFileId,
|
||||
ToKeyId2 = att2.ToKeyId,
|
||||
AttachSource2 = att2.AttachSource,
|
||||
AttachUrl2 = att2.AttachUrl,
|
||||
DataSource = "1",
|
||||
}).ToList();
|
||||
|
||||
return dataList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
|
||||
#region 拉取项目安全检查数据
|
||||
#region 拉取项目安全检查数据
|
||||
|
||||
public static string getHazardRegisterLists(string projectId = "")
|
||||
{
|
||||
int code = 0;
|
||||
string message = "";
|
||||
try
|
||||
public static string getHazardRegisterLists(string projectId = "")
|
||||
{
|
||||
string CollCropCode = string.Empty;
|
||||
string unitId = string.Empty;
|
||||
var thisUnit = CommonService.GetIsThisUnit(); //当前单位
|
||||
if (thisUnit != null)
|
||||
int code = 0;
|
||||
string message = "";
|
||||
try
|
||||
{
|
||||
CollCropCode = thisUnit.CollCropCode; //社会统一信用代码
|
||||
unitId = thisUnit.UnitId;
|
||||
}
|
||||
|
||||
var ProjectList = (from x in Funs.DB.Base_Project
|
||||
where (x.IsDelete == null || x.IsDelete == false) && x.SubjectUnit != null &&
|
||||
x.SubjectProject != null
|
||||
select x).ToList();
|
||||
|
||||
if (!string.IsNullOrEmpty(projectId))
|
||||
{
|
||||
ProjectList = ProjectList.Where(x => x.ProjectId == projectId).ToList();
|
||||
}
|
||||
|
||||
if (ProjectList.Count > 0)
|
||||
{
|
||||
foreach (var project in ProjectList)
|
||||
string CollCropCode = string.Empty;
|
||||
string unitId = string.Empty;
|
||||
var thisUnit = CommonService.GetIsThisUnit(); //当前单位
|
||||
if (thisUnit != null)
|
||||
{
|
||||
string SubjectUnitId = project.SubjectUnit; //集团的单位id
|
||||
string SubjectProjectId = project.SubjectProject; //集团的项目id
|
||||
//获取对应单位的apiurl地址
|
||||
var Url = BLL.UnitService.getUnitApiUrlByUnitId(SubjectUnitId);
|
||||
var ApiUrl = "";
|
||||
var WebUrl = "";
|
||||
if (!string.IsNullOrEmpty(Url))
|
||||
{
|
||||
var urls = Url.Split(',');
|
||||
ApiUrl = urls[0];
|
||||
if (urls.Length > 1)
|
||||
{
|
||||
WebUrl = urls[1];
|
||||
}
|
||||
}
|
||||
CollCropCode = thisUnit.CollCropCode; //社会统一信用代码
|
||||
unitId = thisUnit.UnitId;
|
||||
}
|
||||
|
||||
// CollCropCode = "91420000177570439L"; //三化建 测试使用
|
||||
// SubjectProjectId = "c7ade79e-7646-4c59-a8fd-020a7e3138c6";//测试使用
|
||||
var ProjectList = (from x in Funs.DB.Base_Project
|
||||
where (x.IsDelete == null || x.IsDelete == false) && x.SubjectUnit != null &&
|
||||
x.SubjectProject != null
|
||||
select x).ToList();
|
||||
|
||||
string url =
|
||||
"/api/HazardRegisterSync/getHazardRegisterListByProjectIdAndCollCropCode?projectId=" +
|
||||
SubjectProjectId + "&collCropCode=" + CollCropCode;
|
||||
string baseurl = ApiUrl + url;
|
||||
string contenttype = "application/json;charset=unicode";
|
||||
var strJosn = APIGetHttpService.Http(baseurl, "GET", contenttype, null, null);
|
||||
if (!string.IsNullOrEmpty(strJosn))
|
||||
if (!string.IsNullOrEmpty(projectId))
|
||||
{
|
||||
ProjectList = ProjectList.Where(x => x.ProjectId == projectId).ToList();
|
||||
}
|
||||
|
||||
if (ProjectList.Count > 0)
|
||||
{
|
||||
foreach (var project in ProjectList)
|
||||
{
|
||||
JObject obj = JObject.Parse(strJosn);
|
||||
code = Funs.GetNewIntOrZero(obj["code"].ToString());
|
||||
message = obj["message"].ToString();
|
||||
if (code == 1)
|
||||
string SubjectUnitId = project.SubjectUnit; //集团的单位id
|
||||
string SubjectProjectId = project.SubjectProject; //集团的项目id
|
||||
string ApiUrl = project.SubjectUnitApiUrl;
|
||||
string WebUrl = project.SubjectUnitWebUrl;
|
||||
|
||||
|
||||
// CollCropCode = "91420000177570439L"; //三化建 测试使用
|
||||
// SubjectProjectId = "c7ade79e-7646-4c59-a8fd-020a7e3138c6";//测试使用
|
||||
|
||||
string url =
|
||||
"/api/HazardRegisterSync/getHazardRegisterListByProjectIdAndCollCropCode?projectId=" +
|
||||
SubjectProjectId + "&collCropCode=" + CollCropCode;
|
||||
string baseurl = ApiUrl + url;
|
||||
string contenttype = "application/json;charset=unicode";
|
||||
var strJosn = APIGetHttpService.Http(baseurl, "GET", contenttype, null, null);
|
||||
if (!string.IsNullOrEmpty(strJosn))
|
||||
{
|
||||
var getData =
|
||||
JsonConvert.DeserializeObject<List<HazardRegisterSyncItem>>(obj["data"].ToString());
|
||||
if (getData.Count() > 0)
|
||||
JObject obj = JObject.Parse(strJosn);
|
||||
code = Funs.GetNewIntOrZero(obj["code"].ToString());
|
||||
message = obj["message"].ToString();
|
||||
if (code == 1)
|
||||
{
|
||||
ProcessHazardRegisterData(getData, project.ProjectId, unitId, WebUrl,"pull");
|
||||
var getData =
|
||||
JsonConvert.DeserializeObject<List<HazardRegisterSyncItem>>(obj["data"].ToString());
|
||||
if (getData.Count() > 0)
|
||||
{
|
||||
ProcessHazardRegisterData(getData, project.ProjectId, unitId, WebUrl, "pull");
|
||||
}
|
||||
message = "获取成功:同步安全检查数" + getData.Count().ToString() + "条";
|
||||
}
|
||||
message = "获取成功:同步安全检查数" + getData.Count().ToString() + "条";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
message = "获取失败:" + ex.Message;
|
||||
ErrLogInfo.WriteLog("安全检查获取!", ex);
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 推送安全检查数据
|
||||
|
||||
public static ReturnData pushHazardRegisterLists(string projectId, string dataId = "")
|
||||
{
|
||||
Model.ReturnData responeData = new Model.ReturnData();
|
||||
responeData.code = 0;
|
||||
responeData.message = string.Empty;
|
||||
var project = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectId == projectId);
|
||||
try
|
||||
{
|
||||
if (project != null)
|
||||
catch (Exception ex)
|
||||
{
|
||||
//获取安全检查数据
|
||||
var items = GetHazardRegisterLitsByprojectIdUnitIdPage(projectId, "", dataId);
|
||||
//总包地址推送
|
||||
if (items.Count() > 0)
|
||||
message = "获取失败:" + ex.Message;
|
||||
ErrLogInfo.WriteLog("安全检查获取!", ex);
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 推送安全检查数据
|
||||
|
||||
public static ReturnData pushHazardRegisterLists(string projectId, string dataId = "")
|
||||
{
|
||||
Model.ReturnData responeData = new Model.ReturnData();
|
||||
responeData.code = 0;
|
||||
responeData.message = string.Empty;
|
||||
var project = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectId == projectId);
|
||||
try
|
||||
{
|
||||
if (project != null)
|
||||
{
|
||||
var thisUnit = CommonService.GetIsThisUnit(); //当前单位
|
||||
var apiurl = "/api/HazardRegisterSync/SaveHazardRegisterSyncData";
|
||||
//总包单位接口地址
|
||||
var Url = BLL.UnitService.getUnitApiUrlByUnitId(project.SubjectUnit);
|
||||
var ApiUrl = "";
|
||||
var WebUrl = "";
|
||||
if (!string.IsNullOrEmpty(Url))
|
||||
//获取安全检查数据
|
||||
var items = GetHazardRegisterLitsByprojectIdUnitIdPage(projectId, "", dataId);
|
||||
//总包地址推送
|
||||
if (items.Count() > 0)
|
||||
{
|
||||
var urls = Url.Split(',');
|
||||
ApiUrl = urls[0];
|
||||
if (urls.Length > 1)
|
||||
var thisUnit = CommonService.GetIsThisUnit(); //当前单位
|
||||
var apiurl = "/api/HazardRegisterSync/SaveHazardRegisterSyncData";
|
||||
string ApiUrl = project.SubjectUnitApiUrl;
|
||||
string WebUrl = project.SubjectUnitWebUrl;
|
||||
// thisUnit.CollCropCode = "913404001520228377Y";//测试使用
|
||||
// project.SubjectProject = "B409A8D7-48C7-486E-84C7-E3E7B2C0E5B7";//测试使用
|
||||
|
||||
var pushData = new HazardRegisterSyncData
|
||||
{
|
||||
WebUrl = urls[1];
|
||||
CollCropCode = thisUnit.CollCropCode, //分包单位社会统一信用码
|
||||
// CollCropCode = "91420000177570439L", //分包单位社会统一信用码
|
||||
// ProjectId = "c7ade79e-7646-4c59-a8fd-020a7e3138c6", //主包项目Id
|
||||
ProjectId = project.SubjectProject, //主包项目Id
|
||||
UnitDomain = Funs.SGGLUrl, //分包单位域名地址【文件存储地址】
|
||||
Items = items //安全检查数据
|
||||
};
|
||||
var pushContent = JsonConvert.SerializeObject(pushData);
|
||||
string baseurl = ApiUrl + apiurl;
|
||||
string contenttype = "application/json;charset=unicode";
|
||||
var returndata = APIGetHttpService.Http(baseurl, "Post", contenttype, null, pushContent);
|
||||
if (!string.IsNullOrEmpty(returndata))
|
||||
{
|
||||
JObject obj = JObject.Parse(returndata);
|
||||
string code = obj["code"].ToString();
|
||||
string message = obj["message"].ToString();
|
||||
responeData.code = int.Parse(code);
|
||||
responeData.message = message;
|
||||
}
|
||||
}
|
||||
// thisUnit.CollCropCode = "913404001520228377Y";//测试使用
|
||||
// project.SubjectProject = "B409A8D7-48C7-486E-84C7-E3E7B2C0E5B7";//测试使用
|
||||
|
||||
var pushData = new HazardRegisterSyncData
|
||||
{
|
||||
CollCropCode = thisUnit.CollCropCode, //分包单位社会统一信用码
|
||||
// CollCropCode = "91420000177570439L", //分包单位社会统一信用码
|
||||
// ProjectId = "c7ade79e-7646-4c59-a8fd-020a7e3138c6", //主包项目Id
|
||||
ProjectId = project.SubjectProject, //主包项目Id
|
||||
UnitDomain = Funs.SGGLUrl, //分包单位域名地址【文件存储地址】
|
||||
Items = items //安全检查数据
|
||||
};
|
||||
var pushContent = JsonConvert.SerializeObject(pushData);
|
||||
string baseurl = ApiUrl + apiurl;
|
||||
string contenttype = "application/json;charset=unicode";
|
||||
var returndata = APIGetHttpService.Http(baseurl, "Post", contenttype, null, pushContent);
|
||||
if (!string.IsNullOrEmpty(returndata))
|
||||
{
|
||||
JObject obj = JObject.Parse(returndata);
|
||||
string code = obj["code"].ToString();
|
||||
string message = obj["message"].ToString();
|
||||
responeData.code = int.Parse(code);
|
||||
responeData.message = message;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "当前没有项目安全检查数据";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.message = "同步到总包单位失败!";
|
||||
ErrLogInfo.WriteLog("【安全检查】同步到总包单位失败!", ex);
|
||||
}
|
||||
|
||||
return responeData;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 接收保存项目安全检查数据
|
||||
|
||||
public static string SaveHazardRegisterSyncData(Model.HazardRegisterSyncData items)
|
||||
{
|
||||
int code = 0;
|
||||
string message = "";
|
||||
try
|
||||
{
|
||||
if (items.Items.Count > 0 || items.Items.Count > 0)
|
||||
{
|
||||
var CollCropCode = items.CollCropCode; //分包单位社会统一信用码
|
||||
var ProjectId = items.ProjectId; //总包项目Id
|
||||
var UnitDomain = items.UnitDomain; //分包单位域名地址【文件存储地址】
|
||||
var unit = Funs.DB.Base_Unit.FirstOrDefault(x => x.CollCropCode == CollCropCode); //根据CollCropCode获取单位id
|
||||
if (unit == null)
|
||||
{
|
||||
message = "总包单位不存在本单位,请登录总包系统检查维护本单位信息!";
|
||||
}
|
||||
else
|
||||
{
|
||||
//2、判断主包项目是否存在
|
||||
var porject = BLL.ProjectService.GetProjectByProjectId(ProjectId);
|
||||
if (porject == null)
|
||||
{
|
||||
message = "总包单位不存在本项目,请检查总包项目关联是否正确!";
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcessHazardRegisterData(items.Items, ProjectId, unit.UnitId, UnitDomain, "push");
|
||||
message = "数据推送成功!";
|
||||
responeData.code = 0;
|
||||
responeData.message = "当前没有项目安全检查数据";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Exception ex)
|
||||
{
|
||||
message = "暂无项目安全检查数据!";
|
||||
responeData.message = "同步到总包单位失败!";
|
||||
ErrLogInfo.WriteLog("【安全检查】同步到总包单位失败!", ex);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
|
||||
return responeData;
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
|
||||
#region 处理单个安全检查数据的新增或更新逻辑
|
||||
#region 接收保存项目安全检查数据
|
||||
|
||||
/// <summary>
|
||||
/// 处理单个安全检查数据的新增或更新逻辑
|
||||
/// </summary>
|
||||
/// <param name="item">安全检查数据项</param>
|
||||
/// <param name="projectId">项目id</param>
|
||||
/// <param name="unitId">单位ID</param>
|
||||
/// <param name="WebUrl">Web地址</param>
|
||||
private static void ProcessHazardRegisterData(List<Model.HazardRegisterSyncItem> getData, string projectId,
|
||||
string unitId, string WebUrl, string type)
|
||||
{
|
||||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||||
public static string SaveHazardRegisterSyncData(Model.HazardRegisterSyncData items)
|
||||
{
|
||||
foreach (var item in getData)
|
||||
int code = 0;
|
||||
string message = "";
|
||||
try
|
||||
{
|
||||
Model.HSSE_Hazard_HazardRegister model =
|
||||
db.HSSE_Hazard_HazardRegister.FirstOrDefault(x => x.HazardRegisterId == item.HazardRegisterId);
|
||||
if (model == null)
|
||||
if (items.Items.Count > 0 || items.Items.Count > 0)
|
||||
{
|
||||
Model.HSSE_Hazard_HazardRegister newModel = new Model.HSSE_Hazard_HazardRegister
|
||||
var CollCropCode = items.CollCropCode; //分包单位社会统一信用码
|
||||
var ProjectId = items.ProjectId; //总包项目Id
|
||||
var UnitDomain = items.UnitDomain; //分包单位域名地址【文件存储地址】
|
||||
var unit = Funs.DB.Base_Unit.FirstOrDefault(x => x.CollCropCode == CollCropCode); //根据CollCropCode获取单位id
|
||||
if (unit == null)
|
||||
{
|
||||
HazardRegisterId = item.HazardRegisterId,
|
||||
HazardCode = item.HazardCode,
|
||||
RegisterDate = item.RegisterDate,
|
||||
RegisterDef = item.RegisterDef,
|
||||
Rectification = item.Rectification,
|
||||
Place = APIDataShareSyncService.getUnitWorkId(item.PlaceName, projectId),
|
||||
ResponsibleUnit = unitId,
|
||||
Observer = item.Observer,
|
||||
AttachUrl = item.AttachUrl,
|
||||
ProjectId = projectId,
|
||||
States = item.States,
|
||||
IsEffective = item.IsEffective,
|
||||
ResponsibleMan = APIDataShareSyncService.getUserId(item.ResponsibleManName),
|
||||
CheckManId = APIDataShareSyncService.getUserId(item.CheckManName),
|
||||
CheckTime = item.CheckTime,
|
||||
RectificationPeriod = item.RectificationPeriod,
|
||||
ImageUrl = item.ImageUrl,
|
||||
RectificationImageUrl = item.RectificationImageUrl,
|
||||
RectificationTime = item.RectificationTime,
|
||||
ConfirmMan = APIDataShareSyncService.getUserId(item.ConfirmManName),
|
||||
ConfirmDate = item.ConfirmDate,
|
||||
HandleIdea = item.HandleIdea,
|
||||
CutPayment = item.CutPayment,
|
||||
ProblemTypes = item.ProblemTypes,
|
||||
RegisterTypesId = APIDataShareSyncService.getRegisterTypesId(item.RegisterTypesName),
|
||||
CheckCycle = item.CheckCycle,
|
||||
CheckItemDetailId = item.CheckItemDetailId,
|
||||
SupCheckItemSetId = item.SupCheckItemSetId,
|
||||
CheckItemSetId = item.CheckItemSetId,
|
||||
CheckSpecialId = item.CheckSpecialId,
|
||||
InstallationId = item.InstallationId,
|
||||
SafeSupervisionId = item.SafeSupervisionId,
|
||||
ResponsibleMan2 = APIDataShareSyncService.getUserId(item.ResponsibleMan2Name),
|
||||
SafeSupervisionIsOK = item.SafeSupervisionIsOK,
|
||||
GpsLocation = item.GpsLocation,
|
||||
IsWx = item.IsWx,
|
||||
DIC_ID = item.DIC_ID,
|
||||
CCManIds = item.CCManIds,
|
||||
ResultType = item.ResultType,
|
||||
ResultId = item.ResultId,
|
||||
Requirements = item.Requirements,
|
||||
Risk_Level = item.Risk_Level,
|
||||
ControlId = item.ControlId,
|
||||
};
|
||||
if (type == "pull")
|
||||
{
|
||||
newModel.DataSource = item.DataSource;
|
||||
message = "总包单位不存在本单位,请登录总包系统检查维护本单位信息!";
|
||||
}
|
||||
else
|
||||
{
|
||||
//2、判断主包项目是否存在
|
||||
var porject = BLL.ProjectService.GetProjectByProjectId(ProjectId);
|
||||
if (porject == null)
|
||||
{
|
||||
message = "总包单位不存在本项目,请检查总包项目关联是否正确!";
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcessHazardRegisterData(items.Items, ProjectId, unit.UnitId, UnitDomain, "push");
|
||||
message = "数据推送成功!";
|
||||
}
|
||||
}
|
||||
db.HSSE_Hazard_HazardRegister.InsertOnSubmit(newModel);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
// model.HazardRegisterId = item.HazardRegisterId;
|
||||
model.HazardCode = item.HazardCode;
|
||||
model.RegisterDate = item.RegisterDate;
|
||||
model.RegisterDef = item.RegisterDef;
|
||||
model.Rectification = item.Rectification;
|
||||
model.Place = APIDataShareSyncService.getUnitWorkId(item.PlaceName, projectId);
|
||||
model.ResponsibleUnit = unitId;
|
||||
model.Observer = item.Observer;
|
||||
model.AttachUrl = item.AttachUrl;
|
||||
model.ProjectId = projectId;
|
||||
model.States = item.States;
|
||||
model.IsEffective = item.IsEffective;
|
||||
model.ResponsibleMan = APIDataShareSyncService.getUserId(item.ResponsibleManName);
|
||||
model.CheckManId = APIDataShareSyncService.getUserId(item.CheckManName);
|
||||
model.CheckTime = item.CheckTime;
|
||||
model.RectificationPeriod = item.RectificationPeriod;
|
||||
model.ImageUrl = item.ImageUrl;
|
||||
model.RectificationImageUrl = item.RectificationImageUrl;
|
||||
model.RectificationTime = item.RectificationTime;
|
||||
model.ConfirmMan = APIDataShareSyncService.getUserId(item.ConfirmManName);
|
||||
model.ConfirmDate = item.ConfirmDate;
|
||||
model.HandleIdea = item.HandleIdea;
|
||||
model.CutPayment = item.CutPayment;
|
||||
model.ProblemTypes = item.ProblemTypes;
|
||||
model.RegisterTypesId = APIDataShareSyncService.getRegisterTypesId(item.RegisterTypesName);
|
||||
model.CheckCycle = item.CheckCycle;
|
||||
model.CheckItemDetailId = item.CheckItemDetailId;
|
||||
model.SupCheckItemSetId = item.SupCheckItemSetId;
|
||||
model.CheckItemSetId = item.CheckItemSetId;
|
||||
model.CheckSpecialId = item.CheckSpecialId;
|
||||
model.InstallationId = item.InstallationId;
|
||||
model.SafeSupervisionId = item.SafeSupervisionId;
|
||||
model.ResponsibleMan2 = APIDataShareSyncService.getUserId(item.ResponsibleMan2Name);
|
||||
model.SafeSupervisionIsOK = item.SafeSupervisionIsOK;
|
||||
model.GpsLocation = item.GpsLocation;
|
||||
model.IsWx = item.IsWx;
|
||||
model.DIC_ID = item.DIC_ID;
|
||||
model.CCManIds = item.CCManIds;
|
||||
model.ResultType = item.ResultType;
|
||||
model.ResultId = item.ResultId;
|
||||
model.Requirements = item.Requirements;
|
||||
model.Risk_Level = item.Risk_Level;
|
||||
model.ControlId = item.ControlId;
|
||||
if (type == "pull")
|
||||
message = "暂无项目安全检查数据!";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 处理单个安全检查数据的新增或更新逻辑
|
||||
|
||||
/// <summary>
|
||||
/// 处理单个安全检查数据的新增或更新逻辑
|
||||
/// </summary>
|
||||
/// <param name="item">安全检查数据项</param>
|
||||
/// <param name="projectId">项目id</param>
|
||||
/// <param name="unitId">单位ID</param>
|
||||
/// <param name="WebUrl">Web地址</param>
|
||||
private static void ProcessHazardRegisterData(List<Model.HazardRegisterSyncItem> getData, string projectId,
|
||||
string unitId, string WebUrl, string type)
|
||||
{
|
||||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||||
{
|
||||
foreach (var item in getData)
|
||||
{
|
||||
Model.HSSE_Hazard_HazardRegister model =
|
||||
db.HSSE_Hazard_HazardRegister.FirstOrDefault(x => x.HazardRegisterId == item.HazardRegisterId);
|
||||
if (model == null)
|
||||
{
|
||||
model.DataSource = item.DataSource;
|
||||
Model.HSSE_Hazard_HazardRegister newModel = new Model.HSSE_Hazard_HazardRegister
|
||||
{
|
||||
HazardRegisterId = item.HazardRegisterId,
|
||||
HazardCode = item.HazardCode,
|
||||
RegisterDate = item.RegisterDate,
|
||||
RegisterDef = item.RegisterDef,
|
||||
Rectification = item.Rectification,
|
||||
Place = APIDataShareSyncService.getUnitWorkId(item.PlaceName, projectId),
|
||||
ResponsibleUnit = unitId,
|
||||
Observer = item.Observer,
|
||||
AttachUrl = item.AttachUrl,
|
||||
ProjectId = projectId,
|
||||
States = item.States,
|
||||
IsEffective = item.IsEffective,
|
||||
ResponsibleMan = APIDataShareSyncService.getUserId(item.ResponsibleManName),
|
||||
CheckManId = APIDataShareSyncService.getUserId(item.CheckManName),
|
||||
CheckTime = item.CheckTime,
|
||||
RectificationPeriod = item.RectificationPeriod,
|
||||
ImageUrl = item.ImageUrl,
|
||||
RectificationImageUrl = item.RectificationImageUrl,
|
||||
RectificationTime = item.RectificationTime,
|
||||
ConfirmMan = APIDataShareSyncService.getUserId(item.ConfirmManName),
|
||||
ConfirmDate = item.ConfirmDate,
|
||||
HandleIdea = item.HandleIdea,
|
||||
CutPayment = item.CutPayment,
|
||||
ProblemTypes = item.ProblemTypes,
|
||||
RegisterTypesId = APIDataShareSyncService.getRegisterTypesId(item.RegisterTypesName),
|
||||
CheckCycle = item.CheckCycle,
|
||||
CheckItemDetailId = item.CheckItemDetailId,
|
||||
SupCheckItemSetId = item.SupCheckItemSetId,
|
||||
CheckItemSetId = item.CheckItemSetId,
|
||||
CheckSpecialId = item.CheckSpecialId,
|
||||
InstallationId = item.InstallationId,
|
||||
SafeSupervisionId = item.SafeSupervisionId,
|
||||
ResponsibleMan2 = APIDataShareSyncService.getUserId(item.ResponsibleMan2Name),
|
||||
SafeSupervisionIsOK = item.SafeSupervisionIsOK,
|
||||
GpsLocation = item.GpsLocation,
|
||||
IsWx = item.IsWx,
|
||||
DIC_ID = item.DIC_ID,
|
||||
CCManIds = item.CCManIds,
|
||||
ResultType = item.ResultType,
|
||||
ResultId = item.ResultId,
|
||||
Requirements = item.Requirements,
|
||||
Risk_Level = item.Risk_Level,
|
||||
ControlId = item.ControlId,
|
||||
};
|
||||
if (type == "pull")
|
||||
{
|
||||
newModel.DataSource = item.DataSource;
|
||||
}
|
||||
db.HSSE_Hazard_HazardRegister.InsertOnSubmit(newModel);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
// model.HazardRegisterId = item.HazardRegisterId;
|
||||
model.HazardCode = item.HazardCode;
|
||||
model.RegisterDate = item.RegisterDate;
|
||||
model.RegisterDef = item.RegisterDef;
|
||||
model.Rectification = item.Rectification;
|
||||
model.Place = APIDataShareSyncService.getUnitWorkId(item.PlaceName, projectId);
|
||||
model.ResponsibleUnit = unitId;
|
||||
model.Observer = item.Observer;
|
||||
model.AttachUrl = item.AttachUrl;
|
||||
model.ProjectId = projectId;
|
||||
model.States = item.States;
|
||||
model.IsEffective = item.IsEffective;
|
||||
model.ResponsibleMan = APIDataShareSyncService.getUserId(item.ResponsibleManName);
|
||||
model.CheckManId = APIDataShareSyncService.getUserId(item.CheckManName);
|
||||
model.CheckTime = item.CheckTime;
|
||||
model.RectificationPeriod = item.RectificationPeriod;
|
||||
model.ImageUrl = item.ImageUrl;
|
||||
model.RectificationImageUrl = item.RectificationImageUrl;
|
||||
model.RectificationTime = item.RectificationTime;
|
||||
model.ConfirmMan = APIDataShareSyncService.getUserId(item.ConfirmManName);
|
||||
model.ConfirmDate = item.ConfirmDate;
|
||||
model.HandleIdea = item.HandleIdea;
|
||||
model.CutPayment = item.CutPayment;
|
||||
model.ProblemTypes = item.ProblemTypes;
|
||||
model.RegisterTypesId = APIDataShareSyncService.getRegisterTypesId(item.RegisterTypesName);
|
||||
model.CheckCycle = item.CheckCycle;
|
||||
model.CheckItemDetailId = item.CheckItemDetailId;
|
||||
model.SupCheckItemSetId = item.SupCheckItemSetId;
|
||||
model.CheckItemSetId = item.CheckItemSetId;
|
||||
model.CheckSpecialId = item.CheckSpecialId;
|
||||
model.InstallationId = item.InstallationId;
|
||||
model.SafeSupervisionId = item.SafeSupervisionId;
|
||||
model.ResponsibleMan2 = APIDataShareSyncService.getUserId(item.ResponsibleMan2Name);
|
||||
model.SafeSupervisionIsOK = item.SafeSupervisionIsOK;
|
||||
model.GpsLocation = item.GpsLocation;
|
||||
model.IsWx = item.IsWx;
|
||||
model.DIC_ID = item.DIC_ID;
|
||||
model.CCManIds = item.CCManIds;
|
||||
model.ResultType = item.ResultType;
|
||||
model.ResultId = item.ResultId;
|
||||
model.Requirements = item.Requirements;
|
||||
model.Risk_Level = item.Risk_Level;
|
||||
model.ControlId = item.ControlId;
|
||||
if (type == "pull")
|
||||
{
|
||||
model.DataSource = item.DataSource;
|
||||
}
|
||||
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
db.SubmitChanges();
|
||||
}
|
||||
//附件处理
|
||||
if (!string.IsNullOrEmpty(item.AttachUrl1))
|
||||
{
|
||||
BLL.FileInsertService.SaveAttachFileRecords(WebUrl, item.AttachFileId1, item.ToKeyId1,
|
||||
item.AttachSource1, item.AttachUrl1);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(item.ImageUrl))
|
||||
{
|
||||
APIDataShareSyncService.SafeDownloadHeadImageAsync(WebUrl, item.ImageUrl);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(item.ImageUrl))
|
||||
{
|
||||
APIDataShareSyncService.OperationAttachFile(WebUrl, item.HazardRegisterId,
|
||||
BLL.Const.HSSE_HiddenRectificationListMenuId, item.ImageUrl);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(item.RectificationImageUrl))
|
||||
{
|
||||
APIDataShareSyncService.OperationAttachFile(WebUrl, item.HazardRegisterId+"-R",
|
||||
BLL.Const.HSSE_HiddenRectificationListMenuId, item.RectificationImageUrl);
|
||||
if (!string.IsNullOrEmpty(item.AttachUrl2))
|
||||
{
|
||||
BLL.FileInsertService.SaveAttachFileRecords(WebUrl, item.AttachFileId2, item.ToKeyId2,
|
||||
item.AttachSource2, item.AttachUrl2);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(item.RectificationImageUrl))
|
||||
{
|
||||
APIDataShareSyncService.SafeDownloadHeadImageAsync(WebUrl, item.RectificationImageUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,7 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.ComTypes;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
@@ -88,7 +86,7 @@ namespace BLL
|
||||
if (dataList.Count() > 0)
|
||||
{
|
||||
var thisUnit = CommonService.GetIsThisUnit();
|
||||
var porject = BLL.ProjectService.GetProjectByProjectId(projectId);
|
||||
var project = BLL.ProjectService.GetProjectByProjectId(projectId);
|
||||
var pushData = new LicenseManagerData
|
||||
{
|
||||
CollCropCode = thisUnit.CollCropCode,//分包单位社会统一信用码
|
||||
@@ -96,25 +94,29 @@ namespace BLL
|
||||
UnitName = thisUnit.UnitName,//分包单位名称
|
||||
ShortUnitName = thisUnit.ShortUnitName,//分包单位简称
|
||||
UnitDomain = Funs.SGGLUrl,//分包单位域名地址【文件存储地址】
|
||||
SubjectUnit = porject.SubjectUnit,//主包单位Id
|
||||
SubjectProject = porject.SubjectProject,//主包项目Id
|
||||
SubjectUnit = project.SubjectUnit,//主包单位Id
|
||||
SubjectProject = project.SubjectProject,//主包项目Id
|
||||
Items = dataList//数据
|
||||
};
|
||||
var pushContent = JsonConvert.SerializeObject(pushData);
|
||||
|
||||
//获取总包单位接口apiurl地址
|
||||
var Url = BLL.UnitService.getUnitApiUrlByUnitId(porject.SubjectUnit);
|
||||
var ApiUrl = string.Empty;
|
||||
var WebUrl = string.Empty;
|
||||
if (Url != null)
|
||||
{
|
||||
var urls = Url.Split(',');
|
||||
ApiUrl = urls[0];
|
||||
if (urls.Length > 1)
|
||||
{
|
||||
WebUrl = urls[1];
|
||||
}
|
||||
}
|
||||
////获取总包单位接口apiurl地址
|
||||
//var Url = BLL.UnitService.getUnitApiUrlByUnitId(project.SubjectUnit);
|
||||
//var ApiUrl = string.Empty;
|
||||
//var WebUrl = string.Empty;
|
||||
//if (Url != null)
|
||||
//{
|
||||
// var urls = Url.Split(',');
|
||||
// ApiUrl = urls[0];
|
||||
// if (urls.Length > 1)
|
||||
// {
|
||||
// WebUrl = urls[1];
|
||||
// }
|
||||
//}
|
||||
|
||||
//总包单位接口地址
|
||||
string ApiUrl = project.SubjectUnitApiUrl;
|
||||
string WebUrl = project.SubjectUnitWebUrl;
|
||||
var baseurl = $"{ApiUrl}/api/LicenseSync/ReceiveSaveProjectLicenseManagerData";
|
||||
string contenttype = "application/json;charset=unicode";
|
||||
//Hashtable newToken = new Hashtable
|
||||
@@ -126,7 +128,7 @@ namespace BLL
|
||||
var returndata = APIGetHttpService.Http(baseurl, "Post", contenttype, null, pushContent);
|
||||
if (!string.IsNullOrEmpty(returndata))
|
||||
{
|
||||
ErrLogInfo.WriteLog($"【作业票返回结果】接口地址:{baseurl};{returndata}");
|
||||
//ErrLogInfo.WriteLog($"【作业票返回结果】接口地址:{baseurl};{returndata}");
|
||||
JObject obj = JObject.Parse(returndata);
|
||||
string mess = obj["message"].ToString();
|
||||
string code = obj["code"].ToString();
|
||||
|
||||
@@ -2,7 +2,6 @@ using Model;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
|
||||
namespace BLL
|
||||
@@ -88,7 +87,7 @@ namespace BLL
|
||||
if (dataList.Count() > 0)
|
||||
{
|
||||
var thisUnit = CommonService.GetIsThisUnit();
|
||||
var porject = BLL.ProjectService.GetProjectByProjectId(projectId);
|
||||
var project = BLL.ProjectService.GetProjectByProjectId(projectId);
|
||||
var pushData = new ClassMeetingData
|
||||
{
|
||||
CollCropCode = thisUnit.CollCropCode,//分包单位社会统一信用码
|
||||
@@ -96,25 +95,28 @@ namespace BLL
|
||||
UnitName = thisUnit.UnitName,//分包单位名称
|
||||
ShortUnitName = thisUnit.ShortUnitName,//分包单位简称
|
||||
UnitDomain = Funs.SGGLUrl,//分包单位域名地址【文件存储地址】
|
||||
SubjectUnit = porject.SubjectUnit,//主包单位Id
|
||||
SubjectProject = porject.SubjectProject,//主包项目Id
|
||||
SubjectUnit = project.SubjectUnit,//主包单位Id
|
||||
SubjectProject = project.SubjectProject,//主包项目Id
|
||||
Items = dataList//会议数据
|
||||
};
|
||||
var pushContent = JsonConvert.SerializeObject(pushData);
|
||||
|
||||
//获取总包单位接口apiurl地址
|
||||
var Url = BLL.UnitService.getUnitApiUrlByUnitId(porject.SubjectUnit);
|
||||
var ApiUrl = string.Empty;
|
||||
var WebUrl = string.Empty;
|
||||
if (Url != null)
|
||||
{
|
||||
var urls = Url.Split(',');
|
||||
ApiUrl = urls[0];
|
||||
if (urls.Length > 1)
|
||||
{
|
||||
WebUrl = urls[1];
|
||||
}
|
||||
}
|
||||
////获取总包单位接口apiurl地址
|
||||
//var Url = BLL.UnitService.getUnitApiUrlByUnitId(porject.SubjectUnit);
|
||||
//var ApiUrl = string.Empty;
|
||||
//var WebUrl = string.Empty;
|
||||
//if (Url != null)
|
||||
//{
|
||||
// var urls = Url.Split(',');
|
||||
// ApiUrl = urls[0];
|
||||
// if (urls.Length > 1)
|
||||
// {
|
||||
// WebUrl = urls[1];
|
||||
// }
|
||||
//}
|
||||
//总包单位接口地址
|
||||
string ApiUrl = project.SubjectUnitApiUrl;
|
||||
string WebUrl = project.SubjectUnitWebUrl;
|
||||
var baseurl = $"{ApiUrl}/api/MeetingSync/ReceiveSaveProjectClassMeetingData";
|
||||
string contenttype = "application/json;charset=unicode";
|
||||
//Hashtable newToken = new Hashtable
|
||||
@@ -124,7 +126,7 @@ namespace BLL
|
||||
var returndata = APIGetHttpService.Http(baseurl, "Post", contenttype, null, pushContent);
|
||||
if (!string.IsNullOrEmpty(returndata))
|
||||
{
|
||||
ErrLogInfo.WriteLog($"【班前会返回结果】接口地址:{baseurl};{returndata}");
|
||||
// ErrLogInfo.WriteLog($"【班前会返回结果】接口地址:{baseurl};{returndata}");
|
||||
JObject obj = JObject.Parse(returndata);
|
||||
string code = obj["code"].ToString();
|
||||
string message = obj["message"].ToString();
|
||||
@@ -209,7 +211,7 @@ namespace BLL
|
||||
//model.Remark = item.Remark;
|
||||
model.Remark = $"{(!string.IsNullOrWhiteSpace(data.ShortUnitName) ? data.ShortUnitName : data.UnitName)}#{item.CompileManName}";
|
||||
model.CompileDate = item.CompileDate;
|
||||
model.CompileMan = item.CompileMan;
|
||||
// model.CompileMan = item.CompileMan;
|
||||
|
||||
db.SubmitChanges();
|
||||
}
|
||||
@@ -222,10 +224,8 @@ namespace BLL
|
||||
newModel.ClassMeetingCode = item.ClassMeetingCode;
|
||||
newModel.ClassMeetingName = item.ClassMeetingName;
|
||||
newModel.ClassMeetingDate = item.ClassMeetingDate;
|
||||
newModel.AttentPersonNum = item.AttentPersonNum;
|
||||
//newModel.TeamGroupId = item.TeamGroupId;
|
||||
newModel.TeamGroupId = APIDataShareSyncService.GetTeamGroupId(item.TeamGroupName, data.SubjectProject, unit.UnitId);
|
||||
newModel.AttentPersonNum = item.AttentPersonNum;
|
||||
//newModel.ClassMeetingContents = HttpUtility.HtmlEncode(item.ClassMeetingContents);
|
||||
newModel.ClassMeetingContents = item.ClassMeetingContents;
|
||||
//newModel.States = item.States;
|
||||
@@ -239,7 +239,7 @@ namespace BLL
|
||||
//newModel.Remark = item.Remark;
|
||||
newModel.Remark = $"{(!string.IsNullOrWhiteSpace(data.ShortUnitName) ? data.ShortUnitName : data.UnitName)}#{item.CompileManName}";
|
||||
newModel.CompileDate = item.CompileDate;
|
||||
newModel.CompileMan = item.CompileMan;
|
||||
// newModel.CompileMan = item.CompileMan;
|
||||
|
||||
db.Meeting_ClassMeeting.InsertOnSubmit(newModel);
|
||||
db.SubmitChanges();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user