479 lines
		
	
	
		
			25 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			479 lines
		
	
	
		
			25 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using APT.BaseData.Domain.Entities;
 | 
						|
using APT.BaseData.Domain.Entities.FM;
 | 
						|
using APT.BaseData.Domain.Enums;
 | 
						|
using APT.BaseData.Domain.Enums.PF;
 | 
						|
using APT.BaseData.Domain.IServices;
 | 
						|
using APT.BaseData.Domain.IServices.AE;
 | 
						|
using APT.BaseData.Domain.IServices.FM;
 | 
						|
using APT.BaseData.Services.DomainServices;
 | 
						|
using APT.BaseData.Services.Services.FM;
 | 
						|
using APT.Infrastructure.Core;
 | 
						|
using APT.MS.Domain.Entities.DM;
 | 
						|
using APT.MS.Domain.Enums;
 | 
						|
using APT.Utility;
 | 
						|
using Microsoft.AspNetCore.Mvc;
 | 
						|
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.Linq;
 | 
						|
using System.Linq.Expressions;
 | 
						|
 | 
						|
namespace APT.SC.WebApi.Controllers.Api.DM
 | 
						|
{
 | 
						|
    [Route("api/DM/DMDeviceCheck")]
 | 
						|
    public class DMDeviceCheckController : AuthorizeApiController<T_DM_DEVICE_CHECK>
 | 
						|
    {
 | 
						|
        IPFCodeRuleService CodeRuleService { get; set; }
 | 
						|
        IFMFlowPermitService MFlowPermitService { get; set; }
 | 
						|
        IPFApproveCallBackService ApproveCallBackService { get; set; }
 | 
						|
        IFMNotificationTaskService NotificationTaskService { get; set; }
 | 
						|
        public DMDeviceCheckController(IPFCodeRuleService codeRuleService, IFMNotificationTaskService notificationTaskService, IFMFlowPermitService mFlowPermitService, IPFApproveCallBackService approveCallBackService)
 | 
						|
        {
 | 
						|
            NotificationTaskService = notificationTaskService;
 | 
						|
            CodeRuleService = codeRuleService;
 | 
						|
            MFlowPermitService = mFlowPermitService;
 | 
						|
            ApproveCallBackService = approveCallBackService;
 | 
						|
        }
 | 
						|
        /// <summary>
 | 
						|
        /// 设备设施维保计划 修改
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="entity"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpPost, Route("FullUpdate")]
 | 
						|
        public JsonActionResult<bool> FullUpdate([FromBody] T_DM_DEVICE_CHECK entity)
 | 
						|
        {
 | 
						|
            return SafeExecute<bool>(() =>
 | 
						|
            {
 | 
						|
            var ListDetail = entity.Nav_ListDetail;
 | 
						|
            entity.Nav_ListDetail = null;
 | 
						|
            T_FM_NOTIFICATION_TASK taskEnd = null;
 | 
						|
            List<T_FM_NOTIFICATION_TASK> listTaskCheck = new List<T_FM_NOTIFICATION_TASK>();
 | 
						|
            List<T_FM_NOTIFICATION_TASK> anotherTask = new List<T_FM_NOTIFICATION_TASK>();
 | 
						|
                List<T_DM_DEVICE_CHECK_DETAIL_FILE> detailFiles = new List<T_DM_DEVICE_CHECK_DETAIL_FILE>();
 | 
						|
                List<T_DM_DEVICE_REPAIR_FILE> repairFiles = new List<T_DM_DEVICE_REPAIR_FILE>();
 | 
						|
                List<T_DM_DEVICE_REPAIR> repairs = new List<T_DM_DEVICE_REPAIR>();
 | 
						|
                List <Guid> deleteIds = new List<Guid>();
 | 
						|
                var files = entity.Nav_Files;
 | 
						|
            entity.Nav_Files = null;
 | 
						|
            var users = entity.Nav_ListUser;
 | 
						|
            entity.Nav_ListUser = null;
 | 
						|
            entity.RECORD_DATE = DateTime.Now;
 | 
						|
            var loginID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
 | 
						|
            if (entity.TaskID != Guid.Empty)
 | 
						|
            {
 | 
						|
                var currTask = GetEntity<T_FM_NOTIFICATION_TASK>(t => t.ID == entity.TaskID);
 | 
						|
                if (currTask != null)
 | 
						|
                {
 | 
						|
                        loginID = currTask.USER_ID;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            if (users != null && users.Any())
 | 
						|
            {
 | 
						|
                var i = 0;
 | 
						|
                users.ForEach(t =>
 | 
						|
                {
 | 
						|
                    t.ORG_ID = entity.ORG_ID; t.CHECK_ID = entity.ID;
 | 
						|
                    if (t.USER_ID == (Guid)loginID)
 | 
						|
                    {
 | 
						|
                        t.ISMAIN = true; t.ISCHECK = true;
 | 
						|
                    }
 | 
						|
                    else if (i == 0)
 | 
						|
                    {
 | 
						|
                        t.ISMAIN = true;
 | 
						|
                    }
 | 
						|
                    t.Nav_User = null;
 | 
						|
                    i++;
 | 
						|
                });
 | 
						|
            }
 | 
						|
 | 
						|
                if (ListDetail != null && ListDetail.Any())
 | 
						|
                {
 | 
						|
                    var detailIds = ListDetail.Select(t => t.ID).ToList();
 | 
						|
                    deleteIds = this.GetEntities<T_DM_DEVICE_CHECK_DETAIL_FILE>(t => detailIds.Contains(t.CHECK_DETAIL_ID), new BaseFilter(entity.ORG_ID)).Select(m => m.ID).ToList();
 | 
						|
                    foreach (var item in ListDetail)
 | 
						|
                    {
 | 
						|
                        item.DEVICE_CHECK_ID = entity.ID;
 | 
						|
                        if (!item.IS_DELETED && item.Nav_DetailFiles != null && item.Nav_DetailFiles.Any())
 | 
						|
                        {
 | 
						|
                            item.Nav_DetailFiles.ForEach(t =>
 | 
						|
                            {
 | 
						|
                                T_DM_DEVICE_CHECK_DETAIL_FILE file = new T_DM_DEVICE_CHECK_DETAIL_FILE();
 | 
						|
                                file.ORG_ID = entity.ORG_ID;
 | 
						|
                                file.CHECK_DETAIL_ID = item.ID;
 | 
						|
                                file.IMG_FILE_ID = t.IMG_FILE_ID;
 | 
						|
                                detailFiles.Add(file);
 | 
						|
                            });
 | 
						|
                        }
 | 
						|
                        item.Nav_DetailFiles = null;
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                else
 | 
						|
                {
 | 
						|
                    throw new Exception(entity.CHECKTYPE.GetDescription() + "明细不能为空!");
 | 
						|
                }
 | 
						|
                if (entity.STATUS != PFStandardStatus.Draft)
 | 
						|
                {
 | 
						|
                //users.Add(new T_DM_DEVICE_CHECK_USER
 | 
						|
                //{
 | 
						|
                //    ORG_ID = entity.ORG_ID, CHECK_ID = entity.ID, USER_ID = (Guid)loginID, ISMAIN = true, ISCHECK = true
 | 
						|
                //});
 | 
						|
                int RowIndex = 1;
 | 
						|
                    var deviceBase = this.GetEntity<T_DM_DEVICE_BASE>(t => t.ID == entity.DEVICEBASE_ID, "Nav_UseUser");
 | 
						|
                foreach (var item in ListDetail.Where(t=>!t.IS_DELETED).ToList())
 | 
						|
                {
 | 
						|
                    if (item.CHECK_VALUE == null)
 | 
						|
                    {
 | 
						|
                        throw new Exception("请选择行:" + RowIndex + "检查结论!");
 | 
						|
                    }
 | 
						|
                    //else if ((item.CHECK_VALUE.Value == CheckResult.CheckWork || item.CHECK_VALUE.Value == CheckResult.CheckStop) && string.IsNullOrEmpty(item.DESCRIPTION))
 | 
						|
                    else if (item.CHECK_VALUE.Value == CheckResult.NotOK && string.IsNullOrEmpty(item.DESCRIPTION))
 | 
						|
                    {
 | 
						|
                        throw new Exception("请填写子表行:【" + RowIndex + "】的问题描述!");
 | 
						|
                    }
 | 
						|
                        if (item.CHECK_VALUE.Value == CheckResult.NotOK)
 | 
						|
                        {
 | 
						|
                            T_DM_DEVICE_REPAIR repair = new T_DM_DEVICE_REPAIR();
 | 
						|
                            repair.ORG_ID = entity.ORG_ID;
 | 
						|
                            repair.CODE = DateTime.Now.ToString("yyyyMMddHHmmss");
 | 
						|
                            repair.DESCRPTION = item.DESCRIPTION;
 | 
						|
                            repair.DEVICE_BASE_ID = entity.DEVICEBASE_ID;
 | 
						|
                            repair.MineType = entity.MineType;
 | 
						|
                            repair.MACHINE_CODE = deviceBase?.MACHINE_CODE;
 | 
						|
                            repair.MACHINE_NAME = deviceBase?.NAME;
 | 
						|
                            repairs.Add(repair);
 | 
						|
                            var itemFiles = detailFiles.Where(t => t.CHECK_DETAIL_ID == item.ID).ToList();
 | 
						|
                            if (itemFiles != null && itemFiles.Any())
 | 
						|
                            {
 | 
						|
                                itemFiles.ForEach(t =>
 | 
						|
                                {
 | 
						|
                                    T_DM_DEVICE_REPAIR_FILE file = new T_DM_DEVICE_REPAIR_FILE();
 | 
						|
                                    file.ORG_ID = entity.ORG_ID;
 | 
						|
                                    file.REPAIR_ID = repair.ID;
 | 
						|
                                    file.IMG_FILE_ID = t.IMG_FILE_ID;
 | 
						|
                                    repairFiles.Add(file);
 | 
						|
                                });
 | 
						|
                            }
 | 
						|
                            if (deviceBase != null && deviceBase.Nav_UseUser != null)
 | 
						|
                            {
 | 
						|
                                var task = NotificationTaskService.InsertUserNoticeTaskModel("设备设施故障报修-" + deviceBase.NAME, repair.ID, entity.ORG_ID, (Guid)deviceBase.USE_USER_ID, deviceBase.Nav_UseUser.NAME, DateTime.Now, DateTime.Now.AddDays(1), 1, "DM020");
 | 
						|
                                listTaskCheck.Add(task);
 | 
						|
                            }
 | 
						|
                        }
 | 
						|
                    RowIndex++;
 | 
						|
                }
 | 
						|
 | 
						|
                if (entity.TaskID != Guid.Empty)
 | 
						|
                {
 | 
						|
                    //taskEnd = NotificationTaskService.GetEntityTask(entity.TaskID, "DM010_SHOWPRINT");
 | 
						|
                    taskEnd = NotificationTaskService.GetEntityTask(entity.TaskID, (entity.CHECKTYPE == CheckType.CheckCircuit ? "DM032_SHOWPRINT" : "DM010_SHOWPRINT"));
 | 
						|
                }
 | 
						|
                var formCode = entity.CHECKTYPE == CheckType.CheckCircuit ? "DM032_SHOWPRINT" : "DM010_SHOWPRINT";
 | 
						|
                    //把其他人的待办置为已办
 | 
						|
                    anotherTask = this.GetEntities<T_FM_NOTIFICATION_TASK>(t => t.NOTICE_STATUS == 0 && t.SOURCE_DATA_ID == entity.ID && t.USER_ID != loginID, new BaseFilter(entity.ORG_ID)).ToList();
 | 
						|
                    if (anotherTask != null && anotherTask.Any())
 | 
						|
                    {
 | 
						|
                        anotherTask.ForEach(t => { t.NOTICE_STATUS = 1;t.SOURCE_FORMCODE = formCode; });
 | 
						|
                    }
 | 
						|
                    //给其他人 发送待办 确认
 | 
						|
                    var listUser = users.Where(e => e.CHECK_ID == entity.ID && e.USER_ID != loginID);
 | 
						|
                    if (listUser == null || !listUser.Any())
 | 
						|
                    {
 | 
						|
                        //没有 别的检查人
 | 
						|
                        entity.STATUS = PFStandardStatus.Approving;
 | 
						|
                        //取审批流水码
 | 
						|
                        var sysFilter = new SystemCodeFilter();
 | 
						|
                        sysFilter.CodeType = (int)PFCodeRuleType.审批流编码;
 | 
						|
                        sysFilter.Count = 1;
 | 
						|
                        sysFilter.OrgId = entity.ORG_ID;
 | 
						|
                        var codes = CodeRuleService.NewGenSerial(sysFilter);
 | 
						|
                        var serialCode = codes.Split(new char[] { ',' });
 | 
						|
                        var approveCode = entity.CHECKTYPE == CheckType.Check ? "DM010" : "DM032";
 | 
						|
                        var sourceFormcode = entity.CHECKTYPE == CheckType.Check ? "DM010_SHOWPRINT" : "DM032_SHOWPRINT";
 | 
						|
                        MFlowPermitService.InsertApprove(serialCode[0], approveCode, "", entity.ID, sourceFormcode, entity.TaskID, true, () =>
 | 
						|
                        {
 | 
						|
                            if (entity != null)
 | 
						|
                                UpdateEntityNoCommit(entity);
 | 
						|
                            if (files != null && files.Any())
 | 
						|
                                BantchSaveEntityNoCommit(files);
 | 
						|
                            if (taskEnd != null)//结束待办
 | 
						|
                                UpdateEntityNoCommit(taskEnd);
 | 
						|
                            if (ListDetail != null && ListDetail.Any())//检查明细
 | 
						|
                                BantchSaveEntityNoCommit(ListDetail);
 | 
						|
                            if (users != null && users.Any())//检查明细
 | 
						|
                                BantchSaveEntityNoCommit(users);
 | 
						|
                            if (listTaskCheck != null && listTaskCheck.Any())//检查明细
 | 
						|
                                BantchSaveEntityNoCommit(listTaskCheck);
 | 
						|
                            if (anotherTask != null && anotherTask.Any())
 | 
						|
                                BantchSaveEntityNoCommit(anotherTask);
 | 
						|
                            if (detailFiles != null && detailFiles.Any())
 | 
						|
                                BantchSaveEntityNoCommit(detailFiles);
 | 
						|
                            if (deleteIds != null && deleteIds.Any())
 | 
						|
                                BantchDeleteEntityNoCommit<T_DM_DEVICE_CHECK_DETAIL_FILE>(deleteIds);
 | 
						|
                            if (repairs != null && repairs.Any())
 | 
						|
                                BantchSaveEntityNoCommit(repairs);
 | 
						|
                            if (repairFiles != null && repairFiles.Any())
 | 
						|
                                BantchSaveEntityNoCommit(repairFiles);
 | 
						|
                        }, null, null, null, null, null, sourceFormcode, null);
 | 
						|
                        return true;
 | 
						|
                    }
 | 
						|
                    else
 | 
						|
                    {
 | 
						|
                        entity.STATUS = PFStandardStatus.Sign;
 | 
						|
                        var UserId = listUser.Where(m => m.USER_ID != loginID).Select(t=>t.USER_ID).Distinct().ToList();
 | 
						|
                        var userName = new List<string>();
 | 
						|
                        var userInfos = this.GetEntities<T_FM_USER>(t => UserId.Contains(t.ID), new BaseFilter(entity.ORG_ID));
 | 
						|
                        foreach (var item in userInfos)
 | 
						|
                        {
 | 
						|
                            userName.Add(item.NAME);
 | 
						|
                        }
 | 
						|
 | 
						|
                        //listTaskCheck = NotificationTaskService.InsertUserNoticeTaskModels((entity.CHECKTYPE == CheckType.CheckCircuit ? "设备巡检" : "设备点检") + "确认" + (entity.CREATE_TIME.HasValue ? entity.CREATE_TIME.Value.ToString("MMdd") : ""), entity.ID, entity.ORG_ID, UserId, userName, DateTime.Now, DateTime.Now.AddDays(1), 1, "DM010_SHOWPRINT");
 | 
						|
 | 
						|
                        listTaskCheck = NotificationTaskService.InsertUserNoticeTaskModels((entity.CHECKTYPE == CheckType.CheckCircuit ? "设备设施巡检" : "设备设施点检") + "确认" + (entity.CREATE_TIME.HasValue ? entity.CREATE_TIME.Value.ToString("MMdd") : ""), entity.ID, entity.ORG_ID, UserId, userName, DateTime.Now, DateTime.Now.AddDays(1), 1, (entity.CHECKTYPE == CheckType.CheckCircuit ? "DM032_SHOWPRINT" : "DM010_SHOWPRINT"));
 | 
						|
                    }
 | 
						|
                }
 | 
						|
 | 
						|
                this.UnifiedCommit(() =>
 | 
						|
                {
 | 
						|
                    if (entity != null)
 | 
						|
                        UpdateEntityNoCommit(entity);
 | 
						|
                    if (files != null && files.Any())
 | 
						|
                        BantchSaveEntityNoCommit(files);
 | 
						|
                    if (taskEnd != null)//结束待办
 | 
						|
                        UpdateEntityNoCommit(taskEnd);
 | 
						|
                    if (ListDetail != null && ListDetail.Any())//检查明细
 | 
						|
                        BantchSaveEntityNoCommit(ListDetail);
 | 
						|
                    if (users != null && users.Any())//检查明细
 | 
						|
                        BantchSaveEntityNoCommit(users);
 | 
						|
                    if (listTaskCheck != null && listTaskCheck.Any())//检查明细
 | 
						|
                        BantchSaveEntityNoCommit(listTaskCheck);
 | 
						|
                    if (anotherTask != null && anotherTask.Any())
 | 
						|
                        BantchSaveEntityNoCommit(anotherTask);
 | 
						|
                    if (detailFiles != null && detailFiles.Any())
 | 
						|
                        BantchSaveEntityNoCommit(detailFiles);
 | 
						|
                    if (deleteIds != null && deleteIds.Any())
 | 
						|
                        BantchDeleteEntityNoCommit<T_DM_DEVICE_CHECK_DETAIL_FILE>(deleteIds);
 | 
						|
                    if (repairs != null && repairs.Any())
 | 
						|
                        BantchSaveEntityNoCommit(repairs);
 | 
						|
                    if (repairFiles != null && repairFiles.Any())
 | 
						|
                        BantchSaveEntityNoCommit(repairFiles);
 | 
						|
                });
 | 
						|
                return true;
 | 
						|
            });
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 点检人 确认
 | 
						|
        /// </summary>
 | 
						|
        [HttpPost, Route("Check")]
 | 
						|
        public JsonActionResult<bool> Check([FromBody] KeywordFilter filter)
 | 
						|
        {
 | 
						|
            return SafeExecute<bool>(() =>
 | 
						|
            {
 | 
						|
                if (string.IsNullOrEmpty(filter.Keyword) || string.IsNullOrEmpty(filter.Parameter1))
 | 
						|
                {
 | 
						|
                    throw new Exception("传参有误!");
 | 
						|
                }
 | 
						|
                var guid = new Guid(filter.Keyword);
 | 
						|
                var taskID = new Guid(filter.Parameter1);
 | 
						|
                if (guid == Guid.Empty || taskID == Guid.Empty)
 | 
						|
                {
 | 
						|
                    throw new Exception("传参有误!");
 | 
						|
                }
 | 
						|
                var task = NotificationTaskService.GetEntityTask(taskID);
 | 
						|
 | 
						|
                var loginID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
 | 
						|
                var Check = GetEntity<T_DM_DEVICE_CHECK_USER>(e => e.USER_ID == loginID && e.CHECK_ID == guid, "Nav_Check");
 | 
						|
 | 
						|
                if (Check == null)
 | 
						|
                {
 | 
						|
                    var DeviceCheck = GetEntity<T_DM_DEVICE_CHECK>(e => e.ID == guid); DeviceCheck.STATUS = PFStandardStatus.Archived;//状态修改
 | 
						|
                                                                                                                                      //记录人 上级 确认
 | 
						|
                    this.UnifiedCommit(() =>
 | 
						|
                    {
 | 
						|
                        if (task != null)
 | 
						|
                            UpdateEntityNoCommit(task);
 | 
						|
                        if (DeviceCheck != null)
 | 
						|
                            UpdateEntityNoCommit(DeviceCheck);
 | 
						|
                    });
 | 
						|
 | 
						|
                }
 | 
						|
                else if (Check.ISCHECK)
 | 
						|
                {
 | 
						|
                    this.UnifiedCommit(() =>
 | 
						|
                    {
 | 
						|
                        if (task != null)
 | 
						|
                            UpdateEntityNoCommit(task);
 | 
						|
                    });
 | 
						|
                    throw new Exception("您已审阅,无需再次操作!");
 | 
						|
                }
 | 
						|
                else
 | 
						|
                {
 | 
						|
                    Check.ISCHECK = true;
 | 
						|
                    var UnCheck = GetEntity<T_DM_DEVICE_CHECK_USER>(e => e.USER_ID != loginID && e.CHECK_ID == guid && !e.ISCHECK);
 | 
						|
 | 
						|
                    T_FM_NOTIFICATION_TASK taskMaster = null;
 | 
						|
 | 
						|
                    if (UnCheck == null)
 | 
						|
                    {
 | 
						|
                        //最后一个确认  记录人的 上级 审批
 | 
						|
                        Guid UserId = Guid.Empty;
 | 
						|
                        string userName = string.Empty;
 | 
						|
                        Guid DEPID = Guid.Empty;
 | 
						|
 | 
						|
                        var CheckMain = GetEntity<T_DM_DEVICE_CHECK_USER>(e => e.CHECK_ID == guid && e.ISMAIN, "Nav_User.Nav_Department");
 | 
						|
                        //if (CheckMain.Nav_User.Nav_Department.USER_ID != CheckMain.USER_ID)
 | 
						|
                        //{
 | 
						|
                        //    if (CheckMain.Nav_User.Nav_Department.USER_ID.HasValue)
 | 
						|
                        //    {
 | 
						|
 | 
						|
                        //        UserId = CheckMain.Nav_User.Nav_Department.USER_ID.Value;
 | 
						|
                        //    }
 | 
						|
                        //    else
 | 
						|
                        //    {
 | 
						|
                        //        DEPID = CheckMain.Nav_User.DEPARTMENT_ID.Value;
 | 
						|
                        //    }
 | 
						|
                        //}
 | 
						|
                        //else
 | 
						|
                        //{
 | 
						|
                        //    var dep = GetEntity<T_FM_DEPARTMENT>(CheckMain.Nav_User.Nav_Department.PARENT_ID.Value);
 | 
						|
                        //    if (dep.USER_ID.HasValue)
 | 
						|
                        //    {
 | 
						|
 | 
						|
                        //        UserId = dep.USER_ID.Value;
 | 
						|
                        //    }
 | 
						|
                        //    else
 | 
						|
                        //    {
 | 
						|
                        //        DEPID = dep.ID;
 | 
						|
                        //    }
 | 
						|
                        //}
 | 
						|
                        if (CheckMain != null && CheckMain.USER_ID != Guid.Empty)
 | 
						|
                        {
 | 
						|
                            //userName = GetEntity<T_FM_USER>(CheckMain.USER_ID).NAME;
 | 
						|
                            var DeviceCheck = GetEntity<T_DM_DEVICE_CHECK>(e => e.ID == guid); DeviceCheck.STATUS = PFStandardStatus.Approving;
 | 
						|
                            //取审批流水码
 | 
						|
                            var sysFilter = new SystemCodeFilter();
 | 
						|
                            sysFilter.CodeType = (int)PFCodeRuleType.审批流编码;
 | 
						|
                            sysFilter.Count = 1;
 | 
						|
                            sysFilter.OrgId = DeviceCheck.ORG_ID;
 | 
						|
                            var codes = CodeRuleService.NewGenSerial(sysFilter);
 | 
						|
                            var serialCode = codes.Split(new char[] { ',' });
 | 
						|
                            var approveCode = DeviceCheck.CHECKTYPE == CheckType.Check ? "DM010" : "DM032";
 | 
						|
                            var sourceFormcode= DeviceCheck.CHECKTYPE == CheckType.Check ? "DM010_SHOWPRINT":"DM032_SHOWPRINT";
 | 
						|
                            MFlowPermitService.InsertApprove(serialCode[0], approveCode, "", DeviceCheck.ID, sourceFormcode, Check.TaskID, true, () =>
 | 
						|
                            {
 | 
						|
                                if (DeviceCheck != null)
 | 
						|
                                    this.UpdateEntityNoCommit(DeviceCheck);
 | 
						|
                                //if (task != null)
 | 
						|
                                //    UpdateEntityNoCommit(task);
 | 
						|
                                if (Check != null)
 | 
						|
                                    UpdateEntityNoCommit(Check);
 | 
						|
                            }, null, CheckMain.USER_ID, null, null, null, sourceFormcode, null);
 | 
						|
                            return true;
 | 
						|
                        }
 | 
						|
                        else
 | 
						|
                        {
 | 
						|
                            //先不管
 | 
						|
                        }
 | 
						|
                        //if (UserId != Guid.Empty)
 | 
						|
                        //{
 | 
						|
                        //    if (UserId == loginID)
 | 
						|
                        //    {
 | 
						|
                        //        //自己就是 填表人的 上级 不发送待办
 | 
						|
 | 
						|
                        //    }
 | 
						|
                        //    else
 | 
						|
                        //    {
 | 
						|
                        //        taskMaster = NotificationTaskService.InsertUserNoticeTaskModel((Check.Nav_Check.CHECKTYPE == CheckType.CheckCircuit ? "设备巡检" : "设备点检") + "审阅", CheckMain.CHECK_ID, CheckMain.ORG_ID, UserId, userName, DateTime.Now, DateTime.Now.AddDays(1), 1, (Check.Nav_Check.CHECKTYPE == CheckType.CheckCircuit ? "DM032_SHOWPRINT" : "DM010_SHOWPRINT"));
 | 
						|
                        //    }
 | 
						|
                        //}
 | 
						|
                    }
 | 
						|
 | 
						|
                    //还有别人未 确认
 | 
						|
                    this.UnifiedCommit(() =>
 | 
						|
                    {
 | 
						|
                        if (task != null)
 | 
						|
                            UpdateEntityNoCommit(task);
 | 
						|
                        if (Check != null)
 | 
						|
                            UpdateEntityNoCommit(Check);
 | 
						|
                        if (taskMaster != null)
 | 
						|
                            UpdateEntityNoCommit(taskMaster);
 | 
						|
                    });
 | 
						|
                }
 | 
						|
                return true;
 | 
						|
            });
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 排序分页查询数据
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="pageFilter">分页过滤实体</param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpPost, Route("OrderPagedSuit")]
 | 
						|
        public PagedActionResult<T_DM_DEVICE_CHECK> OrderPaged([FromBody] KeywordPageFilter pageFilter)
 | 
						|
        {
 | 
						|
            return SafeGetPagedData(delegate (PagedActionResult<T_DM_DEVICE_CHECK> result)
 | 
						|
            {
 | 
						|
                if (!string.IsNullOrEmpty(pageFilter.MenuParameter) && pageFilter.MenuParameter.Contains("="))
 | 
						|
                {
 | 
						|
                    var listParm = pageFilter.MenuParameter.Split("=");
 | 
						|
                    pageFilter.FilterGroup.Rules.Add(new FilterRule()
 | 
						|
                    {
 | 
						|
                        Field = listParm[0],
 | 
						|
                        Value = listParm[1]
 | 
						|
                    });
 | 
						|
                }
 | 
						|
                var xxx = pageFilter.FilterGroup.Rules.FirstOrDefault(t => t.Field == "DEVICE_BASE_ID");
 | 
						|
                if (xxx != null)
 | 
						|
                {
 | 
						|
                    var run = this.GetEntity<T_DM_TIME_RUN>(t=>t.ID == Guid.Parse(xxx.Value.ToString()));
 | 
						|
                    pageFilter.FilterGroup = new FilterGroup();
 | 
						|
                    var type = run.SET_TYPE == DMSetTypeEnum.Check ? CheckType.Check : CheckType.CheckCircuit;
 | 
						|
                    PagedActionResult <T_DM_DEVICE_CHECK> orderPageEntities = GetOrderPageEntities<T_DM_DEVICE_CHECK>(t=>t.DEVICEBASE_ID == run.DEVICE_BASE_ID && t.STATUS == PFStandardStatus.Archived && t.CHECKTYPE == type, pageFilter, null);
 | 
						|
                    result.Data = orderPageEntities.Data;
 | 
						|
                    result.TotalCount = orderPageEntities.TotalCount;
 | 
						|
                }
 | 
						|
                else
 | 
						|
                {
 | 
						|
                    PagedActionResult<T_DM_DEVICE_CHECK> orderPageEntities = GetOrderPageEntities<T_DM_DEVICE_CHECK>(null, pageFilter, null);
 | 
						|
                    result.Data = orderPageEntities.Data;
 | 
						|
                    result.TotalCount = orderPageEntities.TotalCount;
 | 
						|
                }
 | 
						|
                
 | 
						|
            });
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 获得单条实体数据
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="filter">过滤实体</param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpPost, Route("GetSuit")]
 | 
						|
        public JsonActionResult<T_DM_DEVICE_CHECK> GetSuit([FromBody] KeywordFilter filter)
 | 
						|
        {
 | 
						|
            return SafeExecute(() =>
 | 
						|
            {
 | 
						|
                var result = GetEntity<T_DM_DEVICE_CHECK>(null, filter, null);
 | 
						|
                if (result.Nav_ListUser != null && result.Nav_ListUser.Any())
 | 
						|
                {
 | 
						|
                    result.Nav_ListUser = result.Nav_ListUser.OrderByDescending(e => e.ISMAIN).ToList();
 | 
						|
                }
 | 
						|
                return result;
 | 
						|
            });
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 回调函数
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="id"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpGet, Route("BackUpdate")]
 | 
						|
        public JsonActionResult<bool> BackUpdate(string id)
 | 
						|
        {
 | 
						|
            return SafeExecute(() =>
 | 
						|
            {
 | 
						|
                return ApproveCallBackService.CallBack("DM/DMDeviceCheck/BackUpdate", id);
 | 
						|
            });
 | 
						|
        }
 | 
						|
    }
 | 
						|
} |