UpstreamController.cs 5.97 KB
using Hh.Mes.POJO.ApiEntity;
using Hh.Mes.POJO.EnumEntitys;
using Hh.Mes.POJO.Response;
using Hh.Mes.Service;
using Hh.Mes.Service.ApiService;
using Hh.Mes.Service.WebService.Wo;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.IO;
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using System.Linq;
using Hh.Mes.POJO.Entity;
using System.Collections.Generic;

namespace Hh.Mes.Api.Controllers
{
    /// <summary>
    /// 上游系统接口
    /// ps:新增方法需要在SystemVariable 注册 APIList、EnumLog 新增枚举 ,方便接口日志定位查询
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UpstreamController : BaseController
    {
        private readonly UpstreamService service;
        private readonly CutWeldService cutWeldService;

        public UpstreamController(UpstreamService service, CutWeldService cutweldService, IHttpContextAccessor accessor, IWebHostEnvironment env)
        {
            this.service = service;
            context = accessor.HttpContext;
            this.cutWeldService = cutweldService;
        }

        /// <summary>
        /// 物料主数据 MOM_HH_001
        /// http://127.0.0.1:10008/api/Upstream/Mes/V1/SendMaterial
        /// </summary>
        [HttpPost]
        [ActionName("Mes/V1/SendMaterial")]
        public string SendMaterial(MaterialEntity requestData)
        {
            var result = service.SendMaterial(requestData);
            return Serialize(result);
        }

        /// <summary>
        /// 工艺路线 MOM_HH_002
        /// http://127.0.0.1:10008/api/Upstream/Mes/V1/SendProcessRoute
        /// </summary>
        [HttpPost]
        [ActionName("Mes/V1/SendProcessRoute")]
        public string SendProcessRoute(MomProcessRouteHeadEntity requestData)
        {
            var result = service.SendProcessRoute(requestData);
            return Serialize(result);
        }

        /// <summary>
        /// 人员信息 MOM_HH_003
        /// http://127.0.0.1:10008/api/Upstream/Mes/V1/SendUser
        /// </summary>
        [HttpPost]
        [ActionName("Mes/V1/SendUser")]
        public string SendUser(SysUserEntity requestData)
        {
            return Serialize(service.SendUser(requestData));
        }

        /// <summary>
        /// 供应商信息  MOM_HH_004
        /// </summary>
        [HttpPost]
        [ActionName("Mes/V1/SendSupplier")]
        public string SendSupplier(SupplierEntity requestData)
        {
            return Serialize(service.SendSupplier(requestData));
        }

        /// <summary>
        /// 生产订单  MOM_HH_005
        /// </summary>
        [HttpPost]
        [ActionName("Mes/V1/SendWorkOrder")]
        public string SendWorkOrder(MomWorkOrderHead requestData)
        {
            return Serialize(service.SendWorkOrder(requestData));
        }

        /// <summary>
        /// 工作日历
        /// </summary>
        [HttpPost]
        [ActionName("Mes/V1/SendCalendar")]
        public string SendCalendar(CalendarEntity requestData)
        {
            return Serialize(service.SendCalendar(requestData));
        }

        /// <summary>
        /// 质量问题状态
        /// </summary>
        [HttpPost]
        [ActionName("Mes/V1/SendCheck")]
        public string SendCheck(QualityFeedbackEntity requestData)
        {
            return Serialize(service.SendCheck(requestData));
        }

        /// <summary>
        /// 产线中控将工序执行信息反馈MOM
        /// </summary>
        [HttpPost]
        [ActionName("Mes/V1/ProcessRouteUpMom")]
        public string ProcessRouteUpMom(ProcessRouteUpMomEntity routeUpMomEntity)
        {
            return Serialize(service.ProcessRouteUpMom(routeUpMomEntity));
        }

        /// <summary>
        /// ANDON报警
        /// </summary>
        [HttpPost]
        [ActionName("Mes/V1/AndonUpMom")]
        public string AndonUpMom(AndonUpMomEntity andonUpMomEntity)
        {
            return Serialize(service.AndonUpMom(andonUpMomEntity));
        }

        /// <summary>
        /// 获取MOM请求Token
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public string GetMomToken()
        {
            return Serialize(service.GetMomToken());
        }


        /// <summary>
        /// 信科物料基础信息 同步
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [ActionName("Mes/V1/MaterialUpCict")]
        public string MaterialUpCict()
        {
            return Serialize(service.MaterialUpCict());
        }

        /// <summary>
        /// ECS(切割的开工、完工)工序完工反馈
        /// </summary>
        [HttpPost]
        [ActionName("Mes/V1/ProcedureEndBack")]
        public string ProcedureEndBack(ProcedureEndEntity procedureEndEntity)
        {
            var response = new Response(true);
            cutWeldService.SendIWPTechnologylineProcess(procedureEndEntity.barCode, procedureEndEntity.enumCutHeadState);
            return Serialize(response);
        }

        /// <summary>
        /// 设备状态查询
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [ActionName("Mes/V1/GetEquipmentType")]
        public string GetEquipmentType(string code)
        {
            return Serialize(service.GetEquipmentType(code));
        }

        /// <summary>
        /// 服务端心跳
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [ActionName("Mes/V1/GetServicesHeartbeat")]
        public string GetServicesHeartbeat()
        {
            return Serialize("ok");
        }

        #region ep3d相关

        /// <summary>
        /// ep3d数据推送接收接口
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionName("Mes/V1/ep3dDataPush")]
        public string ep3dDataPush(productionOrderList list)
        {
            return Serialize(service.ep3dDataPush(list));
        }
        #endregion
    }
}