1193 lines
46 KiB
C#
1193 lines
46 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
using System.Web.UI.WebControls;
|
||
|
||
namespace BLL
|
||
{
|
||
/// <summary>
|
||
/// 特种设备检查主表
|
||
/// </summary>
|
||
public class Special_EquipmentCheckService
|
||
{
|
||
public static Model.SUBQHSEDB db = Funs.DB;
|
||
/// <summary>
|
||
/// 根据主键检查单
|
||
/// </summary>
|
||
/// <param name="incentiveNoticeId"></param>
|
||
public static void DeleteById(string Special_EquipmentCheckId)
|
||
{
|
||
Model.SUBQHSEDB db = Funs.DB;
|
||
Model.Special_EquipmentCheck seModel = db.Special_EquipmentCheck.FirstOrDefault(e => e.Special_EquipmentCheckId == Special_EquipmentCheckId);
|
||
if (seModel != null)
|
||
{
|
||
//删除子表
|
||
var EquipmentCheck_CList = Funs.DB.EquipmentCheck_C.Where(x => x.Special_EquipmentCheckId == Special_EquipmentCheckId).ToList();
|
||
if (EquipmentCheck_CList.Count > 0)
|
||
{
|
||
Funs.DB.EquipmentCheck_C.DeleteAllOnSubmit(EquipmentCheck_CList);
|
||
Funs.DB.SubmitChanges();
|
||
}
|
||
|
||
//删除审核表
|
||
var getFlow = db.Special_EquipmentCheckApprove.Where(x => x.CheckControlCode == Special_EquipmentCheckId);
|
||
if (getFlow.Count() > 0)
|
||
{
|
||
db.Special_EquipmentCheckApprove.DeleteAllOnSubmit(getFlow);
|
||
}
|
||
db.Special_EquipmentCheck.DeleteOnSubmit(seModel);
|
||
db.SubmitChanges();
|
||
}
|
||
}
|
||
|
||
#region 模型类
|
||
|
||
/// <summary>
|
||
/// 特种设备实体类
|
||
/// </summary>
|
||
public class EquipmentInItemModel
|
||
{
|
||
|
||
/// <summary>
|
||
/// 附件主键
|
||
/// </summary>
|
||
public string EquipmentInId { get; set; }
|
||
|
||
/// <summary>
|
||
/// 编号
|
||
/// </summary>
|
||
public string SizeCode { get; set; }
|
||
|
||
/// <summary>
|
||
/// 单位名称
|
||
/// </summary>
|
||
public string UnitName { get; set; }
|
||
|
||
/// <summary>
|
||
/// 设备名称
|
||
/// </summary>
|
||
public string SpecialEquipmentName { get; set; }
|
||
|
||
/// <summary>
|
||
/// 使用单位名称
|
||
/// </summary>
|
||
public string UseUnitName { get; set; }
|
||
|
||
/// <summary>
|
||
/// 规格型号
|
||
/// </summary>
|
||
public string SizeModel { get; set; }
|
||
|
||
/// <summary>
|
||
/// 生产日期
|
||
/// </summary>
|
||
public string ProDate { get; set; }
|
||
|
||
/// <summary>
|
||
/// 进场前自查自检情况
|
||
/// </summary>
|
||
public string OwnerCheck { get; set; }
|
||
|
||
/// <summary>
|
||
/// 检测状态
|
||
/// </summary>
|
||
public string DetectionStatus { get; set; }
|
||
|
||
/// <summary>
|
||
/// 检测日期
|
||
/// </summary>
|
||
public string CheckDate { get; set; }
|
||
|
||
/// <summary>
|
||
/// 检验周期
|
||
/// </summary>
|
||
public string InspectionCycle { get; set; }
|
||
|
||
/// <summary>
|
||
/// 检验有效期
|
||
/// </summary>
|
||
|
||
public string ValidityDateOfInspection { get; set; }
|
||
|
||
/// <summary>
|
||
/// 使用登记日期
|
||
/// </summary>
|
||
public string UseRegDate { get; set; }
|
||
|
||
/// <summary>
|
||
/// 使用登记部门
|
||
/// </summary>
|
||
public string UseRegDepart { get; set; }
|
||
|
||
/// <summary>
|
||
/// 进场日期
|
||
/// </summary>
|
||
public string InDate { get; set; }
|
||
|
||
/// <summary>
|
||
/// 出厂日期
|
||
/// </summary>
|
||
public string OutDate { get; set; }
|
||
|
||
/// <summary>
|
||
/// 操作手姓名
|
||
/// </summary>
|
||
public string OperatorName { get; set; }
|
||
|
||
/// <summary>
|
||
/// 特种作业证件号码
|
||
/// </summary>
|
||
public string SpecialCertificateNumber { get; set; }
|
||
|
||
/// <summary>
|
||
/// 备注
|
||
/// </summary>
|
||
public string Remark { get; set; }
|
||
|
||
public string IsUsed { get; set; }
|
||
|
||
public string Fjitem1 { get; set; }
|
||
public string Fjitem2 { get; set; }
|
||
public string Fjitem3 { get; set; }
|
||
public string Fjitem4 { get; set; }
|
||
|
||
public string ProjectId { get; set; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 审批列表实体类
|
||
/// </summary>
|
||
public class AuditItem
|
||
{
|
||
public string State { get; set; }
|
||
public string ApproveMan { get; set; }
|
||
public string ApproveDate { get; set; }
|
||
public string ApproveIdea { get; set; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 返回查询列表实体类
|
||
/// </summary>
|
||
public class Special_EquipmentCheckList
|
||
{
|
||
/// <summary>
|
||
/// 主表id
|
||
/// </summary>
|
||
public string Special_EquipmentCheckId { get; set; }
|
||
|
||
/// <summary>
|
||
/// 检查日期
|
||
/// </summary>
|
||
public string CheckDate { get; set; }
|
||
|
||
/// <summary>
|
||
/// 设备id
|
||
/// </summary>
|
||
public string EquipmentInItemId { get; set; }
|
||
|
||
/// <summary>
|
||
/// 设备名称
|
||
/// </summary>
|
||
public string EquipmentInItemName { get; set; }
|
||
|
||
/// <summary>
|
||
/// 状态
|
||
/// </summary>
|
||
public string State { get; set; }
|
||
|
||
public string StateName { get; set; }
|
||
|
||
/// <summary>
|
||
/// 状态值
|
||
/// </summary>
|
||
public string Zt { get; set; }
|
||
|
||
/// <summary>
|
||
/// 类型
|
||
/// </summary>
|
||
public string Type { get; set; }
|
||
|
||
/// <summary>
|
||
/// 添加人
|
||
/// </summary>
|
||
public string CompileMan { get; set; }
|
||
|
||
public string SizeModel { get; set; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 明细类
|
||
/// </summary>
|
||
public class ListDetail
|
||
{
|
||
/// <summary>
|
||
/// 主键
|
||
/// </summary>
|
||
public string Special_EquipmentCheckId { get; set; }
|
||
|
||
/// <summary>
|
||
/// 项目id
|
||
/// </summary>
|
||
public string ProjectId { get; set; }
|
||
|
||
/// <summary>
|
||
/// 项目名称
|
||
/// </summary>
|
||
public string ProjectName { get; set; }
|
||
|
||
/// <summary>
|
||
/// 特种设备id
|
||
/// </summary>
|
||
public string EquipmentInItemId { get; set; }
|
||
|
||
/// <summary>
|
||
/// 类型0日常检查 1定期检查 2安装前 3安装中 4使用中 5拆除中
|
||
/// </summary>
|
||
public string Type { get; set; }
|
||
|
||
/// <summary>
|
||
/// 签名
|
||
/// </summary>
|
||
public string SignatureUrl { get; set; }
|
||
|
||
/// <summary>
|
||
/// 结论
|
||
/// </summary>
|
||
public string Conclusion { get; set; }
|
||
|
||
/// <summary>
|
||
/// 检查日期
|
||
/// </summary>
|
||
public string CheckDate { get; set; }
|
||
|
||
/// <summary>
|
||
/// 填写人id
|
||
/// </summary>
|
||
public string CompileMan { get; set; }
|
||
|
||
/// <summary>
|
||
/// 状态(0待提交 1安置部部长 2副经理 3经理 4完成)
|
||
/// </summary>
|
||
public string State { get; set; }
|
||
|
||
/// <summary>
|
||
/// 设备名称
|
||
/// </summary>
|
||
public string EquipmentInItemName { get; set; }
|
||
|
||
/// <summary>
|
||
/// 子表
|
||
/// </summary>
|
||
public List<ListDetail_c> Child { get; set; }
|
||
|
||
/// <summary>
|
||
/// 按钮类型
|
||
/// </summary>
|
||
public string BtnType { get; set; }
|
||
|
||
/// <summary>
|
||
/// 办理人
|
||
/// </summary>
|
||
public string HandleMan { get; set; }
|
||
|
||
/// <summary>
|
||
/// 办理步骤
|
||
/// </summary>
|
||
public string HandleType { get; set; }
|
||
|
||
/// <summary>
|
||
/// 办理意见
|
||
/// </summary>
|
||
public string Opinions { get; set; }
|
||
|
||
/// <summary>
|
||
/// 附件地址
|
||
/// </summary>
|
||
public string AttachUrl { get; set; }
|
||
|
||
/// <summary>
|
||
/// 检查人姓名
|
||
/// </summary>
|
||
public string CompanyManName { get; set; }
|
||
|
||
/// <summary>
|
||
/// 设备规格
|
||
/// </summary>
|
||
public string SizeModel { get; set; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 子集合
|
||
/// </summary>
|
||
public class ListDetail_c
|
||
{
|
||
/// <summary>
|
||
/// 检查结果
|
||
/// </summary>
|
||
public string CheckResult { get; set; }
|
||
|
||
/// <summary>
|
||
/// 备注
|
||
/// </summary>
|
||
public string CheckRemark { get; set; }
|
||
|
||
/// <summary>
|
||
/// 子表id
|
||
/// </summary>
|
||
public string EquipmentCheck_Cid { get; set; }
|
||
|
||
/// <summary>
|
||
/// 检查表id
|
||
/// </summary>
|
||
public string CheckItemDetailId { get; set; }
|
||
|
||
/// <summary>
|
||
/// 检查内容
|
||
/// </summary>
|
||
public string CheckContent { get; set; }
|
||
|
||
/// <summary>
|
||
/// 附件地址
|
||
/// </summary>
|
||
public string AttachUrl { get; set; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 检查项目表实体类
|
||
/// </summary>
|
||
public class CheckItemDetailItem
|
||
{
|
||
/// <summary>
|
||
/// 检查表id
|
||
/// </summary>
|
||
public string CheckItemDetailId { get; set; }
|
||
|
||
/// <summary>
|
||
/// 检查方法、内容及要求
|
||
/// </summary>
|
||
public string CheckContent { get; set; }
|
||
|
||
/// <summary>
|
||
/// 父类名称
|
||
/// </summary>
|
||
public string CheckContent1 { get; set; }
|
||
|
||
/// <summary>
|
||
/// 子类名称
|
||
/// </summary>
|
||
public string CheckContent2 { get; set; }
|
||
|
||
/// <summary>
|
||
/// 排序
|
||
/// </summary>
|
||
public int? SortIndex { get; set; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 特种设备实体类
|
||
/// </summary>
|
||
public class EquipmentInItem
|
||
{
|
||
/// <summary>
|
||
/// 显示的值
|
||
/// </summary>
|
||
public string dataValue { get; set; }
|
||
|
||
/// <summary>
|
||
/// 存起来的值
|
||
/// </summary>
|
||
public string dataKey { get; set; }
|
||
///// <summary>
|
||
///// 主键
|
||
///// </summary>
|
||
//public string SpecialEquipmentId { get; set; }
|
||
|
||
///// <summary>
|
||
///// 设备名称
|
||
///// </summary>
|
||
//public string SpecialEquipmentName { get; set; }
|
||
|
||
///// <summary>
|
||
///// 编号
|
||
///// </summary>
|
||
//public string SizeCode { get; set; }
|
||
}
|
||
#endregion
|
||
|
||
#region 其他方法
|
||
/// <summary>
|
||
/// 返回审批状态
|
||
/// </summary>
|
||
/// <param name="state"></param>
|
||
/// <returns></returns>
|
||
public static string ConvertState(string state)
|
||
{
|
||
if (state != null)
|
||
{
|
||
if (state.ToString() == "0")
|
||
{
|
||
return "重新编制";
|
||
}
|
||
else if (state.ToString() == "1")
|
||
{
|
||
return "编制";
|
||
}
|
||
else if (state.ToString() == "2")
|
||
{
|
||
return "安置部部长审批";
|
||
}
|
||
else if (state.ToString() == "3")
|
||
{
|
||
return "副经理审批";
|
||
}
|
||
else if (state.ToString() == "4")
|
||
{
|
||
return "经理审批";
|
||
}
|
||
else if (state.ToString() == "5")
|
||
{
|
||
return "审批完成";
|
||
}
|
||
else
|
||
{
|
||
return "";
|
||
}
|
||
}
|
||
return "";
|
||
}
|
||
|
||
public static string ConvertStateList(string state)
|
||
{
|
||
if (state != null)
|
||
{
|
||
if (state.ToString() == "0")
|
||
{
|
||
return "待提交";
|
||
}
|
||
else if (state.ToString() == "1")
|
||
{
|
||
return "待提交";
|
||
}
|
||
else if (state.ToString() == "2")
|
||
{
|
||
return "审核中";
|
||
}
|
||
else if (state.ToString() == "3")
|
||
{
|
||
return "审核中";
|
||
}
|
||
else if (state.ToString() == "4")
|
||
{
|
||
return "审核中";
|
||
}
|
||
else if (state.ToString() == "5")
|
||
{
|
||
return "已完成";
|
||
}
|
||
else
|
||
{
|
||
return "";
|
||
}
|
||
}
|
||
return "";
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取特种设备名称
|
||
/// </summary>
|
||
/// <param name="equipmentId"></param>
|
||
/// <returns></returns>
|
||
protected static string ConvertEqiupment(object equipmentId)
|
||
{
|
||
string equipmentName = string.Empty;
|
||
if (equipmentId != null)
|
||
{
|
||
var specialEquipment = BLL.SpecialEquipmentService.GetSpecialEquipmentById(equipmentId.ToString());
|
||
if (specialEquipment != null)
|
||
{
|
||
equipmentName = specialEquipment.SpecialEquipmentName;
|
||
}
|
||
}
|
||
return equipmentName;
|
||
}
|
||
#endregion
|
||
|
||
#region 小程序
|
||
|
||
#region 查询列表
|
||
/// <summary>
|
||
/// 返回特种设备检查表集合
|
||
/// </summary>
|
||
/// <param name="Projectid"></param>
|
||
/// <param name="Type"></param>
|
||
/// <param name="CompileMan"></param>
|
||
/// <returns></returns>
|
||
public static List<Special_EquipmentCheckList> GetSpecial_EquipmentCheckList(string Projectid, string Type, string CompileMan = "", string State = "", string EquipmentInItemId = "")
|
||
{
|
||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||
{
|
||
var list = (from x in db.Special_EquipmentCheck
|
||
where x.ProjectId == Projectid && x.Type == Type
|
||
orderby x.CheckDate
|
||
select new Special_EquipmentCheckList
|
||
{
|
||
Special_EquipmentCheckId = x.Special_EquipmentCheckId,
|
||
EquipmentInItemId = x.EquipmentInItemId,
|
||
CheckDate = string.Format("{0:yyyy-MM-dd}", x.CheckDate),
|
||
State = ReturnState(x.State),
|
||
Zt = x.State,
|
||
CompileMan = x.CompileMan,
|
||
StateName = ConvertStateList(x.State),
|
||
}).ToList();
|
||
|
||
if (!string.IsNullOrEmpty(State))
|
||
{
|
||
//待提交
|
||
if (State == "0")
|
||
{
|
||
list = list.Where(x => x.Zt == "0" || x.Zt == "1").ToList();
|
||
}
|
||
else if (State == "1")
|
||
{
|
||
//待审核
|
||
list = list.Where(x => x.Zt == "2" || x.Zt == "3" || x.Zt == "4").ToList();
|
||
}
|
||
else if (State == "2")
|
||
{
|
||
list = list.Where(x => x.Zt == "5").ToList();
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(EquipmentInItemId))
|
||
{
|
||
list = list.Where(x => x.EquipmentInItemId == EquipmentInItemId).ToList();
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(CompileMan))
|
||
{
|
||
list = list.Where(x => x.CompileMan == CompileMan).ToList();
|
||
}
|
||
|
||
foreach (var item in list)
|
||
{
|
||
var imodel = db.InApproveManager_EquipmentInItem.FirstOrDefault(x => x.EquipmentInItemId == item.EquipmentInItemId);
|
||
if (imodel!=null)
|
||
{
|
||
item.EquipmentInItemName = BLL.SpecialEquipmentService.GetSpecialEquipmentById(imodel.SpecialEquipmentId)?.SpecialEquipmentName;
|
||
if (!string.IsNullOrEmpty(item.CompileMan))
|
||
{
|
||
var uName = UserService.GetUserByUserId(item.CompileMan);
|
||
if (uName != null)
|
||
{
|
||
item.CompileMan = uName.UserName;
|
||
}
|
||
item.SizeModel = imodel.SizeModel;
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
return list.ToList();
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 返回状态
|
||
/// </summary>
|
||
/// <param name="State"></param>
|
||
/// <returns></returns>
|
||
public static string ReturnState(string State)
|
||
{
|
||
if (State.ToString() == "0")
|
||
{
|
||
return "重新编制";
|
||
}
|
||
else if (State.ToString() == "1")
|
||
{
|
||
return "编制";
|
||
}
|
||
else if (State.ToString() == "2")
|
||
{
|
||
return "安置部部长审批";
|
||
}
|
||
else if (State.ToString() == "3")
|
||
{
|
||
return "副经理审批";
|
||
}
|
||
else if (State.ToString() == "4")
|
||
{
|
||
return "经理审批";
|
||
}
|
||
else if (State.ToString() == "5")
|
||
{
|
||
return "审批完成";
|
||
}
|
||
else
|
||
{
|
||
return "";
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 查询日常检查和定期检查明细
|
||
|
||
|
||
/// <summary>
|
||
/// 日常和定期检查明细
|
||
/// </summary>
|
||
/// <param name="Special_EquipmentCheckId">主键id</param>
|
||
/// <returns></returns>
|
||
public static ListDetail getDailyData(string Special_EquipmentCheckId)
|
||
{
|
||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||
{
|
||
ListDetail model = new ListDetail();
|
||
var SpeModel = db.Special_EquipmentCheck.FirstOrDefault(x => x.Special_EquipmentCheckId == Special_EquipmentCheckId);
|
||
if (SpeModel == null)
|
||
{
|
||
return model;
|
||
}
|
||
else
|
||
{
|
||
model.Special_EquipmentCheckId = Special_EquipmentCheckId;
|
||
model.EquipmentInItemId = SpeModel.EquipmentInItemId;
|
||
model.ProjectName = ProjectService.GetProjectNameByProjectId(SpeModel.ProjectId);
|
||
model.ProjectId = SpeModel.ProjectId;
|
||
model.Type = SpeModel.Type;
|
||
model.CompileMan = SpeModel.CompileMan;
|
||
model.State = SpeModel.State;
|
||
model.CheckDate = string.Format("{0:yyyy-MM-dd}", SpeModel.CheckDate);
|
||
var imodel = db.InApproveManager_EquipmentInItem.FirstOrDefault(x => x.EquipmentInItemId == SpeModel.EquipmentInItemId);
|
||
model.EquipmentInItemName = BLL.SpecialEquipmentService.GetSpecialEquipmentById(imodel.SpecialEquipmentId).SpecialEquipmentName;
|
||
model.SizeModel = imodel.SizeModel;
|
||
model.CompanyManName = UserService.GetUserByUserId(SpeModel.CompileMan).UserName;
|
||
model.SignatureUrl = SpeModel.SignatureUrl;
|
||
model.Conclusion = SpeModel.Conclusion;
|
||
|
||
if (db.AttachFile.FirstOrDefault(z => z.ToKeyId == Special_EquipmentCheckId)!=null)
|
||
{
|
||
model.AttachUrl = db.AttachFile.First(z => z.ToKeyId == Special_EquipmentCheckId).AttachUrl.Replace('\\', '/');
|
||
}
|
||
|
||
//查询子表
|
||
var EquipmentCheck_CList = db.EquipmentCheck_C.Where(x => x.Special_EquipmentCheckId == Special_EquipmentCheckId).OrderBy(x => x.SortIndex)
|
||
.ToList();
|
||
List<ListDetail_c> ListDetail_cList = new List<ListDetail_c>();
|
||
if (EquipmentCheck_CList.Count > 0)
|
||
{
|
||
foreach (var item in EquipmentCheck_CList)
|
||
{
|
||
ListDetail_c cModel = new ListDetail_c();
|
||
cModel.CheckResult = item.CheckResult;
|
||
cModel.CheckRemark = item.CheckRemark;
|
||
cModel.EquipmentCheck_Cid = item.EquipmentCheck_Cid;
|
||
cModel.CheckItemDetailId = item.CheckItemDetailId;
|
||
cModel.CheckContent = db.Technique_CheckItemDetail.FirstOrDefault(x => x.CheckItemDetailId == item.CheckItemDetailId).CheckContent;
|
||
//附件
|
||
if (db.AttachFile.FirstOrDefault(z => z.ToKeyId == item.EquipmentCheck_Cid)!=null)
|
||
{
|
||
cModel.AttachUrl = db.AttachFile.First(z => z.ToKeyId == item.EquipmentCheck_Cid).AttachUrl.Replace('\\', '/');
|
||
}
|
||
|
||
ListDetail_cList.Add(cModel);
|
||
}
|
||
}
|
||
model.Child = ListDetail_cList;
|
||
return model;
|
||
}
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 添加日常、定期检查
|
||
|
||
/// <summary>
|
||
/// 加载检查表内容
|
||
/// </summary>
|
||
/// <param name="type">7日常检查 8定期检查 9安装前 10安装中 11使用中 12拆除中</param>
|
||
/// <returns></returns>
|
||
public static List<CheckItemDetailItem> getCheckItemDetailList(string type)
|
||
{
|
||
|
||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||
{
|
||
if (type == "7" || type == "8")
|
||
{
|
||
var list = (from x in db.Technique_CheckItemDetail
|
||
join y in db.Technique_CheckItemSet on x.CheckItemSetId equals y.CheckItemSetId
|
||
join z in db.Technique_CheckItemSet on y.SupCheckItem equals z.CheckItemSetId
|
||
where y.CheckType == type && y.SupCheckItem != "0"
|
||
orderby z.CheckItemName descending, y.SortIndex, z.SortIndex
|
||
select new CheckItemDetailItem
|
||
{
|
||
CheckItemDetailId = x.CheckItemDetailId,
|
||
CheckContent = x.CheckContent,
|
||
CheckContent2 = y.CheckItemName,
|
||
CheckContent1 = z.CheckItemName,
|
||
|
||
}).ToList();
|
||
var i = 1;
|
||
foreach (var item in list)
|
||
{
|
||
//item.CheckContent1 = db.Technique_CheckItemSet.FirstOrDefault(z => z.CheckItemSetId == item.CheckContent1).CheckItemName;
|
||
item.SortIndex = i;
|
||
i += 1;
|
||
}
|
||
return list.ToList();
|
||
}
|
||
else
|
||
{
|
||
var list = (from x in db.Technique_CheckItemDetail
|
||
join y in db.Technique_CheckItemSet on x.CheckItemSetId equals y.CheckItemSetId
|
||
where y.CheckType == type
|
||
orderby y.SortIndex, x.SortIndex
|
||
select new CheckItemDetailItem
|
||
{
|
||
CheckItemDetailId = x.CheckItemDetailId,
|
||
CheckContent = x.CheckContent,
|
||
CheckContent1 = y.CheckItemName
|
||
|
||
}).ToList();
|
||
var i = 1;
|
||
foreach (var item in list)
|
||
{
|
||
item.SortIndex = i;
|
||
i += 1;
|
||
}
|
||
return list;
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据项目id获取特种设备列表
|
||
/// </summary>
|
||
/// <param name="projectId"></param>
|
||
/// <returns></returns>
|
||
public static List<EquipmentInItem> getEquipmentInItem(string projectId)
|
||
{
|
||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||
{
|
||
var list = (from x in db.InApproveManager_EquipmentInItem
|
||
join y in db.InApproveManager_EquipmentIn on x.EquipmentInId equals y.EquipmentInId
|
||
join z in db.Base_SpecialEquipment on x.SpecialEquipmentId equals z.SpecialEquipmentId
|
||
|
||
where y.ProjectId == projectId && (z.SpecialEquipmentName=="塔式起重机" || z.SpecialEquipmentName == "普通塔式起重机"
|
||
|| z.SpecialEquipmentName == "施工升降机" || z.SpecialEquipmentName == "架桥机" || z.SpecialEquipmentName == "普通门式起重机"
|
||
)
|
||
select new EquipmentInItem
|
||
{
|
||
dataKey = x.EquipmentInItemId,
|
||
dataValue = x.SpecialEquipmentId + "," + x.SizeModel
|
||
|
||
}).ToList();
|
||
foreach (var item in list)
|
||
{
|
||
//显示设备名称+规格型号
|
||
item.dataValue = ConvertEqiupment(item.dataValue.Split(',')[0]) + "(" + item.dataValue.Split(',')[1] + ")";
|
||
}
|
||
return list;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 添加修改日常、定期检查
|
||
/// </summary>
|
||
/// <param name="model"></param>
|
||
public static string EditDayEquipment(ListDetail model)
|
||
{
|
||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||
{
|
||
string message = string.Empty;
|
||
try
|
||
{
|
||
Model.Special_EquipmentCheck newModel = new Model.Special_EquipmentCheck();
|
||
newModel.ProjectId = model.ProjectId;
|
||
newModel.EquipmentInItemId = model.EquipmentInItemId;
|
||
newModel.Type = model.Type;
|
||
newModel.SignatureUrl = model.SignatureUrl;
|
||
newModel.Conclusion = model.Conclusion;
|
||
newModel.CheckDate = Convert.ToDateTime(model.CheckDate);
|
||
newModel.CompileDate = DateTime.Now;
|
||
newModel.CompileMan = model.CompileMan;
|
||
newModel.State = model.State;
|
||
|
||
if (!string.IsNullOrEmpty(model.Special_EquipmentCheckId))
|
||
{
|
||
newModel.Special_EquipmentCheckId = model.Special_EquipmentCheckId;
|
||
var addModel = db.Special_EquipmentCheck.FirstOrDefault(x => x.Special_EquipmentCheckId == newModel.Special_EquipmentCheckId);
|
||
if (addModel != null)
|
||
{
|
||
UpdateEquipment(newModel);
|
||
//删除子表
|
||
var EquipmentCheck_CListDel = db.EquipmentCheck_C.Where(x => x.Special_EquipmentCheckId == newModel.Special_EquipmentCheckId).ToList();
|
||
db.EquipmentCheck_C.DeleteAllOnSubmit(EquipmentCheck_CListDel);
|
||
db.SubmitChanges();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//添加
|
||
newModel.Special_EquipmentCheckId = Guid.NewGuid().ToString();
|
||
db.Special_EquipmentCheck.InsertOnSubmit(newModel);
|
||
db.SubmitChanges();
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(model.AttachUrl))
|
||
{
|
||
//// 保存附件
|
||
APIUpLoadFileService.SaveAttachUrl("7D91A998-A665-4CC9-9E6B-141B14FA2690", newModel.Special_EquipmentCheckId, model.AttachUrl, "0");
|
||
}
|
||
|
||
if (model.Child.Count > 0)
|
||
{
|
||
var i = 1;
|
||
//添加子表
|
||
List<Model.EquipmentCheck_C> EquipmentCheck_CList = new List<Model.EquipmentCheck_C>();
|
||
foreach (var item in model.Child)
|
||
{
|
||
Model.EquipmentCheck_C childModel = new Model.EquipmentCheck_C();
|
||
childModel.EquipmentCheck_Cid = Guid.NewGuid().ToString();
|
||
childModel.Special_EquipmentCheckId = newModel.Special_EquipmentCheckId;
|
||
childModel.CheckItemDetailId = item.CheckItemDetailId;
|
||
childModel.CheckResult = item.CheckResult;
|
||
childModel.CheckRemark = item.CheckRemark;
|
||
childModel.SortIndex = i;
|
||
EquipmentCheck_CList.Add(childModel);
|
||
|
||
if (!string.IsNullOrEmpty(item.AttachUrl))
|
||
{
|
||
//// 保存附件
|
||
APIUpLoadFileService.SaveAttachUrl("7D91A998-A665-4CC9-9E6B-141B14FA2690", childModel.EquipmentCheck_Cid, item.AttachUrl, "0");
|
||
}
|
||
|
||
i += 1;
|
||
}
|
||
db.EquipmentCheck_C.InsertAllOnSubmit(EquipmentCheck_CList);
|
||
|
||
|
||
|
||
db.SubmitChanges();
|
||
message = "添加成功";
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
|
||
message = ex.Message;
|
||
}
|
||
return message;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 修改检查主表数据
|
||
/// </summary>
|
||
/// <param name="model"></param>
|
||
public static void UpdateEquipment(Model.Special_EquipmentCheck model)
|
||
{
|
||
Model.Special_EquipmentCheck newModel = new Model.Special_EquipmentCheck();
|
||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||
{
|
||
newModel = db.Special_EquipmentCheck.FirstOrDefault(x => x.Special_EquipmentCheckId == model.Special_EquipmentCheckId);
|
||
newModel.ProjectId = model.ProjectId;
|
||
newModel.EquipmentInItemId = model.EquipmentInItemId;
|
||
newModel.Type = model.Type;
|
||
newModel.SignatureUrl = model.SignatureUrl;
|
||
newModel.Conclusion = model.Conclusion;
|
||
newModel.CheckDate = model.CheckDate;
|
||
newModel.State = model.State;
|
||
db.SubmitChanges();
|
||
}
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 添加修改隐患排查清单
|
||
/// </summary>
|
||
/// <param name="model"></param>
|
||
public static string EditFlowEquipment(ListDetail model)
|
||
{
|
||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||
{
|
||
string message = string.Empty;
|
||
try
|
||
{
|
||
Model.Special_EquipmentCheck newModel = new Model.Special_EquipmentCheck();
|
||
newModel.ProjectId = model.ProjectId;
|
||
newModel.EquipmentInItemId = model.EquipmentInItemId;
|
||
newModel.Type = model.Type;
|
||
newModel.SignatureUrl = model.SignatureUrl;
|
||
newModel.Conclusion = model.Conclusion;
|
||
newModel.CheckDate = Convert.ToDateTime(model.CheckDate);
|
||
newModel.CompileDate = DateTime.Now;
|
||
newModel.CompileMan = model.CompileMan;
|
||
newModel.State = model.State;
|
||
|
||
if (!string.IsNullOrEmpty(model.Special_EquipmentCheckId))
|
||
{
|
||
newModel.Special_EquipmentCheckId = model.Special_EquipmentCheckId;
|
||
var addModel = db.Special_EquipmentCheck.FirstOrDefault(x => x.Special_EquipmentCheckId == newModel.Special_EquipmentCheckId);
|
||
if (addModel != null)
|
||
{
|
||
UpdateEquipment(newModel);
|
||
//删除子表
|
||
var EquipmentCheck_CListDel = db.EquipmentCheck_C.Where(x => x.Special_EquipmentCheckId == newModel.Special_EquipmentCheckId).ToList();
|
||
db.EquipmentCheck_C.DeleteAllOnSubmit(EquipmentCheck_CListDel);
|
||
db.SubmitChanges();
|
||
}
|
||
|
||
|
||
|
||
Model.Special_EquipmentCheckApprove approve1 = Funs.DB.Special_EquipmentCheckApprove.FirstOrDefault(x => x.CheckControlCode == newModel.Special_EquipmentCheckId
|
||
&& x.ApproveType != "S" && x.ApproveDate == null);
|
||
|
||
if (approve1 != null && model.BtnType == "submit")
|
||
{
|
||
approve1.ApproveDate = DateTime.Now;
|
||
approve1.ApproveIdea = model.Opinions;
|
||
//approve1.IsAgree = Convert.ToBoolean(this.rblIsAgree.SelectedValue);
|
||
BLL.EquipmentCheckApproveService.UpdateApprove(approve1);
|
||
}
|
||
if (model.BtnType == "submit")
|
||
{
|
||
Model.Special_EquipmentCheckApprove approve = new Model.Special_EquipmentCheckApprove();
|
||
approve.CheckControlCode = newModel.Special_EquipmentCheckId;
|
||
approve.ApproveMan = model.HandleMan;
|
||
approve.ApproveType = model.HandleType;
|
||
if (model.HandleType == "5")
|
||
{
|
||
approve.ApproveDate = DateTime.Now.AddMinutes(1);
|
||
}
|
||
BLL.EquipmentCheckApproveService.AddApprove(approve);
|
||
|
||
var username = UserService.GetUserByUserId(newModel.CompileMan).UserName;
|
||
|
||
APICommonService.SendSubscribeMessage(approve.ApproveMan, "特种设备隐患排查清单代办理",
|
||
username, string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//添加
|
||
newModel.Special_EquipmentCheckId = Guid.NewGuid().ToString();
|
||
|
||
|
||
db.Special_EquipmentCheck.InsertOnSubmit(newModel);
|
||
db.SubmitChanges();
|
||
#region 添加到审核
|
||
if (model.BtnType == "submit")
|
||
{
|
||
//添加流程第一个,编制
|
||
Model.Special_EquipmentCheckApprove approve1 = new Model.Special_EquipmentCheckApprove();
|
||
approve1.CheckControlCode = newModel.Special_EquipmentCheckId;
|
||
approve1.ApproveDate = DateTime.Now;
|
||
approve1.ApproveMan = newModel.CompileMan;
|
||
approve1.ApproveType = "1";
|
||
BLL.EquipmentCheckApproveService.AddApprove(approve1);
|
||
|
||
Model.Special_EquipmentCheckApprove approve = new Model.Special_EquipmentCheckApprove();
|
||
approve.CheckControlCode = newModel.Special_EquipmentCheckId;
|
||
approve.ApproveMan = model.HandleMan;
|
||
approve.ApproveType = model.HandleType;
|
||
BLL.EquipmentCheckApproveService.AddApprove(approve);
|
||
|
||
var username = UserService.GetUserByUserId(newModel.CompileMan).UserName;
|
||
APICommonService.SendSubscribeMessage(approve.ApproveMan, "特种设备隐患排查清单代办理", username,
|
||
string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now));
|
||
}
|
||
else
|
||
{
|
||
Model.Special_EquipmentCheckApprove approve1 = new Model.Special_EquipmentCheckApprove();
|
||
approve1.CheckControlCode = newModel.Special_EquipmentCheckId;
|
||
approve1.ApproveMan = newModel.CompileMan;
|
||
approve1.ApproveType = "1";
|
||
BLL.EquipmentCheckApproveService.AddApprove(approve1);
|
||
}
|
||
|
||
#endregion
|
||
}
|
||
if (model.Child.Count > 0)
|
||
{
|
||
var i = 1;
|
||
//添加子表
|
||
List<Model.EquipmentCheck_C> EquipmentCheck_CList = new List<Model.EquipmentCheck_C>();
|
||
foreach (var item in model.Child)
|
||
{
|
||
Model.EquipmentCheck_C childModel = new Model.EquipmentCheck_C();
|
||
childModel.EquipmentCheck_Cid = Guid.NewGuid().ToString();
|
||
childModel.Special_EquipmentCheckId = newModel.Special_EquipmentCheckId;
|
||
childModel.CheckItemDetailId = item.CheckItemDetailId;
|
||
childModel.CheckResult = item.CheckResult;
|
||
childModel.CheckRemark = item.CheckRemark;
|
||
childModel.SortIndex = i;
|
||
EquipmentCheck_CList.Add(childModel);
|
||
|
||
if (!string.IsNullOrEmpty(item.AttachUrl))
|
||
{
|
||
//// 保存附件
|
||
APIUpLoadFileService.SaveAttachUrl("2F477173-25A5-4107-AA73-720DEACC00B2", childModel.EquipmentCheck_Cid, item.AttachUrl, "0");
|
||
}
|
||
|
||
i += 1;
|
||
}
|
||
db.EquipmentCheck_C.InsertAllOnSubmit(EquipmentCheck_CList);
|
||
db.SubmitChanges();
|
||
|
||
if (!string.IsNullOrEmpty(model.AttachUrl))
|
||
{
|
||
//// 保存附件
|
||
APIUpLoadFileService.SaveAttachUrl("2F477173-25A5-4107-AA73-720DEACC00B2", newModel.Special_EquipmentCheckId, model.AttachUrl, "0");
|
||
}
|
||
message = "编辑成功";
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
|
||
message = ex.Message;
|
||
}
|
||
return message;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 获取审批列表
|
||
/// <summary>
|
||
/// 获取审批列表
|
||
/// </summary>
|
||
/// <param name="satartRowIndex"></param>
|
||
/// <param name="maximumRows"></param>
|
||
/// <returns></returns>
|
||
public static List<AuditItem> getListData(string Special_EquipmentCheckId)
|
||
{
|
||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||
{
|
||
var res = from x in db.Special_EquipmentCheckApprove
|
||
where x.CheckControlCode == Special_EquipmentCheckId && x.ApproveType != "S"
|
||
orderby x.ApproveType
|
||
select new AuditItem
|
||
{
|
||
State = ConvertState(x.ApproveType),
|
||
ApproveMan = (from y in db.Sys_User where y.UserId == x.ApproveMan select y.UserName).First(),
|
||
ApproveDate = string.Format("{0:yyyy-MM-dd HH:mm:ss}", x.ApproveDate),
|
||
ApproveIdea = x.ApproveIdea
|
||
};
|
||
|
||
return res.ToList();
|
||
}
|
||
|
||
}
|
||
#endregion
|
||
|
||
|
||
|
||
|
||
#endregion
|
||
|
||
#region 根据主键id获取特种设备信息
|
||
|
||
/// <summary>
|
||
/// 根据主键加载特种设备信息
|
||
/// </summary>
|
||
/// <param name="EquipmentInItemId"></param>
|
||
public static EquipmentInItemModel getEquipmentInItemModel(string EquipmentInItemId)
|
||
{
|
||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||
{
|
||
EquipmentInItemModel model = new EquipmentInItemModel();
|
||
Model.InApproveManager_EquipmentInItem equipmentInItem = BLL.EquipmentInItemService.GetEquipmentInItemById(EquipmentInItemId);
|
||
if (equipmentInItem != null)
|
||
{
|
||
model.EquipmentInId = equipmentInItem.EquipmentInId;
|
||
var modelEqin = db.InApproveManager_EquipmentIn.FirstOrDefault(x => x.EquipmentInId == model.EquipmentInId);
|
||
if (modelEqin!=null)
|
||
{
|
||
model.ProjectId = modelEqin.ProjectId;
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(equipmentInItem.SpecialEquipmentId))
|
||
{
|
||
model.SpecialEquipmentName = db.Base_SpecialEquipment.FirstOrDefault(x => x.SpecialEquipmentId == equipmentInItem.SpecialEquipmentId).SpecialEquipmentName;
|
||
model.SizeModel = equipmentInItem.SizeModel;
|
||
model.OwnerCheck = equipmentInItem.OwnerCheck;
|
||
model.SizeCode = equipmentInItem.SizeCode;
|
||
model.DetectionStatus = equipmentInItem.DetectionStatus;
|
||
if (!string.IsNullOrEmpty(equipmentInItem.CheckDate))
|
||
{
|
||
model.CheckDate = string.Format("{0:yyyy-MM-dd}", DateTime.Parse(equipmentInItem.CheckDate));
|
||
}
|
||
if (!string.IsNullOrEmpty(equipmentInItem.ProDate.ToString()))
|
||
{
|
||
model.ProDate = string.Format("{0:yyyy-MM-dd}", equipmentInItem.ProDate);
|
||
}
|
||
model.InspectionCycle = equipmentInItem.InspectionCycle;
|
||
model.ValidityDateOfInspection = equipmentInItem.ValidityDateOfInspection.ToString();
|
||
if (!string.IsNullOrEmpty(equipmentInItem.UseRegDate))
|
||
{
|
||
model.UseRegDate = string.Format("{0:yyyy-MM-dd}", DateTime.Parse(equipmentInItem.UseRegDate));
|
||
}
|
||
model.UseRegDepart = equipmentInItem.UseRegDepart;
|
||
if (!string.IsNullOrEmpty(equipmentInItem.InDate))
|
||
{
|
||
model.InDate = string.Format("{0:yyyy-MM-dd}", DateTime.Parse(equipmentInItem.InDate));
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(equipmentInItem.OutDate))
|
||
{
|
||
model.OutDate = string.Format("{0:yyyy-MM-dd}", DateTime.Parse(equipmentInItem.OutDate));
|
||
}
|
||
model.OperatorName = equipmentInItem.OperatorName;
|
||
model.SpecialCertificateNumber = equipmentInItem.SpecialCertificateNumber;
|
||
model.Remark = equipmentInItem.Remark;
|
||
model.IsUsed = "在用";
|
||
if (equipmentInItem.IsUsed != true)
|
||
{
|
||
model.IsUsed = "未用";
|
||
}
|
||
model.EquipmentInId = equipmentInItem.EquipmentInId;
|
||
var equipmentIn = BLL.EquipmentInService.GetEquipmentInById(model.EquipmentInId);
|
||
if (!string.IsNullOrEmpty(equipmentIn.UnitId))
|
||
{
|
||
model.UnitName = UnitService.GetUnitByUnitId(equipmentIn.UnitId).UnitName;
|
||
if (!string.IsNullOrEmpty(equipmentIn.UseUnitId))
|
||
{
|
||
model.UseUnitName = UnitService.GetUnitByUnitId(equipmentIn.UseUnitId).UnitName;
|
||
}
|
||
|
||
}
|
||
var Fj1 = db.AttachFile.FirstOrDefault(z => z.ToKeyId == equipmentIn.EquipmentInId + "_Item");
|
||
if (Fj1 != null)
|
||
{
|
||
model.Fjitem1 = Fj1.AttachUrl.Replace('\\', '/');
|
||
}
|
||
var Fj2 = db.AttachFile.FirstOrDefault(z => z.ToKeyId == equipmentIn.EquipmentInId + "_Item_2");
|
||
if (Fj2 != null)
|
||
{
|
||
model.Fjitem2 = Fj2.AttachUrl.Replace('\\', '/');
|
||
}
|
||
var Fj3 = db.AttachFile.FirstOrDefault(z => z.ToKeyId == equipmentIn.EquipmentInId + "_Item_3");
|
||
if (Fj3 != null)
|
||
{
|
||
model.Fjitem3 = Fj3.AttachUrl.Replace('\\', '/');
|
||
}
|
||
var Fj4 = db.AttachFile.FirstOrDefault(z => z.ToKeyId == equipmentIn.EquipmentInId + "_Item_4");
|
||
if (Fj4 != null)
|
||
{
|
||
model.Fjitem4 = Fj4.AttachUrl.Replace('\\', '/');
|
||
}
|
||
}
|
||
}
|
||
return model;
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
}
|
||
}
|