잔량 거래명세서데이터베이스저장완료 출하일눌렀을대 보임
This commit is contained in:
@@ -1510,6 +1510,9 @@ ORDER BY T.REGDATE DESC, T.PROJECT_NO DESC
|
||||
COALESCE(SR.incoterms, '') AS INCOTERMS
|
||||
FROM PROJECT_MGMT AS T
|
||||
LEFT JOIN sales_registration SR ON T.PROJECT_NO = SR.project_no
|
||||
<if test="saleNo != null and saleNo != ''">
|
||||
AND SR.sale_no = #{saleNo}
|
||||
</if>
|
||||
LEFT JOIN CONTRACT_MGMT CM ON CM.OBJID::VARCHAR = T.CONTRACT_OBJID
|
||||
WHERE T.PROJECT_NO = #{orderNo}
|
||||
</select>
|
||||
@@ -1727,35 +1730,12 @@ ORDER BY T.REGDATE DESC, T.PROJECT_NO DESC
|
||||
</choose>
|
||||
#{shippingMethod}, #{salesUnitPrice}::numeric, #{salesSupplyPrice}::numeric,
|
||||
#{salesVat}::numeric, #{salesTotalAmount}::numeric, #{salesCurrency},
|
||||
#{salesExchangeRate}::numeric, #{manager}, #{incoterms}, #{serialNo},
|
||||
#{salesExchangeRate}::numeric, #{managerUserId}, #{incoterms}, #{serialNo},
|
||||
#{parentSaleNo}::integer, #{cretEmpNo}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- PROJECT_MGMT의 OBJID 조회 (shipment_log의 target_objid로 사용) -->
|
||||
<select id="getProjectObjid" parameterType="map" resultType="map">
|
||||
/* salesNcollectMgmt.getProjectObjid - PROJECT_MGMT의 OBJID 조회 */
|
||||
SELECT OBJID FROM PROJECT_MGMT WHERE PROJECT_NO = #{orderNo}
|
||||
</select>
|
||||
|
||||
<!-- 출하일 상세 내역 조회 (shipment_log에서 조회) -->
|
||||
<select id="getShippingDetailList" parameterType="map" resultType="map">
|
||||
/* salesNcollectMgmt.getShippingDetailList - shipment_log에서 모든 분할 출하 조회 */
|
||||
SELECT
|
||||
COALESCE(TO_CHAR(SL.shipping_date, 'YYYY-MM-DD'), '미등록') AS shipping_date,
|
||||
COALESCE(SL.split_quantity, 0) AS shipping_quantity,
|
||||
COALESCE(SL.shipping_status, '미등록') AS shipping_order_status,
|
||||
COALESCE(SL.serial_no, '-') AS serial_no,
|
||||
SL.target_objid AS project_no,
|
||||
'분할 출하 ' || SL.log_id AS source,
|
||||
TO_CHAR(SL.reg_date, 'YYYY-MM-DD HH24:MI:SS') AS reg_date
|
||||
FROM shipment_log SL
|
||||
WHERE SL.target_objid = #{projectNo}
|
||||
|
||||
ORDER BY SL.shipping_date DESC, SL.log_id DESC
|
||||
</select>
|
||||
|
||||
<!-- sales_registration의 sales_quantity를 shipment_log 합계로 업데이트 -->
|
||||
<!-- sales_registration의 수량을 shipment_log 합계로 업데이트 -->
|
||||
<update id="updateSalesQuantityFromShipmentLog" parameterType="map">
|
||||
/* salesNcollectMgmt.updateSalesQuantityFromShipmentLog - shipment_log 합계로 sales_quantity 업데이트 */
|
||||
UPDATE sales_registration
|
||||
@@ -1782,6 +1762,28 @@ ORDER BY T.REGDATE DESC, T.PROJECT_NO DESC
|
||||
WHERE sale_no = #{saleNo}
|
||||
</update>
|
||||
|
||||
<!-- PROJECT_MGMT의 OBJID 조회 (shipment_log의 target_objid로 사용) -->
|
||||
<select id="getProjectObjid" parameterType="map" resultType="map">
|
||||
/* salesNcollectMgmt.getProjectObjid - PROJECT_MGMT의 OBJID 조회 */
|
||||
SELECT OBJID FROM PROJECT_MGMT WHERE PROJECT_NO = #{orderNo}
|
||||
</select>
|
||||
|
||||
<!-- 출하일 상세 내역 조회 (모든 분할 출하 포함) -->
|
||||
<select id="getShippingDetailList" parameterType="map" resultType="map">
|
||||
/* salesNcollectMgmt.getShippingDetailList - shipment_log에서 모든 분할 출하 조회 */
|
||||
SELECT
|
||||
COALESCE(TO_CHAR(SL.shipping_date, 'YYYY-MM-DD'), '미등록') AS shipping_date,
|
||||
COALESCE(SL.split_quantity, 0) AS shipping_quantity,
|
||||
COALESCE(SL.shipping_status, '미등록') AS shipping_order_status,
|
||||
COALESCE(SL.serial_no, '-') AS serial_no,
|
||||
SL.target_objid AS project_no,
|
||||
'분할 출하 ' || SL.log_id AS source,
|
||||
TO_CHAR(SL.reg_date, 'YYYY-MM-DD HH24:MI:SS') AS reg_date
|
||||
FROM shipment_log SL
|
||||
WHERE SL.target_objid = #{projectNo}
|
||||
ORDER BY SL.shipping_date DESC, SL.log_id DESC
|
||||
</select>
|
||||
|
||||
<!-- 거래명세서 - 고객 정보 조회 -->
|
||||
<select id="getCustomerInfoByProjectNo" parameterType="map" resultType="map">
|
||||
/* salesNcollectMgmt.getCustomerInfoByProjectNo - 프로젝트 번호로 고객 정보 조회 */
|
||||
@@ -1812,5 +1814,64 @@ ORDER BY T.REGDATE DESC, T.PROJECT_NO DESC
|
||||
WHERE PM.PROJECT_NO = #{projectNo}
|
||||
</select>
|
||||
|
||||
<!-- 거래명세서 저장 - NSWOS100_TBL 테이블 사용 -->
|
||||
<insert id="saveTransactionStatement" parameterType="map">
|
||||
/* salesNcollectMgmt.saveTransactionStatement - 거래명세서 저장 */
|
||||
INSERT INTO NSWOS100_TBL (
|
||||
SuVndCd /* 업체코드 */
|
||||
,IssueDt /* 작성일자 */
|
||||
,IssueNo /* 거래명세서번호 */
|
||||
,IsNo /* 순번 */
|
||||
,ProdCd /* 기종코드 */
|
||||
,OdOrderNo /* 발주번호 */
|
||||
,ImItemId /* 품번 */
|
||||
,RmDueDt /* 납기일자 */
|
||||
,RmOrderQty /* 발주수량 */
|
||||
,RmRcptQty /* 입고처리수량 */
|
||||
,RmRemQty /* 잔량 */
|
||||
,IsDt /* 납기일자 */
|
||||
,IsQty /* 납품수량 */
|
||||
,IsPrice /* 납품단가 */
|
||||
,IsAmount /* 납품금액 */
|
||||
) VALUES (
|
||||
#{suVndCd} /* 업체코드 */
|
||||
,#{issueDt} /* 작성일자 */
|
||||
,#{issueNo}::integer /* 거래명세서번호 */
|
||||
,#{isNo}::integer /* 순번 */
|
||||
,COALESCE(#{prodCd}, '') /* 기종코드 */
|
||||
,COALESCE(#{odOrderNo}, '') /* 발주번호 */
|
||||
,COALESCE(#{imItemId}, '') /* 품번 */
|
||||
,COALESCE(#{rmDueDt}, '') /* 납기일자 */
|
||||
,COALESCE(#{rmOrderQty}, 0)::integer /* 발주수량 */
|
||||
,COALESCE(#{rmRcptQty}, 0)::integer /* 입고처리수량 */
|
||||
,COALESCE(#{rmRemQty}, 0)::integer /* 잔량 */
|
||||
,COALESCE(#{isDt}, '') /* 납기일자 */
|
||||
,COALESCE(#{isQty}, 0)::integer /* 납품수량 */
|
||||
,COALESCE(#{isPrice}, 0)::numeric /* 납품단가 */
|
||||
,COALESCE(#{isAmount}, 0)::numeric /* 납품금액 */
|
||||
) ON CONFLICT (SuVndCd, IssueDt, IssueNo, IsNo) DO
|
||||
UPDATE SET
|
||||
ProdCd = COALESCE(#{prodCd}, '')
|
||||
,OdOrderNo = COALESCE(#{odOrderNo}, '')
|
||||
,ImItemId = COALESCE(#{imItemId}, '')
|
||||
,RmDueDt = COALESCE(#{rmDueDt}, '')
|
||||
,RmOrderQty = COALESCE(#{rmOrderQty}, 0)::integer
|
||||
,RmRcptQty = COALESCE(#{rmRcptQty}, 0)::integer
|
||||
,RmRemQty = COALESCE(#{rmRemQty}, 0)::integer
|
||||
,IsDt = COALESCE(#{isDt}, '')
|
||||
,IsQty = COALESCE(#{isQty}, 0)::integer
|
||||
,IsPrice = COALESCE(#{isPrice}, 0)::numeric
|
||||
,IsAmount = COALESCE(#{isAmount}, 0)::numeric
|
||||
</insert>
|
||||
|
||||
<!-- 거래명세서 번호 생성 -->
|
||||
<select id="getNextTransactionStatementNo" parameterType="map" resultType="int">
|
||||
/* salesNcollectMgmt.getNextTransactionStatementNo - 거래명세서 번호 생성 */
|
||||
SELECT COALESCE(MAX(IssueNo), 0) + 1 AS nextNo
|
||||
FROM NSWOS100_TBL
|
||||
WHERE SuVndCd = #{suVndCd}
|
||||
AND IssueDt = #{issueDt}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user