WeldTechnologyController.cs 10.4 KB
using Hh.Mes.Common.Request;
using Hh.Mes.POJO.Entity;
using Hh.Mes.POJO.Response;
using Hh.Mes.Service;
using Hh.Mes.Service.Configure;
using Hh.Mes.Service.SystemAuth;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
using WebMvc.Aop;

namespace WebMvc.Areas.configure.Controllers
{
    /// <summary>
    /// 焊接工艺
    /// </summary>
    [Area("configure")]
    public class WeldTechnologyController : BaseController
    {
        private readonly WeldTechnologyService weldTechnologyService;
        private readonly IWebHostEnvironment hostingEnvironment;

        public WeldTechnologyController(IAuth authUtil, WeldTechnologyService service, IWebHostEnvironment hostingEnvironment) : base(authUtil)
        {
            this.weldTechnologyService = service;
            weldTechnologyService.sysWebUser = authUtil.GetCurrentUser().User;
            this.hostingEnvironment = hostingEnvironment;
        }



        #region 视图功能
        /// <summary>
        /// 默认视图Action
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            return View();
        }

        /// <summary>
        /// 打印页面展示
        /// </summary>
        /// <returns></returns>
        public ActionResult PrintView(int id)
        {
            var data = weldTechnologyService.GetPrintInfo(id);
            ViewData.Model = data;
            return View();
        }
        #endregion

        
        #region 获取数据
        /// <summary>
        /// 加载及分页查询
        /// </summary>
        /// <param name="pageRequest">表单请求信息</param>
        /// <param name="entity">请求条件实例</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<string> Load(PageReq pageRequest, base_weld_technology_head entity)
        {
            var dataResult = await weldTechnologyService.GetWeldTechnologyHeadList(pageRequest, entity);
            var dataTable = dataResult.Tables[0];
            var retrunResult = new Response
            {
                Result = dataTable,
                //count = entity.Exel ? dataTable.Rows.Count : (int)dataResult.Tables[1].Rows[0]["rowTotal"]
            };
            return Serialize(retrunResult);
        }



        /// <summary>
        /// 加载及分页查询
        /// </summary>
        /// <param name="pageRequest">表单请求信息</param>
        /// <param name="entity">请求条件实例</param>
        /// <returns></returns>
        [HttpPost]
        public string LoadDesc(PageReq pageRequest, base_weld_technology_detail entity)
        {
            return Serialize(weldTechnologyService.GetWeldTechnologyBodyList(pageRequest, entity));
        }

        #endregion

        #region 提交数据
        /// <summary>
        /// 新增数据
        /// </summary>
        /// <param name="excelfile">新增实例</param>
        /// <returns></returns>
        [HttpPost]
        [XSSFilter]
        [ServiceFilter(typeof(OperLogFilter))]
        public string Ins(IFormFileCollection excelfile)
        {
            var model = new base_weld_technology_head
            {
                MaterialGrade = Request.Form["MaterialGrade"],
                Diameter = Convert.ToDecimal(Request.Form["Diameter"]),
                Thickness = Convert.ToDecimal(Request.Form["Thickness"]),
                MaterialCode = Request.Form["MaterialCode"],
                WeldingWire = Request.Form["WeldingWire"],

                GrooveAngle = Convert.ToDecimal(Request.Form["GrooveAngle"]),
                RootFace = Convert.ToInt32(Request.Form["RootFace"]),
                Interval = Convert.ToInt32(Request.Form["Interval"]),
                ErrorVariable = Convert.ToDecimal(Request.Form["ErrorVariable"]),
                PreheatingTemperature = Convert.ToDecimal(Request.Form["PreheatingTemperature"]),

                PreheatingTime = Convert.ToDecimal(Request.Form["PreheatingTime"]),
                InterlaminarTemperature = Convert.ToDecimal(Request.Form["InterlaminarTemperature"]),
                TreatmentTemperature = Convert.ToDecimal(Request.Form["TreatmentTemperature"]),
                ProcessingTime = Request.Form["ProcessingTime"],
                ToolingSystem = Request.Form["ToolingSystem"],

                ToolingShapeAndSize = Convert.ToDecimal(Request.Form["ToolingShapeAndSize"]),
                WeldingPowerSource = Request.Form["WeldingPowerSource"],
                WeldingGunModel = Request.Form["WeldingGunModel"],
                WeldingBrand = Request.Form["WeldingBrand"],
                WeldingSpecs = Request.Form["WeldingSpecs"],

                WeldingGas = Request.Form["WeldingGas"],
                WeldingPosition = Request.Form["WeldingPosition"],
                WeldingDirection = Request.Form["WeldingDirection"],
                WeldingStroke = Request.Form["WeldingStroke"],
                ElectricCurrentForm = Request.Form["ElectricCurrentForm"],

                OutputPolarity = Request.Form["OutputPolarity"],
                Remark = Request.Form["Remark"],
                Recorder = Request.Form["Recorder"],
                RecordingTime = Convert.ToDateTime(Request.Form["RecordingTime"]),
                AuditBy = Request.Form["AuditBy"],

                AuditTime = Convert.ToDateTime(Request.Form["AuditTime"]),
                isFileChange = Convert.ToBoolean(Request.Form["isFileChange"])
            };
            var result = weldTechnologyService.Ins(model, excelfile, hostingEnvironment.ContentRootPath);
            return Serialize(result);
        }

