IPC-610
2024-09-28 e79cf581b2f0038a41de5da1c6eadb3541f4d69e
Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs
@@ -555,7 +555,14 @@
    [DisplayName("获取设备对应工位列表")]
    public async Task<List<WcsDeviceTaskOrderDto>> WcsPackStationPlcList([FromQuery] WcsDeviceBaseInput entry)
    {
        return await _wcsDeviceRep.Context.Queryable<WcsDevice>()
        //var list = await _wcsDeviceRep.AsQueryable()
        //                            .LeftJoin<WcsPlc>((a, b) => a.PlcId == b.Id)
        //                            .Where((a, b) => a.DeviceType == DeviceTypeEnum.Business)
        //                            .Select<WcsDeviceOutput>((a, b) => new WcsDeviceOutput() { Type = b.Type }, true)
        //                            .ToListAsync();
        var list = await _wcsDeviceRep.Context.Queryable<WcsDevice>()
                .InnerJoin<WcsPlc>((device, plc) => device.PlcId == plc.Id)
                .LeftJoin<WcsCheckTask>((device, plc, task) => device.StationNum == task.Port)
                .Where((device, plc, task) => device.PlcId == entry.PlcId)
@@ -574,9 +581,24 @@
                    PZNo = task.PZNo,
                    Qty = task.Qty,
                    PlcId=device.PlcId,
                    Type = plc.Type
                })
                .ToListAsync();
        bool connStatus = false;
        //获取设备的状态
        var modPlc = await _wcsDeviceRep.Context.Queryable<WcsPlc>().FirstAsync(s => s.Id == list[0].PlcId);
        PLCUtil modUtil = new PLCUtil(modPlc);
        if (modUtil.Connected)
        {
            connStatus = true;
        }
        foreach (var item in list)
        {
            item.PlcStatus = connStatus;
        }
        return list;
    }
    #endregion
}