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.
75 lines
3.3 KiB
75 lines
3.3 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
|
|
namespace ICSSoft.Frame.Data.DAL
|
|
{
|
|
public class ICSLOTONWIPDAL
|
|
{
|
|
|
|
public static void End(bool LotNoEnd, ICSLOTONWIP wip, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var user = db.Sys_User.SingleOrDefault(a => a.UserCode == wip.UserCodeEnd && a.WorkPointCode == wip.WorkPoint);
|
|
if (user == null)
|
|
{
|
|
throw new Exception("人员不存在!" + wip.UserCodeEnd);
|
|
}
|
|
|
|
//工序表.
|
|
var lineOnwip = db.ICSLOTONWIP.SingleOrDefault(a => a.LOTNO == wip.LOTNO && a.LOTSEQ == wip.LOTSEQ && a.ROUTECODE == wip.ROUTECODE && a.OPCODE == wip.OPCODE && a.WorkPoint == wip.WorkPoint);
|
|
if (lineOnwip == null)
|
|
{
|
|
throw new Exception("跟踪单-工序表数据获取错误,[结束工序]失败!");
|
|
}
|
|
lineOnwip.ACTIONRESULT = wip.ACTIONRESULT;
|
|
lineOnwip.EndTime = wip.EndTime;
|
|
lineOnwip.UserCodeEnd = wip.UserCodeEnd;
|
|
db.SubmitChanges();
|
|
|
|
|
|
//跟踪单表.保存最新一笔工序状态
|
|
//(注意)并行工序:不管跟踪单表原来存的是哪道工序,状态如何,只要onwip表变更就更新跟踪单表[即 多人+并行工序时,跟踪单表中的工序及状态永远存的是操作员最新上传的数据,并不是并行工序中序号最大的那个].
|
|
var lineSim = db.ICSLOTSIMULATION.SingleOrDefault(a => a.LOTNO == wip.LOTNO && a.LOTSEQ == wip.LOTSEQ && a.WorkPoint == wip.WorkPoint);
|
|
lineSim.OPSEQ = wip.OPSEQ;
|
|
lineSim.OPCODE = wip.OPCODE;
|
|
//对于并行组,如果出现过NG,则不能再更改.除此以外可以直接赋值当前工序结果
|
|
if (lineOnwip.EATTRIBUTE1 != "并行" || lineSim.OPListAttr != "并行" || lineSim.LACTION == "GOOD")
|
|
{
|
|
lineSim.LACTION = lineOnwip.ACTION;
|
|
lineSim.PRODUCTSTATUS = lineOnwip.ACTION;
|
|
lineSim.ACTIONLIST = lineOnwip.ACTION;
|
|
}
|
|
lineSim.CollectStatus = wip.ACTIONRESULT;
|
|
lineSim.MTIME = DateTime.Now;
|
|
lineSim.MUSER = user.UserCode;
|
|
lineSim.MUSERName = user.UserName;
|
|
if (lineSim.GOODQTY > lineOnwip.GOODQTY)
|
|
{
|
|
lineSim.GOODQTY = lineOnwip.GOODQTY;
|
|
}
|
|
if (LotNoEnd)
|
|
{
|
|
//结束跟踪单.变更状态,时间
|
|
lineSim.ISCOM = "1";
|
|
lineSim.EndTime = lineSim.MTIME;
|
|
lineSim.EATTRIBUTE1 = "最后一道工序完成";//跟踪单结束原因,还有可能分批将数量分没了
|
|
}
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
}
|
|
}
|