大连融科 WMS
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.

153 lines
7.0 KiB

using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using Quartz;
using SiaSun.LMS.Implement;
namespace SiaSun.LMS.WinService
{
[DisallowConcurrentExecution]
public class UpdateDeviceStateJob : IJob
{
public void Execute(IJobExecutionContext context)
{
int a = 0;
try
{
string sResult = string.Empty;
//sResult = "1111111111111";
//if (sResult.Length>12)
//{
// sResult= sResult.Substring(0, 12);
//}
// string aaa = sResult.Substring(0, 2000);
// MainApp._I_BaseService.Invoke("ControlBase", "ControlTranslate", new object[]{3},out sResult);
DataTable dt= MainApp._I_BaseService.GetList(string.Format(@"select * from io_control_route where control_route_type='9'"));
//循环处理设备状态更新,根据翻转机构报给电气、再报给调度、调度更新表状态
foreach (DataRow dr in dt.Rows)
{
if (dr["CONTROL_ROUTE_STATUS"].ToString().Equals("0"))
{
a= MainApp._I_BaseService.ExecuteNonQuery_ReturnInt(string.Format(@"update wh_cell set CELL_STATUS='Exception' where
CELL_CODE='{0}'", dr["end_device"].ToString()));
}
else
{
DataTable dtmange = MainApp._I_BaseService.GetList(string.Format(@"select * from v_storage_list where cell_code='{0}'", dr["end_device"].ToString()));
DataTable dtstorage = MainApp._I_BaseService.GetList(string.Format(@"select * from v_storage_list where cell_code='{0}'", dr["end_device"].ToString()));
if (dtstorage != null&&dtstorage.Rows.Count>0)
{
if (Convert.ToInt32(dtstorage.Rows[0]["goods_id"]) == 909)
{
a = MainApp._I_BaseService.ExecuteNonQuery_ReturnInt(string.Format(@"update wh_cell set CELL_STATUS='Pallet' where
CELL_CODE='{0}' ", dr["end_device"].ToString()));
}
else
{
a = MainApp._I_BaseService.ExecuteNonQuery_ReturnInt(string.Format(@"update wh_cell set CELL_STATUS='Full' where
CELL_CODE='{0}' ", dr["end_device"].ToString()));
}
string b = dr["end_device"].ToString();
}
else
{
a = MainApp._I_BaseService.ExecuteNonQuery_ReturnInt(string.Format(@"update wh_cell set CELL_STATUS='Nohave' where
CELL_CODE='{0}' ", dr["end_device"].ToString()));
}
}
}
if (a ==0)
{
Program.sysLog.Error("轮询更新货位状态失败" + sResult);
}
//先看1排可用翻转货位
DataTable dtdk = MainApp._I_BaseService.GetList(string.Format(@"select * from wh_cell where
cell_logical_name='FZ' and CELL_status='Nohave' and run_status='Enable' and cell_z='1' order by cell_y,cell_x "));
//先看1排可用翻转货位
DataTable dtdkk = MainApp._I_BaseService.GetList(string.Format(@"select * from wh_cell where
cell_logical_name='FZ' and CELL_status='Nohave' and run_status='Enable' and cell_z='2' order by cell_y,cell_x "));
string STOCK_BARCODE = string.Empty;
int END_CELL_ID = 0;
bool bResult = false;
bool bAutoSendControl = true;
bool bTrans = false;
string Opertator = "SYS";
sResult = string.Empty;
ManageMove mv = new ManageMove();
////有可用翻转货位,倒库。
if (dtdk.Rows.Count>=1)
{
END_CELL_ID =Convert.ToInt32(dtdk.Rows[0]["CELL_ID"]);
//如果正常入库,库存记录未翻转,此时如果有空的翻转货位,将未翻转的料进行倒库到翻转货位进行翻转
DataTable dtstorage = MainApp._I_BaseService.GetList(string.Format(@"select * from v_storage_list where
goods_property6='' and CELL_status='Full' and run_status='Enable' and cell_logical_name !='FZ' and cell_z=1 order by update_time"));
if (dtstorage.Rows.Count > 0)
{
bResult= mv.ManageCreate(dtstorage.Rows[0]["STOCK_BARCODE"].ToString(),
END_CELL_ID,
bAutoSendControl,
true,
Opertator,
out sResult);
}
}
else
{
//看第二排
if (dtdkk.Rows.Count >= 1)
{
END_CELL_ID = Convert.ToInt32(dtdkk.Rows[0]["CELL_ID"]);
//如果正常入库,库存记录未翻转,此时如果有空的翻转货位,将未翻转的料进行倒库到翻转货位进行翻转
DataTable dtstoragee = MainApp._I_BaseService.GetList(string.Format(@"select * from v_storage_list where
goods_property6='' and CELL_status='Full' and run_status='Enable' and cell_logical_name !='FZ' and cell_z=2 order by update_time"));
if (dtstoragee.Rows.Count > 0)
{
bResult = mv.ManageCreate(dtstoragee.Rows[0]["STOCK_BARCODE"].ToString(),
END_CELL_ID,
bAutoSendControl,
true,
Opertator,
out sResult);
}
}
}
}
catch (Exception ex)
{
Program.sysLog.Fatal("任务完成处理异常 " , ex);
}
}
}
}