LogicHandler.cs 75 KB

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