        /// <summary>
        /// 修改数据
        /// </summary>
        /// <param name="excelfile">修改实例</param>
        /// <returns></returns>
        [HttpPost]
        [XSSFilter]
        [ServiceFilter(typeof(OperLogFilter))]
        public string Upd(IFormFileCollection excelfile)
        {
            var model = new base_weld_technology_head
            {
                id = Convert.ToInt32(Request.Form["id"]),
                MaterialGrade = Request.Form["MaterialGrade"],
                Diameter = Convert.ToDecimal(Request.Form["Diameter"]),
                Thickness = Convert.ToDecimal(Request.Form["Thickness"]),
                MaterialCode = Request.Form["MaterialCode"],
                WeldingWire = Request.Form["WeldingWire"],

                GrooveAngle = Convert.ToDecimal(Request.Form["GrooveAngle"]),
                RootFace = Convert.ToInt32(Request.Form["RootFace"]),
                Interval = Convert.ToInt32(Request.Form["Interval"]),
                ErrorVariable = Convert.ToDecimal(Request.Form["ErrorVariable"]),
                PreheatingTemperature = Convert.ToDecimal(Request.Form["PreheatingTemperature"]),

                PreheatingTime = Convert.ToDecimal(Request.Form["PreheatingTime"]),
                InterlaminarTemperature = Convert.ToDecimal(Request.Form["InterlaminarTemperature"]),
                TreatmentTemperature = Convert.ToDecimal(Request.Form["TreatmentTemperature"]),
                ProcessingTime = Request.Form["ProcessingTime"],
                ToolingSystem = Request.Form["ToolingSystem"],

                ToolingShapeAndSize = Convert.ToDecimal(Request.Form["ToolingShapeAndSize"]),
                WeldingPowerSource = Request.Form["WeldingPowerSource"],
                WeldingGunModel = Request.Form["WeldingGunModel"],
                WeldingBrand = Request.Form["WeldingBrand"],
                WeldingSpecs = Request.Form["WeldingSpecs"],

                WeldingGas = Request.Form["WeldingGas"],
                WeldingPosition = Request.Form["WeldingPosition"],
                WeldingDirection = Request.Form["WeldingDirection"],
                WeldingStroke = Request.Form["WeldingStroke"],
                ElectricCurrentForm = Request.Form["ElectricCurrentForm"],

                OutputPolarity = Request.Form["OutputPolarity"],
                Remark = Request.Form["Remark"],
                Recorder = Request.Form["Recorder"],
                RecordingTime = Convert.ToDateTime(Request.Form["RecordingTime"]),
                AuditBy = Request.Form["AuditBy"],

                AuditTime = Convert.ToDateTime(Request.Form["AuditTime"]),
                isFileChange = Convert.ToBoolean(Request.Form["isFileChange"])
            };
            var result = weldTechnologyService.Upd(model, excelfile, hostingEnvironment.ContentRootPath);
            return Serialize(result);
        }

        [HttpPost]
        [ServiceFilter(typeof(OperLogFilter))]
        public string DelByIds(int[] ids)
        {
            var result = weldTechnologyService.DelByIds(ids);
            return Serialize(result);
        }




        /// <summary>
        /// 新增明细数据
        /// </summary>
        /// <param name="entity">新增实例</param>
        /// <returns></returns>
        [HttpPost]
        [XSSFilter]
        [ServiceFilter(typeof(OperLogFilter))]
        public string InsDesc(base_weld_technology_detail entity)
        {
            var result = weldTechnologyService.InsDesc(entity);
            return Serialize(result);
        }

        /// <summary>
        /// 修改明细数据
        /// </summary>
        /// <param name="entity">修改实例</param>
        /// <returns></returns>
        [HttpPost]
        [XSSFilter]
        [ServiceFilter(typeof(OperLogFilter))]
        public string UpdDesc(base_weld_technology_detail entity)
        {
            var result = weldTechnologyService.UpdDesc(entity);
            return Serialize(result);
        }

        [HttpPost]
        [ServiceFilter(typeof(OperLogFilter))]
        public string DelByIdsDesc(int[] ids)
        {
            var result = weldTechnologyService.DelByIdsDesc(ids);
            return Serialize(result);
        }
        #endregion

        #region 导出数据
        /// <summary>
        /// 导出数据
        /// </summary>
        /// <param name="entity">请求条件实例</param>
        /// <returns></returns>
        [HttpPost]
        public async Task< string> Export(base_weld_technology_head entity)
        {
            var dataResult = await weldTechnologyService.GetWeldTechnologyHeadList(null, entity);
            var retrunResult = new Response
            {
                Result = dataResult.Tables[0],
                Count=dataResult.Tables[0].Rows.Count
            };
            return Serialize(retrunResult);
        }
        #endregion

        #region 自定义方法

        #endregion
    }
}