2025-08-25 09:56:57 +08:00
|
|
|
|
using APT.BaseData.Domain.Entities.FM;
|
|
|
|
|
|
using APT.BaseData.Domain.Entities;
|
|
|
|
|
|
using APT.BaseData.Domain.Enums.PF;
|
|
|
|
|
|
using APT.BaseData.Domain.Enums;
|
|
|
|
|
|
using APT.BaseData.Services.DomainServices;
|
|
|
|
|
|
using APT.BaseData.Services.Services.FM;
|
|
|
|
|
|
using APT.Infrastructure.Core;
|
|
|
|
|
|
using APT.MS.Domain.Entities.SK;
|
|
|
|
|
|
using APT.MS.Domain.Enums.SK;
|
|
|
|
|
|
using APT.MS.Domain.Enums;
|
|
|
|
|
|
using APT.Utility;
|
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
using APT.BaseData.Domain.IServices.FM;
|
|
|
|
|
|
using APT.BaseData.Domain.IServices;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System;
|
2025-09-20 13:03:07 +08:00
|
|
|
|
using APT.MS.Domain.Entities.BS;
|
|
|
|
|
|
using System.Dynamic;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using static APT.Utility.FileUtils;
|
|
|
|
|
|
using System.Configuration;
|
2025-08-25 09:56:57 +08:00
|
|
|
|
|
|
|
|
|
|
namespace APT.SK.WebApi.Controllers.Api
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 手动隐患上报表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[Route("api/SK/SKHiddenDangerHandReport")]
|
|
|
|
|
|
public partial class HiddenDangerHandReportController : AuthorizeApiController<T_SK_HIDDEN_DANGER_HAND_REPORT>
|
|
|
|
|
|
{
|
|
|
|
|
|
IPFApproveCallBackService ApproveCallBackService { get; set; }
|
|
|
|
|
|
IFMNotificationTaskService NotificationTaskService { get; set; }
|
|
|
|
|
|
IPFCodeRuleService CodeRuleService { get; set; }
|
|
|
|
|
|
IFMFlowPermitService MFlowPermitService { get; set; }
|
|
|
|
|
|
public HiddenDangerHandReportController(IFMNotificationTaskService notificationTaskService, IFMFlowPermitService mFlowPermitService, IPFCodeRuleService codeRuleService, IPFApproveCallBackService approveCallBackService)
|
|
|
|
|
|
{
|
|
|
|
|
|
NotificationTaskService = notificationTaskService;
|
|
|
|
|
|
MFlowPermitService = mFlowPermitService;
|
|
|
|
|
|
CodeRuleService = codeRuleService;
|
|
|
|
|
|
ApproveCallBackService = approveCallBackService;
|
|
|
|
|
|
}
|
|
|
|
|
|
[HttpPost, Route("FullUpdate")]
|
|
|
|
|
|
public JsonActionResult<bool> FullUpdate([FromBody] T_SK_HIDDEN_DANGER_HAND_REPORT entity)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SafeExecute<bool>(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
var userId = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
|
|
|
|
|
|
var departId = APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID;
|
|
|
|
|
|
var orgId = APT.Infrastructure.Api.AppContext.CurrentSession.OrgId;
|
2025-09-20 13:03:07 +08:00
|
|
|
|
if (entity.ID == null)
|
2025-08-25 09:56:57 +08:00
|
|
|
|
entity.ID = Guid.NewGuid();
|
|
|
|
|
|
if (entity.APPLY_USER_ID == null)
|
|
|
|
|
|
entity.APPLY_USER_ID = userId;
|
|
|
|
|
|
if (entity.APPLY_DEPARTMENT_ID == null)
|
|
|
|
|
|
entity.APPLY_DEPARTMENT_ID = departId;
|
|
|
|
|
|
if (entity.ORG_ID == null)
|
|
|
|
|
|
entity.ORG_ID = orgId;
|
|
|
|
|
|
var files = entity.Nav_ReportFiles;
|
|
|
|
|
|
entity.Nav_ReportFiles = null;
|
|
|
|
|
|
entity.Nav_RiskArea = null;
|
|
|
|
|
|
if (files != null && files.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var item in files)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.ORG_ID = entity.ORG_ID;
|
|
|
|
|
|
item.HIDDEN_DANGER_HAND_REPORT_ID = entity.ID;
|
|
|
|
|
|
item.Nav_ImgFile = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
List<T_FM_NOTIFICATION_TASK> notices = new List<T_FM_NOTIFICATION_TASK>();
|
|
|
|
|
|
T_SK_HIDDEN_DANGER_CONFIRM confirm = null;
|
2025-09-20 13:03:07 +08:00
|
|
|
|
List<T_SK_HIDDEN_DANGER_CONFIRM_PHOTO> photoList = new List<T_SK_HIDDEN_DANGER_CONFIRM_PHOTO>();
|
2025-08-25 09:56:57 +08:00
|
|
|
|
if (entity.PUBLISH != null && entity.PUBLISH.Equals("SaveAndNotify"))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (entity.APPLY_USER_ID != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var sendUser = entity.APPLY_USER_ID;
|
|
|
|
|
|
var depart = this.GetEntity<T_FM_DEPARTMENT>(t => t.ID == entity.APPLY_DEPARTMENT_ID && t.ENABLE_STATUS == 0);
|
|
|
|
|
|
entity.STATUS = PFStandardStatus.Archived;
|
|
|
|
|
|
if (depart != null && depart.DEPARTMENT_TYPE == 2 && depart.USER_ID != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
sendUser = depart.USER_ID;
|
|
|
|
|
|
}
|
|
|
|
|
|
var userName = this.GetEntity<T_FM_USER>(t => t.ENABLE_STATUS == (int)FMEnableStatusEnum.启用 && sendUser == t.ID)?.NAME;
|
|
|
|
|
|
confirm = new T_SK_HIDDEN_DANGER_CONFIRM();
|
|
|
|
|
|
confirm.HIDDEN_DANGER_HAND_REPORT_ID = entity.ID;
|
|
|
|
|
|
confirm.ORG_ID = entity.ORG_ID;
|
|
|
|
|
|
confirm.MineType = entity.MineType;
|
|
|
|
|
|
confirm.APPLY_USER_ID = entity.APPLY_USER_ID;
|
|
|
|
|
|
confirm.APPLY_DEPARTMENT_ID = entity.APPLY_DEPARTMENT_ID;
|
|
|
|
|
|
confirm.RISK_AREA_ID = entity.RISK_AREA_ID;
|
|
|
|
|
|
confirm.HIDDEN_PLACE = entity.HIDDEN_PLACE;
|
|
|
|
|
|
confirm.HIDDEN_DESCRIPTION = entity.HIDDEN_DESCRIPTION;
|
|
|
|
|
|
if (files != null && files.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var file in files)
|
|
|
|
|
|
{
|
|
|
|
|
|
T_SK_HIDDEN_DANGER_CONFIRM_PHOTO photo = new T_SK_HIDDEN_DANGER_CONFIRM_PHOTO();
|
|
|
|
|
|
photo.ORG_ID = file.ORG_ID;
|
|
|
|
|
|
photo.IMG_FILE_ID = file.IMG_FILE_ID;
|
|
|
|
|
|
photo.HIDDEN_DANGER_CONFIRM_ID = confirm.ID;
|
|
|
|
|
|
photoList.Add(photo);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//发消息
|
2025-09-20 13:03:07 +08:00
|
|
|
|
var titleName = "隐患确认单(" + depart?.NAME + DateTime.Now.ToShortDateString().Replace("/", "") + ")";
|
|
|
|
|
|
if (orgId.ToString() == "d9871ba8-0eec-9e4a-bb87-7d5a540d8913")
|
|
|
|
|
|
{
|
|
|
|
|
|
titleName = "手动隐患上报完善";
|
|
|
|
|
|
}
|
|
|
|
|
|
var notice = NotificationTaskService.InsertUserNoticeTaskModel(titleName, confirm.ID, entity.ORG_ID, (Guid)sendUser, userName, DateTime.Now,
|
2025-08-25 09:56:57 +08:00
|
|
|
|
DateTime.Now.AddHours(24), (int)FMNoticeTypeEnum.消息, "SK018");
|
|
|
|
|
|
notices.Add(notice);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
entity.STATUS = PFStandardStatus.Archived;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
this.UnifiedCommit(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (entity != null)
|
|
|
|
|
|
UpdateEntityNoCommit(entity);
|
|
|
|
|
|
if (files != null && files.Any())
|
|
|
|
|
|
BantchSaveEntityNoCommit(files);
|
|
|
|
|
|
if (confirm != null)
|
|
|
|
|
|
UpdateEntityNoCommit(confirm);
|
|
|
|
|
|
if (photoList != null && photoList.Any())
|
|
|
|
|
|
BantchSaveEntityNoCommit(photoList);
|
|
|
|
|
|
if (notices != null && notices.Any())
|
|
|
|
|
|
BantchSaveEntityNoCommit(notices);
|
|
|
|
|
|
});
|
|
|
|
|
|
return true;
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2025-09-20 13:03:07 +08:00
|
|
|
|
|
|
|
|
|
|
#region 隐患上报 离线缓存版
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 手动隐患上报 单次 一张图片 必备输入信息 imgID = CONTENT_ID
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost, Route("UploadFileRiskCache")]
|
|
|
|
|
|
public JsonActionResult<dynamic> UploadFileRiskCache()
|
|
|
|
|
|
{
|
|
|
|
|
|
return SafeExecute<dynamic>(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
dynamic result = new ExpandoObject();
|
|
|
|
|
|
var httpRequest = HttpContext.Request;
|
|
|
|
|
|
Microsoft.AspNetCore.Http.IFormCollection formInfo = httpRequest.Form;
|
|
|
|
|
|
var strOrgId = formInfo["OrgId"][0]; // 获取 组织
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(strOrgId))
|
|
|
|
|
|
throw new Exception("组织不允许为空");
|
|
|
|
|
|
var orgId = new Guid(strOrgId);
|
|
|
|
|
|
var now = DateTime.Now;
|
|
|
|
|
|
var LoginID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
|
|
|
|
|
|
|
|
|
|
|
|
#region 图片处理
|
|
|
|
|
|
|
|
|
|
|
|
var strImgID = string.Empty;
|
|
|
|
|
|
if (formInfo.ContainsKey("imgFileID"))
|
|
|
|
|
|
{
|
|
|
|
|
|
strImgID = formInfo["imgFileID"][0];
|
|
|
|
|
|
}
|
|
|
|
|
|
Guid ImgID = Guid.Empty;
|
|
|
|
|
|
if (strImgID != null && !string.IsNullOrEmpty(strImgID))
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
ImgID = new Guid(strImgID.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { }
|
|
|
|
|
|
}
|
|
|
|
|
|
if (ImgID == Guid.Empty)
|
|
|
|
|
|
ImgID = Guid.NewGuid();
|
|
|
|
|
|
string filePath = GetFilePath(orgId);
|
|
|
|
|
|
|
|
|
|
|
|
var fullFilePath = $"{ConfigurationManager.AppSettings["Img_Local"]}{filePath}";
|
|
|
|
|
|
|
|
|
|
|
|
ImageConverterFactory imageConverterFactory = new ImageConverterFactory();
|
|
|
|
|
|
var host = ConfigurationManager.AppSettings["SapInvokeHost"];
|
|
|
|
|
|
|
|
|
|
|
|
List<T_PF_FILE> fileList = new List<T_PF_FILE>();
|
|
|
|
|
|
List<T_PF_IMG_FILE> imgFileList = new List<T_PF_IMG_FILE>();
|
|
|
|
|
|
List<T_PF_IMG_FILE_DETAIL> imgFileDetailList = new List<T_PF_IMG_FILE_DETAIL>();
|
|
|
|
|
|
var files = formInfo.Files;
|
|
|
|
|
|
if (!Directory.Exists(fullFilePath))
|
|
|
|
|
|
{
|
|
|
|
|
|
Directory.CreateDirectory(fullFilePath);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var item in files)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (item != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
//文件后缀
|
|
|
|
|
|
var fileExtension = Path.GetExtension(item.FileName);
|
|
|
|
|
|
var strDateTime = DateTime.Now.ToString("yyMMddhhmmssfff"); //取得时间字符串
|
|
|
|
|
|
var strRan = Convert.ToString(new Random().Next(100, 999)); //生成三位随机数
|
|
|
|
|
|
var saveName = strDateTime + strRan + fileExtension;
|
|
|
|
|
|
string fileName = item.FileName;
|
|
|
|
|
|
|
|
|
|
|
|
//插入图片数据
|
|
|
|
|
|
using (FileStream fs = System.IO.File.Create(fullFilePath + saveName))//fullFilePath + fileName wyw
|
|
|
|
|
|
{
|
|
|
|
|
|
item.CopyTo(fs);
|
|
|
|
|
|
fs.Flush();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (fileExtension == ".jpg" || fileExtension == ".png" || fileExtension == ".jpeg")
|
|
|
|
|
|
{
|
|
|
|
|
|
using (FileStream inputFileStream = new FileStream(fullFilePath + saveName, FileMode.Open, FileAccess.Read))
|
|
|
|
|
|
{
|
|
|
|
|
|
MemoryStream compressedStream = CompressImageFileStream(inputFileStream);
|
|
|
|
|
|
inputFileStream.Close();
|
|
|
|
|
|
using (FileStream outputFileStream = new FileStream(fullFilePath + saveName, FileMode.Create, FileAccess.Write))
|
|
|
|
|
|
{
|
|
|
|
|
|
compressedStream.CopyTo(outputFileStream);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var pos = fileName.LastIndexOf(".");
|
|
|
|
|
|
var extendName = fileName.Substring(pos);
|
|
|
|
|
|
List<ConvertImageFile> list = new List<ConvertImageFile>();
|
|
|
|
|
|
bool isSuppot = imageConverterFactory.Support(extendName);
|
|
|
|
|
|
bool isSaveSelf = true;
|
|
|
|
|
|
|
|
|
|
|
|
T_PF_IMG_FILE imgFile = new T_PF_IMG_FILE
|
|
|
|
|
|
{
|
|
|
|
|
|
ID = ImgID,
|
|
|
|
|
|
FILE_NAME = fileName,
|
|
|
|
|
|
FILE_TYPE = item.ContentType,
|
|
|
|
|
|
ORG_ID = orgId,
|
|
|
|
|
|
CREATER_ID = LoginID,
|
|
|
|
|
|
CREATE_TIME = now
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var inputStream = item.OpenReadStream();
|
|
|
|
|
|
//支持转换时,按类型转为图片,否则直接存储
|
|
|
|
|
|
if (isSuppot)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrEmpty(host))
|
|
|
|
|
|
{
|
|
|
|
|
|
ConvertImageFileParam param = new ConvertImageFileParam();
|
|
|
|
|
|
param.FileName = fileName;
|
|
|
|
|
|
Byte[] fileData = new Byte[(int)item.Length];
|
|
|
|
|
|
Stream sr = inputStream;//创建数据流对象
|
|
|
|
|
|
sr.Read(fileData, 0, (int)item.Length);
|
|
|
|
|
|
param.FileData = fileData;
|
|
|
|
|
|
string url = host + "ImageConvert/ImageConvert";
|
|
|
|
|
|
ConvertImageFileParam retModel =
|
|
|
|
|
|
WebUtils.Execute<ConvertImageFileParam>(url, param, string.Empty, SendType.Post);
|
|
|
|
|
|
if (retModel != null && retModel.Files != null && retModel.Files.Any())
|
|
|
|
|
|
list.AddRange(retModel.Files);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var convert = imageConverterFactory.CreateImageConverter(fileName);
|
|
|
|
|
|
convert.ConvertToImage(fileName, inputStream, list);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (isSaveSelf)//保存自身数据
|
|
|
|
|
|
{
|
|
|
|
|
|
Byte[] fileData = new Byte[(int)item.Length];
|
|
|
|
|
|
Stream sr = inputStream;//创建数据流对象
|
|
|
|
|
|
sr.Read(fileData, 0, (int)item.Length);
|
|
|
|
|
|
T_PF_FILE file = new T_PF_FILE
|
|
|
|
|
|
{
|
|
|
|
|
|
FILE_NAME = fileName,
|
|
|
|
|
|
FILE_TYPE = item.ContentType,
|
|
|
|
|
|
//FILE_DATA = fileData,
|
|
|
|
|
|
ORG_ID = orgId,
|
|
|
|
|
|
//FILE_PATH = filePath + fileName
|
|
|
|
|
|
FILE_PATH = filePath + saveName,//wyw,
|
|
|
|
|
|
CREATER_ID = LoginID,
|
|
|
|
|
|
CREATE_TIME = now
|
|
|
|
|
|
};
|
|
|
|
|
|
imgFile.FILE_ID = file.ID;
|
|
|
|
|
|
imgFile.Nav_File = file;
|
|
|
|
|
|
fileList.Add(file);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
ConvertImageFile tmpImgFile = new ConvertImageFile();
|
|
|
|
|
|
//tmpImgFile.FileName = fileName;
|
|
|
|
|
|
tmpImgFile.FileName = saveName;//wyw
|
|
|
|
|
|
tmpImgFile.FileType = item.ContentType;
|
|
|
|
|
|
Byte[] fileData = new Byte[(int)item.Length];
|
|
|
|
|
|
Stream sr = inputStream;//创建数据流对象
|
|
|
|
|
|
sr.Read(fileData, 0, (int)item.Length);
|
|
|
|
|
|
tmpImgFile.FileData = fileData;
|
|
|
|
|
|
list.Add(tmpImgFile);
|
|
|
|
|
|
}
|
|
|
|
|
|
//保存文件数据
|
|
|
|
|
|
if (list.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
int i = 1;
|
|
|
|
|
|
foreach (var fileitem in list)
|
|
|
|
|
|
{
|
|
|
|
|
|
T_PF_FILE file = new T_PF_FILE
|
|
|
|
|
|
{
|
|
|
|
|
|
ID = Guid.NewGuid(),
|
|
|
|
|
|
FILE_NAME = fileitem.FileName,
|
|
|
|
|
|
FILE_TYPE = fileitem.FileType,
|
|
|
|
|
|
//FILE_DATA = fileitem.FileData,
|
|
|
|
|
|
//FILE_PATH = filePath + fileName,
|
|
|
|
|
|
FILE_PATH = filePath + saveName,//wyw,
|
|
|
|
|
|
ORG_ID = orgId,
|
|
|
|
|
|
CREATER_ID = LoginID,
|
|
|
|
|
|
CREATE_TIME = now
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (!isSuppot && isSaveSelf)
|
|
|
|
|
|
{
|
|
|
|
|
|
imgFile.FILE_ID = file.ID;
|
|
|
|
|
|
imgFile.Nav_File = file;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(imgFile.FILE_PATH) && !string.IsNullOrEmpty(file.FILE_PATH))
|
|
|
|
|
|
imgFile.FILE_PATH = file.FILE_PATH;
|
|
|
|
|
|
|
|
|
|
|
|
T_PF_IMG_FILE_DETAIL detail = new T_PF_IMG_FILE_DETAIL
|
|
|
|
|
|
{
|
|
|
|
|
|
ORG_ID = orgId,
|
|
|
|
|
|
IMG_FILE_ID = imgFile.ID,
|
|
|
|
|
|
FILE_ID = file.ID,
|
|
|
|
|
|
NUM = i,
|
|
|
|
|
|
CREATER_ID = LoginID,
|
|
|
|
|
|
CREATE_TIME = now
|
|
|
|
|
|
};
|
|
|
|
|
|
i++;
|
|
|
|
|
|
fileList.Add(file);
|
|
|
|
|
|
imgFileDetailList.Add(detail);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
imgFileList.Add(imgFile);
|
|
|
|
|
|
result.imgFileID = imgFile.ID;
|
|
|
|
|
|
result.imgFilePath = imgFile.Nav_File?.FILE_PATH;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 隐患上报处理
|
|
|
|
|
|
T_SK_HIDDEN_DANGER_HAND_REPORT risk = new T_SK_HIDDEN_DANGER_HAND_REPORT();
|
|
|
|
|
|
List<T_SK_HIDDEN_DANGER_HAND_REPORT_FILE> listFiles = new List<T_SK_HIDDEN_DANGER_HAND_REPORT_FILE>();
|
|
|
|
|
|
T_SK_HIDDEN_DANGER_CONFIRM confirm = new T_SK_HIDDEN_DANGER_CONFIRM();
|
|
|
|
|
|
List<T_SK_HIDDEN_DANGER_CONFIRM_PHOTO> listPhotos = new List<T_SK_HIDDEN_DANGER_CONFIRM_PHOTO>();
|
|
|
|
|
|
#region risk 赋值
|
|
|
|
|
|
risk.ID = Guid.NewGuid();
|
|
|
|
|
|
risk.ORG_ID = orgId;
|
|
|
|
|
|
risk.CREATE_TIME = DateTime.Now;
|
|
|
|
|
|
risk.CREATER_ID = LoginID;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
risk.RISK_AREA_ID = new Guid(formInfo["RISK_AREA_ID"]);
|
|
|
|
|
|
risk.HIDDEN_PLACE = formInfo["HIDDEN_PLACE"];
|
|
|
|
|
|
risk.HIDDEN_DESCRIPTION = formInfo["HIDDEN_DESCRIPTION"];
|
|
|
|
|
|
risk.APPLY_USER_ID = new Guid(formInfo["APPLY_USER_ID"]);
|
|
|
|
|
|
risk.APPLY_DEPARTMENT_ID = new Guid(formInfo["APPLY_DEPARTMENT_ID"]);
|
|
|
|
|
|
var minetype = int.Parse(formInfo["MineType"]);
|
|
|
|
|
|
switch (minetype)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
risk.MineType = SKProductionUnit.All;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 10:
|
|
|
|
|
|
risk.MineType = SKProductionUnit.MineChoose;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 20:
|
|
|
|
|
|
risk.MineType = SKProductionUnit.Minelast;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 30:
|
|
|
|
|
|
risk.MineType = SKProductionUnit.Mine;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 31:
|
|
|
|
|
|
risk.MineType = SKProductionUnit.Department;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 32:
|
|
|
|
|
|
risk.MineType = SKProductionUnit.Nonmetallic;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 40:
|
|
|
|
|
|
risk.MineType = SKProductionUnit.MineUnderGround;
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
risk.MineType = SKProductionUnit.All;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { }
|
|
|
|
|
|
if (!risk.RISK_AREA_ID.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new Exception("检查区域不能为空!");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (string.IsNullOrEmpty(risk.HIDDEN_PLACE))
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new Exception("隐患地点不能为空!");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (string.IsNullOrEmpty(risk.HIDDEN_DESCRIPTION))
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new Exception("隐患描述不能为空!");
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (risk.HIDDEN_DESCRIPTION.Length > 500)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new Exception("隐患描述不能超过500字!");
|
|
|
|
|
|
}
|
|
|
|
|
|
risk.STATUS = PFStandardStatus.Archived;
|
|
|
|
|
|
if (risk.APPLY_DEPARTMENT_ID == null || risk.APPLY_DEPARTMENT_ID == Guid.Empty)
|
|
|
|
|
|
risk.APPLY_DEPARTMENT_ID = APT.Infrastructure.Api.AppContext.DepartmentID;
|
|
|
|
|
|
if (risk.APPLY_USER_ID == null || risk.APPLY_USER_ID == Guid.Empty)
|
|
|
|
|
|
risk.APPLY_USER_ID = LoginID;
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 隐患确认单 赋值
|
|
|
|
|
|
confirm.ID = Guid.NewGuid();
|
|
|
|
|
|
confirm.HIDDEN_DANGER_HAND_REPORT_ID = risk.ID;
|
|
|
|
|
|
confirm.ORG_ID = orgId;
|
|
|
|
|
|
confirm.CREATE_TIME = DateTime.Now;
|
|
|
|
|
|
confirm.CREATER_ID = LoginID;
|
|
|
|
|
|
confirm.APPLY_USER_ID = risk.APPLY_USER_ID;
|
|
|
|
|
|
confirm.APPLY_DEPARTMENT_ID = risk.APPLY_DEPARTMENT_ID;
|
|
|
|
|
|
confirm.MineType = risk.MineType;
|
|
|
|
|
|
confirm.RISK_AREA_ID = risk.RISK_AREA_ID;
|
|
|
|
|
|
confirm.HIDDEN_PLACE = risk.HIDDEN_PLACE;
|
|
|
|
|
|
confirm.HIDDEN_DESCRIPTION = risk.HIDDEN_DESCRIPTION;
|
|
|
|
|
|
confirm.STATUS = PFStandardStatus.Draft;
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 待办 日志 等 赋值处理
|
|
|
|
|
|
|
|
|
|
|
|
T_FM_NOTIFICATION_TASK taskMaster = null;
|
|
|
|
|
|
T_FM_NOTIFICATION_TASK taskEnd = null;
|
|
|
|
|
|
//手动上报 保存并发送 通知安全员
|
|
|
|
|
|
if (risk.STATUS == PFStandardStatus.Archived)
|
|
|
|
|
|
{
|
|
|
|
|
|
Guid UserId = Guid.Empty;
|
|
|
|
|
|
string userName = String.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
#region 版本 2 本层级找 安全员 找不到就找负责人 (如果是负责人 就是自己)
|
|
|
|
|
|
|
|
|
|
|
|
var master = GetEntity<T_FM_USER>(risk.APPLY_USER_ID.Value, "Nav_Department");
|
|
|
|
|
|
if (master.Nav_Department == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new Exception("未获取到您的组织信息,操作失败!");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (master.Nav_Department.USER_ID.HasValue && master.Nav_Department.USER_ID.Value == risk.APPLY_USER_ID.Value)
|
|
|
|
|
|
{
|
|
|
|
|
|
//如果自己是负责人 就是自己
|
|
|
|
|
|
UserId = risk.APPLY_USER_ID.Value;
|
|
|
|
|
|
userName = master.NAME;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
//找安全员 如果没有 找负责人
|
|
|
|
|
|
// 班组 班长 否则 安全员 FMDepartmentType 部门=0, 车间=1, 班组=2, 公司=3
|
|
|
|
|
|
if (master.Nav_Department.DEPARTMENT_TYPE == 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (master.Nav_Department.USER_ID.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
UserId = master.Nav_Department.USER_ID.Value;
|
|
|
|
|
|
userName = GetEntity<T_FM_USER>(UserId)?.NAME;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var userSafe = GetEntity<T_FM_USER>(e => !e.IS_DELETED && e.DEPARTMENT_ID == master.DEPARTMENT_ID && e.Nav_ApproveRole.NAME.Contains("负责人"));
|
|
|
|
|
|
if (userSafe != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UserId = userSafe.ID;
|
|
|
|
|
|
userName = userSafe.NAME;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var userSafe = GetEntity<T_FM_USER>(e => !e.IS_DELETED && e.DEPARTMENT_ID == master.DEPARTMENT_ID && e.Nav_ApproveRole.NAME.Contains("安全员"));
|
|
|
|
|
|
if (userSafe != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UserId = userSafe.ID;
|
|
|
|
|
|
userName = userSafe.NAME;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
userSafe = GetEntity<T_FM_USER>(e => !e.IS_DELETED && e.DEPARTMENT_ID == master.DEPARTMENT_ID && e.Nav_ApproveRole.NAME.Contains("负责人"));
|
|
|
|
|
|
if (userSafe != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UserId = userSafe.ID;
|
|
|
|
|
|
userName = userSafe.NAME;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (UserId == Guid.Empty)//没找到给自己
|
|
|
|
|
|
{
|
|
|
|
|
|
UserId = risk.APPLY_USER_ID.Value;
|
|
|
|
|
|
userName = master.NAME;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
taskMaster = NotificationTaskService.InsertUserNoticeTaskModel("隐患确认单(离线触发)", confirm.ID, confirm.ORG_ID, UserId, userName, DateTime.Now, DateTime.Now.AddHours(24), (int)FMNoticeTypeEnum.消息, "SK018");
|
|
|
|
|
|
if (risk.TaskID != Guid.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
taskEnd = NotificationTaskService.GetEntityTask(risk.TaskID, "SK016_SHOWPRINT");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region CONTENT_FILE 赋值
|
|
|
|
|
|
|
|
|
|
|
|
//隐患上报信息附件
|
|
|
|
|
|
foreach (var item in imgFileList)
|
|
|
|
|
|
{
|
|
|
|
|
|
listFiles.Add(new T_SK_HIDDEN_DANGER_HAND_REPORT_FILE()
|
|
|
|
|
|
{
|
|
|
|
|
|
ID = Guid.NewGuid(),
|
|
|
|
|
|
ORG_ID = orgId,
|
|
|
|
|
|
CREATE_TIME = now,
|
|
|
|
|
|
CREATER_ID = LoginID,
|
|
|
|
|
|
HIDDEN_DANGER_HAND_REPORT_ID = risk.ID,
|
|
|
|
|
|
IMG_FILE_ID = item.ID
|
|
|
|
|
|
});
|
|
|
|
|
|
listPhotos.Add(new T_SK_HIDDEN_DANGER_CONFIRM_PHOTO()
|
|
|
|
|
|
{
|
|
|
|
|
|
ID = Guid.NewGuid(),
|
|
|
|
|
|
ORG_ID = orgId,
|
|
|
|
|
|
CREATE_TIME = now,
|
|
|
|
|
|
CREATER_ID = LoginID,
|
|
|
|
|
|
HIDDEN_DANGER_CONFIRM_ID = confirm.ID,
|
|
|
|
|
|
IMG_FILE_ID = item.ID
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 数据操作
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
//为了不让隐患上报数据冲突 entity.ID 前端直接传入
|
|
|
|
|
|
this.UnifiedCommit(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (fileList != null && fileList.Any())
|
|
|
|
|
|
BantchSaveEntityNoCommit(fileList);
|
|
|
|
|
|
if (imgFileList != null && imgFileList.Any())
|
|
|
|
|
|
BantchSaveEntityNoCommit(imgFileList);
|
|
|
|
|
|
if (imgFileDetailList != null && imgFileDetailList.Any())
|
|
|
|
|
|
BantchSaveEntityNoCommit(imgFileDetailList);
|
|
|
|
|
|
|
|
|
|
|
|
if (risk != null)
|
|
|
|
|
|
UpdateEntityNoCommit(risk);
|
|
|
|
|
|
if (confirm != null)
|
|
|
|
|
|
UpdateEntityNoCommit(confirm);
|
|
|
|
|
|
if (taskMaster != null)
|
|
|
|
|
|
UpdateEntityNoCommit(taskMaster);
|
|
|
|
|
|
if (taskEnd != null)
|
|
|
|
|
|
UpdateEntityNoCommit(taskEnd);
|
|
|
|
|
|
if (listFiles != null && listFiles.Any())
|
|
|
|
|
|
BantchSaveEntityNoCommit(listFiles);
|
|
|
|
|
|
if (listPhotos != null && listPhotos.Any())
|
|
|
|
|
|
BantchSaveEntityNoCommit(listPhotos);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
catch
|
|
|
|
|
|
{
|
|
|
|
|
|
//提交错误
|
|
|
|
|
|
result.imgFileID = "";
|
|
|
|
|
|
result.imgFilePath = "";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据OrgId获取文件夹名称
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="OrgId"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
private string GetFilePath(Guid OrgId)
|
|
|
|
|
|
{
|
|
|
|
|
|
string orgid = OrgId.ToString().ToUpperInvariant();
|
|
|
|
|
|
string pathHead = "";
|
|
|
|
|
|
if (OrgId != new Guid())
|
|
|
|
|
|
{
|
|
|
|
|
|
List<EnumberEntity> listHead = EnumToList<FilePathHead>();
|
|
|
|
|
|
var info = listHead.FirstOrDefault(e => e.Desction == orgid);
|
|
|
|
|
|
if (info != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
pathHead = info.EnumName;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
|
|
|
var filePath = string.Format("/{0}/{1}/{2}/", dtNow.ToString("yyyy"), dtNow.ToString("yyyyMM"), dtNow.ToString("yyyyMMdd"));
|
|
|
|
|
|
return string.IsNullOrEmpty(pathHead) ? filePath : "/" + pathHead + filePath;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
2025-08-25 09:56:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|