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 WorkStation11 : StationBase
|
|
{
|
|
public void PalletNum(string stationCode, object value, DateTime triggerTime)
|
|
{
|
|
|
|
try
|
|
{
|
|
|
|
PalletCode = Convert.ToInt32(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);
|
|
|
|
// var aa = deploydata.First();
|
|
if (deploydata.Count() > 0)
|
|
{
|
|
PresentOrder = ProductOrder.Query().Where(p => p.plan_id == deploydata.First().plan_id).First();
|
|
|
|
|
|
|
|
|
|
//如果是不合格 也不打印条码 直接放行
|
|
if ((deploydata.First().all_result == 2))
|
|
{
|
|
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
//未经过OP120工位 默认未合格工件
|
|
string _sql = $"update Deploy_Data set all_result =1 where Id={deploydata.First().Id}";
|
|
SqlSugarAdo.ExecuteCommand(_sql);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
//无当前工件数据,默认为空托盘 不打印条码
|
|
PresentOrder = ProductOrder.Query().OrderBy(p => p.id, OrderByType.Desc).First();
|
|
|
|
|
|
return;
|
|
}
|
|
|
|
ViewInit();
|
|
|
|
ProductTypeCode = Convert.ToInt32(PresentOrder.product_id);
|
|
|
|
//创建条码Id
|
|
ProductSerialInfoOperate(PalletCode, ProductTypeCode);
|
|
|
|
//打印条码
|
|
PrintOkLabel(ProductTypeCode, (int)ProductSerialId) ;
|
|
|
|
//已存在,更新上线时间
|
|
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);
|
|
// View.ProductCode = deploydata.First().print_pid;
|
|
View.PrintCode = deploydata.First().print_pid;
|
|
View.ScanTime= DateTime.Now;
|
|
SendMsg.SendMsgToStation(StationInfo.StationCode, "ProductCode", NgProductCode);
|
|
}
|
|
else
|
|
{
|
|
ProductCycleTime = ExecDateDiff(ArrivedTime, DateTime.Now);
|
|
|
|
ArrivedTime = DateTime.Now;
|
|
//托盘离开,清空界面
|
|
ViewClear();
|
|
//查询合格数量 更新到订单表
|
|
int okcount= Deploy_Data.Query().Where(p => p.plan_id == PresentOrder.plan_id && p.all_result == 1).Count();
|
|
int nOkcount = Deploy_Data.Query().Where(p => p.plan_id == PresentOrder.plan_id && p.all_result == 2).Count();
|
|
SqlSugarAdo.ExecuteCommand($"update ProductOrder set ok_account ='{okcount}',nok_account ='{nOkcount}' where plan_id ={PresentOrder.plan_id}" );
|
|
|
|
SendMsg.SendMsgToStation(StationInfo.StationCode, "OkNum", okcount);
|
|
SendMsg.SendMsgToStation(StationInfo.StationCode, "NgProductCode", NgProductCode);
|
|
SendMsg.SendMsgToStation(StationInfo.StationCode, "NgPalletCode", NgPalletCode);
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLog(LogHelper.GetMethodInfo(), ex);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
}
|