diff --git a/DataBase/版本日志/SUBQHSE_V2026-03-02-xiaj(View_License_LicenseManager).sql b/DataBase/版本日志/SUBQHSE_V2026-03-02-xiaj(View_License_LicenseManager).sql new file mode 100644 index 00000000..b8490983 --- /dev/null +++ b/DataBase/版本日志/SUBQHSE_V2026-03-02-xiaj(View_License_LicenseManager).sql @@ -0,0 +1,71 @@ + + + +--ҵƱ岹ֶΣԴ˵ +IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'License_LicenseManager' AND COLUMN_NAME = 'SourceDes') +BEGIN + ALTER TABLE License_LicenseManager ADD SourceDes nvarchar(500); +END +GO + +----ҵƱ岹ֶΣ֤ +--IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'License_LicenseManager' AND COLUMN_NAME = 'LicenseCodes') +--BEGIN +-- ALTER TABLE License_LicenseManager ADD LicenseCodes nvarchar(50); +--END +--GO + + + + +ALTER VIEW [dbo].[View_License_LicenseManager] +AS +/*ֳȫ֤*/ +SELECT LicenseManager.LicenseManagerId, + LicenseManager.ProjectId, + LicenseManager.LicenseTypeId, + LicenseManager.LicenseManagerCode, + LicenseManager.LicenseManageName, + LicenseManager.UnitId, + LicenseManager.LicenseManageContents, + LicenseManager.CompileMan, + LicenseManager.CompileDate, + LicenseManager.States, + Project.ProjectCode, + Project.ProjectName, + LicenseType.LicenseTypeName, + Unit.UnitName, + UnitType.UnitTypeId, + UnitType.UnitTypeName, + Users.UserName, + LicenseManager.WorkAreaId, + --WorkArea.WorkAreaName, + LicenseManager.StartDate, + LicenseManager.EndDate, + LicenseManager.ApplicantMan, + LicenseManager.IsHighRisk, + LicenseManager.WorkStates, + LicenseManager.IsUpdate, + LicenseManager.SourceDes, + case LicenseManager.WorkStates when '1' then '' + when '2' then 'ҵ' + when '3' then 'ѹر' + when '-1' then 'ȡ' + else '' end as WorkStatesStr, + WorkAreaName = STUFF(( SELECT ',' + UnitWorkName FROM WBS_UnitWork + where PATINDEX('%,' + RTRIM(WBS_UnitWork.UnitWorkId) + ',%',',' + LicenseManager.WorkAreaId + ',')>0 + ORDER BY PATINDEX('%,' + RTRIM(LicenseManager.WorkAreaId) + ',%',',' + LicenseManager.WorkAreaId + ',') + FOR XML PATH('')), 1, 1,'') +FROM dbo.License_LicenseManager AS LicenseManager +LEFT JOIN dbo.Base_Project AS Project ON Project.ProjectId = LicenseManager.ProjectId +LEFT JOIN dbo.Base_LicenseType AS LicenseType ON LicenseType.LicenseTypeId = LicenseManager.LicenseTypeId +LEFT JOIN dbo.Base_Unit AS Unit ON Unit.UnitId = LicenseManager.UnitId +LEFT JOIN dbo.Sys_User AS Users ON Users.UserId = LicenseManager.CompileMan +LEFT JOIN dbo.WBS_UnitWork AS WorkArea ON WorkArea.UnitWorkId = LicenseManager.WorkAreaId +LEFT JOIN dbo.Base_UnitType as UnitType ON UnitType.UnitTypeId=Unit.UnitTypeId + + + +GO + + diff --git a/SGGL/BLL/BLL.csproj b/SGGL/BLL/BLL.csproj index cf1165f6..22d94ed2 100644 --- a/SGGL/BLL/BLL.csproj +++ b/SGGL/BLL/BLL.csproj @@ -317,6 +317,7 @@ + diff --git a/SGGL/BLL/BLL.csproj.user b/SGGL/BLL/BLL.csproj.user index a607660d..0b246432 100644 --- a/SGGL/BLL/BLL.csproj.user +++ b/SGGL/BLL/BLL.csproj.user @@ -1,6 +1,6 @@ - ShowAllFiles + ProjectFiles \ No newline at end of file diff --git a/SGGL/BLL/DataShare/APIDataShareSyncService.cs b/SGGL/BLL/DataShare/APIDataShareSyncService.cs index 298fee0e..5c1e9885 100644 --- a/SGGL/BLL/DataShare/APIDataShareSyncService.cs +++ b/SGGL/BLL/DataShare/APIDataShareSyncService.cs @@ -1,8 +1,8 @@ -using System.Linq; -using System; +using System; using System.Collections.Generic; using System.Configuration; using System.IO; +using System.Linq; using System.Net.Http; using System.Threading.Tasks; @@ -37,7 +37,7 @@ namespace BLL ProjectId = projectId, UnitId = unitId, TeamGroupName = TeamGroupName, - Remark = "导入" + Remark = "分包数据同步导入" }; TeamGroupService.AddTeamGroup(newTeamGroup); TeamGroupId = newTeamGroup.TeamGroupId; @@ -53,6 +53,49 @@ namespace BLL #endregion + #region 作业票许可证类型 + + /// + /// 获取作业票许可证类型Id + /// + /// + /// + /// + /// + public static string GetLicenseTypeId(string LicenseTypeId, string LicenseTypeCode, string LicenseTypeName) + { + string Id = null; + if (!string.IsNullOrEmpty(LicenseTypeName)) + { + var obj = Funs.DB.Base_LicenseType.Where(x => x.LicenseTypeName == LicenseTypeName).ToList(); + if (obj.Count == 0) + { + string newId = LicenseTypeId; + var type = Funs.DB.Base_LicenseType.Where(x => x.LicenseTypeId == LicenseTypeId).FirstOrDefault(); + if (type == null) + { + newId = SQLHelper.GetNewID(typeof(Model.Base_LicenseType)); + } + Model.Base_LicenseType newModel = new Model.Base_LicenseType + { + LicenseTypeId = newId, + LicenseTypeCode = LicenseTypeCode, + LicenseTypeName = LicenseTypeName, + Remark = "分包数据同步导入" + }; + LicenseTypeService.AddLicenseType(newModel); + Id = newId; + } + else + { + Id = obj.FirstOrDefault().LicenseTypeId; + } + } + return Id; + } + + #endregion + #region 获取作业区域 diff --git a/SGGL/BLL/DataShare/HSSE/APILicenseSyncService.cs b/SGGL/BLL/DataShare/HSSE/APILicenseSyncService.cs new file mode 100644 index 00000000..ba034a14 --- /dev/null +++ b/SGGL/BLL/DataShare/HSSE/APILicenseSyncService.cs @@ -0,0 +1,262 @@ +using Model; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections; +using System.Linq; +using System.Runtime.InteropServices.ComTypes; + +namespace BLL +{ + /// + /// 作业票数据共享互通 + /// + public class APILicenseSyncService + { + #region 分包单位推送数据到总包单位 + + /// + /// 推送分包作业票定稿数据 + /// + /// 项目Id + /// 作业票定稿数据Id(为空的时候推送全部) + /// + 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.Sys_User on x.CompileMan equals su.UserId 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.UserName, + 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 } + //}; + var returndata = APIGetHttpService.Http(baseurl, "Post", contenttype, null, pushContent); + if (!string.IsNullOrEmpty(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 总包单位接收分包单位推送数据 + + /// + /// 总包单位接收保存分包单位推送的作业票定稿数据 + /// + /// + /// + 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 + } +} \ No newline at end of file diff --git a/SGGL/BLL/DataShare/HSSE/APIMeetingSyncService.cs b/SGGL/BLL/DataShare/HSSE/APIMeetingSyncService.cs index 29e7e10a..4384daf6 100644 --- a/SGGL/BLL/DataShare/HSSE/APIMeetingSyncService.cs +++ b/SGGL/BLL/DataShare/HSSE/APIMeetingSyncService.cs @@ -118,12 +118,11 @@ namespace BLL } var baseurl = $"{ApiUrl}/api/MeetingSync/ReceiveSaveProjectClassMeetingData"; string contenttype = "application/json;charset=unicode"; - Hashtable newToken = new Hashtable - { - { "token", ServerService.GetToken().Token } - }; - //var returndata = APIGetHttpService.Http(baseurl, "Post", contenttype, newToken, pushContent); - var returndata = ""; + //Hashtable newToken = new Hashtable + //{ + // { "token", ServerService.GetToken().Token } + //}; + var returndata = APIGetHttpService.Http(baseurl, "Post", contenttype, null, pushContent); if (!string.IsNullOrEmpty(returndata)) { JObject obj = JObject.Parse(returndata); @@ -161,8 +160,8 @@ namespace BLL string result = string.Empty; if (data.Items.Count() > 0) { - var jsonData = JsonConvert.SerializeObject(data); - ErrLogInfo.WriteLog($"【班前会接收数据】{jsonData}"); + //var jsonData = JsonConvert.SerializeObject(data); + //ErrLogInfo.WriteLog($"【班前会接收数据】{jsonData}"); //1、判断分包单位是否存在 var unit = UnitService.getUnitByCollCropCodeUnitName(data.CollCropCode, data.UnitName); if (unit == null) @@ -185,7 +184,7 @@ namespace BLL { try { - var model = ClassMeetingService.GetClassMeetingById(item.ClassMeetingId); + var model = db.Meeting_ClassMeeting.FirstOrDefault(e => e.ClassMeetingId == item.ClassMeetingId); if (model != null) {//编辑 model.ProjectId = data.SubjectProject; diff --git a/SGGL/BLL/OpenService/FileInsertService.cs b/SGGL/BLL/OpenService/FileInsertService.cs index 331ffca1..a65738ee 100644 --- a/SGGL/BLL/OpenService/FileInsertService.cs +++ b/SGGL/BLL/OpenService/FileInsertService.cs @@ -266,14 +266,14 @@ namespace BLL /// public static void InsertAttachFilesRecord(string attachFileId, string dataId, string attachSource, string attachUrl, List fileContext) { - BLL.ErrLogInfo.WriteLog($"数据和附件插入到多附件表:1"); + //BLL.ErrLogInfo.WriteLog($"数据和附件插入到多附件表:1"); if (!string.IsNullOrEmpty(attachFileId)) { //多附件 var attachFile = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == dataId); if (attachFile == null) { - BLL.ErrLogInfo.WriteLog($"数据和附件插入到多附件表:2:attachFile == null"); + //BLL.ErrLogInfo.WriteLog($"数据和附件插入到多附件表:2:attachFile == null"); ////插入附件文件 BLL.FileInsertService.FileMoreInsert(fileContext, attachUrl); @@ -289,10 +289,10 @@ namespace BLL } else { - BLL.ErrLogInfo.WriteLog($"数据和附件插入到多附件表:2:attachFile != null"); + //BLL.ErrLogInfo.WriteLog($"数据和附件插入到多附件表:2:attachFile != null"); if (attachFile.AttachUrl != attachUrl) { - BLL.ErrLogInfo.WriteLog($"数据和附件插入到多附件表:2:attachFile != null attachFile.AttachUrl != attachUrl"); + //BLL.ErrLogInfo.WriteLog($"数据和附件插入到多附件表:2:attachFile != null attachFile.AttachUrl != attachUrl"); /////删除附件文件 //BLL.UploadAttachmentService.DeleteFile(ConfigurationManager.AppSettings["localRoot"], attachFile.AttachUrl); ////插入附件文件 diff --git a/SGGL/FineUIPro.Web/HSSE/License/LicenseManager.aspx b/SGGL/FineUIPro.Web/HSSE/License/LicenseManager.aspx index cd922240..5ad4f126 100644 --- a/SGGL/FineUIPro.Web/HSSE/License/LicenseManager.aspx +++ b/SGGL/FineUIPro.Web/HSSE/License/LicenseManager.aspx @@ -9,125 +9,139 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - <%-- + + + + + + + + + + <%-- --%> - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + +