315 lines
10 KiB
C#
315 lines
10 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Diagnostics;
|
||
using System.Drawing;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading;
|
||
using System.Threading.Tasks;
|
||
using System.Windows.Forms;
|
||
using WMS.Business;
|
||
using WMS.Business.CK;
|
||
using WMS.Business.Stock;
|
||
using WMS.Common;
|
||
using WMS.IData;
|
||
using WMS.Model.CK;
|
||
using WMS.Model.RK;
|
||
|
||
namespace ServerSystem
|
||
{
|
||
public partial class FrmSytem : Form
|
||
{
|
||
public FrmSytem()
|
||
{
|
||
InitializeComponent();
|
||
ThreadExceptionDialog.CheckForIllegalCrossThreadCalls = false;
|
||
DevExpress.Data.CurrencyDataController.DisableThreadingProblemsDetection = true;
|
||
}
|
||
void HideMainform()
|
||
{
|
||
this.Hide();
|
||
}
|
||
void ShowMainForm()
|
||
{
|
||
this.Show();
|
||
this.WindowState = FormWindowState.Normal;
|
||
this.Activate();
|
||
}
|
||
private void notifyIcon1_DoubleClick(object sender, EventArgs e)
|
||
{
|
||
if (this.WindowState == FormWindowState.Normal)
|
||
{
|
||
this.WindowState = FormWindowState.Minimized;
|
||
Hide();
|
||
}
|
||
else if(this.WindowState == FormWindowState.Minimized)
|
||
{
|
||
ShowMainForm();
|
||
}
|
||
}
|
||
|
||
private void FrmSytem_FormClosing(object sender, FormClosingEventArgs e)
|
||
{
|
||
e.Cancel = true;
|
||
HideMainform();
|
||
}
|
||
|
||
private void FrmSytem_SizeChanged(object sender, EventArgs e)
|
||
{
|
||
if (this.WindowState == FormWindowState.Maximized)
|
||
{
|
||
HideMainform();
|
||
}
|
||
}
|
||
|
||
private void toolStripMenuItem3_Click(object sender, EventArgs e)
|
||
{
|
||
if (SystemCommon.ShowMessageBoxResult("exit System") == DialogResult.OK)
|
||
{
|
||
PassWord pass = new PassWord();
|
||
if (DialogResult.OK == pass.ShowDialog())
|
||
{
|
||
this.notifyIcon1.Visible = false;
|
||
this.Close();
|
||
this.Dispose();
|
||
|
||
Process.GetCurrentProcess().Close();
|
||
Process.GetCurrentProcess().Kill();
|
||
|
||
Application.Exit();
|
||
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
private void toolStripMenuItem1_Click(object sender, EventArgs e)
|
||
{
|
||
this.Show();
|
||
this.WindowState = FormWindowState.Normal;
|
||
this.Activate();
|
||
}
|
||
|
||
#region 日志记录
|
||
string[] OhpPlatform = { "222", "224", "225", "228", "229", "232", "233", "236", "237", "239" };
|
||
string[] MOdeLis = { "202", "204", "205", "208", "209", "212", "213", "216", "217", "219" };
|
||
private static object writelog = new object();
|
||
/// <summary>
|
||
/// 写日志
|
||
/// </summary>
|
||
/// <param name="strLog"></param>
|
||
public static void WriteLog(string strLog)
|
||
{
|
||
lock (writelog)
|
||
{
|
||
try
|
||
{
|
||
strLog = "时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + Environment.NewLine + strLog + Environment.NewLine;
|
||
DirectoryInfo di = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "\\Log");
|
||
if (di.Exists == false)
|
||
{
|
||
di.Create();
|
||
}
|
||
string logFileName;
|
||
logFileName = AppDomain.CurrentDomain.BaseDirectory + "\\Log\\" + DateTime.Now.ToString("yyyyMMdd") + ".log";
|
||
//超过10M覆盖原文件
|
||
if (File.Exists(logFileName))
|
||
{
|
||
FileInfo fi = new FileInfo(logFileName);
|
||
if (fi.Length > 5024000)
|
||
{
|
||
fi.Delete();
|
||
}
|
||
}
|
||
StreamWriter sw = null;
|
||
FileStream fs = new FileStream(logFileName, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
|
||
sw = new StreamWriter(fs);
|
||
sw.WriteLine(strLog);
|
||
sw.Close();
|
||
}
|
||
catch
|
||
{
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
private void toolStripMenuItem2_Click(object sender, EventArgs e)
|
||
{
|
||
this.Hide();
|
||
}
|
||
System.Timers.Timer timeCgd = new System.Timers.Timer(1000);
|
||
System.Timers.Timer timeOrder = new System.Timers.Timer(2000);
|
||
System.Timers.Timer timeOnGoods = new System.Timers.Timer(3000);
|
||
private void FrmSytem_Load(object sender, EventArgs e)
|
||
{
|
||
label2.Text = "系统启动时间:" + DateTime.Now.ToString();
|
||
timer1.Start();
|
||
|
||
////查询 成品搬运单完成接口表订单 查询出库表对应的订单 更改状态为10 扣除库存
|
||
//Thread tr1 = new Thread(new ThreadStart(GetCk_cux_wms_move_order_lot_itf_zh));
|
||
//tr1.IsBackground = true;
|
||
//tr1.Start();
|
||
|
||
}
|
||
public void GetCk_cux_wms_move_order_lot_itf_zh()
|
||
{
|
||
while (true)
|
||
{
|
||
lock ("Out")
|
||
{
|
||
|
||
Thread.Sleep(2000);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
void OutCkNull()
|
||
{
|
||
DataTable tb=IBussFactory<BussMIStock>.Instance().GetMisDataNullOut("33");
|
||
if(tb!=null)
|
||
{
|
||
if(tb.Rows.Count>0)
|
||
{
|
||
string locid = tb.Rows[0]["location_id"].ToString();
|
||
string outStand = tb.Rows[0]["outStand1"].ToString();
|
||
IBussFactory<BussPickingWaveGoods>.Instance().HandDataLoc(locid, outStand,"33");
|
||
}
|
||
}
|
||
tb = IBussFactory<BussMIStock>.Instance().GetMisDataNullOut("34");
|
||
if (tb != null)
|
||
{
|
||
if (tb.Rows.Count > 0)
|
||
{
|
||
string locid = tb.Rows[0]["location_id"].ToString();
|
||
string outStand = tb.Rows[0]["outStand1"].ToString();
|
||
IBussFactory<BussPickingWaveGoods>.Instance().HandDataLoc(locid, outStand,"34");
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
private void Time2_Elapsed()
|
||
{
|
||
lock("1")
|
||
{
|
||
try
|
||
{
|
||
CgOrder order = new CgOrder();
|
||
order.STS = "1";
|
||
List<CgOrder> listOrder = IBussFactory<BussOrders>.Instance().GetTableOrder(order);
|
||
if (listOrder != null)
|
||
{
|
||
bgc_cg.DataSource = listOrder;
|
||
}
|
||
//IBussFactory<WMS.Business.RK.BussWareNotice>.Instance().InsertOrderCgData();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogWriteText.WriteLog("采购入库单写通知单失败" + ex.Message.ToString());
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
List<AutoRkGoodsInfo> listIn = new List<AutoRkGoodsInfo>();
|
||
List<PickingWaveGoodsModel> listOt = new List<PickingWaveGoodsModel>();
|
||
int i = 0;
|
||
private void timer1_Tick(object sender, EventArgs e)
|
||
{
|
||
lock ("v")
|
||
{
|
||
//入库查询码盘任务 写入库订单T_ONGOODSSHELF
|
||
//IBussFactory<BussAutoRk>.Instance().OrderAdd();
|
||
|
||
//decimal goodsArea = 0;
|
||
//DataTable dsGoodId = DataProvider.Instance.PickingWaveGoods.GetGoodsArea("PL0182749B");
|
||
//if (dsGoodId != null)
|
||
//{
|
||
// if (dsGoodId.Rows.Count > 0)
|
||
// {
|
||
// //a.shipping_length,a.shipping_width,a.pcs_number
|
||
// //Shipping_width*Shipping_length/PCS_number/1000000
|
||
// decimal shipping_length = Convert.ToDecimal(dsGoodId.Rows[0]["shipping_length"].ToString());
|
||
// decimal shipping_width = Convert.ToDecimal(dsGoodId.Rows[0]["shipping_width"].ToString());
|
||
// decimal pcs_number = Convert.ToDecimal(dsGoodId.Rows[0]["pcs_number"].ToString());
|
||
|
||
// goodsArea = shipping_length * shipping_width / pcs_number / 1000000;
|
||
|
||
// }
|
||
//}
|
||
|
||
|
||
//查询 cux_wms_move_order_issu_itf_zh 成品搬运单接口表订单 生成T_CK_PICKINGWAVEGOODS 出库任务
|
||
//IBussFactory<BussPickingWaveGoods>.Instance().OutPickData();
|
||
|
||
|
||
//入库完成后加库存 查下表T_ONGOODSSHELF 状态status=10,
|
||
IBussFactory<BussAutoRk>.Instance().WriteMesData();
|
||
|
||
|
||
// 查询出库任务完成状态为6 的任务select * T_CK_PICKINGWAVEGOODS,堆垛机出库完成过账后状态6,PDA拣货完成9
|
||
IBussFactory<BussPickingWaveGoods>.Instance().TimerOutData();
|
||
//出库任务下发
|
||
// IBussFactory<BussPickingWaveGoods>.Instance().TimerMoveData();
|
||
|
||
if (i > 30)
|
||
{
|
||
GetData();
|
||
i = 0;
|
||
}
|
||
i++;
|
||
|
||
|
||
|
||
label1.Text = "系统运行中:" + DateTime.Now.ToString();
|
||
}
|
||
}
|
||
void GetData()
|
||
{
|
||
DataSet ds = WMS.Business.IBussFactory<BussAutoRk>.Instance().GetTaksAllData();
|
||
if (ds != null)
|
||
{
|
||
if (ds.Tables.Count > 0)
|
||
{
|
||
DataTable tbIn = ds.Tables[0];
|
||
listIn = ConvertHelper<AutoRkGoodsInfo>.ConvertToList(tbIn);
|
||
if (listIn != null)
|
||
{
|
||
bindingSource2.DataSource = listIn;
|
||
}
|
||
DataTable tbOt = ds.Tables[1];
|
||
listOt = ConvertHelper<PickingWaveGoodsModel>.ConvertToList(tbOt);
|
||
if (listOt != null)
|
||
{
|
||
bgc_outMx.DataSource = listOt;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
private void simpleButton1_Click(object sender, EventArgs e)
|
||
{
|
||
timeCgd.Start();
|
||
}
|
||
|
||
private void simpleButton2_Click(object sender, EventArgs e)
|
||
{
|
||
timeCgd.Stop();
|
||
}
|
||
|
||
private void simpleButton6_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
}
|
||
}
|