PDAController.cs 13 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413
using System;
using System.Collections.Generic;
using System.Linq;
using Hh.Mes.Api.Controllers;
using Hh.Mes.Common.Json;
using Hh.Mes.Common.log;
using Hh.Mes.POJO.ApiEntity;
using Hh.Mes.POJO.Entity;
using Hh.Mes.POJO.EnumEntitys;
using Hh.Mes.POJO.Response;
using Hh.Mes.POJO.WebEntity.api;
using Hh.Mes.Service;
using Hh.Mes.Service.WebService.Planned;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Headers;
using Microsoft.AspNetCore.Mvc;

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

        public PDAController(PDAService pdaService, IHttpContextAccessor accessor)
        {

            service = pdaService;
            context = accessor.HttpContext;

            var sysUserApi = base.GetUser(context);
            this.service.sysUserApi = sysUserApi;
        }


        /// <summary>
        /// PDA物料追溯查询
        /// 1:使用动态类型、或者使用实体类
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionName("Mes/V1/GetMaterialByPDABarCode")]
        public string GetMaterialInfoByBarCode(dynamic requestData)
        {
            var result = service.GetMaterialInfoByBarCode(requestData);
            return Serialize(result);
        }

        #region 组对、焊接

        /// <summary>
        /// 获取匹配的组对信息
        /// </summary>
        /// <param name="station">工位码</param>
        /// <param name="pipe">管段码</param>
        /// <param name="batch">批次码</param>
        /// <returns></returns>
        [HttpGet]
        [ActionName("Mes/V1/GetMatchTeamList")]
        public string GetMatchTeamList(string station, string pipe, string batch)
        {
            var result = service.GetMatchTeamList(station,pipe, batch);
            return JsonHelper.Instance.Serialize(result);
        }

        /// <summary>
        /// 获取组对开始列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [ActionName("Mes/V1/GetTeamStartList")]
        public string GetTeamStartList()
        {
            var result = service.GetTeamStartList();
            return JsonHelper.Instance.Serialize(result);
        }


        /// <summary>
        /// 保存组对开始列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionName("Mes/V1/SaveTeamStartList")]
        public string SaveTeamStartList(List<bus_workOrder_detail> details)
        {
            var result = service.SaveTeamStartList(details);
            return JsonHelper.Instance.Serialize(result);
        }


        /// <summary>
        /// 保存组对结束列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionName("Mes/V1/SaveTeamEndList")]
        public string SaveTeamEndList(List<bus_workOrder_detail> details)
        {
            var result = service.SaveTeamEndList(details);
            return JsonHelper.Instance.Serialize(result);
        }

        /// <summary>
        /// 获取匹配的焊接信息
        /// </summary>
        /// <param name="station">工位码</param>
        /// <param name="batch">批次码</param>
        /// <returns></returns>
        [HttpGet]
        [ActionName("Mes/V1/GetMatchWeldList")]
        public string GetMatchWeldList(string station, string pipe)
        {
            var result = service.GetMatchWeldList(station,pipe);
            return JsonHelper.Instance.Serialize(result);
        }

        /// <summary>
        /// 获取焊接开始列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [ActionName("Mes/V1/GetWeldStartList")]
        public string GetWeldStartList()
        {
            var result = service.GetWeldStartList();
            return JsonHelper.Instance.Serialize(result);
        }


        /// <summary>
        /// 保存焊接开始列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionName("Mes/V1/SaveWeldStartList")]
        public string SaveWeldStartList(List<bus_workOrder_detail> details)
        {
            var result = service.SaveWeldStartList(details);
            return JsonHelper.Instance.Serialize(result);
        }


        /// <summary>
        /// 保存焊接结束列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionName("Mes/V1/SaveWeldEndList")]
        public string SaveWeldEndList(List<bus_workOrder_detail> details)
        {
            var result = service.SaveWeldEndList(details);
            return JsonHelper.Instance.Serialize(result);
        }


        /// <summary>
        /// 焊接工艺下发保存
        /// </summary>
        /// <param name="equipmentCode">设备编码</param>
        /// <param name="barCode">管段码</param>
        /// <returns></returns>
        [HttpGet]
        [ActionName("Mes/V1/SaveWeldTechnology")]
        public string SaveWeldTechnology(string equipmentCode, string barCode)
        {
            var result = service.SaveWeldTechnology(equipmentCode, barCode);
            return JsonHelper.Instance.Serialize(result);
        }

        /// <summary>
        /// 批次码获取物料信息
        /// </summary>
        /// <param name="lotNo">批次码</param>
        /// <returns></returns>
        [HttpGet]
        [ActionName("Mes/V1/GetMaterialBylotNo")]
        public string GetMaterialBylotNo(string lotNo)
        {
            var result = service.GetMaterialBylotNo(lotNo);
            return JsonHelper.Instance.Serialize(result);
        }

        /// <summary>
        /// 设备编码获取设备信息
        /// </summary>
        /// <param name="equipmentCode">设备编码</param>
        /// <returns></returns>
        [HttpGet]
        [ActionName("Mes/V1/GetEquipmentByCode")]
        public string GetEquipmentByCode(string equipmentCode)
        {
            var result = service.GetEquipmentByCode(equipmentCode);
            return JsonHelper.Instance.Serialize(result);
        }

        /// <summary>
        /// 呼叫Agv接料
        /// </summary>
        /// <param name="equipmentCode">设备编码</param>
        /// <returns></returns>
        [HttpGet]
        [ActionName("Mes/V1/AgvCollectingStart")]
        public string AgvCollectingStart(string equipmentCode)
        {
            var result = service.AgvCollectingStart(equipmentCode);
            return JsonHelper.Instance.Serialize(result);
        }

        /// <summary>
        /// Agv接料完成
        /// </summary>
        /// <param name="equipmentCode">设备编码</param>
        /// <returns></returns>
        [HttpGet]
        [ActionName("Mes/V1/AgvCollectingEnd")]
        public string AgvCollectingEnd(string equipmentCode)
        {
            var result = service.AgvCollectingEnd(equipmentCode);
            return JsonHelper.Instance.Serialize(result);
        }

        /// <summary>
        /// 托盘入库
        /// </summary>
        /// <param name="containerCode">托盘码</param>
        /// <returns></returns>
        [HttpGet]
        [ActionName("Mes/V1/ContainerTransfer")]
        public string ContainerTransfer(string containerCode)
        {
            var result = service.ContainerTransfer(containerCode);
            return JsonHelper.Instance.Serialize(result);
        }

        /// <summary>
        /// 设备任务列表查询
        /// </summary>
        /// <param name="equipmentCode">设备编码</param>
        /// <param name="state">查询状态:0未完成,30进行中,100已经完成</param>
        /// <returns></returns>
        [HttpGet]
        [ActionName("Mes/V1/GetEquipmentTaskList")]
        public string GetEquipmentTaskList(string equipmentCode, int state)
        {
            var result = service.GetEquipmentTaskList(equipmentCode, state);
            return JsonHelper.Instance.Serialize(result);
        }

        /// <summary>
        /// 设备任务下发
        /// </summary>
        /// <param name="equipmentCode">设备编码</param>
        /// <param name="taskNumber">任务号</param>
        /// <returns></returns>
        [HttpGet]
        [ActionName("Mes/V1/EquipmentTaskDistribute")]
        public string EquipmentTaskDistribute(string equipmentCode, string taskNumber)
        {
            var result = service.EquipmentTaskDistribute(equipmentCode, taskNumber);
            return JsonHelper.Instance.Serialize(result);
        }

        [HttpGet]
        [ActionName("Mes/V1/robotDeviceStatus")]
        public string robotDeviceStatus()
        {
            var result = service.robotDeviceStatus();
            return result.ToString();
        }

        [HttpGet]
        [ActionName("Mes/V1/PipeInfo")]
        public string PipeInfo(string materialCode)
        {
            var result = service.PipeInfo(materialCode);
            return result;
        }

        /// <summary>
        /// 设备任务手动完成
        /// </summary>
        /// <param name="equipmentCode">设备编码</param>
        /// <param name="taskNumber">任务号</param>
        /// <returns></returns>
        [HttpGet]
        [ActionName("Mes/V1/EquipmentTaskEnd")]
        public string EquipmentTaskEnd(string equipmentCode, string taskNumber)
        {
            var response = new Response(true);
            return ExceptionsHelp.Instance.ExecuteT(() =>
            {
                CutWeldService cutService = new CutWeldService();
                cutService.SendTaskEnd(taskNumber, equipmentCode);
                return JsonHelper.Instance.Serialize(response);
            });
        }

        #endregion

        #region 工位任务

        /// <summary>
        /// 工位任务列表查询(自动线,组对与焊接)
        /// </summary>
        /// <param name="workCenterCode">工作中心</param>
        [HttpGet]
        [ActionName("Mes/V1/GetTaskList")]
        public string GetTaskList(string workCenterCode)
        {
            var result = service.GetTaskList(workCenterCode);
            return Serialize(result);
        }

        /// <summary>
        /// 获取扫码记录
        /// </summary>
        /// <param name="workCenterCode">工作中心</param>
        /// <returns></returns>
        [HttpGet]
        [ActionName("Mes/V1/GetScanRecord")]
        public string GetScanRecord(string workCenterCode)
        {
            var result = service.GetScanRecord(workCenterCode);
            return Serialize(result);
        }

        #endregion

        #region 工序问题记录

        /// <summary>
        /// 工序问题记录
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionName("Mes/V1/SetProblem")]
        public string SetProblem(dynamic requestData)
        {
            var result = service.SetProblem(requestData);
            return Serialize(result);
        }

        #endregion


        #region 物料到达

        /// <summary>
        /// PDA扫码物料到达
        /// </summary>
        /// <param name="workStationCode">工位码</param>
        /// <param name="pipeSN">管材SN</param>
        [HttpGet]
        [ActionName("Mes/V1/MaterialReach")]
        public string MaterialReach(string workStationCode, string pipeSN)
        {
            var result = service.MaterialReach(workStationCode, pipeSN);
            return Serialize(result);
        }

        /// <summary>
        /// 查询库存物料
        /// </summary>
        /// <param name="pipeSN">管材SN</param>
        [HttpGet]
        [ActionName("Mes/V1/GetInventoryByPipeSN")]
        public string GetInventoryByPipeSN(string pipeSN)
        {
            var result = service.GetInventoryByPipeSN(pipeSN);
            return Serialize(result);
        }

        #endregion

        #region 质检

        /// <summary>
        /// 质检任务查询
        /// </summary>
        /// <param name="workCenterCode">工序code</param>
        /// <param name="barCode">管段码</param>
        [HttpGet]
        [ActionName("Mes/V1/GetqualityStencilList")]
        public string GetqualityStencilList(string workCenterCode, string barCode)
        {
            var result = service.GetqualityStencilList(workCenterCode, barCode);
            return Serialize(result);
        }

        /// <summary>
        /// 质检执行
        /// </summary>
        /// <param name="keys">keys 多个用逗号隔开</param>
        /// <param name="executeResult">执行结果 10合格,20不合格</param>
        /// <param name="executeUser">执行人</param>
        [HttpPost]
        [ActionName("Mes/V1/QualityStencilExecute")]
        public string QualityStencilExecute(QualityExecute qualityExecute)
        {
            var result = service.QualityStencilExecute(qualityExecute);
            return Serialize(result);
        }

        #endregion
    }
}