DrawHelper.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. //create or replace PROCEDURE "CS_PACKCARTON"
  2. //-- =============================================
  3. //-- Author: <XIAOST>
  4. //-- Create date: <2017-09-23>
  5. //-- Description: <装卡通箱
  6. //-- 1、 支持自动生成箱号,
  7. //-- 2、 支持转入已存在箱号,
  8. //-- 3、 标准装箱需要产品和箱号的包装规则一致 包含:按合同 SALE,按订单 MAKE ,按产品 PROD,混合 MIX
  9. //-- 4、 特殊装箱,无需考虑装箱规则等限制
  10. //-- >
  11. //-- =============================================
  12. //( /*
  13. // 参数:输入 -- SN号,箱号,是否自动生成,装箱类型,岗位资源,操作人编号
  14. // 输出 --箱号,异常信息
  15. // */
  16. // v_i_sncode in varchar2, --SN
  17. // v_i_outboxcode in varchar2, --卡通箱号
  18. // v_i_autonew in varchar2 default 'N', --默认否
  19. // v_i_type in varchar2 ,-- 装箱类型,标准或者特殊,默认标准
  20. // v_i_sourcecode in varchar2, --岗位资源编号
  21. // v_i_usercode in varchar2, --人员编号
  22. // v_i_standardqty in number, --标准容量
  23. // v_i_inorout in varchar2, ---装箱或取消装箱入或者出 IN, OUT
  24. // v_o_outboxcode out varchar2, --输出卡通箱号
  25. // v_o_errmsg out varchar2 ---输入异常信息
  26. //) as
  27. // v_pr_packrule product.pr_packrule%type; --产品包装规则
  28. //v_pr_outboxinnerqty product.pr_outboxinnerqty%type;--装箱容量
  29. //v_pa_packtype varchar2(20); --卡通箱装箱类型
  30. //v_pa_standardqty number; ---标准容量
  31. //v_pa_currentqty number;
  32. // v_pa_prodcode varchar2(50);
  33. //v_pa_makecode varchar2(50);
  34. //v_pa_salecode varchar2(50);
  35. //v_pa_downstatus number; --是否下地
  36. //v_pa_id number;
  37. // v_pa_status number;
  38. //v_pa_checkno varchar2(30);
  39. //v_pa_currentstep varchar2(60);
  40. //v_pa_mothercode varchar2(50);
  41. //v_pa_outno varchar2(50);
  42. //v_ob_status varchar2(20);
  43. //v_outboxcode varchar2(30);
  44. //v_ms_prodcode varchar2(50);
  45. //v_ms_makecode make.ma_code%type;
  46. //v_ms_id makeserial.ms_id%type;
  47. //v_ms_outboxcode varchar2(50);
  48. //v_ms_craftcode varchar2(50);
  49. //v_ms_salecode varchar2(50);
  50. //v_ms_downstatus number; --是否下地
  51. //v_currentstep varchar2(50);
  52. //v_linecode varchar2(50);
  53. //v_scstatuscode varchar2(50);
  54. //v_stepname varchar2(100);
  55. //v_wccode varchar2(30);
  56. //v_count int;
  57. // v_new int:=0; ---0表示否,-1 需要新增箱号
  58. //BEGIN
  59. // --初始化输出参数值
  60. // v_o_errmsg:=null;
  61. // v_o_outboxcode:=null;
  62. // --判定岗位资源
  63. // select sc_statuscode,sc_stepcode,sc_linecode,sc_stepname,sc_wccode into v_scstatuscode,v_currentstep,v_linecode,v_stepname ,v_wccode from source where sc_code=v_i_sourcecode;
  64. // IF v_scstatuscode<>'AUDITED' or v_scstatuscode is null THEN
  65. // v_o_errmsg:='岗位资源不存在或者未审核';
  66. //RETURN;
  67. // END IF;
  68. // --获取序列号
  69. // select max(ms_id) into v_ms_id from makeserial where ms_sncode = v_i_sncode;
  70. // IF(v_ms_id>0)THEN
  71. // select ms_outboxcode,ms_prodcode,ms_salecode,ms_makecode,pr_packrule,ms_craftcode,pr_outboxinnerqty,nvl(ms_downstatus,0) into v_ms_outboxcode, v_ms_prodcode, v_ms_salecode, v_ms_makecode, v_pr_packrule, v_ms_craftcode, v_pr_outboxinnerqty, v_ms_downstatus from makeserial left join product on pr_code=ms_prodcode where ms_id=v_ms_id;
  72. // ELSE
  73. // v_o_errmsg:='序列号:'||v_i_sncode||'不存在';
  74. // RETURN;
  75. // END IF;
  76. // --判断是否下地
  77. // IF(v_ms_downstatus<>0)THEN
  78. // v_o_errmsg:='序列号:'||v_i_sncode||'不允许采集,下地状态不允许采集';
  79. // RETURN;
  80. // END IF;
  81. // --装箱
  82. // IF('IN'=v_i_inorout)THEN
  83. // --必须是未装箱,如果是已装箱提示
  84. // IF(NVL(v_ms_outboxcode,' ')<>' ')THEN
  85. // IF(v_ms_outboxcode= v_i_outboxcode)THEN
  86. // v_o_errmsg:='序列号:'||v_i_sncode||'已在箱内';
  87. // RETURN;
  88. // ELSE
  89. // v_o_errmsg:='序列号:'||v_i_sncode||'不允许采集,已装入箱号:'||v_ms_outboxcode;
  90. // RETURN;
  91. // END IF;
  92. //END IF;
  93. // --判断有传入需装箱号
  94. // IF(nvl(v_i_outboxcode,' ')<>' ')THEN
  95. // v_outboxcode :=v_i_outboxcode;
  96. // BEGIN
  97. // select pa_id,pa_prodcode,pa_salecode,pa_maKEcode,pa_packtype,pa_standardqty,nvl(pa_currentqty,0),pa_status,pa_downstatus into v_pa_id,v_pa_prodcode,v_pa_salecode,v_pa_makecode,v_pa_packtype,v_pa_standardqty,v_pa_currentqty,v_pa_status,v_pa_downstatus from package where pa_outboxcode=v_i_outboxcode and pa_type=1;
  98. // IF(NVL(v_pa_downstatus,0)<>0)THEN
  99. // v_o_errmsg:='箱号:'||v_i_outboxcode||'处于下地状态,不允许操作!';
  100. // RETURN;
  101. // END IF;
  102. //EXCEPTION
  103. //WHEN OTHERS THEN --需要新增箱号
  104. // v_new := -1;
  105. // END;
  106. // ELSE --没有传入箱号,并且也没有勾选自动生成箱号
  107. // IF(NVL(v_i_autonew,'N')='N')THEN
  108. // v_o_errmsg:='无装箱箱号,请输入装箱箱号或者勾选自动生成箱号!';
  109. // RETURN;
  110. // ELSE --生成新箱号
  111. // v_new := -1;
  112. // SP_GETPACKORPALLETCODE('PACKAGE', v_ms_makecode, v_ms_prodcode, v_linecode, v_outboxcode);
  113. //END IF;
  114. //END IF;
  115. // IF(v_i_type= '标准')THEN--标准装箱
  116. // IF(v_new= -1)THEN
  117. // ---页面传了标准容量
  118. // /*IF(v_i_standardqty<=0)THEN
  119. // IF(v_pr_outboxinnerqty>0)THEN
  120. // v_pa_standardqty:=v_pr_outboxinnerqty;
  121. // ELSE
  122. // v_outboxcode:=null;
  123. // v_o_errmsg:='请维护箱标准容量或者维护产品资料中的包装容量!';
  124. // RETURN;
  125. // END IF;
  126. // ELSE
  127. // v_pa_standardqty:=v_i_standardqty;
  128. // END IF;*/
  129. // IF(v_pr_outboxinnerqty>0)THEN
  130. // v_pa_standardqty:=v_pr_outboxinnerqty;
  131. // ELSE
  132. // v_outboxcode:=null;
  133. // v_o_errmsg:='请维护箱标准容量或者维护产品资料中的包装容量!';
  134. // RETURN;
  135. // END IF;
  136. //v_pa_id := package_seq.nextval;
  137. // insert into package(PA_ID, PA_OUTBOXCODE, PA_PRODCODE, PA_LEVEL, PA_PACKAGEQTY, PA_TOTALQTY,
  138. // PA_MAKECODE, PA_STATUS, PA_INDATE, PA_SALECODE, PA_TYPE, PA_CURRENTQTY, PA_PACKTYPE, PA_STANDARDQTY, PA_SCCODE)
  139. // values(v_pa_id, v_outboxcode,case when nvl(v_pr_packrule,' ')<>'MIX' then v_ms_prodcode ELSE''END,3,0,0,case when v_pr_packrule = 'MAKE' THEN v_ms_makecode ELSE '' END,
  140. // 0,SYSDATE,case when v_pr_packrule = 'SALE' then v_ms_salecode else ''end,1,0,v_pr_packrule,v_pa_standardqty,v_i_sourcecode);
  141. // ELSE --无需新增箱号
  142. // --判断箱是否已装满
  143. // IF(v_pa_currentqty= v_pa_standardqty)THEN
  144. // v_o_errmsg:='箱号:'||v_outboxcode||'已经满箱,请输入新箱号或勾选自动生成箱号!';
  145. // RETURN;
  146. // ELSIF(nvl(v_pa_status,0)<>0)THEN
  147. // v_o_errmsg:='箱号:'||v_outboxcode||'已经封箱,请输入新箱号或勾选自动生成箱号!';
  148. // RETURN;
  149. // END IF;
  150. // --判断序列号包装规则与箱内规则一致
  151. // --IF(v_pa_currentqty= 0 or (v_pa_currentqty>0 and v_pr_packrule = v_pa_packtype))THEN
  152. // IF(v_pa_currentqty>0 and v_pr_packrule = v_pa_packtype)THEN
  153. // IF(v_pr_packrule= 'SALE' AND v_ms_salecode<>v_pa_salecode)THEN
  154. // v_o_errmsg:='包装规则为:合同,序列号和卡通箱合同号不一致,不能装入该箱';
  155. // RETURN;
  156. // ELSIF(v_pr_packrule= 'SALE' AND v_ms_prodcode<>v_pa_prodcode)THEN
  157. // v_o_errmsg:='包装规则为:合同,序列号产品编号'||v_ms_prodcode||'和箱的产品编号'||v_pa_prodcode||'不一致,不能装入该箱';
  158. // RETURN;
  159. // ELSIF(v_pr_packrule= 'MAKE' AND v_ms_makecode<>v_pa_makecode)THEN
  160. // v_o_errmsg:='包装规则为:工单,序列号和卡通箱工单号不一致,不能装入该箱';
  161. // RETURN;
  162. // ELSIF(NVL(v_pr_packrule,'PROD')='PROD' AND v_ms_prodcode<>v_pa_prodcode)THEN
  163. // v_o_errmsg:='序列号:'||v_i_sncode||'产品编号和卡通箱产品编号不一致,不能装入该箱';
  164. // RETURN;
  165. // END IF;
  166. // ELSIF(v_pa_currentqty>0 and NVL(v_pr_packrule,' ')<>NVL(v_pa_packtype,' '))THEN
  167. // v_o_errmsg:='序列号:'||v_i_sncode||'对应产品的包装规则与箱号的包装规则不一致,不能装入同一箱';
  168. // RETURN;
  169. // END IF;
  170. //END IF;
  171. //ELSE --特殊装箱
  172. // v_pr_packrule:='SPEC';
  173. // IF(v_new= -1)THEN
  174. // ---页面必须传标准容量
  175. // IF(v_i_standardqty<=0)THEN
  176. // v_outboxcode:=null;
  177. // v_o_errmsg:='请维护箱标准容量!';
  178. // RETURN;
  179. // END IF;
  180. //v_pa_id := package_seq.nextval;
  181. // insert into package(PA_ID, PA_OUTBOXCODE, PA_PRODCODE, PA_LEVEL, PA_PACKAGEQTY, PA_TOTALQTY,
  182. // PA_MAKECODE, PA_STATUS, PA_INDATE, PA_SALECODE, PA_TYPE, PA_CURRENTQTY, PA_PACKTYPE, PA_STANDARDQTY, PA_SCCODE)
  183. // values(v_pa_id, v_outboxcode, v_ms_prodcode,3,0,0,'',0, SYSDATE,'',1,0, v_pr_packrule, v_i_standardqty, v_i_sourcecode);
  184. //ELSE --无需新增箱号
  185. // --判断箱是否已装满
  186. // IF(v_pa_currentqty= v_pa_standardqty)THEN
  187. // v_o_errmsg:='箱号:'||v_outboxcode||'已经满箱,请输入新箱号或勾选自动生成箱号!';
  188. // RETURN;
  189. // -- ELSIF(nvl(v_pa_status,0)<>0)THEN
  190. // -- v_o_errmsg:='箱号:'||v_outboxcode||'已经封箱,请输入新箱号或勾选自动生成箱号!';
  191. // -- RETURN;
  192. // END IF;
  193. //END IF;
  194. //END IF;
  195. // --装明细
  196. // insert into packagedetail(PD_ID, PD_PAID, PD_OUTBOXCODE, PD_INNERQTY, PD_BARCODE, PD_MAKECODE, PD_PRODCODE, PD_BUILDDATE, PD_YMD)
  197. // VALUES(packagedetail_seq.NEXTVAL, v_pa_id, v_outboxcode,1, v_i_sncode, v_ms_makecode, v_ms_prodcode, sysdate, to_char(sysdate,'yyyymmdd'));
  198. // --更新序列号所在箱号
  199. // update makeserial set ms_outboxcode=v_outboxcode,ms_currentstepcode=v_currentstep where ms_id=v_ms_id;
  200. // --更新装箱规则 pa_currentqty = 0
  201. // update package set pa_packtype = v_pr_packrule, PA_SCCODE = v_i_sourcecode, pa_salecode =case when v_pr_packrule = 'SALE' then v_ms_salecode else ''end,pa_makecode=case when v_pr_packrule = 'MAKE' THEN v_ms_makecode ELSE '' END,pa_prodcode=case when v_pr_packrule<>'MIX' then v_ms_prodcode ELSE''END where pa_outboxcode= v_outboxcode and pa_currentqty = 0;
  202. //update package set pa_currentqty = nvl(pa_currentqty, 0) + 1, pa_totalqty = nvl(pa_totalqty, 0) + 1, pa_packageqty = nvl(pa_packageqty, 0) + 1 where pa_outboxcode = v_outboxcode;
  203. // --取消装箱
  204. // ELSIF('OUT'=v_i_inorout)THEN
  205. // IF(NVL(v_ms_outboxcode,' ')=' ')THEN
  206. // v_o_errmsg:='序列号没有装箱,无需取消装箱';
  207. // RETURN;
  208. // END IF;
  209. // --取消装箱必须有箱号v_i_outboxcode
  210. // IF(NVL(v_i_outboxcode,' ')=' ' OR v_i_outboxcode = NULL)then
  211. // v_o_errmsg:='请选择需要取消装箱的箱号';
  212. // RETURN;
  213. // END IF;
  214. // IF(v_i_outboxcode<> v_ms_outboxcode)THEN
  215. // v_o_errmsg:='序列号不在箱号:'||v_i_outboxcode||',无法取消装箱';
  216. // RETURN;
  217. // END IF;
  218. // --箱号未封装,允许取消
  219. // select count(1) into v_count from packagedetail where pd_outboxcode = v_i_outboxcode and pd_barcode = v_i_sncode;
  220. // IF(v_count= 0)THEN
  221. // v_o_errmsg:='序列号不在箱号:'||v_i_outboxcode||',无法取消装箱';
  222. // RETURN;
  223. // END IF;
  224. //select pa_id, pa_prodcode, pa_status, pa_checkno, pa_currentqty, pa_downstatus into v_pa_id, v_pa_prodcode, v_pa_status, v_pa_checkno, v_pa_currentqty, v_pa_downstatus from package where pa_outboxcode = v_i_outboxcode and pa_type = 1;
  225. // IF(NVL(v_pa_downstatus,0)<>0)THEN
  226. // v_o_errmsg:='箱号:'||v_i_outboxcode||'处于下地状态,不允许操作!';
  227. // RETURN;
  228. // END IF;
  229. //delete from packagedetail where pd_outboxcode=v_i_outboxcode and pd_barcode=v_i_sncode;
  230. // --更新序列号所在箱号
  231. // update makeserial set ms_outboxcode='',ms_currentstepcode=null where ms_id = v_ms_id;
  232. // --更新数量,抽检批次号,更新未封箱
  233. // update package set pa_currentqty=pa_currentqty-1,pa_totalqty=pa_totalqty-1,pa_packageqty=pa_packageqty-1,pa_status=0 where pa_outboxcode = v_i_outboxcode;
  234. //update package set pa_packtype = null, pa_sccode = null, pa_checkno = null, pa_salecode = null, pa_makecode = null, pa_prodcode = null where pa_outboxcode = v_i_outboxcode and pa_currentqty = 0;
  235. // IF(nvl(v_pa_checkno,' ')<>' ')THEN
  236. // --未断批直接移除,更新数量
  237. // select MAX(OB_STATUS) INTO v_ob_status from oqcbatch where ob_checkno = v_pa_checkno;
  238. // IF(NVL(v_ob_status,' ')=' ' or v_ob_status = 'ENTERING')THEN
  239. // --更新序列号抽检批次号
  240. // update makeserial set ms_checkno=null where ms_id = v_ms_id;
  241. // --删除oqcbatchdetail
  242. // delete from oqcbatchdetail where obd_checkno = v_pa_checkno and obd_sncode = v_i_sncode;
  243. // --更新OQCBATCH 数量
  244. // update OQCBATCH set ob_nowcheckqty = ob_nowcheckqty - 1 where ob_checkno = v_pa_checkno;
  245. //END IF;
  246. //END IF;
  247. // --如果序列号已有抽检批次号,
  248. // /* IF(nvl(v_pa_checkno,' ')<>' ')THEN
  249. // --未断批直接移除,更新数量
  250. // select MAX(OB_STATUS) INTO v_ob_status from oqcbatch where ob_checkno=v_pa_checkno;
  251. // IF(NVL(v_ob_status,' ')=' ' or v_ob_status='ENTERING')THEN
  252. // --取消装箱
  253. // delete from packagedetail where pd_outboxcode=v_i_outboxcode and pd_barcode=v_i_sncode;
  254. // --更新序列号所在箱号
  255. // update makeserial set ms_outboxcode='',ms_checkno='',ms_currentstepcode=null where ms_id=v_ms_id;
  256. // --更新数量,抽检批次号,更新未封箱
  257. // update package set pa_currentqty=pa_currentqty-1,pa_status=0 where pa_outboxcode=v_i_outboxcode;
  258. // update package set pa_packtype='',pa_checkno='',pa_sccode='' where pa_outboxcode=v_i_outboxcode and pa_currentqty=0;
  259. // --删除oqcbatchdetail
  260. // delete from oqcbatchdetail where obd_checkno=v_pa_checkno and obd_sncode=v_i_sncode;
  261. // --更新OQCBATCH 数量
  262. // update OQCBATCH set ob_nowcheckqty=ob_nowcheckqty-1 where ob_checkno=v_pa_checkno;
  263. // ELSE
  264. // v_o_errmsg:='序列号对应的抽检批次号已经断批.不允许取消装箱';
  265. // RETURN;
  266. // END IF;
  267. // ELSE --无送检批次号
  268. // delete from packagedetail where pd_outboxcode=v_i_outboxcode and pd_barcode=v_i_sncode;
  269. // --更新序列号所在箱号
  270. // update makeserial set ms_outboxcode='',ms_currentstepcode=null where ms_id=v_ms_id;
  271. // --更新数量,抽检批次号,更新未封箱
  272. // update package set pa_currentqty=pa_currentqty-1,pa_status=0 where pa_outboxcode=v_i_outboxcode;
  273. // update package set pa_packtype='',pa_sccode='' where pa_outboxcode=v_i_outboxcode and pa_currentqty=0;
  274. // END IF; */
  275. // --修改完工状态,mcd_inqty
  276. // v_o_outboxcode:=v_i_outboxcode;
  277. // END IF;
  278. //EXCEPTION--统一的异常捕捉
  279. // WHEN OTHERS THEN
  280. // BEGIN
  281. // v_o_errmsg:=SQLERRM;
  282. // ROLLBACK;
  283. // IF SQLCODE<> 0 THEN
  284. // BEGIN
  285. // v_o_errmsg := v_o_errmsg || dbms_utility.format_error_backtrace();
  286. //END;
  287. // END IF;
  288. //END;
  289. // END;