出站_完工下線fs
1.打開子應用後光標定位到設備碼文本框,掃設備碼,獲取資源對象resrce對象所有屬性,查詢條件爲RESRCE屬性=掃碼值
名稱 | 類型 | 可爲空 | 默認/表達式 | Generated | On Null | 不可見 | 存儲 | 註釋 |
ID | NUMBER | N |
| Always | N | N |
| 流水碼 |
RESRCE | NVARCHAR2(255) | N |
|
| N | N |
| 資源編碼 |
SITE | NVARCHAR2(255) | Y |
|
| N | N |
| 工廠 |
DESCRIPTION | NVARCHAR2(255) | Y |
|
| N | N |
| 資源描述 |
ENABLED | NUMBER(1) | N | 1 |
| N | N |
| 有效否1:true 0:false |
RESOURCE_TYPE | NVARCHAR2(255) | N |
|
| N | N |
| 資源類型 |
WORK_CENTER | NVARCHAR2(255) | N |
|
| N | N |
| 所屬產線 |
OPERATION | NVARCHAR2(255) | Y |
|
| N | N |
| 工序 |
MUSTHASWO | NUMBER(1) | Y | 0 |
| N | N |
| 上料必先指定工單1:true 0:false |
WCSTORE | NUMBER | Y | 0 |
| N | N |
| 設備在產線上的前後排序 |
ALLOW_SCANNING | NUMBER | Y | 0 |
| N | N |
| 設備是否允許掃碼 |
CURR_ORDER_RESRCE | NVARCHAR2(255) | Y |
|
| N | N |
| 當前生產資源 |
OLD_CONTAINER_FINISH | NUMBER(1) | Y | 0 |
| N | N |
| 原容器出站1:true 0:false |
CONTAINER_FREE_OUTBOUND | 無容器出站 v18 如果=1 則 容器文本框灰色,並且跳過後續所有容器相關的綁定動作 |
2. 若步驟1實體ENABLED =false 則報錯"1028:資源xxx已失效請聯繫it",若ALLOW_SCANNING=false,報錯:" 10031:設備不允許掃碼,請聯繫IT部門註冊設備"
3. 使用第一步獲取的OPERATION屬性到 operation表查詢 描述DESCRIPTION
select operation || ':' || description from imes.operation x where operation = 'YG039' /*替換爲畫面工序*/ 顯示於 畫面
3.1 獲取產線信息
select x.* from work_center x where work_center = '11300101' /*替換爲畫面產線*/
名稱 | 類型 | 可爲空 | 默認 | 註釋 |
WORK_CENTER | NVARCHAR2(255) | N |
| 產線編碼 |
DESCRIPTION | NVARCHAR2(255) | Y |
| 生產線描述 |
SITE | NVARCHAR2(255) | N |
| 工廠 |
ENABLED | NUMBER(1) | N | 1 | 有效否1:true 0:false |
COST_CENTER | NVARCHAR2(255) | N |
| 成本中心 |
LASER_INPUT | NVARCHAR2(255) | Y |
| 輸入端IP |
LASER_OUTPUT | NVARCHAR2(255) | Y |
| 輸出端IP |
INPUT_OR_NOT | NUMBER(1) | Y | 0 | 是否下發 |
PLC_NAME | NVARCHAR2(255) | Y |
| 對應PLC編碼 |
PARMGROUP_CODE | NVARCHAR2(255) | Y |
| 參數組編碼 |
EQUIPMENT_GROUP | NVARCHAR2(255) | Y |
| 設備組名 |
AGING_CONTROL_CABINET | NVARCHAR2(255) | Y |
| 老化控制櫃編號 |
BANZHANG | NVARCHAR2(255) | Y |
| 班長工號 |
WORK_SHOP | NVARCHAR2(255) | N |
| 車間 |
STANDARD_LABOR_TIME | NUMBER(1) | N | 0 | 是否標準工時 |
SAME_ITEM_CHECK | NUMBER(1) | Y | 0 | 相同物料裝框校驗 廢棄 |
RUBBER_CHECK_FLAG | NUMBER(1) | Y | 0 | 是否橡皮章效驗 |
MUST_SO_EXPAND | NUMBER(1) | N | 1 | 須按計劃生產 |
PRINTER_IP | NVARCHAR2(255) | Y |
| 打印機ip |
PRINT_TEMPLATE | NVARCHAR2(255) | Y |
| 打印模板 |
AGV_FLAG | NUMBER(1) | N | 0 | 是否啓用AGV 1-true 0-false |
COEFFICIENT_FLAG | NUMBER(1) | N | 0 | 存在生產係數 1-true 0-false |
QUALITY_AUDIT | NUMBER | Y | 0 | 不良退料是否需質量審覈 |
CARD_READER_SN | NVARCHAR2(255) | Y |
| 讀卡器標識 |
MERGE_LOAD | NUMBER(1) | Y | 1 | 出站混裝 1:相同工單允許 2:不同工單料號相同允許 |
COMPLETE_TOWMS | NUMBER(1) | Y | 1 | 下線入庫 1-true 0-false |
3.2獲取 site 對象
select x.* from imes.site x where site = '1130' /*替換爲當前工廠*/
名稱 | 類型 | 可爲空 | 默認 | 註釋 |
SITE | NVARCHAR2(255) | N |
| 站點 |
DESCRIPTION | NVARCHAR2(255) | Y |
| 描述 |
ENABLED | NUMBER(1) | N | 1 | 有效否1:true 0:false |
COST_CENTER | NVARCHAR2(255) | N |
| 成本中心 |
AGV_FLAG | NUMBER(1) | Y | 0 | 啓用AGV 1:true 0:false |
4.畫面 agv 預設值 = 步驟3.2 獲取的 agv字段
到此步驟無報錯 則 顯示 設備名稱 工序 和工序編碼
5.點工單查詢
V15-1 start
with a as
(select distinct x.shop_order
from imes.shop_order x , routing r
where status = '501' and r.shop_order = x.shop_order
and r.work_center = '11300102' /*替換爲產線*/
and qty_ordered > nvl(qty_done, 0)),
b as
(select distinct shop_order, erp_control_key_group
from item_order_bind_new io
where io.work_center = '11300102' /*替換爲產線*/
and io.erp_control_key_group = 1
and exists (select 1 from a where io.shop_order = a.shop_order)),
t1 as /*非首段工序找工單按在制進站數*/
(select shop_order, erp_control_key_group
from shop_order_manufacture_report t
where exists (select 1
from shop_order s
where s.status = '501'
and s.shop_order = t.shop_order)
and t.work_center = '11300102' /*替換爲產線*/
and erp_control_key_group > 1
v42start and ( IN_OUT = -1 or (IN_OUT = 1 and t. CREATED_DATE_TIME<sysdate-8/1440 ) ) v42end
group by shop_order, erp_control_key_group
having sum(in_out * qty) > 0),
c as
(select r.shop_order
,s.planned_item
,i.description itemdesc
,s.qty_ordered
,s.qty_done
,work_center
,operation
,erp_step
,r.erp_control_key_group
,r.erp_control_key
from (select *
from b
union
select * from t1) b
,routing r
,shop_order s
,item i
where r.shop_order = b.shop_order
and r.erp_control_key_group = b.erp_control_key_group
and r.erp_control_key = 'SP01'
and s.shop_order = r.shop_order
and i.item = s.planned_item
and i.site = r.site)
select * from c where operation = 'YG014' /*替換爲當前工序*/
v15-1 end
v21 start
廢除 v15-1 找工單sql,以下面的替換
with a as
(select distinct x.shop_order
from imes.shop_order x, routing r
where status = '501'
and r.shop_order = x.shop_order
and r.work_center = '11300102' /*替換爲產線*/
),
b as
(select distinct shop_order, erp_control_key_group
from item_order_bind_new io
where io.work_center = '11300102' /*替換爲產線*/
and io.erp_control_key_group = 1
and exists (select 1 from a where io.shop_order = a.shop_order)),
t1 as
(select shop_order, erp_control_key_group
from shop_order_manufacture_report t
where exists (select 1
from shop_order s
where s.status = '501'
and s.shop_order = t.shop_order)
and t.work_center = '11300102' /*替換爲產線*/
and erp_control_key_group > 1
group by shop_order, erp_control_key_group
having sum(in_out * qty) > 0),
t2 as
(select shop_order, 1 erp_control_key_group
from imes.shop_order x
where planned_work_center = '11300601' /*替換爲產線*/
and scanitem = 0
and qty_ordered > nvl(x.qty_done, 0)
and status = '501'),
c as
(select r.shop_order, s.planned_item, i.description itemdesc, s.qty_ordered, s.qty_done, work_center, operation, erp_step, r.erp_control_key_group, r.erp_control_key
from (select *
from b
union
select *
from t1
union
select * from t2) b, routing r, shop_order s, item i
where r.shop_order = b.shop_order
and r.erp_control_key_group = b.erp_control_key_group
and r.erp_control_key = 'SP01'
and s.shop_order = r.shop_order
and i.item = s.planned_item
and i.site = r.site)
select * from c where operation = 'YG014' /*替換爲當前工序*/
v21 end
V40start
V40end
查詢到的數據顯示到 lov ,用戶選擇的時候判斷 當前工序是否= operation 不等於則報錯 "1179所選工單在當前工序不可出站"
如果 一致 則 物料號 描述 顯示於畫面 erp_control_key_group 記錄於畫面變量
V32 start
select item
,lot_num_rule
,work_center
from imes.lot_number_rule x
where item = '1000020772' /*替換爲頭物料*/
and enabled = 1
AND LOT_NUM_RULE = 'B'
只有在 返回行數>0 才執行 v20 start
V32end
V42 備註 最新的找工單SQL 20240122 start
with a as
(select distinct x.shop_order
from shop_order x, routing r
where status = '501'
and r.shop_order = x.shop_order
and r.work_center = '11300105'),
b as
(select distinct shop_order, erp_control_key_group
from item_order_bind_new io
where io.work_center = '11300105'
and io.erp_control_key_group = 1
and exists (select 1 from a where io.shop_order = a.shop_order)),
t1 as
(select shop_order, erp_control_key_group
from shop_order_manufacture_report t
where exists (select 1
from shop_order s
where s.status = '501'
and s.shop_order = t.shop_order)
and t.work_center = '11300105'
v42start and (t.in_out = -1 or (t.in_out = 1 and t.created_date_time < sysdate - 8 / 1440)) v42end
and erp_control_key_group > 1
group by shop_order, erp_control_key_group
having sum(in_out * qty) > 0),
t2 as
(select shop_order, 1 erp_control_key_group
from shop_order x
where planned_work_center = '11300105'
and scanitem = 0
and qty_ordered > nvl(x.qty_done, 0)
and status = '501'),
c as
(select r.shop_order
,s.planned_item
,i.description itemdesc
,s.qty_ordered
,s.qty_done
,work_center
,operation
,erp_step
,r.erp_control_key_group
,r.erp_control_key
from (select *
from b
union
select *
from t1
union
select * from t2) b
,routing r
,shop_order s
,item i
where r.shop_order = b.shop_order
and r.erp_control_key_group = b.erp_control_key_group
and r.erp_control_key = 'SP01'
and s.shop_order = r.shop_order
and i.item = s.planned_item
and i.site = r.site)
select * from c where operation = 'YG027'
V42 備註 最新的找工單SQL 20240122 end
V20 start
選定工單號 執行
select i.scan_check, x.component_gbo
from imes.bom x, shop_order s, item i
where x.shop_order = '232400003910' /*需替換*/
and s.shop_order = x.shop_order
and exists (select 1
from lot_number_rule c
where c.item = s.planned_item
and c.enabled = 1)
and exists (select 1
from lot_number_rule c
where c.item = x.component_gbo v30: and (lot_num_rule = 'A' or lot_num_rule = 'B')
and c.enabled = 1)
and i.item = x.component_gbo
and i.site = x.site
若行數>1 則報錯 1197資料錯誤 ,發現多個需要選批次的料號
若行數=1 則 緩存 v22: component_gbo 到畫面變量 並繼續查詢
如果 scan_check =0 sql:
V25.1 替換後的sql: with a as
(select i.scan_check, x.component_gbo, x.wbs, x.sales_order, x.so_line, r.operation, x.site, r.work_center
from imes.bom x, shop_order s, item i, routing r
where x.shop_order = '232400003910' /*需替換*/
and s.shop_order = x.shop_order
and r.shop_order = x.shop_order
and r.erp_step = x.erp_step
and exists (select 1
from lot_number_rule c
where c.item = s.planned_item
and c.enabled = 1)
and exists (select 1
from lot_number_rule c
where c.item = x.component_gbo v30: and (lot_num_rule = 'A' or lot_num_rule = 'B')
and c.enabled = 1)
and i.item = x.component_gbo
and i.site = x.site),
b as
(select inv.lot_number, inv.qty_on_hand, inv.warehouse, inv.inventory_type, inv.inventory_status, inv.inventory
from inventory inv, a
where inv.site = a.site
and inv.item = a.component_gbo
and inv.lot_number is not null
and inv.qty_on_hand > 0
and inv.enabled = 1
and inv.inventory_status = '102'
and inv.inventory_type = '122'
and nvl(inv.so_num, ' ') = nvl(a.sales_order, ' ')
and nvl(inv.so_line_num, 0) = nvl(a.so_line, 0)
and nvl(inv.wbs_num, ' ') = nvl(a.wbs, ' ')
and inv.warehouse in (select warehouse
from operation_warehouse tt
where tt.work_center = a.work_center
and tt.operation = a.operation))
select lot_number, sum(qty_on_hand) qty from b group by lot_number order by 2
如果 scan_check=1 sql:
V25.2 替換後的sql: with a as
(select i.scan_check, x.component_gbo, x.wbs, x.so_line, x.sales_order
from imes.bom x, shop_order s, item i
where x.shop_order = '232400003910' /*需替換*/
and s.shop_order = x.shop_order
and exists (select 1
from lot_number_rule c
where c.item = s.planned_item
and c.enabled = 1)
and exists (select 1
from lot_number_rule c
where c.item = x.component_gbo v30: and (lot_num_rule = 'A' or lot_num_rule = 'B')
and c.enabled = 1)
and i.item = x.component_gbo
and i.site = x.site),
b as
(select inv.lot_number, inv.qty_on_hand, t.created_date_time bindtime, t.key, t.operation, t.item, t.so_line_num, t.so_num, t.wbs_num, max(key) over(partition by t.operation, t.item, t.so_line_num, t.so_num, t.wbs_num) maxkey
from item_resource_bind_new t, inventory inv, a
where inv.inventory = t.inventory
and inv.site = t.site
and t.item = a.component_gbo
and inv.qty_on_hand > 0
and inv.enabled = 1
and inv.inventory_status = '102'
and inv.inventory_type = '122'
and nvl(t.so_num, ' ') = nvl(a.sales_order, ' ')
and nvl(t.so_line_num, 0) = nvl(a.so_line, 0)
and nvl(t.wbs_num, ' ') = nvl(a.wbs, ' ')
and exists (select 1
from item_order_bind_new tt
where tt.shop_order = '232400003910' /*需替換*/
and tt.bindkey = t.key)
and t.work_center = '11300110' /*需替換*/
)
select lot_number, sum(qty_on_hand) qty from b where maxkey = key group by lot_number
然後彈出數據 批次號 數量 等待用戶選擇
用戶選擇後 記錄於畫面緩存 LOT_NUMBER maxoutQTY
在後面輸入 下線數量的時候 前端判斷 如果輸入數量> maxoutQTY 則報錯 "下線數量>批次可出庫量"
點確定按鈕的時候 需要傳入 LOT_NUMBER 到後端
V20 end
V22start: 選擇工單後
select con.convertion_data
from shop_order x, item i, item_group_pro_convertion con
where shop_order = '232400003210' /*需替換選擇的工單*/
and i.item = x.planned_item
and i.site = x.site
and con.work_center = x.planned_work_center
and con.operation = 'YG005' /*需替換畫面工序*/
and con.item_group = i.category3
顯示於 畫面 係數文本框
點確定按鈕後 發送到後端
V22end
6. 判斷末工序否
6.1查詢最大工序序號
select max(sequence) sequence from routing x where shop_order = '210700607400' /*替換爲所選工單號*/
6.2 查詢本工序的工序序號
select sequence, description, work_center, erp_step, erp_control_key,末工序否
from routing x
where shop_order = '220600556710' /*替換爲工單號*/
and operation = 'YG039' /*替換爲畫面工序*/
and erp_control_key_group = 1 /*替換爲選擇的erp_control_key_group*/
如果本查詢 有多行記錄 則報錯 "1180系統不支持重複工序"
只有一行記錄 則 判斷步驟6.1 SEQUENCE 和步驟6.2 SEQUENCE, 相同則表示爲末工序 , 否則爲 中間工序
本sql查詢的所有字段 緩存於頁面
當判斷爲 末工序時候 則畫面 入庫否 和agv 才顯示 否則 值均設置爲 否 並且隱藏
7.掃描容器碼
容器平臺查詢
http://10.30.35.83:8088/services/containerQueryWebService?wsdl
{
"code":"0",
"data":[
{
"containerCode":"",
"level":0,
"levelSpecified":true,
"loadObjectCode":"WMBI00369",
"loadObjectType":"CONTAINER",
"path":"WMBI00369",
"qty":null
},
{
"containerCode":"WMBI00369",
"level":1,
"levelSpecified":true,
"loadObjectCode":"SPBZ05710",
"loadObjectType":"CONTAINER",
"path":"WMBI00369\SPBZ05710",
"qty":null
},
{
"containerCode":"SPBZ05710",
"level":2,
"levelSpecified":true,
"loadObjectCode":"1000043191103902A2211250022",
"loadObjectType":"MATERIAL_LOT",
"path":"WMBI00369\SPBZ05710\1000043191103902A2211250022",
"qty":"0"
}
],
"message":"SUCCESS",
"status":true,
"statusSpecified":true
}
從返回 集合中 取出 "loadObjectType"="MATERIAL_LOT", 所有的 loadObjectCode ,
查詢每個條碼的信息
select enabled, inventory_status, inventory_type, x.source_shop_order, x.item
from inventory x
where site = '1130' /*替換爲當前工廠*/
and inventory = '100002750110393202110220016113' /*替換爲條碼 loadObjectCode */
如果是末工序 inventory_type<>121 則報錯 1086容器內條碼非下線條碼
如果是中間工序 inventory_type<>123 則報錯 1105容器內條碼非在制條碼
若步驟3.1獲取的混裝參數 MERGE_LOAD =1 並且source_shop_order<>畫面工單號 則報錯 1107不允許不同工單混裝
若步驟3.1獲取的混裝參數 MERGE_LOAD =2 並且 item <> 畫面料號 則報錯" 1083不允許不同物料混裝"
8.輸入 下線數量
9.點確定按鈕 執行9.1-9.x的check
V39 start
SELECT STEEL_SEAL_NUM
FROM SHOP_ORDER x
WHERE SHOP_ORDER = '232800703010'/*需替換*/
and STEEL_SEAL_NUM IS NOT NULL
如果返回行數>0 則 繼續判斷有無鋼板印領用記錄
SELECT count(*) FROM SHOP_ORDER_STEEL x
WHERE SHOP_ORDER = '232200001010'/*需替換*/
如果返回 0 則報錯 1225沒有領用鋼板印記錄,不可下線
檢查有無領用鋼板印
SELECT sos.SHOP_ORDER
FROM SHOP_ORDER_STEEL sos
JOIN SHOP_ORDER so
ON sos.SITE = so.SITE
AND sos.SHOP_ORDER = so.SHOP_ORDER
WHERE sos.SHOP_ORDER = '232300759610' /*需替換*/
AND so.STEEL_SEAL_NUM IS NOT NULL
返回行數0 則報錯 1225沒有領用鋼板印記錄,不可下線
V39 end
V41start
判斷是否包含橡皮印物料
select b.component_gbo 橡皮印料號
from bom b, item t
where b.shop_order = '232300618310' /*需替換*/
and t.category3 = 'O0002'
and t.item = b.component_gbo
and t.site = b.site
AND NOT EXISTS (SELECT 1 FROM ROUTING r WHERE r.shop_order=b.SHOP_ORDER AND r.WORK_CENTER<>'11300101')
如果返回行數>0 則 繼續判斷有無橡皮印投料記錄
select 1
from inventory_transaction inv
where inv.transaction_reason_code = '261' and inv. CREATED_DATE_TIME<sysdate-10/1440
and shop_order = '232300618310' /*需替換*/
and inv.item= 橡皮印料號 /*需替換*/
返回行數0 則報錯 1252 bom有橡皮印物料,無10分鐘前投料記錄,不可下線
V41end
V35start
出站完工下線 點確認 按鈕
select x.container_code
from shop_order_manufacture_report x
where work_center = '11300328' /*需替換爲畫面產線*/
and operation = 'BZ019' /*需替換爲畫面工序*/
and container_code <> 'WMA100044A' /*需替換爲畫面容器*/
and x.created_date_time >= sysdate - 25 /*需替換爲sysset.OUTTIME*/
/ 1440
and in_out = -1
and container_code is not null
返回行數>0 則報錯 1208和上托盤出站間隔小於%s分鐘
V35end
V16-1 start
9.1 如果 畫面 erp_control_key_group >1 則
select sum(in_out * qty)
from shop_order_manufacture_report t
where exists (select 1
from shop_order s
where s.status = '501'
and s.shop_order = t.shop_order)
and t.work_center = '11300102' /*替換爲產線*/
and erp_control_key_group = 2 /*替換爲選擇的erp_control_key_group*/
and t.shop_order = '232400001110' /*替換爲當前工單*/
group by shop_order, erp_control_key_group
如果返回的數據< 畫面下線數量 則報錯 1184 輸入的出站數量過大,剩餘可出站數量%s,
V16-1 end
V43 start 點確定按鈕後
v43.1 執行 班次檢查
最終執行的sql如下:
SELECT count(1) FROM class_record_master m JOIN class_record_line c ON m.id = c.master_id WHERE m.work_center = '11200403' AND c.user_id = '20170311' AND m.end_time IS NULL AND m.start_time > sysdate - 19 / 24
下方會拋異常 1236 外套條件判斷
if site.systemerr=0 then
拋異常 1236
end if
v43.2執行 質檢單處理完畢檢查
實際執行的sql
SELECT TASK_ORDER FROM QM_TASK_MASTER qtm WHERE qtm.TASK_STATUS IN ('560', '561') AND NVL(NVL(qtm.RE_TASK_RESULT, qtm.TASK_RESULT), 0) <> 1 AND qtm.SITE = '1130' AND qtm.SHOP_ORDER = '242100431110' AND EXISTS (SELECT * FROM QM_BASIC_DATA qbd WHERE qbd.SITE = qtm.SITE AND qbd.WORK_CENTER = qtm.WORK_CENTER AND qbd.TASK_TYPE = qtm.TASK_TYPE AND qbd.TEST_POST = qtm.TEST_POST AND qbd.CONTROL = 1)
下方會拋異常 1196 外套條件判斷
if site.systemerr=0 then
拋異常 1196 zh_CN 存在質檢單%s未處理,請到質檢任務平臺對該單據做完成或關閉
end if
v43.3 系統異常情況下 跳過異常 未找到工單232900558310未關閉的FQC,請先生成FQC(1193)
if site.systemerr=0 then
拋異常 1193
end if
v43.4 系統異常情況下 跳過異常 未找到工單232900558310未關閉的FQC,請先生成FQC(1193)
if site.systemerr=0 then
拋異常 1193
end if
v43 end
V17 start
9.2
SELECT COUNT(*) FROM QM_TASK_MASTER qtm
WHERE qtm.TASK_STATUS IN ('560','561')
AND NVL(NVL(qtm.RE_TASK_RESULT,qtm.TASK_RESULT),0) <> 1
AND qtm.SITE = '1130' /*替換爲工廠*/
AND qtm.SHOP_ORDER = '220600411510' /*替換爲下線工單*/
AND EXISTS (SELECT * FROM QM_BASIC_DATA qbd WHERE qbd.SITE = qtm.SITE AND qbd.WORK_CENTER = qtm.WORK_CENTER AND qbd.TASK_TYPE = qtm.TASK_TYPE AND qbd.TEST_POST = qtm.TEST_POST AND qbd.CONTROL = 1)
返回 >0 則報錯 "1196存在質檢單未處理"
V17 end
V26 start
設置警報數量 最大超入數量
V42start
超入規則 抓取1 start
select x.qty_ordered 警報數量, x.qty_ordered * m.proportion 最大超入數量
from shop_order x
join multistep_excess_rules m on m.work_center = x.planned_work_center
and x.qty_ordered between lower_limit and upper_limit
where shop_order = '233200659010' /*需替換爲工單號*/
and m.proportion > 0
and m.enabled = 1
超入規則 抓取1 end
如果 返回0行 則 執行 超入規則抓取 2 (物料 物料組 產線 等超入規則抓取)
返回1 行 則 不執行超入規則抓取 2
V42end
超入規則抓取 2 start
--物料
select warning_qty, max_qty
from imes.multistep_excess_rules x
where material_object_type = 'MATERIAL'
and material_object_code = '1000016875' /*需替換*/
and work_center = '11300101' /*需替換*/
and 5 /*需替換*/
between lower_limit and upper_limit;
如果行數=1 則 警報數量 = warning_qty 最大超入數量 = max_qty 並且不在繼續抓取超量設置
如果行數=0 則 抓取物料組 超入率
--物料組
select warning_qty, max_qty
from imes.multistep_excess_rules x
where work_center = '11300401' /*需替換*/
and material_object_type = 'CATEGORY'
and material_object_code = 'R0037' /*需替換*/
and 5 between lower_limit and upper_limit;
如果行數=1 則 警報數量 = warning_qty 最大超入數量 = max_qty 並且不在繼續抓取超量設置
如果行數=0 則 抓取產線超入率
--產線
select warning_qty, max_qty
from imes.multistep_excess_rules x
where work_center = '11300102' /*需替換*/
and 5 between lower_limit and upper_limit;
如果行數=0 則 警報數量 = 0 最大超入數量 = 0 跳出
如果行數=1 則 警報數量 = warning_qty 最大超入數量 = max_qty 並且不在繼續抓取超量設置
超入規則抓取 2 end
已出站數量 = select sum(qty) qty
From shop_order_manufacture_report x
where shop_order = '232400011410' 需替換
and erp_control_key_group = 1 需替換
and in_out = -1
工單計劃量 = SELECT QTY_ORDERED FROM SHOP_ORDER x WHERE SHOP_ORDER = '220600295800'
如果 警報數量>0 則 檢查
- 已出站數量3000+ 輸入數量10518 >工單量+最大超入數量 則報錯 1198超過允許超入量%s
- 已出站數量+ 輸入數量 >工單量 and 已出站數量+ 輸入數量 < 工單量+警報數量 提示" 1199已超過工單計劃量,小於警報數量,是否繼續入庫?" 選是 繼續往下走 否則退出過程
- 已出站數量1702+ 輸入數量947 >工單量 and 已出站數量1702+ 輸入數量927 > 工單量1648+警報數量50 and 已出站數量1702+ 輸入數量947 > 工單量1608+最大超入數量1000
提示" 1200已超過工單計劃量,大於警報數量,是否繼續入庫?" 選是 繼續往下走 否則退出過程
V26end
10. 非末工序 則 生成在制條碼. 在制條碼生成規則
select nvl(max(to_number(regexp_substr(inventory_bo, '[^-]+', 1, 4))), 0) + 1
from imes.shop_order_manufacture_report x
where in_out = '-1'
and shop_order = '220600554510'
and erp_control_key_group = 1
最終 在制條碼格式爲 220600554510-1/3-YG039-0001
220600554510 當前工單號
1 是 erp_control_key_group
3 是 select max(erp_control_key_group) from routing r where shop_order = '220600554510'
YG039 提取 select operation
from routing r
where shop_order = '220600554510'
and sequence = (select max(sequence)
from routing r
where shop_order = '220600554510'
and erp_control_key_group = 1)
0001 最上語句生成 拼接爲4位長度
V16-2 start
末工序 則生成完工條碼 規則 執行 語句
/*下線條碼生成*/
select max(substr('0000' || to_char(to_number(regexp_substr(inventory_bo, '[^-]+', 1, 2)) + 1), -4))
from shop_order_manufacture_report
where inv_type = 'F'
and shop_order = '222700094510' /*替換爲工單號*/
如果返回行數0 則 條碼編號= '220600556710-0001'
如果返回行數>0 則條碼編號 = inventory_bo
V16-2 end
v37 出站卡配方 start
不管末工序還是 中間工序 均執行以下check
select sum(request_formula) request_formula
from wc_operation_section x, routing x1, routing x2
where x2.shop_order = '232700000910' /*需替換*/
and x2.operation = 'ZP009' /*需替換*/
and x2.shop_order = x1.shop_order
and x1.erp_control_key_group = x2.erp_control_key_group
and x1.work_center = x.work_center and x1.operation = x.operation
如果返回0 則 跳出邏輯
如果返回>0 則 繼續執行check
SELECT count(*) 配方單個數 FROM SHOP_ORDER_SLURRY x
WHERE SHOP_ORDER = '232700000910'/*需替換*/
如果 配方單個數=0 則報錯 "1223系統配置工單出站需要配方單,實際沒有做關聯"
否則 繼續執行流程
v37 出站卡配方 end
11.寫條碼錶-在制 inventory
如果上述語句返回行數>0 則 新在制條碼= 220600554510-1/3-YG039-0001 下線條碼 220600554510-0001
名稱 | 類型 | 可空 | 默認/表達式 | 註釋 |
|
SITE | NVARCHAR2(255) | N |
| 工廠 | 步驟1取得的工廠 |
INVENTORY | NVARCHAR2(255) | N |
| 條碼 | 步驟10的條碼 |
ITEM | NVARCHAR2(255) | N |
| 物料 | 畫面物料號 |
WAREHOUSE | NVARCHAR2(255) | N |
| 線邊倉 | 查詢工序線邊倉 select warehouse from imes.operation_warehouse x where work_center = '11300102' /*替換爲當前產線*/ and operation = 'YG014' /*替換爲當前工序*/ and out_warehouse = 1 如果返回行數=0 則報錯 1101沒有設定工序默認出站線邊倉 |
INVENTORY_TYPE | NVARCHAR2(255) | N |
| 庫存類型 | V16-3 末工序 121 非末工序123 在製品 |
INVENTORY_STATUS | NVARCHAR2(255) | N |
| 庫存狀態 | V16:非末工序 102 可用 末工序 畫面入庫申請=true 104 入庫中 末工序 畫面入庫申請=fasle 102 可用 |
QTY_ON_HAND | NUMBER(38,6) | N |
| 現有量 | 界面下線數量 |
ACTUAL_RECEIVE_TIME | DATE | Y |
| 接收時間 | 當前時間 |
CONTAINER_CODE | NVARCHAR2(255) | Y |
| 容器條碼 | 界面容器 |
LOT_NUMBER | NVARCHAR2(255) | Y |
| 條碼批次 | 步驟99生成的批次規則 |
MRB_NUM | NVARCHAR2(255) | Y |
| MRB編號 | NULL |
SO_LINE_NUM | NUMBER | Y |
| 銷售訂單行號 | V27 寫入 SHOP_ORDER. SO_LINE |
SO_NUM | NVARCHAR2(255) | Y |
| 銷售訂單號 | V27 寫入 SHOP_ORDER.SALES_ORDER |
SWR_NUM | NVARCHAR2(255) | Y |
| SWR編號 | NULL步驟15.1獲取的值 |
WBS_NUM | NVARCHAR2(255) | Y |
| WBS編號 | V27 寫入 SHOP_ORDER. WBS |
AVAILABLE_TAG | NVARCHAR2(255) | Y |
| 免校驗掃碼倒扣標記(暫取消) |
|
COEFFICIENT | NVARCHAR2(255) | Y |
| 基板係數 | NULL |
PRE_WORK1 | NVARCHAR2(255) | Y |
| 前加工完成標識 | NULL |
PRE_WORK2 | NVARCHAR2(255) | Y |
| 前加工物料標識 | NULL |
QM_MATERIAL_DEFECT | NVARCHAR2(255) | Y |
| 不合格原材料缺陷代碼(廢棄) | NULL |
QM_PRODUCT_DEFECT | NVARCHAR2(255) | Y |
| 不合格成品缺陷代碼(廢棄) | NULL |
QM_MATERIAL_DEFECT_DESC | NVARCHAR2(255) | Y |
| 缺陷代碼描述(廢棄) | NULL |
QM_DESCRIPTION | NVARCHAR2(255) | Y |
| 質量備註(廢棄) | NULL |
SLO_CHECK_SIGN | NVARCHAR2(255) | Y |
| 銷售訂單行校驗標識(暫取消) | NULL |
FQC_TASK_ORDER | NVARCHAR2(255) | Y |
| FQC任務單號 | NULL |
SHOP_ORDER | NVARCHAR2(555) | Y |
| 工單號 | 畫面工單號 |
SUPPLIER | NVARCHAR2(255) | Y |
| 質量判定責任供應商編碼(廢棄) | NULL |
SUPPLIER_DESC | NVARCHAR2(255) | Y |
| 質量判定責任供應商描述(廢棄) | NULL |
ORIGINAL_QTY | NUMBER | N |
| 發料數量 | NULL |
ORIGINAL_INVENTORY | NVARCHAR2(255) | Y |
| 原始條碼 | NULL |
QM_AUDITOR | NVARCHAR2(255) | Y |
| 不良退料審覈人(廢棄) | NULL |
CREATED_DATE_TIME | DATE | N | sysdate | 創建時間 |
|
CREATED_USER | NVARCHAR2(255) | Y |
| 創建人 |
|
ENABLED | NUMBER | N | 0 | 條碼可用狀態 | 0 |
SWR_MESSAGE | NVARCHAR2(1000) | Y |
| SWR備註信息 | NULL |
MRB_MESSAGE | NVARCHAR2(1000) | Y |
| MRB備註信息 | NULL |
12工單出站記錄 寫報工接口表 shop_order_manufacture_report
名稱 | 類型 | 可空 | 默認 | 註釋 |
|
SITE | NVARCHAR2(255) | N |
| 工廠 | 步驟1 工廠 |
RESOURCE_BO | NVARCHAR2(255) | N |
| 資源 | 畫面資源 |
OPERATION | NVARCHAR2(255) | N |
| 工序 | 步驟5 獲取的 頁面變量 工序 |
WORK_CENTER | NVARCHAR2(255) | N |
| 所屬產線 | 步驟1帶出的產線 |
WAREHOUSE | NVARCHAR2(255) | N |
| 線邊倉 | 獲取出站線邊倉 V5:select warehouse from imes.operation_warehouse x where work_center = '11300102' /*替換爲當前產線*/ and operation = 'YG014' /*替換爲當前工序*/ and out_warehouse = 1 如果返回行數=0 則報錯 1101沒有設定工序默認出站線邊倉 |
CONTAINER_CODE | NVARCHAR2(255) | N |
| 容器 | 畫面容器 |
INV_TYPE | NVARCHAR2(255) | N |
| 條碼類型F完工W在制 | V16-4 末工序 F 非末工序W |
IN_OUT | NVARCHAR2(255) | Y |
| 進/出站 1:進站 -1:出站 | -1 |
SHOP_ORDER | NVARCHAR2(255) | N |
| 工單號 | 畫面工單號 |
INVENTORY_BO | NVARCHAR2(255) | N |
| 庫存條碼BO/在制條碼 | 步驟10生成的條碼 |
QTY | NUMBER(38,6) | N |
| 進站/出站數量 | 畫面出站數量 |
PSD_LOCATION | NVARCHAR2(255) | Y |
| 配送點 |
|
CARGO_LOCATION | NVARCHAR2(255) | Y |
| 托盤位 |
|
CREATED_DATE_TIME | DATE | N | sysdate | 創建時間 |
|
CREATED_USER | NVARCHAR2(255) | Y |
| 創建人 |
|
TEAM | NVARCHAR2(36) | N |
| 生產班組 | 暫寫入 "測試班組" |
DATA_FROM | NVARCHAR2(255) | Y |
| 寫入程序類名稱 |
|
START_TIME | DATE | Y |
| 開始時間 |
|
FINISH_TIME | DATE | Y |
| 下線時間 | 當前時間 |
ERP_STEP | NVARCHAR2(255) | Y |
| ERP工序ID | 步驟5獲取的 頁面變量 ERP_STEP |
ERP_CONTROL_KEY_GROUP | NUMBER | Y |
| ERP報工工段組序號 | 步驟5 獲取的 頁面變量 ERP_CONTROL_KEY_GROUP |
13.1 v16 -5 如果非末工序 或者末工序 但是畫面 生成入庫=false 則 對 條碼和容器 調用 容器平臺進行綁定
http://10.30.35.155:8088/services/containerIfaceService?wsdl
對象類型:①EO 在制 非工序 v16
②CONTAINER 容器
③MATERIAL_LOT 條碼 末工序 v16
V19 start
如果是末工序 新增寫表 INVENTORY_TRANSACTION
SITE | NVARCHAR2(255) | N | 站點 | 當前工廠 |
TRANSACTION_REASON_CODE | NVARCHAR2(255) | N | 事務代碼 | 101 |
TRANSACTION_TYPE | NVARCHAR2(255) | N | 業務類型 | PRO_WAREHOUSING |
ACCOUNT_DATE | DATE | N | 記賬日期 | sysdate |
SHOP_ORDER | NVARCHAR2(255) | Y | 工單號 | 畫面工單 |
WORK_CENTER | NVARCHAR2(255) | Y | 產線 | 畫面產線 |
WAREHOUSE | NVARCHAR2(255) | N | 倉庫 | inventory.WAREHOUSE |
INVENTORY | NVARCHAR2(255) | Y | 關聯的條碼 | inventory.inventory |
ITEM | NVARCHAR2(255) | N | 物料編碼 | inventory.ITEM |
QTY | NUMBER(38,6) | N | 數量 | INVENTORY.QTY_ON_HAND |
UNIT | NVARCHAR2(255) | N | 單位 | ITEM.UNIT |
CLASS_RECORD_MASTER_ID | NUMBER(38) | Y | 班次主表ID |
|
DATA_FROM | NVARCHAR2(255) | Y | 數據來源 |
|
DATA_FROM_ID | NUMBER(38) | Y | 數據來源的ID |
|
LQJ_LOT | NVARCHAR2(255) | Y | 漏氣撿松下批次號 | SELECT LQJTS FROM IMES.ITEM x WHERE ITEM = '1000133121' AND (LQJTS is not NULL ) 非空 則 生成 如下格式232300765510-1000081548-2122881-20230426 工單號-物料號-LOT_NUMBER-日期 |
CREATED_USER | NVARCHAR2(255) | N | 創建人 |
|
LOT_NUMBER | NVARCHAR2(255) | Y | 本批批次 | INVENTORY.LOT_NUMBER |
V31: | ||||
SO_NUM | Shop_order. SALES_ORDER | |||
SO_LINE | Shop_order.SO_LINE | |||
WBS_NUM | Shop_order. WBS |
V19 end
V16-6 start
13.2.1 如果末工序並且 畫面入庫申請=true 則 先寫me入庫表 並且 調用wms 接口生成入庫單
插表 INSTRUCTION_MASTER
SITE | NVARCHAR2(255) | N |
| 站點 | 當前工廠 |
WORK_CENTER | NVARCHAR2(255) | N |
| 產線編碼 | 當前產線 |
INSTRUCTION_NUM | NVARCHAR2(255) | N |
| 單據號 | 暫時使用 20230228-0001 這種 年月日四位流水碼 |
INSTRUCTION_STATUS | NVARCHAR2(255) | N |
| 單據狀態 | ME.Z.INSTRUCTION_STATUS 410新建 |
SHOP_ORDER | NVARCHAR2(2000) | Y |
| 工單號 | 畫面工單號 |
INSTRUCTION_TYPE | NVARCHAR2(255) | N |
| 單據類型(送、領、退料單) | ME.Z.INSTRUCTION_TYPE 304 入庫單 |
INSTRUCTION_FORM | NUMBER(38) | N | 0 | 單據類別(正常或不合格單) 0:正常/1:不合格 | 0 |
TO_WMS | NUMBER(1) | Y |
| 傳輸WMS | 1 |
CREATED_USER | NVARCHAR2(255) | Y |
| 創建人 |
|
DATA_FROM | NVARCHAR2(255) | Y |
| 寫入程序類名稱 |
|
AGV_FLAG | NUMBER | N | 0 | 是否AGV運送 |
|
插表INSTRUCTION_LINE
SITE | NVARCHAR2(255) | N |
|
| 工廠 | 當前工廠 |
INSTRUCTION_NUM | NVARCHAR2(255) | N |
|
| 單據號 | 暫時使用 20230228-0001 這種 年月日四位流水碼 |
SEQUENCE | NVARCHAR2(255) | N |
|
| 序號 | 序號 |
INVENTORY | NVARCHAR2(255) | N |
|
| 條碼 | 12.2生成的條碼 |
ITEM | NVARCHAR2(255) | Y |
|
| 物料號 | 畫面物料號 |
ORIGINAL_QTY | NUMBER | N |
|
| 發料數量 | 畫面下線數量 |
ACTUAL_QTY | NUMBER(38) | N | 0 |
| 實際數量 | 畫面下線數量 |
JOIN_OUT_FLAG | NUMBER(38) | N | 1 |
| 進出標識(-1 出庫 1 入庫 0調撥) | -1 |
TOP_CONTAINER | NVARCHAR2(255) | Y |
|
| 頂層容器 | 畫面容器 |
WAREHOUSE | NVARCHAR2(255) | N |
|
| 線邊倉 | V5:select warehouse from imes.operation_warehouse x where work_center = '11300102' /*替換爲當前產線*/ and operation = 'YG014' /*替換爲當前工序*/ and out_warehouse = 1 如果返回行數=0 則報錯 1101沒有設定工序默認出站線邊倉 |
LOT_NUMBER | NVARCHAR2(255) | Y |
|
| 批次號 | 步驟13.2獲取的值 |
SHOP_ORDER_INV | NVARCHAR2(255) | Y |
|
| 指定工單 |
|
CREATED_USER | NVARCHAR2(255) | Y |
|
| 創建人 |
|
DATA_FROM | NVARCHAR2(255) | Y |
|
| 寫入程序類名稱 |
|
UPPER_CONTAINER | NVARCHAR2(255) | Y |
|
| 上層容器 | 畫面容器 |
13.2.2調用 入庫單接口推送到wms:
http://10.30.35.83:8088/services/productApplicationWebService?wsdl
(有單據頭有條碼明細,則是正常提交單據和生成條碼;沒有單據頭只有條碼明細,則只生成條碼)
V31:新增傳遞 INVENTORY. SO_LINE_NUM SO_NUM WBS_NUM .3個 字段 到wms
13.2.3 更新工單完工數量Update SHOP_ORDER x set x. QTY_DONE=nvl(QTY_DONE,0)+下線數量 WHERE SHOP_ORDER = '220600295800'
V16-6 end
V28start 末工序執行
select QTY_ORDERED
from item_group x, item i, shop_order s
where auto_close_order = '1'
and i.category3 = x.item_group
and item = s.planned_item
and i.site = s.site
and s.shop_order = '220600473910' 需替換
如果返回0行 則啥也不做
返回1 行 則 查詢工單已出站數= select sum(qty) from SHOP_ORDER_MANUFACTURE_REPORT where SHOP_ORDER = '232400002110' 需替換AND IN_OUT = -1 and ERP_CONTROL_KEY_GROUP=2 需替換
工單已出站數>= 工單計劃量 則 更新 Update SHOP_ORDER x set STATUS='503' WHERE SHOP_ORDER = '220600295800'
還需要發送 狀態到nps
測試環境:http://poqas01.super.local:50000/dir/wsdl?p=ic/27b2e2f813cd366b99e2ba82a9c2d3df
入參 工單號 , F
生產環境:http://poprd01.super.local:50000/dir/wsdl?p=ic/cdd2577b44c33d94beb6081fb28efc32
V28end
V29start
select template_describe, template_file_name, printer_name, DEFAULT_PRINTER from print_template_info x where work_center = '11300102'
返回行數>0 則 確定按鈕 變成 確定並打印
返回行數>1 則判斷 DEFAULT_PRINTER 是否=1 直接選擇DEFAULT_PRINTER=1的這一行的template_file_name
如果都設置 DEFAULT_PRINTER=0 DEFAULT_PRINTER=1 則 彈出lov 用戶選擇後 填充下面的打印服務的入庫參數
點確定並打印 則 調用接口打印
http://10.30.35.116:8080/imes-print/v1/12/inventory-print/print
報文
[
{
"inventory": "222700098410-0006", 條碼號
"container": "MELED2091", 容器
"site": "1130", 工廠
"printType":"glassTag"
}
]
V29end
14 本批批次生成
15.1 SWR_NUM 生成 null
15.2 wbs生成 默認 null
16.
V16-7 99. 本批批次規則 此處細節步驟從0開始編號
0.批次變量默認=20230301 4位年 2位月 2位日
1.獲取本批批次 規則
select item
,lot_num_rule
,work_center
from imes.lot_number_rule x
where item = '1000020772' /*替換爲頭物料*/
and enabled = 1
返回行數0 則 返回默認批次變量
2.獲取到行數=1 則 判斷lot_num_rule值
2.1 A : 批次變量= 年最後一位 + 兩位月 + 兩位日期 + 產線編號 + 工單的規格順序
產線編號 從值集 ME.Z.LOT_NUM_PRODLINE 過濾後取值 查詢條件爲 當前產線
工單的規則順序 數據提取
with a as
(select id
,created_date_time
,item
,lead(item) over(order by created_date_time) n
,lag(item) over(order by created_date_time) p
from imes.shop_order_manufacture_report x
where inv_type = 'F'
and created_date_time >= trunc(sysdate) /* - 30*/
and in_out = -1
v34: and exists (SELECT 1 FROM IMES.LOT_NUMBER_RULE lot WHERE lot.LOT_NUM_RULE = 'A' and lot.ITEM = x.item)
and work_center = '11300201' /*替換爲當前產線*/
order by created_date_time),
b as
(select id
,created_date_time
,item
from a
where p <> item
or p is null
or n = null)
select b.*
,row_number() over(order by created_date_time) 切換順序
from b
返回行數0 則 設置值=1
返回行數>0 取最後一行 的 item 和當前下線料號比較,一致則 設置值=切換順序
返回行數>0 取最後一行 的 item 和當前下線料號比較,不一致則 設置值=切換順序+1
循環返回的記錄集 對比 item和當前物料 首個一致的 行 切換順序作爲 設置值
如果沒有找到相同的記錄設置值=最大切換順序+1
V34: 如果生成的批次超過9 如10則 又從1 開始
2.2 B: 後續提供 按默認值返回
with a as
(select i.scan_check, x.component_gbo, x.wbs, x.so_line, x.sales_order, s.planned_work_center work_center
from bom x, shop_order s, item i
where x.shop_order = '232900113410'
and s.shop_order = x.shop_order
and exists (select 1
from lot_number_rule c
where c.item = s.planned_item
and c.enabled = 1)
and exists (select 1
from lot_number_rule c
where c.item = x.component_gbo
and (lot_num_rule = 'A' or lot_num_rule = 'B')
and c.enabled = 1)
and i.item = x.component_gbo
and i.site = x.site),
b as
(select t.inventory
,inv.lot_number
,inv.qty_on_hand
,t.created_date_time bindtime
,t.key
,t.operation
,t.item
,t.so_line_num
,t.so_num
,t.wbs_num
,max(key) over(partition by t.operation, t.item, t.so_line_num, t.so_num, t.wbs_num) maxkey
from item_resource_bind_new t, inventory inv, a
where inv.inventory = t.inventory
and inv.site = t.site
and t.item = a.component_gbo
and inv.qty_on_hand > 0
and inv.enabled = 1
and inv.inventory_status = '102'
and inv.inventory_type = '122'
and nvl(t.so_num, ' ') = nvl(a.sales_order, ' ')
and nvl(t.so_line_num, 0) = nvl(a.so_line, 0)
and nvl(t.wbs_num, ' ') = nvl(a.wbs, ' ')
and exists (select 1
from item_order_bind_new tt
where tt.work_center = a.work_center
and tt.bindkey = t.key)
and t.work_center = '11300112')
select lot_number, sum(qty_on_hand) maxoutqty from b where maxkey = key group by lot_number
V23-1 start: 繼承 畫面選擇的 批次號
V23-1 end
V36start
針對c和d類 加入如下規則
SELECT x.*
FROM IMES.LOT_NUMBER_RULE x
WHERE ITEM = '1000106531'
AND (LOT_NUM_RULE = 'C' or LOT_NUM_RULE = 'D')
返回行數>0 則 不執行 2.3 2.4的批次生成規則
出站批次號 灰色 只讀 後面帶個編輯按鈕 點按鈕 彈出對話框 對話框確定點擊後 對話框 的內容(可空白 直接點確定) 去掉收尾空格 寫入 出站批次號文本框
點確定後 輸入的批次號 則替代 2.3 /2.4 生成的結果
V36end
2.3 C: 批次變量= 年最後一位 + 兩位月 + 兩位日期 + 產線編號 + 工單的規格順序
產線編號 從1 中取到的 work_center
工單的規則順序 數據提取
with a as
(select id
,created_date_time
,item
,lead(item) over(order by created_date_time) n
,lag(item) over(order by created_date_time) p
from imes.shop_order_manufacture_report x
where inv_type = 'F'
and created_date_time >= trunc(sysdate) /* - 30*/
and in_out = -1
and work_center = '11300201' /*替換爲當前產線*/
v33: and exists (SELECT 1 FROM IMES.LOT_NUMBER_RULE lot WHERE lot.LOT_NUM_RULE = 'C' and lot.ITEM = x.item)
order by created_date_time),
b as
(select id
,created_date_time
,item
from a
where p <> item
or p is null
or n = null)
select b.*
,row_number() over(order by created_date_time) 切換順序
from b
返回行數0 則 設置值=1
返回行數>0 取最後一行 的 item 和當前下線料號比較,一致則 設置值=切換順序
返回行數>0 取最後一行 的 item 和當前下線料號比較,不一致則 設置值=切換順序+1
循環返回的記錄集 對比 item和當前物料 首個一致的 行sn 作爲 設置值
如果沒有找到相同的記錄設置值=最大sn +1
2.4 D: 批次變量= 年後2位 + 2位月 + 2位日
2.5 E: 批次變量= 年4位 + 2位月 + 2位日 + 白夜班 (1白班 2夜班) + GU9(固定字符)
SELECT CLASSES FROM IMES.CLASS_RECORD_MASTER x WHERE WORK_CENTER = '11300424' and END_TIME is NULL
CLASSES = A : 白夜班 =1 ;
CLASSES = C : 白夜班=2
2.6 F: 批次變量= 前綴 + 流水碼
前綴規則: 按頭物料
1000017773:批次SP-981-68-000
1000017772:批次SP-981-128-000
1000017775:批次SP-981-128-山蒲/Φ2.0-000
1000017774:批次1322-500-37504-PHILIPS/Φ2.0-000
流水碼 : 基準數字 + 工單開工次序
基準數字 維護在 Z_LOT_NUMBER_ASSY_DATA表
工單開工次序:
with a as
(select shop_order, min(created_date_time) mincreated_date_time
from imes.shop_order_manufacture_report x
where item = '1000101731' /*替換爲頭物料*/
group by shop_order)
select a.*, row_number() over(order by mincreated_date_time) sn from a
返回行數0 則 開工次序=1
返回行數>0 則過濾返回記錄集 x=>x.shop_order==畫面工單 得到行數 =1 則開工次序=sn
的到行數=0 則開工次序=max(sn)+1
2.7 G: 批次變量=產線編號 +年4位 + 2位月 + 白夜班 (白班=日期*2-1 夜班=日期*2)
產線編號 : 從值集 ME.Z.LOT_NUM_PRODLINE 過濾後取值 查詢條件爲 當前產線
白夜班: eg: 4月1日 1*2-1 前面補0 變爲2位 01 (白班默認值)
4/1夜班=1*2 面補0 變爲2位 02
4月8日 8*2-1 前面補0 變爲2位 15 (白班默認值)
4/8夜班=8*2 面補0 變爲2位 16
時間在 當日 8:00前 屬於 前一天夜班 8點後屬於本日白班 , 4/1 9:00 白夜班=01 4/8 7:00白夜班=14