You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
212 lines
11 KiB
XML
212 lines
11 KiB
XML
4 years ago
|
<?xml version="1.0" encoding="UTF-8"?>
|
||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||
|
<mapper namespace="com.foreverwin.mesnac.production.mapper.SfcCrossMapper">
|
||
|
|
||
|
<resultMap id="StepOperationMap" type="com.foreverwin.mesnac.production.model.StepOperation">
|
||
|
<result property="operationBo" column="OPERATION_BO" />
|
||
|
<result property="stepId" column="STEP_ID" />
|
||
|
<result property="sequence" column="SEQUENCE" javaType="java.math.BigDecimal" />
|
||
|
<result property="reportingCenterBo" column="REPORTING_CENTER_BO" />
|
||
|
<result property="operation" column="OPERATION" />
|
||
|
<result property="description" column="DESCRIPTION" />
|
||
|
<result property="resourceBo" column="RESOURCE_BO" />
|
||
|
</resultMap>
|
||
|
|
||
|
<select id="findBindingBarcode" resultMap="com.foreverwin.mesnac.meapi.mapper.SfcMapper.BaseResultMap">
|
||
|
SELECT
|
||
|
SFC.HANDLE,
|
||
|
SFC.SFC,
|
||
|
SFC.SHOP_ORDER_BO,
|
||
|
SFC.STATUS_BO
|
||
|
FROM SFC SFC
|
||
|
JOIN SFC_DATA DT ON DT.SFC_BO = SFC.HANDLE AND DT.DATA_FIELD = #{dataField}
|
||
|
WHERE DT.DATA_ATTR = #{dataAttr}
|
||
|
AND SFC.SITE = #{site}
|
||
|
|
||
|
<if test="statusBoList != null and statusBoList.size() > 0">
|
||
|
AND SFC.STATUS_BO IN
|
||
|
<foreach collection="statusBoList" item="item" index="index" open="(" close=")" separator=",">
|
||
|
#{item}
|
||
|
</foreach>
|
||
|
</if>
|
||
|
|
||
|
ORDER BY DT.DATE_TIME DESC
|
||
|
</select>
|
||
|
|
||
|
<select id="findRouterOperationByRouterBo" resultMap="StepOperationMap">
|
||
|
SELECT
|
||
|
STEP.STEP_ID ,
|
||
|
STEP."SEQUENCE",
|
||
|
STEP.REPORTING_CENTER_BO,
|
||
|
STEP.ERP_OPERATION ,
|
||
|
OP.HANDLE AS OPERATION_BO,
|
||
|
OP.OPERATION ,
|
||
|
OPT.DESCRIPTION
|
||
|
FROM ROUTER R
|
||
|
JOIN ROUTER_STEP STEP ON R.HANDLE = STEP.ROUTER_BO
|
||
|
JOIN ROUTER_OPERATION RO ON STEP.HANDLE = RO.ROUTER_STEP_BO
|
||
|
JOIN OPERATION OP ON 'OperationBO:' || #{site} || ',' || OP.OPERATION || ',#' = RO.OPERATION_BO AND OP.CURRENT_REVISION = 'true'
|
||
|
JOIN OPERATION_T OPT ON OP.HANDLE = OPT.OPERATION_BO AND OPT.LOCALE='zh'
|
||
|
WHERE R.HANDLE = #{routerBo}
|
||
|
AND OP.SITE = #{site}
|
||
|
AND OPT.LOCALE = #{locale}
|
||
|
ORDER BY STEP."SEQUENCE"
|
||
|
</select>
|
||
|
|
||
|
<select id="findRouterLastOperationByRouterBo" resultMap="StepOperationMap">
|
||
|
SELECT
|
||
|
STEP.STEP_ID ,
|
||
|
STEP."SEQUENCE",
|
||
|
RO.OPERATION_BO
|
||
|
FROM ROUTER R
|
||
|
JOIN ROUTER_STEP STEP ON R.HANDLE = STEP.ROUTER_BO
|
||
|
JOIN ROUTER_OPERATION RO ON STEP.HANDLE = RO.ROUTER_STEP_BO
|
||
|
WHERE R.HANDLE = #{routerBo}
|
||
|
ORDER BY STEP."SEQUENCE" DESC
|
||
|
</select>
|
||
|
|
||
|
<select id="findShopOrderListByStatus" resultMap="com.foreverwin.mesnac.meapi.mapper.ShopOrderMapper.BaseResultMap">
|
||
|
SELECT
|
||
|
ORD.HANDLE,
|
||
|
ORD.SHOP_ORDER,
|
||
|
ORD.PLANNED_ITEM_BO,
|
||
|
ORD.ITEM_BO
|
||
|
FROM SHOP_ORDER ORD
|
||
|
JOIN CUSTOM_FIELDS CF ON ORD.HANDLE = CF.HANDLE AND CF.ATTRIBUTE = 'WORK_ORDER_STATUS'
|
||
|
WHERE ORD.PLANNED_WORK_CENTER_BO = #{plannedWorkCenterBo}
|
||
|
AND CF.VALUE = #{status}
|
||
|
</select>
|
||
|
|
||
|
<select id="findOpenStatusSnByShopOrder" resultMap="com.foreverwin.mesnac.meapi.mapper.SfcMapper.BaseResultMap">
|
||
|
SELECT
|
||
|
SFC.SFC,
|
||
|
SFC.QTY ,
|
||
|
SFC.CREATED_DATE_TIME
|
||
|
FROM SFC SFC
|
||
|
WHERE SFC.SHOP_ORDER_BO = #{shopOrderRef}
|
||
|
AND SFC.SITE = #{site}
|
||
|
AND SFC.STATUS_BO IN ('StatusBO:' || #{site} || ',403', 'StatusBO:' || #{site} || ',402')
|
||
|
ORDER BY SFC.CREATED_DATE_TIME DESC
|
||
|
</select>
|
||
|
|
||
|
<select id="findSfcBySn" resultMap="com.foreverwin.mesnac.meapi.mapper.SfcMapper.BaseResultMap">
|
||
|
SELECT
|
||
|
SFC.HANDLE,
|
||
|
SFC.SFC,
|
||
|
SFC.STATUS_BO,
|
||
|
SFC.SHOP_ORDER_BO,
|
||
|
SFC.QTY,
|
||
|
SFC.ITEM_BO
|
||
|
FROM SFC SFC
|
||
|
JOIN SFC_DATA SD ON SFC.HANDLE = SD.SFC_BO AND SD.DATA_FIELD = 'SN'
|
||
|
WHERE SFC.SITE = #{site}
|
||
|
AND SD.DATA_ATTR = #{sn}
|
||
|
AND SFC.STATUS_BO IN ('StatusBO:' || #{site} || ',403', 'StatusBO:' || #{site} || ',402' , 'StatusBO:'|| #{site} || ',401')
|
||
|
ORDER BY SFC.CREATED_DATE_TIME DESC
|
||
|
</select>
|
||
|
|
||
|
|
||
|
<select id="findSfcBySnContainComplete" resultMap="com.foreverwin.mesnac.meapi.mapper.SfcMapper.BaseResultMap">
|
||
|
SELECT
|
||
|
SFC.HANDLE,
|
||
|
SFC.SFC,
|
||
|
SFC.STATUS_BO,
|
||
|
SFC.SHOP_ORDER_BO,
|
||
|
SFC.QTY,
|
||
|
SFC.ITEM_BO
|
||
|
FROM SFC SFC
|
||
|
JOIN SFC_DATA SD ON SFC.HANDLE = SD.SFC_BO AND SD.DATA_FIELD = 'SN'
|
||
|
WHERE SFC.SITE = #{site}
|
||
|
AND SD.DATA_ATTR = #{sn}
|
||
|
AND SFC.STATUS_BO IN ('StatusBO:' || #{site} || ',403', 'StatusBO:' || #{site} || ',402','StatusBO:' || #{site} || ',405')
|
||
|
ORDER BY SFC.CREATED_DATE_TIME DESC
|
||
|
</select>
|
||
|
|
||
|
<select id="getResourceBySfc" resultMap="StepOperationMap">
|
||
|
select siw.RESOURCE_BO
|
||
|
from sfc as sfc
|
||
|
inner join sfc_routing as sri on sfc.handle = sri.sfc_bo
|
||
|
inner join sfc_router as srt on sri.handle = srt.sfc_routing_bo
|
||
|
inner join sfc_step as sep on srt.handle = sep.sfc_router_bo
|
||
|
INNER JOIN SFC_IN_WORK siw ON sep.HANDLE = siw.SFC_STEP_BO
|
||
|
WHERE sfc.site = #{site} and
|
||
|
sfc.SFC = #{sfc}
|
||
|
</select>
|
||
|
<select id="querySfcData" resultType="map">
|
||
|
SELECT SO.SHOP_ORDER, SO_CF.VALUE ITEM_NUMBER, I.ITEM, IT.DESCRIPTION ITEM_DESC,
|
||
|
CASE WHEN ST.STATUS='403' AND SS.QTY_IN_QUEUE > 0 THEN N'402' ELSE ST.STATUS END STATUS,
|
||
|
OP.OPERATION, OT.DESCRIPTION OPERATION_DESC,OP.OPERATION||'/'||RS.STEP_ID OPERATION_STEP,
|
||
|
RO_CF2.VALUE TOOL ,SOD.HANDLE SFC_DISPATCH_DETAIL_BO,
|
||
|
S.SFC,S.QTY SFC_QTY,RS.STEP_ID, SOD.DISPATCH_NO ,
|
||
|
TO_CHAR( SOD.PLANNED_START_DATE + INTERVAL '8' HOUR,'yyyy-mm-dd hh24:mi:ss')START_DATE,
|
||
|
TO_CHAR(SOD.PLANNED_COMPLETE_DATE + INTERVAL '8' HOUR ,'yyyy-mm-dd hh24:mi:ss')COMP_DATE,
|
||
|
TO_CHAR((SOD.PLANNED_COMPLETE_DATE - SOD.PLANNED_START_DATE )*24,'fm9999999990.00')||'H' ADD_DATE,
|
||
|
CASE WHEN OT.DESCRIPTION LIKE 'CH%' THEN SUBSTR(OT.DESCRIPTION, 0, 3) ELSE N'' END SLOT
|
||
|
FROM SFC S
|
||
|
INNER JOIN STATUS ST ON ST.HANDLE = S.STATUS_BO
|
||
|
INNER JOIN SFC_ROUTING SR ON SR.SFC_BO = S.HANDLE
|
||
|
INNER JOIN SFC_ROUTER SRO ON SRO.SFC_ROUTING_BO = SR.HANDLE AND SRO.IN_USE = 'true'
|
||
|
INNER JOIN SFC_STEP SS ON SS.SFC_ROUTER_BO = SRO.HANDLE AND (SS.QTY_IN_QUEUE > 0 OR SS.QTY_IN_WORK > 0)
|
||
|
INNER JOIN ROUTER RO ON SRO.ROUTER_BO = RO.HANDLE
|
||
|
INNER JOIN ROUTER_STEP RS ON RS.ROUTER_BO = RO.HANDLE AND RS.STEP_ID = SS.STEP_ID
|
||
|
INNER JOIN ROUTER_OPERATION ROP ON ROP.HANDLE = RS.ROUTER_COMP_GBO AND SS.OPERATION_BO = ROP.OPERATION_BO
|
||
|
LEFT JOIN CUSTOM_FIELDS RO_CF2 ON RO_CF2.HANDLE = ROP.HANDLE AND RO_CF2."ATTRIBUTE" = 'TOOL_NUMBER'
|
||
|
INNER JOIN OPERATION OP ON 'OperationBO:'||OP.SITE||','||OP.OPERATION||',#' = SS.OPERATION_BO AND OP.CURRENT_REVISION='true'
|
||
|
AND (#{dto.operation} IS NULL OR OP.OPERATION = #{dto.operation})
|
||
|
LEFT JOIN OPERATION_T OT ON OT.OPERATION_BO = OP.HANDLE AND OT.LOCALE =#{locale}
|
||
|
INNER JOIN SHOP_ORDER SO ON SO.HANDLE = S.SHOP_ORDER_BO
|
||
|
LEFT JOIN CUSTOM_FIELDS SO_CF ON SO_CF.HANDLE = SO.HANDLE AND SO_CF."ATTRIBUTE" = 'ITEM_NUMBER'
|
||
|
INNER JOIN ITEM I ON I.HANDLE = S.ITEM_BO
|
||
|
LEFT JOIN ITEM_T IT ON IT.ITEM_BO = I.HANDLE AND IT.LOCALE =#{locale}
|
||
|
INNER JOIN (
|
||
|
SELECT SD.HANDLE, SD.SFC,SD.RESRCE,SD.OPERATION,SD.STEP_ID,SD.PLANNED_COMPLETE_DATE, SD.PLANNED_START_DATE,SD.DISPATCH_NO
|
||
|
FROM Z_PROD_READY_TASK RB
|
||
|
INNER JOIN Z_SFC_DISPATCH SD ON SD.HANDLE = RB.SFC_DISPATCH_BO
|
||
|
WHERE RB.SITE =#{site} AND RB.STATUS = 'F'
|
||
|
) SOD ON SOD.RESRCE =#{dto.resrce} AND SOD.SFC= S.SFC AND SOD.OPERATION = OP.OPERATION
|
||
|
WHERE S.SITE = #{site} AND S.SFC = #{dto.sfc} AND ROWNUM=1
|
||
|
GROUP BY SO.SHOP_ORDER, SO_CF.VALUE , I.ITEM, IT.DESCRIPTION ,
|
||
|
CASE WHEN ST.STATUS='403' AND SS.QTY_IN_QUEUE > 0 THEN N'402' ELSE ST.STATUS END,
|
||
|
OP.OPERATION, OT.DESCRIPTION ,OP.OPERATION||'/'||RS.STEP_ID ,RO_CF2.VALUE,
|
||
|
S.SFC,S.QTY ,RS.STEP_ID,SOD.DISPATCH_NO , SOD.HANDLE ,
|
||
|
TO_CHAR( SOD.PLANNED_START_DATE + INTERVAL '8' HOUR,'yyyy-mm-dd hh24:mi:ss'),
|
||
|
TO_CHAR(SOD.PLANNED_COMPLETE_DATE + INTERVAL '8' HOUR,'yyyy-mm-dd hh24:mi:ss'),
|
||
|
TO_CHAR((SOD.PLANNED_COMPLETE_DATE - SOD.PLANNED_START_DATE )*24,'fm9999999990.00')||'H',
|
||
|
CASE WHEN OT.DESCRIPTION LIKE 'CH%' THEN SUBSTR(OT.DESCRIPTION, 0, 3) ELSE N'' END
|
||
|
</select>
|
||
|
<select id="querySfcStep" resultType="map">
|
||
|
SELECT B1.OPERATION,B1.STEP_ID,B1.DESCRIPTION STEP_DESC,B1.STATE,
|
||
|
B1.HANDLE,B1."SEQUENCE",
|
||
|
CASE WHEN B1."SEQUENCE"=B1.MAXSEQ THEN 'true'
|
||
|
ELSE 'false' END IS_SEQTRUE,B1.LONG_DESCRIPTION,
|
||
|
CASE WHEN B1.STATE ='FINISHED' THEN N'已完工'
|
||
|
WHEN B1."SEQUENCE"=B1.MAXSEQ AND B1.STATE ='READY' AND B1.STATUS ='403' THEN N'加工中'
|
||
|
ELSE N'未加工'
|
||
|
END STEP_STATUS
|
||
|
FROM (
|
||
|
SELECT A1.*,MAX(A1.SELECTSEQ) OVER(PARTITION BY OPERATION) MAXSEQ
|
||
|
FROM (
|
||
|
SELECT O.OPERATION,SST.SUBSTEP STEP_ID,SS.STATE,
|
||
|
NVL(SST.DESCRIPTION,SU.DESCRIPTION) DESCRIPTION,
|
||
|
CASE WHEN SS.STATE ='FINISHED' THEN N'已完工' ELSE N'加工中' END STEP_STATUS,
|
||
|
SS.HANDLE,SS."SEQUENCE",
|
||
|
CASE WHEN SS.STATE='FINISHED' THEN SST."SEQUENCE"+1 ELSE 0 END SELECTSEQ,ST.STATUS,
|
||
|
NVL(SST.LONG_DESCRIPTION,SU.LONG_DESCRIPTION) LONG_DESCRIPTION
|
||
|
FROM SFC_SUBSTEP SS
|
||
|
INNER JOIN SFC_STEP SSTEP ON SS.SFC_STEP_BO=SSTEP.HANDLE AND SSTEP.DONE='false'
|
||
|
AND (SSTEP.QTY_IN_QUEUE > 0 OR SSTEP.QTY_IN_WORK > 0)
|
||
|
INNER JOIN SFC_ROUTER SR ON SR.HANDLE=SSTEP.SFC_ROUTER_BO
|
||
|
INNER JOIN SFC_ROUTING SRI ON SRI.HANDLE=SR.SFC_ROUTING_BO
|
||
|
INNER JOIN ROUTER_SUBSTEP SST ON SS.ROUTER_SUBSTEP_BO = SST.HANDLE
|
||
|
LEFT JOIN SUBSTEP SU ON SU.SUBSTEP = SST.SUBSTEP AND SU.CURRENT_REVISION = 'true' AND SU.SITE = #{site}
|
||
|
INNER JOIN SFC S ON S.HANDLE=SRI.SFC_BO
|
||
|
INNER JOIN STATUS ST ON ST.HANDLE = S.STATUS_BO
|
||
|
INNER JOIN OPERATION O ON O.OPERATION=SPLIT(SSTEP.OPERATION_BO,2) AND O.SITE=S.SITE AND O.CURRENT_REVISION = 'true'
|
||
|
AND #{operation} IS NULL OR #{operation} = O.OPERATION)
|
||
|
WHERE S.SFC=#{sfc} AND S.SITE= #{site} ORDER BY SST."SEQUENCE"
|
||
|
) A1
|
||
|
) B1 ORDER BY B1."SEQUENCE" ASC
|
||
|
|
||
|
</select>
|
||
|
</mapper>
|