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.
345 lines
12 KiB
345 lines
12 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using DevExpress.XtraEditors;
|
|
|
|
using System.IO;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
using ICSSoft.Base.Config.DBHelper;
|
|
|
|
namespace ICSSoft.Frame.APP
|
|
{
|
|
public partial class FormICSOrderBoard : DevExpress.XtraEditors.XtraForm
|
|
{
|
|
private string LineCode = "";
|
|
private float RefreshTime = 1;
|
|
public FormICSOrderBoard()
|
|
{
|
|
InitializeComponent();
|
|
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
|
|
this.WindowState = FormWindowState.Maximized;
|
|
|
|
labTime.Text = DateTime.Now.ToString();
|
|
//searchAndView();
|
|
|
|
timer.Enabled = true;
|
|
timer.Start();
|
|
|
|
//grvDetail.Columns["Mo"].Width = 120;
|
|
//grvDetail.Columns["ITEM"].Width = 165;
|
|
//grvDetail.Columns["TBFlag"].Width = 50;
|
|
//grvDetail.Columns["Status"].Width = 95;
|
|
grvDetail.RowHeight = 59;
|
|
|
|
splitContainerControl1.SplitterPosition = 50;
|
|
|
|
InitAppconfig();
|
|
}
|
|
private void InitAppconfig()
|
|
{
|
|
try
|
|
{
|
|
using (StreamReader fReader = new StreamReader(AppConfig.BaseServiceFile))
|
|
{
|
|
while (fReader.Peek() > -1)
|
|
{
|
|
string value = fReader.ReadLine();
|
|
if (!string.IsNullOrEmpty(value))
|
|
{
|
|
AppConfig.BaseServiceUri = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetMainConnectString", new object[] { });
|
|
|
|
if (obj != null)
|
|
{
|
|
bool flag = AppConfig.CheckDbConnectionState(obj.ToString());
|
|
if (flag == true)
|
|
{
|
|
AppConfig.FrameConnectString = obj.ToString();
|
|
}
|
|
else
|
|
{
|
|
AppConfig.FrameConnectString = "";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AppConfig.FrameConnectString = "";
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
AppConfig.FrameConnectString = "";
|
|
}
|
|
}
|
|
//public FormICSOrderBoard(string lineCode, string lineName, float refreshTime)
|
|
//{
|
|
// InitializeComponent();
|
|
// this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
|
|
// this.WindowState = FormWindowState.Maximized;
|
|
// LineCode = lineCode;
|
|
// RefreshTime = refreshTime;
|
|
// lblTitle.Text = "线体-" + lineName;
|
|
// labTime.Text = DateTime.Now.ToString();
|
|
// searchAndView();
|
|
|
|
// RefreshTimer.Interval = Convert.ToInt32(RefreshTime * 60 * 1000);
|
|
// RefreshTimer.Enabled = true;
|
|
// RefreshTimer.Start();
|
|
// timer.Enabled = true;
|
|
// timer.Start();
|
|
|
|
// grvDetail.Columns["Mo"].Width = 120;
|
|
// grvDetail.Columns["ITEM"].Width = 165;
|
|
// grvDetail.Columns["TBFlag"].Width = 50;
|
|
// grvDetail.Columns["Status"].Width = 95;
|
|
// grvDetail.RowHeight = 59;
|
|
|
|
// splitContainerControl1.SplitterPosition = 50;
|
|
//}
|
|
/// <summary>
|
|
/// 操作权限
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable RightOfExute()
|
|
{
|
|
DataTable rData = new DataTable();
|
|
rData.Columns.Add("BtnName");
|
|
rData.Columns.Add("ActionName");
|
|
//查看权限(必须有)
|
|
DataRow seeRow = rData.NewRow();
|
|
seeRow["BtnName"] = "see";
|
|
seeRow["ActionName"] = "查看";
|
|
rData.Rows.Add(seeRow);
|
|
DataRow upinvRow = rData.NewRow();
|
|
//upinvRow["BtnName"] = btnSelect.Name;
|
|
//upinvRow["ActionName"] = btnSelect.Text;
|
|
rData.Rows.Add(upinvRow);
|
|
rData.AcceptChanges();
|
|
return rData;
|
|
}
|
|
/// <summary>
|
|
/// 数据权限
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable RightOfData()
|
|
{
|
|
DataTable rData = new DataTable();
|
|
rData.Columns.Add("BodyName");
|
|
rData.Columns.Add("ControlName");
|
|
rData.Columns.Add("ControlCaption");
|
|
|
|
rData.AcceptChanges();
|
|
return rData;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载数据
|
|
/// </summary>
|
|
private void searchAndView()
|
|
{
|
|
try
|
|
{
|
|
string sqlwhere = "";
|
|
if (!string.IsNullOrEmpty(mocode.Text)) {
|
|
|
|
sqlwhere += " and B.MOCODE like '%"+mocode.Text.Trim()+"%'";
|
|
}
|
|
if (!string.IsNullOrEmpty(invcode.Text))
|
|
{
|
|
|
|
sqlwhere += " and B.ITEMCODE like '%"+invcode.Text.Trim()+"%'";
|
|
}
|
|
|
|
string sql = @"select distinct motype as 订单状态,a.lotno as 产品跟踪单号,B.MOCODE AS 生产工单号,B.MOSEQ AS 工单行号,B.ITEMCODE AS 产品编码,F.INVNAME AS 产品名称,
|
|
D.StartPlanDate AS 预计开工日期,D.EndPlanDate AS 预计完工日期,
|
|
J.OPNAME AS 产品工序,
|
|
CASE
|
|
WHEN C.OPCODE IS NULL THEN H.OPNAME
|
|
ELSE I.OPNAME
|
|
END AS 下道工序,
|
|
a.LOTQTY as 跟踪单数量,
|
|
B.MOPLANQTY AS 工单数量,
|
|
case
|
|
when c.CollectStatus='COLLECT_BEGINN'
|
|
then
|
|
CONVERT(NVARCHAR(20),CONVERT(DECIMAL(18,2),CONVERT(DECIMAL,isnull(l.seq-1,0))/CONVERT(DECIMAL,k.count))*100)+'%'
|
|
else
|
|
CONVERT(NVARCHAR(20),CONVERT(DECIMAL(18,2),CONVERT(DECIMAL,isnull(l.seq,0))/CONVERT(DECIMAL,k.count))*100)+'%'
|
|
end as 工序完成率,
|
|
B.MDeptCode AS 生产部门,
|
|
case
|
|
when c.CollectStatus='COLLECT_BEGINN'
|
|
then n.UserName
|
|
when c.CollectStatus='COLLECT_END'
|
|
then o.UserName
|
|
else ''
|
|
end as 最新操作人员,
|
|
CASE
|
|
when d.EndPlanDate>=c.EndTime
|
|
then '是'
|
|
when d.EndPlanDate>c.EndTime
|
|
then '否'
|
|
end as 是否正常
|
|
from ICSITEMLot a
|
|
inner join ICSMO b on a.TransNO=b.MOCODE and a.TransLine=b.MOSEQ
|
|
left join ICSLOTSIMULATION c on c.lotno=a.LotNO
|
|
left join ICSMO2User d on d.LOTNO=c.LOTNO and d.OPCODE=c.OPCODE
|
|
LEFT JOIN ICSINVENTORY F ON F.INVCODE=B.ITEMCODE
|
|
left join ICSITEMROUTE2OPLot e on e.LotNo=a.LotNO and e.OPSEQ=(select min(opseq) as OPSEQ from ICSITEMROUTE2OPLot where lotno=e.LotNo and OPSEQ>(select opseq from ICSITEMROUTE2OPLot where opcode=c.OPCODE and lotno=e.LotNo))
|
|
LEFT JOIN ICSITEMROUTE2OPLot G ON G.LotNo=A.LotNO AND E.OPSEQ=(SELECT MIN(OPSEQ) AS OPSEQ FROM ICSITEMROUTE2OPLot where lotno=e.LotNo)
|
|
LEFT JOIN ICSOP H ON H.OPCODE=G.OPCODE
|
|
LEFT JOIN ICSOP I ON I.OPCODE=E.OPCODE
|
|
LEFT JOIN ICSOP J ON J.OPCODE=C.OPCODE
|
|
left join ICSLOTONWIP m on m.LOTNO=c.LOTNO and m.OPCODE=c.OPCODE
|
|
left join Sys_User n on n.UserCode=m.UserCodeBegin
|
|
left join Sys_User o on o.UserCode=m.UserCodeEnd
|
|
left join (select lotno, count(*) as count from ICSITEMROUTE2OPLot group by LotNo)k on k.lotno=a.LotNO
|
|
left join (select lotno,OPCODE,ROW_NUMBER() over(partition by lotno order by opseq) as seq from ICSITEMROUTE2OPLot) l on l.LotNo=a.LotNO and l.OPCODE=c.OPCODE
|
|
where d.EndPlanDate is not null and 1=1";
|
|
|
|
|
|
sql += sqlwhere;
|
|
DataTable table = DBHelper.ExecuteDataset(AppConfig.AppConnectString,CommandType.Text,sql).Tables[0];
|
|
grdAll.DataSource = table;
|
|
grvDetail.BestFitColumns();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
|
|
{
|
|
if (e.RowHandle < 0)
|
|
return;
|
|
e.Info.DisplayText = (e.RowHandle + 1).ToString();
|
|
}
|
|
|
|
private void btnClose_Click(object sender, EventArgs e)
|
|
{
|
|
RefreshTimer.Enabled = false;
|
|
RefreshTimer.Stop();
|
|
timer.Enabled = false;
|
|
timer.Stop();
|
|
//this.DialogResult = DialogResult.Cancel;
|
|
AppConfig.CloseFormShow(this.Text);
|
|
this.Close();
|
|
}
|
|
|
|
private void RefreshTimer_Tick(object sender, EventArgs e)
|
|
{
|
|
searchAndView();
|
|
}
|
|
|
|
private void timer_Tick(object sender, EventArgs e)
|
|
{
|
|
labTime.Text = DateTime.Now.ToString();
|
|
}
|
|
|
|
private void grvDetail_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
|
|
{
|
|
//if (e.RowHandle < 0)
|
|
// return;
|
|
//if (e.Column == colStatus)
|
|
//{
|
|
// string state = grvDetail.GetRowCellValue(e.RowHandle, colStatus).ToString();
|
|
// if (state == "运行")
|
|
// {
|
|
// e.Appearance.BackColor = Color.Green;
|
|
// }
|
|
//}
|
|
}
|
|
|
|
#region 查询
|
|
private void btnSearch_Click(object sender, EventArgs e)
|
|
{
|
|
searchAndView();
|
|
}
|
|
#endregion
|
|
|
|
private void FormICSOrderBoard_Load(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
|
|
string sql = @"select distinct motype as 订单状态,a.lotno as 产品跟踪单号,B.MOCODE AS 生产工单号,B.MOSEQ AS 工单行号,B.ITEMCODE AS 产品编码,F.INVNAME AS 产品名称,
|
|
D.StartPlanDate AS 预计开工时间,D.EndPlanDate AS 预计完工时间,
|
|
J.OPNAME AS 产品工序,
|
|
CASE
|
|
WHEN C.OPCODE IS NULL THEN H.OPNAME
|
|
ELSE I.OPNAME
|
|
END AS 下道工序,
|
|
a.LOTQTY as 跟踪单数量,
|
|
B.MOPLANQTY AS 工单数量,
|
|
case
|
|
when c.CollectStatus = 'COLLECT_BEGINN'
|
|
then
|
|
CONVERT(NVARCHAR(20), CONVERT(DECIMAL(18, 2), CONVERT(DECIMAL, isnull(l.seq - 1, 0)) / CONVERT(DECIMAL, k.count)) * 100) + '%'
|
|
else
|
|
CONVERT(NVARCHAR(20), CONVERT(DECIMAL(18, 2), CONVERT(DECIMAL, isnull(l.seq, 0)) / CONVERT(DECIMAL, k.count)) * 100) + '%'
|
|
end as 工序完成率,
|
|
B.MDeptCode AS 生产部门,
|
|
case
|
|
when c.CollectStatus = 'COLLECT_BEGINN'
|
|
then n.UserName
|
|
when c.CollectStatus = 'COLLECT_END'
|
|
then o.UserName
|
|
else ''
|
|
end as 最新操作人员,
|
|
CASE
|
|
when d.EndPlanDate >= c.EndTime
|
|
then '是'
|
|
when d.EndPlanDate > c.EndTime
|
|
then '否'
|
|
end as 是否正常,
|
|
CASE C.collectstatus
|
|
when 'COLLECT_END' then convert(nvarchar(20),c.endtime,120)
|
|
else ''
|
|
end as 实际完工时间
|
|
from ICSITEMLot a
|
|
inner
|
|
join ICSMO b on a.TransNO = b.MOCODE and a.TransLine = b.MOSEQ
|
|
left join ICSLOTSIMULATION c on c.lotno = a.LotNO
|
|
left join ICSMO2User d on d.LOTNO = c.LOTNO and d.OPCODE = c.OPCODE
|
|
LEFT JOIN ICSINVENTORY F ON F.INVCODE = B.ITEMCODE
|
|
left join ICSITEMROUTE2OPLot e on e.LotNo = a.LotNO and e.OPSEQ = (select min(opseq) as OPSEQ from ICSITEMROUTE2OPLot where lotno = e.LotNo and OPSEQ> (select opseq from ICSITEMROUTE2OPLot where opcode = c.OPCODE and lotno = e.LotNo))
|
|
LEFT JOIN ICSITEMROUTE2OPLot G ON G.LotNo = A.LotNO AND E.OPSEQ = (SELECT MIN(OPSEQ) AS OPSEQ FROM ICSITEMROUTE2OPLot where lotno = e.LotNo)
|
|
LEFT JOIN ICSOP H ON H.OPCODE = G.OPCODE
|
|
LEFT JOIN ICSOP I ON I.OPCODE = E.OPCODE
|
|
LEFT JOIN ICSOP J ON J.OPCODE = C.OPCODE
|
|
left join ICSLOTONWIP m on m.LOTNO = c.LOTNO and m.OPCODE = c.OPCODE
|
|
left join Sys_User n on n.UserCode = m.UserCodeBegin
|
|
left join Sys_User o on o.UserCode = m.UserCodeEnd
|
|
left join (select lotno, count(*) as count from ICSITEMROUTE2OPLot group by LotNo)k on k.lotno = a.LotNO
|
|
left join (select lotno, OPCODE, ROW_NUMBER() over(partition by lotno order by opseq) as seq from ICSITEMROUTE2OPLot) l on l.LotNo = a.LotNO and l.OPCODE = c.OPCODE
|
|
where d.EndPlanDate is not null";
|
|
DataTable table = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
grdAll.DataSource = table;
|
|
grvDetail.BestFitColumns();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.ToString());
|
|
}
|
|
}
|
|
|
|
private void lblTitle_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.FormBorderStyle == FormBorderStyle.None)
|
|
this.FormBorderStyle = FormBorderStyle.FixedSingle;
|
|
else
|
|
this.FormBorderStyle = FormBorderStyle.None;
|
|
}
|
|
|
|
}
|
|
}
|