using iWareCC.BLL; using iWareCC.Common.Helper; using iWareCommon.Utils; using iWareModel; using iWareModel.Entity; using iWareModel.Entity.Device; using iWareSql.DataAccess; using iWareSql.DBModel; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.Text; using XiGang.Core.Model; using XiGang.Core.Model.PostParamModels; using XiGang.Core.Model.PostParamModels.Task; namespace iWareCC.WCF { // 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的类名“CCWcfService”。 public class CCWcfService : ICCWcfService { /// /// MES提供某个发动机的详细信息 /// /// 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); } /// /// 获取设备坐标 /// /// 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; } } /// /// 模式是否正在运行 /// /// public bool IsStartedModel() { return SystemValue.isStartedModel; } /// /// 生成最新的任务序列号 /// /// /// public TaskSequenceEntity GenerateTaskSequence() { try { using (DbModel edm = new DbModel()) { TaskSequenceEntity entity = new TaskSequenceEntity(); entity = MainTaskHandler.GetTaskSequenceEntity(edm); return entity; } } catch (Exception ex) { Log4NetHelper.WriteErrorLog(LogType.CCWCFService, "GenerateTaskSequence出现异常:" + ex.Message, ex); return null; } } /// /// 组盘入库 /// /// /// /// /// /// /// /// /// 入库口 /// 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); } catch (Exception ex) { return FunRetEntity.Fail("异常:" + ex.Message); } } /// /// 重新扫描输送线1015上的托盘号 /// /// public FunRetEntity Write1015ReScan(bool value) { 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) { return FunRetEntity.Success("成功", ""); } else { return FunRetEntity.Fail(result.resMsg, ""); } } } catch (Exception ex) { return FunRetEntity.Fail("获取输送线1015上扫描的托盘号出现异常:" + ex.Message); } } /// /// 获取输送线1015上的扫描值 /// /// 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); } } /// /// 重新扫描输送线1019上的托盘号 /// /// 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); } } /// /// 获取输送线1019上的扫描值 /// /// public FunRetEntity GetScanValueFor1019() { try { //注意:这里是模拟的,发布要改过来啊!!! if (WCSConfigHelper.GetConfig_IsSimulationPLC()) { return FunRetEntity.Success("模拟成功", "XGT000205"); } else { return FunRetEntity.Success("成功", FormCC.rgvView.R_1019_Scan); } } catch (Exception ex) { return FunRetEntity.Fail("获取输送线1019上扫描的托盘号出现异常:" + ex.Message); } } #region 1015和1019 #endregion /// /// 寻找空闲的立库空库位 (普通物料) /// /// 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; } } } }