|
|
@@ -22,139 +22,50 @@ namespace MES_Interface
|
|
|
/// </summary>
|
|
|
/// <param name="iSnCode"></param>
|
|
|
/// <param name="iMakeCode"></param>
|
|
|
- /// <param name="iSource"></param>
|
|
|
+ /// <param name="iSourceCode"></param>
|
|
|
/// <param name="oErrMessage"></param>
|
|
|
/// <returns></returns>
|
|
|
- private bool CheckCurrentStep(string iSnCode, string iMakeCode, string iSource, out string oErrMessage)
|
|
|
+ public bool CheckCurrentStep(string iSnCode, string iMakeCode, string iSourceCode, out string oErrMessage)
|
|
|
{
|
|
|
- oErrMessage = "";
|
|
|
- if (iMakeCode == "")
|
|
|
+ if (GetMakeInfo(iSnCode, out iMakeCode, out oErrMessage))
|
|
|
{
|
|
|
- if (!GetMakeInfo(iSnCode, out iMakeCode, out oErrMessage))
|
|
|
+ string nextstepcode = dh.getFieldDataByCondition("makeserial", "ms_nextstepcode", "ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakeCode + "'").ToString();
|
|
|
+ string sourcestepcode = GetStepCodeBySource(iSourceCode);
|
|
|
+ if (nextstepcode == "")
|
|
|
+ {
|
|
|
+ oErrMessage = "当前序列号已无可执行工序";
|
|
|
return false;
|
|
|
- }
|
|
|
- string nextstepcode = dh.getFieldDataByCondition("makeserial", "ms_nextstepcode", "ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakeCode + "'").ToString();
|
|
|
- string sourcestepcode = GetStepCodeBySource(iSource);
|
|
|
- if (nextstepcode == "")
|
|
|
- {
|
|
|
- oErrMessage = "当前序列号已无可执行工序";
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (nextstepcode == sourcestepcode)
|
|
|
- return true;
|
|
|
- else {
|
|
|
- oErrMessage = "资源" + iSource + "对应的工序是" + sourcestepcode + ",序列号" + iSnCode + "当前工序是" + nextstepcode;
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private bool CheckMakeStatus(string iMaCode)
|
|
|
- {
|
|
|
- if (dh.getFieldDataByCondition(" make ", "ma_statuscode", "ma_code='" + iMaCode + "' ").ToString() == "STARTED")
|
|
|
- return true;
|
|
|
- else
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 判断当前工序是否是第一道工序
|
|
|
- /// </summary>
|
|
|
- /// <param name="iSnCode"></param>
|
|
|
- /// <param name="iMakecode"></param>
|
|
|
- /// <param name="iSourceCode"></param>
|
|
|
- /// <returns></returns>
|
|
|
- public bool CheckIfFirstMakeSerial(string iSnCode, string iMakecode, string iSourceCode)
|
|
|
- {
|
|
|
- //选取当前的最小的执行顺序
|
|
|
- string CurrentStep = GetStepCodeBySource(iSourceCode);
|
|
|
- DataTable dt = (DataTable)dh.ExecuteSql("select min(mcd_detno) detno from makecraftdetail where mcd_macode='" + iMakecode + "'", "select");
|
|
|
- string detno = dt.Rows[0]["detno"].ToString();
|
|
|
- //判断当前最小的执行顺序是否有记录
|
|
|
- if (dh.getRowCount("makecraftdetail", "mcd_stepcode='" + CurrentStep + "' and mcd_macode='" + iMakecode + "' and mcd_detno ='" + detno + "'") > 0)
|
|
|
- {
|
|
|
- if (!dh.CheckExist("MakeSerial", "ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakecode + "'"))
|
|
|
+ }
|
|
|
+ if (nextstepcode == sourcestepcode)
|
|
|
+ return true;
|
|
|
+ else
|
|
|
{
|
|
|
- sql.Clear();
|
|
|
- sql.Append("Insert into MakeSerial (ms_id, ms_code, ms_sncode ,ms_prodcode, ms_indate,");
|
|
|
- sql.Append("ms_wccode,ms_craftcode,ms_craftname,ms_nextstepcode,ms_status,ms_makecode) select MAKESERIAL_SEQ.NEXTVAL,");
|
|
|
- sql.Append("'" + iSnCode + "','" + iSnCode + "',ma_prodcode,sysdate,ma_wccode,ma_craftcode,ma_craftname,'" + CurrentStep + "',0,ma_code ");
|
|
|
- sql.Append("from make left join makecraftdetail on ma_code =mcd_macode where ma_code='" + iMakecode + "' and mcd_stepcode='" + CurrentStep + "'");
|
|
|
- dh.ExecuteSql(sql.ToString(), "insert");
|
|
|
+ oErrMessage = "资源" + iSourceCode + "对应的工序是" + sourcestepcode + ",序列号" + iSnCode + "当前工序是" + nextstepcode;
|
|
|
+ return false;
|
|
|
}
|
|
|
- return true;
|
|
|
}
|
|
|
- else
|
|
|
- return false;
|
|
|
+ else return false;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 判断下一工序是否是送检工序
|
|
|
+ /// 判断工单是否已经下放
|
|
|
/// </summary>
|
|
|
+ /// <param name="iMaCode"></param>
|
|
|
/// <returns></returns>
|
|
|
- public bool CheckNextStepIfQC(string iSnCode, string iMakeCode, string iStepCode, string iCraftCode, string iUserName, out string oErrorMessage)
|
|
|
+ public bool CheckMakeStatus(string iMaCode, out string ErrorMessage)
|
|
|
{
|
|
|
- oErrorMessage = "";
|
|
|
- string IfQC = dh.getFieldDataByCondition("craft left join craftdetail on cd_crid=cr_id", "cd_ifoqc", "cr_code='" + iCraftCode + "' and cd_stepcode='" + iStepCode + "'").ToString();
|
|
|
- if (IfQC != "0" && IfQC != "")
|
|
|
+ string ma_statuscode = dh.getFieldDataByCondition(" make ", "ma_statuscode", "ma_code='" + iMaCode + "' ").ToString();
|
|
|
+ ErrorMessage = "";
|
|
|
+ if (ma_statuscode == "")
|
|
|
{
|
|
|
- DataTable dt = dh.getFieldsDataByCondition("make left join product on ma_prodcode=pr_code", new string[] { "ma_nowcheckqty", "pr_qcbatchqty", "ma_checkno", "ma_prodcode", "pr_qualmethod" }, "ma_code='" + iMakeCode + "'");
|
|
|
- if (dt.Rows.Count > 0)
|
|
|
- {
|
|
|
- string ma_nowcheckqty = dt.Rows[0]["ma_nowcheckqty"].ToString();
|
|
|
- string pr_qcbatchqty = dt.Rows[0]["pr_qcbatchqty"].ToString();
|
|
|
- string ma_checkno = dt.Rows[0]["ma_checkno"].ToString();
|
|
|
- string ma_prodcode = dt.Rows[0]["ma_prodcode"].ToString();
|
|
|
- string pr_qualmethod = dt.Rows[0]["pr_qualmethod"].ToString();
|
|
|
- if (pr_qcbatchqty != "" && pr_qcbatchqty != "0")
|
|
|
- {
|
|
|
- //当前批次的送检批数量大于物料资料中的抽检批数或者当前批次编号为空
|
|
|
- string checkno = "";
|
|
|
- if (int.Parse(ma_nowcheckqty == "" ? "0" : ma_nowcheckqty) >= int.Parse(pr_qcbatchqty) || ma_checkno == "")
|
|
|
- {
|
|
|
- //原有的抽检批次插入OQCBatch
|
|
|
- string ob_id = dh.GetSEQ("OQCBatch_SEQ");
|
|
|
- checkno = dh.GetSerialNumberByCaller("Make!CheckQC");
|
|
|
- sql.Clear();
|
|
|
- sql.Append("insert into OQCBatch (ob_id, ob_checkno,ob_makecode,ob_source,ob_indate,ob_checkman,ob_batchqty,ob_status,ob_prodcode,ob_projectcode)");
|
|
|
- sql.Append(" values('" + ob_id + "','" + checkno + "','" + iMakeCode + "', '工序',sysdate, '" + iUserName + "','" + ma_nowcheckqty + "','UNCHECK','" + ma_prodcode + "','" + pr_qualmethod + "')");
|
|
|
- sqls.Add(sql.ToString());
|
|
|
- sqls.Add("update makeserial set ms_checkno='" + checkno + "' where ms_makecode='" + iMakeCode + "' and ms_sncode='" + iSnCode + "'");
|
|
|
- sqls.Add("update make set ma_checkno='" + checkno + "',ma_nowcheckqty=1 where ma_code='" + iMakeCode + "'");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- sqls.Add("update makeserial set ms_checkno='" + ma_checkno + "' where ms_makecode='" + iMakeCode + "' and ms_sncode='" + iSnCode + "'");
|
|
|
- sqls.Add("update make set ma_nowcheckqty= ma_nowcheckqty+1 where ma_code='" + iMakeCode + "'");
|
|
|
- }
|
|
|
- dh.ExecuteSQLTran(sqls.ToArray());
|
|
|
- sqls.Clear();
|
|
|
- //如果制造单的ma_checkno没有值则新加入一个值
|
|
|
- string checkno1 = checkno == "" ? ma_checkno : checkno;
|
|
|
- string obd_obid = dh.getFieldDataByCondition("oqcbatch", "ob_id", "ob_checkno='" + checkno1 + "'").ToString();
|
|
|
- //插入抽检批次明细表
|
|
|
- sql.Clear();
|
|
|
- sql.Append("insert into OQCBatchDetail (obd_id,obd_obid,obd_sncode,obd_outboxcode,obd_makecode,obd_checkno,obd_builddate) ");
|
|
|
- sql.Append("select OQCBatchDetail_SEQ.nextval,'" + obd_obid + "',ms_sncode,ms_outboxcode,ms_makecode,ms_checkno,");
|
|
|
- sql.Append("sysdate from makeserial where ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakeCode + "'");
|
|
|
- dh.ExecuteSql(sql.ToString(), "insert");
|
|
|
- return true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- oErrorMessage = "请维护物料资料的抽检批数";
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- oErrorMessage = "制造单号不存在";
|
|
|
- return false;
|
|
|
- }
|
|
|
+ ErrorMessage = "工单号" + iMaCode + "不存在";
|
|
|
+ return false;
|
|
|
}
|
|
|
+ if (ma_statuscode == "STARTED")
|
|
|
+ return true;
|
|
|
else
|
|
|
{
|
|
|
- oErrorMessage = "当前工序的下一工序不是OQC检测";
|
|
|
+ ErrorMessage = "工单必须是已下放状态";
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
@@ -196,9 +107,10 @@ namespace MES_Interface
|
|
|
if (dt.Rows.Count > 0)
|
|
|
{
|
|
|
string em_name = dt.Rows[0]["em_name"].ToString();
|
|
|
- if (dt.Rows[0]["em_type"].ToString() == "admin" && iSourceCode == "")
|
|
|
+ if (iSourceCode == "")
|
|
|
{
|
|
|
- return true;
|
|
|
+ oErrorMessage = "岗位资源不允许为空";
|
|
|
+ return false;
|
|
|
}
|
|
|
dt = dh.getFieldsDatasByCondition("cs$empgroup left join cs$userresource on ur_groupcode=eg_groupcode left join source on ur_resourcecode=sc_code", new string[] { "ur_resourcecode" }, "eg_emcode = '" + iUserCode + "' and sc_statuscode='AUDITED'");
|
|
|
//如果存在该编号
|
|
|
@@ -220,6 +132,33 @@ namespace MES_Interface
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ public bool CheckStepAttribute(string iCaller, string iSourceCode, out string oErrorMessage)
|
|
|
+ {
|
|
|
+ oErrorMessage = "";
|
|
|
+ string[] param = new string[] { iCaller, iSourceCode, oErrorMessage };
|
|
|
+ dh.CallProcedure("CS_CHECKSTEPATTRIBUTE", ref param);
|
|
|
+ if (oErrorMessage == "" || oErrorMessage == null)
|
|
|
+ return true;
|
|
|
+ else
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ public bool CheckStepSNAndMacode(string iMakeCode, string iSourceCode, string iSN, string iUserCode, out string oMakeCode, out string oMsID, out string oErrorMessage)
|
|
|
+ {
|
|
|
+ oErrorMessage = "";
|
|
|
+ oMakeCode = "";
|
|
|
+ oMsID = "";
|
|
|
+ string[] param = new string[] { iMakeCode, iSourceCode, iSN, iUserCode, oMakeCode, oMsID, oErrorMessage };
|
|
|
+ dh.CallProcedure("CS_CHECKSTEPSNANDMACODE", ref param);
|
|
|
+ oMakeCode = param[4];
|
|
|
+ oMsID = param[5];
|
|
|
+ oErrorMessage = param[6];
|
|
|
+ if (oErrorMessage == "" || oErrorMessage == null || oErrorMessage == "null")
|
|
|
+ return true;
|
|
|
+ else
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 分配Mac地址和BT地址
|
|
|
/// </summary>
|
|
|
@@ -436,7 +375,7 @@ namespace MES_Interface
|
|
|
return true;
|
|
|
else
|
|
|
{
|
|
|
- oErrorMessage = "当前序列号" + iSnCode + "不存在生产记录";
|
|
|
+ oErrorMessage = "序列号:" + iSnCode + " 未归属工单";
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
@@ -510,38 +449,28 @@ namespace MES_Interface
|
|
|
/// <summary>
|
|
|
/// 记录操作日志
|
|
|
/// </summary>
|
|
|
- /// <param name="iMakeCode"></param>
|
|
|
/// <param name="iSnCode"></param>
|
|
|
- public void InsertMakeProcess(string iSnCode, string iMakeCode, string result, string iUserName)
|
|
|
+ /// <param name="iMakeCode"></param>
|
|
|
+ /// <param name="iMPKind"></param>
|
|
|
+ /// <param name="iResult"></param>
|
|
|
+ /// <param name="iUserName"></param>
|
|
|
+ public void InsertMakeProcess(string iSnCode, string iMakeCode, string iSourceCode, string iMPKind, string iResult, string iUserName)
|
|
|
{
|
|
|
+ string CurrentStep = "";
|
|
|
+ string LineCode = "";
|
|
|
+ string CurrentStepName = "";
|
|
|
+ GetStepCodeAndNameAndLineBySource(iSourceCode, ref CurrentStep, ref CurrentStepName, ref LineCode);
|
|
|
sql.Clear();
|
|
|
sql.Append("insert into MakeProcess(mp_id,mp_makecode,mp_maid, mp_mscode,mp_sncode,mp_stepcode,mp_stepname,");
|
|
|
- sql.Append("mp_craftcode,mp_craftname,mp_kind,mp_result,mp_indate,mp_inman,mp_wccode,mp_linecode,mp_sourcecode) ");
|
|
|
+ sql.Append("mp_craftcode,mp_craftname,mp_kind,mp_result,mp_indate,mp_inman,mp_wccode,mp_linecode,mp_sourcecode,mp_snstatus,mp_sncheckno,mp_snoutboxcode)");
|
|
|
sql.Append("select MakeProcess_seq.nextval, ma_code,ma_id,ms_code,ms_sncode,mcd_stepcode,mcd_stepname,");
|
|
|
- sql.Append("ma_craftcode,ma_craftname,ma_kind,'" + result + "',sysdate,'" + iUserName + "',ma_wccode,ma_linecode,''");
|
|
|
- sql.Append("from make left join makecraftdetail on mcd_macode=ma_code left join makeserial on ms_makecode=ma_code ");
|
|
|
- sql.Append("where ms_sncode='" + iSnCode + "' and ma_code='" + iMakeCode + "'");
|
|
|
- //插入makeprocess
|
|
|
+ sql.Append("ma_craftcode,ma_craftname,'" + iMPKind + "','" + iResult + "',sysdate,'" + iUserName + "',ma_wccode,'" + LineCode + "','" + iSourceCode + "',");
|
|
|
+ sql.Append("ms_status,ms_checkno,ms_outboxcode from make left join makecraftdetail on mcd_macode=ma_code left join makeserial on ms_makecode=ma_code ");
|
|
|
+ sql.Append("where ms_sncode='" + iSnCode + "' and ma_code='" + iMakeCode + "' and mcd_stepcode='" + CurrentStep + "'");
|
|
|
dh.ExecuteSql(sql.ToString(), "insert");
|
|
|
sql.Clear();
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 记录一般操作日志
|
|
|
- /// </summary>
|
|
|
- /// <param name="inMan"></param>
|
|
|
- /// <param name="Content"></param>
|
|
|
- /// <param name="Result"></param>
|
|
|
- /// <param name="Search"></param>
|
|
|
- /// <param name="Code"></param>
|
|
|
- public void InsertMessageLog(string inMan, string Content, string Result, string Search, string Code)
|
|
|
- {
|
|
|
- sql.Clear();
|
|
|
- sql.Append("insert into messagelog (ml_id,ml_date,ml_man,ml_content,ml_result,ml_search,code) ");
|
|
|
- sql.Append("values (messagelog_seq.nextval,sysdate,'" + inMan + "','" + Content + "','" + Result + "','" + Search + "','" + Code + "')");
|
|
|
- dh.ExecuteSql(sql.ToString(), "insert");
|
|
|
- }
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 保存Mac地址和BT地址
|
|
|
/// </summary>
|
|
|
@@ -560,12 +489,14 @@ namespace MES_Interface
|
|
|
{
|
|
|
string sql = "update MakeSerial set ms_mac=:iWifi,ms_bt=:iBT,ms_othcode1=:iCode1,ms_othcode2=:iCode2,ms_othcode3=:iCode3 where ms_sncode='" + iSN + "' and ms_makecode='" + MakeCode + "'";
|
|
|
dh.ExecuteSql(sql, "update", iWIFI, iBT, iCode1, iCode2, iCode3);
|
|
|
- if (dh.CheckExist("SnInfo", "si_sn='" + iSN + "'"))
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql("select si_sn from SnInfo where si_sn='" + iSN + "' or si_sn in (select sn from makesnrelation where firstsn='" + iSN + "' or sn='" + iSN + "')", "select");
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
{
|
|
|
- sql = "update SnInfo set si_mac=:iMac,si_bt=:iBT,si_othcode1=:iCode1,si_othcode2=:iCode2,si_othcode3=:iCode3 where si_sncode='" + iSN + "'";
|
|
|
+ sql = "update SnInfo set si_mac=:iMac,si_bt=:iBT,si_othcode1=:iCode1,si_othcode2=:iCode2,si_othcode3=:iCode3 where si_sn='" + dt.Rows[0]["si_sn"].ToString() + "'";
|
|
|
dh.ExecuteSql(sql, "update", iWIFI, iBT, iCode1, iCode2, iCode3);
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
sql = "insert into SnInfo(si_id,si_sn,si_mac,si_bt,si_othcode1,si_othcode2,si_othcode3) values(SnInfo_seq.nextval,:iSn,:iWifi,:iBt,:iCode1,:iCode2,:iCode3)";
|
|
|
dh.ExecuteSql(sql, "insert", iSN, iWIFI, iBT, iCode1, iCode2, iCode3);
|
|
|
}
|
|
|
@@ -575,6 +506,31 @@ namespace MES_Interface
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ public bool SetStepFinish(string iMakeCode, string iSourceCode, string iSN, string iMPKind, string iResult, string iUserCode, out string oErrorMessage)
|
|
|
+ {
|
|
|
+ oErrorMessage = "";
|
|
|
+ string StepCode = dh.getFieldDataByCondition("Makeserial", "ms_stepcode", "ms_sncode='" + iSN + "'").ToString();
|
|
|
+ string CurrentStep = GetStepCodeBySource(iSourceCode);
|
|
|
+ if (StepCode == CurrentStep)
|
|
|
+ {
|
|
|
+ InsertMakeProcess(iSN, iMakeCode, iSourceCode, iMPKind, iResult, iUserCode);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return CS_SetFinish(iMakeCode, iSourceCode, iSN, iUserCode, out oErrorMessage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool CS_SetFinish(string iMakeCode, string iSourceCode, string iSN, string iUserCode, out string oErrorMessage)
|
|
|
+ {
|
|
|
+ oErrorMessage = "";
|
|
|
+ string[] param = new string[] { iMakeCode, iSourceCode, iSN, iUserCode, oErrorMessage };
|
|
|
+ dh.CallProcedure("CS_SETSTEPFINISH", ref param);
|
|
|
+ if (oErrorMessage == "" || oErrorMessage == null)
|
|
|
+ return true;
|
|
|
+ else
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 方法说明:测试详细信息录入系统,针对一个SN多个测试项目结果可循环调用
|
|
|
@@ -637,43 +593,34 @@ namespace MES_Interface
|
|
|
/// </summary>
|
|
|
/// <param name="iSnCode"></param>
|
|
|
/// <param name="iMakeCode"></param>
|
|
|
- /// <param name="iUserName"></param>
|
|
|
+ /// <param name="iUserCode"></param>
|
|
|
/// <param name="iSourceCode"></param>
|
|
|
/// <param name="iBadCode"></param>
|
|
|
/// <param name="iBadRemark"></param>
|
|
|
/// <param name="oErrorMessage"></param>
|
|
|
/// <returns></returns>
|
|
|
- public bool SetTestNGDetail(string iSnCode, string iMakeCode, string iUserName, string iSourceCode, string iResult, string[] iBadCode, string[] iBadRemark, out string oErrorMessage)
|
|
|
+ public bool SetTestNGDetail(string iSnCode, string iMakeCode, string iUserCode, string iSourceCode, string iResult, string[] iBadGroupCode, string[] iBadCode, string[] iBadRemark, out string oErrorMessage)
|
|
|
{
|
|
|
oErrorMessage = "";
|
|
|
string StepCode = "";
|
|
|
string StepName = "";
|
|
|
if (iResult == "" || iResult == null)
|
|
|
- {
|
|
|
iResult = "检查未通过";
|
|
|
- }
|
|
|
GetStepCodeAndNameBySource(iSourceCode, ref StepCode, ref StepName);
|
|
|
+ string ms_status = dh.getFieldDataByCondition("makeserial", "ms_status", "ms_sncode='" + iSnCode + "'").ToString();
|
|
|
sql.Clear();
|
|
|
- sql.Append("insert into makebad(mb_id,mb_makecode,mb_mscode,mb_sncode,mb_inman,");
|
|
|
- sql.Append("mb_indate,mb_stepcode,mb_sourcecode,mb_badcode,mb_badtable,mb_soncode,mb_status,mb_badremark)");
|
|
|
- sql.Append("select makebad_seq.nextval,ma_code,ms_code,ms_sncode,'" + iUserName + "',sysdate,'" + StepCode + "',ms_sourcecode,:bc_code,'',");
|
|
|
+ sql.Append("insert into makebad(mb_id,mb_makecode,mb_mscode,mb_sncode,mb_inman,mb_indate,mb_stepcode");
|
|
|
+ sql.Append(",mb_sourcecode,mb_badcode,mb_bgcode,mb_badtable,mb_soncode,mb_status,mb_badremark)");
|
|
|
+ sql.Append("select makebad_seq.nextval,ma_code,ms_code,ms_sncode,'" + iUserCode + "',sysdate,'" + StepCode + "',ms_sourcecode,:bc_code,:bg_code,'',");
|
|
|
sql.Append("sp_soncode,'0',:bc_remark from make left join makeSerial on ms_makecode=ma_code left join stepProduct on ");
|
|
|
sql.Append("sp_mothercode=ma_prodcode and sp_stepcode=ms_nextstepcode where ms_sncode='" + iSnCode + "'");
|
|
|
- dh.BatchInsert(sql.ToString(), new string[] { "bc_code", "bc_remark" }, iBadCode, iBadRemark);
|
|
|
- //更新序列号状态,待维修,返修工序
|
|
|
- string st_rstepcode = dh.getFieldDataByCondition("step", "st_rstepcode", "st_code='" + StepCode + "'").ToString();
|
|
|
- sql.Clear();
|
|
|
- sql.Append("update makeserial set ms_status = 3,ms_nextstepcode ='" + st_rstepcode + "', ");
|
|
|
- sql.Append("ms_stepcode ='" + StepCode + "' where ms_sncode ='" + iSnCode + "' and ms_makecode ='" + iMakeCode + "'");
|
|
|
- dh.ExecuteSql(sql.ToString(), "update");
|
|
|
- //更新makecraftdetail 工单采集记录表,根据工单号和工序编号 记录当前测试工序采集数量
|
|
|
- dh.UpdateByCondition("makecraftdetail", "mcd_inqty=mcd_inqty+1,mcd_outqty = mcd_outqty + 1", "mcd_macode='" + iMakeCode + "' and mcd_stepcode='" + StepCode + "'");
|
|
|
+ dh.BatchInsert(sql.ToString(), new string[] { "bc_code", "bg_code", "bc_remark" }, iBadCode, iBadGroupCode, iBadRemark);
|
|
|
//更新序列号已经采集的工序 ms_paststep 已采集数据,更新下一工序
|
|
|
- dh.UpdateByCondition("makeserial", "ms_paststep = ms_paststep ||'," + StepCode + "'", "ms_sncode='" + iSnCode + "'");
|
|
|
- //记录操作日志
|
|
|
- InsertMakeProcess(iSnCode, iMakeCode, iResult, iUserName);
|
|
|
+ dh.UpdateByCondition("makeserial", "ms_paststep = ms_paststep ||'," + StepCode + "',ms_status=3", "ms_sncode='" + iSnCode + "'");
|
|
|
//判断当前采集点是否为扣料工序cd_ifreduce =-1 则为扣料工序
|
|
|
- SetCollectionFinish(iSnCode, iMakeCode, iUserName, iSourceCode, out oErrorMessage);
|
|
|
+ //之前保存的不良就不再调用
|
|
|
+ if (ms_status != "3")
|
|
|
+ SetStepFinish(iMakeCode, iSourceCode, iSnCode, "不良采集", iResult, iUserCode, out oErrorMessage);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -697,8 +644,8 @@ namespace MES_Interface
|
|
|
return false;
|
|
|
}
|
|
|
sql.Clear();
|
|
|
- sql.Append("select nvl(cd_ifreduce,0) cd_ifreduce from craft left join ");
|
|
|
- sql.Append("craftdetail on cd_crid=cr_id where cr_code=(select ma_craftcode from makeserial left join make on ma_code = ms_makecode ");
|
|
|
+ sql.Append("select nvl(cd_ifreduce,0) cd_ifreduce from craft left join craftdetail on cd_crid=cr_id ");
|
|
|
+ sql.Append("where cr_code=(select ma_craftcode from makeserial left join make on ma_code = ms_makecode ");
|
|
|
sql.Append("where ms_sncode = '" + iSnCode + "') and cd_stepcode='" + StepCode + "'");
|
|
|
DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
|
|
|
sql.Clear();
|
|
|
@@ -708,21 +655,21 @@ namespace MES_Interface
|
|
|
if (cd_ifreduce == "-1")
|
|
|
{
|
|
|
sql.Clear();
|
|
|
- sql.Append("select dsl_location,dsl_table, max(dsl_baseqty) baseqty from devsmtlocation where dsl_makecode='" + iMakeCode + "' and ");
|
|
|
+ sql.Append("select dsl_location,dsl_table,max(dsl_baseqty) baseqty from devsmtlocation where dsl_makecode='" + iMakeCode + "' and ");
|
|
|
sql.Append("dsl_linecode='" + LineCode + "' and dsl_status=0 and dsl_remainqty>0 and dsl_invalidtime is null group by dsl_location,dsl_table");
|
|
|
dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
|
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
{
|
|
|
sql.Clear();
|
|
|
- sql.Append("selet dsl_id,dsl_remainqty from devsmtlocation where dsl_makecode='" + iMakeCode + "' and dsl_linecode='" + LineCode + "' ");
|
|
|
+ sql.Append("select dsl_id,dsl_remainqty from devsmtlocation where dsl_makecode='" + iMakeCode + "' and dsl_linecode='" + LineCode + "' ");
|
|
|
sql.Append("and dsl_status=0 and dsl_remainqty>0 and dsl_invalidtime is null and rownum<3 order by dsl_id asc ");
|
|
|
DataTable dt1 = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
|
|
|
- for (int j = 0; j < dt.Rows.Count; j++)
|
|
|
+ for (int j = 0; j < dt1.Rows.Count; j++)
|
|
|
{
|
|
|
//外层循环的值dt
|
|
|
double baseqty = (double)dt.Rows[i]["baseqty"];
|
|
|
- double dsl_remainqty = (double)dt.Rows[i]["dsl_remainqty"];
|
|
|
//内层循环的值dt1
|
|
|
+ double dsl_remainqty = (double)dt1.Rows[j]["dsl_remainqty"];
|
|
|
string dsl_id = dt1.Rows[j]["dsl_id"].ToString();
|
|
|
if (baseqty > 0)
|
|
|
{
|
|
|
@@ -730,21 +677,21 @@ namespace MES_Interface
|
|
|
{
|
|
|
sql.Clear();
|
|
|
sql.Append("update devsmtlocation set dsl_remainqty=0,dsl_invalidtime =sysdate, dsl_validtime =(case when dsl_validtime ");
|
|
|
- sql.Append("is null then sysdate else dsl_validtime),dsl_status=-1 where dsl_id=" + dsl_id);
|
|
|
+ sql.Append("is null then sysdate else dsl_validtime end),dsl_status=-1 where dsl_id=" + dsl_id);
|
|
|
dh.ExecuteSql(sql.ToString(), "update");
|
|
|
baseqty -= dsl_remainqty;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sql.Clear();
|
|
|
- sql.Append("update devsmtlocation set dsl_remainqty=dsl_remainqty-NVL(dsl_baseqty,0),dsl_efftime=(case when");
|
|
|
- sql.Append("dsl_validtime is null then sysdate else dsl_validtime) where dsl_id=" + dsl_id);
|
|
|
+ sql.Append("update devsmtlocation set dsl_remainqty=dsl_remainqty-NVL(dsl_baseqty,0),DSL_INVALIDTIME=(case when");
|
|
|
+ sql.Append("dsl_validtime is null then sysdate else dsl_validtime end) where dsl_id=" + dsl_id);
|
|
|
dh.ExecuteSql(sql.ToString(), "update");
|
|
|
baseqty = 0;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
- dh.ExecuteSql("update devsmtlocation set dsl_efftime=sysdate where dsl_id=" + dsl_id, "update");
|
|
|
+ dh.ExecuteSql("update devsmtlocation set DSL_INVALIDTIME=sysdate where dsl_id=" + dsl_id, "update");
|
|
|
}
|
|
|
}
|
|
|
sql.Clear();
|
|
|
@@ -811,7 +758,7 @@ namespace MES_Interface
|
|
|
/// <param name="iUserName"></param>
|
|
|
/// <param name="oErrorMessage"></param>
|
|
|
/// <returns></returns>
|
|
|
- public bool SetMaterialDown(string iSnCode, string iBarCode, string iCurrentStep, string iUserName, out string oErrorMessage)
|
|
|
+ public bool SetMaterialDown(string iSnCode, string iBarCode, string iSourceCode, string iCurrentStep, string iUserName, out string oErrorMessage)
|
|
|
{
|
|
|
//序列号不为空的时候
|
|
|
oErrorMessage = "";
|
|
|
@@ -849,10 +796,10 @@ namespace MES_Interface
|
|
|
string cm_stepcode = dt.Rows[0]["cm_stepcode"].ToString();
|
|
|
string cm_mccode = dt.Rows[0]["cm_mccode"].ToString();
|
|
|
dh.ExecuteSql("delete from Craftmaterial where cm_id=" + cm_id, "delete");
|
|
|
- InsertMakeProcess(ms_macode, iSnCode, "下料成功", iUserName);
|
|
|
+ InsertMakeProcess(ms_macode, iSnCode, iSourceCode, "下料操作", "下料成功", iUserName);
|
|
|
int count = dh.getRowCount("craftMaterial", "cm_mccode='" + cm_mccode + "' and cm_stepcode='" + cm_stepcode + "' and cm_sncode='" + iSnCode + "'");
|
|
|
if (count == 0)
|
|
|
- dh.UpdateByCondition("makecraftdetail", "mcd_inqty=mcd_inqty-1,mcd_outqty=mcd_outqty-1,mcd_okqty = mcd_okqty - 1", "mcd_mccode='" + cm_mccode + "' and mcd_stepcode='" + cm_stepcode + "'");
|
|
|
+ dh.UpdateByCondition("makecraftdetail ", "mcd_inqty=mcd_inqty-1,mcd_outqty=mcd_outqty-1,mcd_okqty = mcd_okqty - 1", "mcd_mccode='" + cm_mccode + "' and mcd_stepcode='" + cm_stepcode + "'");
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
@@ -870,139 +817,9 @@ namespace MES_Interface
|
|
|
/// <param name="iResult"></param>
|
|
|
/// <param name="oErrorMessage"></param>
|
|
|
/// <returns></returns>
|
|
|
- public bool UpdateMakeMessage(string iSnCode, string iMakeCode, string iSourceCode, string iUserName, string iResult, out string oErrorMessage)
|
|
|
+ public bool UpdateMakeMessage(string iSnCode, string iMakeCode, string iMPKind, string iSourceCode, string iUserCode, string iResult, out string oErrorMessage)
|
|
|
{
|
|
|
- oErrorMessage = "";
|
|
|
- string StepCode = "";
|
|
|
- string StepName = "";
|
|
|
- string LineCode = "";
|
|
|
- if (iResult == "" || iResult == null)
|
|
|
- {
|
|
|
- iResult = "测试合格";
|
|
|
- }
|
|
|
- GetStepCodeAndNameAndLineBySource(iSourceCode, ref StepCode, ref StepName, ref LineCode);
|
|
|
- //判断是否上料工序,如果是的话执行该步骤
|
|
|
- DataTable dt = dh.getFieldsDataByCondition("make left join craft on cr_code=ma_craftcode left join craftdetail on cd_crid=cr_id", new string[] { "cd_ifinput", "cr_code" }, "ma_code='" + iMakeCode + "' and cd_stepcode='" + StepCode + "'");
|
|
|
- string Yes_No = dh.GetConfig("BatchNumber", "MESSetting").ToString();
|
|
|
- string cr_code = "";
|
|
|
- if (dt.Rows.Count > 0)
|
|
|
- {
|
|
|
- cr_code = dt.Rows[0]["cr_code"].ToString();
|
|
|
- if (dt.Rows[0]["cd_ifinput"].ToString() != "0")
|
|
|
- {
|
|
|
- sql.Clear();
|
|
|
- sql.Append("select wm_concat(mss_prodcode) code,count(1) cn from (select sum(nvl(mss_remain,0))remain,mss_prodcode,max(mss_baseqty) mss_baseqty ");
|
|
|
- sql.Append("from makesourcestock where mss_makecode='" + iMakeCode + "' and mss_stepcode='" + StepCode + "' ");
|
|
|
- sql.Append("and mss_linecode='" + LineCode + "' group by mss_prodcode)T where T.remain<mss_baseqty and rownum<20");
|
|
|
- dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
|
|
|
- //如果配置的是Yes
|
|
|
- if (Yes_No != "0")
|
|
|
- {
|
|
|
- //如果批次料不足
|
|
|
- if (dt.Rows.Count > 0 && int.Parse(dt.Rows[0]["cn"].ToString()) > 0)
|
|
|
- {
|
|
|
- oErrorMessage += "批次物料:" + iSnCode + "," + dt.Rows[0]["code"] + "岗位备料不足";
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- //如果配置的是No 或者批次料足够
|
|
|
- else if (Yes_No == "0" || dt.Rows.Count == 0)
|
|
|
- {
|
|
|
- //扣减批次数量,插入数据至用料表
|
|
|
- sql.Clear();
|
|
|
- sql.Append("select mss_prodcode , max(mss_baseqty) baseqty from makesourcestock ");
|
|
|
- sql.Append("mss_makecode='" + iMakeCode + "' and mss_stepcode='" + StepCode + "' and mss_linecode='" + LineCode + "' group by mss_prodcode");
|
|
|
- DataTable dt1 = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
|
|
|
- for (int i = 0; i < dt1.Rows.Count; i++)
|
|
|
- {
|
|
|
- string prodcode = dt1.Rows[i]["mss_prodcode"].ToString();
|
|
|
- //本次上料需要扣除的数量
|
|
|
- int baseqty = int.Parse(dt1.Rows[i]["baseqty"].ToString());
|
|
|
- sql.Clear();
|
|
|
- sql.Append("select mss_remain,mss_useqty,mss_id ,mss_barcode from makesourcestock where mss_makecode='" + iMakeCode + "' and ");
|
|
|
- sql.Append("mss_stepcode='" + StepCode + "' and mss_prodcode='" + prodcode + "' and mss_linecode='" + LineCode + "' and mss_remain >0 order by mss_id asc");
|
|
|
- DataTable dt2 = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
|
|
|
- for (int j = 0; i < dt2.Rows.Count; j++)
|
|
|
- {
|
|
|
- int remain = int.Parse(dt2.Rows[j]["mss_remain"].ToString());
|
|
|
- int useqty = int.Parse(dt2.Rows[j]["mss_useqty"].ToString());
|
|
|
- string mss_id = dt2.Rows[j]["mss_id"].ToString();
|
|
|
- string barcode = dt2.Rows[j]["mss_barcode"].ToString();
|
|
|
- //如果可扣数量大于0
|
|
|
- if (baseqty > 0)
|
|
|
- {
|
|
|
- //并且可扣数量大于剩余数量
|
|
|
- if (baseqty > remain)
|
|
|
- {
|
|
|
- sql.Clear();
|
|
|
- sql.Append("update makesourcestock set mss_useqty=nvl(mss_useqty,0)+mss_remain,mss_remain = 0 where mss_id='" + mss_id + "' ");
|
|
|
- dh.ExecuteSql(sql.ToString(), "update");
|
|
|
- //扣减剩余数量
|
|
|
- baseqty -= remain;
|
|
|
- }
|
|
|
- else if (remain >= baseqty)
|
|
|
- {
|
|
|
- dh.ExecuteSql("update makesourcestock set mss_remain = mss_remain-baseqty where mss_id =" + mss_id, "select");
|
|
|
- baseqty = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //查询批次和批数量
|
|
|
- int batchqty = 0;
|
|
|
- string checkno = "";
|
|
|
- dt = (DataTable)dh.ExecuteSql("select count(ms_checkno) count,ms_checkno from makeserial where ms_checkno=(select ms_checkno from makeserial where ms_sncode='" + iSnCode + "') group by ms_checkno", "select");
|
|
|
- if (dt.Rows.Count > 0)
|
|
|
- {
|
|
|
- batchqty = int.Parse(dt.Rows[0]["count"].ToString());
|
|
|
- checkno = dt.Rows[0]["ms_checkno"].ToString();
|
|
|
- }
|
|
|
- object nextstepcode = dh.getFieldDataByCondition("makecraftdetail", "mcd_nextstepcode", "mcd_macode='" + iMakeCode + "' and mcd_stepcode='" + StepCode + "'");
|
|
|
- if (iResult.Contains("批次通过") && dt.Rows.Count > 0)
|
|
|
- {
|
|
|
- //更新执行的数量
|
|
|
- sqls.Add("update makecraftdetail set mcd_inqty=mcd_inqty+" + batchqty + ",mcd_outqty = mcd_outqty + " + batchqty + ",mcd_okqty = mcd_okqty + " + batchqty + " where mcd_macode='" + iMakeCode + "' and mcd_stepcode='" + StepCode + "' ");
|
|
|
- //更新makeSerial 的下一工序
|
|
|
- sqls.Add("update makeserial set ms_paststep = ms_paststep || '," + StepCode + "',ms_nextstepcode='" + nextstepcode.ToString() + "' where ms_checkno='" + checkno + "'");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //更新执行的数量
|
|
|
- sqls.Add("update makecraftdetail set mcd_inqty=mcd_inqty+1,mcd_outqty = mcd_outqty + 1,mcd_okqty = mcd_okqty + 1 where mcd_macode='" + iMakeCode + "' and mcd_stepcode='" + StepCode + "' ");
|
|
|
- //更新makeSerial 的下一工序
|
|
|
- sqls.Add("update makeserial set ms_paststep = ms_paststep || '," + StepCode + "',ms_nextstepcode='" + nextstepcode.ToString() + "' where ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakeCode + "'");
|
|
|
- }
|
|
|
- //更新序列号已经采集的工序 ms_paststep 已采集数据,更新下一工序
|
|
|
- dh.ExecuteSQLTran(sqls.ToArray());
|
|
|
- sqls.Clear();
|
|
|
- //记录操作日志
|
|
|
- InsertMakeProcess(iSnCode, iMakeCode, iResult, iUserName);
|
|
|
- //检测下道工序是否存在,不存在 更新状态为已完成
|
|
|
- if (nextstepcode == null || nextstepcode.ToString() == "")
|
|
|
- {
|
|
|
- if (iResult.Contains("批次通过"))
|
|
|
- {
|
|
|
- sqls.Add("update make set ma_madeqty=ma_madeqty+" + batchqty + " where ma_code='" + iMakeCode + "'");
|
|
|
- sqls.Add("update makeserial set ms_status=2 where ms_checkno='" + checkno + "'");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- sqls.Add("update make set ma_madeqty=ma_madeqty+1 where ma_code='" + iMakeCode + "'");
|
|
|
- sqls.Add("update makeserial set ms_status=2 where ms_sncode='" + iSnCode + "'");
|
|
|
- }
|
|
|
- dh.ExecuteSQLTran(sqls.ToArray());
|
|
|
- sqls.Clear();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- CheckNextStepIfQC(iSnCode, iMakeCode, nextstepcode.ToString(), cr_code, iUserName, out oErrorMessage);
|
|
|
- }
|
|
|
- // 将数据插入craftmaterial表
|
|
|
- SetCollectionFinish(iSnCode, iMakeCode, iUserName, iSourceCode, out oErrorMessage);
|
|
|
- return true;
|
|
|
+ return SetStepFinish(iMakeCode, iSourceCode, iSnCode, iMPKind, iResult, iUserCode, out oErrorMessage);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|