ManualMaterialLoading.cs 2.96 KB
using Hh.Mes.Pojo.System;
using Hh.Mes.POJO.Entity;
using Hh.Mes.POJO.EnumEntitys;
using Hh.Mes.POJO.Request;
using Hh.Mes.Service.Distribution;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Linq;
using Hh.Mes.POJO.Response;
using Hh.Mes.Service.SystemAuth;

namespace WebMvc.Areas.wo.Controllers
{
    #region 人工装料

    /// <summary>
    /// 人工装料
    /// </summary>
    [Area("distribution")]
    public class ManualMaterialLoadingController : BaseController
    {
        private readonly MaterialDistributeLoadDataService service;

        public ManualMaterialLoadingController(IAuth authUtil, MaterialDistributeLoadDataService service) : base(authUtil)
        {
            this.service = service;
            var user = authUtil.GetCurrentUser();
            if (user != null)
            {
                this.service.sysWebUser = user.User;
            }

        }

        #region 视图功能

        public IActionResult Index()
        {
            return View();
        }
        #endregion

        #region 获取数据

        /// <summary>
        /// 加载装料头数据
        /// </summary>
        [HttpPost]
        public string LoadHead()
        {
            return Serialize(service.GteChargeAreaData("loadGroupCode"));
        }

        /// <summary>
        /// 加载装料叫料点
        /// </summary>
        [HttpPost]
        public string LoadData(string keys)
        {
            return Serialize(service.GetChargeData(keys));
        }

        /// <summary>
        /// 料点对应装料点查询
        /// </summary>
        [HttpPost]
        public string GetLocationRelData(string locationCode)
        {
            return Serialize(service.GetLocationRelData(locationCode));
        }


        #endregion

        #region 提交数据

        #endregion

        #region 自定义方法
        /// <summary>
        /// 装料操作
        /// </summary>
        [HttpPost]
        public string LoadingCharge(bus_material_distribute_load model)
        {
            return Serialize(service.LoadingCharge(model));
        }
        #endregion

        #region ECS交互
        /// <summary>
        /// 收取ECS发送过来的叫料请求
        /// </summary>
        [HttpPost]
        public string ECSLoadingAsking([FromBody] RequestData<List<string>> requestData)
        {
            //初始化
            service.IniLocationVm();

            foreach (var item in requestData.Data)
            {
                var locationItem = SystemVariable.locationList.Where(x => x.locationCode == item).FirstOrDefault();
                if (locationItem != null && locationItem.askingStatus == (int)EnumLocationAskingStatus.未叫料) 
                {
                    service.UpLocationVm(item, EnumLocationAskingStatus.已叫料);
                }
            }

            var response = new Response();
            return Serialize(response);
        }

        #endregion
    }

    #endregion
}