123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- using System.Collections.Generic;
- using System.Data;
- using System.Text;
- using UAS_XmlAnalysor;
- namespace UAS_XmlAnalysor
- {
- class LogicHandler
- {
- public LogicHandler() { }
- public static DataHelper dh = new DataHelper();
- //用于拼接SQL
- static StringBuilder sql = new StringBuilder();
- //用于存放批量执行的SQL
- static List<string> sqls = new List<string>();
- public static 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;
- }
- public static void AutoPassLog(string iSN, string iSource, string iMakeCode, string iDate, string iStepCode, string iLineCode, string iFileName, string iIFNG,string iIFAutoSN)
- {
- sql.Clear();
- sql.Append("insert into AUTOSCANLOG(as_id,as_indate,as_testdate,as_sourcecode,as_stepcode,");
- sql.Append("as_linecode,as_makecode,as_sncode,as_filename,as_ifng,as_autosn)values(AUTOSCANLOG_seq.nextval,");
- sql.Append("sysdate,to_date('" + iDate + "','yyyy-mm-dd,hh24:mi:ss'),'" + iSource + "','" + iStepCode + "','" + iLineCode + "','" + iMakeCode + "',");
- sql.Append("'" + iSN + "','" + iFileName + "','" + iIFNG + "','"+iIFAutoSN+"')");
- dh.ExecuteSql(sql.ToString(), "select");
- }
- /// <summary>
- /// 获取工单的最近一条执行记录
- /// </summary>
- /// <param name="iSnCode"></param>
- /// <param name="oMakeCode"></param>
- /// <param name="oErrorMessage"></param>
- /// <returns></returns>
- public static bool GetMakeInfo(string iSnCode, out string oMakeCode, out string oStatus, out string oErrorMessage)
- {
- //取MakeProcess表中的执行记录ID最大的一个工单的号码
- oMakeCode = "";
- oErrorMessage = "";
- oStatus = "";
- DataTable dt = dh.getFieldsDataByCondition("MakeSerial", new string[] { "ms_makecode", "ms_status" }, "ms_id=(select max(ms_id) from makeserial where ms_sncode='" + iSnCode + "')");
- if (dt.Rows.Count > 0)
- {
- oMakeCode = dt.Rows[0]["ms_makecode"].ToString();
- oStatus = dt.Rows[0]["ms_status"].ToString();
- }
- if (oMakeCode != "")
- return true;
- else
- {
- oErrorMessage = "序列号:" + iSnCode + " 未归属工单";
- return false;
- }
- }
- public static void AutoPassJudge(string iSN, string iMakeCode, string iSource, string iFileName, string iLineCode, string iCombine)
- {
- //插入不良判断记录
- sql.Clear();
- sql.Append("insert into AUTOSCAN_REJUDGE(asr_id,asr_indate,asr_filename,asr_combinecode,asr_sourcecode,");
- sql.Append("asr_linecode,asr_makecode,asr_sncode) values(AUTOSCAN_REJUDGE_seq.nextval,sysdate,");
- sql.Append("'" + iFileName + "','" + iCombine + "','" + iSource + "','" + iLineCode + "','" + iMakeCode + "','" + iSN + "')");
- dh.ExecuteSql(sql.ToString(), "insert");
- }
- public static bool CheckUserLogin(string iUserCode, string iPassWord, out string oErrorMessage)
- {
- oErrorMessage = "";
- string SQL = "select em_code from employee where upper(em_code)=:UserName and em_password =:PassWord";
- DataTable dt;
- dt = (DataTable)dh.ExecuteSql(SQL, "select", iUserCode.ToUpper(), iPassWord);
- if (dt.Rows.Count > 0)
- return true;
- else
- {
- oErrorMessage = "用户名或者密码不正确!";
- return false;
- }
- }
- public static bool SetTestNGDetail(string iSnCode, string iMakeCode, string iUserCode, string iSourceCode, string iResult, out string oErrorMessage)
- {
- oErrorMessage = "";
- string StepCode = "";
- string StepName = "";
- if (iResult == "" || iResult == null)
- iResult = "检查未通过";
- GetStepCodeAndNameBySource(iSourceCode, ref StepCode, ref StepName);
- //更新序列号已经采集的工序 ms_paststep 已采集数据,更新下一工序
- //如果存在送检批号则进行删除
- if (dh.CheckExist("oqcbatchdetail", "obd_sncode='" + iSnCode + "'"))
- {
- string checkno = dh.getFieldDataByCondition("oqcbatchdetail", "obd_checkno", "obd_sncode='" + iSnCode + "'").ToString();
- dh.ExecuteSql("delete from oqcbatchdetail where obd_sncode='" + iSnCode + "'", "delete");
- dh.ExecuteSql("update oqcbatch set ob_nowcheckqty=ob_nowcheckqty-1 where ob_checkno='" + checkno + "'", "update");
- }
- //之前保存的不良就不再调用
- DataTable dt = dh.getFieldsDataByCondition("makeserial", new string[] { "ms_stepcode", "nvl(ms_ifrework,0)ms_ifrework" }, "ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakeCode + "'");
- if (dt.Rows.Count > 0)
- {
- string ifrework = dt.Rows[0]["ms_ifrework"].ToString();
- string ms_stepcode = dt.Rows[0]["ms_stepcode"].ToString();
- if (ms_stepcode == StepCode)
- {
- if (ifrework == "0")
- dh.UpdateByCondition("makeserial", "ms_status=3", "ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakeCode + "'");
- else
- dh.UpdateByCondition("makeserial", "ms_reworkstatus=3", "ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakeCode + "'");
- }
- else
- {
- if (ifrework == "0")
- dh.UpdateByCondition("makeserial", "ms_nextstepcode='',ms_paststep = ms_paststep ||'," + StepCode + "',ms_status=3", "ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakeCode + "' ");
- else
- dh.UpdateByCondition("makeserial", "ms_nextstepcode='',ms_paststep = ms_paststep ||'," + StepCode + "',ms_reworkstatus=3", "ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakeCode + "'");
- SetStepResult(iMakeCode, iSourceCode, iSnCode, "不良采集", iResult, iUserCode, out oErrorMessage);
- }
- }
- return true;
- }
- /// <summary>
- /// 获取步骤代码和名称
- /// </summary>
- /// <param name="Source"></param>
- /// <param name="StepCode"></param>
- /// <param name="StepName"></param>
- private static void GetStepCodeAndNameBySource(string Source, ref string StepCode, ref string StepName)
- {
- DataTable dt = dh.getFieldsDataByCondition("source", new string[] { "sc_stepcode", "sc_stepname", "sc_linecode" }, "sc_code='" + Source + "'");
- if (dt.Rows.Count > 0)
- {
- StepCode = dt.Rows[0]["sc_stepcode"].ToString();
- StepName = dt.Rows[0]["sc_stepname"].ToString();
- }
- }
- public static bool CheckUserAndResourcePassed(string iUserCode, string iSourceCode, out string oErrorMessage)
- {
- oErrorMessage = "";
- iUserCode = iUserCode.ToUpper();
- iSourceCode = iSourceCode.ToUpper();
- string SQL = "select em_code,em_type from employee where upper(em_code)=:UserName ";
- DataTable dt;
- dt = (DataTable)dh.ExecuteSql(SQL, "select", iUserCode);
- if (dt.Rows.Count > 0)
- {
- string em_type = dt.Rows[0]["em_type"].ToString();
- if (iSourceCode == "")
- {
- oErrorMessage = "岗位资源不允许为空";
- return false;
- }
- if (em_type == "admin")
- {
- if (dh.CheckExist("Source", "upper(sc_code)='" + iSourceCode + "' and sc_statuscode='AUDITED'"))
- {
- return true;
- }
- else
- {
- oErrorMessage = "岗位资源编号错误或者未审核!";
- return false;
- }
- }
- else
- {
- dt = dh.getFieldsDatasByCondition("cs$empgroup left join cs$userresource on ur_groupcode=eg_groupcode left join source on ur_resourcecode=sc_code", new string[] { "upper(ur_resourcecode) ur_resourcecode" }, "upper(eg_emcode)= '" + iUserCode + "' and sc_statuscode='AUDITED'");
- //如果存在该编号
- if (dt.Rows.Count > 0)
- {
- //判断如果多个岗位资源存在,用户输入的只要在其中就行
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (dt.Rows[i]["ur_resourcecode"].ToString() == iSourceCode)
- return true;
- }
- oErrorMessage = "用户不处于当前资源所属分组!";
- }
- else
- oErrorMessage = "岗位资源编号错误或者未审核!";
- }
- }
- else
- oErrorMessage = "用户不存在!";
- return false;
- }
- public static bool SetStepResult(string iMakeCode, string iSourceCode, string iSN, string iMPKind, string iResult, string iUserCode, out string oErrorMessage)
- {
- return CS_SetResult(iMakeCode, iSourceCode, iSN, iUserCode, iResult, out oErrorMessage);
- }
- public static bool CS_SetResult(string iMakeCode, string iSourceCode, string iSN, string iUserCode, string iResult, out string oErrorMessage)
- {
- oErrorMessage = "";
- string[] param = new string[] { iMakeCode, iSourceCode, iSN, iUserCode, iResult, oErrorMessage };
- dh.CallProcedure("CS_SETSTEPRESULT", ref param);
- oErrorMessage = param[5];
- if (oErrorMessage == "" || oErrorMessage == null || oErrorMessage == "null")
- return true;
- else
- return false;
- }
- }
- }
|