更改分拣任务的绑定和结批功能;更改演示模式开关和滚筒反转开关
| | |
| | | //"ConnectionString": "PORT=5432;DATABASE=xxx;HOST=localhost;PASSWORD=xxx;USER ID=xxx", // PostgreSQL 库连接字符串 |
| | | //"ConnectionString": "Server=localhost;Database=xxx;Uid=xxx;Pwd=xxx;SslMode=None;", // MySql 库连接字符串", |
| | | //"ConnectionString": "User Id=xxx; Password=xxx; Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL)))", // Oracle 库连接字符串 |
| | | "ConnectionString": "Server=10.18.99.10;Database=WCSnet6;User Id=sa;Password=sql2024;", // SqlServer 库连接字符串 |
| | | //"ConnectionString": "Server=10.18.99.10;Database=WCSnet6;User Id=sa;Password=sql2024;", // SqlServer 库连接字符串 |
| | | "ConnectionString": "Server=.\\MSSQLSERVER2019;Database=WCSnet6;User Id=sa;Password=admin2023@;", // SqlServer 库连接字符串 |
| | | |
| | | |
| | | //"SlaveConnectionConfigs": [ // 读写分离/主从 |
| | | // { |
| | |
| | | /// </summary> |
| | | [SugarColumn(ColumnName = "Status", ColumnDescription = "工位绑定状态", Length = 2)] |
| | | public string? Status { get; set; } |
| | | |
| | | |
| | | /// <summary> |
| | | /// DB区域 |
| | | /// </summary> |
| | | [Required] |
| | | [SugarColumn(ColumnName = "DbNumber", ColumnDescription = "DB区域", Length = 10)] |
| | | public string DbNumber { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 抓箱品种偏移量 |
| | | /// </summary> |
| | | [Required] |
| | | [SugarColumn(ColumnName = "PlcPos", ColumnDescription = "抓箱品种偏移量", Length = 10)] |
| | | public string PlcPos { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 流程字类型 |
| | | /// </summary> |
| | | [Required] |
| | | [SugarColumn(ColumnName = "PosType", ColumnDescription = "流程字类型")] |
| | | public PLCDataTypeEnum PosType { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 批次偏移量 |
| | | /// </summary> |
| | | [Required] |
| | | [SugarColumn(ColumnName = "PlcPos", ColumnDescription = "批次偏移量", Length = 10)] |
| | | public string PosLot { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 批次流程字类型 |
| | | /// </summary> |
| | | [Required] |
| | | [SugarColumn(ColumnName = "PosType", ColumnDescription = "批次流程字类型")] |
| | | public PLCDataTypeEnum PosTypeLot { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 品种号 |
| | | /// </summary> |
| | |
| | | if (context.BoDemo.HasValue) |
| | | { |
| | | PLCTaskAction.boDemo = context.BoDemo.Value; |
| | | await _sysConfigService.UpdateConfigValue("sys_demo", context.BoDemo.Value); |
| | | |
| | | //PLC连接 |
| | | var plcStackeConn = PLCTaskAction.listPlcConn.First(m => m.PlcIP == "10.18.51.120"); |
| | | if (plcStackeConn.Connected) |
| | | { |
| | | //写入流程字 |
| | | var ret = plcStackeConn.SetPlcDBValue(PLCDataTypeEnum.Bit, "DB119", "0", PLCTaskAction.boDemo == true ? "1" : "0"); |
| | | if (ret.IsSucceed) |
| | | { |
| | | await _sysConfigService.UpdateConfigValue("sys_demo", context.BoDemo.Value); |
| | | } |
| | | else |
| | | { |
| | | PLCTaskAction.boDemo = !PLCTaskAction.boDemo; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | PLCTaskAction.boDemo = !PLCTaskAction.boDemo; |
| | | } |
| | | } |
| | | //滚筒反转 |
| | | if (context.BoDrumReversal.HasValue) |
| | | { |
| | | PLCTaskAction.boDrumReversal = context.BoDrumReversal.Value; |
| | | await _sysConfigService.UpdateConfigValue("sys_DrumReversal", context.BoDrumReversal.Value); |
| | | |
| | | //PLC连接 |
| | | var plcStackeConn = PLCTaskAction.listPlcConn.First(m => m.PlcIP == "10.18.51.120"); |
| | | if (plcStackeConn.Connected) |
| | | { |
| | | //写入流程字 |
| | | var ret = plcStackeConn.SetPlcDBValue(PLCDataTypeEnum.Bit, "DB119", "0.1", PLCTaskAction.boDemo == true ? "1" : "0"); |
| | | if (ret.IsSucceed) |
| | | { |
| | | await _sysConfigService.UpdateConfigValue("sys_DrumReversal", context.BoDrumReversal.Value); |
| | | } |
| | | else |
| | | { |
| | | PLCTaskAction.boDrumReversal = !PLCTaskAction.boDrumReversal; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | PLCTaskAction.boDrumReversal = !PLCTaskAction.boDrumReversal; |
| | | } |
| | | } |
| | | await _plcHubContext.Clients.All.UpdateService(new PLCServiceModel() { BoRunningState = PLCTaskAction.boRunningState, BoRefresh = PLCTaskAction.boRefresh, BoOffline = PLCTaskAction.boOffline, BoDemo = PLCTaskAction.boDemo, BoDrumReversal = PLCTaskAction.boDrumReversal }); |
| | | } |
| | |
| | | checkTaskInfo.BoxType = taskInfo.BoxType; |
| | | checkTaskInfo.Qty = taskInfo.Qty; |
| | | checkTaskInfo.Status = "1";//已绑定 |
| | | checkTaskInfo.PZNo = skuInfo.PZNo; |
| | | //更新分拣任务 |
| | | await _wcsCheckTaskRep.AsUpdateable(checkTaskInfo).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); |
| | | checkTaskInfo.PZNo = skuInfo.PZNo; |
| | | |
| | | #region#给PLC写数据 |
| | | |
| | | #region#给PLC写入抓箱品种号 |
| | | var modPlc = await _wcsDeviceRep.Context.Queryable<WcsPlc>().FirstAsync(s => s.Id == deviceInfo.PlcId); |
| | | if (modPlc == null) |
| | | { |
| | | throw Oops.Bah("找不到PLC信息"); |
| | | } |
| | | PLCUtil modUtil = new PLCUtil(modPlc); |
| | | var ret= modUtil.SetPlcDBValue(checkTaskInfo.PosType, checkTaskInfo.DbNumber, checkTaskInfo.PlcPos, checkTaskInfo.PZNo); |
| | | if (ret.IsSucceed) |
| | | { |
| | | //写入流程字成功后更新分拣任务 |
| | | await _wcsCheckTaskRep.AsUpdateable(checkTaskInfo).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); |
| | | } |
| | | #endregion |
| | | } |
| | | |
| | | [HttpPost] |
| | | [ApiDescriptionSettings(Name = "CloseTaskForPLC")] |
| | | [DisplayName("任务结批")] |
| | | public async Task CloseTaskForPLC(BindTaskPLCInput input) |
| | | public async Task CloseTaskForPLC(CloseTaskPLCInput input) |
| | | { |
| | | #region 请求PLC接口(这个方法实际是预结批,给PLC发送预结批信息,然后PLC再给WCS发送结批信号再将分拣信息清空) |
| | | |
| | | #endregion |
| | | //分拣任务信息 |
| | | var checkTaskList = _wcsCheckTaskRep.Context.Queryable<WcsCheckTask>().Where(w => w.LotNo == input.lotNo && w.Status == "1").ToList(); |
| | | if (checkTaskList.Count <= 0) |
| | | { |
| | | throw Oops.Bah("找不到该批次分拣任务信息"); |
| | | } |
| | | foreach (var item in checkTaskList) |
| | | { |
| | | item.OrderNo = ""; |
| | | item.TaskNo = ""; |
| | | item.LotNo = ""; |
| | | item.SkuNo = ""; |
| | | item.SkuName = ""; |
| | | item.BoxType = ""; |
| | | item.Qty = 0; |
| | | item.PZNo = ""; |
| | | item.Status = "0";//未绑定 |
| | | } |
| | | //更新分拣任务 |
| | | await _wcsCheckTaskRep.AsUpdateable(checkTaskList).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); |
| | | #region#给PLC写入结批批次号 |
| | | var deviceInfo = await _wcsDeviceRep.Context.Queryable<WcsDevice>().FirstAsync(w => w.StationNum == item.Port); |
| | | if (deviceInfo == null) |
| | | { |
| | | throw Oops.Bah($"找不到工位号:{item.Port} 的码垛工位信息"); |
| | | } |
| | | var modPlc = await _wcsDeviceRep.Context.Queryable<WcsPlc>().FirstAsync(s => s.Id == deviceInfo.PlcId); |
| | | if (modPlc == null) |
| | | { |
| | | throw Oops.Bah($"找不到工位号:{item.Port} 的设备信息"); |
| | | } |
| | | PLCUtil modUtil = new PLCUtil(modPlc); |
| | | var ret = modUtil.SetPlcDBValue(item.PosType, item.DbNumber, item.PlcPos, item.PZNo); |
| | | if (ret.IsSucceed) |
| | | { |
| | | //写入流程字成功后更新分拣任务 |
| | | item.OrderNo = ""; |
| | | item.TaskNo = ""; |
| | | item.LotNo = ""; |
| | | item.SkuNo = ""; |
| | | item.SkuName = ""; |
| | | item.BoxType = ""; |
| | | item.Qty = 0; |
| | | item.PZNo = ""; |
| | | item.Status = "0";//未绑定 |
| | | |
| | | //更新分拣任务 |
| | | await _wcsCheckTaskRep.AsUpdateable(item).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); |
| | | } |
| | | #endregion |
| | | } |
| | | } |
| | | } |
| | |
| | | public long deviceId { get; set; } |
| | | |
| | | public long oderTaskId { get; set; } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 结批任务参数 |
| | | /// </summary> |
| | | public class CloseTaskPLCInput |
| | | { |
| | | public string lotNo { get; set; } |
| | | } |
| | | } |