You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

112 lines
3.6 KiB

using Aborlen.Model;
using FrameWork.Log;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WorkStationBase;
namespace Aborlen.WorkStation
{
public partial class WorkStation12 : StationBase
{
public void PalletNum(string stationCode, object value, DateTime triggerTime)
{
try
{
PalletCode = Convert.ToByte(value);
LogHelper.WriteLog(stationCode + "到位托盘号" + PalletCode);
if (PalletCode != 0)
{
//托盘到达,更新条码验证规则 查询产品型号
//查询订单
var deploydata = Deploy_Data.Query().Where(p => p.tuopan_id == PalletCode && p.process_state < 4).OrderBy(p=>p.Id,OrderByType.Desc);
if (deploydata.Count() > 0)
{
PresentOrder = ProductOrder.Query().Where(p => p.plan_id == deploydata.First().plan_id).First();
//修改数据workstation 为当前工位序号
string _sql = $"update Deploy_Data set all_result =2 where Id={deploydata.First().Id}";
SqlSugarAdo.ExecuteCommand(_sql);
}
else
{
PresentOrder = ProductOrder.Query().OrderBy(p => p.id, OrderByType.Desc).First();
//不存在当前工件
SendMsg.SendMsgToStation("OP110", "AlarmMsg", "不合格下线工位当前工件系统不存在");
//直接放行工件
//不需要创建条码 直接return即可
return;
}
ProductTypeCode = Convert.ToInt32(PresentOrder.product_id);
//创建条码Id
ProductSerialInfoOperate_NG(PalletCode);
if (LastPallet != PalletCode)
{
//打印条码
PrintNOkLabel(ProductTypeCode, (int)ProductSerialId);
}
LastPallet = PalletCode;
NgPalletCode = PalletCode;
//发送显示消息
SendMsg.SendMsgToStation("OP110", "NgPalletCode", NgPalletCode);
//已存在,更新上线时间
string sql = $" update Deploy_Data set process_state=2 where tuopan_id ='{Read(2180, triggerTime)}' and process_state<4 and plan_id='{PresentOrder.plan_id}'";
SqlSugarAdo.ExecuteCommand(sql);
//写入打印完成
//Write(1190, (byte)1);
}
else
{
ProductCycleTime = ExecDateDiff(ArrivedTime, DateTime.Now);
ArrivedTime = DateTime.Now;
//托盘离开,清空界面
ViewClear();
StationBase.NgProductCode = "";
NgPalletCode =0;
SendMsg.SendMsgToStation("OP110", "NgProductCode", StationBase.NgProductCode);
SendMsg.SendMsgToStation("OP110", "NgPalletCode", NgPalletCode);
SendMsg.SendMsgToStation("OP110", "AlarmMsg", "");
}
}
catch (Exception ex)
{
LogHelper.WriteLog(LogHelper.GetMethodInfo(), ex);
}
}
}
}