222
schangxiang@126.com
2024-12-14 3eabfd8dfa2574efbe8ce8d4a64862c16ad04823
CC/iWareCC_ASRS/WCF/CCWcfService.cs
@@ -1,6 +1,8 @@

using iWareCC.BLL;
using iWareCC.Common.Helper;
using iWareCC.SrmService;
using iWareCC.StationService;
using iWareCommon.Utils;
using iWareModel;
using iWareModel.Entity;
@@ -23,44 +25,6 @@
    // 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的类名“CCWcfService”。
    public class CCWcfService : ICCWcfService
    {
        /// <summary>
        /// MES提供某个发动机的详细信息
        /// </summary>
        /// <param name="_barCode"></param>
        public string getEngineInfo(string mes_url, string XiGang_Mes_Url_getEngineInfo, string token, string _barCode)
        {
            return MyMesService.getEngineInfo(mes_url, XiGang_Mes_Url_getEngineInfo, token, _barCode);
        }
        /// <summary>
        /// 获取设备坐标
        /// </summary>
        /// <returns></returns>
        public DeviceCoordinat GetDeviceCoordinat()
        {
            DeviceCoordinat result = null;
            try
            {
                result = new DeviceCoordinat()
                {
                };
                result.RgvCoordinate = FormCC.rgvView.R_RGV_Coordinate;
                result.Srm1Coordinat = FormCC.srmViewDict[(int)EDevice.一号堆垛机].R_PosXmm.ToString();
                result.Srm2Coordinat = FormCC.srmViewDict[(int)EDevice.二号堆垛机].R_PosXmm.ToString();
                result.Srm3Coordinat = FormCC.srmViewDict[(int)EDevice.三号堆垛机].R_PosXmm.ToString();
                result.Srm4Coordinat = FormCC.srmViewDict[(int)EDevice.四号堆垛机].R_PosXmm.ToString();
                return result;
            }
            catch (Exception ex)
            {
                Log4NetHelper.WriteErrorLog(LogType.CCWCFService, "GetDeviceCoordinat出现异常:" + ex.Message, ex);
                return result;
            }
        }
        /// <summary>
        /// 模式是否正在运行
@@ -72,55 +36,23 @@
        }
        /// <summary>
        /// 生成最新的任务序列号
        /// 补板工位允许进板
        /// </summary>
        /// <param name="edm"></param>
        /// <returns></returns>
        public TaskSequenceEntity GenerateTaskSequence()
        public FunRetEntity WriteStation_AllowIn()
        {
            try
            {
                using (DbModel edm = new DbModel())
                using (StationServiceClient client = new StationServiceClient())
                {
                    TaskSequenceEntity entity = new TaskSequenceEntity();
                    entity = MainTaskHandler.GetTaskSequenceEntity(edm);
                    return entity;
                    var res = client.WriteStation_AllowIn((int)EDevice.Station, true, StationLocationEnum.BZ39.ToString());
                    if (!res.result)
                    {
                        return FunRetEntity.Fail(res.resMsg);
                    }
                }
            }
            catch (Exception ex)
            {
                Log4NetHelper.WriteErrorLog(LogType.CCWCFService, "GenerateTaskSequence出现异常:" + ex.Message, ex);
                return null;
            }
        }
        /// <summary>
        /// 组盘入库
        /// </summary>
        /// <param name="taskSequence"></param>
        /// <param name="taskSequenceGuid"></param>
        /// <param name="isBtj"></param>
        /// <param name="Task_InStoreSlaver"></param>
        /// <param name="request"></param>
        /// <param name="userName"></param>
        /// <param name="userId"></param>
        /// <param name="inStoreNo">入库口</param>
        /// <returns></returns>
        public FunRetEntity SalverMaterialBind(bool isValidate1015ScanValue,
            bool isBtj,
            C_Task_InStoreSlaverParam Task_InStoreSlaver, C_AnalyzeMaterialPostParam request,
            string userName, int userId, string inStoreNo)
        {
            try
            {
                var ret = SalverMaterialBindBLL.SalverMaterialBind(isValidate1015ScanValue, isBtj, Task_InStoreSlaver, request, userName, userId, inStoreNo);
                if (ret.success)
                {
                    return FunRetEntity.Success("成功");
                }
                return FunRetEntity.Fail(ret.msg);
                return FunRetEntity.Success("成功", "");
            }
            catch (Exception ex)
            {
@@ -128,139 +60,38 @@
            }
        }
        /// <summary>
        /// 重新扫描输送线1015上的托盘号
        /// 验证模式
        /// </summary>
        /// <param name="flag"></param>
        /// <returns></returns>
        public FunRetEntity Write1015ReScan(bool value)
        public FunRetEntity ValidateMode(int flag)
        {
            try
            {
                if (WCSConfigHelper.GetConfig_IsSimulationPLC())
                {
                    return FunRetEntity.Success("模拟成功", "");
                }
                using (RgvService.RgvServiceClient client = new RgvService.RgvServiceClient())
                {
                    iWareCC.RgvService.SdaResEntity result = client.Write1015ReScan((int)EDevice.RGV, value);
                    if (result.result)
                var rgvLocation = StationLocationEnum.BZ39.ToString();
                var obj = FormCC.stationView.R_StationForReadCommList.Where(x => x.StationCode == rgvLocation.ToString()).FirstOrDefault();
                if (flag == 1)
                {//要强制出库
                    if (obj.R_ForceOutboundMode == false)
                    {
                        return FunRetEntity.Success("成功", "");
                        return FunRetEntity.Fail("PLC不是强制出库模式");
                    }
                    else
                    {
                        return FunRetEntity.Fail(result.resMsg, "");
                    }
                }
            }
            catch (Exception ex)
            {
                return FunRetEntity.Fail("获取输送线1015上扫描的托盘号出现异常:" + ex.Message);
            }
        }
        /// <summary>
        /// 获取输送线1015上的扫描值
        /// </summary>
        /// <returns></returns>
        public FunRetEntity GetScanValueFor1015()
        {
            try
            {
                //注意:这里是模拟的,发布要改过来啊!!!
                if (WCSConfigHelper.GetConfig_IsSimulationPLC())
                {
                    return FunRetEntity.Success("模拟成功", "XGT000205");
                }
                return FunRetEntity.Success("成功", FormCC.rgvView.R_1015_Scan);
            }
            catch (Exception ex)
            {
                return FunRetEntity.Fail("获取输送线1015上扫描的托盘号出现异常:" + ex.Message);
            }
        }
        /// <summary>
        /// 重新扫描输送线1019上的托盘号
        /// </summary>
        /// <returns></returns>
        public FunRetEntity Write1019ReScan(bool value)
        {
            try
            {
                if (WCSConfigHelper.GetConfig_IsSimulationPLC())
                {
                    return FunRetEntity.Success("模拟成功", "");
                }
                using (RgvService.RgvServiceClient client = new RgvService.RgvServiceClient())
                {
                    iWareCC.RgvService.SdaResEntity result = client.Write1019ReScan((int)EDevice.RGV, value);
                    if (result.result)
                    {
                        return FunRetEntity.Success("成功", "");
                    }
                    else
                    {
                        return FunRetEntity.Fail(result.resMsg, "");
                    }
                }
            }
            catch (Exception ex)
            {
                return FunRetEntity.Fail("获取输送线1019上扫描的托盘号出现异常:" + ex.Message);
            }
        }
        /// <summary>
        /// 获取输送线1019上的扫描值
        /// </summary>
        /// <returns></returns>
        public FunRetEntity GetScanValueFor1019()
        {
            try
            {
                //注意:这里是模拟的,发布要改过来啊!!!
                if (WCSConfigHelper.GetConfig_IsSimulationPLC())
                {
                    return FunRetEntity.Success("模拟成功", "XGT000205");
                }
                else
                {
                    return FunRetEntity.Success("成功", FormCC.rgvView.R_1019_Scan);
                    if (obj.R_OutboundMode == false)
                    {
                        return FunRetEntity.Fail("PLC不是出库模式");
                    }
                }
                return FunRetEntity.Success("成功", "");
            }
            catch (Exception ex)
            {
                return FunRetEntity.Fail("获取输送线1019上扫描的托盘号出现异常:" + ex.Message);
                return FunRetEntity.Fail("异常:" + ex.Message);
            }
        }
        #region 1015和1019
        #endregion
        /// <summary>
        /// 寻找空闲的立库空库位 (普通物料)
        /// </summary>
        /// <returns></returns>
        public Base_Station FindBestEmptyPlaceForOrdinaryMaterial(string orderNo)
        {
            try
            {
                using (DbModel edm = new DbModel())
                {
                    var item = StationHandler.FindBestEmptyPlaceForOrdinaryMaterial(edm, orderNo, MaterialTypeEnum.一般物料);
                    return item;
                }
            }
            catch (Exception ex)
            {
                return null;
            }
        }
    }
}