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 { /// /// 特种设备检查主表 /// public class Special_EquipmentCheckService { public static Model.SUBQHSEDB db = Funs.DB; /// /// 根据主键检查单 /// /// 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 模型类 /// /// 特种设备实体类 /// public class EquipmentInItemModel { /// /// 附件主键 /// public string EquipmentInId { get; set; } /// /// 编号 /// public string SizeCode { get; set; } /// /// 单位名称 /// public string UnitName { get; set; } /// /// 设备名称 /// public string SpecialEquipmentName { get; set; } /// /// 使用单位名称 /// public string UseUnitName { get; set; } /// /// 规格型号 /// public string SizeModel { get; set; } /// /// 生产日期 /// public string ProDate { get; set; } /// /// 进场前自查自检情况 /// public string OwnerCheck { get; set; } /// /// 检测状态 /// public string DetectionStatus { get; set; } /// /// 检测日期 /// public string CheckDate { get; set; } /// /// 检验周期 /// public string InspectionCycle { get; set; } /// /// 检验有效期 /// public string ValidityDateOfInspection { get; set; } /// /// 使用登记日期 /// public string UseRegDate { get; set; } /// /// 使用登记部门 /// public string UseRegDepart { get; set; } /// /// 进场日期 /// public string InDate { get; set; } /// /// 出厂日期 /// public string OutDate { get; set; } /// /// 操作手姓名 /// public string OperatorName { get; set; } /// /// 特种作业证件号码 /// public string SpecialCertificateNumber { get; set; } /// /// 备注 /// 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; } } /// /// 审批列表实体类 /// public class AuditItem { public string State { get; set; } public string ApproveMan { get; set; } public string ApproveDate { get; set; } public string ApproveIdea { get; set; } } /// /// 返回查询列表实体类 /// public class Special_EquipmentCheckList { /// /// 主表id /// public string Special_EquipmentCheckId { get; set; } /// /// 检查日期 /// public string CheckDate { get; set; } /// /// 设备id /// public string EquipmentInItemId { get; set; } /// /// 设备名称 /// public string EquipmentInItemName { get; set; } /// /// 状态 /// public string State { get; set; } public string StateName { get; set; } /// /// 状态值 /// public string Zt { get; set; } /// /// 类型 /// public string Type { get; set; } /// /// 添加人 /// public string CompileMan { get; set; } public string SizeModel { get; set; } } /// /// 明细类 /// public class ListDetail { /// /// 主键 /// public string Special_EquipmentCheckId { get; set; } /// /// 项目id /// public string ProjectId { get; set; } /// /// 项目名称 /// public string ProjectName { get; set; } /// /// 特种设备id /// public string EquipmentInItemId { get; set; } /// /// 类型0日常检查 1定期检查 2安装前 3安装中 4使用中 5拆除中 /// public string Type { get; set; } /// /// 签名 /// public string SignatureUrl { get; set; } /// /// 结论 /// public string Conclusion { get; set; } /// /// 检查日期 /// public string CheckDate { get; set; } /// /// 填写人id /// public string CompileMan { get; set; } /// /// 状态(0待提交 1安置部部长 2副经理 3经理 4完成) /// public string State { get; set; } /// /// 设备名称 /// public string EquipmentInItemName { get; set; } /// /// 子表 /// public List Child { get; set; } /// /// 按钮类型 /// public string BtnType { get; set; } /// /// 办理人 /// public string HandleMan { get; set; } /// /// 办理步骤 /// public string HandleType { get; set; } /// /// 办理意见 /// public string Opinions { get; set; } /// /// 附件地址 /// public string AttachUrl { get; set; } /// /// 检查人姓名 /// public string CompanyManName { get; set; } /// /// 设备规格 /// public string SizeModel { get; set; } } /// /// 子集合 /// public class ListDetail_c { /// /// 检查结果 /// public string CheckResult { get; set; } /// /// 备注 /// public string CheckRemark { get; set; } /// /// 子表id /// public string EquipmentCheck_Cid { get; set; } /// /// 检查表id /// public string CheckItemDetailId { get; set; } /// /// 检查内容 /// public string CheckContent { get; set; } /// /// 附件地址 /// public string AttachUrl { get; set; } } /// /// 检查项目表实体类 /// public class CheckItemDetailItem { /// /// 检查表id /// public string CheckItemDetailId { get; set; } /// /// 检查方法、内容及要求 /// public string CheckContent { get; set; } /// /// 父类名称 /// public string CheckContent1 { get; set; } /// /// 子类名称 /// public string CheckContent2 { get; set; } /// /// 排序 /// public int? SortIndex { get; set; } } /// /// 特种设备实体类 /// public class EquipmentInItem { /// /// 显示的值 /// public string dataValue { get; set; } /// /// 存起来的值 /// public string dataKey { get; set; } ///// ///// 主键 ///// //public string SpecialEquipmentId { get; set; } ///// ///// 设备名称 ///// //public string SpecialEquipmentName { get; set; } ///// ///// 编号 ///// //public string SizeCode { get; set; } } #endregion #region 其他方法 /// /// 返回审批状态 /// /// /// 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 ""; } /// /// 获取特种设备名称 /// /// /// 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 查询列表 /// /// 返回特种设备检查表集合 /// /// /// /// /// public static List 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(); } } /// /// 返回状态 /// /// /// 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 查询日常检查和定期检查明细 /// /// 日常和定期检查明细 /// /// 主键id /// 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_cList = new List(); 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 添加日常、定期检查 /// /// 加载检查表内容 /// /// 7日常检查 8定期检查 9安装前 10安装中 11使用中 12拆除中 /// public static List 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; } } } /// /// 根据项目id获取特种设备列表 /// /// /// public static List 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; } } /// /// 添加修改日常、定期检查 /// /// 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 EquipmentCheck_CList = new List(); 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; } } /// /// 修改检查主表数据 /// /// 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(); } } /// /// 添加修改隐患排查清单 /// /// 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 EquipmentCheck_CList = new List(); 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 获取审批列表 /// /// 获取审批列表 /// /// /// /// public static List 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获取特种设备信息 /// /// 根据主键加载特种设备信息 /// /// 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 } }