CutWeldService.cs 3.59 KB
using ApkInfo;
using Hh.Mes.Common;
using Hh.Mes.Common.config;
using Hh.Mes.Common.Json;
using Hh.Mes.Common.log;
using Hh.Mes.Common.Redis;
using Hh.Mes.Pojo.System;
using Hh.Mes.POJO.Entity;
using Hh.Mes.POJO.EnumEntitys;
using Hh.Mes.POJO.Response;
using Hh.Mes.POJO.ViewModel;
using Hh.Mes.POJO.WebEntity;
using Hh.Mes.Service.Repository;
using Hh.Mes.Service.SystemAuth;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Hh.Mes.Service
{
    public class CutWeldService : RepositorySqlSugar<dynamic>
    {
        /// <summary>
        /// 管段工序完工调用
        /// </summary>
        /// <param name="BarCode">追踪码</param>
        /// <param name="processesState">状态</param>
        /// <returns></returns>
        public void SendIWPTechnologylineProcess(string BarCode, int processesState)
        {

            ExceptionsHelp.Instance.ExecuteVoidFunc(() =>
            {

                if (string.IsNullOrWhiteSpace(BarCode)) return;
                if (processesState != (int)EnumCutHeadState.已套料
                    || processesState != (int)EnumCutHeadState.切割完成
                    || processesState != (int)EnumCutHeadState.打磨完成
                    || processesState != (int)EnumCutHeadState.组对完成
                    || processesState != (int)EnumCutHeadState.焊接完成) return;

                //切割完成处理,ECS完成时会更新套料方案,工单工序,这里只需要组织数据反馈上游
                var oprSequenceCode = EnumoprSequenceCode.套料;
                if (processesState == (int)EnumCutHeadState.切割完成)
                    oprSequenceCode = EnumoprSequenceCode.切割坡口;
                if (processesState == (int)EnumCutHeadState.打磨完成)
                    oprSequenceCode = EnumoprSequenceCode.打磨;
                if (processesState == (int)EnumCutHeadState.组对完成)
                    oprSequenceCode = EnumoprSequenceCode.组对;
                if (processesState == (int)EnumCutHeadState.焊接完成)
                    oprSequenceCode = EnumoprSequenceCode.焊接;

                var workOrderDetail = base.Context.Queryable<bus_workOrder_detail>().Where(x => x.oprSequenceCode == oprSequenceCode).First();
                if (workOrderDetail == null) return;

                var requestData = new
                {
                    workOrderCode = workOrderDetail.workOrderCode,//工单
                    partCode = workOrderDetail.partCode,//管段号
                    barCode = workOrderDetail.barCode,//追踪码(管段码)
                    oprSequenceCode = workOrderDetail.oprSequenceCode,//工序
                    stationCode = workOrderDetail.stationCode,//工位
                    equipmentCode = workOrderDetail.equipmentCode,//生产设备
                    actualStartTime = workOrderDetail.actualStartTime,//开始时间
                    actualEndTime = workOrderDetail.actualEndTime,// 完成时间
                    cutMaterCode = workOrderDetail.cutMaterCode,//管段物料编码
                    weldNo = workOrderDetail.weldNo,//组对(焊接)焊口号
                    batchNo = workOrderDetail.batchNo,//组对(焊接)批次号
                    createBy = workOrderDetail.createBy,//操作人
                };

                //调用上游MES工序完工反馈
                var url = GetDictionaryDictValue("UrlProcessFeedback", "GetUrl");

                var WCSresponse = HttpManWCS(url, requestData, EnumLog.调用上游MES工序完工反馈.ToString(), method: "post");
            });
        }
    }
}