|
|
@@ -19,10 +19,11 @@ namespace UAS_MES_NEW.Make
|
|
|
//查询结果:craftdetail 中 cd_detno 最小的 cd_stepcode
|
|
|
string cdStepCode = "";
|
|
|
|
|
|
- //查询结果:makeserial 中的主键、工艺编号与产品编号
|
|
|
+ //查询结果:makeserial 中的主键、工艺编号、产品编号与当前下一工序
|
|
|
string msId = "";
|
|
|
string craftCode = "";
|
|
|
string prodCode = "";
|
|
|
+ string nextStepCode = "";
|
|
|
|
|
|
public Make_StepType()
|
|
|
{
|
|
|
@@ -91,8 +92,8 @@ namespace UAS_MES_NEW.Make
|
|
|
|
|
|
string sn = sncode.Text.Trim();
|
|
|
|
|
|
- //一、按序列号取 makeserial 的主键、工艺编号与产品编号
|
|
|
- DataTable dtSn = (DataTable)dh.ExecuteSql("select ms_id,ms_craftcode,ms_prodcode from makeserial where ms_sncode='" + sn + "'", "select");
|
|
|
+ //一、按序列号取 makeserial 的主键、工艺编号、产品编号与当前下一工序
|
|
|
+ DataTable dtSn = (DataTable)dh.ExecuteSql("select ms_id,ms_craftcode,ms_prodcode,ms_nextstepcode from makeserial where ms_sncode='" + sn + "'", "select");
|
|
|
if (dtSn.Rows.Count == 0)
|
|
|
{
|
|
|
OperateResult.AppendText("<<" + sn + "不存在\n", Color.Red, sncode);
|
|
|
@@ -103,6 +104,7 @@ namespace UAS_MES_NEW.Make
|
|
|
msId = dtSn.Rows[0]["ms_id"].ToString();
|
|
|
craftCode = dtSn.Rows[0]["ms_craftcode"].ToString();
|
|
|
prodCode = dtSn.Rows[0]["ms_prodcode"].ToString();
|
|
|
+ nextStepCode = dtSn.Rows[0]["ms_nextstepcode"].ToString();
|
|
|
|
|
|
//二、按工艺编号+产品编号+工序类型取 craftdetail 明细,cd_detno 升序取第一条即最小的 cd_stepcode
|
|
|
DataTable dtStep = (DataTable)dh.ExecuteSql("select cd_stepcode from craft left join craftdetail on cd_crid=cr_id where cr_code='" + craftCode + "' and cr_prodcode='" + prodCode + "' and CD_STEPTYPE='" + stepTypeCode + "' order by cd_detno", "select");
|
|
|
@@ -116,10 +118,35 @@ namespace UAS_MES_NEW.Make
|
|
|
}
|
|
|
cdStepCode = dtStep.Rows[0]["cd_stepcode"].ToString();
|
|
|
|
|
|
- //三、把查到的工序编号回写到 makeserial 的下道工序字段(用主键 ms_id 更新)
|
|
|
+ //三、检查 makeserial.ms_nextstepcode 到本次查到的工序之间是否存在未跳站的中间工序
|
|
|
+ // cd_detno 落在两者之间 nvl(cd_ifjump,0)=0 的记录即为必须完成却未完成的工序
|
|
|
+ if (nextStepCode != "")
|
|
|
+ {
|
|
|
+ DataTable dtJump = (DataTable)dh.ExecuteSql("select a.cd_detno,a.cd_stepcode from craftdetail a where a.cd_crid=(select cr_id from craft where cr_code='" + craftCode + "' and cr_prodcode='" + prodCode + "')"
|
|
|
+ + " and a.cd_detno>(select b.cd_detno from craftdetail b where b.cd_crid=a.cd_crid and b.cd_stepcode='" + nextStepCode + "' and rownum=1)"
|
|
|
+ + " and a.cd_detno<(select c.cd_detno from craftdetail c where c.cd_crid=a.cd_crid and c.cd_stepcode='" + cdStepCode + "' and rownum=1)"
|
|
|
+ + " and nvl(a.cd_ifjump,0)=0"
|
|
|
+ + " order by a.cd_detno", "select");
|
|
|
+ if (dtJump.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ //取 ms_nextstepcode 对应的工序名称一并在提示中给出
|
|
|
+ DataTable dtNextName = (DataTable)dh.ExecuteSql("select st_name from step where st_code='" + nextStepCode + "'", "select");
|
|
|
+ string nextStepName = dtNextName.Rows.Count > 0 ? dtNextName.Rows[0]["st_name"].ToString() : "";
|
|
|
+ OperateResult.AppendText("<<" + sn + "中间工序未完成,下一工序是" + nextStepCode + "(" + nextStepName + ")\n", Color.Red, sncode);
|
|
|
+ sncode.Clear();
|
|
|
+ sncode.Focus();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //四、关联 step 表取下一工序名称
|
|
|
+ DataTable dtStepName = (DataTable)dh.ExecuteSql("select st_name from step where st_code='" + cdStepCode + "'", "select");
|
|
|
+ string stepName = dtStepName.Rows.Count > 0 ? dtStepName.Rows[0]["st_name"].ToString() : "";
|
|
|
+
|
|
|
+ //五、把查到的工序编号回写到 makeserial 的下道工序字段(用主键 ms_id 更新)
|
|
|
dh.ExecuteSql("update makeserial set ms_nextstepcode='" + cdStepCode + "' where ms_id='" + msId + "'", "update");
|
|
|
|
|
|
- OperateResult.AppendText("<<" + sn + "执行" + stepTypeName + ",下一工序为" + cdStepCode + "\n", Color.Green, sncode);
|
|
|
+ OperateResult.AppendText("<<" + sn + "执行" + stepTypeName + ",下一工序为" + cdStepCode + "(" + stepName + ")\n", Color.Green, sncode);
|
|
|
sncode.Clear();
|
|
|
sncode.Focus();
|
|
|
}
|