1126 lines
52 KiB
C#
1126 lines
52 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Linq.Expressions;
|
||
using APT.BaseData.Domain.Entities;
|
||
using APT.BaseData.Domain.Entities.FM;
|
||
using APT.BaseData.Domain.Entities.OP;
|
||
using APT.BaseData.Domain.Enums;
|
||
using APT.BaseData.Domain.Enums.PF;
|
||
using APT.BaseData.Domain.IServices;
|
||
using APT.BaseData.Domain.IServices.FM;
|
||
using APT.BaseData.Services.Services.FM;
|
||
using APT.Infrastructure.Api;
|
||
using APT.Infrastructure.Core;
|
||
using APT.Migrations;
|
||
using APT.MS.Domain.Entities.FO;
|
||
using APT.MS.Domain.Entities.LR;
|
||
using APT.MS.Domain.Entities.SE;
|
||
using APT.MS.Domain.Entities.WB;
|
||
using APT.MS.Domain.Enums;
|
||
using APT.Utility;
|
||
using Microsoft.AspNetCore.Mvc;
|
||
using Microsoft.CodeAnalysis;
|
||
using NPOI.SS.Formula.Functions;
|
||
|
||
namespace APT.SC.WebApi.Controllers.Api.WB
|
||
{
|
||
[Route("api/WB/WBRegister")]
|
||
public class WBRegisterController : AuthorizeApiController<T_WB_REGISTER>
|
||
{
|
||
IFMNotificationTaskService NotificationTaskService { get; set; }
|
||
IPFApproveCallBackService ApproveCallBackService { get; set; }
|
||
IFMFlowPermitService MFlowPermitService { get; set; }
|
||
public WBRegisterController(IFMNotificationTaskService notificationTaskService, IPFApproveCallBackService approveCallBackService, IFMFlowPermitService mFlowPermitService)
|
||
{
|
||
NotificationTaskService = notificationTaskService;
|
||
ApproveCallBackService = approveCallBackService;
|
||
MFlowPermitService = mFlowPermitService;
|
||
}
|
||
/// <summary>
|
||
/// 保存
|
||
/// </summary>
|
||
/// <param name="id"></param>
|
||
/// <returns></returns>
|
||
[HttpPost, Route("FullUpdate")]
|
||
public JsonActionResult<bool> FullUpdate([FromBody] T_WB_REGISTER entity)
|
||
{
|
||
return SafeExecute(() =>
|
||
{
|
||
//wyw 修改 人员信息 已经提出单独页面处理 此处不处理
|
||
|
||
List<T_WB_REGISTER_1_FILE> file1 = new List<T_WB_REGISTER_1_FILE>();
|
||
//List<T_WB_REGISTER_2_FILE1> file21 = new List<T_WB_REGISTER_2_FILE1>();
|
||
//List<T_WB_REGISTER_2_FILE2> file22 = new List<T_WB_REGISTER_2_FILE2>();
|
||
//List<T_WB_REGISTER_2_FILE3> file23 = new List<T_WB_REGISTER_2_FILE3>();
|
||
//List<T_WB_REGISTER_2_FILE4> file24 = new List<T_WB_REGISTER_2_FILE4>();
|
||
List<T_WB_REGISTER_3_FILE> file3 = new List<T_WB_REGISTER_3_FILE>();
|
||
List<T_WB_REGISTER_4_FILE> file4 = new List<T_WB_REGISTER_4_FILE>();
|
||
//List<T_FM_PERSON> newPersons = new List<T_FM_PERSON>();
|
||
//List<T_FM_USER> newUsers = new List<T_FM_USER>();
|
||
//T_FM_USER_PRODUCTION_UNIT unit = null;
|
||
//List<T_FM_USER_PRODUCTION_UNIT> productionUnit = null;
|
||
//List<T_FM_USER_BELONG_ROLE> belongRole1s = new List<T_FM_USER_BELONG_ROLE>();
|
||
//List<T_FM_USER_BELONG_ROLE> belongRole2s = new List<T_FM_USER_BELONG_ROLE>();
|
||
T_FM_NOTIFICATION_TASK sendNotice = null;
|
||
T_FM_NOTIFICATION_TASK finishNotice = null;
|
||
var project = GetEntity<T_WB_PROJECT_INPUT>(t => t.ID == entity.PROJECT_ID);
|
||
var item1 = entity.Nav_Item1;
|
||
var item2 = entity.Nav_Item2;
|
||
var item3 = entity.Nav_Item3;
|
||
var item4 = entity.Nav_Item4;
|
||
DateTime dtNow = DateTime.Now;
|
||
//暂不必填
|
||
//if (item4 == null || item4.Count() < 1)
|
||
//{
|
||
// throw new Exception("外包单位必须要有【设备设施】!");
|
||
//}
|
||
entity.Nav_Item1.ForEach(t =>
|
||
{
|
||
if (t.Nav_Files != null && t.Nav_Files.Count() > 0)
|
||
{
|
||
file1.AddRange(t.Nav_Files);
|
||
t.Nav_Files = null;
|
||
}
|
||
});
|
||
//entity.Nav_Item2.ForEach(t =>
|
||
//{
|
||
// if (t.Nav_Files1 != null && t.Nav_Files1.Count() > 0)
|
||
// {
|
||
// file21.AddRange(t.Nav_Files1);
|
||
// t.Nav_Files1 = null;
|
||
// }
|
||
// if (t.Nav_Files2 != null && t.Nav_Files2.Count() > 0)
|
||
// {
|
||
// file22.AddRange(t.Nav_Files2);
|
||
// t.Nav_Files2 = null;
|
||
// }
|
||
// if (t.Nav_Files3 != null && t.Nav_Files3.Count() > 0)
|
||
// {
|
||
// file23.AddRange(t.Nav_Files3);
|
||
// t.Nav_Files3 = null;
|
||
// }
|
||
// if (t.Nav_Files4 != null && t.Nav_Files4.Count() > 0)
|
||
// {
|
||
// file24.AddRange(t.Nav_Files4);
|
||
// t.Nav_Files4 = null;
|
||
// }
|
||
//});
|
||
|
||
entity.Nav_Item3.ForEach(t =>
|
||
{
|
||
if (t.Nav_Files != null && t.Nav_Files.Count() > 0)
|
||
{
|
||
file3.AddRange(t.Nav_Files);
|
||
t.Nav_Files = null;
|
||
}
|
||
});
|
||
entity.Nav_Item4.ForEach(t =>
|
||
{
|
||
if (t.Nav_Files != null && t.Nav_Files.Count() > 0)
|
||
{
|
||
file4.AddRange(t.Nav_Files);
|
||
t.Nav_Files = null;
|
||
}
|
||
});
|
||
|
||
entity.Nav_Item1 = null;
|
||
entity.Nav_Item2 = null;
|
||
entity.Nav_Item3 = null;
|
||
entity.Nav_Item4 = null;
|
||
//foreach (var it2 in item2)
|
||
//{
|
||
// it2.AGE = CalculateAgeFromIDCard(it2.ID_CARD);
|
||
//}
|
||
List<T_FM_USER> iListUser = null;
|
||
|
||
string CALLBACK_INTERFACE = string.Empty;
|
||
T_PF_APPROVE approve = null;
|
||
List<T_PF_APPROVE_DETAIL> listApproveDetail = null;
|
||
List<string> listDATA_ID = new List<string>();
|
||
|
||
if (entity.PUBLISH != null && entity.PUBLISH.Equals("SaveAndNotify"))
|
||
{
|
||
if (item1.Count() == 0)
|
||
{
|
||
throw new Exception("安全生产管理协议不能为空!");
|
||
}
|
||
else
|
||
{
|
||
foreach (var item in item1)
|
||
{
|
||
if (item.END_TIME.HasValue && item.END_TIME.Value <= dtNow)
|
||
{
|
||
throw new Exception("安全生产管理协议结束时间必须大于今天!");
|
||
}
|
||
}
|
||
}
|
||
if (item2.Count() == 0)
|
||
{
|
||
throw new Exception("人员信息不能为空!");
|
||
}
|
||
|
||
if (item3 != null && item3.Any())
|
||
{
|
||
foreach (var item in item3)
|
||
{
|
||
if (item.VALID_TIME.HasValue && item.VALID_TIME.Value <= dtNow)
|
||
{
|
||
throw new Exception("资质证书有效期必须大于今天!");
|
||
}
|
||
}
|
||
}
|
||
T_WB_REGISTER_4_FILE modelFileCheck = null;
|
||
if (item4 != null && item4.Any())
|
||
{
|
||
foreach (var item in item4)
|
||
{
|
||
if (item.IS_SPECIAL_DEVICE)
|
||
{
|
||
modelFileCheck = file4.FirstOrDefault(e => e.PARENT_ID == item.ID);
|
||
if (modelFileCheck == null)
|
||
{
|
||
throw new Exception("特种设备【" + item.NAME + "】必须上传检测报告!");
|
||
}
|
||
else if (!item.DATE_LIMIT.HasValue)
|
||
{
|
||
throw new Exception("【" + item.NAME + "】报告有效期限必填!");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
//if (entity.STATUS != PFStandardStatus.Archived)//如果都是已归档数据 那么只做信息修改 比如状态启用禁用 不走流程
|
||
//{
|
||
entity.STATUS = PFStandardStatus.Approving;
|
||
#region // wyw 代码已抽离 并且此代码有bug
|
||
|
||
//foreach (var user in item2)
|
||
//{
|
||
// if (user.IS_LOGIN)
|
||
// {
|
||
// var isrepeat = GetEntity<T_FM_USER>(t => t.CODE == user.PHONE);
|
||
|
||
// if (isrepeat == null && user.IS_LOGIN)
|
||
// {
|
||
// T_FM_USER newUser = new T_FM_USER();
|
||
// T_FM_PERSON newPerson = new T_FM_PERSON();
|
||
// newPerson.ID = Guid.NewGuid();
|
||
// newPerson.CODE = user.PHONE;
|
||
// newPerson.NAME = user.NAME;
|
||
// newPerson.SEX = 0;
|
||
// newPerson.TEL = user.PHONE;
|
||
// newPerson.ORG_ID = entity.ORG_ID;
|
||
// newUser.ID = Guid.NewGuid();
|
||
// newUser.CODE = user.PHONE;
|
||
// newUser.NAME = user.NAME;
|
||
// newUser.SEX = 0;
|
||
// newUser.PHONE = user.PHONE;
|
||
// newUser.ENTRYTIME = DateTime.Now;
|
||
// newUser.PERSON_ID = newPerson.ID;
|
||
// newUser.PROJECT_ID = entity.PROJECT_ID;
|
||
// newUser.MineType = "_0_10_20_30_";
|
||
// newUser.ID_CARD = user.ID_CARD;
|
||
// var mineTypeList = newUser.MineType.Split("_");
|
||
// unit = new T_FM_USER_PRODUCTION_UNIT();
|
||
// productionUnit = new List<T_FM_USER_PRODUCTION_UNIT>();
|
||
// foreach (var mineTypeItem in mineTypeList)
|
||
// {
|
||
// if (mineTypeItem != "")
|
||
// {
|
||
// var enumList = this.GetEntity<T_FM_ENUMS>(t => t.CODE == "BSMineTypeEnum" && t.VALUE == int.Parse(mineTypeItem));
|
||
// unit.ORG_ID = entity.ORG_ID;
|
||
// unit.USER_ID = newUser.ID;
|
||
// unit.ENUMS_ID = enumList?.ID;
|
||
// unit.Nav_Enums = null;
|
||
// productionUnit.Add(unit);
|
||
// }
|
||
// }
|
||
// newUser.PASSWORD = "E10ADC3949BA59ABBE56E057F20F883E";
|
||
// newUser.ORG_ID = entity.ORG_ID;
|
||
// var role1 = this.GetEntity<T_FM_ROLE>(t => t.NAME == "APP用户");
|
||
// var role2 = this.GetEntity<T_FM_ROLE>(t => t.NAME == "作业员");
|
||
// if (role1 != null)
|
||
// {
|
||
// T_FM_USER_BELONG_ROLE belongRole1 = new T_FM_USER_BELONG_ROLE();
|
||
// belongRole1.USER_ID = newUser.ID;
|
||
// belongRole1.BELONG_ROLE_ID = role1.ID;
|
||
// belongRole1.ORG_ID = entity.ORG_ID;
|
||
// belongRole1s.Add(belongRole1);
|
||
// }
|
||
// if (role2 != null)
|
||
// {
|
||
// T_FM_USER_BELONG_ROLE belongRole2 = new T_FM_USER_BELONG_ROLE();
|
||
// belongRole2.USER_ID = newUser.ID;
|
||
// belongRole2.BELONG_ROLE_ID = role2.ID;
|
||
// belongRole2.ORG_ID = entity.ORG_ID;
|
||
// belongRole2s.Add(belongRole2);
|
||
// }
|
||
// newUsers.Add(newUser);
|
||
// newPersons.Add(newPerson);
|
||
// var Tenant = this.Request.Headers["Tenant"];
|
||
// using (var context = new MigrationContext(ConfigurationManager.ConnectionStrings["default"]))
|
||
// {
|
||
// T_OP_ALLUSER alluser = new T_OP_ALLUSER();
|
||
// alluser.CODE = user.PHONE;
|
||
// alluser.TENANT = Tenant;
|
||
// alluser.ORG_ID = entity.ORG_ID;
|
||
// alluser.PHONE = user.PHONE;
|
||
// context.AddEntity(alluser);
|
||
// context.SaveChanges();
|
||
// }
|
||
// }
|
||
// }
|
||
//}
|
||
#endregion
|
||
|
||
//sendNotice = NotificationTaskService.InsertUserNoticeTaskModel("外包单位信息登记表审批", entity.ID, entity.ORG_ID, project.USER_ID, GetEntity<T_FM_USER>(project.USER_ID).NAME, DateTime.Now, DateTime.Now.AddDays(7), 1, "WB004_SHOWPRINT");
|
||
//if (entity.TaskID != Guid.Empty)
|
||
//{
|
||
// finishNotice = NotificationTaskService.FOGetTaskFinishModel(entity.TaskID, entity.ID, "WB004_SHOWPRINT");
|
||
//}
|
||
|
||
Dictionary<int, T_FM_USER> dicApproveUser = new Dictionary<int, T_FM_USER>();
|
||
//dicApproveUser.Add(1, GetEntity<T_FM_USER>(project.USER_ID));//建设项目负责人
|
||
|
||
dicApproveUser.Add(1, GetEntity<T_FM_USER>(project.LAUNCH_USER_ID));//外包录入人
|
||
T_FM_USER fmDep = null;
|
||
if (!project.LAUNCH_DEPARTMENT_ID.HasValue)
|
||
{
|
||
throw new Exception("建设部门不能为空!");
|
||
}
|
||
else
|
||
{
|
||
var modelDep = GetEntity<T_FM_DEPARTMENT>(e => e.ID == project.LAUNCH_DEPARTMENT_ID.Value, "Nav_User");
|
||
if (modelDep != null)
|
||
{
|
||
if (modelDep.DEPARTMENT_TYPE == 10 || modelDep.DEPARTMENT_TYPE == 5)
|
||
{
|
||
fmDep = modelDep.Nav_User;
|
||
}
|
||
else if (modelDep.DEPARTMENT_TYPE == 15)
|
||
{
|
||
if (modelDep.PARENT_ID.HasValue)
|
||
{
|
||
modelDep = GetEntity<T_FM_DEPARTMENT>(modelDep.PARENT_ID.Value, null, "Nav_User");
|
||
if (modelDep.Nav_User != null)
|
||
{
|
||
fmDep = modelDep.Nav_User;
|
||
}
|
||
}
|
||
}
|
||
else if (modelDep.DEPARTMENT_TYPE == 20)
|
||
{
|
||
modelDep = GetEntity<T_FM_DEPARTMENT>(modelDep.PARENT_ID.Value, null, "Nav_Parent.Nav_User");
|
||
if (modelDep.Nav_Parent != null && modelDep.Nav_Parent.Nav_User != null)
|
||
{
|
||
fmDep = modelDep.Nav_Parent.Nav_User;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
throw new Exception("获取建设部门信息失败!");
|
||
}
|
||
if (fmDep != null)
|
||
{
|
||
dicApproveUser.Add(2, fmDep);//建设部门负责人
|
||
}
|
||
}
|
||
|
||
string Msg = "";
|
||
approve = MFlowPermitService.GetApproveInfo("WB004", null, entity.ID, "WB004_SHOWPRINT", entity.TaskID, "WB004_SHOWPRINT", null, dicApproveUser, null, "", ref Msg, ref finishNotice, ref sendNotice, ref CALLBACK_INTERFACE, ref listDATA_ID);
|
||
if (Msg != null && !string.IsNullOrEmpty(Msg))
|
||
{
|
||
throw new Exception(Msg);//如果有问题 进行提示
|
||
}
|
||
//listApproveDetail = approve.Nav_ApproveDetails;
|
||
listApproveDetail = approve.Nav_ApproveDetails.Where(e => e.APPROVE_USER_ID.HasValue && e.APPROVE_USER_ID != Guid.Empty).ToList();
|
||
approve.Nav_ApproveDetails = null;
|
||
//}
|
||
|
||
//启用、禁用
|
||
if (entity.ENABLE_STATUS == FMEnableStatusEnum.禁用)
|
||
{
|
||
iListUser = GetEntities<T_FM_USER>(e => e.PROJECT_ID.HasValue && e.PROJECT_ID == entity.PROJECT_ID && e.ENABLE_STATUS == 0, null, null).ToList();
|
||
foreach (var item in iListUser)
|
||
{
|
||
item.ENABLE_STATUS = 1;//账号禁用
|
||
}
|
||
}
|
||
else
|
||
{
|
||
var iListUserALL = GetEntities<T_FM_USER>(e => e.PROJECT_ID.HasValue && e.PROJECT_ID == entity.PROJECT_ID, null, null);
|
||
var iListUser0 = iListUserALL.Where(e => e.ENABLE_STATUS == 0);
|
||
if (iListUser0 == null || !iListUser0.Any())
|
||
{
|
||
iListUser = new List<T_FM_USER>();
|
||
//签约 但是没有一个可用账号 //全部可用
|
||
foreach (var item in iListUser)
|
||
{
|
||
item.ENABLE_STATUS = 0;//账号启用
|
||
iListUser.Add(item);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
UnifiedCommit(() =>
|
||
{
|
||
UpdateEntityNoCommit(entity);
|
||
if (item1 != null && item1.Any())
|
||
BantchSaveEntityNoCommit(item1);
|
||
if (item2 != null && item2.Any())
|
||
BantchSaveEntityNoCommit(item2);
|
||
if (item3 != null && item3.Any())
|
||
BantchSaveEntityNoCommit(item3);
|
||
if (item4 != null && item4.Any())
|
||
BantchSaveEntityNoCommit(item4);
|
||
if (file1 != null && file1.Any())
|
||
BantchSaveEntityNoCommit(file1);
|
||
//if (file21 != null && file21.Any())
|
||
// BantchSaveEntityNoCommit(file21);
|
||
//if (file22 != null && file22.Any())
|
||
// BantchSaveEntityNoCommit(file22);
|
||
//if (file23 != null && file23.Any())
|
||
// BantchSaveEntityNoCommit(file23);
|
||
//if (file24 != null && file24.Any())
|
||
// BantchSaveEntityNoCommit(file24);
|
||
if (file3 != null && file3.Any())
|
||
BantchSaveEntityNoCommit(file3);
|
||
if (file4 != null && file4.Any())
|
||
BantchSaveEntityNoCommit(file4);
|
||
//if (newUsers != null && newUsers.Any())
|
||
// BantchSaveEntityNoCommit(newUsers);
|
||
//if (newPersons != null && newPersons.Any())
|
||
// BantchSaveEntityNoCommit(newPersons);
|
||
//if (belongRole1s != null && belongRole1s.Any())
|
||
// BantchSaveEntityNoCommit(belongRole1s);
|
||
//if (belongRole2s != null && belongRole2s.Any())
|
||
// BantchSaveEntityNoCommit(belongRole2s);
|
||
if (sendNotice != null)
|
||
AddEntityNoCommit(sendNotice);
|
||
if (finishNotice != null)
|
||
UpdateEntityNoCommit(finishNotice);
|
||
if (iListUser != null && iListUser.Any())
|
||
BantchSaveEntityNoCommit(iListUser);
|
||
|
||
if (approve != null)
|
||
UpdateEntityNoCommit(approve);
|
||
if (listApproveDetail != null && listApproveDetail.Any())
|
||
BantchSaveEntityNoCommit(listApproveDetail);
|
||
});
|
||
//执行信息
|
||
if (!string.IsNullOrEmpty(CALLBACK_INTERFACE))
|
||
{
|
||
if (CALLBACK_INTERFACE.EndsWith("New"))
|
||
{
|
||
this.UnifiedCommit(() =>
|
||
{
|
||
ApproveCallBackService.CallBackNew(CALLBACK_INTERFACE, approve, false);
|
||
});
|
||
}
|
||
else
|
||
{
|
||
this.UnifiedCommit(() =>
|
||
{
|
||
ApproveCallBackService.CallBack(CALLBACK_INTERFACE, listDATA_ID);
|
||
});
|
||
}
|
||
}
|
||
return true;
|
||
});
|
||
}
|
||
/// <summary>
|
||
/// 审核通过
|
||
/// </summary>
|
||
/// <param name="entity"></param>
|
||
/// <returns></returns>
|
||
[HttpPost, Route("UserAgree")]
|
||
public JsonActionResult<bool> UserAgree([FromBody] T_WB_REGISTER entity)
|
||
{
|
||
return SafeExecute<bool>(() =>
|
||
{
|
||
var register = GetEntity<T_WB_REGISTER>(t => t.ID == entity.ID);
|
||
var project = GetEntity<T_WB_PROJECT_INPUT>(t => t.ID == register.PROJECT_ID);
|
||
|
||
register.STATUS = PFStandardStatus.Archived;
|
||
var finishTask = NotificationTaskService.FOGetTaskFinishModel(entity.TaskID, entity.ID);
|
||
T_WB_TRAIN_SELECT select = new T_WB_TRAIN_SELECT();
|
||
select.ID = Guid.NewGuid();
|
||
select.ORG_ID = entity.ORG_ID;
|
||
select.PROJECT_ID = register.PROJECT_ID;
|
||
|
||
//人员信息修改都要走审批流 //如果有人没有分数 进行入场培训
|
||
var modelCheck = GetEntity<T_WB_REGISTER_2>(e => e.SCORE == 0 && e.PARENT_ID == entity.ID);
|
||
T_FM_NOTIFICATION_TASK sendNotice = null;
|
||
if (modelCheck != null && modelCheck.ID != Guid.Empty)
|
||
{
|
||
var taskCheck = GetEntity<T_FM_NOTIFICATION_TASK>(e => e.USER_ID == project.SCENE_USER_ID && e.NOTICE_STATUS == 0 && e.SOURCE_FORMCODE == "WB006");
|
||
if (taskCheck == null || taskCheck.ID == Guid.Empty)
|
||
{
|
||
sendNotice = NotificationTaskService.InsertUserNoticeTaskModel(project.UNIT_NAME + "-入厂安全培训指派", select.ID, entity.ORG_ID, project.SCENE_USER_ID, GetEntity<T_FM_USER>(project.SCENE_USER_ID).NAME, DateTime.Now, DateTime.Now.AddDays(7), 1, "WB006");
|
||
}
|
||
}
|
||
|
||
UnifiedCommit(() =>
|
||
{
|
||
if (register != null)
|
||
UpdateEntityNoCommit(register);
|
||
if (sendNotice != null)
|
||
AddEntityNoCommit(sendNotice);
|
||
if (select != null)
|
||
AddEntityNoCommit(select);
|
||
});
|
||
return true;
|
||
});
|
||
}
|
||
///// <summary>
|
||
///// 签到 已经被修改
|
||
///// </summary>
|
||
///// <param name="pageFilter"></param>
|
||
///// <returns></returns>
|
||
//[HttpPost, Route("UserDisAgree")]
|
||
//public JsonActionResult<bool> UserDisAgree([FromBody] T_WB_REGISTER entity)
|
||
//{
|
||
// return SafeExecute<bool>(() =>
|
||
// {
|
||
// var register = GetEntity<T_WB_REGISTER>(t => t.ID == entity.ID);
|
||
// var project = GetEntity<T_WB_PROJECT_INPUT>(t => t.ID == register.PROJECT_ID);
|
||
// var finishTask = NotificationTaskService.FOGetTaskFinishModel(entity.TaskID, entity.ID);
|
||
// var user = GetEntity<T_FM_USER>(t => t.CODE == project.WB_USER_CODE);
|
||
// register.STATUS = PFStandardStatus.Rejected;
|
||
// var sendNotice = NotificationTaskService.InsertUserNoticeTaskModel("外包单位信息登记表-驳回", entity.ID, entity.ORG_ID, user.ID, user.NAME, DateTime.Now, DateTime.Now.AddDays(7), 1, "WB004");
|
||
|
||
|
||
// UnifiedCommit(() =>
|
||
// {
|
||
// if (register != null)
|
||
// UpdateEntityNoCommit(register);
|
||
// if (sendNotice != null)
|
||
// AddEntityNoCommit(sendNotice);
|
||
// if (finishTask != null)
|
||
// UpdateEntityNoCommit(finishTask);
|
||
// });
|
||
// return true;
|
||
// });
|
||
//}
|
||
|
||
public static int CalculateAgeFromIDCard(string idCard)
|
||
{
|
||
// 验证身份证号码长度是否正确
|
||
if (idCard.Length != 18)
|
||
{
|
||
throw new ArgumentException("身份证号码必须是18位", nameof(idCard));
|
||
}
|
||
|
||
// 提取出生年月日
|
||
string birthDateStr = idCard.Substring(6, 8);
|
||
DateTime birthDate;
|
||
if (!DateTime.TryParseExact(birthDateStr, "yyyyMMdd", null, System.Globalization.DateTimeStyles.None, out birthDate))
|
||
{
|
||
throw new ArgumentException("身份证号码中的日期无效", nameof(idCard));
|
||
}
|
||
|
||
// 获取当前日期
|
||
DateTime today = DateTime.Now;
|
||
|
||
// 计算年龄
|
||
int age = today.Year - birthDate.Year;
|
||
if (today.Month < birthDate.Month || (today.Month == birthDate.Month && today.Day < birthDate.Day))
|
||
{
|
||
age--;
|
||
}
|
||
|
||
return age;
|
||
}
|
||
|
||
|
||
|
||
|
||
#region wyw
|
||
|
||
|
||
/// <summary>
|
||
/// 审核通过
|
||
/// </summary>
|
||
/// <param name="entity"></param>
|
||
/// <returns></returns>
|
||
[HttpPost, Route("UserAgreeNew")]
|
||
public JsonActionResult<bool> UserAgreeNew([FromBody] T_PF_APPROVE entity)
|
||
{
|
||
return SafeExecute<bool>(() =>
|
||
{
|
||
return ApproveCallBackService.CallBackNew("WB/WBRegister/UserAgreeNew", entity);
|
||
});
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 获得单条实体数据
|
||
/// </summary>
|
||
/// <param name="filter">过滤实体</param>
|
||
/// <returns></returns>
|
||
[HttpPost, Route("GetRegister2")]
|
||
public JsonActionResult<T_WB_REGISTER_2> GetRegister2([FromBody] KeywordFilter filter)
|
||
{
|
||
return SafeExecute(() =>
|
||
{
|
||
var user2 = GetEntity<T_WB_REGISTER_2>(null, filter, null);
|
||
if (user2 != null)
|
||
{
|
||
var reg = GetEntity<T_WB_REGISTER>(e => e.ID == user2.PARENT_ID);
|
||
if (reg != null)
|
||
{
|
||
user2.PROJECT_ID = reg.PROJECT_ID;
|
||
}
|
||
//var user = GetEntity<T_FM_USER>(e => e.CODE == user2.PHONE && e.PROJECT_ID.HasValue && !e.IS_DELETED);
|
||
//if (user != null)
|
||
//{
|
||
// user2.PROJECT_ID = user.PROJECT_ID;
|
||
//}
|
||
}
|
||
return user2;
|
||
});
|
||
}
|
||
|
||
/// <summary>
|
||
/// 外包单位信息录入 - 人员信息 (参考此页面 FullUpdate)
|
||
/// </summary>
|
||
/// <param name="entity">对象实体</param>
|
||
/// <returns></returns>
|
||
[HttpPost, Route("FullUpdateUser")]
|
||
public JsonActionResult<bool> Update([FromBody] T_WB_REGISTER_2 entity)
|
||
{
|
||
return SafeExecute(() =>
|
||
{
|
||
if (entity.IS_LOGIN)
|
||
{
|
||
if (string.IsNullOrEmpty(entity.PHONE))
|
||
throw new Exception("需要登录的用户,手机号码必填!");
|
||
}
|
||
if (entity.PARENT_ID == Guid.Empty)
|
||
{
|
||
if (entity.TaskID != Guid.Empty && APT.Infrastructure.Api.AppContext.CurrentSession.UserID.HasValue)
|
||
{
|
||
var taskAdd = GetEntity<T_FM_NOTIFICATION_TASK>(e => e.USER_ID == APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value && e.SOURCE_FORMCODE == "WB004" && e.NOTICE_STATUS == 0);
|
||
if (taskAdd != null && taskAdd.SOURCE_DATA_ID.HasValue)
|
||
{
|
||
entity.PARENT_ID = taskAdd.SOURCE_DATA_ID.Value;
|
||
}
|
||
}
|
||
if (entity.PARENT_ID == Guid.Empty)
|
||
throw new Exception("获取信息失败,请先关闭页面后重新添加此用户信息!");
|
||
}
|
||
T_FM_USER_PRODUCTION_UNIT unit = null;
|
||
List<T_FM_USER_PRODUCTION_UNIT> productionUnit = new List<T_FM_USER_PRODUCTION_UNIT>();
|
||
List<T_FM_USER_BELONG_ROLE> belongRoles = new List<T_FM_USER_BELONG_ROLE>();
|
||
T_FM_USER newUser = null;
|
||
T_FM_USER UserEnable = null;//登录变成不可登录
|
||
T_FM_PERSON newPerson = null;
|
||
if (!string.IsNullOrEmpty(entity.ID_CARD))
|
||
{
|
||
entity.AGE = CalculateAgeFromIDCard(entity.ID_CARD);
|
||
}
|
||
bool isAddAll = true;
|
||
|
||
if (entity.IS_LOGIN)
|
||
{
|
||
if (entity.WORKTYPE.HasValue)
|
||
{
|
||
var workTypeCheck = GetEntity<T_WB_REGISTER_2>(e => e.PARENT_ID == entity.PARENT_ID && e.IS_LOGIN && e.WORKTYPE.HasValue && e.WORKTYPE.Value == entity.WORKTYPE.Value && !e.IS_DELETED && e.ID != entity.ID);
|
||
if (workTypeCheck != null)
|
||
{
|
||
throw new Exception("每个单位该工种只能添加一位可登录人员,审批根据工种找审批人!");
|
||
}
|
||
}
|
||
if (!entity.PROJECT_ID.HasValue)
|
||
{
|
||
throw new Exception("获取传参失败,请关闭页面后重试!");
|
||
}
|
||
|
||
//var isrepeat = GetEntity<T_FM_USER>(t => t.CODE == entity.PHONE && t.PROJECT_ID.HasValue && t.PROJECT_ID.Value == entity.PROJECT_ID.Value && !t.IS_DELETED);
|
||
Expression<Func<T_FM_USER, bool>> expression = t => t.CODE == entity.PHONE && t.PROJECT_ID.HasValue && t.PROJECT_ID.Value == entity.PROJECT_ID.Value && !t.IS_DELETED;
|
||
if (entity.USERID.HasValue)
|
||
{
|
||
expression = t => t.ID == entity.USERID.Value;
|
||
}
|
||
|
||
var iListsrepeat = GetEntities(expression, null, null);
|
||
if (iListsrepeat != null && iListsrepeat.Count() > 0)
|
||
{
|
||
//有对应手机号码信息 要么重复 要么修改
|
||
//if (isrepeat != null && isrepeat.ID != entity.ID && isrepeat.ENABLE_STATUS == 0 && !isrepeat.IS_DELETED)
|
||
// throw new Exception("该手机号码已注册!");
|
||
var list = iListsrepeat.ToList();
|
||
if (list.Count() > 1 || list[0].NAME != entity.NAME)
|
||
{
|
||
throw new Exception("该手机号码已注册!");
|
||
}
|
||
else
|
||
{
|
||
isAddAll = false;
|
||
//信息修改
|
||
newUser = list[0];
|
||
newPerson = GetEntity<T_FM_PERSON>(newUser.PERSON_ID.Value);
|
||
|
||
newPerson.NAME = entity.NAME;
|
||
newPerson.TEL = entity.PHONE;
|
||
if (entity.SEX.HasValue)
|
||
{
|
||
newPerson.SEX = (int)entity.SEX.Value;//FMSexEnum FMSexEnum
|
||
}
|
||
else
|
||
{
|
||
newPerson.SEX = 1;
|
||
}
|
||
|
||
newUser.NAME = entity.NAME;
|
||
newUser.SEX = newPerson.SEX;
|
||
newUser.PHONE = entity.PHONE;
|
||
newUser.ENTRYTIME = DateTime.Now;
|
||
newUser.PROJECT_ID = entity.PROJECT_ID;
|
||
newUser.ID_CARD = entity.ID_CARD;
|
||
newUser.ENABLE_STATUS = (int)entity.ENABLE_STATUS;//登录
|
||
|
||
//if (entity.ENABLE_STATUS == FMEnableStatusEnum.禁用)
|
||
//{
|
||
// newUser.ENABLE_STATUS = (int)entity.ENABLE_STATUS;
|
||
//}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//没有对应手机号码信息
|
||
if (entity.IS_LOGIN)
|
||
{
|
||
newUser = new T_FM_USER();
|
||
newPerson = new T_FM_PERSON();
|
||
newPerson.ID = Guid.NewGuid();
|
||
newPerson.ORG_ID = entity.ORG_ID;
|
||
newPerson.CODE = entity.PHONE;
|
||
newPerson.NAME = entity.NAME;
|
||
|
||
newUser.ID = Guid.NewGuid();
|
||
newUser.ORG_ID = entity.ORG_ID;
|
||
newUser.CODE = entity.PHONE;
|
||
newUser.NAME = entity.NAME;
|
||
|
||
|
||
if (entity.SEX.HasValue)
|
||
{
|
||
newPerson.SEX = (int)entity.SEX.Value;//FMSexEnum FMSexEnum
|
||
}
|
||
else
|
||
{
|
||
newPerson.SEX = 1;
|
||
}
|
||
|
||
newPerson.TEL = entity.PHONE;
|
||
|
||
newUser.SEX = newPerson.SEX;
|
||
newUser.PHONE = entity.PHONE;
|
||
newUser.ENTRYTIME = DateTime.Now;
|
||
newUser.PERSON_ID = newPerson.ID;
|
||
newUser.PROJECT_ID = entity.PROJECT_ID;
|
||
newUser.MineType = "_0_10_20_30_";
|
||
newUser.ID_CARD = entity.ID_CARD;
|
||
|
||
|
||
var mineTypeList = newUser.MineType.Split("_", StringSplitOptions.RemoveEmptyEntries);
|
||
unit = new T_FM_USER_PRODUCTION_UNIT();
|
||
foreach (var mineTypeItem in mineTypeList)
|
||
{
|
||
var enumList = this.GetEntity<T_FM_ENUMS>(t => t.CODE == "BSMineTypeEnum" && t.VALUE == int.Parse(mineTypeItem));
|
||
unit.ORG_ID = entity.ORG_ID;
|
||
unit.USER_ID = newUser.ID;
|
||
unit.ENUMS_ID = enumList?.ID;
|
||
unit.Nav_Enums = null;
|
||
productionUnit.Add(unit);
|
||
}
|
||
newUser.PASSWORD = "E10ADC3949BA59ABBE56E057F20F883E";
|
||
var role1 = this.GetEntity<T_FM_ROLE>(t => t.NAME == "外包App用户");
|
||
var role2 = this.GetEntity<T_FM_ROLE>(t => t.NAME == "外包作业员");
|
||
if (role1 != null)
|
||
{
|
||
T_FM_USER_BELONG_ROLE belongRole1 = new T_FM_USER_BELONG_ROLE();
|
||
belongRole1.USER_ID = newUser.ID;
|
||
belongRole1.BELONG_ROLE_ID = role1.ID;
|
||
belongRole1.ORG_ID = entity.ORG_ID;
|
||
belongRoles.Add(belongRole1);
|
||
}
|
||
if (role2 != null)
|
||
{
|
||
T_FM_USER_BELONG_ROLE belongRole2 = new T_FM_USER_BELONG_ROLE();
|
||
belongRole2.USER_ID = newUser.ID;
|
||
belongRole2.BELONG_ROLE_ID = role2.ID;
|
||
belongRole2.ORG_ID = entity.ORG_ID;
|
||
belongRoles.Add(belongRole2);
|
||
}
|
||
}
|
||
}
|
||
|
||
//人员部门信息赋值
|
||
if (newUser != null && !newUser.DEPARTMENT_ID.HasValue && entity.PROJECT_ID.HasValue)
|
||
{
|
||
var proj = GetEntity<T_WB_PROJECT_INPUT>(entity.PROJECT_ID.Value, null);
|
||
if (proj.DEPARTMENT_ID.HasValue)
|
||
{
|
||
newUser.DEPARTMENT_ID = proj.DEPARTMENT_ID.Value;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//如果不登录了
|
||
//T_WB_REGISTER_2//entity.USERID
|
||
if (entity.USERID.HasValue)
|
||
{
|
||
var listCheckReg = GetEntities<T_WB_REGISTER_2>(e => e.ID != entity.ID && e.USERID.HasValue && e.USERID.Value == entity.USERID.Value && e.IS_LOGIN, null, null);
|
||
if (listCheckReg == null || !listCheckReg.Any() || listCheckReg.Count() < 1)
|
||
{
|
||
UserEnable = GetEntity<T_FM_USER>(e => e.ID == entity.USERID.Value && e.ENABLE_STATUS == 0);
|
||
if (UserEnable != null)
|
||
{
|
||
UserEnable.ENABLE_STATUS = 1;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
var files1 = entity.Nav_Files1;
|
||
var files2 = entity.Nav_Files2;
|
||
var files3 = entity.Nav_Files3;
|
||
var files4 = entity.Nav_Files4;
|
||
var JobTypes = entity.Nav_JobTypes;
|
||
entity.Nav_Files1 = null;
|
||
entity.Nav_Files2 = null;
|
||
entity.Nav_Files3 = null;
|
||
entity.Nav_Files4 = null;
|
||
entity.Nav_JobTypes = null;
|
||
|
||
#region 后台配置了 但是接收时 可能 为空 重新赋值
|
||
|
||
if (files1 != null && files1.Any())
|
||
{
|
||
foreach (var item in files1)
|
||
{
|
||
if (item.PARENT_ID == Guid.Empty)
|
||
item.PARENT_ID = entity.ID;
|
||
}
|
||
}
|
||
if (files2 != null && files2.Any())
|
||
{
|
||
foreach (var item in files2)
|
||
{
|
||
if (item.PARENT_ID == Guid.Empty)
|
||
item.PARENT_ID = entity.ID;
|
||
}
|
||
}
|
||
if (files3 != null && files3.Any())
|
||
{
|
||
foreach (var item in files3)
|
||
{
|
||
if (item.PARENT_ID == Guid.Empty)
|
||
item.PARENT_ID = entity.ID;
|
||
}
|
||
}
|
||
if (files4 != null && files4.Any())
|
||
{
|
||
foreach (var item in files4)
|
||
{
|
||
if (item.PARENT_ID == Guid.Empty)
|
||
item.PARENT_ID = entity.ID;
|
||
}
|
||
}
|
||
|
||
if (JobTypes != null && JobTypes.Any())
|
||
{
|
||
foreach (var item in JobTypes)
|
||
{
|
||
item.Nav_JobType = null;
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
if (newUser != null && newUser.ID != Guid.Empty && entity.USERID == null)
|
||
{
|
||
entity.USERID = newUser.ID;
|
||
}
|
||
|
||
|
||
#region 人员信息变动 判断如果有人没有分数 外包单位现场安全员 如果没有 审批待办 给触发审批
|
||
|
||
#endregion
|
||
|
||
UnifiedCommit(() =>
|
||
{
|
||
if (newPerson != null)
|
||
UpdateEntity(newPerson);
|
||
if (newUser != null)
|
||
UpdateEntity(newUser);
|
||
if (UserEnable != null)
|
||
UpdateEntity(UserEnable);
|
||
if (belongRoles != null && belongRoles.Any())
|
||
BantchSaveEntityNoCommit(belongRoles);
|
||
if (productionUnit != null && productionUnit.Any())
|
||
BantchSaveEntityNoCommit(productionUnit);
|
||
|
||
UpdateEntity(entity);
|
||
if (files1 != null && files1.Any())
|
||
BantchSaveEntityNoCommit(files1);
|
||
if (files2 != null && files2.Any())
|
||
BantchSaveEntityNoCommit(files2);
|
||
if (files3 != null && files3.Any())
|
||
BantchSaveEntityNoCommit(files3);
|
||
if (files4 != null && files4.Any())
|
||
BantchSaveEntityNoCommit(files4);
|
||
if (JobTypes != null && JobTypes.Any())
|
||
BantchSaveEntityNoCommit(JobTypes);
|
||
});
|
||
|
||
//操作完成后入主库
|
||
if (entity.IS_LOGIN && isAddAll)
|
||
{
|
||
var Tenant = this.Request.Headers["Tenant"];
|
||
using (var context = new MigrationContext(ConfigurationManager.ConnectionStrings["default"]))
|
||
{
|
||
T_OP_ALLUSER alluser = new T_OP_ALLUSER();
|
||
alluser.CODE = entity.PHONE;
|
||
alluser.TENANT = Tenant;
|
||
alluser.ORG_ID = entity.ORG_ID;
|
||
alluser.PHONE = entity.PHONE;
|
||
context.AddEntity(alluser);
|
||
context.SaveChanges();
|
||
}
|
||
}
|
||
|
||
return true;
|
||
});
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 驳回
|
||
/// </summary>
|
||
/// <param name="model"></param>
|
||
/// <returns></returns>
|
||
[HttpPost, Route("UserDisAgree")]
|
||
public JsonActionResult<bool> RejectUpdate([FromBody] T_PF_APPROVE model)
|
||
{
|
||
return SafeExecute(() =>
|
||
{
|
||
//公共 获取审批流信息
|
||
T_PF_APPROVE modelApp = null;
|
||
List<T_PF_APPROVE_DETAIL> listAppDetail = null;
|
||
T_FM_NOTIFICATION_TASK taskFinish = null;
|
||
string Msg = string.Empty;
|
||
bool ResultGetInfo = ApproveCallBackService.GetApproject(model, ref modelApp, ref listAppDetail, ref taskFinish, ref Msg);
|
||
if (!ResultGetInfo)
|
||
throw new Exception("驳回失败!");
|
||
if (modelApp == null || listAppDetail == null)
|
||
throw new Exception("获取驳回信息失败!");
|
||
|
||
//var entity = this.GetEntity<T_SK_SECURITY_INSPECTION_NOTICE>(model.DATA_ID, new string[] { "Nav_ApplyUser" });
|
||
//entity.STATUS = PFStandardStatus.Rejected;
|
||
// T_FM_NOTIFICATION_TASK notice = new T_FM_NOTIFICATION_TASK();
|
||
// if (entity.APPLY_USER_ID != null)
|
||
// {
|
||
// //发消息
|
||
// notice = NotificationTaskService.InsertUserNoticeTaskModel("安全检查通知表被驳回", entity.ID, entity.ORG_ID, (Guid)entity.APPLY_USER_ID, entity.Nav_ApplyUser?.NAME, DateTime.Now,
|
||
//DateTime.Now.AddHours(24), (int)FMNoticeTypeEnum.消息, "SK006");
|
||
// }
|
||
|
||
var register = GetEntity<T_WB_REGISTER>(t => t.ID == model.DATA_ID);
|
||
var project = GetEntity<T_WB_PROJECT_INPUT>(t => t.ID == register.PROJECT_ID);
|
||
//var finishTask = NotificationTaskService.FOGetTaskFinishModel(model.TaskID, model.ID);
|
||
var user = GetEntity<T_FM_USER>(t => t.CODE == project.WB_USER_CODE);
|
||
register.STATUS = PFStandardStatus.Rejected;
|
||
var sendNotice = NotificationTaskService.InsertUserNoticeTaskModel("外包单位信息登记表-驳回", register.ID, register.ORG_ID, user.ID, user.NAME, DateTime.Now, DateTime.Now.AddDays(7), 1, "WB004");
|
||
|
||
UnifiedCommit(() =>
|
||
{
|
||
if (register != null)
|
||
UpdateEntityNoCommit(register);
|
||
if (sendNotice != null)
|
||
AddEntityNoCommit(sendNotice);
|
||
|
||
if (modelApp != null)
|
||
UpdateEntityNoCommit(modelApp);
|
||
if (listAppDetail != null && listAppDetail.Count > 0)
|
||
BantchUpdateEntityNoCommit(listAppDetail);
|
||
if (taskFinish != null)
|
||
UpdateEntityNoCommit(taskFinish);
|
||
});
|
||
return true;
|
||
});
|
||
}
|
||
|
||
/// <summary>
|
||
/// 新增外包人员 获取对应人员信息
|
||
/// </summary>
|
||
/// <param name="filter"></param>
|
||
/// <returns></returns>
|
||
[HttpPost, Route("GetRegisterAdd")]
|
||
public JsonActionResult<T_WB_REGISTER_2> GetRegisterAdd([FromBody] KeywordFilter filter)
|
||
{
|
||
return SafeExecute(() =>
|
||
{
|
||
var result = GetEntity<T_WB_REGISTER_2>(null, filter, null);
|
||
if (result == null || result.ID == Guid.Empty)
|
||
{
|
||
string Phone = "";
|
||
if (filter.FilterGroup.Rules != null && filter.FilterGroup.Rules.Any())
|
||
{
|
||
foreach (var item in filter.FilterGroup.Rules)
|
||
{
|
||
if (item.Field == "PHONE")
|
||
{
|
||
Phone = item.Value.ToString();
|
||
}
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(Phone))
|
||
{
|
||
var users = GetEntities<T_FM_USER>(e => e.PHONE == Phone, null, null);
|
||
if (users != null && users.Any() && users.Count() > 0)
|
||
{
|
||
T_FM_USER modelU = users.ToList()[0];
|
||
result = new T_WB_REGISTER_2()
|
||
{
|
||
ID = modelU.ID,//去前端判断是否现有人员
|
||
ORG_ID = modelU.ORG_ID,
|
||
NAME = modelU.NAME,
|
||
PHONE = modelU.PHONE,
|
||
ID_CARD = modelU.ID_CARD,
|
||
SEX = (FMSexEnum)modelU.SEX,
|
||
USERID = modelU.ID,
|
||
CREATE_TIME = DateTime.Now,
|
||
CREATER_ID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID,
|
||
|
||
};
|
||
}
|
||
}
|
||
}
|
||
return result;
|
||
});
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 获得单条实体数据
|
||
/// </summary>
|
||
/// <param name="filter">过滤实体</param>
|
||
/// <returns></returns>
|
||
[HttpPost, Route("Get")]
|
||
public JsonActionResult<T_WB_REGISTER> Get([FromBody] KeywordFilter filter)
|
||
{
|
||
return SafeExecute<T_WB_REGISTER>(() =>
|
||
{
|
||
var result = GetEntity<T_WB_REGISTER>(null, filter, null);
|
||
if (result.Nav_Item2 != null && result.Nav_Item2.Any())
|
||
{
|
||
foreach (var item in result.Nav_Item2)
|
||
{
|
||
item.PROJECT_ID = result.PROJECT_ID;
|
||
}
|
||
}
|
||
return result;
|
||
});
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新或新增数据
|
||
/// </summary>
|
||
/// <param name="entity">对象实体</param>
|
||
/// <returns></returns>
|
||
[HttpPost, Route("FullUpdate1")]
|
||
public JsonActionResult<bool> FullUpdate1([FromBody] T_WB_REGISTER_1 entity)
|
||
{
|
||
return SafeExecute(() =>
|
||
{
|
||
var files = entity.Nav_Files;
|
||
entity.Nav_Files = null;
|
||
|
||
if (entity.END_TIME.HasValue && entity.END_TIME.Value.Date < DateTime.Now.Date)
|
||
throw new Exception("协议结束时间不能小于当前日期!");
|
||
|
||
if (files != null && files.Any() && files.Count() > 0)
|
||
foreach (var item in files)
|
||
item.Nav_ImgFile = null;
|
||
UnifiedCommit(() =>
|
||
{
|
||
UpdateEntityNoCommit(entity);
|
||
if (files != null && files.Any())
|
||
BantchSaveEntityNoCommit(files);
|
||
});
|
||
return true;
|
||
});
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新或新增数据
|
||
/// </summary>
|
||
/// <param name="entity">对象实体</param>
|
||
/// <returns></returns>
|
||
[HttpPost, Route("FullUpdate3")]
|
||
public JsonActionResult<bool> FullUpdate3([FromBody] T_WB_REGISTER_3 entity)
|
||
{
|
||
return SafeExecute(() =>
|
||
{
|
||
var files = entity.Nav_Files;
|
||
entity.Nav_Files = null;
|
||
if (entity.VALID_TIME.HasValue && entity.VALID_TIME.Value.Date < DateTime.Now.Date)
|
||
throw new Exception("证书有效期不能小于当前日期!");
|
||
|
||
entity.Nav_Level = null;
|
||
if (files != null && files.Any() && files.Count() > 0)
|
||
foreach (var item in files)
|
||
item.Nav_ImgFile = null;
|
||
UnifiedCommit(() =>
|
||
{
|
||
UpdateEntityNoCommit(entity);
|
||
if (files != null && files.Any())
|
||
BantchSaveEntityNoCommit(files);
|
||
});
|
||
return true;
|
||
});
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新或新增数据
|
||
/// </summary>
|
||
/// <param name="entity">对象实体</param>
|
||
/// <returns></returns>
|
||
[HttpPost, Route("FullUpdate4")]
|
||
public JsonActionResult<bool> FullUpdate4([FromBody] T_WB_REGISTER_4 entity)
|
||
{
|
||
return SafeExecute(() =>
|
||
{
|
||
var files = entity.Nav_Files;
|
||
entity.Nav_Files = null;
|
||
if (entity.DATE_LIMIT.HasValue && entity.DATE_LIMIT.Value.Date < DateTime.Now.Date)
|
||
throw new Exception("报告有效期不能小于当前日期!");
|
||
|
||
if (entity.IS_SPECIAL_DEVICE && (files == null || !files.Any() || files.Count() < 1))
|
||
throw new Exception("特种设备必须上传检测报告!");
|
||
|
||
if (files != null && files.Any() && files.Count() > 0)
|
||
foreach (var item in files)
|
||
item.Nav_ImgFile = null;
|
||
UnifiedCommit(() =>
|
||
{
|
||
UpdateEntityNoCommit(entity);
|
||
if (files != null && files.Any())
|
||
BantchSaveEntityNoCommit(files);
|
||
});
|
||
return true;
|
||
});
|
||
}
|
||
|
||
#endregion
|
||
|
||
}
|
||
}
|