huanghongfeng
3 天以前 5ffc36a1db18d3112a9b50a9cf3953d7fcf21bae
ÏîÄ¿´úÂë/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -41,6 +41,7 @@
        private readonly ITask_HtyRepository _taskHtyRepository;
        private readonly IDt_needBarcodeRepository _taskNeedBarcodeRepository;
        private Dictionary<string, OrderByType> _taskOrderBy = new()
        {
            {nameof(Dt_Task.Grade), OrderByType.Desc },
@@ -974,6 +975,7 @@
        public WebResponseContent GetPlcState(string TargetAddress)
        {
            Dt_StationManager dt_Station=_stationManagerRepository.QueryFirst(x => x.stationLocation == TargetAddress);
            if(dt_Station == null)
                return WebResponseContent.Instance.Error("未找到压装位信息!");
@@ -982,6 +984,17 @@
            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1000");
            CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
            //DeviceProDTO? devicePr = conveyorLine.DeviceProDTOs.Find(x => x.DeviceChildCode == "2033" && x.DeviceProParamName == "ConveyorLineSingal");
            short agv20 = conveyorLine.Communicator.Read<short>("DB5.794");
            if (agv20 != 1)    //获取下轴处是否有料占用
            {
                return WebResponseContent.Instance.Error($"未检测到agv取料站台有货,不可下发任务,读取到:{agv20}");
            }
            DeviceProDTO? deviceProDTOt = conveyorLine.DeviceProDTOs.Find(x => x.DeviceChildCode == TargetAddress && x.DeviceProParamName == "ConveyorLineSingal");
            DeviceProDTO? deviceProDTOt2 = conveyorLine.DeviceProDTOs.Find(x => x.DeviceChildCode == TargetAddress && x.DeviceProParamName == "ResponState");
            if (conveyorLine.Communicator.Read<short>(deviceProDTOt.DeviceProAddress)==1)
@@ -995,5 +1008,57 @@
                return WebResponseContent.Instance.Error("读取到压装位信号反馈不可放货!不可生成agv任务");
            }
        }
        public WebResponseContent SetPlcPalletCode(SaveModel saveModel)
        {
            WebResponseContent webResponse = new WebResponseContent();
            try
            {
                if (saveModel.DelKeys.Count != 2)
                {
                    return webResponse.Error("wcs传参错误!");
                }
                string AddStitic = saveModel.DelKeys[0].ToString();
                if (AddStitic == "") return webResponse.Error("选择的站台为空,请选择选择站台!");
                string PalletCode = saveModel.DelKeys[1].ToString();
                if (PalletCode == "") return webResponse.Error("输入的条码为空,请输入条码信息!");
                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1000");
                CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
                bool setplc = false;
                switch (AddStitic)
                {
                    case "1010":
                        setplc = conveyorLine.Communicator.Write("DB5.914", (string)PalletCode);
                        break;
                    case "2015":
                        setplc = conveyorLine.Communicator.Write("DB5.434", (string)PalletCode);
                        break;
                    case "2017":
                        setplc = conveyorLine.Communicator.Write("DB5.554", (string)PalletCode);
                        break;
                    case "2021":
                        setplc = conveyorLine.Communicator.Write("DB5.794", (string)PalletCode);
                        break;
                }
                if (setplc)
                {
                    return webResponse.OK($"对{AddStitic}站台写入条码:{PalletCode},成功");
                }
                else
                {
                    return webResponse.Error($"对{AddStitic}站台写入条码:{PalletCode},失败");
                }
            }
            catch (Exception ex)
            {
                return webResponse.Error($"错误信息:{ex.Message}");
                throw;
            }
        }
    }
}