| | |
| | | namespace WCS.Application; |
| | | public static class PLCTaskAction |
| | | { |
| | | //服务运行状态 |
| | | public static bool boRunningState = false; |
| | | |
| | | private static readonly ISqlSugarClient _db = SqlSugarSetup.ITenant.GetConnectionScope(SqlSugarConst.MainConfigId); |
| | | |
| | | private static List<WcsPlc> listPlc; |
| | |
| | | listPlcUtil.Add(plc); |
| | | } |
| | | cts = new CancellationTokenSource(); |
| | | boRunningState = true; |
| | | StartRead(); |
| | | } |
| | | /// <summary> |
| | |
| | | public static void Stop() |
| | | { |
| | | cts.Cancel(); |
| | | boRunningState = false; |
| | | } |
| | | } |
| | |
| | | { |
| | | |
| | | } |
| | | public class GeneratePosInput |
| | | { |
| | | /// <summary> |
| | | /// 主键Id |
| | | /// </summary> |
| | | [Required(ErrorMessage = "主键Id不能为空")] |
| | | public long Id { get; set; } |
| | | /// <summary> |
| | | /// 起始点位 |
| | | /// </summary> |
| | | [Required(ErrorMessage = "起始点位不能为空")] |
| | | public int Pos { get; set; } |
| | | } |
| | |
| | | input.Field = "u.Id"; |
| | | input.Order = "desc"; |
| | | } |
| | | input.SearchKey = input.SearchKey?.Trim(); |
| | | input.SearchKey = input.SearchKey?.Trim(); |
| | | var query = _wcsDeviceRep.AsQueryable() |
| | | .WhereIF(!string.IsNullOrEmpty(input.SearchKey), u => |
| | | u.Text.Contains(input.SearchKey) |
| | | ) |
| | | .WhereIF(input.PlcId>0, u => u.PlcId == input.PlcId) |
| | | .WhereIF(input.PlcId > 0, u => u.PlcId == input.PlcId) |
| | | .WhereIF(!string.IsNullOrWhiteSpace(input.Text), u => u.Text.Contains(input.Text.Trim())) |
| | | //处理外键和TreeSelector相关字段的连接 |
| | | .LeftJoin<WcsPlc>((u, plcid) => u.PlcId == plcid.Id ) |
| | | .LeftJoin<WcsPlc>((u, plcid) => u.PlcId == plcid.Id) |
| | | .Select((u, plcid) => new WcsDeviceOutput |
| | | { |
| | | Id = u.Id, |
| | | PlcId = u.PlcId, |
| | | PlcId = u.PlcId, |
| | | PlcIdIP = plcid.IP, |
| | | Level = (DeviceLevelEnum)u.Level, |
| | | DbNumber = u.DbNumber, |
| | |
| | | CreateOrgName = u.CreateOrgName, |
| | | IsDelete = u.IsDelete, |
| | | }); |
| | | return await query.OrderBuilder(input).ToPagedListAsync(input.Page, input.PageSize); |
| | | return await query.OrderBuilder(input).ToPagedListAsync(input.Page, input.PageSize); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | ).ToListAsync(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 生成点位 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [ApiDescriptionSettings(Name = "GeneratePos")] |
| | | [DisplayName("生成点位")] |
| | | public async Task GeneratePos(GeneratePosInput input) |
| | | { |
| | | var modDevice = await _wcsDeviceRep.GetByIdAsync(input.Id); |
| | | |
| | | var listPosition = new List<WcsPosition>(); |
| | | listPosition.Add(new WcsPosition() |
| | | { |
| | | DeviceId = modDevice.Id, |
| | | StationNum = modDevice.StationNum, |
| | | PlcPos = input.Pos.ToString(), |
| | | PosType = PLCDataTypeEnum.String, |
| | | Text = "TaskNo" |
| | | }); |
| | | listPosition.Add(new WcsPosition() |
| | | { |
| | | DeviceId = modDevice.Id, |
| | | StationNum = modDevice.StationNum, |
| | | PlcPos = (input.Pos + 4).ToString(), |
| | | PosType = PLCDataTypeEnum.UShort, |
| | | Text = "TaskType" |
| | | }); |
| | | listPosition.Add(new WcsPosition() |
| | | { |
| | | DeviceId = modDevice.Id, |
| | | StationNum = modDevice.StationNum, |
| | | PlcPos = (input.Pos + 6).ToString(), |
| | | PosType = PLCDataTypeEnum.UShort, |
| | | Text = "StartLocatNo" |
| | | }); |
| | | listPosition.Add(new WcsPosition() |
| | | { |
| | | DeviceId = modDevice.Id, |
| | | StationNum = modDevice.StationNum, |
| | | PlcPos = (input.Pos + 8).ToString(), |
| | | PosType = PLCDataTypeEnum.UShort, |
| | | Text = "EndLocatNo" |
| | | }); |
| | | |
| | | await _wcsDeviceRep.Context.Insertable(listPosition).ExecuteCommandAsync(); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | PageWcsDevice = '/api/wcsDevice/page', |
| | | DetailWcsDevice = '/api/wcsDevice/detail', |
| | | GetWcsPlcPlcIdDropdown = '/api/wcsDevice/WcsPlcPlcIdDropdown', |
| | | GeneratePos = '/api/wcsDevice/GeneratePos', |
| | | } |
| | | |
| | | // 增加设备信息 |
| | |
| | | method: 'get' |
| | | }); |
| | | |
| | | export const generatePos = (params?: any) => |
| | | request({ |
| | | url: Api.GeneratePos, |
| | | method: 'post', |
| | | data: params |
| | | }); |
| | | |
| | |
| | | style="margin-left:5px;"> 隐藏 </el-button> |
| | | <el-button type="primary" style="margin-left:5px;" icon="ele-Plus" @click="openAddWcsDevice" |
| | | v-auth="'wcsDevice:add'"> 新增 </el-button> |
| | | |
| | | </el-button-group> |
| | | </el-form-item> |
| | | |
| | |
| | | <el-table-column prop="level" label="设备级别" show-overflow-tooltip=""> |
| | | <template #default="scope"> |
| | | <el-tag :type="dv('DeviceLevelEnum', scope.row.level)?.tagType"> {{ dv('DeviceLevelEnum', |
| | | scope.row.level)?.name}}</el-tag> |
| | | scope.row.level)?.name }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="dbNumber" label="DB区域" show-overflow-tooltip="" /> |
| | |
| | | <el-table-column prop="posType" label="流程字类型" show-overflow-tooltip=""> |
| | | <template #default="scope"> |
| | | <el-tag :type="dv('PLCDataTypeEnum', scope.row.posType)?.tagType"> {{ dv('PLCDataTypeEnum', |
| | | scope.row.posType)?.name}}</el-tag> |
| | | scope.row.posType)?.name }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="ledIP" label="显示屏ip地址" show-overflow-tooltip="" /> |
| | |
| | | <ModifyRecord :data="scope.row" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" width="140" align="center" fixed="right" show-overflow-tooltip="" |
| | | <el-table-column label="操作" width="220" align="center" fixed="right" show-overflow-tooltip="" |
| | | v-if="auth('wcsDevice:update') || auth('wcsDevice:delete')"> |
| | | <template #default="scope"> |
| | | <el-button icon="ele-Edit" size="small" text="" type="primary" @click="openEditWcsDevice(scope.row)" |
| | | v-auth="'wcsDevice:update'"> 编辑 </el-button> |
| | | <el-button icon="ele-Delete" size="small" text="" type="primary" @click="delWcsDevice(scope.row)" |
| | | v-auth="'wcsDevice:delete'"> 删除 </el-button> |
| | | <el-button icon="ele-Plus" size="small" text="" type="primary" @click="generateDevicePos(scope.row)" |
| | | v-auth="'wcsDevice:generate'"> 生成点位 </el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | |
| | | |
| | | import printDialog from '/@/views/system/print/component/hiprint/preview.vue' |
| | | import editDialog from '/@/views/wcs/wcsDevice/component/editDialog.vue' |
| | | import { pageWcsDevice, deleteWcsDevice } from '/@/api/wcs/wcsDevice'; |
| | | import { pageWcsDevice, deleteWcsDevice, generatePos } from '/@/api/wcs/wcsDevice'; |
| | | import { getWcsPlcPlcIdDropdown } from '/@/api/wcs/wcsDevice'; |
| | | |
| | | const showAdvanceQueryUI = ref(false); |
| | |
| | | editWcsDeviceTitle.value = '编辑设备信息'; |
| | | editDialogRef.value.openDialog(row); |
| | | }; |
| | | |
| | | //生成点位 |
| | | const generateDevicePos = (row: any) => { |
| | | ElMessageBox.prompt('请输入起始点位', '生成点位', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | }) |
| | | .then(async ({ value }) => { |
| | | await generatePos({ id: row.id, pos: value }); |
| | | ElMessage({ |
| | | type: 'success', |
| | | message: `生成点位成功`, |
| | | }) |
| | | }) |
| | | } |
| | | // 删除 |
| | | const delWcsDevice = (row: any) => { |
| | | ElMessageBox.confirm(`确定要删除吗?`, "提示", { |