281 lines
9.0 KiB
C#
281 lines
9.0 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.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)
|
|||
|
|
{
|
|||
|
|
timer1.Start();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
private void TimeOutGoods_Elapsed()
|
|||
|
|
{
|
|||
|
|
while (true)
|
|||
|
|
{
|
|||
|
|
lock ("Out")
|
|||
|
|
{
|
|||
|
|
//查询 T_CK_ORDERDETAIL 接口表订单 生成T_CK_PICKINGWAVEGOODS 出库任务
|
|||
|
|
|
|||
|
|
Thread.Sleep(3000);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
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();
|
|||
|
|
//入库完成后加库存 查下表T_ONGOODSSHELF 状态status=10,
|
|||
|
|
IBussFactory<BussAutoRk>.Instance().WriteMesData();
|
|||
|
|
|
|||
|
|
//出库 insert into T_CK_PICKINGWAVEGOODS
|
|||
|
|
//IBussFactory<BussPickingWaveGoods>.Instance().OutPickData();
|
|||
|
|
// 查询出库任务完成状态为10 的任务select * T_CK_PICKINGWAVEGOODS,减库存
|
|||
|
|
IBussFactory<BussPickingWaveGoods>.Instance().TimerOutData();
|
|||
|
|
|
|||
|
|
if (i > 30)
|
|||
|
|
{
|
|||
|
|
GetData();
|
|||
|
|
i = 0;
|
|||
|
|
}
|
|||
|
|
i++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
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)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|