using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using BLL;
namespace WebAPI.Controllers
{
    /// 
    /// 点口,委托,无损检测
    /// 
    public class NDETrustController : ApiController
    {
        #region 点口
        /// 
        /// 选择单位工程、探伤类型、探伤比例、点口批号获取需要进行点口的批,自动点口调用
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        public Model.ResponeData getAutoPointBatchCode(string unitWorkId, string detectionTypeId, string detectionRateId, string pointBatchCode)
        {
            var responeData = new Model.ResponeData();
            try
            {
                responeData.data = APINDETrustService.getAutoPointBatchCode(unitWorkId, detectionTypeId, pointBatchCode, pointBatchCode);
            }
            catch (Exception ex)
            {
                responeData.code = 0;
                responeData.message = ex.Message;
            }
            return responeData;
        }
        /// 
        /// 根据单位工程、点口批号、批开始时间获取需要调整的批(已点口但还未进行委托的批列表)
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        public Model.ResponeData getPointBatchCode(string unitWorkId, string detectionTypeId, string detectionRateId, string pointBatchCode)
        {
            var responeData = new Model.ResponeData();
            try
            {
                responeData.data = APINDETrustService.getPointBatchCode(unitWorkId, detectionTypeId, pointBatchCode, pointBatchCode);
            }
            catch (Exception ex)
            {
                responeData.code = 0;
                responeData.message = ex.Message;
            }
            return responeData;
        }
        /// 
        /// 根据点口批ID获取批明细(自动点口调用呈现)
        /// 
        /// 
        /// 
        public Model.ResponeData getPointBatchDetail(string pointBatchId)
        {
            var responeData = new Model.ResponeData();
            try
            {
                responeData.data = APINDETrustService.getPointBatchDetail(pointBatchId);
            }
            catch (Exception ex)
            {
                responeData.code = 0;
                responeData.message = ex.Message;
            }
            return responeData;
        }
        /// 
        /// 根据点口批ID获取已点口还未审批的焊口
        /// 
        /// 
        /// 
        public Model.ResponeData getPointWeldJoint(string pointBatchId)
        {
            var responeData = new Model.ResponeData();
            try
            {
                responeData.data = APINDETrustService.getPointWeldJoint(pointBatchId);
            }
            catch (Exception ex)
            {
                responeData.code = 0;
                responeData.message = ex.Message;
            }
            return responeData;
        }
        /// 
        /// 根据点口批ID和焊口ID获取待调整焊口
        /// 
        /// 
        /// 
        /// 
        public Model.ResponeData getPointWeldJoint(string pointBatchId, string weldJointId)
        {
            var responeData = new Model.ResponeData();
            try
            {
                responeData.data = APINDETrustService.getPointWeldJoint(pointBatchId, weldJointId);
            }
            catch (Exception ex)
            {
                responeData.code = 0;
                responeData.message = ex.Message;
            }
            return responeData;
        }
        /// 
        /// 根据单位工程获取所有已点的焊口列表
        /// 
        /// 
        /// 
        public Model.ResponeData GetPointWeldJointList(string unitWorkId)
        {
            var responeData = new Model.ResponeData();
            try
            {
                responeData.data = APINDETrustService.GetPointWeldJointList(unitWorkId);
            }
            catch (Exception ex)
            {
                responeData.code = 0;
                responeData.message = ex.Message;
            }
            return responeData;
        }
        /// 
        /// 对所选批次进行自动点口
        /// 
        /// 
        /// 
        public Model.ResponeData getAutoPointSave(string pointBatchId)
        {
            var responeData = new Model.ResponeData();
            try
            {
                APINDETrustService.AutoPointSave(pointBatchId);
            }
            catch (Exception ex)
            {
                responeData.code = 0;
                responeData.message = ex.Message;
            }
            return responeData;
        }
        /// 
        /// 点口调整 
        /// 
        /// 
        /// 
        /// 
        public Model.ResponeData getRePointSave(string oldJointId, string newJointId)
        {
            var responeData = new Model.ResponeData();
            try
            {
                APINDETrustService.RePointSave(oldJointId, newJointId);
            }
            catch (Exception ex)
            {
                responeData.code = 0;
                responeData.message = ex.Message;
            }
            return responeData;
        }
        /// 
        /// 根据单位工程获取所有已点的焊口生成委托单
        /// 
        /// 
        /// 
        public Model.ResponeData getGenerateTrust(string unitWorkId)
        {
            var responeData = new Model.ResponeData();
            try
            {
                APINDETrustService.GenerateTrust(unitWorkId);
            }
            catch (Exception ex)
            {
                responeData.code = 0;
                responeData.message = ex.Message;
            }
            return responeData;
        }
        #endregion
        #region 无损委托
        /// 
        /// 选择单位工程、探伤类型、探伤比例、委托单号等获取委托单
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        public Model.ResponeData getBatchTrustCode(string unitWorkId, string detectionTypeId, string detectionRateId, bool? isAudit, string trustBatchCode)
        {
            var responeData = new Model.ResponeData();
            try
            {
                responeData.data = APINDETrustService.getBatchTrustCode(unitWorkId, detectionTypeId, detectionRateId, isAudit, trustBatchCode);
            }
            catch (Exception ex)
            {
                responeData.code = 0;
                responeData.message = ex.Message;
            }
            return responeData;
        }
        /// 
        /// 选择委托单ID获取委托单明细信息
        /// 
        /// 
        /// 
        public Model.ResponeData getBatchTrustDetail(string trustBatchId)
        {
            var responeData = new Model.ResponeData();
            try
            {
                responeData.data = APINDETrustService.GetBatchTrustDetail(trustBatchId);
            }
            catch (Exception ex)
            {
                responeData.code = 0;
                responeData.message = ex.Message;
            }
            return responeData;
        }
        /// 
        /// 对所选委托单进行审核
        /// 
        /// 
        /// 
        public Model.ResponeData getBatchTrustAudit(string trustBatchId)
        {
            var responeData = new Model.ResponeData();
            try
            {
                APINDETrustService.BatchTrustAudit(trustBatchId);
            }
            catch (Exception ex)
            {
                responeData.code = 0;
                responeData.message = ex.Message;
            }
            return responeData;
        }
        #endregion
        #region 无损检测单
        /// 
        /// 选择单位工程、探伤类型、检测单号获取检测单
        /// 
        /// 
        /// 
        /// 
        /// 
        public Model.ResponeData getBatchNdeCode(string unitWorkId, string detectionTypeId, string ndeCode)
        {
            var responeData = new Model.ResponeData();
            try
            {
                responeData.data = APINDETrustService.getBatchNdeCode(unitWorkId, detectionTypeId, ndeCode);
            }
            catch (Exception ex)
            {
                responeData.code = 0;
                responeData.message = ex.Message;
            }
            return responeData;
        }
        /// 
        /// 根据检测单ID获取检测单明细
        /// 
        /// 
        /// 
        public Model.ResponeData getBatchNDEDetail(string ndeId)
        {
            var responeData = new Model.ResponeData();
            try
            {
                responeData.data = APINDETrustService.GetBatchNDEDetail(ndeId);
            }
            catch (Exception ex)
            {
                responeData.code = 0;
                responeData.message = ex.Message;
            }
            return responeData;
        }
        #endregion
        #region 返修/扩透
        /// 
        /// 获取返修单列表
        /// 
        /// 
        /// 
        /// 
        /// 
        public Model.ResponeData GetRepairRecord(string unitWorkId, bool isAudit, string repairRecordCode)
        {
            var responeData = new Model.ResponeData();
            try
            {
                responeData.data = APINDETrustService.GetRepairRecord(unitWorkId, isAudit, repairRecordCode);
            }
            catch (Exception ex)
            {
                responeData.code = 0;
                responeData.message = ex.Message;
            }
            return responeData;
        }
        /// 
        /// 获取返修单信息
        /// 
        /// 
        /// 
        public Model.ResponeData GetRepairInfoByRepairRecordId(string repairRecordId)
        {
            var responeData = new Model.ResponeData();
            try
            {
                responeData.data = APINDETrustService.GetRepairInfoByRepairRecordId(repairRecordId);
            }
            catch (Exception ex)
            {
                responeData.code = 0;
                responeData.message = ex.Message;
            }
            return responeData;
        }
        /// 
        /// 根据条件获取可选取扩透口的批明细
        /// 
        /// 
        /// 同焊工
        /// 同管线
        /// 同一天
        /// 返修前所焊
        /// 同材质
        /// 同规格
        /// 
        public Model.ResponeData GetRepairExpDetail(string repairRecordId, bool welder, bool pipeLine, bool daily, bool repairBefore, bool mat, bool spec)
        {
            var responeData = new Model.ResponeData();
            try
            {
                responeData.data = APINDETrustService.GetRepairExpDetail(repairRecordId, welder, pipeLine, daily, repairBefore, mat, spec);
            }
            catch (Exception ex)
            {
                responeData.code = 0;
                responeData.message = ex.Message;
            }
            return responeData;
        }
        /// 
        /// 获取扩透口的随机数
        /// 
        /// 
        /// 
        public Model.ResponeData GetRandomExport(int num)
        {
            var responeData = new Model.ResponeData();
            try
            {
                responeData.data = APINDETrustService.RandomExport(num);
            }
            catch (Exception ex)
            {
                responeData.code = 0;
                responeData.message = ex.Message;
            }
            return responeData;
        }
        /// 
        /// 保存返修/扩透口信息
        /// 
        /// 返修ID
        /// 扩透口ID(多个用“,”号隔开)
        /// 返修焊工
        /// 返修日期
        /// 是否切除
        public Model.ResponeData GetRepairExpSaveInfo(string repairRecordId, string expandId, string repairWelder, string repairDate, bool isCut)
        {
            var responeData = new Model.ResponeData();
            try
            {
                APINDETrustService.GetRepairExpSaveInfo(repairRecordId, expandId, repairWelder, repairDate, isCut);
            }
            catch (Exception ex)
            {
                responeData.code = 0;
                responeData.message = ex.Message;
            }
            return responeData;
        }
        /// 
        /// 返修单审核
        /// 
        /// 
        /// 
        public Model.ResponeData GetRepairAudit(string repairRecordId)
        {
            var responeData = new Model.ResponeData();
            try
            {
                APINDETrustService.RepairAudit(repairRecordId);
            }
            catch (Exception ex)
            {
                responeData.code = 0;
                responeData.message = ex.Message;
            }
            return responeData;
        }
        /// 
        /// 生成返修委托单
        /// 
        /// 
        /// 
        public Model.ResponeData GetGenerateRepairTrust(string repairRecordId)
        {
            var responeData = new Model.ResponeData();
            try
            {
                responeData.data = APINDETrustService.GenerateRepairTrust(repairRecordId);
            }
            catch (Exception ex)
            {
                responeData.code = 0;
                responeData.message = ex.Message;
            }
            return responeData;
        }
        #endregion
        #region NDE预警
        /// 
        /// 无损检测不合格焊口信息
        /// 
        /// 
        /// 
        public Model.ResponeData GetNdeCheckNoPassWarn(string projectId)
        {
            var responeData = new Model.ResponeData();
            try
            {
                responeData.data = APINDETrustService.GetNdeCheckNoPassWarn(projectId);
            }
            catch (Exception ex)
            {
                responeData.code = 0;
                responeData.message = ex.Message;
            }
            return responeData;
        }
        /// 
        /// 未委托焊口预警
        /// 
        /// 
        /// 
        public Model.ResponeData GetNoTrustJointWarn(string projectId)
        {
            var responeData = new Model.ResponeData();
            try
            {
                responeData.data = APINDETrustService.GetNoTrustJointWarn(projectId);
            }
            catch (Exception ex)
            {
                responeData.code = 0;
                responeData.message = ex.Message;
            }
            return responeData;
        }
        /// 
        /// 未检测焊口预警
        /// 
        /// 
        /// 
        public Model.ResponeData GetNoCheckJointWarn(string projectId)
        {
            var responeData = new Model.ResponeData();
            try
            {
                responeData.data = APINDETrustService.GetNoTrustJointWarn(projectId);
            }
            catch (Exception ex)
            {
                responeData.code = 0;
                responeData.message = ex.Message;
            }
            return responeData;
        }
        #endregion
    }
}