1
This commit is contained in:
@@ -0,0 +1,537 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections;
|
||||
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
|
||||
{
|
||||
public class APICheckSpecialSyncService
|
||||
{
|
||||
#region 根据项目、单位获取专项检查列表
|
||||
|
||||
public static List<Model.CheckSpecialSyncItem> GetCheckSpecialLitsByprojectIdUnitId(string projectId,
|
||||
string unitId, string dataId = "")
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var list = from x in db.Check_CheckSpecial where x.ProjectId == projectId select x;
|
||||
if (!string.IsNullOrEmpty(unitId))
|
||||
{
|
||||
// 通过关联明细表来筛选包含指定单位的主表数据
|
||||
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
|
||||
{
|
||||
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,
|
||||
HSEManage="",
|
||||
//HSEManageName = u1.UserName,
|
||||
HSEManageName = "",
|
||||
RiskLevel = x.HiddenHazardType,
|
||||
//LimitDate = x.LimitDate,
|
||||
//AttachUrl = x.AttachUrl,
|
||||
//HandleWay = x.HandleWay,
|
||||
//RectifyOpinion = x.RectifyOpinion,
|
||||
RectifyOpinion = x.HandleStep,
|
||||
//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
|
||||
{
|
||||
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.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 ApiUrl = "";
|
||||
var WebUrl = "";
|
||||
if (!string.IsNullOrEmpty(Url))
|
||||
{
|
||||
var urls = Url.Split(',');
|
||||
ApiUrl = urls[0];
|
||||
if (urls.Length > 1)
|
||||
{
|
||||
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)
|
||||
{
|
||||
ProcessCheckSpecialData(getData, project.ProjectId, unitId, WebUrl);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
//获取专项检查数据
|
||||
var items = GetCheckSpecialLitsByprojectIdUnitId(projectId, "", dataId);
|
||||
//总包地址推送
|
||||
if (items.Count() > 0)
|
||||
{
|
||||
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 urls = Url.Split(',');
|
||||
ApiUrl = urls[0];
|
||||
if (urls.Length > 1)
|
||||
{
|
||||
WebUrl = urls[1];
|
||||
}
|
||||
}
|
||||
|
||||
// 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 = "数据推送成功!";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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 ProcessCheckSpecialData(List<Model.CheckSpecialSyncItem> getData, string projectId,
|
||||
string unitId, string WebUrl)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
foreach (var item in getData)
|
||||
{
|
||||
var model = db.Check_CheckSpecial.FirstOrDefault(e => e.CheckSpecialId == item.CheckSpecialId);
|
||||
if (model == null)
|
||||
{
|
||||
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_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();
|
||||
}
|
||||
|
||||
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.SGGLDB db = new Model.SGGLDB(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,
|
||||
//HandleStep= 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.HiddenHazardType = 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();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(item.AttachUrl1)) //整改前图片
|
||||
{
|
||||
APIDataShareSyncService.OperationAttachFile(WebUrl, item.CheckSpecialDetailId,
|
||||
BLL.Const.ProjectCheckSpecialMenuId, item.AttachUrl1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,468 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections;
|
||||
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
|
||||
{
|
||||
public class APIHazardRegisterSyncService
|
||||
{
|
||||
#region 根据项目、单位获取安全检查列表分页
|
||||
|
||||
public static List<Model.HazardRegisterSyncItem> GetHazardRegisterLitsByprojectIdUnitIdPage(string projectId,
|
||||
string unitId, string dataId = "")
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var list = from x in db.HSSE_Hazard_HazardRegister where x.ProjectId == projectId select x;
|
||||
if (!string.IsNullOrEmpty(unitId))
|
||||
{
|
||||
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.Person_Persons on x.ResponsibleMan equals u1.PersonId into u1Temp
|
||||
from u1 in u1Temp.DefaultIfEmpty()
|
||||
join u2 in db.Person_Persons on x.CheckManId equals u2.PersonId into u2Temp
|
||||
from u2 in u2Temp.DefaultIfEmpty()
|
||||
join u3 in db.Person_Persons on x.ConfirmMan equals u3.PersonId into u3Temp
|
||||
from u3 in u3Temp.DefaultIfEmpty()
|
||||
join u4 in db.Person_Persons on x.ResponsibleMan2 equals u4.PersonId into u4Temp
|
||||
from u4 in u4Temp.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.PersonName,
|
||||
CheckManId = x.CheckManId,
|
||||
CheckManName = u2.PersonName,
|
||||
CheckTime = x.CheckTime,
|
||||
RectificationPeriod = x.RectificationPeriod,
|
||||
ImageUrl = x.ImageUrl,
|
||||
RectificationImageUrl = x.RectificationImageUrl,
|
||||
RectificationTime = x.RectificationTime,
|
||||
ConfirmMan = x.ConfirmMan,
|
||||
ConfirmManName = u3.PersonName,
|
||||
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.PersonName,
|
||||
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.HazardValue,
|
||||
ControlId = x.ControlId,
|
||||
DataSource = "1",
|
||||
}).ToList();
|
||||
|
||||
return dataList;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 拉取项目安全检查数据
|
||||
|
||||
public static string getHazardRegisterLists(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.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 ApiUrl = "";
|
||||
var WebUrl = "";
|
||||
if (!string.IsNullOrEmpty(Url))
|
||||
{
|
||||
var urls = Url.Split(',');
|
||||
ApiUrl = urls[0];
|
||||
if (urls.Length > 1)
|
||||
{
|
||||
WebUrl = urls[1];
|
||||
}
|
||||
}
|
||||
|
||||
// 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))
|
||||
{
|
||||
JObject obj = JObject.Parse(strJosn);
|
||||
code = Funs.GetNewIntOrZero(obj["code"].ToString());
|
||||
message = obj["message"].ToString();
|
||||
if (code == 1)
|
||||
{
|
||||
var getData =
|
||||
JsonConvert.DeserializeObject<List<HazardRegisterSyncItem>>(obj["data"].ToString());
|
||||
if (getData.Count() > 0)
|
||||
{
|
||||
ProcessHazardRegisterData(getData, project.ProjectId, unitId, WebUrl, "pull");
|
||||
}
|
||||
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)
|
||||
{
|
||||
//获取安全检查数据
|
||||
var items = GetHazardRegisterLitsByprojectIdUnitIdPage(projectId, "", dataId);
|
||||
//总包地址推送
|
||||
if (items.Count() > 0)
|
||||
{
|
||||
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 urls = Url.Split(',');
|
||||
ApiUrl = urls[0];
|
||||
if (urls.Length > 1)
|
||||
{
|
||||
WebUrl = urls[1];
|
||||
}
|
||||
}
|
||||
// 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 = "数据推送成功!";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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.SGGLDB db = new Model.SGGLDB(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.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,
|
||||
HazardValue = 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.HazardValue = item.Risk_Level;
|
||||
model.ControlId = item.ControlId;
|
||||
if (type == "pull")
|
||||
{
|
||||
model.DataSource = item.DataSource;
|
||||
}
|
||||
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,265 @@
|
||||
using Model;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.ComTypes;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// 作业票数据共享互通
|
||||
/// </summary>
|
||||
public class APILicenseSyncService
|
||||
{
|
||||
#region 分包单位推送数据到总包单位
|
||||
|
||||
/// <summary>
|
||||
/// 推送分包作业票定稿数据
|
||||
/// </summary>
|
||||
/// <param name="projectId">项目Id</param>
|
||||
/// <param name="dataId">作业票定稿数据Id(为空的时候推送全部)</param>
|
||||
/// <returns></returns>
|
||||
public static ReturnData PushLicenseManagerLists(string projectId, string dataId = "")
|
||||
{
|
||||
Model.ReturnData responeData = new Model.ReturnData();
|
||||
responeData.code = 0;
|
||||
responeData.message = string.Empty;
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = from x in db.View_License_LicenseManager where x.ProjectId == projectId select x;
|
||||
if (!string.IsNullOrWhiteSpace(dataId))
|
||||
{
|
||||
list = list.Where(x => x.LicenseManagerId == dataId);
|
||||
}
|
||||
var dataList = (from x in list
|
||||
join blt in db.Base_LicenseType on x.LicenseTypeId equals blt.LicenseTypeId into bltGroup
|
||||
from blt in bltGroup.DefaultIfEmpty()
|
||||
join su in db.Person_Persons on x.CompileMan equals su.PersonId into sUser
|
||||
from su in sUser.DefaultIfEmpty()
|
||||
//join uw in db.WBS_UnitWork on x.WorkAreaId equals uw.UnitWorkId into uwGroup
|
||||
//from uw in uwGroup.DefaultIfEmpty()
|
||||
join att in db.AttachFile on x.LicenseManagerId equals att.ToKeyId into attTemp
|
||||
from att in attTemp.DefaultIfEmpty()
|
||||
join att1 in db.AttachFile on (x.LicenseManagerId + "_GB") equals att1.ToKeyId into att1Temp
|
||||
from att1 in att1Temp.DefaultIfEmpty()
|
||||
orderby x.CompileDate descending
|
||||
select new LicenseManagerItem
|
||||
{
|
||||
ProjectId = x.ProjectId,
|
||||
UnitId = x.UnitId,
|
||||
LicenseManagerId = x.LicenseManagerId,
|
||||
LicenseManagerCode = x.LicenseManagerCode,
|
||||
LicenseManageName = x.LicenseManageName,
|
||||
LicenseTypeId = x.LicenseTypeId,
|
||||
LicenseTypeCode = blt.LicenseTypeCode,
|
||||
LicenseTypeName = blt.LicenseTypeName,
|
||||
LicenseManageContents = x.LicenseManageContents,
|
||||
CompileMan = x.CompileMan,
|
||||
CompileManName = su.PersonName,
|
||||
CompileDate = x.CompileDate,
|
||||
States = x.States,
|
||||
WorkAreaId = x.WorkAreaId,
|
||||
//UnitWorkCode = uw.UnitWorkCode,
|
||||
//UnitWorkName = uw.UnitWorkName,
|
||||
UnitWorkName = x.WorkAreaName,
|
||||
StartDate = x.StartDate,
|
||||
EndDate = x.EndDate,
|
||||
ApplicantMan = x.ApplicantMan,
|
||||
WorkStates = x.WorkStates,
|
||||
IsHighRisk = x.IsHighRisk,
|
||||
LicenseCodes = x.LicenseCodes,
|
||||
SourceDes = x.SourceDes,
|
||||
//AttachUrl = AttachFileService.getFileUrl(x.LicenseManagerId),//附件
|
||||
//AttachUrl1 = AttachFileService.getFileUrl(x.LicenseManagerId + "_GB"),//关闭附件
|
||||
AttachFileId = att.AttachFileId,
|
||||
ToKeyId = att.ToKeyId,
|
||||
AttachSource = att.AttachSource,
|
||||
AttachUrl = att.AttachUrl,
|
||||
AttachFileId1 = att1.AttachFileId,
|
||||
ToKeyId1 = att1.ToKeyId,
|
||||
AttachSource1 = att1.AttachSource,
|
||||
AttachUrl1 = att1.AttachUrl,
|
||||
}).ToList();
|
||||
|
||||
if (dataList.Count() > 0)
|
||||
{
|
||||
var thisUnit = CommonService.GetIsThisUnit();
|
||||
var porject = BLL.ProjectService.GetProjectByProjectId(projectId);
|
||||
var pushData = new LicenseManagerData
|
||||
{
|
||||
CollCropCode = thisUnit.CollCropCode,//分包单位社会统一信用码
|
||||
UnitId = thisUnit.UnitId,//分包单位Id
|
||||
UnitName = thisUnit.UnitName,//分包单位名称
|
||||
ShortUnitName = thisUnit.ShortUnitName,//分包单位简称
|
||||
UnitDomain = Funs.SGGLUrl,//分包单位域名地址【文件存储地址】
|
||||
SubjectUnit = porject.SubjectUnit,//主包单位Id
|
||||
SubjectProject = porject.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];
|
||||
}
|
||||
}
|
||||
var baseurl = $"{ApiUrl}/api/LicenseSync/ReceiveSaveProjectLicenseManagerData";
|
||||
string contenttype = "application/json;charset=unicode";
|
||||
//Hashtable newToken = new Hashtable
|
||||
//{
|
||||
// { "token", ServerService.GetToken().Token }
|
||||
//};
|
||||
|
||||
//ErrLogInfo.WriteLog($"【班前会推送数据】接口地址:{baseurl};{pushContent}");
|
||||
var returndata = APIGetHttpService.Http(baseurl, "Post", contenttype, null, pushContent);
|
||||
if (!string.IsNullOrEmpty(returndata))
|
||||
{
|
||||
ErrLogInfo.WriteLog($"【作业票返回结果】接口地址:{baseurl};{returndata}");
|
||||
JObject obj = JObject.Parse(returndata);
|
||||
string mess = obj["message"].ToString();
|
||||
string code = obj["code"].ToString();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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 ReceiveSaveProjectLicenseManagerData(LicenseManagerData data)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
string result = string.Empty;
|
||||
if (data.Items.Count() > 0)
|
||||
{
|
||||
//var jsonData = JsonConvert.SerializeObject(data);
|
||||
//ErrLogInfo.WriteLog($"【作业票定稿接收数据】{jsonData}");
|
||||
//1、判断分包单位是否存在
|
||||
var unit = UnitService.getUnitByCollCropCodeUnitName(data.CollCropCode, data.UnitName);
|
||||
if (unit == null)
|
||||
{
|
||||
result = "总包单位不存在本单位,请登录总包系统检查维护本单位信息!";
|
||||
}
|
||||
else
|
||||
{
|
||||
//2、判断主包项目是否存在
|
||||
var porject = BLL.ProjectService.GetProjectByProjectId(data.SubjectProject);
|
||||
if (porject == null)
|
||||
{
|
||||
result = "总包单位不存在本项目,请检查总包项目关联是否正确!";
|
||||
}
|
||||
else
|
||||
{
|
||||
int succ = 0;
|
||||
//3、保存数据
|
||||
foreach (var item in data.Items)
|
||||
{
|
||||
try
|
||||
{
|
||||
var model = db.License_LicenseManager.FirstOrDefault(e => e.LicenseManagerId == item.LicenseManagerId);
|
||||
if (model != null)
|
||||
{//编辑
|
||||
model.ProjectId = data.SubjectProject;
|
||||
model.UnitId = unit.UnitId;
|
||||
model.LicenseManagerCode = item.LicenseManagerCode;
|
||||
model.LicenseManageName = item.LicenseManageName;
|
||||
//model.LicenseTypeId = item.LicenseTypeId;
|
||||
model.LicenseTypeId = APIDataShareSyncService.GetLicenseTypeId(item.LicenseTypeId, item.LicenseTypeCode, item.LicenseTypeName);
|
||||
//model.LicenseManageContents = HttpUtility.HtmlEncode(item.LicenseManageContents);
|
||||
model.LicenseManageContents = item.LicenseManageContents;
|
||||
model.States = item.States;
|
||||
model.StartDate = item.StartDate;
|
||||
model.EndDate = item.EndDate;
|
||||
model.ApplicantMan = item.ApplicantMan;
|
||||
model.IsHighRisk = item.IsHighRisk;
|
||||
model.WorkStates = item.WorkStates;
|
||||
model.SourceDes = $"{(!string.IsNullOrWhiteSpace(data.ShortUnitName) ? data.ShortUnitName : data.UnitName)}#{item.CompileManName}#单位工程:{item.UnitWorkName}";
|
||||
model.CompileDate = item.CompileDate;
|
||||
//model.CompileMan = item.CompileMan;
|
||||
|
||||
db.SubmitChanges();
|
||||
}
|
||||
else
|
||||
{//新增
|
||||
Model.License_LicenseManager newModel = new Model.License_LicenseManager();
|
||||
newModel.LicenseManagerId = item.LicenseManagerId;
|
||||
newModel.ProjectId = data.SubjectProject;
|
||||
newModel.UnitId = unit.UnitId;
|
||||
newModel.LicenseManagerCode = item.LicenseManagerCode;
|
||||
newModel.LicenseManageName = item.LicenseManageName;
|
||||
//newModel.LicenseTypeId = item.LicenseTypeId;
|
||||
newModel.LicenseTypeId = APIDataShareSyncService.GetLicenseTypeId(item.LicenseTypeId, item.LicenseTypeCode, item.LicenseTypeName);
|
||||
//newModel.LicenseManageContents = HttpUtility.HtmlEncode(item.LicenseManageContents);
|
||||
newModel.LicenseManageContents = item.LicenseManageContents;
|
||||
newModel.States = item.States;
|
||||
newModel.StartDate = item.StartDate;
|
||||
newModel.EndDate = item.EndDate;
|
||||
newModel.ApplicantMan = item.ApplicantMan;
|
||||
newModel.IsHighRisk = item.IsHighRisk;
|
||||
newModel.WorkStates = item.WorkStates;
|
||||
newModel.SourceDes = $"{(!string.IsNullOrWhiteSpace(data.ShortUnitName) ? data.ShortUnitName : data.UnitName)}#{item.CompileManName}#单位工程:{item.UnitWorkName}";
|
||||
newModel.CompileDate = item.CompileDate;
|
||||
//newModel.CompileMan = item.CompileMan;
|
||||
|
||||
db.License_LicenseManager.InsertOnSubmit(newModel);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
succ++;
|
||||
|
||||
//ErrLogInfo.WriteLog($"【作业票定稿接收数据——内容附件】UnitDomain:{data.UnitDomain};AttachFileId:{item.AttachFileId};ToKeyId:{item.ToKeyId};AttachSource:{item.AttachSource};AttachUrl:{item.AttachUrl}");
|
||||
//附件处理:附件
|
||||
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);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BLL.ErrLogInfo.WriteLog($"【{porject.ProjectName}】作业票定稿数据推送总包失败", ex.Message);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
result = $"推送成功:总数{data.Items.Count()}条,成功{succ}条";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = "推送数据对象为空!";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,277 @@
|
||||
using Model;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// 安全会议数据共享互通
|
||||
/// </summary>
|
||||
public class APIMeetingSyncService
|
||||
{
|
||||
#region 分包单位推送数据到总包单位
|
||||
|
||||
/// <summary>
|
||||
/// 推送分包班前会数据
|
||||
/// </summary>
|
||||
/// <param name="projectId">项目Id</param>
|
||||
/// <param name="dataId">班前会数据Id(为空的时候推送全部)</param>
|
||||
/// <returns></returns>
|
||||
public static ReturnData PushClassMeetingLists(string projectId, string dataId = "")
|
||||
{
|
||||
Model.ReturnData responeData = new Model.ReturnData();
|
||||
responeData.code = 0;
|
||||
responeData.message = string.Empty;
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = from x in db.Meeting_ClassMeeting where x.ProjectId == projectId select x;
|
||||
if (!string.IsNullOrWhiteSpace(dataId))
|
||||
{
|
||||
list = list.Where(x => x.ClassMeetingId == dataId);
|
||||
}
|
||||
var dataList = (from x in list
|
||||
join ptg in db.ProjectData_TeamGroup on x.TeamGroupId equals ptg.TeamGroupId into ptGroup
|
||||
from ptg in ptGroup.DefaultIfEmpty()
|
||||
join su in db.Person_Persons on x.CompileMan equals su.PersonId into sUser
|
||||
from su in sUser.DefaultIfEmpty()
|
||||
join att in db.AttachFile on x.ClassMeetingId equals att.ToKeyId into attTemp
|
||||
from att in attTemp.DefaultIfEmpty()
|
||||
join att1 in db.AttachFile on (x.ClassMeetingId + "#1") equals att1.ToKeyId into att1Temp
|
||||
from att1 in att1Temp.DefaultIfEmpty()
|
||||
join att2 in db.AttachFile on (x.ClassMeetingId + "#2") equals att2.ToKeyId into att2Temp
|
||||
from att2 in att2Temp.DefaultIfEmpty()
|
||||
orderby x.CompileDate descending
|
||||
select new ClassMeetingItem
|
||||
{
|
||||
ProjectId = x.ProjectId,
|
||||
UnitId = x.UnitId,
|
||||
ClassMeetingId = x.ClassMeetingId,
|
||||
ClassMeetingCode = x.ClassMeetingCode,
|
||||
ClassMeetingName = x.ClassMeetingName,
|
||||
ClassMeetingDate = x.ClassMeetingDate,
|
||||
ClassMeetingContents = x.ClassMeetingContents,
|
||||
CompileMan = x.CompileMan,
|
||||
CompileManName = su.PersonName,
|
||||
TeamGroupId = x.TeamGroupId,
|
||||
TeamGroupName = ptg.TeamGroupName,
|
||||
CompileDate = x.CompileDate,
|
||||
States = x.States,
|
||||
MeetingPlace = x.MeetingPlace,
|
||||
MeetingHours = x.MeetingHours,
|
||||
MeetingHostMan = x.MeetingHostMan,
|
||||
AttentPerson = x.AttentPerson,
|
||||
AttentPersonNum = x.AttentPersonNum,
|
||||
//MeetingHostManOther = x.MeetingHostManOther,
|
||||
MeetingHostManOther = string.Empty,
|
||||
Remark = x.Remark,
|
||||
//AttachUrl = AttachFileService.getFileUrl(x.ClassMeetingId),//内容
|
||||
//AttachUrl1 = AttachFileService.getFileUrl(x.ClassMeetingId + "#1"),//签到表
|
||||
//AttachUrl2 = AttachFileService.getFileUrl(x.ClassMeetingId + "#2"),//会议过程
|
||||
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 porject = BLL.ProjectService.GetProjectByProjectId(projectId);
|
||||
var pushData = new ClassMeetingData
|
||||
{
|
||||
CollCropCode = thisUnit.CollCropCode,//分包单位社会统一信用码
|
||||
UnitId = thisUnit.UnitId,//分包单位Id
|
||||
UnitName = thisUnit.UnitName,//分包单位名称
|
||||
ShortUnitName = thisUnit.ShortUnitName,//分包单位简称
|
||||
UnitDomain = Funs.SGGLUrl,//分包单位域名地址【文件存储地址】
|
||||
SubjectUnit = porject.SubjectUnit,//主包单位Id
|
||||
SubjectProject = porject.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];
|
||||
}
|
||||
}
|
||||
var baseurl = $"{ApiUrl}/api/MeetingSync/ReceiveSaveProjectClassMeetingData";
|
||||
string contenttype = "application/json;charset=unicode";
|
||||
//Hashtable newToken = new Hashtable
|
||||
//{
|
||||
// { "token", ServerService.GetToken().Token }
|
||||
//};
|
||||
ErrLogInfo.WriteLog($"【班前会推送数据】接口地址:{baseurl};{pushContent}");
|
||||
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.message = "当前项目没有班前会数据";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.message = "同步到总包单位失败!";
|
||||
ErrLogInfo.WriteLog("【班前会】同步到总包单位失败!", ex);
|
||||
}
|
||||
}
|
||||
return responeData;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 总包单位接收分包单位推送数据
|
||||
|
||||
/// <summary>
|
||||
/// 总包单位接收保存分包单位推送的班前会数据
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public static string ReceiveSaveProjectClassMeetingData(ClassMeetingData data)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
string result = string.Empty;
|
||||
if (data.Items.Count() > 0)
|
||||
{
|
||||
//1、判断分包单位是否存在
|
||||
var unit = UnitService.getUnitByCollCropCodeUnitName(data.CollCropCode, data.UnitName);
|
||||
if (unit == null)
|
||||
{
|
||||
result = "总包单位不存在本单位,请登录总包系统检查维护本单位信息!";
|
||||
}
|
||||
else
|
||||
{
|
||||
//2、判断主包项目是否存在
|
||||
var porject = BLL.ProjectService.GetProjectByProjectId(data.SubjectProject);
|
||||
if (porject == null)
|
||||
{
|
||||
result = "总包单位不存在本项目,请检查总包项目关联是否正确!";
|
||||
}
|
||||
else
|
||||
{
|
||||
int succ = 0;
|
||||
//3、保存数据
|
||||
foreach (var item in data.Items)
|
||||
{
|
||||
try
|
||||
{
|
||||
var model = db.Meeting_ClassMeeting.FirstOrDefault(e => e.ClassMeetingId == item.ClassMeetingId);
|
||||
if (model != null)
|
||||
{//编辑
|
||||
model.ProjectId = data.SubjectProject;
|
||||
model.UnitId = unit.UnitId;
|
||||
model.ClassMeetingCode = item.ClassMeetingCode;
|
||||
model.ClassMeetingName = item.ClassMeetingName;
|
||||
model.ClassMeetingDate = item.ClassMeetingDate;
|
||||
model.AttentPersonNum = item.AttentPersonNum;
|
||||
//model.TeamGroupId = item.TeamGroupId;
|
||||
model.TeamGroupId = APIDataShareSyncService.GetTeamGroupId(item.TeamGroupName, data.SubjectProject, unit.UnitId);
|
||||
model.AttentPersonNum = item.AttentPersonNum;
|
||||
//model.ClassMeetingContents = HttpUtility.HtmlEncode(item.ClassMeetingContents);
|
||||
model.ClassMeetingContents = item.ClassMeetingContents;
|
||||
//model.States = item.States;
|
||||
model.States = BLL.Const.State_2; ;//分包推送过来的班前会数据默认已完成
|
||||
model.MeetingPlace = item.MeetingPlace;
|
||||
model.MeetingHours = item.MeetingHours;
|
||||
model.MeetingHostMan = item.MeetingHostMan;
|
||||
model.AttentPerson = item.AttentPerson;
|
||||
model.AttentPersonNum = item.AttentPersonNum;
|
||||
//model.MeetingHostManOther = item.MeetingHostManOther;
|
||||
//model.Remark = item.Remark;
|
||||
model.Remark = $"{(!string.IsNullOrWhiteSpace(data.ShortUnitName) ? data.ShortUnitName : data.UnitName)}#{item.CompileManName}";
|
||||
model.CompileDate = item.CompileDate;
|
||||
model.CompileMan = item.CompileMan;
|
||||
|
||||
db.SubmitChanges();
|
||||
}
|
||||
else
|
||||
{//新增
|
||||
Model.Meeting_ClassMeeting newModel = new Model.Meeting_ClassMeeting();
|
||||
newModel.ClassMeetingId = item.ClassMeetingId;
|
||||
newModel.ProjectId = data.SubjectProject;
|
||||
newModel.UnitId = unit.UnitId;
|
||||
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;
|
||||
newModel.States = BLL.Const.State_2; ;//分包推送过来的班前会数据默认已完成
|
||||
newModel.MeetingPlace = item.MeetingPlace;
|
||||
newModel.MeetingHours = item.MeetingHours;
|
||||
newModel.MeetingHostMan = item.MeetingHostMan;
|
||||
newModel.AttentPerson = item.AttentPerson;
|
||||
newModel.AttentPersonNum = item.AttentPersonNum;
|
||||
//newModel.MeetingHostManOther = item.MeetingHostManOther;
|
||||
//newModel.Remark = item.Remark;
|
||||
newModel.Remark = $"{(!string.IsNullOrWhiteSpace(data.ShortUnitName) ? data.ShortUnitName : data.UnitName)}#{item.CompileManName}";
|
||||
newModel.CompileDate = item.CompileDate;
|
||||
newModel.CompileMan = item.CompileMan;
|
||||
|
||||
db.Meeting_ClassMeeting.InsertOnSubmit(newModel);
|
||||
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,575 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections;
|
||||
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
|
||||
{
|
||||
public class APIPersonSyncService
|
||||
{
|
||||
#region 根据项目、单位获取人员列表分页
|
||||
|
||||
public static List<Model.PersonSyncItem> GetPersonLitsByProjectIdAndUnitId(string projectId, string unitId,
|
||||
string dataId = "")
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var list = from x in db.SitePerson_Person 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.PersonId == dataId);
|
||||
}
|
||||
|
||||
var personList = (from x in list
|
||||
join wp in db.Base_WorkPost on x.WorkPostId equals wp.WorkPostId into wpTemp
|
||||
from wp in wpTemp.DefaultIfEmpty()
|
||||
join tg in db.ProjectData_TeamGroup on x.TeamGroupId equals tg.TeamGroupId into tgTemp
|
||||
from tg in tgTemp.DefaultIfEmpty()
|
||||
join c in db.Base_Certificate on x.CertificateId equals c.CertificateId into cTemp
|
||||
from c in cTemp.DefaultIfEmpty()
|
||||
join att1 in db.AttachFile on (x.PersonId + "#1") equals att1.ToKeyId into att1Temp
|
||||
from att1 in att1Temp.DefaultIfEmpty()
|
||||
join att2 in db.AttachFile on (x.PersonId + "#2") equals att2.ToKeyId into att2Temp
|
||||
from att2 in att2Temp.DefaultIfEmpty()
|
||||
join att3 in db.AttachFile on (x.PersonId + "#3") equals att3.ToKeyId into att3Temp
|
||||
from att3 in att3Temp.DefaultIfEmpty()
|
||||
join att4 in db.AttachFile on (x.PersonId + "#4") equals att4.ToKeyId into att4Temp
|
||||
from att4 in att4Temp.DefaultIfEmpty()
|
||||
join att5 in db.AttachFile on (x.PersonId + "#5") equals att5.ToKeyId into att5Temp
|
||||
from att5 in att5Temp.DefaultIfEmpty()
|
||||
select new Model.PersonSyncItem
|
||||
{
|
||||
PersonId = x.PersonId,
|
||||
CardNo = x.CardNo,
|
||||
PersonName = x.PersonName,
|
||||
//Sex = x.Sex,
|
||||
IdentityCard = x.IdentityCard,
|
||||
//Address = x.Address,
|
||||
ProjectId = x.ProjectId,
|
||||
UnitId = x.UnitId,
|
||||
TeamGroupId = x.TeamGroupId,
|
||||
WorkAreaId = x.WorkAreaId,
|
||||
WorkPostId = x.WorkPostId,
|
||||
InTime = x.InTime,
|
||||
OutTime = x.OutTime,
|
||||
OutResult = x.OutResult,
|
||||
//Telephone = x.Telephone,
|
||||
// x.PositionId,//职务
|
||||
// x.PostTitleId,//职称
|
||||
//PhotoUrl = x.PhotoUrl,
|
||||
//IsUsed = x.IsUsed,
|
||||
//IsCardUsed = x.IsCardUsed,
|
||||
//PersonIndex = x.PersonIndex,
|
||||
// x.DepartId,//部门
|
||||
CertificateId = x.CertificateId,
|
||||
CertificateItem = APIDataShareSyncService.GetPersonQualityByPersonId(x.PersonId), //特岗证书
|
||||
CertificateCode = x.CertificateCode,
|
||||
CertificateName = c.CertificateName,
|
||||
CertificateLimitTime = x.CertificateLimitTime,
|
||||
//QualificationCertificateUrl = x.QualificationCertificateUrl,
|
||||
//TrainingCertificateUrl = x.TrainingCertificateUrl,
|
||||
//QRCodeAttachUrl = x.QRCodeAttachUrl,
|
||||
//Password = x.Password,
|
||||
//FromPersonId = x.FromPersonId,
|
||||
// x.AuditorId,审核人
|
||||
AuditorDate = x.AuditorDate,
|
||||
ExchangeTime = x.ExchangeTime,
|
||||
ExchangeTime2 = x.ExchangeTime2,
|
||||
//IDCardUrl = x.IDCardUrl,
|
||||
//IsForeign = x.IsForeign,
|
||||
//IsOutside = x.IsOutside,
|
||||
//EduLevel = x.EduLevel,
|
||||
//MaritalStatus = x.MaritalStatus,
|
||||
Isprint = x.Isprint,
|
||||
//MainCNProfessionalId = x.MainCNProfessionalId,
|
||||
//ViceCNProfessionalId = x.ViceCNProfessionalId,
|
||||
//Birthday = x.Birthday,
|
||||
//IdcardType = x.IdcardType,
|
||||
//IdcardStartDate = x.IdcardStartDate,
|
||||
//IdcardEndDate = x.IdcardEndDate,
|
||||
//IdcardForever = x.IdcardForever,
|
||||
//PoliticsStatus = x.PoliticsStatus,
|
||||
//IdcardAddress = x.IdcardAddress,
|
||||
//Nation = x.Nation,
|
||||
//CountryCode = x.CountryCode,
|
||||
IsSafetyMonitoring = x.IsSafetyMonitoring,
|
||||
//ProvinceCode = x.ProvinceCode,
|
||||
//IsCardNoOK = x.IsCardNoOK,
|
||||
// AttachUrl1 = AttachFileService.getFileUrl(x.PersonId + "#1"),
|
||||
// AttachUrl2 = AttachFileService.getFileUrl(x.PersonId + "#2"),
|
||||
// AttachUrl3 = AttachFileService.getFileUrl(x.PersonId + "#3"),
|
||||
// AttachUrl4 = AttachFileService.getFileUrl(x.PersonId + "#4"),
|
||||
// AttachUrl5 = AttachFileService.getFileUrl(x.PersonId + "#5"),
|
||||
AttachUrl1 = att1.AttachUrl,
|
||||
AttachUrl2 = att2.AttachUrl,
|
||||
AttachUrl3 = att3.AttachUrl,
|
||||
AttachUrl4 = att4.AttachUrl,
|
||||
AttachUrl5 = att5.AttachUrl,
|
||||
WorkPostName = wp.WorkPostName, //岗位名称
|
||||
PostType = wp.PostType, //岗位诶类型
|
||||
IsHsse = wp.IsHsse, //岗位是否是安管人员
|
||||
IsCQMS = wp.IsCQMS, //岗位是否是质量管理
|
||||
TeamGroupName = tg.TeamGroupName,
|
||||
WorkAreaName = APIDataShareSyncService.GetWorkAreaNames(x.WorkAreaId, projectId)
|
||||
}).ToList();
|
||||
|
||||
return personList;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 拉取项目人员数据
|
||||
|
||||
public static async Task<string> getPersonLists()
|
||||
{
|
||||
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.SubjectUnit != null &&
|
||||
x.SubjectProject != null
|
||||
select x).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 ApiUrl = "";
|
||||
var WebUrl = "";
|
||||
if (!string.IsNullOrEmpty(Url))
|
||||
{
|
||||
var urls = Url.Split(',');
|
||||
ApiUrl = urls[0];
|
||||
if (urls.Length > 1)
|
||||
{
|
||||
WebUrl = urls[1];
|
||||
}
|
||||
}
|
||||
|
||||
// CollCropCode = "913404001520228377Y";//测试使用
|
||||
// SubjectProjectId = "B409A8D7-48C7-486E-84C7-E3E7B2C0E5B7";//测试使用
|
||||
// unitId = "aaa9e72b-e3a6-441e-a7bb-afc008adebc9";//测试使用
|
||||
|
||||
string url = "/api/PersonSync/getPersonListByProjectIdAndCollCropCode?projectId=" +
|
||||
SubjectProjectId + "&collCropCode=" + CollCropCode;
|
||||
string baseurl = ApiUrl + url;
|
||||
|
||||
string contenttype = "application/json;charset=unicode";
|
||||
var strJosn = "";
|
||||
using (HttpClient client = new HttpClient())
|
||||
{
|
||||
client.Timeout = TimeSpan.FromMinutes(5); // 设置超时时间为5分钟
|
||||
client.DefaultRequestHeaders.Add("token",
|
||||
"AF17168B-87BD-4GLY-1111-F0A0A1158F9B"); // 前提是所有二级单位都有sysGLY账号且id是AF17168B-87BD-4GLY-1111-F0A0A1158F9B可作为token
|
||||
strJosn = await client.GetStringAsync(baseurl);
|
||||
}
|
||||
// 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<PersonSyncItem>>(obj["data"].ToString());
|
||||
if (getData.Count() > 0)
|
||||
{
|
||||
ProcessPersonData(getData, project.ProjectId, unitId, WebUrl);
|
||||
}
|
||||
|
||||
message = "获取成功:同步人员数" + getData.Count().ToString() + "条";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
message = "获取失败:" + ex.Message;
|
||||
ErrLogInfo.WriteLog("人员获取!", ex);
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 推送人员数据
|
||||
|
||||
public static ReturnData pushPersonLists(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 items = GetPersonLitsByProjectIdAndUnitId(projectId, "", dataId);
|
||||
//总包地址推送
|
||||
if (items.Count() > 0)
|
||||
{
|
||||
var thisUnit = CommonService.GetIsThisUnit(); //当前单位
|
||||
var apiurl = "/api/PersonSync/SavePersonSyncData";
|
||||
//总包单位接口地址
|
||||
var Url = BLL.UnitService.getUnitApiUrlByUnitId(project.SubjectUnit);
|
||||
var ApiUrl = "";
|
||||
var WebUrl = "";
|
||||
if (!string.IsNullOrEmpty(Url))
|
||||
{
|
||||
var urls = Url.Split(',');
|
||||
ApiUrl = urls[0];
|
||||
if (urls.Length > 1)
|
||||
{
|
||||
WebUrl = urls[1];
|
||||
}
|
||||
}
|
||||
|
||||
// thisUnit.CollCropCode = "913404001520228377Y"; //分包单位社会统一信用码 测试使用
|
||||
// project.SubjectProject = "B409A8D7-48C7-486E-84C7-E3E7B2C0E5B7";//测试使用
|
||||
|
||||
var pushData = new PersonSyncData
|
||||
{
|
||||
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> SavePersonSyncData(Model.PersonSyncData items)
|
||||
{
|
||||
int code = 0;
|
||||
string message = "";
|
||||
try
|
||||
{
|
||||
if (items.Items.Count > 0)
|
||||
{
|
||||
//获取分包单位CollCropCode
|
||||
var CollCropCode = items.CollCropCode;
|
||||
var ProjectId = items.ProjectId;
|
||||
var UnitDomain = items.UnitDomain; //分包单位域名地址【文件存储地址】
|
||||
//1、判断分包单位是否存在
|
||||
//根据分包单位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
|
||||
{
|
||||
ProcessPersonData(items.Items, ProjectId, unit.UnitId, UnitDomain);
|
||||
message = "数据推送成功!";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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 async void ProcessPersonData(List<Model.PersonSyncItem> getData, string projectId, string unitId,
|
||||
string WebUrl)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
foreach (var item in getData)
|
||||
{
|
||||
try
|
||||
{
|
||||
string IdentityCard = item.IdentityCard;
|
||||
var model = db.SitePerson_Person.FirstOrDefault(e => e.IdentityCard == IdentityCard && e.ProjectId == projectId);
|
||||
if (model == null)
|
||||
{
|
||||
Model.SitePerson_Person newModel = new Model.SitePerson_Person
|
||||
{
|
||||
PersonId = item.PersonId,
|
||||
CardNo = item.CardNo,
|
||||
PersonName = item.PersonName,
|
||||
//Sex = item.Sex,
|
||||
IdentityCard = item.IdentityCard,
|
||||
//Address = item.Address,
|
||||
ProjectId = projectId,
|
||||
UnitId = unitId,
|
||||
TeamGroupId = APIDataShareSyncService.GetTeamGroupId(item.TeamGroupName, projectId, unitId),
|
||||
WorkAreaId = APIDataShareSyncService.getWorkAreaId(item.WorkAreaName, projectId),
|
||||
WorkPostId = APIDataShareSyncService.getWorkPostId(item.WorkPostName, item.PostType,
|
||||
item.IsHsse.ToString(), item.IsCQMS.ToString()),
|
||||
InTime = item.InTime,
|
||||
OutTime = item.OutTime,
|
||||
OutResult = item.OutResult,
|
||||
//Telephone = item.Telephone,
|
||||
//PhotoUrl = item.PhotoUrl,
|
||||
// 异步安全的头像下载
|
||||
//HeadImage = await SafeDownloadHeadImageAsync(WebUrl, item.PhotoUrl),
|
||||
//IsUsed = item.IsUsed,
|
||||
//IsCardUsed = item.IsCardUsed,
|
||||
//PersonIndex = item.PersonIndex,
|
||||
CertificateId = item.CertificateId,
|
||||
CertificateCode = item.CertificateCode,
|
||||
CertificateLimitTime = item.CertificateLimitTime,
|
||||
//QualificationCertificateUrl = item.QualificationCertificateUrl,
|
||||
//TrainingCertificateUrl = item.TrainingCertificateUrl,
|
||||
//QRCodeAttachUrl = item.QRCodeAttachUrl,
|
||||
//Password = item.Password,
|
||||
//FromPersonId = item.FromPersonId,
|
||||
AuditorDate = item.AuditorDate,
|
||||
ExchangeTime = item.ExchangeTime,
|
||||
ExchangeTime2 = item.ExchangeTime2,
|
||||
//IDCardUrl = item.IDCardUrl,
|
||||
//IsForeign = item.IsForeign,
|
||||
//IsOutside = item.IsOutside,
|
||||
//EduLevel = item.EduLevel,
|
||||
//MaritalStatus = item.MaritalStatus,
|
||||
Isprint = item.Isprint,
|
||||
//MainCNProfessionalId = item.MainCNProfessionalId,
|
||||
//ViceCNProfessionalId = item.ViceCNProfessionalId,
|
||||
//Birthday = item.Birthday,
|
||||
//IdcardType = item.IdcardType,
|
||||
//IdcardStartDate = item.IdcardStartDate,
|
||||
//IdcardEndDate = item.IdcardEndDate,
|
||||
//IdcardForever = item.IdcardForever,
|
||||
//PoliticsStatus = item.PoliticsStatus,
|
||||
//IdcardAddress = item.IdcardAddress,
|
||||
//Nation = item.Nation,
|
||||
//CountryCode = item.CountryCode,
|
||||
IsSafetyMonitoring = item.IsSafetyMonitoring,
|
||||
//ProvinceCode = item.ProvinceCode,
|
||||
//IsCardNoOK = item.IsCardNoOK
|
||||
};
|
||||
|
||||
db.SitePerson_Person.InsertOnSubmit(newModel);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 更新现有记录
|
||||
UpdatePersonModel(model, item, projectId, unitId, WebUrl);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
|
||||
// 异步安全的附件处理
|
||||
await ProcessPersonAttachmentsAsync(WebUrl, item);
|
||||
|
||||
if (item.CertificateItem != null)
|
||||
{
|
||||
APIDataShareSyncService.ProcessPersonQualityData(item.CertificateItem, item.PersonId);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 记录异常但不中断整个批处理
|
||||
BLL.ErrLogInfo.WriteLog($"处理人员数据时出错 PersonId: {item?.PersonId}, 错误: {ex.Message}");
|
||||
continue; // 继续处理下一个记录
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 安全的头像下载方法
|
||||
public static async Task<byte[]> SafeDownloadHeadImageAsync(string webUrl, string photoUrl)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(photoUrl))
|
||||
return null;
|
||||
return await APIDataShareSyncService.DownloadHeadImageAsync(webUrl, photoUrl);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BLL.ErrLogInfo.WriteLog($"下载头像失败: {photoUrl}, 错误: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// 更新人员模型的辅助方法
|
||||
private static void UpdatePersonModel(Model.SitePerson_Person model, PersonSyncItem item, string projectId,
|
||||
string unitId, string webUrl)
|
||||
{
|
||||
// model.PersonId = item.PersonId;
|
||||
model.CardNo = item.CardNo;
|
||||
model.PersonName = item.PersonName;
|
||||
//model.Sex = item.Sex;
|
||||
model.IdentityCard = item.IdentityCard;
|
||||
//model.Address = item.Address;
|
||||
model.ProjectId = projectId;
|
||||
model.UnitId = unitId;
|
||||
model.TeamGroupId = APIDataShareSyncService.GetTeamGroupId(item.TeamGroupName, projectId, unitId);
|
||||
model.WorkAreaId = APIDataShareSyncService.getWorkAreaId(item.WorkAreaName, projectId);
|
||||
model.WorkPostId = APIDataShareSyncService.getWorkPostId(item.WorkPostName, item.PostType,
|
||||
item.IsHsse.ToString(), item.IsCQMS.ToString());
|
||||
model.InTime = item.InTime;
|
||||
model.OutTime = item.OutTime;
|
||||
model.OutResult = item.OutResult;
|
||||
//model.Telephone = item.Telephone;
|
||||
//model.PhotoUrl = item.PhotoUrl;
|
||||
|
||||
// 异步操作需要特殊处理
|
||||
Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
//model.HeadImage = await APIDataShareSyncService.DownloadHeadImageAsync(webUrl, item.PhotoUrl);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BLL.ErrLogInfo.WriteLog($"更新头像失败: {ex.Message}");
|
||||
}
|
||||
});
|
||||
|
||||
//model.IsUsed = item.IsUsed;
|
||||
//model.IsCardUsed = item.IsCardUsed;
|
||||
//model.PersonIndex = item.PersonIndex;
|
||||
model.CertificateId = item.CertificateId;
|
||||
model.CertificateCode = item.CertificateCode;
|
||||
model.CertificateLimitTime = item.CertificateLimitTime;
|
||||
//model.QualificationCertificateUrl = item.QualificationCertificateUrl;
|
||||
//model.TrainingCertificateUrl = item.TrainingCertificateUrl;
|
||||
//model.QRCodeAttachUrl = item.QRCodeAttachUrl;
|
||||
//model.Password = item.Password;
|
||||
//model.FromPersonId = item.FromPersonId;
|
||||
model.AuditorDate = item.AuditorDate;
|
||||
model.ExchangeTime = item.ExchangeTime;
|
||||
model.ExchangeTime2 = item.ExchangeTime2;
|
||||
//model.IDCardUrl = item.IDCardUrl;
|
||||
//model.IsForeign = item.IsForeign;
|
||||
//model.IsOutside = item.IsOutside;
|
||||
//model.EduLevel = item.EduLevel;
|
||||
//model.MaritalStatus = item.MaritalStatus;
|
||||
model.Isprint = item.Isprint;
|
||||
//model.MainCNProfessionalId = item.MainCNProfessionalId;
|
||||
//model.ViceCNProfessionalId = item.ViceCNProfessionalId;
|
||||
//model.Birthday = item.Birthday;
|
||||
//model.IdcardType = item.IdcardType;
|
||||
//model.IdcardStartDate = item.IdcardStartDate;
|
||||
//model.IdcardEndDate = item.IdcardEndDate;
|
||||
//model.IdcardForever = item.IdcardForever;
|
||||
//model.PoliticsStatus = item.PoliticsStatus;
|
||||
//model.IdcardAddress = item.IdcardAddress;
|
||||
//model.Nation = item.Nation;
|
||||
//model.CountryCode = item.CountryCode;
|
||||
model.IsSafetyMonitoring = item.IsSafetyMonitoring;
|
||||
//model.ProvinceCode = item.ProvinceCode;
|
||||
//model.IsCardNoOK = item.IsCardNoOK;
|
||||
}
|
||||
|
||||
// 异步安全的附件处理
|
||||
private static async Task ProcessPersonAttachmentsAsync(string webUrl, PersonSyncItem item)
|
||||
{
|
||||
try
|
||||
{
|
||||
var attachmentTasks = new List<Task>
|
||||
{
|
||||
APIDataShareSyncService.OperationAttachFile(webUrl, item.PersonId + "#1", BLL.Const.PersonListMenuId,
|
||||
item.AttachUrl1),
|
||||
APIDataShareSyncService.OperationAttachFile(webUrl, item.PersonId + "#2", BLL.Const.PersonListMenuId,
|
||||
item.AttachUrl2),
|
||||
APIDataShareSyncService.OperationAttachFile(webUrl, item.PersonId + "#3", BLL.Const.PersonListMenuId,
|
||||
item.AttachUrl3),
|
||||
APIDataShareSyncService.OperationAttachFile(webUrl, item.PersonId + "#4", BLL.Const.PersonListMenuId,
|
||||
item.AttachUrl4),
|
||||
APIDataShareSyncService.OperationAttachFile(webUrl, item.PersonId + "#5", BLL.Const.PersonListMenuId,
|
||||
item.AttachUrl5)
|
||||
};
|
||||
|
||||
await Task.WhenAll(attachmentTasks);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BLL.ErrLogInfo.WriteLog($"处理人员附件失败 PersonId: {item.PersonId}, 错误: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user