LogicHandler.cs 77 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Drawing;
  5. using System.Text;
  6. using System.Windows;
  7. using System.Windows.Forms;
  8. using UAS_MES_NEW.DataOperate;
  9. using UAS_MES_NEW.Entity;
  10. using UAS_MES_NEW.PublicForm;
  11. namespace UAS_MES_NEW.PublicMethod
  12. {
  13. class LogicHandler
  14. {
  15. public LogicHandler() { }
  16. static DataHelper dh = SystemInf.dh;
  17. //用于拼接SQL
  18. static StringBuilder sql = new StringBuilder();
  19. //用于存放批量执行的SQL
  20. static List<string> sqls = new List<string>();
  21. /// <summary>
  22. /// 记录复判记录
  23. /// </summary>
  24. /// <param name="iSN"></param>
  25. /// <param name="iMakeCode"></param>
  26. /// <param name="iSource"></param>
  27. /// <param name="iFileName"></param>
  28. /// <param name="iLineCode"></param>
  29. /// <param name="iCombine"></param>
  30. public static void AutoPassJudge(string iSN, string iMakeCode, string iSource, string iFileName, string iLineCode, string iCombine, string iStatus)
  31. {
  32. //插入不良判断记录
  33. sql.Clear();
  34. sql.Append("insert into AUTOSCAN_REJUDGE(asr_id,asr_indate,asr_filename,asr_combinecode,asr_sourcecode,");
  35. sql.Append("asr_linecode,asr_makecode,asr_rejdate,asr_sncode,asr_rejusername,asr_status) values(AUTOSCAN_REJUDGE_seq.nextval,sysdate,");
  36. sql.Append("'" + iFileName + "','" + iCombine + "','" + iSource + "','" + iLineCode + "','" + iMakeCode + "',sysdate,'" + iSN + "','" + User.UserName + "','" + iStatus + "')");
  37. dh.ExecuteSql(sql.ToString(), "insert");
  38. }
  39. /// <summary>
  40. /// 判断工单是否已经下放
  41. /// </summary>
  42. /// <param name="iMaCode"></param>
  43. /// <returns></returns>
  44. public static bool CheckMakeStatus(string iMaCode, out string ErrorMessage)
  45. {
  46. string ma_statuscode = dh.getFieldDataByCondition(" make ", "ma_statuscode", "Lower(ma_code)='" + iMaCode.ToLower() + "' ").ToString();
  47. ErrorMessage = "";
  48. if (ma_statuscode == "")
  49. {
  50. ErrorMessage = "工单号" + iMaCode + "不存在";
  51. return false;
  52. }
  53. if (ma_statuscode == "STARTED")
  54. return true;
  55. else
  56. {
  57. ErrorMessage = "工单必须是已下放状态";
  58. return false;
  59. }
  60. }
  61. public static void GetSerialNumByCaller(string iCaller, out string SerialNum)
  62. {
  63. SerialNum = "";
  64. string[] param = new string[] { iCaller, "2", SerialNum };
  65. dh.CallProcedure("SP_GETMAXNUMBER", ref param);
  66. SerialNum = param[2];
  67. }
  68. /// <summary>
  69. /// 验证用户身份信息
  70. /// </summary>
  71. /// <param name="iUserCode"></param>
  72. /// <param name="oErrorMessage"></param>
  73. /// <returns></returns>
  74. public static bool CheckUserLogin(string iUserCode, string iPassWord, out string oErrorMessage)
  75. {
  76. oErrorMessage = "";
  77. string SQL = "select em_code from employee where upper(em_code)=:UserName and em_password =:PassWord";
  78. DataTable dt;
  79. dt = (DataTable)dh.ExecuteSql(SQL, "select", iUserCode.ToUpper(), iPassWord);
  80. if (dt.Rows.Count > 0)
  81. return true;
  82. else
  83. {
  84. oErrorMessage = "用户名或者密码不正确!";
  85. return false;
  86. }
  87. }
  88. /// <summary>
  89. /// 记录登陆信息
  90. /// </summary>
  91. public static void RecordLogInfo(string iUserCode, string iUserName, string iVersion, string iType, string iIP)
  92. {
  93. dh.ExecuteSql("insert into LogInfo(id,sip,usname,indate,uscode,versioncode,terminaltype) values (LogInfo_seq.nextval,'" + iIP + "','" + iUserName + "',sysdate,'" + iUserCode + "','" + iVersion + "','" + iType + "')", "insert");
  94. }
  95. /// <summary>
  96. /// 验证用户身份信息和岗位资源
  97. /// </summary>
  98. /// <param name="iUserCode"></param>
  99. /// <param name="iPassWord"></param>
  100. /// <param name="oErrorMessage"></param>
  101. /// <returns></returns>
  102. public static bool CheckUserAndResourcePassed(string iUserCode, string iSourceCode, out string oErrorMessage)
  103. {
  104. oErrorMessage = "";
  105. iUserCode = iUserCode.ToUpper();
  106. iSourceCode = iSourceCode.ToUpper();
  107. string SQL = "select em_code,em_type from employee where upper(em_code)=:UserName ";
  108. DataTable dt;
  109. dt = (DataTable)dh.ExecuteSql(SQL, "select", iUserCode);
  110. if (dt.Rows.Count > 0)
  111. {
  112. string em_type = dt.Rows[0]["em_type"].ToString();
  113. if (iSourceCode == "")
  114. {
  115. oErrorMessage = "岗位资源不允许为空";
  116. return false;
  117. }
  118. if (em_type == "admin")
  119. {
  120. if (dh.CheckExist("Source", "upper(sc_code)='" + iSourceCode + "' and sc_statuscode='AUDITED'"))
  121. {
  122. return true;
  123. }
  124. else
  125. {
  126. oErrorMessage = "岗位资源编号错误或者未审核!";
  127. return false;
  128. }
  129. }
  130. else
  131. {
  132. 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'");
  133. //如果存在该编号
  134. if (dt.Rows.Count > 0)
  135. {
  136. //判断如果多个岗位资源存在,用户输入的只要在其中就行
  137. for (int i = 0; i < dt.Rows.Count; i++)
  138. {
  139. if (dt.Rows[i]["ur_resourcecode"].ToString() == iSourceCode)
  140. return true;
  141. }
  142. oErrorMessage = "用户不处于当前资源所属分组!";
  143. }
  144. else
  145. oErrorMessage = "岗位资源编号错误或者未审核!";
  146. }
  147. }
  148. else
  149. oErrorMessage = "用户不存在!";
  150. return false;
  151. }
  152. public static bool CheckStepAttribute(string iCaller, string iSourceCode, out string oErrorMessage)
  153. {
  154. oErrorMessage = "";
  155. string[] param = new string[] { iCaller, iSourceCode, oErrorMessage };
  156. dh.CallProcedure("CS_CHECKSTEPATTRIBUTE", ref param);
  157. oErrorMessage = param[2];
  158. if (oErrorMessage == "" || oErrorMessage == null || oErrorMessage == "null")
  159. return true;
  160. else
  161. return false;
  162. }
  163. public static bool CheckStepSNAndMacode(string iMakeCode, string iSourceCode, string iSN, string iUserCode, out string oMakeCode, out string oMsID, out string oErrorMessage)
  164. {
  165. oErrorMessage = "";
  166. oMakeCode = "";
  167. oMsID = "";
  168. string[] param = new string[] { iMakeCode, iSourceCode, iSN, iUserCode, oMakeCode, oMsID, oErrorMessage };
  169. dh.CallProcedure("CS_CHECKSTEPSNANDMACODE", ref param);
  170. oMakeCode = param[4];
  171. oMsID = param[5];
  172. oErrorMessage = param[6];
  173. if (oErrorMessage == "" || oErrorMessage == null || oErrorMessage == "null")
  174. {
  175. return true;
  176. }
  177. else
  178. {
  179. if (!(User.CurrentStepCode == "Aging" || User.CurrentStepCode == "PKG"))
  180. {
  181. SetCheck set = new SetCheck("NG", Color.Red);
  182. BaseUtil.SetFormCenter(set);
  183. set.ShowDialog();
  184. }
  185. return false;
  186. }
  187. }
  188. public static void DoCommandLog(string iCaller, string iUserCode, string iMakeCode, string iLineCode, string iSourceCode, string iOperate, string iResult, string iSncode, string iCheckno)
  189. {
  190. sql.Clear();
  191. sql.Append("insert into commandlog(cl_id,cl_caller,cl_man,cl_date,cl_linecode,cl_sourcecode,cl_makecode,cl_operate,");
  192. sql.Append("cl_result,cl_sncode,cl_code) values( commandlog_seq.nextval,:cl_caller,:iUserCode,sysdate,:iLineCode ,");
  193. sql.Append(":iSourceCode ,:iMakeCode,:iOperate,:iResult,:iSncode,:iCheckno)");
  194. dh.ExecuteSql(sql.ToString(), "insert", iCaller, iUserCode, iLineCode, iSourceCode, iMakeCode, iOperate, iResult, iSncode, iCheckno);
  195. }
  196. /// <summary>
  197. /// 获取工单的最近一条执行记录
  198. /// </summary>
  199. /// <param name="iSnCode"></param>
  200. /// <param name="oMakeCode"></param>
  201. /// <param name="oErrorMessage"></param>
  202. /// <returns></returns>
  203. public static bool GetMakeInfo(string iSnCode, out string oMakeCode, out string oStatus, out string oErrorMessage)
  204. {
  205. //取MakeProcess表中的执行记录ID最大的一个工单的号码
  206. oMakeCode = "";
  207. oErrorMessage = "";
  208. oStatus = "";
  209. DataTable dt = dh.getFieldsDataByCondition("MakeSerial", new string[] { "ms_makecode", "ms_status" }, "ms_id=(select max(ms_id) from makeserial where ms_sncode='" + iSnCode + "' and ms_status <> 2)");
  210. if (dt.Rows.Count > 0)
  211. {
  212. oMakeCode = dt.Rows[0]["ms_makecode"].ToString();
  213. oStatus = dt.Rows[0]["ms_status"].ToString();
  214. }
  215. if (oMakeCode != "")
  216. return true;
  217. else
  218. {
  219. dt = (DataTable)dh.ExecuteSql("select msl_makecode from makesnlist left join make on msl_makecode=ma_code where msl_sncode='" + iSnCode + "' and msl_type='before' and ma_wccode='" + User.WorkCenter + "'", "select");
  220. if (dt.Rows.Count > 0)
  221. {
  222. oMakeCode = dt.Rows[0]["msl_makecode"].ToString();
  223. return true;
  224. }
  225. else
  226. {
  227. dt = (DataTable)dh.ExecuteSql("select msd_makecode from MAKESNRULEDETAIL left join make on msd_makecode=ma_code where msd_sncode='" + iSnCode + "' and msd_type='before' and ma_wccode='" + User.WorkCenter + "'", "select");
  228. if (dt.Rows.Count > 0)
  229. {
  230. oMakeCode = dt.Rows[0]["msd_makecode"].ToString();
  231. return true;
  232. }
  233. else
  234. {
  235. oErrorMessage = "序列号:" + iSnCode + " 未归属工单";
  236. return false;
  237. }
  238. }
  239. }
  240. }
  241. /// <summary>
  242. /// 获取送检批次,根据不同的iOQCStep执行不同的操作,查询到有具体的信息时返回Form和Detail的两个DataTable
  243. /// iOQCStep 有四个固定参数
  244. /// OQCSENDCHECK 生成送检批
  245. /// OQCPLANMAINTAIN 抽样计划维护
  246. /// OQCDATACOLLECTION 抽样数据采集
  247. /// OQCRESULTDETERMINE 批结果判定
  248. /// </summary>
  249. /// <returns></returns>
  250. public static DataTable[] GetOQCBatch(string iSnCode, string iOutBoxCode, string iCheckNo, string iOQCStep, out string oErrorMessage)
  251. {
  252. oErrorMessage = "";
  253. string SQL = "";
  254. string ms_checkno = "";
  255. DataTable dt = new DataTable();
  256. if (iCheckNo != "")
  257. return GetBatch(iCheckNo, iOQCStep, out oErrorMessage);
  258. else if (iSnCode != "")
  259. {
  260. //如果返工批次为空则获取当前的批次
  261. SQL = "select nvl(MS_REWORKCHECKNO,ms_checkno)ms_checkno from makeserial where ms_id=(select max(ms_id) from makeserial where ms_sncode='" + iSnCode + "' or ms_psn='" + iSnCode + "')";
  262. dt = (DataTable)dh.ExecuteSql(SQL, "select");
  263. if (dt.Rows.Count == 0)
  264. {
  265. oErrorMessage = "序列号" + iSnCode + "不存在";
  266. return null;
  267. }
  268. else
  269. {
  270. if (dt.Rows[0]["ms_checkno"].ToString() == "")
  271. {
  272. oErrorMessage = "该序列号没有送检批次号";
  273. return null;
  274. }
  275. else
  276. ms_checkno = dt.Rows[0]["ms_checkno"].ToString();
  277. }
  278. }
  279. else if (iOutBoxCode != "")
  280. {
  281. SQL = "select ms_checkno from MES_PACKAGE_VIEW left join makeserial on v_barcode=ms_sncode where v_outboxcode='" + iOutBoxCode + "' ";
  282. dt = (DataTable)dh.ExecuteSql(SQL, "select");
  283. if (dt.Rows.Count == 0)
  284. {
  285. oErrorMessage = "该箱号不存在";
  286. return null;
  287. }
  288. else
  289. {
  290. if (dt.Rows[0]["ms_checkno"].ToString() == "")
  291. {
  292. oErrorMessage = "该箱号没有送检批次号";
  293. return null;
  294. }
  295. else
  296. ms_checkno = dt.Rows[0]["ms_checkno"].ToString();
  297. }
  298. }
  299. if (ms_checkno != "")
  300. {
  301. return GetBatch(ms_checkno, iOQCStep, out oErrorMessage);
  302. }
  303. else
  304. {
  305. oErrorMessage = "送检批次不存在";
  306. return null;
  307. }
  308. }
  309. /// <summary>
  310. /// 第一个是Form的主表信息,第二个是Grid的信息
  311. /// </summary>
  312. /// <param name="iCheckNo"></param>
  313. /// <returns></returns>
  314. private static DataTable[] GetBatch(string iCheckNo, string iOQCStep, out string oErrorMessage)
  315. {
  316. DataTable Form = new DataTable();
  317. DataTable Grid = new DataTable();
  318. oErrorMessage = "";
  319. switch (iOQCStep.ToUpper())
  320. {
  321. case "OQCSENDCHECK":
  322. sql.Clear();
  323. sql.Append("select obd_outboxcode,obd_id,obd_makecode,obd_sncode from OQCBatchdetail where obd_checkno = '" + iCheckNo + "' order by obd_sncode");
  324. Grid = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  325. Form = (DataTable)dh.ExecuteSql("select ob_id,ob_status,ob_prodcode,ob_batchqty,ob_source,ob_checkno from OQCBatch where ob_checkno='" + iCheckNo + "'", "select");
  326. if (Form.Rows.Count > 0)
  327. {
  328. if (/*Form.Rows[0]["ob_source"].ToString() == "新增" &&*/ Form.Rows[0]["ob_status"].ToString() == "ENTERING")
  329. {
  330. sql.Clear();
  331. sql.Append("select ob_id,ob_status,ob_prodcode ma_prodcode,ob_batchqty,ob_source,ob_checkno,obd_id,obd_outboxcode,obd_makecode ma_code,count(1) cn from OQCBatch left join OQCBatchdetail ");
  332. sql.Append("on obd_obid = ob_id where ob_checkno ='" + iCheckNo + "' group by ob_id,ob_status,ob_prodcode,ob_batchqty,ob_source,ob_checkno,obd_outboxcode,obd_makecode,obd_id");
  333. Form = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  334. }
  335. else oErrorMessage = "自动生成的抽检批次号不允许在该页面操作,或者该抽检批次号不是在录入状态";
  336. }
  337. else oErrorMessage = "抽检批次" + iCheckNo + "不存在";
  338. break;
  339. case "OQCPLANMAINTAIN":
  340. sql.Clear();
  341. sql.Append("select ob_reworkcode,ob_prodcode,ob_maxngacceptqty,ob_id,ob_checkno,ob_projectcode,ob_nowcheckqty,ob_source,ob_remark,");
  342. sql.Append("ob_status,pr_id,pr_detail,pr_kind,pr_manutype,pr_qualmethod,nvl(ob_aqlcode,pr_aql)ob_aqlcode from OQCBatch left join product on ");
  343. sql.Append("pr_code=ob_prodcode where ob_checkno='" + iCheckNo + "'");
  344. Form = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  345. sql.Clear();
  346. if (Form.Rows.Count > 0)
  347. {
  348. string pr_id;
  349. //判断状态是否是待检验
  350. if (Form.Rows[0]["ob_status"].ToString() == "UNCHECK")
  351. {
  352. //判断送检方案是否为空
  353. string qualmethod = "";
  354. //第一原则送检方案为空
  355. if (Form.Rows[0]["pr_qualmethod"].ToString() == "")
  356. {
  357. //判读第二原则送检方案为空
  358. qualmethod = dh.getFieldDataByCondition("product left join productkind on pr_kind=pk_name", "pk_qualmethod", "pr_code='" + Form.Rows[0]["ob_prodcode"] + "'").ToString();
  359. }
  360. //第一原则送检方案不为空
  361. else
  362. {
  363. qualmethod = Form.Rows[0]["pr_qualmethod"].ToString();
  364. }
  365. Form.Rows[0]["ob_projectcode"] = qualmethod;
  366. pr_id = dh.getFieldDataByCondition("QUA_Project", "pr_id", "pr_code = '" + qualmethod + "'").ToString();
  367. sql.Clear();
  368. sql.Append("select 1 choose,nvl(max(oi_id),0)oi_id,ci_code, ci_kind,nvl(max(oi_sampleqty),0) oi_sampleqty from QUA_PROJECT left join ");
  369. sql.Append(" QUA_ProjectDetail on pd_prid=pr_id left join QUA_CheckItem on pd_ciid=ci_id ");
  370. sql.Append("left join OQCITEMS on oi_checkno ='" + iCheckNo + "' and oi_projectcode='" + qualmethod + "' ");
  371. sql.Append("and oi_projectcode = pr_code and oi_checkkind = ci_kind where pr_code='" + qualmethod + "' group by ci_kind,ci_code");
  372. Grid = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  373. }
  374. else
  375. {
  376. if (Form.Rows[0]["ob_status"].ToString().Contains("OK") || (Form.Rows[0]["ob_status"].ToString().Contains("NG") && Form.Rows[0]["ob_status"].ToString().Length < 4))
  377. {
  378. oErrorMessage = "抽检批次" + iCheckNo + "检验完毕,不允许采集";
  379. }
  380. else if (Form.Rows[0]["ob_status"].ToString() == "CHECKING")
  381. {
  382. oErrorMessage = "抽检批次" + iCheckNo + "处于检验中,无法维护抽样计划";
  383. }
  384. else if (Form.Rows[0]["ob_status"].ToString() == "ENTERING")
  385. {
  386. oErrorMessage = "抽检批次" + iCheckNo + "处于未送检状态,请送检";
  387. }
  388. }
  389. }
  390. else
  391. oErrorMessage = "抽检批次" + iCheckNo + "不存在";
  392. break;
  393. case "OQCDATACOLLECTION":
  394. sql.Clear();
  395. sql.Append("select ob_checkno,ob_makecode,ob_prodcode,ob_nowcheckqty,pr_detail,ob_ngqty,ob_okqty,");
  396. sql.Append("ob_remark,ob_makecode,ob_status,ob_projectcode,ob_aqlcode,ob_maxngacceptqty from OQCBatch left join product on ");
  397. sql.Append("pr_code=ob_prodcode left join oqcitems on oi_checkno =ob_checkno and oi_projectcode =ob_projectcode where ob_checkno='" + iCheckNo + "'");
  398. Form = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  399. //状态为UNCHECK或者CHECKING并且有抽样计划的才能操作
  400. if (Form.Rows.Count > 0)
  401. {
  402. if (Form.Rows[0]["ob_projectcode"].ToString() == "" || !(Form.Rows[0]["ob_status"].ToString() != "UNCHECK" || Form.Rows[0]["ob_status"].ToString() != "CHECKING"))
  403. {
  404. if (Form.Rows[0]["ob_status"].ToString().Contains("OK") || (Form.Rows[0]["ob_status"].ToString().Contains("NG") && Form.Rows[0]["ob_status"].ToString().Length < 4))
  405. {
  406. oErrorMessage = "抽检批次" + iCheckNo + "检验完毕,不允许采集";
  407. }
  408. else if (Form.Rows[0]["ob_status"].ToString() == "ENTERING")
  409. {
  410. oErrorMessage = "抽检批次" + iCheckNo + "处于未送检状态,请送检";
  411. }
  412. else if (Form.Rows[0]["ob_projectcode"].ToString() == "")
  413. {
  414. oErrorMessage = "抽检批次" + iCheckNo + "未维护抽样计划,请维护";
  415. }
  416. //oErrorMessage = "状态为未检验或者送检中并且有抽样计划的才能操作";
  417. }
  418. }
  419. else
  420. {
  421. oErrorMessage = "抽检批次" + iCheckNo + "不存在";
  422. }
  423. break;
  424. case "OQCRESULTDETERMINE":
  425. sql.Clear();
  426. sql.Append("select ob_remark Remark,ob_id,ob_aqlcode,ob_makecode,ob_status,ob_prodcode,(select max(oi_checkqty)from OQCItems where oi_checkno='" + iCheckNo + "') oi_checkqty,");
  427. sql.Append("ob_nowcheckqty,nvl(ob_okqty,0) ob_okqty,nvl(ob_ngqty,0) ob_ngqty,ob_maxngacceptqty,ob_source,ob_checkno,ob_result from OQCBatch where ob_checkno='" + iCheckNo + "'");
  428. Form = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  429. if (Form.Rows.Count == 0)
  430. {
  431. oErrorMessage = "抽检批次" + iCheckNo + "不存在";
  432. }
  433. break;
  434. case "OQCCHECKNOSPLIT":
  435. sql.Clear();
  436. sql.Append("select ob_checkno,ob_makecode,ob_prodcode,ob_nowcheckqty,pr_detail,ob_ngqty,ob_okqty,");
  437. sql.Append("ob_remark,ob_makecode,ob_status,ob_projectcode,ob_aqlcode,ob_maxngacceptqty from OQCBatch left join product on ");
  438. sql.Append("pr_code=ob_prodcode left join oqcitems on oi_checkno =ob_checkno and oi_projectcode =ob_projectcode where ob_checkno='" + iCheckNo + "' and ob_status='UNCHECK'");
  439. Form = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  440. //状态为UNCHECK或者CHECKING并且有抽样计划的才能操作
  441. if (Form.Rows.Count > 0)
  442. {
  443. sql.Clear();
  444. sql.Append("select obd_outboxcode,obd_builddate,obd_makecode,obd_sncode from oqcbatchdetail where obd_checkno='" + Form.Rows[0]["ob_checkno"].ToString() + "'");
  445. Grid = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  446. }
  447. else oErrorMessage = "抽检批次" + iCheckNo + "不存在或者状态不处于待检验";
  448. break;
  449. default:
  450. break;
  451. }
  452. return new DataTable[] { Form, Grid };
  453. }
  454. public static bool CartonBoxStepPass(string iMakeCode, string iSourceCode, string iCartonBox, string iUserCode, string iResult, out string oErrorMessage)
  455. {
  456. DataTable dt = (DataTable)dh.ExecuteSql("select ms_status,V_BARCODE,V_MAKECODE,ms_craftcode,ms_prodcode from mes_package_view left join makeserial on V_MAKECODE=ms_makecode and v_barcode = ms_sncode where V_OUTBOXCODE='" + iCartonBox + "'", "select");
  457. //获取当前资源的工序
  458. string stepcode = dh.getFieldDataByCondition("source", "sc_stepcode", "sc_code='" + iSourceCode + "'").ToString();
  459. string Prcode = dt.Rows[0]["ms_prodcode"].ToString();
  460. string Craftcode = dt.Rows[0]["ms_craftcode"].ToString();
  461. string ifoqc = dh.getFieldDataByCondition("craft left join craftdetail on cd_crid=cr_id", "nvl(cd_ifoqc,0) cd_ifoqc", "cr_prodcode='" + Prcode + "' and cr_code='" + Craftcode + "' and cd_stepcode='" + stepcode + "'").ToString();
  462. oErrorMessage = "";
  463. if (ifoqc == "0")
  464. {
  465. for (int i = 0; i < dt.Rows.Count; i++)
  466. {
  467. string ms_status = dt.Rows[i]["ms_status"].ToString();
  468. string sn = dt.Rows[i]["V_BARCODE"].ToString();
  469. string makecode = dt.Rows[i]["V_MAKECODE"].ToString();
  470. if (ms_status != "2")
  471. {
  472. CS_SetResult(makecode, iSourceCode, sn, iUserCode, iResult, out oErrorMessage);
  473. }
  474. }
  475. }
  476. if (oErrorMessage == "" || oErrorMessage == null || oErrorMessage == "null" || oErrorMessage.Contains("AFTERSUCCESS"))
  477. return true;
  478. else
  479. return false;
  480. }
  481. /// <summary>
  482. /// 箱号过站的公用方法
  483. /// </summary>
  484. /// <param name="iOutBoxCode"></param>
  485. /// <param name="iSourceCode"></param>
  486. /// <param name="iUserCode"></param>
  487. /// <param name="iResult"></param>
  488. /// <param name="iBoxType"></param>
  489. public static bool OutBoxStepPass(string iOutBoxCode, string iMakeCode, string iSourceCode, string iUserCode, string iResult, string iBoxType, out string oErrorMessage)
  490. {
  491. oErrorMessage = "";
  492. string[] param = new string[] { iOutBoxCode, iMakeCode, iSourceCode, iUserCode, iResult, iBoxType, oErrorMessage };
  493. dh.CallProcedure("CS_CARTONBOXSTEPRESULT", ref param);
  494. oErrorMessage = param[6];
  495. if (oErrorMessage == "" || oErrorMessage == null || oErrorMessage == "null")
  496. return true;
  497. else
  498. return false;
  499. }
  500. /// <summary>
  501. /// 大箱栈板解除装箱
  502. /// </summary>
  503. public static void OutBoxDrawStepPass(string iOutBoxCode, string iMakeCode, string iSourceCode)
  504. {
  505. string CurrentStep = "";
  506. string LineCode = "";
  507. string CurrentStepName = "";
  508. List<string> ExeSQL = new List<string>();
  509. GetStepCodeAndNameAndLineBySource(iSourceCode, ref CurrentStep, ref CurrentStepName, ref LineCode);
  510. //判断是否是线外采集
  511. string unfinpack = dh.getFieldDataByCondition("Line", "nvl(li_allowUnFinPack,0)", "li_code='" + User.UserLineCode + "'").ToString();
  512. //更新工序会上一执行步骤
  513. if (unfinpack != "" && unfinpack != "0")
  514. {
  515. sql.Clear();
  516. sql.Append("merge into makeserial using mes_package_view on (v_outboxcode='" + iOutBoxCode + "' and ms_sncode=");
  517. sql.Append("v_barcode and ms_makecode=v_makecode) when matched then update set ms_nextstepcode=ms_nextstepcode");
  518. sql.Append(",ms_status=1,ms_sccode='" + iSourceCode + "' ");
  519. }
  520. else
  521. {
  522. sql.Clear();
  523. sql.Append("merge into makeserial using mes_package_view on (v_outboxcode='" + iOutBoxCode + "' and ms_sncode=");
  524. sql.Append("v_barcode and ms_makecode=v_makecode) when matched then update set ms_nextstepcode=ms_stepcode");
  525. sql.Append(",ms_status=1,ms_sccode='" + iSourceCode + "' ");
  526. }
  527. ExeSQL.Add(sql.ToString());
  528. //更新完工数量
  529. ExeSQL.Add("update make set ma_madeqty=(select count(1) from makeserial where ms_makecode='" + iMakeCode + "' and ms_status=2) where ma_code='" + iMakeCode + "'");
  530. //删除StepPassed数据
  531. sql.Clear();
  532. sql.Append("delete from steppassed where sp_sncode in (select v_barcode from mes_package_view where v_outboxcode='" + iOutBoxCode + "') ");
  533. sql.Append("and sp_makecode='" + iMakeCode + "' and sp_stepcode='" + CurrentStep + "'");
  534. ExeSQL.Add(sql.ToString());
  535. //更新大箱或栈板的母箱编号为空
  536. ExeSQL.Add("update package set pa_mothercode='' where pa_outboxcode in(select PD_INNERBOXCODE from package left join packagedetail on pa_id=pd_paid where pa_outboxcode='" + iOutBoxCode + "')");
  537. //删除从表明细
  538. ExeSQL.Add("delete from packagedetail where pd_paid=(select pa_id from package where pa_outboxcode='" + iOutBoxCode + "')");
  539. //设置大箱或栈板的已装数量为0
  540. ExeSQL.Add("update package set pa_totalqty=0,pa_status=0,pa_currentqty=0,pa_packageqty=0 where pa_outboxcode='" + iOutBoxCode + "'");
  541. dh.ExecuteSQLTran(ExeSQL.ToArray());
  542. }
  543. /// <summary>
  544. /// 大箱栈板解除装箱
  545. /// </summary>
  546. public static void OutBoxDrawStepPass(string iOutBoxCode, string iInnerBoxCode, string iMakeCode, string iSourceCode)
  547. {
  548. string CurrentStep = "";
  549. string LineCode = "";
  550. string CurrentStepName = "";
  551. List<string> ExeSQL = new List<string>();
  552. GetStepCodeAndNameAndLineBySource(iSourceCode, ref CurrentStep, ref CurrentStepName, ref LineCode);
  553. //更新工序会上一执行步骤
  554. sql.Clear();
  555. sql.Append("update makeserial set ms_nextstepcode=ms_stepcode,MS_STATUS=1,ms_sccode='" + iSourceCode + "' ");
  556. sql.Append("where ms_sncode in (select v_barcode from mes_package_view where v_outboxcode='" + iOutBoxCode + "')");
  557. ExeSQL.Add(sql.ToString());
  558. //更新完工数量
  559. ExeSQL.Add("update make set ma_madeqty=(select count(1) from makeserial where ms_makecode='" + iMakeCode + "' and ms_status=2) where ma_code='" + iMakeCode + "'");
  560. //删除StepPassed数据
  561. sql.Clear();
  562. sql.Append("delete from steppassed where sp_sncode in (select v_barcode from mes_package_view where v_outboxcode='" + iOutBoxCode + "') ");
  563. sql.Append("and sp_makecode='" + iMakeCode + "' and sp_stepcode='" + CurrentStep + "'");
  564. ExeSQL.Add(sql.ToString());
  565. //更新大箱或栈板的母箱编号为空
  566. ExeSQL.Add("update package set pa_mothercode='' where pa_outboxcode in(select PD_INNERBOXCODE from package left join packagedetail on pa_id=pd_paid where pa_outboxcode='" + iOutBoxCode + "')");
  567. //删除从表明细
  568. ExeSQL.Add("delete from packagedetail where pd_paid=(select pa_id from package where pa_outboxcode='" + iOutBoxCode + "')");
  569. //设置大箱或栈板的已装数量为0
  570. ExeSQL.Add("update package set pa_totalqty=0,pa_status=0,pa_currentqty=0,pa_packageqty=0 where pa_outboxcode='" + iOutBoxCode + "'");
  571. dh.ExecuteSQLTran(ExeSQL.ToArray());
  572. }
  573. /// <summary>
  574. /// 记录操作日志
  575. /// </summary>
  576. /// <param name="iSnCode"></param>
  577. /// <param name="iMakeCode"></param>
  578. /// <param name="iMPKind"></param>
  579. /// <param name="result"></param>
  580. /// <param name="iUserCode"></param>
  581. public static void InsertMakeProcess(string iSnCode, string iMakeCode, string iSourceCode, string iMPKind, string result, string iUserCode)
  582. {
  583. string CurrentStep = "";
  584. string LineCode = "";
  585. string CurrentStepName = "";
  586. GetStepCodeAndNameAndLineBySource(iSourceCode, ref CurrentStep, ref CurrentStepName, ref LineCode);
  587. sql.Clear();
  588. sql.Append("insert into MakeProcess(mp_id,mp_makecode,mp_maid, mp_mscode,mp_sncode,mp_stepcode,mp_stepname,");
  589. 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)");
  590. sql.Append("select MakeProcess_seq.nextval, ma_code,ma_id,ms_code,ms_sncode,'" + CurrentStep + "','" + CurrentStepName + "',");
  591. sql.Append("ms_craftcode,cr_name,'" + iMPKind + "','" + result + "',sysdate,'" + iUserCode + "',ma_wccode,'" + LineCode + "','" + iSourceCode + "',");
  592. sql.Append("ms_status,ms_checkno,ms_outboxcode from make left join makeserial on ms_makecode=ma_code left join step on st_code=ms_stepcode left join craft on ms_craftcode=cr_code and cr_prodcode=ma_prodcode ");
  593. sql.Append("where ms_sncode='" + iSnCode + "' and ma_code='" + iMakeCode + "' and st_code='" + CurrentStep + "'");
  594. dh.ExecuteSql(sql.ToString(), "insert");
  595. }
  596. /// <summary>
  597. ///
  598. /// </summary>
  599. /// <param name="iSNMakeCode">序列号的工单号</param>
  600. /// <param name="iMakeCode">界面上的工单号</param>
  601. /// <param name="ChangeMakeCodeNote">是否需要切换工单提醒</param>
  602. /// <returns></returns>
  603. public static bool CheckDiffMakeCodeBeforeStepCheck(string iSN, string iMakeCode, bool iChangeMakeCodeNote, out string oMakeCode, out string oErrorMessage)
  604. {
  605. string oStatus = "";
  606. GetMakeInfo(iSN, out oMakeCode, out oStatus, out oErrorMessage);
  607. oErrorMessage = "";
  608. bool NoteAlready = false;
  609. if (iChangeMakeCodeNote)
  610. {
  611. if (iMakeCode != oMakeCode && oMakeCode != "" && iMakeCode != "" && oStatus != "2")
  612. {
  613. string ChangeMakeCode = System.Windows.Forms.MessageBox.Show("序列号" + iSN + "所属工单不同,是否切换?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  614. //如果选择不切换赋值当前界面工单
  615. if (ChangeMakeCode != "Yes")
  616. {
  617. oErrorMessage = "请重新采集序列号";
  618. NoteAlready = true;
  619. }
  620. else
  621. {
  622. NoteAlready = true;
  623. }
  624. }
  625. else
  626. {
  627. oMakeCode = iMakeCode;
  628. }
  629. }
  630. else
  631. {
  632. if (oMakeCode == "" || (oMakeCode != "" && oMakeCode == iMakeCode))
  633. {
  634. oMakeCode = iMakeCode;
  635. }
  636. }
  637. return (oErrorMessage == "" || oErrorMessage == null);
  638. }
  639. /// <summary>
  640. /// 校验方法之后的检测
  641. /// </summary>
  642. /// <param name="iSNMakecode"></param>
  643. /// <param name="iMakeCode"></param>
  644. /// <param name="iChangeMakeCodeNote"></param>
  645. /// <param name="NoteAlready"></param>
  646. public static bool CheckDiffMakeCodeAfterStepCheck(string iSN, string iSNMakecode, bool iChangeMakeCodeNote, bool NoteAlready, Control ctl, out string oErrMessage)
  647. {
  648. oErrMessage = "";
  649. if (iChangeMakeCodeNote && !NoteAlready)
  650. {
  651. if (iSNMakecode != ctl.Text && ctl.Text != "")
  652. {
  653. string ChangeMakeCode = System.Windows.Forms.MessageBox.Show("序列号" + iSN + "所属工单不同,是否切换?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  654. //如果选择不切换赋值当前界面工单
  655. if (ChangeMakeCode == "Yes")
  656. {
  657. ctl.Text = iSNMakecode;
  658. }
  659. else
  660. {
  661. oErrMessage = "请重新采集序列号";
  662. }
  663. }
  664. }
  665. return (oErrMessage == "" || oErrMessage == null);
  666. }
  667. public static bool OQCBatchJudge(string iCheckno, string iSourceCode, string iResult, string iRework, string iUserCode, string iRemark, out string oReworkCode, out string oErrorMessage)
  668. {
  669. oReworkCode = "";
  670. oErrorMessage = "";
  671. string[] param = new string[] { iCheckno, iSourceCode, iResult, iRework, iUserCode, iRemark, oReworkCode, oErrorMessage };
  672. dh.CallProcedure("CS_OQCRESULTJUDGE", ref param);
  673. oReworkCode = param[6];
  674. oErrorMessage = param[7];
  675. if (oErrorMessage == "" || oErrorMessage == null || oErrorMessage == "null")
  676. return true;
  677. else
  678. return false;
  679. }
  680. public static String GetNextStep(string iCraftCode, string iStepCode, string iPrCode)
  681. {
  682. sql.Clear();
  683. sql.Append("select cd_nextstepcode from craft left join craftdetail on cr_id =cd_crid where ");
  684. sql.Append("cr_code='" + iCraftCode + "' and cr_prodcode='" + iPrCode + "' and cd_stepcode='" + iStepCode + "'");
  685. DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  686. if (dt.Rows.Count > 0)
  687. {
  688. return dt.Rows[0][0].ToString();
  689. }
  690. return "";
  691. }
  692. public static bool SetStepFinish(string iMakeCode, string iSourceCode, string iSN, string iMPKind, string iResult, string iUserCode, out string oErrorMessage)
  693. {
  694. oErrorMessage = "";
  695. string StepCode = dh.getFieldDataByCondition("Makeserial", "ms_stepcode", "ms_sncode='" + iSN + "' and ms_makecode='" + iMakeCode + "'").ToString();
  696. string CurrentStep = GetStepCodeBySource(iSourceCode);
  697. if (StepCode == CurrentStep)
  698. {
  699. InsertMakeProcess(iSN, iMakeCode, iSourceCode, iMPKind, iResult, iUserCode);
  700. return true;
  701. }
  702. else
  703. {
  704. return CS_SetResult(iMakeCode, iSourceCode, iSN, iUserCode, iResult, out oErrorMessage);
  705. }
  706. }
  707. public static bool SetStepResult(string iMakeCode, string iSourceCode, string iSN, string iMPKind, string iResult, string iUserCode, out string oErrorMessage)
  708. {
  709. bool result = CS_SetResult(iMakeCode, iSourceCode, iSN, iUserCode, iResult, out oErrorMessage);
  710. if (result)
  711. {
  712. SetCheck set = new SetCheck("OK", Color.Green);
  713. BaseUtil.SetFormCenter(set);
  714. set.ShowDialog();
  715. }
  716. else
  717. {
  718. SetCheck set = new SetCheck("NG", Color.Red);
  719. BaseUtil.SetFormCenter(set);
  720. set.ShowDialog();
  721. }
  722. return result;
  723. }
  724. public static bool CS_SetResult(string iMakeCode, string iSourceCode, string iSN, string iUserCode, string iResult, out string oErrorMessage)
  725. {
  726. oErrorMessage = "";
  727. string[] param = new string[] { iMakeCode, iSourceCode, iSN, iUserCode, iResult, oErrorMessage };
  728. dh.CallProcedure("CS_SETSTEPRESULT", ref param);
  729. oErrorMessage = param[5];
  730. if (oErrorMessage == "" || oErrorMessage == null || oErrorMessage == "null" || oErrorMessage.Contains("AFTERSUCCESS"))
  731. return true;
  732. else
  733. return false;
  734. }
  735. /// <summary>
  736. /// 设置测试结果
  737. /// </summary>
  738. /// <param name="iMakeCode"></param>
  739. /// <param name="iSourceCode"></param>
  740. /// <param name="iSN"></param>
  741. /// <param name="iMPKind"></param>
  742. /// <param name="iResult"></param>
  743. /// <param name="iUserCode"></param>
  744. /// <param name="oErrorMessage"></param>
  745. /// <returns></returns>
  746. public static bool SetTestResult(string iMakeCode, string iSourceCode, string iSN, string iMPKind, string iResult, string iUserCode, out string oErrorMessage)
  747. {
  748. return SetStepFinish(iMakeCode, iSourceCode, iSN, iMPKind, iResult, iUserCode, out oErrorMessage);
  749. }
  750. /// <summary>
  751. ///
  752. /// </summary>
  753. /// <returns></returns>
  754. public static string GetPiInoutCode(string iCaller, string iType)
  755. {
  756. string Code = "";
  757. string[] param = new string[] { iCaller, iType, Code };
  758. dh.CallProcedure("SP_GETMAXNUMBER", ref param);
  759. return param[2];
  760. }
  761. /// <summary>
  762. /// 执行不良信息采集
  763. /// </summary>
  764. /// <param name="iSnCode"></param>
  765. /// <param name="iMakeCode"></param>
  766. /// <param name="iUserCode"></param>
  767. /// <param name="iSourceCode"></param>
  768. /// <param name="iBadCode"></param>
  769. /// <param name="iBadRemark"></param>
  770. /// <param name="oErrorMessage"></param>
  771. /// <returns></returns>
  772. public static bool SetTestNGDetail(string iSnCode, string iMakeCode, string iUserCode, string iSourceCode, string iResult, string[] iBadGroupCode, string[] iBadCode, string[] iBadGroupName, string[] iBadName, string[] iBadRemark, out string oErrorMessage)
  773. {
  774. oErrorMessage = "";
  775. string StepCode = "";
  776. string StepName = "";
  777. string ScanType = "";
  778. string LineCode = "";
  779. if (iResult == "" || iResult == null)
  780. iResult = "检查未通过";
  781. GetStepCodeAndNameAndTypAndLineCodeBySource(iSourceCode, ref StepCode, ref StepName, ref ScanType, ref LineCode);
  782. if (ScanType == "REJUDGE")
  783. {
  784. AutoPassJudge(iSnCode, iMakeCode, iSourceCode, "", LineCode, "", "-1");
  785. }
  786. string dutystepcode = dh.getFieldDataByCondition("step", "nvl(ST_DUTYSTEPCODE,st_code)", "st_code = '" + StepCode + "'").ToString();
  787. string dutyemcode = dh.getFieldDataByCondition("steppassed", "sp_inman", "sp_sncode = '" + iSnCode + "' and sp_stepcode = '" + dutystepcode + "' and sp_makecode = '" + iMakeCode + "' order by sp_id desc").ToString();
  788. string asemcode = dh.getFieldDataByCondition("steppassed", "sp_inman", "sp_sncode = '" + iSnCode + "' and sp_stepcode = 'Assing' and sp_makecode = '" + iMakeCode + "' order by sp_id desc").ToString();
  789. if (dutyemcode == "")
  790. {
  791. dutystepcode = StepCode;
  792. dutyemcode = iUserCode;
  793. }
  794. sql.Clear();
  795. sql.Append("insert into makebad(mb_id,mb_makecode,mb_mscode,mb_sncode,mb_inman,mb_indate,mb_stepcode");
  796. sql.Append(",mb_sourcecode,mb_badcode,mb_bgcode,mb_badtable,mb_status,mb_badremark,mb_bgname,mb_badname,mb_type,MB_DUTYSTEPCODE,MB_DUTYEMCODE,MB_ASEMCODE)");
  797. sql.Append("select makebad_seq.nextval,ma_code,ms_code,ms_sncode,'" + iUserCode + "',sysdate,'" + StepCode + "','" + iSourceCode + "',:bc_code,:bg_code,'',");
  798. sql.Append("'0',:bc_remark,:bg_name,:bc_name,'Client','" + dutystepcode + "','" + dutyemcode + "','"+ asemcode + "' from make left join makeSerial on ms_makecode=ma_code ");
  799. sql.Append(" where ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakeCode + "'");
  800. if (iBadGroupCode.Length > 0)
  801. {
  802. dh.BatchInsert(sql.ToString(), new string[] { "bc_code", "bg_code", "bc_remark", "bg_name", "bc_name" }, iBadCode, iBadGroupCode, iBadRemark, iBadGroupName, iBadName);
  803. }
  804. //更新序列号已经采集的工序 ms_paststep 已采集数据,更新下一工序
  805. //如果存在送检批号则进行删除
  806. if (dh.CheckExist("oqcbatchdetail", "obd_sncode='" + iSnCode + "'"))
  807. {
  808. string checkno = dh.getFieldDataByCondition("oqcbatchdetail", "obd_checkno", "obd_sncode='" + iSnCode + "'").ToString();
  809. string ifng = dh.getFieldDataByCondition("oqcbatchdetail", "obd_ifng", "obd_sncode='" + iSnCode + "'").ToString();
  810. if (ifng == "-1")
  811. {
  812. dh.ExecuteSql("delete OQCITEMSAMPLES where ois_sncode = '" + iSnCode + "'", "select");
  813. dh.ExecuteSql("update oqcbatch set ob_nowcheckqty=ob_nowcheckqty-1,ob_ngqty = ob_ngqty -1 where ob_checkno='" + checkno + "'", "update");
  814. }
  815. dh.ExecuteSql("delete from oqcbatchdetail where obd_sncode='" + iSnCode + "'", "delete");
  816. }
  817. //之前保存的不良就不再调用
  818. DataTable dt = dh.getFieldsDataByCondition("makeserial", new string[] { "ms_stepcode", "nvl(ms_ifrework,0)ms_ifrework", "ms_status" }, "ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakeCode + "'");
  819. if (dt.Rows.Count > 0)
  820. {
  821. string ifrework = dt.Rows[0]["ms_ifrework"].ToString();
  822. string ms_stepcode = dt.Rows[0]["ms_stepcode"].ToString();
  823. string ms_status = dt.Rows[0]["ms_status"].ToString();
  824. if (ms_status == "2")
  825. {
  826. dh.ExecuteSql("delete from steppassed where sp_sncode='" + iSnCode + "' and sp_makecode='" + iMakeCode + "' and sp_stepcode='" + StepCode + "'", "delete");
  827. dh.UpdateByCondition("make", "ma_madeqty=nvl(ma_madeqty,0)-1", "ma_code='" + iMakeCode + "'");
  828. }
  829. if (ms_stepcode == StepCode)
  830. {
  831. if (ifrework == "0")
  832. dh.UpdateByCondition("makeserial", "ms_status=3,ms_nextstepcode=''", "ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakeCode + "'");
  833. else
  834. dh.UpdateByCondition("makeserial", "ms_reworkstatus=3,ms_nextstepcode=''", "ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakeCode + "'");
  835. }
  836. else
  837. {
  838. if (ifrework == "0")
  839. dh.UpdateByCondition("makeserial", "ms_nextstepcode='',ms_status=3", "ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakeCode + "' ");
  840. else
  841. dh.UpdateByCondition("makeserial", "ms_nextstepcode='',ms_paststep = ms_paststep ||'," + StepCode + "',ms_reworkstatus=3", "ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakeCode + "'");
  842. SetTestResult(iMakeCode, iSourceCode, iSnCode, "不良采集", "NG", iUserCode, out oErrorMessage);
  843. }
  844. }
  845. return true;
  846. }
  847. /// <summary>
  848. /// 判断是否扣料工序,执行扣料,执行上料表记录
  849. /// </summary>
  850. /// <param name="iSnCode"></param>
  851. /// <param name="iMakeCode"></param>
  852. /// <param name="iUserName"></param>
  853. /// <param name="iSourceCode"></param>
  854. public static bool SetCollectionFinish(string iSnCode, string iMakeCode, string iUserName, string iSourceCode, out string oErrorMessage)
  855. {
  856. string StepCode = "";
  857. string StepName = "";
  858. string LineCode = "";
  859. oErrorMessage = "";
  860. GetStepCodeAndNameAndLineBySource(iSourceCode, ref StepCode, ref StepName, ref LineCode);
  861. if (StepCode == "" && StepName == "")
  862. {
  863. oErrorMessage = "当前岗位资源找不到对应工序,请先进行维护";
  864. return false;
  865. }
  866. sql.Clear();
  867. sql.Append("select nvl(cd_ifreduce,0) cd_ifreduce from craft left join craftdetail on cd_crid=cr_id ");
  868. sql.Append("where cr_code=(select ma_craftcode from makeserial left join make on ma_code = ms_makecode ");
  869. sql.Append("where ms_sncode = '" + iSnCode + "' and ms_makecode='" + iMakeCode + "') and cd_stepcode='" + StepCode + "'");
  870. DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  871. sql.Clear();
  872. if (dt.Rows.Count > 0)
  873. {
  874. string cd_ifreduce = dt.Rows[0][0].ToString();
  875. if (cd_ifreduce == "-1")
  876. {
  877. sql.Clear();
  878. sql.Append("select dsl_location,dsl_table,max(dsl_baseqty) baseqty from devsmtlocation where dsl_makecode='" + iMakeCode + "' and ");
  879. sql.Append("dsl_linecode='" + LineCode + "' and dsl_status=0 and dsl_remainqty>0 and dsl_invalidtime is null group by dsl_location,dsl_table");
  880. dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  881. for (int i = 0; i < dt.Rows.Count; i++)
  882. {
  883. sql.Clear();
  884. sql.Append("select dsl_id,dsl_remainqty from devsmtlocation where dsl_makecode='" + iMakeCode + "' and dsl_linecode='" + LineCode + "' ");
  885. sql.Append("and dsl_status=0 and dsl_remainqty>0 and dsl_invalidtime is null and rownum<3 order by dsl_id asc ");
  886. DataTable dt1 = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  887. for (int j = 0; j < dt1.Rows.Count; j++)
  888. {
  889. //外层循环的值dt
  890. double baseqty = (double)dt.Rows[i]["baseqty"];
  891. //内层循环的值dt1
  892. double dsl_remainqty = (double)dt1.Rows[j]["dsl_remainqty"];
  893. string dsl_id = dt1.Rows[j]["dsl_id"].ToString();
  894. if (baseqty > 0)
  895. {
  896. if (dsl_remainqty <= baseqty)
  897. {
  898. sql.Clear();
  899. sql.Append("update devsmtlocation set dsl_remainqty=0,dsl_invalidtime =sysdate, dsl_validtime =(case when dsl_validtime ");
  900. sql.Append("is null then sysdate else dsl_validtime end),dsl_status=-1 where dsl_id=" + dsl_id);
  901. dh.ExecuteSql(sql.ToString(), "update");
  902. baseqty -= dsl_remainqty;
  903. }
  904. else
  905. {
  906. sql.Clear();
  907. sql.Append("update devsmtlocation set dsl_remainqty=dsl_remainqty-NVL(dsl_baseqty,0),DSL_INVALIDTIME=(case when");
  908. sql.Append("dsl_validtime is null then sysdate else dsl_validtime end) where dsl_id=" + dsl_id);
  909. dh.ExecuteSql(sql.ToString(), "update");
  910. baseqty = 0;
  911. }
  912. }
  913. else
  914. dh.ExecuteSql("update devsmtlocation set DSL_INVALIDTIME=sysdate where dsl_id=" + dsl_id, "update");
  915. }
  916. }
  917. sql.Clear();
  918. sql.Append("insert into ReduceStepRecord (rsd_id,rsd_macode,rsd_maprodcode,rsd_table,rsd_sncode,rsd_linecode,rsd_sourcecode) select ");
  919. sql.Append("ReduceStepRecord_SEQ.nextval,'" + iMakeCode + "',ma_prodcode,'','" + iSnCode + "','" + LineCode + "','" + iSourceCode + "' ");
  920. sql.Append("from make where ma_code='" + iMakeCode + "'");
  921. dh.ExecuteSql(sql.ToString(), "insert");
  922. }
  923. return true;
  924. }
  925. else
  926. {
  927. return false;
  928. }
  929. }
  930. /// <summary>
  931. /// 执行下料操作
  932. /// </summary>
  933. /// <param name="iSnCode"></param>
  934. /// <param name="iBarCode"></param>
  935. /// <param name="iCurrentStep"></param>
  936. /// <param name="iUserName"></param>
  937. /// <param name="oErrorMessage"></param>
  938. /// <returns></returns>
  939. public static bool SetMaterialDown(string iSnCode, string iBarCode, string iSourceCode, string iCurrentStep, string iUserName, out string oErrorMessage)
  940. {
  941. //序列号不为空的时候
  942. oErrorMessage = "";
  943. DataTable dt;
  944. //对序列号进行验证
  945. dt = (DataTable)dh.ExecuteSql("select ms_status,ms_stepcode,ms_nextstepcode from makeserial where ms_sncode='" + iBarCode + "'", "select");
  946. if (dt.Rows.Count > 0)
  947. {
  948. string ms_status = dt.Rows[0]["ms_status"].ToString();
  949. string ms_stepcode = dt.Rows[0]["ms_stepcode"].ToString();
  950. string ms_nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
  951. if (ms_status == "1" && ms_stepcode != iCurrentStep)
  952. oErrorMessage = "当前工序不是" + iCurrentStep + "";
  953. else if (ms_status == "0" && ms_stepcode != iCurrentStep)
  954. oErrorMessage = "当前工序不是" + iCurrentStep + "";
  955. else if (ms_status == "2" && ms_nextstepcode != iCurrentStep)
  956. oErrorMessage = "该序列号已经包装";
  957. else
  958. {
  959. dt = (DataTable)dh.ExecuteSql("select * from craftmaterial where cm_sncode='" + iSnCode + "'", "select");
  960. if (dt.Rows.Count > 0)
  961. oErrorMessage = "请采集需要下料的序列号";
  962. else
  963. oErrorMessage = "该序列号未上料,无需下料";
  964. }
  965. }
  966. if (oErrorMessage == "")
  967. {
  968. dt = (DataTable)dh.ExecuteSql("select cm_id,cm_stepcode,ms_makecode,cm_mccode from craftmaterial left join makeserial on cm_makecode=ms_makecode and cm_sncode=ms_sncode where ms_sncode='" + iSnCode + "' and cm_barcode='" + iBarCode + "'", "select");
  969. if (dt.Rows.Count > 0)
  970. {
  971. string cm_id = dt.Rows[0]["cm_id"].ToString();
  972. string ms_macode = dt.Rows[0]["ms_makecode"].ToString();
  973. string cm_stepcode = dt.Rows[0]["cm_stepcode"].ToString();
  974. string cm_mccode = dt.Rows[0]["cm_mccode"].ToString();
  975. dh.ExecuteSql("delete from Craftmaterial where cm_id=" + cm_id, "delete");
  976. InsertMakeProcess(ms_macode, iSnCode, iSourceCode, "下料操作", "下料成功", iUserName);
  977. int count = dh.getRowCount("craftMaterial", "cm_mccode='" + cm_mccode + "' and cm_stepcode='" + cm_stepcode + "' and cm_sncode='" + iSnCode + "'");
  978. if (count == 0)
  979. 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 + "'");
  980. }
  981. return true;
  982. }
  983. else
  984. return false;
  985. }
  986. public static void CollectRemarkInf(string iSN, string iECN, string iSoftVersion, string iMaCode, string iPrCode, string iRemark)
  987. {
  988. sql.Clear();
  989. sql.Append("insert into SNRELATIONINFORECORD(SIR_ID,SIR_SNCODE,SIR_MSCODE,SIR_ECNCODE,SIR_SOFTVER,");
  990. sql.Append("SIR_LINECODE,SIR_SOURCECODE,SIR_STEPCODE,SIR_MACODE,SIR_PRODCODE,SIR_INMAN,SIR_INDATE,sir_firstsn,sir_remark) select ");
  991. sql.Append("SNRELATIONINFORECORD_SEQ.nextval,'" + iSN + "',ms_code,'" + iECN + "','" + iSoftVersion + "',");
  992. sql.Append("'" + User.UserLineCode + "','" + User.UserSourceCode + "','" + User.CurrentStepCode + "','" + iMaCode + "','" + iPrCode + "',");
  993. sql.Append("'" + User.UserCode + "',sysdate,ms_firstsn,'" + iRemark + "' from makeserial where ms_sncode='" + iSN + "' and ms_makecode='" + iMaCode + "'");
  994. dh.ExecuteSql(sql.ToString(), "insert");
  995. }
  996. /// <summary>
  997. /// 获取执行步骤代码,名称和线别
  998. /// </summary>
  999. /// <param name="Source"></param>
  1000. /// <param name="StepCode"></param>
  1001. /// <param name="StepName"></param>
  1002. /// <param name="LineCode"></param>
  1003. private static void GetStepCodeAndNameAndLineBySource(string Source, ref string StepCode, ref string StepName, ref string LineCode)
  1004. {
  1005. DataTable dt = dh.getFieldsDataByCondition("source", new string[] { "sc_stepcode", "sc_stepname", "sc_linecode" }, "sc_code='" + Source + "'");
  1006. if (dt.Rows.Count > 0)
  1007. {
  1008. StepCode = dt.Rows[0]["sc_stepcode"].ToString();
  1009. StepName = dt.Rows[0]["sc_stepname"].ToString();
  1010. LineCode = dt.Rows[0]["sc_linecode"].ToString();
  1011. }
  1012. }
  1013. /// <summary>
  1014. /// 获取步骤代码和名称
  1015. /// </summary>
  1016. /// <param name="Source"></param>
  1017. /// <param name="StepCode"></param>
  1018. /// <param name="StepName"></param>
  1019. private static void GetStepCodeAndNameAndTypAndLineCodeBySource(string Source, ref string StepCode, ref string StepName, ref string ScanType, ref string LineCode)
  1020. {
  1021. DataTable dt = dh.getFieldsDataByCondition("source", new string[] { "sc_scantype", "sc_stepcode", "sc_stepname", "sc_linecode" }, "sc_code='" + Source + "'");
  1022. if (dt.Rows.Count > 0)
  1023. {
  1024. StepCode = dt.Rows[0]["sc_stepcode"].ToString();
  1025. StepName = dt.Rows[0]["sc_stepname"].ToString();
  1026. ScanType = dt.Rows[0]["sc_scantype"].ToString();
  1027. LineCode = dt.Rows[0]["sc_linecode"].ToString();
  1028. }
  1029. }
  1030. /// <summary>
  1031. /// 获取步骤代码
  1032. /// </summary>
  1033. /// <param name="Source"></param>
  1034. /// <returns></returns>
  1035. private static string GetStepCodeBySource(string Source)
  1036. {
  1037. return dh.getFieldDataByCondition("source", "sc_stepcode", "sc_code='" + Source + "'").ToString();
  1038. }
  1039. /// <summary>
  1040. /// 获取箱号
  1041. /// </summary>
  1042. /// <param name="pr_id">物料主表的ID</param>
  1043. /// <param name="kind">管控类型</param>
  1044. /// <returns></returns>
  1045. public static string GetOutBoxCode(string Caller, string iMakeCode, string iProdCode, string iUserCode)
  1046. {
  1047. string BoxCode = "";
  1048. string[] param = new string[] { Caller, iMakeCode, iProdCode, iUserCode, BoxCode };
  1049. dh.CallProcedure("SP_GETPACKORPALLETCODE", ref param);
  1050. return param[4];
  1051. }
  1052. /// <summary>
  1053. /// 获取老化编号
  1054. /// </summary>
  1055. /// <returns></returns>
  1056. public static string GetAGCode()
  1057. {
  1058. string BoxCode = "";
  1059. string[] param = new string[] { BoxCode };
  1060. dh.CallProcedure("SP_GETAGCODE", ref param);
  1061. return param[0];
  1062. }
  1063. public static bool CheckSNBeforeLoad(string iMakeCode, string iSN, string iFSonCode, string iSonCode, string iRule, string iPrefix, string iLength, string iIfRepeat, string iChecksalecode, out string ErrMessage)
  1064. {
  1065. DataTable dt;
  1066. ErrMessage = "";
  1067. switch (iRule)
  1068. {
  1069. case "TSN":
  1070. dt = (DataTable)dh.ExecuteSql("select ms_id,ms_prodcode,ms_nextmacode,ms_salecode,ms_downstatus from makeserial where ms_sncode='" + iSN + "' and ms_makecode<>'" + iMakeCode + "' and ms_status=2 order by ms_id desc", "select");
  1071. if (dt.Rows.Count > 0)
  1072. {
  1073. if (dt.Rows[0]["ms_downstatus"].ToString() != "0")
  1074. {
  1075. ErrMessage = "序列号:" + iSN + "已下地,请先取消下地";
  1076. return false;
  1077. }
  1078. if (dt.Rows[0]["ms_nextmacode"].ToString() != "")
  1079. {
  1080. ErrMessage = "序列号:" + iSN + "已被工单" + dt.Rows[0]["ms_nextmacode"].ToString() + "使用";
  1081. return false;
  1082. }
  1083. if ((dt.Rows[0]["ms_salecode"].ToString() != dh.getFieldDataByCondition("make", "ma_salecode", "ma_code='" + iMakeCode + "'").ToString()) && iChecksalecode != "0")
  1084. {
  1085. ErrMessage = "序列号对应销售订单与工单不符";
  1086. return false;
  1087. }
  1088. //ms_salecode是否等于工单的SaleCode
  1089. if (iSonCode != dt.Rows[0]["ms_prodcode"].ToString())
  1090. {
  1091. ErrMessage = "序列号对应的物料不是:" + iSonCode;
  1092. return false;
  1093. }
  1094. else
  1095. {
  1096. return true;
  1097. }
  1098. }
  1099. else ErrMessage = "序列号" + iSN + "不存在";
  1100. break;
  1101. case "BARCODE":
  1102. if (iIfRepeat != "-1")
  1103. {
  1104. //判定条码是否已经上料了
  1105. dt = (DataTable)dh.ExecuteSql("select cm_barcode from craftmaterial where cm_barcode='" + iSN + "' and cm_status=0", "select");
  1106. if (dt.Rows.Count > 0)
  1107. {
  1108. ErrMessage = "条码" + iSN + "已经上料";
  1109. return false;
  1110. }
  1111. }
  1112. dt = (DataTable)dh.ExecuteSql("select bar_prodcode,bar_code from barcode where bar_code='" + iSN + "'", "select");
  1113. if (dt.Rows.Count > 0)
  1114. {
  1115. string bar_prodcode = dt.Rows[0]["bar_prodcode"].ToString();
  1116. if (!iFSonCode.Contains(bar_prodcode))
  1117. {
  1118. if (!iSonCode.Contains(bar_prodcode))
  1119. {
  1120. ErrMessage = "用户条码号对应的物料不是:" + iSonCode;
  1121. }
  1122. else
  1123. {
  1124. ErrMessage = bar_prodcode;
  1125. return true;
  1126. }
  1127. }
  1128. else
  1129. {
  1130. ErrMessage = bar_prodcode;
  1131. return true;
  1132. }
  1133. }
  1134. else ErrMessage = "条码" + iSN + "不存在";
  1135. break;
  1136. case "RULE":
  1137. if (iIfRepeat != "-1")
  1138. {
  1139. dt = (DataTable)dh.ExecuteSql("select cm_barcode from craftmaterial where cm_barcode='" + iSN + "' and cm_status=0", "select");
  1140. if (dt.Rows.Count > 0)
  1141. {
  1142. ErrMessage = "条码" + iSN + "已经上料";
  1143. return false;
  1144. }
  1145. }
  1146. if (iFSonCode == "LT.41.133.001A")
  1147. {
  1148. dt = (DataTable)dh.ExecuteSql("select * from ( select count(1) cn from CRAFTMATERIAL where cm_barcode='" + iSN + "' and cm_status = 0 ) where cn>=100", "select");
  1149. if (dt.Rows.Count > 0)
  1150. {
  1151. ErrMessage = "条码" + iSN + "所属物料" + iFSonCode + ",已使用100次";
  1152. return false;
  1153. }
  1154. }
  1155. //int sp_length = int.Parse(iLength != "" ? iLength : "0");
  1156. //若有多个,以|分割
  1157. string[] pres = iPrefix.Split('|');
  1158. bool f = false;
  1159. for (int i = 0; i < pres.Length; i++)
  1160. {
  1161. if (pres[i] == "" ? true : iSN.Contains(pres[i]))
  1162. {
  1163. //满足其中一条即可
  1164. f = true;
  1165. break;
  1166. }
  1167. }
  1168. if (f)
  1169. {
  1170. string[] lengths = iLength.Split('|');
  1171. if (lengths.Length == 0)
  1172. return true;
  1173. else
  1174. {
  1175. for (int i = 0; i < lengths.Length; i++)
  1176. {
  1177. if (int.Parse(lengths[i] != "" ? lengths[i] : "0") == iSN.Length || int.Parse(lengths[i] != "" ? lengths[i] : "0") == 0)
  1178. {
  1179. return true;
  1180. }
  1181. }
  1182. }
  1183. ErrMessage = iSN + "长度不匹配";
  1184. }
  1185. else ErrMessage = iSN + "前缀不匹配";
  1186. break;
  1187. default:
  1188. break;
  1189. }
  1190. return false;
  1191. }
  1192. public static bool Packing(string iSN, string iOutBoxCode, bool iAutoNew, string iType, string iSource, string iUser, string iStandarqty, bool iInOrOut, out string oOutBoxCode, out string oErrorMessage)
  1193. {
  1194. oErrorMessage = "";
  1195. oOutBoxCode = "";
  1196. string[] param = new string[] { iSN, iOutBoxCode, iAutoNew ? "Y" : "N", iType, iSource, iUser, iStandarqty, iInOrOut ? "OUT" : "IN", oOutBoxCode, oErrorMessage };
  1197. dh.CallProcedure("CS_PACKCARTON", ref param);
  1198. oOutBoxCode = param[8];
  1199. oErrorMessage = param[9];
  1200. if (oErrorMessage == "" || oErrorMessage == null || oErrorMessage == "null")
  1201. return true;
  1202. else
  1203. return false;
  1204. }
  1205. public static void RecordProdWeight(string iSN, string iType, float iWeight, string iUnit, string iLineCode, string iPrCode, string iSource, string iUser)
  1206. {
  1207. //记录重量
  1208. sql.Clear();
  1209. sql.Append("insert into weightlog(wl_id,wl_type,wl_scancode,wl_weight,wl_unit,wl_linecode,");
  1210. sql.Append("wl_prodcode,wl_sccode,wl_indate,wl_inman) values (weightlog_seq.nextval,:wl_type,:wl_scancode,");
  1211. sql.Append(":wl_weight,:wl_unit,:wl_linecode,:wl_prodcode,:wl_sccode,sysdate,:wl_inman)");
  1212. dh.ExecuteSql(sql.ToString(), "insert", iType, iSN, iWeight, iUnit, iLineCode, iPrCode, iSource, iUser);
  1213. }
  1214. public static bool CheckUpdate()
  1215. {
  1216. string version = BaseUtil.GetCacheData("Version").ToString();
  1217. DataHelper dh = new DataHelper();
  1218. string LastVersion = dh.getFieldDataByCondition("configs", "code", "caller='CSUPDATE'").ToString();
  1219. if (version == LastVersion || version == "" || LastVersion == "")
  1220. {
  1221. return false;
  1222. }
  1223. else
  1224. {
  1225. BaseUtil.SetCacheData("Version", LastVersion);
  1226. return true;
  1227. }
  1228. }
  1229. /// <summary>
  1230. /// 小箱装大箱的包装规则判断
  1231. /// </summary>
  1232. /// <param name="packrule"></param>
  1233. /// <param name="pa_outboxcode"></param>
  1234. /// <param name="outboxcode"></param>
  1235. /// <param name="pa_makecode"></param>
  1236. /// <param name="pa_salecode"></param>
  1237. /// <param name="pa_prodcode"></param>
  1238. /// <param name="error"></param>
  1239. /// <returns></returns>
  1240. public static Boolean CheckPackRule(string packrule, string pa_outboxcode, string outboxcode, string pa_makecode, string pa_salecode, string pa_prodcode, string type, out string error)
  1241. {
  1242. //按工单核对装箱
  1243. switch (packrule.ToUpper())
  1244. {
  1245. case "MAKE":
  1246. string makecode = dh.getFieldDataByCondition("package", "pa_makecode", "pa_outboxcode='" + outboxcode + "'").ToString();
  1247. if (makecode != pa_makecode && pa_makecode != "")
  1248. {
  1249. error = ">>当前箱" + outboxcode + "对应工单号" + makecode + "和所装" + type + "号" + pa_outboxcode + "对应工单" + pa_makecode + "不相等";
  1250. return false;
  1251. }
  1252. break;
  1253. case "SALE":
  1254. if (dh.CheckExist("package", "pa_outboxcode='" + pa_outboxcode + "'"))
  1255. {
  1256. string salecode = dh.getFieldDataByCondition("package", "pa_salecode", "pa_outboxcode = '" + outboxcode + "'").ToString();
  1257. if (salecode != pa_salecode)
  1258. {
  1259. error = ">>当前箱" + outboxcode + "对应订单号" + salecode + "和所装" + type + "号" + pa_outboxcode + "对应订单" + pa_salecode + "不相等";
  1260. return false;
  1261. }
  1262. }
  1263. break;
  1264. case "PROD":
  1265. string prodcode = dh.getFieldDataByCondition("package", "pa_prodcode", "pa_outboxcode='" + outboxcode + "'").ToString();
  1266. if (prodcode != pa_prodcode)
  1267. {
  1268. error = ">>当前箱" + outboxcode + "对应物料" + prodcode + "和所装" + type + "号" + pa_outboxcode + "对应物料" + pa_prodcode + "不相等";
  1269. return false;
  1270. }
  1271. break;
  1272. case "MIX":
  1273. break;
  1274. default:
  1275. prodcode = dh.getFieldDataByCondition("package", "pa_prodcode", "pa_outboxcode='" + outboxcode + "'").ToString();
  1276. error = ">>当前箱" + outboxcode + "对应物料" + prodcode + "没有维护装箱规则";
  1277. return false;
  1278. break;
  1279. }
  1280. error = "";
  1281. return true;
  1282. }
  1283. /// <summary>
  1284. /// 验证是否符合合同防呆
  1285. /// </summary>
  1286. /// <param name="msid"></param>
  1287. /// <param name="macOrBt"></param>
  1288. /// <param name="type"></param>
  1289. /// <returns></returns>
  1290. public static Boolean checkMacOrBtRange(string msid, string macOrBt, string type)
  1291. {
  1292. //--判断是否有合同,是否在合同定义的范围内
  1293. string saleCode = dh.getFieldDataByCondition("makeserial", "ms_salecode", "ms_id='" + msid + "'").ToString();
  1294. if (saleCode == "")
  1295. {
  1296. return true;
  1297. }
  1298. //判断是否有合同范围
  1299. if (dh.CheckExist("SaleMacBTRange", "Sr_Sacode = '" + saleCode + "' and sr_type = '" + type + "'"))
  1300. {
  1301. //有合同范围再判断是否在范围内
  1302. if (!dh.CheckExist("SaleMacBTRange", "Sr_Sacode = '" + saleCode + "' and sr_type = '" + type + "' and '" + macOrBt + "' between SR_STARTCODE and SR_ENDCODE"))
  1303. {
  1304. return false;
  1305. }
  1306. }
  1307. return true;
  1308. }
  1309. /// <summary>
  1310. /// 序列烧录转换
  1311. /// </summary>
  1312. /// <param name="iTSN"></param>
  1313. /// <param name="iSN"></param>
  1314. /// <param name="iSourcecode"></param>
  1315. /// <param name="iUsercode"></param>
  1316. /// <param name="iMacode"></param>
  1317. /// <param name="iifrechange"></param>
  1318. /// <param name="iMEI1"></param>
  1319. /// <param name="iMEI2"></param>
  1320. /// <param name="iMEI3"></param>
  1321. /// <param name="iMEID"></param>
  1322. /// <param name="iNETCODE"></param>
  1323. /// <param name="iPSN"></param>
  1324. /// <param name="iID1"></param>
  1325. /// <param name="iID2"></param>
  1326. /// <param name="iID3"></param>
  1327. /// <param name="iMAC"></param>
  1328. /// <param name="iBT"></param>
  1329. /// <param name="iCODE1"></param>
  1330. /// <param name="iCODE2"></param>
  1331. /// <param name="iCODE3"></param>
  1332. /// <param name="oErrorMessage"></param>
  1333. /// <returns></returns>
  1334. public static bool snChangeAndBurn(string iTSN, string iSN, string iSourcecode, string iUsercode, string iMacode, int iifrechange, string iMEI1, string iMEI2, string iMEI3, string iMEID, string iNETCODE, string iPSN, string iID1, string iID2, string iID3, string iMAC, string iBT, string iCODE1, string iCODE2, string iCODE3, out string oErrorMessage)
  1335. {
  1336. oErrorMessage = "";
  1337. string[] param = new string[] { iTSN, iSN, iSourcecode, iUsercode, iMacode, iifrechange + "", iMEI1, iMEI2, iMEI3, iMEID, iNETCODE, iPSN, iID1, iID2, iID3, iMAC, iBT, iCODE1, iCODE2, iCODE3, oErrorMessage };
  1338. dh.CallProcedure("CS_SNCHANGEANDBURN", ref param);
  1339. oErrorMessage = param[20];
  1340. if (oErrorMessage == "" || oErrorMessage == null || oErrorMessage == "null" || oErrorMessage.Contains("AFTERSUCCESS"))
  1341. return true;
  1342. else
  1343. return false;
  1344. }
  1345. public static bool snBurn(string iTSN, string iSN, string iSourcecode, string iUsercode, string iMacode, int iifrechange, string iMEI1, string iMEI2, string iMEI3, string iMEID, string iNETCODE, string iPSN, string iID1, string iID2, string iID3, string iMAC, string iBT, string iCODE1, string iCODE2, string iCODE3, out string oErrorMessage)
  1346. {
  1347. oErrorMessage = "";
  1348. string[] param = new string[] { iTSN, iSN, iSourcecode, iUsercode, iMacode, iifrechange + "", iMEI1, iMEI2, iMEI3, iMEID, iNETCODE, iPSN, iID1, iID2, iID3, iMAC, iBT, iCODE1, iCODE2, iCODE3, oErrorMessage };
  1349. dh.CallProcedure("CS_SNBURN", ref param);
  1350. oErrorMessage = param[20];
  1351. if (oErrorMessage == "" || oErrorMessage == null || oErrorMessage == "null" || oErrorMessage.Contains("AFTERSUCCESS"))
  1352. return true;
  1353. else
  1354. return false;
  1355. }
  1356. /// <summary>
  1357. /// 记录打印
  1358. /// </summary>
  1359. /// <param name="printValue"></param>
  1360. /// <param name="printType"></param>
  1361. /// <param name="MakeCode"></param>
  1362. /// <param name="prodCode"></param>
  1363. /// <param name="sourceCode"></param>
  1364. /// <param name="stepcode"></param>
  1365. /// <param name="ifRePrint"></param>
  1366. /// <param name="userCode"></param>
  1367. public static void doLabelPrintLog(string printValue, string printType, string MakeCode, string prodCode, string sourceCode, string stepcode, string ifRePrint, string userCode)
  1368. {
  1369. sql.Clear();
  1370. sql.Append("insert into labelprintlog(LPL_ID,LPL_VALUE,LPL_TYPE,LPL_MAKECODE,LPL_PRODCODE,LPL_SOURCECODE,LPL_STEPCODE,LPL_IFREPRINT,LPL_INDATE,LPL_INMAN) ");
  1371. sql.Append("values( labelprintlog_seq.nextval,:lpl_value,:lpl_type,:makecode,:prodcode,");
  1372. sql.Append(":SourceCode,:stepcode,:ifreprint,sysdate,:inman)");
  1373. dh.ExecuteSql(sql.ToString(), "insert", printValue, printType, MakeCode, prodCode, sourceCode, stepcode, ifRePrint, userCode);
  1374. }
  1375. public static bool GetMobileAllInfo(string iSN, out Dictionary<string, string> oInfo, out string oErrMessage)
  1376. {
  1377. oInfo = new Dictionary<string, string>();
  1378. oErrMessage = "";
  1379. if (iSN == "")
  1380. {
  1381. oErrMessage = "SN不能为空";
  1382. return false;
  1383. }
  1384. //通过序列号获取最近操作的工单号
  1385. string ms_id = dh.getFieldDataByCondition("makeserial", "max(ms_id)", "ms_sncode='" + iSN + "'").ToString();
  1386. if (ms_id != "")
  1387. {
  1388. DataTable dt = dh.getFieldsDataByCondition("MakeSerial", new string[] { "ms_id", "ms_mac", "ms_bt", "ms_meid", "ms_netcode", "ms_psn", "ms_imei1", "ms_imei2", "ms_imei3", "ms_othcode1", "ms_othcode2", "ms_othcode3", "ms_othid1", "ms_othid2", "ms_othid3" }, "ms_id='" + ms_id + "'");
  1389. if (dt.Rows.Count > 0)
  1390. {
  1391. string Code1 = "";
  1392. string Code2 = "";
  1393. string Code3 = "";
  1394. string Code4 = "";
  1395. string Code5 = "";
  1396. string Code6 = "";
  1397. string Code7 = "";
  1398. string Code8 = "";
  1399. string Code9 = "";
  1400. string Code10 = "";
  1401. string Code11 = "";
  1402. string Code12 = "";
  1403. string Code13 = "";
  1404. string Code14 = "";
  1405. string Code15 = "";
  1406. string[] param = new string[] { ms_id, Code1, Code2, Code3, Code4, Code5, Code6, Code7, Code8, Code9, Code10, Code11, Code12, Code13, Code14, Code15 };
  1407. string[] ParamName = new string[] { "v_ms_id", "v_i_code1", "v_i_code2", "v_i_code3", "v_i_code4", "v_i_code5", "v_i_code6", "v_i_code7", "v_i_code8", "v_i_code9", "v_i_code10", "v_i_code11", "v_i_code12", "v_i_code13", "v_i_code14", "v_i_code15" };
  1408. dh.CallProcedure("GetMobileAllInfo", ParamName, ref param);
  1409. for (int i = 1; i < param.Length; i++)
  1410. {
  1411. //获取出来的参数使用^分割
  1412. if (param[i] != "" && param[i] != "null" && param[i] != null)
  1413. {
  1414. oInfo.Add(param[i].Split('^')[0], param[i].Split('^')[1]);
  1415. }
  1416. }
  1417. oErrMessage = "";
  1418. return true;
  1419. }
  1420. else
  1421. {
  1422. oErrMessage = "序列号" + iSN + "不存在";
  1423. return false;
  1424. }
  1425. }
  1426. else
  1427. {
  1428. oErrMessage = "序列号" + iSN + "不存在";
  1429. return false;
  1430. }
  1431. }
  1432. public static void GetQuerySQL(string iCondition, string type, out string v_sql1)
  1433. {
  1434. v_sql1 = "";
  1435. string[] param = new string[] { iCondition, type, v_sql1 };
  1436. dh.CallProcedure("GetQuerySQL", ref param);
  1437. v_sql1 = param[2];
  1438. }
  1439. }
  1440. }