Compare commits
6 Commits
feature/es
...
V202511120
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c394900a83 | ||
|
|
479025bb79 | ||
|
|
606172fada | ||
|
|
fdd5346c99 | ||
|
|
6b3a2c1cf1 | ||
| c366b71174 |
@@ -3205,4 +3205,32 @@ SELECT option_objid::VARCHAR AS CODE
|
||||
WHERE USER_ID = #{userId}
|
||||
AND MASTER_OBJID::varchar = #{masterObjid}
|
||||
</select>
|
||||
|
||||
<!-- 고객사 정보 조회 -->
|
||||
<select id="getSupplyInfo" parameterType="map" resultType="map">
|
||||
SELECT
|
||||
OBJID,
|
||||
SUPPLY_CODE,
|
||||
SUPPLY_NAME,
|
||||
REG_NO,
|
||||
SUPPLY_ADDRESS,
|
||||
SUPPLY_BUSNAME,
|
||||
SUPPLY_STOCKNAME,
|
||||
SUPPLY_TEL_NO,
|
||||
SUPPLY_FAX_NO,
|
||||
CHARGE_USER_NAME,
|
||||
PAYMENT_METHOD,
|
||||
MANAGER1_NAME,
|
||||
MANAGER1_EMAIL,
|
||||
MANAGER2_NAME,
|
||||
MANAGER2_EMAIL,
|
||||
MANAGER3_NAME,
|
||||
MANAGER3_EMAIL,
|
||||
MANAGER4_NAME,
|
||||
MANAGER4_EMAIL,
|
||||
MANAGER5_NAME,
|
||||
MANAGER5_EMAIL
|
||||
FROM SUPPLY_MNG
|
||||
WHERE OBJID = #{objId}::numeric
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -790,6 +790,102 @@
|
||||
ORDER BY REGDATE DESC
|
||||
</select>
|
||||
|
||||
<!-- 주문서관리 Total 합계 조회 (조회된 데이터 전체 합계) -->
|
||||
<select id="getContractGridTotalAmount" parameterType="map" resultType="map">
|
||||
/* contractMgmt.getContractGridTotalAmount */
|
||||
SELECT
|
||||
COALESCE(SUM(COALESCE(T.ORDER_TOTAL_AMOUNT_KRW, 0)), 0) AS "totalAmountKRW"
|
||||
FROM
|
||||
<include refid="contractBase"/> T
|
||||
WHERE 1=1
|
||||
<if test="Year !=null and Year != '' ">
|
||||
AND SUBSTR(CONTRACT_DATE,0,5) = #{Year}
|
||||
</if>
|
||||
|
||||
<if test="category_cd !=null and category_cd != '' ">
|
||||
AND category_cd = #{category_cd}
|
||||
</if>
|
||||
|
||||
<if test="customer_objid !=null and customer_objid != '' ">
|
||||
AND customer_objid = #{customer_objid}
|
||||
</if>
|
||||
|
||||
<if test="product != null and product !='' ">
|
||||
AND product = #{product}
|
||||
</if>
|
||||
|
||||
<if test="status_cd !=null and status_cd !=''">
|
||||
AND status_cd = #{status_cd}
|
||||
</if>
|
||||
|
||||
<if test="result_cd !=null and result_cd !=''">
|
||||
AND result_cd = #{result_cd}
|
||||
</if>
|
||||
<if test="contract_result !=null and contract_result !=''">
|
||||
AND contract_result = #{contract_result}
|
||||
</if>
|
||||
|
||||
<if test="contract_start_date != null and !''.equals(contract_start_date)">
|
||||
AND TO_DATE(CONTRACT_DATE,'YYYY-MM-DD') <![CDATA[ >= ]]> TO_DATE(#{contract_start_date}, 'YYYY-MM-DD')
|
||||
</if>
|
||||
<if test="contract_end_date != null and !''.equals(contract_end_date)">
|
||||
AND TO_DATE(CONTRACT_DATE,'YYYY-MM-DD') <![CDATA[ <= ]]> TO_DATE(#{contract_end_date}, 'YYYY-MM-DD')
|
||||
</if>
|
||||
|
||||
<if test="pm_user_id !=null and pm_user_id !=''">
|
||||
AND pm_user_id = #{pm_user_id}
|
||||
</if>
|
||||
<if test="contract_month != null and !''.equals(contract_month)">
|
||||
AND TO_DATE(TO_CHAR(TO_DATE(CONTRACT_DATE,'YYYY-MM-DD'),'YYYY-MM-DD'),'YYYY-MM') <![CDATA[ = ]]> TO_DATE(SUBSTRING(#{contract_month} FROM 1 FOR 4) || '-' || SUBSTRING(#{contract_month} FROM 5 FOR 2), 'YYYY-MM')
|
||||
</if>
|
||||
|
||||
<!-- 견적관리 추가 검색조건 -->
|
||||
<if test="appr_status !=null and appr_status != '' ">
|
||||
AND APPR_STATUS = #{appr_status}
|
||||
</if>
|
||||
|
||||
<if test="area_cd != null and area_cd !='' ">
|
||||
AND AREA_CD = #{area_cd}
|
||||
</if>
|
||||
|
||||
<if test="paid_type != null and paid_type !='' ">
|
||||
AND PAID_TYPE = #{paid_type}
|
||||
</if>
|
||||
|
||||
<!-- 품번/품명 검색: PART_OBJID로 정확하게 검색 -->
|
||||
<if test="search_partObjId != null and search_partObjId != ''">
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM CONTRACT_ITEM CI
|
||||
WHERE CI.CONTRACT_OBJID = T.OBJID
|
||||
AND CI.STATUS = 'ACTIVE'
|
||||
AND CI.PART_OBJID = #{search_partObjId}
|
||||
)
|
||||
</if>
|
||||
|
||||
<if test="search_serialNo != null and search_serialNo != ''">
|
||||
AND UPPER(SERIAL_NO) LIKE UPPER('%${search_serialNo}%')
|
||||
</if>
|
||||
|
||||
<if test="search_poNo != null and search_poNo != ''">
|
||||
AND UPPER(PO_NO) LIKE UPPER('%${search_poNo}%')
|
||||
</if>
|
||||
|
||||
<if test="order_start_date != null and !''.equals(order_start_date)">
|
||||
AND TO_DATE(ORDER_DATE,'YYYY-MM-DD') <![CDATA[ >= ]]> TO_DATE(#{order_start_date}, 'YYYY-MM-DD')
|
||||
</if>
|
||||
<if test="order_end_date != null and !''.equals(order_end_date)">
|
||||
AND TO_DATE(ORDER_DATE,'YYYY-MM-DD') <![CDATA[ <= ]]> TO_DATE(#{order_end_date}, 'YYYY-MM-DD')
|
||||
</if>
|
||||
|
||||
<if test="due_start_date != null and !''.equals(due_start_date)">
|
||||
AND TO_DATE(DUE_DATE,'YYYY-MM-DD') <![CDATA[ >= ]]> TO_DATE(#{due_start_date}, 'YYYY-MM-DD')
|
||||
</if>
|
||||
<if test="due_end_date != null and !''.equals(due_end_date)">
|
||||
AND TO_DATE(DUE_DATE,'YYYY-MM-DD') <![CDATA[ <= ]]> TO_DATE(#{due_end_date}, 'YYYY-MM-DD')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="contractList_bak" parameterType="map" resultType="map">
|
||||
SELECT *
|
||||
FROM (
|
||||
@@ -3870,7 +3966,14 @@ ORDER BY ASM.SUPPLY_NAME
|
||||
FROM
|
||||
CONTRACT_MGMT AS T
|
||||
WHERE
|
||||
OBJID::VARCHAR = #{objId}
|
||||
<choose>
|
||||
<when test="templateObjId != null and templateObjId != '' and templateObjId != '-1' and (objId == null or objId == '' or objId == '-1')">
|
||||
OBJID::VARCHAR = (SELECT CONTRACT_OBJID FROM ESTIMATE_TEMPLATE WHERE OBJID = #{templateObjId})
|
||||
</when>
|
||||
<otherwise>
|
||||
OBJID::VARCHAR = #{objId}
|
||||
</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
<!-- 견적서 템플릿 목록 조회 (CONTRACT_OBJID 기준) -->
|
||||
@@ -3935,6 +4038,12 @@ ORDER BY ASM.SUPPLY_NAME
|
||||
ET.TOTAL_AMOUNT_KRW,
|
||||
ET.MANAGER_NAME,
|
||||
ET.MANAGER_CONTACT,
|
||||
ET.PART_NAME,
|
||||
ET.PART_OBJID,
|
||||
ET.NOTES_CONTENT,
|
||||
ET.VALIDITY_PERIOD,
|
||||
ET.CATEGORIES_JSON,
|
||||
ET.GROUP1_SUBTOTAL,
|
||||
ET.WRITER,
|
||||
ET.REGDATE,
|
||||
ET.CHG_USER_ID,
|
||||
@@ -3960,12 +4069,19 @@ ORDER BY ASM.SUPPLY_NAME
|
||||
ESTIMATE_TEMPLATE ET
|
||||
LEFT JOIN CONTRACT_MGMT CM ON ET.CONTRACT_OBJID = CM.OBJID
|
||||
WHERE
|
||||
ET.CONTRACT_OBJID = #{objId}
|
||||
<if test="template_type != null and template_type != ''">
|
||||
AND ET.TEMPLATE_TYPE = #{template_type}
|
||||
</if>
|
||||
ORDER BY ET.REGDATE DESC
|
||||
LIMIT 1
|
||||
<choose>
|
||||
<when test="templateObjId != null and templateObjId != '' and templateObjId != '-1'">
|
||||
ET.OBJID = #{templateObjId}
|
||||
</when>
|
||||
<otherwise>
|
||||
ET.CONTRACT_OBJID = #{objId}
|
||||
<if test="template_type != null and template_type != ''">
|
||||
AND ET.TEMPLATE_TYPE = #{template_type}
|
||||
</if>
|
||||
ORDER BY ET.REGDATE DESC
|
||||
LIMIT 1
|
||||
</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
<!-- 견적서 템플릿 데이터 조회 (OBJID 기준) -->
|
||||
@@ -3991,6 +4107,13 @@ ORDER BY ASM.SUPPLY_NAME
|
||||
ET.TOTAL_AMOUNT_KRW,
|
||||
ET.MANAGER_NAME,
|
||||
ET.MANAGER_CONTACT,
|
||||
ET.SHOW_TOTAL_ROW,
|
||||
ET.PART_NAME,
|
||||
ET.PART_OBJID,
|
||||
ET.NOTES_CONTENT,
|
||||
ET.VALIDITY_PERIOD,
|
||||
ET.CATEGORIES_JSON,
|
||||
ET.GROUP1_SUBTOTAL,
|
||||
ET.WRITER,
|
||||
TO_CHAR(ET.REGDATE, 'YYYY-MM-DD HH24:MI') AS REGDATE,
|
||||
ET.CHG_USER_ID,
|
||||
@@ -4069,6 +4192,30 @@ ORDER BY ASM.SUPPLY_NAME
|
||||
ORDER BY SEQ
|
||||
</select>
|
||||
|
||||
<!-- 견적서 템플릿 품목 조회 (PART_OBJID로) -->
|
||||
<select id="getEstimateTemplateItemByPartObjId" parameterType="map" resultType="map">
|
||||
SELECT
|
||||
OBJID,
|
||||
TEMPLATE_OBJID,
|
||||
SEQ,
|
||||
CATEGORY,
|
||||
PART_OBJID,
|
||||
DESCRIPTION,
|
||||
SPECIFICATION,
|
||||
QUANTITY,
|
||||
UNIT,
|
||||
UNIT_PRICE,
|
||||
AMOUNT,
|
||||
NOTE,
|
||||
REMARK
|
||||
FROM
|
||||
ESTIMATE_TEMPLATE_ITEM
|
||||
WHERE
|
||||
TEMPLATE_OBJID = #{templateObjId}
|
||||
AND PART_OBJID = #{partObjId}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 견적서 템플릿 저장 -->
|
||||
<insert id="insertEstimateTemplate" parameterType="map">
|
||||
INSERT INTO ESTIMATE_TEMPLATE (
|
||||
@@ -4092,6 +4239,7 @@ ORDER BY ASM.SUPPLY_NAME
|
||||
TOTAL_AMOUNT_KRW,
|
||||
MANAGER_NAME,
|
||||
MANAGER_CONTACT,
|
||||
SHOW_TOTAL_ROW,
|
||||
WRITER,
|
||||
REGDATE,
|
||||
CHG_USER_ID,
|
||||
@@ -4117,6 +4265,7 @@ ORDER BY ASM.SUPPLY_NAME
|
||||
#{total_amount_krw},
|
||||
#{manager_name},
|
||||
#{manager_contact},
|
||||
#{show_total_row},
|
||||
#{writer},
|
||||
NOW(),
|
||||
#{chg_user_id},
|
||||
@@ -4145,6 +4294,7 @@ ORDER BY ASM.SUPPLY_NAME
|
||||
TOTAL_AMOUNT_KRW = #{total_amount_krw},
|
||||
MANAGER_NAME = #{manager_name},
|
||||
MANAGER_CONTACT = #{manager_contact},
|
||||
SHOW_TOTAL_ROW = #{show_total_row},
|
||||
CHG_USER_ID = #{chg_user_id},
|
||||
CHGDATE = NOW()
|
||||
WHERE
|
||||
@@ -4202,6 +4352,67 @@ WHERE
|
||||
OBJID = #{template_objid}
|
||||
</update>
|
||||
|
||||
<!-- 장비 견적서 템플릿 신규 저장 (Template 2) -->
|
||||
<insert id="insertEstimateTemplate2" parameterType="map">
|
||||
INSERT INTO ESTIMATE_TEMPLATE (
|
||||
OBJID,
|
||||
CONTRACT_OBJID,
|
||||
TEMPLATE_TYPE,
|
||||
EXECUTOR_DATE,
|
||||
RECIPIENT,
|
||||
PART_NAME,
|
||||
PART_OBJID,
|
||||
NOTES_CONTENT,
|
||||
VALIDITY_PERIOD,
|
||||
CATEGORIES_JSON,
|
||||
GROUP1_SUBTOTAL,
|
||||
TOTAL_AMOUNT,
|
||||
TOTAL_AMOUNT_KRW,
|
||||
WRITER,
|
||||
REGDATE,
|
||||
CHG_USER_ID,
|
||||
CHGDATE
|
||||
) VALUES (
|
||||
#{template_objid},
|
||||
#{contract_objid},
|
||||
'2',
|
||||
#{executor_date},
|
||||
#{recipient},
|
||||
#{part_name},
|
||||
#{part_objid},
|
||||
#{notes_content},
|
||||
#{validity_period},
|
||||
#{categories_json},
|
||||
#{group1_subtotal},
|
||||
#{total_amount},
|
||||
#{total_amount_krw},
|
||||
#{writer},
|
||||
NOW(),
|
||||
#{chg_user_id},
|
||||
NOW()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 장비 견적서 템플릿 수정 (Template 2) -->
|
||||
<update id="updateEstimateTemplate2" parameterType="map">
|
||||
UPDATE ESTIMATE_TEMPLATE
|
||||
SET
|
||||
EXECUTOR_DATE = #{executor_date},
|
||||
RECIPIENT = #{recipient},
|
||||
PART_NAME = #{part_name},
|
||||
PART_OBJID = #{part_objid},
|
||||
NOTES_CONTENT = #{notes_content},
|
||||
VALIDITY_PERIOD = #{validity_period},
|
||||
CATEGORIES_JSON = #{categories_json},
|
||||
GROUP1_SUBTOTAL = #{group1_subtotal},
|
||||
TOTAL_AMOUNT = #{total_amount},
|
||||
TOTAL_AMOUNT_KRW = #{total_amount_krw},
|
||||
CHG_USER_ID = #{chg_user_id},
|
||||
CHGDATE = NOW()
|
||||
WHERE
|
||||
OBJID = #{template_objid}
|
||||
</update>
|
||||
|
||||
<!-- 최종 차수 견적서 조회 (메일 발송용) -->
|
||||
<select id="getLatestEstimateTemplate" parameterType="map" resultType="map">
|
||||
SELECT
|
||||
@@ -4359,14 +4570,112 @@ WHERE
|
||||
</if>
|
||||
ORDER BY REGDATE DESC
|
||||
</select>
|
||||
|
||||
<!-- 주문서관리 Total 합계 조회 -->
|
||||
<select id="getOrderTotalAmount" parameterType="map" resultType="map">
|
||||
SELECT
|
||||
COALESCE(SUM(COALESCE(T.ORDER_SUPPLY_PRICE_SUM, 0)), 0) AS TOTAL_SUPPLY_PRICE,
|
||||
COALESCE(SUM(COALESCE(T.ORDER_VAT_SUM, 0)), 0) AS TOTAL_VAT,
|
||||
COALESCE(SUM(COALESCE(T.ORDER_TOTAL_AMOUNT_SUM, 0)), 0) AS TOTAL_AMOUNT
|
||||
FROM
|
||||
<include refid="contractBase"/> T
|
||||
WHERE 1=1
|
||||
<if test="Year !=null and Year != '' ">
|
||||
AND SUBSTR(CONTRACT_DATE,0,5) = #{Year}
|
||||
</if>
|
||||
|
||||
<if test="category_cd !=null and category_cd != '' ">
|
||||
AND category_cd = #{category_cd}
|
||||
</if>
|
||||
|
||||
<if test="customer_objid !=null and customer_objid != '' ">
|
||||
AND customer_objid = #{customer_objid}
|
||||
</if>
|
||||
|
||||
<if test="product != null and product !='' ">
|
||||
AND product = #{product}
|
||||
</if>
|
||||
|
||||
<if test="status_cd !=null and status_cd !=''">
|
||||
AND status_cd = #{status_cd}
|
||||
</if>
|
||||
|
||||
<if test="result_cd !=null and result_cd !=''">
|
||||
AND result_cd = #{result_cd}
|
||||
</if>
|
||||
<if test="contract_result !=null and contract_result !=''">
|
||||
AND contract_result = #{contract_result}
|
||||
</if>
|
||||
|
||||
<if test="contract_start_date != null and !''.equals(contract_start_date)">
|
||||
AND TO_DATE(CONTRACT_DATE,'YYYY-MM-DD') <![CDATA[ >= ]]> TO_DATE(#{contract_start_date}, 'YYYY-MM-DD')
|
||||
</if>
|
||||
<if test="contract_end_date != null and !''.equals(contract_end_date)">
|
||||
AND TO_DATE(CONTRACT_DATE,'YYYY-MM-DD') <![CDATA[ <= ]]> TO_DATE(#{contract_end_date}, 'YYYY-MM-DD')
|
||||
</if>
|
||||
|
||||
<if test="pm_user_id !=null and pm_user_id !=''">
|
||||
AND pm_user_id = #{pm_user_id}
|
||||
</if>
|
||||
<if test="contract_month != null and !''.equals(contract_month)">
|
||||
AND TO_DATE(TO_CHAR(TO_DATE(CONTRACT_DATE,'YYYY-MM-DD'),'YYYY-MM-DD'),'YYYY-MM') <![CDATA[ = ]]> TO_DATE(SUBSTRING(#{contract_month} FROM 1 FOR 4) || '-' || SUBSTRING(#{contract_month} FROM 5 FOR 2), 'YYYY-MM')
|
||||
</if>
|
||||
|
||||
<!-- 견적관리 추가 검색조건 -->
|
||||
<if test="appr_status !=null and appr_status != '' ">
|
||||
AND APPR_STATUS = #{appr_status}
|
||||
</if>
|
||||
|
||||
<if test="area_cd != null and area_cd !='' ">
|
||||
AND AREA_CD = #{area_cd}
|
||||
</if>
|
||||
|
||||
<if test="paid_type != null and paid_type !='' ">
|
||||
AND PAID_TYPE = #{paid_type}
|
||||
</if>
|
||||
|
||||
<!-- 품번/품명 검색: PART_OBJID로 정확하게 검색 -->
|
||||
<if test="search_partObjId != null and search_partObjId != ''">
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM CONTRACT_ITEM CI
|
||||
WHERE CI.CONTRACT_OBJID = T.OBJID
|
||||
AND CI.STATUS = 'ACTIVE'
|
||||
AND CI.PART_OBJID = #{search_partObjId}
|
||||
)
|
||||
</if>
|
||||
|
||||
<if test="search_serialNo != null and search_serialNo != ''">
|
||||
AND UPPER(SERIAL_NO) LIKE UPPER('%${search_serialNo}%')
|
||||
</if>
|
||||
|
||||
<if test="search_poNo != null and search_poNo != ''">
|
||||
AND UPPER(PO_NO) LIKE UPPER('%${search_poNo}%')
|
||||
</if>
|
||||
|
||||
<if test="order_start_date != null and !''.equals(order_start_date)">
|
||||
AND TO_DATE(ORDER_DATE,'YYYY-MM-DD') <![CDATA[ >= ]]> TO_DATE(#{order_start_date}, 'YYYY-MM-DD')
|
||||
</if>
|
||||
<if test="order_end_date != null and !''.equals(order_end_date)">
|
||||
AND TO_DATE(ORDER_DATE,'YYYY-MM-DD') <![CDATA[ <= ]]> TO_DATE(#{order_end_date}, 'YYYY-MM-DD')
|
||||
</if>
|
||||
|
||||
<if test="due_start_date != null and !''.equals(due_start_date)">
|
||||
AND TO_DATE(DUE_DATE,'YYYY-MM-DD') <![CDATA[ >= ]]> TO_DATE(#{due_start_date}, 'YYYY-MM-DD')
|
||||
</if>
|
||||
<if test="due_end_date != null and !''.equals(due_end_date)">
|
||||
AND TO_DATE(DUE_DATE,'YYYY-MM-DD') <![CDATA[ <= ]]> TO_DATE(#{due_end_date}, 'YYYY-MM-DD')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 영업정보 조회 (수주등록용) -->
|
||||
<select id="getContractInfo" parameterType="map" resultType="map">
|
||||
SELECT
|
||||
OBJID,
|
||||
CONTRACT_NO,
|
||||
CUSTOMER_OBJID,
|
||||
CONTRACT_CURRENCY,
|
||||
(SELECT CODE_NAME FROM TB_CODE WHERE CODE_ID = CONTRACT_CURRENCY) AS CONTRACT_CURRENCY_NAME,
|
||||
(SELECT CODE_NAME FROM COMM_CODE WHERE CODE_ID = CONTRACT_CURRENCY) AS CONTRACT_CURRENCY_NAME,
|
||||
EXCHANGE_RATE,
|
||||
QUANTITY,
|
||||
PART_NO,
|
||||
@@ -4592,8 +4901,8 @@ WHERE
|
||||
CI.CONTRACT_OBJID,
|
||||
CI.SEQ,
|
||||
CI.PART_OBJID,
|
||||
CI.PART_NO,
|
||||
CI.PART_NAME,
|
||||
COALESCE(NULLIF(CI.PART_NO, ''), PM.PART_NO) AS PART_NO,
|
||||
COALESCE(NULLIF(CI.PART_NAME, ''), PM.PART_NAME) AS PART_NAME,
|
||||
CI.QUANTITY,
|
||||
CI.DUE_DATE,
|
||||
CI.CUSTOMER_REQUEST,
|
||||
@@ -4607,6 +4916,8 @@ WHERE
|
||||
LEFT JOIN CONTRACT_ITEM_SERIAL CIS
|
||||
ON CI.OBJID = CIS.ITEM_OBJID
|
||||
AND CIS.STATUS = 'ACTIVE'
|
||||
LEFT JOIN PART_MNG PM
|
||||
ON CI.PART_OBJID = PM.OBJID
|
||||
WHERE
|
||||
CI.CONTRACT_OBJID = #{contractObjId}
|
||||
AND CI.STATUS = 'ACTIVE'
|
||||
@@ -4616,7 +4927,9 @@ WHERE
|
||||
CI.SEQ,
|
||||
CI.PART_OBJID,
|
||||
CI.PART_NO,
|
||||
CI.PART_NAME,
|
||||
CI.PART_NAME,
|
||||
PM.PART_NO,
|
||||
PM.PART_NAME,
|
||||
CI.QUANTITY,
|
||||
CI.DUE_DATE,
|
||||
CI.CUSTOMER_REQUEST,
|
||||
|
||||
@@ -875,16 +875,32 @@
|
||||
(SELECT CM.PRODUCTION_STATUS FROM CONTRACT_MGMT CM WHERE CM.OBJID = T.CONTRACT_OBJID) AS PRODUCTION_STATUS,
|
||||
-- 판매 관련 필드들 (sales_registration 테이블에서 한 번에 가져오기)
|
||||
COALESCE(SR.shipping_order_status, '') AS SHIPPING_ORDER_STATUS,
|
||||
COALESCE(SR.sales_quantity, 0) AS SALES_QUANTITY,
|
||||
-- 판매수량: 모든 분할 출하의 합계
|
||||
COALESCE(
|
||||
(SELECT SUM(sales_quantity)
|
||||
FROM sales_registration
|
||||
WHERE project_no LIKE T.PROJECT_NO || '%'),
|
||||
0
|
||||
) AS SALES_QUANTITY,
|
||||
COALESCE(SR.sales_unit_price, 0) AS SALES_UNIT_PRICE,
|
||||
COALESCE(SR.sales_supply_price, 0) AS SALES_SUPPLY_PRICE,
|
||||
COALESCE(SR.sales_vat, 0) AS SALES_VAT,
|
||||
COALESCE(SR.sales_total_amount, 0) AS SALES_TOTAL_AMOUNT,
|
||||
COALESCE(SR.sales_total_amount, 0) AS SALES_TOTAL_AMOUNT_KRW,
|
||||
-- 잔량 계산: 수주수량 - 판매수량
|
||||
COALESCE(T.QUANTITY::numeric, 0) - COALESCE(SR.sales_quantity, 0) AS REMAINING_QUANTITY,
|
||||
-- 잔량원화총액 계산: (수주수량 - 판매수량) * 판매단가
|
||||
(COALESCE(T.QUANTITY::numeric, 0) - COALESCE(SR.sales_quantity, 0)) * COALESCE(SR.sales_unit_price, 0) AS REMAINING_AMOUNT_KRW,
|
||||
-- 잔량 계산: 수주수량 - 모든 분할 출하의 합계
|
||||
COALESCE(T.QUANTITY::numeric, 0) - COALESCE(
|
||||
(SELECT SUM(sales_quantity)
|
||||
FROM sales_registration
|
||||
WHERE project_no LIKE T.PROJECT_NO || '%'),
|
||||
0
|
||||
) AS REMAINING_QUANTITY,
|
||||
-- 잔량원화총액 계산: (수주수량 - 모든 분할 출하 합계) * 판매단가
|
||||
(COALESCE(T.QUANTITY::numeric, 0) - COALESCE(
|
||||
(SELECT SUM(sales_quantity)
|
||||
FROM sales_registration
|
||||
WHERE project_no LIKE T.PROJECT_NO || '%'),
|
||||
0
|
||||
)) * COALESCE(SR.sales_unit_price, 0) AS REMAINING_AMOUNT_KRW,
|
||||
COALESCE(SR.sales_currency, T.CONTRACT_CURRENCY) AS SALES_CURRENCY,
|
||||
CODE_NAME(COALESCE(SR.sales_currency, T.CONTRACT_CURRENCY)) AS SALES_CURRENCY_NAME,
|
||||
COALESCE(SR.sales_exchange_rate, T.CONTRACT_PRICE_CURRENCY::numeric, 0) AS SALES_EXCHANGE_RATE,
|
||||
@@ -1397,29 +1413,12 @@ ORDER BY T.REGDATE DESC, T.PROJECT_NO DESC
|
||||
NULL,
|
||||
</otherwise>
|
||||
</choose>
|
||||
#{shippingMethod},
|
||||
#{manager},
|
||||
#{incoterms},
|
||||
#{cretEmpNo}
|
||||
)
|
||||
ON CONFLICT (project_no)
|
||||
DO UPDATE SET
|
||||
shipping_order_status = EXCLUDED.shipping_order_status,
|
||||
serial_no = EXCLUDED.serial_no,
|
||||
sales_quantity = EXCLUDED.sales_quantity,
|
||||
sales_unit_price = EXCLUDED.sales_unit_price,
|
||||
sales_supply_price = EXCLUDED.sales_supply_price,
|
||||
sales_vat = EXCLUDED.sales_vat,
|
||||
sales_total_amount = EXCLUDED.sales_total_amount,
|
||||
sales_currency = EXCLUDED.sales_currency,
|
||||
sales_exchange_rate = EXCLUDED.sales_exchange_rate,
|
||||
shipping_date = EXCLUDED.shipping_date,
|
||||
shipping_method = EXCLUDED.shipping_method,
|
||||
manager_user_id = EXCLUDED.manager_user_id,
|
||||
incoterms = EXCLUDED.incoterms,
|
||||
upd_date = NOW(),
|
||||
upd_user_id = EXCLUDED.reg_user_id
|
||||
</insert>
|
||||
#{shippingMethod},
|
||||
#{manager},
|
||||
#{incoterms},
|
||||
#{cretEmpNo}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!--
|
||||
/**
|
||||
@@ -1488,9 +1487,15 @@ ORDER BY T.REGDATE DESC, T.PROJECT_NO DESC
|
||||
AND UPPER(STATUS) = 'ACTIVE'
|
||||
) THEN 'Y' ELSE 'N' END AS ORDER_ATTACH,
|
||||
(SELECT CM.PRODUCTION_STATUS FROM CONTRACT_MGMT CM WHERE CM.OBJID = T.CONTRACT_OBJID) AS PRODUCTION_STATUS,
|
||||
-- 판매 관련 필드들 (sales_registration 테이블에서 가져오기)
|
||||
COALESCE(SR.shipping_order_status, '') AS SHIPPING_ORDER_STATUS,
|
||||
COALESCE(SR.sales_quantity, 0) AS SALES_QUANTITY,
|
||||
-- 판매 관련 필드들 (sales_registration 테이블에서 가져오기)
|
||||
SR.sale_no AS SALE_NO,
|
||||
COALESCE(SR.shipping_order_status, '') AS SHIPPING_ORDER_STATUS,
|
||||
|
||||
-- 주문수량 (PROJECT_MGMT에서 가져오기) - 잔량 계산용
|
||||
COALESCE(T.QUANTITY::NUMERIC, 0) AS ORDER_QUANTITY,
|
||||
|
||||
-- 판매수량 (sales_registration에서 가져오기) - 이미 판매한 수량
|
||||
COALESCE(SR.sales_quantity, 0) AS SALES_QUANTITY,
|
||||
COALESCE(SR.sales_unit_price, 0) AS SALES_UNIT_PRICE,
|
||||
COALESCE(SR.sales_supply_price, 0) AS SALES_SUPPLY_PRICE,
|
||||
COALESCE(SR.sales_vat, 0) AS SALES_VAT,
|
||||
@@ -1498,7 +1503,7 @@ ORDER BY T.REGDATE DESC, T.PROJECT_NO DESC
|
||||
COALESCE(SR.sales_total_amount, 0) AS SALES_TOTAL_AMOUNT_KRW,
|
||||
COALESCE(NULLIF(SR.sales_currency, ''), CM.CONTRACT_CURRENCY) AS SALES_CURRENCY,
|
||||
CODE_NAME(COALESCE(NULLIF(SR.sales_currency, ''), CM.CONTRACT_CURRENCY)) AS SALES_CURRENCY_NAME,
|
||||
COALESCE(NULLIF(SR.sales_exchange_rate, 0), CM.EXCHANGE_RATE::numeric, 0) AS SALES_EXCHANGE_RATE,
|
||||
COALESCE(NULLIF(SR.sales_exchange_rate, 0), NULLIF(CM.EXCHANGE_RATE, '')::numeric, 0) AS SALES_EXCHANGE_RATE,
|
||||
COALESCE(TO_CHAR(SR.shipping_date, 'YYYY-MM-DD'), '') AS SHIPPING_DATE,
|
||||
COALESCE(SR.shipping_method, '') AS SHIPPING_METHOD,
|
||||
COALESCE(SR.manager_user_id, T.PM_USER_ID) AS MANAGER,
|
||||
@@ -1566,40 +1571,43 @@ ORDER BY T.REGDATE DESC, T.PROJECT_NO DESC
|
||||
-->
|
||||
<select id="getOrderDataByOrderNo" parameterType="map" resultType="map">
|
||||
/* salesNcollectMgmt.getOrderDataByOrderNo - orderNo로 판매등록용 수주 데이터 조회 */
|
||||
SELECT
|
||||
-- 기본 정보
|
||||
CM.CONTRACT_NO AS ORDER_NO,
|
||||
CM.OBJID AS CONTRACT_OBJID,
|
||||
|
||||
-- 수주 금액 정보 (CONTRACT_ITEM 테이블에서 합산) - VARCHAR 타입이므로 NUMERIC으로 캐스팅
|
||||
COALESCE(SUM(CI.ORDER_QUANTITY::NUMERIC), 0) AS SALES_QUANTITY,
|
||||
COALESCE(ROUND(AVG(CI.ORDER_UNIT_PRICE::NUMERIC), 2), 0) AS SALES_UNIT_PRICE,
|
||||
COALESCE(SUM(CI.ORDER_SUPPLY_PRICE::NUMERIC), 0) AS SALES_SUPPLY_PRICE,
|
||||
COALESCE(SUM(CI.ORDER_VAT::NUMERIC), 0) AS SALES_VAT,
|
||||
COALESCE(SUM(CI.ORDER_TOTAL_AMOUNT::NUMERIC), 0) AS SALES_TOTAL_AMOUNT,
|
||||
|
||||
-- 환종 정보
|
||||
CM.CONTRACT_CURRENCY AS SALES_CURRENCY,
|
||||
CODE_NAME(CM.CONTRACT_CURRENCY) AS SALES_CURRENCY_NAME,
|
||||
COALESCE(CM.EXCHANGE_RATE::NUMERIC, 0) AS SALES_EXCHANGE_RATE,
|
||||
|
||||
-- 수주 날짜 - VARCHAR 타입이므로 그대로 사용
|
||||
CM.ORDER_DATE AS SHIPPING_DATE,
|
||||
|
||||
-- 담당자
|
||||
CM.PM_USER_ID AS MANAGER
|
||||
|
||||
FROM PROJECT_MGMT PM
|
||||
INNER JOIN CONTRACT_MGMT CM ON PM.CONTRACT_OBJID = CM.OBJID
|
||||
LEFT JOIN CONTRACT_ITEM CI ON CM.OBJID::VARCHAR = CI.CONTRACT_OBJID AND UPPER(CI.STATUS) = 'ACTIVE'
|
||||
WHERE PM.PROJECT_NO = #{orderNo}
|
||||
GROUP BY
|
||||
CM.CONTRACT_NO,
|
||||
CM.OBJID,
|
||||
CM.CONTRACT_CURRENCY,
|
||||
CM.EXCHANGE_RATE,
|
||||
CM.ORDER_DATE,
|
||||
CM.PM_USER_ID
|
||||
SELECT
|
||||
-- 기본 정보
|
||||
CM.CONTRACT_NO AS ORDER_NO,
|
||||
CM.OBJID AS CONTRACT_OBJID,
|
||||
|
||||
-- 수주 수량 정보 (PROJECT_MGMT에서 직접 가져오기)
|
||||
COALESCE(PM.QUANTITY::NUMERIC, 0) AS SALES_QUANTITY,
|
||||
|
||||
-- 수주 금액 정보 (CONTRACT_ITEM 테이블에서 합산) - VARCHAR 타입이므로 NULLIF로 빈 문자열 제거 후 NUMERIC 캐스팅
|
||||
COALESCE(ROUND(AVG(NULLIF(CI.ORDER_UNIT_PRICE, '')::NUMERIC), 2), 0) AS SALES_UNIT_PRICE,
|
||||
COALESCE(SUM(NULLIF(CI.ORDER_SUPPLY_PRICE, '')::NUMERIC), 0) AS SALES_SUPPLY_PRICE,
|
||||
COALESCE(SUM(NULLIF(CI.ORDER_VAT, '')::NUMERIC), 0) AS SALES_VAT,
|
||||
COALESCE(SUM(NULLIF(CI.ORDER_TOTAL_AMOUNT, '')::NUMERIC), 0) AS SALES_TOTAL_AMOUNT,
|
||||
|
||||
-- 환종 정보
|
||||
CM.CONTRACT_CURRENCY AS SALES_CURRENCY,
|
||||
CODE_NAME(CM.CONTRACT_CURRENCY) AS SALES_CURRENCY_NAME,
|
||||
COALESCE(NULLIF(CM.EXCHANGE_RATE, '')::NUMERIC, 0) AS SALES_EXCHANGE_RATE,
|
||||
|
||||
-- 수주 날짜 - VARCHAR 타입이므로 그대로 사용
|
||||
CM.ORDER_DATE AS SHIPPING_DATE,
|
||||
|
||||
-- 담당자
|
||||
CM.PM_USER_ID AS MANAGER
|
||||
|
||||
FROM PROJECT_MGMT PM
|
||||
INNER JOIN CONTRACT_MGMT CM ON PM.CONTRACT_OBJID = CM.OBJID
|
||||
LEFT JOIN CONTRACT_ITEM CI ON CM.OBJID::VARCHAR = CI.CONTRACT_OBJID AND UPPER(CI.STATUS) = 'ACTIVE'
|
||||
WHERE PM.PROJECT_NO = #{orderNo}
|
||||
GROUP BY
|
||||
CM.CONTRACT_NO,
|
||||
CM.OBJID,
|
||||
CM.CONTRACT_CURRENCY,
|
||||
CM.EXCHANGE_RATE,
|
||||
CM.ORDER_DATE,
|
||||
CM.PM_USER_ID,
|
||||
PM.QUANTITY
|
||||
</select>
|
||||
|
||||
<!--
|
||||
@@ -1619,5 +1627,159 @@ ORDER BY T.REGDATE DESC, T.PROJECT_NO DESC
|
||||
WHERE OBJID::VARCHAR = #{OBJID}
|
||||
</update>
|
||||
|
||||
<!-- 모든 분할 출하의 총 판매 수량 조회 -->
|
||||
<select id="getTotalSalesQuantity" parameterType="map" resultType="map">
|
||||
/* salesNcollectMgmt.getTotalSalesQuantity - project_no로 시작하는 모든 레코드의 판매 수량 합계 */
|
||||
SELECT COALESCE(SUM(NULLIF(sales_quantity, '')::NUMERIC), 0) as total
|
||||
FROM sales_registration
|
||||
WHERE project_no LIKE #{orderNo} || '%'
|
||||
</select>
|
||||
|
||||
<!-- sales_registration 개수 조회 (분할 출하 순번용) -->
|
||||
<select id="getSaleRegistrationCount" parameterType="map" resultType="map">
|
||||
/* salesNcollectMgmt.getSaleRegistrationCount - project_no로 시작하는 레코드 개수 */
|
||||
SELECT COUNT(*) as count
|
||||
FROM sales_registration
|
||||
WHERE project_no LIKE #{orderNo} || '%'
|
||||
</select>
|
||||
|
||||
<!-- sales_registration DELETE (기존 데이터 삭제) -->
|
||||
<delete id="deleteSaleRegistration" parameterType="map">
|
||||
/* salesNcollectMgmt.deleteSaleRegistration - sales_registration 삭제 */
|
||||
DELETE FROM sales_registration
|
||||
WHERE project_no = #{orderNo}
|
||||
</delete>
|
||||
|
||||
<!-- sales_registration UPDATE (기존 데이터 수정) -->
|
||||
<update id="updateSaleRegistration" parameterType="map">
|
||||
/* salesNcollectMgmt.updateSaleRegistration - sales_registration 업데이트 */
|
||||
UPDATE sales_registration
|
||||
SET
|
||||
shipping_order_status = <choose>
|
||||
<when test="shippingOrderStatus != null and shippingOrderStatus != ''">
|
||||
#{shippingOrderStatus},
|
||||
</when>
|
||||
<otherwise>
|
||||
'',
|
||||
</otherwise>
|
||||
</choose>
|
||||
serial_no = #{serialNo},
|
||||
sales_quantity = #{salesQuantity}::integer,
|
||||
sales_unit_price = #{salesUnitPrice}::numeric,
|
||||
sales_supply_price = #{salesSupplyPrice}::numeric,
|
||||
sales_vat = #{salesVat}::numeric,
|
||||
sales_total_amount = #{salesTotalAmount}::numeric,
|
||||
sales_currency = #{salesCurrency},
|
||||
sales_exchange_rate = #{salesExchangeRate}::numeric,
|
||||
shipping_date = <choose>
|
||||
<when test="shippingDate != null and shippingDate != ''">
|
||||
TO_DATE(#{shippingDate}, 'YYYY-MM-DD'),
|
||||
</when>
|
||||
<otherwise>
|
||||
NULL,
|
||||
</otherwise>
|
||||
</choose>
|
||||
shipping_method = #{shippingMethod},
|
||||
manager_user_id = #{manager},
|
||||
incoterms = #{incoterms},
|
||||
upd_date = NOW(),
|
||||
upd_user_id = #{cretEmpNo}
|
||||
WHERE project_no = #{orderNo}
|
||||
</update>
|
||||
|
||||
<!-- ========================================
|
||||
분할 출하 관련 쿼리 (shipment_log 테이블 활용)
|
||||
======================================== -->
|
||||
|
||||
<!-- shipment_log의 split_quantity 합산 조회 -->
|
||||
<select id="getShipmentLogTotal" parameterType="map" resultType="map">
|
||||
/* salesNcollectMgmt.getShipmentLogTotal - shipment_log의 split_quantity 합산 */
|
||||
SELECT COALESCE(SUM(split_quantity), 0) as total
|
||||
FROM shipment_log SL
|
||||
INNER JOIN project_mgmt PM ON SL.target_objid = PM.OBJID::VARCHAR
|
||||
WHERE PM.PROJECT_NO = #{orderNo}
|
||||
</select>
|
||||
|
||||
<!-- shipment_log에 분할 출하 기록 저장 -->
|
||||
<insert id="insertShipmentLog" parameterType="map">
|
||||
/* salesNcollectMgmt.insertShipmentLog - 분할 출하 기록 저장 */
|
||||
INSERT INTO shipment_log (
|
||||
target_objid, log_type, log_message, split_quantity, original_quantity,
|
||||
remaining_quantity, shipping_status, shipping_date, shipping_method,
|
||||
sales_unit_price, sales_supply_price, sales_vat, sales_total_amount,
|
||||
sales_currency, sales_exchange_rate, manager_user_id, incoterms,
|
||||
serial_no, parent_sale_no, reg_user_id
|
||||
) VALUES (
|
||||
#{targetObjid}, 'SPLIT_SHIPMENT', '분할 출하',
|
||||
#{salesQuantity}::integer, #{originalQuantity}::integer, #{remainingQuantity}::integer,
|
||||
#{shippingOrderStatus},
|
||||
<choose>
|
||||
<when test="shippingDate != null and shippingDate != ''">
|
||||
TO_DATE(#{shippingDate}, 'YYYY-MM-DD'),
|
||||
</when>
|
||||
<otherwise>NULL,</otherwise>
|
||||
</choose>
|
||||
#{shippingMethod}, #{salesUnitPrice}::numeric, #{salesSupplyPrice}::numeric,
|
||||
#{salesVat}::numeric, #{salesTotalAmount}::numeric, #{salesCurrency},
|
||||
#{salesExchangeRate}::numeric, #{manager}, #{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>
|
||||
|
||||
<!-- 출하일 상세 내역 조회 (모든 분할 출하 포함) -->
|
||||
<select id="getShippingDetailList" parameterType="map" resultType="map">
|
||||
/* salesNcollectMgmt.getShippingDetailList - 모든 분할 출하 포함 */
|
||||
SELECT
|
||||
COALESCE(TO_CHAR(SR.shipping_date, 'YYYY-MM-DD'), '미등록') AS shipping_date,
|
||||
COALESCE(SR.sales_quantity, 0) AS shipping_quantity,
|
||||
COALESCE(SR.shipping_order_status, '미등록') AS shipping_order_status,
|
||||
COALESCE(SR.serial_no, '-') AS serial_no,
|
||||
SR.project_no,
|
||||
CASE
|
||||
WHEN SR.project_no = #{projectNo} THEN '최초 출하'
|
||||
ELSE '분할 출하 ' || SUBSTRING(SR.project_no FROM LENGTH(#{projectNo}) + 2)
|
||||
END AS source
|
||||
FROM sales_registration SR
|
||||
WHERE SR.project_no LIKE #{projectNo} || '%'
|
||||
|
||||
ORDER BY shipping_date DESC, project_no
|
||||
</select>
|
||||
|
||||
<!-- 거래명세서 - 고객 정보 조회 -->
|
||||
<select id="getCustomerInfoByProjectNo" parameterType="map" resultType="map">
|
||||
/* salesNcollectMgmt.getCustomerInfoByProjectNo - 프로젝트 번호로 고객 정보 조회 */
|
||||
SELECT
|
||||
SM.SUPPLY_NAME AS CUSTOMER_NAME,
|
||||
SM.BUSINESS_NO AS CUSTOMER_REG_NO,
|
||||
SM.ADDRESS AS CUSTOMER_ADDRESS,
|
||||
SM.BUSINESS_TYPE AS CUSTOMER_BUSINESS,
|
||||
SM.BUSINESS_ITEM AS CUSTOMER_TYPE,
|
||||
SM.TEL_NO AS CUSTOMER_CONTACT
|
||||
FROM PROJECT_MGMT PM
|
||||
INNER JOIN SUPPLY_MNG SM ON PM.CUSTOMER_OBJID::NUMERIC = SM.OBJID
|
||||
WHERE PM.PROJECT_NO = #{projectNo}
|
||||
</select>
|
||||
|
||||
<!-- 거래명세서 - 품목 정보 조회 -->
|
||||
<select id="getTransactionStatementItem" parameterType="map" resultType="map">
|
||||
/* salesNcollectMgmt.getTransactionStatementItem - 프로젝트 번호로 품목 정보 조회 */
|
||||
SELECT
|
||||
PM.PART_NAME AS productName,
|
||||
PM.PART_NO AS spec,
|
||||
COALESCE(SR.sales_quantity, PM.QUANTITY) AS quantity,
|
||||
COALESCE(SR.sales_unit_price, 0) AS unitPrice,
|
||||
COALESCE(SR.sales_supply_price, 0) AS supplyPrice,
|
||||
COALESCE(SR.sales_vat, 0) AS vat
|
||||
FROM PROJECT_MGMT PM
|
||||
LEFT JOIN sales_registration SR ON PM.PROJECT_NO = SR.project_no
|
||||
WHERE PM.PROJECT_NO = #{projectNo}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
|
||||
@@ -24,6 +24,11 @@ $(document).ready(function(){
|
||||
//날짜
|
||||
_fnc_datepick();
|
||||
|
||||
// 그리드 높이 동적 계산 (Total 합계 영역 + 여유 공간 80px)
|
||||
fnc_calculateContentHeight("gridDiv", 80);
|
||||
$(window).resize(function() {
|
||||
fnc_calculateContentHeight("gridDiv", 80);
|
||||
});
|
||||
|
||||
$('.select2').select2();
|
||||
|
||||
@@ -96,14 +101,14 @@ $(document).ready(function(){
|
||||
});
|
||||
|
||||
var columns = [
|
||||
{formatter:"rowSelection", titleFormatter:"rowSelection", hozAlign:"center", headerSort:false, width:40, frozen:true},
|
||||
{headerHozAlign : 'center', hozAlign : 'center', width : '90', title : '영업번호', field : 'CONTRACT_NO', frozen:true,
|
||||
formatter:fnc_createGridAnchorTag,
|
||||
cellClick:function(e, cell){
|
||||
var objid = fnc_checkNull(cell.getData().OBJID);
|
||||
fn_projectConceptDetail(objid);
|
||||
}
|
||||
},
|
||||
// rowSelection 제거 - fnc_tabul_search의 showCheck 파라미터로 자동 추가됨
|
||||
{headerHozAlign : 'center', hozAlign : 'center', width : '90', title : '영업번호', field : 'CONTRACT_NO', frozen:true,
|
||||
formatter:fnc_createGridAnchorTag,
|
||||
cellClick:function(e, cell){
|
||||
var objid = fnc_checkNull(cell.getData().OBJID);
|
||||
fn_projectConceptDetail(objid);
|
||||
}
|
||||
},
|
||||
{headerHozAlign : 'center', hozAlign : 'center', width : '80', title : '주문유형', field : 'CATEGORY_NAME' },
|
||||
{headerHozAlign : 'center', hozAlign : 'center', width : '100', title : '발주일', field : 'ORDER_DATE' },
|
||||
{headerHozAlign : 'center', hozAlign : 'center', width : '100', title : '발주번호', field : 'PO_NO' },
|
||||
@@ -182,64 +187,49 @@ var columns = [
|
||||
|
||||
//var grid;
|
||||
function fn_search(){
|
||||
// 그리드 조회 및 Total 합계 업데이트를 위한 커스텀 AJAX
|
||||
$.ajax({
|
||||
url: "/contractMgmt/contractGridList.do",
|
||||
type: "POST",
|
||||
data: $("#form1").serializeObject(),
|
||||
dataType: "json",
|
||||
beforeSend: function(){
|
||||
_startLoading("Loading...");
|
||||
},
|
||||
complete: function(){
|
||||
_endLoading();
|
||||
},
|
||||
success: function(response) {
|
||||
// 그리드 데이터 설정
|
||||
if(_tabulGrid){
|
||||
_tabulGrid.setData(response.RESULTLIST || []);
|
||||
} else {
|
||||
// 그리드 초기화
|
||||
_tabulGrid = new Tabulator("#mainGrid", {
|
||||
layout: _tabul_layout_fitColumns,
|
||||
columns: columns,
|
||||
data: response.RESULTLIST || [],
|
||||
selectable: true
|
||||
});
|
||||
}
|
||||
|
||||
// 조회된 전체 데이터의 합계 계산
|
||||
var totalSupplyPrice = 0;
|
||||
var totalVat = 0;
|
||||
var totalAmount = 0;
|
||||
|
||||
if(response.RESULTLIST && response.RESULTLIST.length > 0) {
|
||||
response.RESULTLIST.forEach(function(row) {
|
||||
var supplyPrice = parseFloat(row.ORDER_SUPPLY_PRICE_SUM || 0);
|
||||
var vat = parseFloat(row.ORDER_VAT_SUM || 0);
|
||||
var amount = parseFloat(row.ORDER_TOTAL_AMOUNT_SUM || 0);
|
||||
|
||||
totalSupplyPrice += supplyPrice;
|
||||
totalVat += vat;
|
||||
totalAmount += amount;
|
||||
});
|
||||
}
|
||||
|
||||
// 합계 표시
|
||||
$("#totalSupplyPrice").text(Number(totalSupplyPrice).toLocaleString());
|
||||
$("#totalVat").text(Number(totalVat).toLocaleString());
|
||||
$("#totalAmount").text(Number(totalAmount).toLocaleString());
|
||||
|
||||
// 페이징 HTML 업데이트
|
||||
if(response.PAGE_HTML){
|
||||
$(".table_paging_wrap").html(response.PAGE_HTML);
|
||||
}
|
||||
},
|
||||
error: function(jqxhr, status, error){
|
||||
alert("데이터 조회 중 오류가 발생했습니다.");
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
// fnc_tabul_search로 페이징 처리
|
||||
_tabulGrid = fnc_tabul_search(
|
||||
_tabul_layout_fitColumns,
|
||||
_tabulGrid,
|
||||
"/contractMgmt/contractGridList.do",
|
||||
columns,
|
||||
true
|
||||
);
|
||||
|
||||
// 데이터 렌더링 완료 후 합계 계산 (한 번만 실행)
|
||||
if(_tabulGrid) {
|
||||
// 기존 이벤트 제거 후 재등록
|
||||
_tabulGrid.off("renderComplete");
|
||||
_tabulGrid.on("renderComplete", function(){
|
||||
fn_calculateTotalFromGrid();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 그리드에 표시된 데이터의 원화총액 합계 계산
|
||||
function fn_calculateTotalFromGrid(){
|
||||
if(!_tabulGrid) {
|
||||
console.log("⚠️ [주문서관리] 그리드가 초기화되지 않음");
|
||||
$("#totalAmount").text("0");
|
||||
return;
|
||||
}
|
||||
|
||||
// 현재 그리드에 표시된 데이터만 가져오기
|
||||
var data = _tabulGrid.getData();
|
||||
var totalAmountKRW = 0;
|
||||
|
||||
console.log("🔍 [주문서관리] 표시된 데이터 개수:", data.length);
|
||||
|
||||
if(data.length > 0) {
|
||||
// ORDER_TOTAL_AMOUNT_KRW 합산
|
||||
data.forEach(function(row) {
|
||||
var amountKRW = parseFloat(row.ORDER_TOTAL_AMOUNT_KRW || 0);
|
||||
totalAmountKRW += amountKRW;
|
||||
});
|
||||
}
|
||||
|
||||
console.log("✅ [주문서관리] 표시된 데이터 합계:", totalAmountKRW);
|
||||
$("#totalAmount").text(Number(totalAmountKRW).toLocaleString());
|
||||
}
|
||||
|
||||
function _fnc_datepick(){
|
||||
@@ -716,23 +706,17 @@ function openProjectFormPopUp(objId){
|
||||
<input type="text" name="due_end_date" id="due_end_date" style="width:90px;" autocomplete="off" value="${param.due_end_date}" class="date_icon">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Total 합계 표시 영역 -->
|
||||
<div style="padding: 3px 10px; background: #f5f5f5; border-radius: 3px; margin: 10px 0;">
|
||||
<span style="font-weight: bold; font-size: 12px; margin-right: 20px;">
|
||||
Total 공급가액: <span id="totalSupplyPrice" style="color: #2196F3;">0</span> 원
|
||||
</span>
|
||||
<span style="font-weight: bold; font-size: 12px; margin-right: 20px;">
|
||||
Total 부가세: <span id="totalVat" style="color: #FF9800;">0</span> 원
|
||||
</span>
|
||||
<span style="font-weight: bold; font-size: 12px;">
|
||||
Total 총액: <span id="totalAmount" style="color: #4CAF50;">0</span> 원
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<%@include file= "/WEB-INF/view/common/common_gridArea.jsp" %>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Total 합계 표시 영역 (그리드 위) -->
|
||||
<div style="padding:5px 10px; background: #f5f5f5;">
|
||||
<span style="font-weight: bold; font-size: 13px;">
|
||||
수주 금액 : <span id="totalAmount" style="color: #4CAF50;">0</span> 원
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<%@include file= "/WEB-INF/view/common/common_gridArea.jsp" %>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -53,6 +53,11 @@
|
||||
$("#btnBulkRegister").click(function(){
|
||||
fn_bulkRegister();
|
||||
});
|
||||
|
||||
// 거래명세서 출력 버튼
|
||||
$("#btnTransactionStatement").click(function(){
|
||||
fn_printTransactionStatement();
|
||||
});
|
||||
});
|
||||
|
||||
// 날짜 선택기 초기화 함수
|
||||
@@ -125,6 +130,58 @@
|
||||
fn_centerPopup(popup_width, popup_height, url);
|
||||
}
|
||||
|
||||
// 그리드 데이터를 전달하는 판매등록 팝업
|
||||
function fn_openSaleRegPopupWithData(rowData){
|
||||
console.log("=== fn_openSaleRegPopupWithData 호출 ===");
|
||||
console.log("rowData:", rowData);
|
||||
|
||||
var popup_width = 850;
|
||||
var popup_height = 550;
|
||||
|
||||
// 기본 파라미터만 전달 (orderNo, saleNo)
|
||||
// 잔량 계산은 Controller에서 자동으로 처리됨
|
||||
var params = "orderNo=" + encodeURIComponent(rowData.PROJECT_NO);
|
||||
params += "&saleNo=" + (rowData.SALE_NO ? encodeURIComponent(rowData.SALE_NO) : "");
|
||||
|
||||
// 금액 정보는 Controller에서 자동으로 불러옴 (수주 데이터 기반)
|
||||
// URL 파라미터로 전달하지 않음
|
||||
|
||||
var url = "/salesMgmt/salesRegForm.do?" + params;
|
||||
console.log("최종 URL:", url);
|
||||
fn_centerPopup(popup_width, popup_height, url);
|
||||
}
|
||||
|
||||
// 거래명세서 출력 함수
|
||||
function fn_printTransactionStatement() {
|
||||
var selectedData = _tabulGrid.getSelectedData();
|
||||
|
||||
if(selectedData.length === 0) {
|
||||
alert("거래명세서를 출력할 항목을 선택해주세요.");
|
||||
return;
|
||||
}
|
||||
|
||||
// 같은 거래처인지 확인
|
||||
var firstCustomer = selectedData[0].CUSTOMER;
|
||||
|
||||
for(var i = 1; i < selectedData.length; i++) {
|
||||
if(selectedData[i].CUSTOMER !== firstCustomer) {
|
||||
alert("같은 거래처만 선택 가능합니다.\n선택한 거래처: " + firstCustomer + ", " + selectedData[i].CUSTOMER);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 프로젝트 번호들을 수집
|
||||
var projectNos = selectedData.map(function(row) {
|
||||
return row.PROJECT_NO;
|
||||
}).join(',');
|
||||
|
||||
// 새로 만든 거래명세서 팝업 열기
|
||||
var popup_width = 1000;
|
||||
var popup_height = 800;
|
||||
var url = "/salesMgmt/transactionStatementForm.do?projectNos=" + encodeURIComponent(projectNos);
|
||||
fn_centerPopup(popup_width, popup_height, url);
|
||||
}
|
||||
|
||||
function fn_FileRegist(objId, docType, docTypeName){
|
||||
var popup_width = 800;
|
||||
var popup_height = 680;
|
||||
@@ -163,11 +220,39 @@ var columns = [
|
||||
{headerHozAlign : 'center', hozAlign : 'center', width : '100', title : '발주일', field : 'ORDER_DATE'},
|
||||
{headerHozAlign : 'center', hozAlign : 'center', width : '120', title : '발주번호', field : 'PO_NO'},
|
||||
{headerHozAlign : 'center', hozAlign : 'center', width : '100', title : '요청납기', field : 'REQUEST_DATE'},
|
||||
{headerHozAlign : 'center', hozAlign : 'center', width : '100', title : '출하일', field : 'SHIPPING_DATE'},
|
||||
{headerHozAlign : 'center', hozAlign : 'center', width : '100', title : '출하일', field : 'SHIPPING_DATE',
|
||||
cellClick: function(e, cell) {
|
||||
var projectNo = cell.getRow().getData().PROJECT_NO;
|
||||
if(projectNo) {
|
||||
fn_openShippingDetail(projectNo);
|
||||
}
|
||||
}
|
||||
},
|
||||
{headerHozAlign : 'center', hozAlign : 'left', width : '150', title : '고객사', field : 'CUSTOMER'},
|
||||
{headerHozAlign : 'center', hozAlign : 'left', width : '180', title : '품명', field : 'PRODUCT_NAME'},
|
||||
{headerHozAlign : 'center', hozAlign : 'right', width : '100', title : '견적수량', field : 'ESTIMATE_QUANTITY',
|
||||
formatter: function(cell) {
|
||||
var value = cell.getValue();
|
||||
if(!value || value === '' || value === '0') return '';
|
||||
// "X 외 Y건" 형식인지 확인
|
||||
if(typeof value === 'string' && value.includes('외')) {
|
||||
return value;
|
||||
}
|
||||
// 숫자인 경우 포맷팅
|
||||
return Number(value).toLocaleString();
|
||||
}
|
||||
},
|
||||
{headerHozAlign : 'center', hozAlign : 'right', width : '100', title : '수주수량', field : 'ORDER_QUANTITY',
|
||||
formatter: "money", formatterParams: {thousand: ",", symbolAfter: "", precision: false}
|
||||
formatter: function(cell) {
|
||||
var value = cell.getValue();
|
||||
if(!value || value === '' || value === '0') return '';
|
||||
// "X 외 Y건" 형식인지 확인
|
||||
if(typeof value === 'string' && value.includes('외')) {
|
||||
return value;
|
||||
}
|
||||
// 숫자인 경우 포맷팅
|
||||
return Number(value).toLocaleString();
|
||||
}
|
||||
},
|
||||
{headerHozAlign : 'center', hozAlign : 'right', width : '100', title : '판매수량', field : 'SALES_QUANTITY',
|
||||
formatter: "money", formatterParams: {thousand: ",", symbolAfter: "", precision: false}
|
||||
@@ -294,6 +379,23 @@ function fn_search(){
|
||||
});
|
||||
}
|
||||
|
||||
// 출하일 상세 내역 팝업
|
||||
function fn_openShippingDetail(projectNo) {
|
||||
console.log("=== fn_openShippingDetail 호출 ===");
|
||||
console.log("전달받은 projectNo:", projectNo);
|
||||
console.log("projectNo 타입:", typeof projectNo);
|
||||
|
||||
if(!projectNo) {
|
||||
alert("프로젝트 번호가 없습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
var url = "/salesMgmt/shippingDetailPopup.do?projectNo=" + encodeURIComponent(projectNo);
|
||||
console.log("팝업 URL:", url);
|
||||
|
||||
window.open(url, "shippingDetailPopup", "width=800,height=600,scrollbars=yes,resizable=yes");
|
||||
}
|
||||
|
||||
// 출하지시/판매등록 함수 (1건만 선택 가능)
|
||||
function fn_bulkRegister(){
|
||||
if(!_tabulGrid){
|
||||
@@ -318,8 +420,8 @@ function fn_bulkRegister(){
|
||||
// 선택한 1건의 항목 가져오기
|
||||
var selectedRow = selectedRows[0];
|
||||
|
||||
// 판매등록 팝업 열기
|
||||
fn_openSaleRegPopup(selectedRow.PROJECT_NO, selectedRow.SALE_NO);
|
||||
// 판매등록 팝업 열기 (그리드 데이터 전달)
|
||||
fn_openSaleRegPopupWithData(selectedRow);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
@@ -335,6 +437,7 @@ function fn_bulkRegister(){
|
||||
</h2>
|
||||
<div class="btnArea">
|
||||
<input type="button" value="조회" class="plm_btns" id="btnSearch">
|
||||
<input type="button" value="거래명세서 출력" class="plm_btns" id="btnTransactionStatement" style="background-color: #2196F3; color: white;">
|
||||
<input type="button" value="출하지시/판매등록" class="plm_btns" id="btnBulkRegister" style="background-color: #4CAF50; color: white;">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
<%@ page import="com.pms.common.utils.*"%>
|
||||
<%@ page import="java.util.*"%>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
||||
<%@include file="/init_new.jsp"%>
|
||||
<%
|
||||
PersonBean person = (PersonBean) session.getAttribute(Constants.PERSON_BEAN);
|
||||
@@ -19,6 +21,15 @@
|
||||
var snCounter = 1;
|
||||
|
||||
$(function() {
|
||||
console.log("=== salesRegForm.jsp 로드 ===");
|
||||
console.log("SALES_QUANTITY: ${saleInfo.SALES_QUANTITY}");
|
||||
console.log("SALES_UNIT_PRICE: ${saleInfo.SALES_UNIT_PRICE}");
|
||||
console.log("SALES_SUPPLY_PRICE: ${saleInfo.SALES_SUPPLY_PRICE}");
|
||||
console.log("SALES_VAT: ${saleInfo.SALES_VAT}");
|
||||
console.log("SALES_TOTAL_AMOUNT: ${saleInfo.SALES_TOTAL_AMOUNT}");
|
||||
console.log("SALES_CURRENCY: ${saleInfo.SALES_CURRENCY}");
|
||||
console.log("SALES_EXCHANGE_RATE: ${saleInfo.SALES_EXCHANGE_RATE}");
|
||||
|
||||
$('.select2').select2();
|
||||
|
||||
// 날짜 선택기 초기화
|
||||
@@ -33,18 +44,6 @@
|
||||
// 판매환종 초기값 설정 (견적환종과 동기화)
|
||||
initializeSalesCurrency();
|
||||
|
||||
// 페이지 로드 시 금액 자동 계산 (수주 데이터가 있을 때)
|
||||
setTimeout(function() {
|
||||
var quantity = parseFloat($("#salesQuantity").val()) || 0;
|
||||
var unitPrice = parseFloat($("#salesUnitPrice").val()) || 0;
|
||||
|
||||
// 수주 데이터가 있으면 자동 계산
|
||||
if(quantity > 0 || unitPrice > 0) {
|
||||
fn_calculateSupplyPrice();
|
||||
console.log("페이지 로드 시 금액 자동 계산 완료");
|
||||
}
|
||||
}, 500);
|
||||
|
||||
// S/N 필드 클릭 이벤트
|
||||
$("#serialNo").click(function() {
|
||||
fn_openSnManagePopup();
|
||||
@@ -75,13 +74,77 @@
|
||||
self.close();
|
||||
});
|
||||
|
||||
// 저장 버튼
|
||||
$("#btnSave").click(function() {
|
||||
fn_save();
|
||||
});
|
||||
// 저장 버튼
|
||||
$("#btnSave").click(function() {
|
||||
fn_save();
|
||||
});
|
||||
|
||||
// 품목이 여러 개인 경우 자동으로 첫 번째 품목 선택 - 주석처리: 품목은 하나만 존재
|
||||
/*
|
||||
if($(".item-radio").length > 0) {
|
||||
$(".item-radio").first().prop("checked", true);
|
||||
fn_calculateSelectedItem();
|
||||
}
|
||||
*/
|
||||
});
|
||||
|
||||
// 판매공급가액 계산 함수
|
||||
// === Phase 2: 품목 선택 관련 함수 (단일 선택) - 주석처리: 품목은 하나만 존재 ===
|
||||
/*
|
||||
// 행 클릭 시 라디오 버튼 선택
|
||||
function fn_selectItem(itemObjid) {
|
||||
$(".item-radio[value='" + itemObjid + "']").prop("checked", true);
|
||||
fn_calculateSelectedItem();
|
||||
}
|
||||
|
||||
// 선택한 품목의 정보를 입력 필드에 반영
|
||||
function fn_calculateSelectedItem() {
|
||||
var selectedRadio = $(".item-radio:checked");
|
||||
|
||||
if(selectedRadio.length === 0) {
|
||||
$("#selectedItemInfo").text("품목을 선택하세요");
|
||||
return;
|
||||
}
|
||||
|
||||
var quantity = parseFloat(selectedRadio.data("quantity")) || 0;
|
||||
var unitPrice = parseFloat(selectedRadio.data("unit-price")) || 0;
|
||||
var supplyPrice = parseFloat(selectedRadio.data("supply-price")) || 0;
|
||||
var vat = parseFloat(selectedRadio.data("vat")) || 0;
|
||||
var totalAmount = parseFloat(selectedRadio.data("total")) || 0;
|
||||
|
||||
// 선택한 품목 정보 표시
|
||||
var itemObjid = selectedRadio.val();
|
||||
var itemRow = $("tr[data-item-objid='" + itemObjid + "']");
|
||||
var partNo = itemRow.find("td:eq(1)").text().trim();
|
||||
var partName = itemRow.find("td:eq(2)").text().trim();
|
||||
|
||||
$("#selectedItemInfo").html(
|
||||
"<strong>" + partName + "</strong> (" + partNo + ") - " +
|
||||
"수량: <strong>" + quantity.toLocaleString() + "</strong>개 | " +
|
||||
"공급가액: <strong>" + supplyPrice.toLocaleString() + "</strong>원"
|
||||
);
|
||||
|
||||
// 입력 필드에 자동 반영
|
||||
$("#salesQuantity").val(quantity);
|
||||
$("#salesUnitPrice").val(unitPrice);
|
||||
$("#salesSupplyPrice").val(supplyPrice);
|
||||
$("#salesVat").val(vat);
|
||||
$("#salesTotalAmount").val(totalAmount);
|
||||
|
||||
// hidden 필드에 선택한 품목 OBJID 저장
|
||||
if($("#selectedItemObjid").length === 0) {
|
||||
$("<input>").attr({
|
||||
type: "hidden",
|
||||
id: "selectedItemObjid",
|
||||
name: "selectedItemObjid"
|
||||
}).appendTo("form");
|
||||
}
|
||||
$("#selectedItemObjid").val(itemObjid);
|
||||
}
|
||||
*/
|
||||
|
||||
// === 기존 함수들 ===
|
||||
|
||||
// 판매공급가액 계산 함수
|
||||
function fn_calculateSupplyPrice() {
|
||||
var currency = $("#salesCurrency").val();
|
||||
var exchangeRate = parseFloat($("#salesExchangeRate").val()) || 1;
|
||||
@@ -120,6 +183,7 @@
|
||||
|
||||
// 판매환종 초기값 설정 (견적환종과 동기화하되, 사용자가 변경 가능)
|
||||
function initializeSalesCurrency() {
|
||||
// Controller에서 계산한 값 사용 (잔량 기반)
|
||||
var existingSalesCurrency = "${saleInfo.SALES_CURRENCY}";
|
||||
var contractCurrency = "${orderInfo.SALES_CURRENCY}"; // 견적환종 (SALES_CURRENCY로 통일)
|
||||
var contractExchangeRate = "${orderInfo.SALES_EXCHANGE_RATE}"; // 견적환율
|
||||
@@ -511,23 +575,78 @@
|
||||
}
|
||||
console.log("=== S/N 처리 완료 ===");
|
||||
|
||||
if (confirm("저장하시겠습니까?")) {
|
||||
if (confirm("저장하시겠습니까?")) {
|
||||
$.ajax({
|
||||
url : "/salesMgmt/saveSales.do",
|
||||
type : "POST",
|
||||
data : $("#form1").serialize(),
|
||||
dataType : "json",
|
||||
success : function(data) {
|
||||
alert(data.msg);
|
||||
|
||||
// 저장 후 잔량 확인을 위해 서버에 다시 조회
|
||||
$.ajax({
|
||||
url : "/salesMgmt/saveSales.do",
|
||||
type : "POST",
|
||||
data : $("#form1").serialize(),
|
||||
dataType : "json",
|
||||
success : function(data) {
|
||||
alert(data.msg);
|
||||
url: "/salesMgmt/salesRegForm.do",
|
||||
type: "GET",
|
||||
data: { orderNo: "${param.orderNo}" },
|
||||
dataType: "html",
|
||||
success: function(response) {
|
||||
// 응답에서 SALES_QUANTITY 추출 (잔량)
|
||||
var match = response.match(/SALES_QUANTITY:\s*(\d+)/);
|
||||
var remainingQuantity = match ? parseInt(match[1]) : 0;
|
||||
|
||||
console.log("서버에서 계산한 잔량:", remainingQuantity);
|
||||
|
||||
if(remainingQuantity > 0) {
|
||||
if(confirm("잔량 " + remainingQuantity + "개가 남았습니다. 계속 등록하시겠습니까?")) {
|
||||
// 부모 창 새로고침 후 팝업 새로고침
|
||||
if(opener && opener.fn_search) {
|
||||
console.log("분할 출하 계속 - 부모 창 fn_search 호출");
|
||||
opener.fn_search();
|
||||
}
|
||||
// 팝업 새로고침 (잔량으로 수량 자동 설정)
|
||||
location.reload();
|
||||
} else {
|
||||
// 목록 새로고침 후 팝업 닫기
|
||||
console.log("분할 출하 중단 - 팝업 닫기");
|
||||
if(opener && opener.fn_search) {
|
||||
console.log("부모 창 fn_search 호출");
|
||||
opener.fn_search();
|
||||
} else {
|
||||
console.log("부모 창 fn_search 없음!");
|
||||
}
|
||||
self.close();
|
||||
}
|
||||
} else {
|
||||
// 목록 새로고침 후 팝업 닫기
|
||||
console.log("잔량 없음 - 팝업 닫기");
|
||||
if(opener && opener.fn_search) {
|
||||
console.log("부모 창 fn_search 호출");
|
||||
opener.fn_search();
|
||||
} else {
|
||||
console.log("부모 창 fn_search 없음!");
|
||||
}
|
||||
self.close();
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
// 에러 시 그냥 팝업 닫기
|
||||
if(opener && opener.fn_search) {
|
||||
opener.fn_search();
|
||||
}
|
||||
self.close();
|
||||
},
|
||||
error : function(jqxhr, status, error) {
|
||||
alert("저장 중 오류가 발생했습니다.");
|
||||
}
|
||||
});
|
||||
},
|
||||
error : function(jqxhr, status, error) {
|
||||
console.log("=== AJAX 에러 ===");
|
||||
console.log("status:", status);
|
||||
console.log("error:", error);
|
||||
console.log("responseText:", jqxhr.responseText);
|
||||
console.log("status code:", jqxhr.status);
|
||||
alert("저장 중 오류가 발생했습니다.\n상태: " + status + "\n에러: " + error);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -609,6 +728,67 @@
|
||||
<col width="35%" />
|
||||
</colgroup>
|
||||
|
||||
<!-- 품목 선택 영역 (Phase 2) - 주석처리: 품목은 하나만 존재 -->
|
||||
<%--
|
||||
<c:if test="${not empty projectItems and fn:length(projectItems) > 1}">
|
||||
<tr>
|
||||
<td colspan="4" style="padding:10px;">
|
||||
<div style="border:1px solid #ddd; padding:10px; background:#f9f9f9;">
|
||||
<strong style="display:block; margin-bottom:8px;">📦 품목 선택 (${fn:length(projectItems)}개) - 하나만 선택 가능</strong>
|
||||
<table style="width:100%; border-collapse:collapse;">
|
||||
<thead>
|
||||
<tr style="background:#e9ecef; border-bottom:2px solid #dee2e6;">
|
||||
<th style="padding:8px; text-align:center; width:50px;">선택</th>
|
||||
<th style="padding:8px; text-align:left;">품번</th>
|
||||
<th style="padding:8px; text-align:left;">품명</th>
|
||||
<th style="padding:8px; text-align:right;">수량</th>
|
||||
<th style="padding:8px; text-align:right;">단가</th>
|
||||
<th style="padding:8px; text-align:right;">공급가액</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="itemListBody">
|
||||
<c:forEach var="item" items="${projectItems}" varStatus="status">
|
||||
<tr style="border-bottom:1px solid #dee2e6; cursor:pointer;"
|
||||
data-item-objid="${item.ITEM_OBJID}"
|
||||
onclick="fn_selectItem('${item.ITEM_OBJID}')">
|
||||
<td style="padding:8px; text-align:center;">
|
||||
<input type="radio" name="selectedItem" class="item-radio"
|
||||
value="${item.ITEM_OBJID}"
|
||||
data-objid="${item.ITEM_OBJID}"
|
||||
data-quantity="${item.QUANTITY}"
|
||||
data-unit-price="${item.UNIT_PRICE}"
|
||||
data-supply-price="${item.SUPPLY_PRICE}"
|
||||
data-vat="${item.VAT}"
|
||||
data-total="${item.TOTAL_AMOUNT}"
|
||||
onchange="fn_calculateSelectedItem()" />
|
||||
</td>
|
||||
<td style="padding:8px;">${item.PART_NO}</td>
|
||||
<td style="padding:8px;">${item.PART_NAME}</td>
|
||||
<td style="padding:8px; text-align:right;">
|
||||
<fmt:formatNumber value="${item.QUANTITY}" pattern="#,##0" />
|
||||
</td>
|
||||
<td style="padding:8px; text-align:right;">
|
||||
<fmt:formatNumber value="${item.UNIT_PRICE}" pattern="#,##0" />
|
||||
</td>
|
||||
<td style="padding:8px; text-align:right;">
|
||||
<fmt:formatNumber value="${item.SUPPLY_PRICE}" pattern="#,##0" />
|
||||
</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
<div style="margin-top:10px; padding:8px; background:#d1ecf1; border:1px solid #0c5460; border-radius:4px;">
|
||||
<strong>💡 선택한 품목:</strong>
|
||||
<span id="selectedItemInfo" style="margin-left:10px; color:#0c5460;">
|
||||
품목을 선택하세요
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</c:if>
|
||||
--%>
|
||||
|
||||
<!-- 첫번째 행: S/N -->
|
||||
<tr>
|
||||
<td class="input_title"><label for="serialNo">S/N</label></td>
|
||||
@@ -621,11 +801,19 @@
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- 두번째 행: 판매수량, 출하일 -->
|
||||
<!-- 두번째 행: 판매수량 (잔량 자동 표시), 출하일 -->
|
||||
<tr>
|
||||
<td class="input_title"><label for="salesQuantity">판매수량</label></td>
|
||||
<td class="input_title">
|
||||
<label for="salesQuantity">판매수량</label>
|
||||
<span style="color:#666; font-size:11px; display:block; margin-top:2px;">
|
||||
(잔량: ${saleInfo.SALES_QUANTITY}개)
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" name="salesQuantity" id="salesQuantity" value="${saleInfo.SALES_QUANTITY}" onchange="fn_calculateSupplyPrice()" />
|
||||
<input type="number" name="salesQuantity" id="salesQuantity"
|
||||
value="${saleInfo.SALES_QUANTITY}"
|
||||
onchange="fn_calculateSupplyPrice()"
|
||||
placeholder="판매할 수량 입력" />
|
||||
</td>
|
||||
<td class="input_title"><label for="shippingDate">출하일</label></td>
|
||||
<td>
|
||||
@@ -681,11 +869,15 @@
|
||||
<tr>
|
||||
<td class="input_title"><label for="salesUnitPrice">판매단가</label></td>
|
||||
<td>
|
||||
<input type="number" name="salesUnitPrice" id="salesUnitPrice" value="${saleInfo.SALES_UNIT_PRICE}" onchange="fn_calculateSupplyPrice()" />
|
||||
<input type="number" name="salesUnitPrice" id="salesUnitPrice"
|
||||
value="${saleInfo.SALES_UNIT_PRICE}"
|
||||
onchange="fn_calculateSupplyPrice()" />
|
||||
</td>
|
||||
<td class="input_title"><label for="salesSupplyPrice">판매공급가액</label></td>
|
||||
<td>
|
||||
<input type="number" name="salesSupplyPrice" id="salesSupplyPrice" value="${saleInfo.SALES_SUPPLY_PRICE}" readonly style="background-color:#f5f5f5;" />
|
||||
<input type="number" name="salesSupplyPrice" id="salesSupplyPrice"
|
||||
value="${saleInfo.SALES_SUPPLY_PRICE}"
|
||||
readonly style="background-color:#f5f5f5;" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -693,11 +885,15 @@
|
||||
<tr>
|
||||
<td class="input_title"><label for="salesVat">판매부가세</label></td>
|
||||
<td>
|
||||
<input type="number" name="salesVat" id="salesVat" value="${saleInfo.SALES_VAT}" onchange="fn_calculateTotalAmount()" />
|
||||
<input type="number" name="salesVat" id="salesVat"
|
||||
value="${saleInfo.SALES_VAT}"
|
||||
readonly style="background-color:#f5f5f5;" />
|
||||
</td>
|
||||
<td class="input_title"><label for="salesTotalAmount">판매총액</label></td>
|
||||
<td>
|
||||
<input type="number" name="salesTotalAmount" id="salesTotalAmount" value="${saleInfo.SALES_TOTAL_AMOUNT}" readonly style="background-color:#f5f5f5;" />
|
||||
<input type="number" name="salesTotalAmount" id="salesTotalAmount"
|
||||
value="${saleInfo.SALES_TOTAL_AMOUNT}"
|
||||
readonly style="background-color:#f5f5f5;" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -712,7 +908,9 @@
|
||||
</td>
|
||||
<td class="input_title"><label for="salesExchangeRate">판매환율</label></td>
|
||||
<td>
|
||||
<input type="number" name="salesExchangeRate" id="salesExchangeRate" step="0.01" value="${saleInfo.SALES_EXCHANGE_RATE}" onchange="fn_recalculateByExchangeRate()" />
|
||||
<input type="number" name="salesExchangeRate" id="salesExchangeRate" step="0.01"
|
||||
value="${saleInfo.SALES_EXCHANGE_RATE}"
|
||||
onchange="fn_recalculateByExchangeRate()" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>출하일 상세 내역</title>
|
||||
<link rel="stylesheet" href="/css/basic.css">
|
||||
<script src="/js/jquery-2.1.4.min.js"></script>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 20px;
|
||||
font-family: 'Malgun Gothic', sans-serif;
|
||||
}
|
||||
.popup-header {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 20px;
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 2px solid #333;
|
||||
}
|
||||
.shipping-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.shipping-table th {
|
||||
background-color: #f5f5f5;
|
||||
padding: 10px;
|
||||
border: 1px solid #ddd;
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
}
|
||||
.shipping-table td {
|
||||
padding: 10px;
|
||||
border: 1px solid #ddd;
|
||||
text-align: center;
|
||||
}
|
||||
.btn-close {
|
||||
padding: 8px 20px;
|
||||
background-color: #666;
|
||||
color: white;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
}
|
||||
.btn-close:hover {
|
||||
background-color: #444;
|
||||
}
|
||||
.btn-wrap {
|
||||
text-align: center;
|
||||
margin-top: 20px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="popup-header">
|
||||
출하일 상세 내역 - ${projectNo}
|
||||
</div>
|
||||
|
||||
<table class="shipping-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>출하일</th>
|
||||
<th>출하수량</th>
|
||||
<th>출하지시상태</th>
|
||||
<th>S/N</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:choose>
|
||||
<c:when test="${empty shippingList}">
|
||||
<tr>
|
||||
<td colspan="4">출하 내역이 없습니다.</td>
|
||||
</tr>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<c:forEach items="${shippingList}" var="item">
|
||||
<tr>
|
||||
<td>${item.shipping_date}</td>
|
||||
<td>${item.shipping_quantity}</td>
|
||||
<td>${item.shipping_order_status}</td>
|
||||
<td>${item.serial_no}</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="btn-wrap">
|
||||
<button type="button" class="btn-close" onclick="window.close();">닫기</button>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,674 @@
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
||||
<%@ page import="com.pms.common.utils.*"%>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@include file= "/init.jsp" %>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>거래명세서</title>
|
||||
<style>
|
||||
@media print {
|
||||
.no-print { display: none !important; }
|
||||
@page { margin: 5mm; }
|
||||
}
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: "맑은 고딕", "Malgun Gothic", sans-serif;
|
||||
font-size: 11pt;
|
||||
line-height: 1.4;
|
||||
padding: 10px;
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
.container {
|
||||
width: 210mm;
|
||||
min-height: 297mm;
|
||||
margin: 0 auto;
|
||||
border: 2px solid #000;
|
||||
background-color: white;
|
||||
box-shadow: 0 0 10px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
/* 제목 */
|
||||
.header {
|
||||
text-align: center;
|
||||
font-size: 24pt;
|
||||
font-weight: bold;
|
||||
padding: 15px 0;
|
||||
border-bottom: 2px solid #000;
|
||||
letter-spacing: 8px;
|
||||
}
|
||||
|
||||
/* 상단 정보 테이블 */
|
||||
.info-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.info-table td {
|
||||
border: 1px solid #000;
|
||||
padding: 6px 10px;
|
||||
font-size: 9pt;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.row-1 td, .row-2 td, .row-3 td, .row-4 td, .row-5 td {
|
||||
height: 30px;
|
||||
}
|
||||
|
||||
.date-cell {
|
||||
text-align: left;
|
||||
width: 30%;
|
||||
padding: 8px 12px;
|
||||
}
|
||||
|
||||
.date-label {
|
||||
font-weight: bold;
|
||||
margin-right: 6px;
|
||||
font-size: 9pt;
|
||||
}
|
||||
|
||||
.reg-label-cell {
|
||||
background-color: #e8e8e8;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
width: 15%;
|
||||
font-size: 9pt;
|
||||
}
|
||||
|
||||
.reg-value-cell {
|
||||
font-size: 13pt;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
width: 40%;
|
||||
}
|
||||
|
||||
.stamp-cell {
|
||||
width: 15%;
|
||||
text-align: center;
|
||||
padding: 5px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.stamp-box {
|
||||
width: 70px;
|
||||
height: 140px;
|
||||
border: 1px solid #666;
|
||||
display: inline-flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 9pt;
|
||||
color: #333;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.receiver-cell {
|
||||
text-align: left;
|
||||
padding: 8px 12px;
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
.receiver-name {
|
||||
font-size: 13pt;
|
||||
font-weight: bold;
|
||||
display: inline;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.receiver-suffix {
|
||||
font-size: 12pt;
|
||||
font-weight: bold;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.supplier-label-cell {
|
||||
background-color: #e8e8e8;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
width: 30px;
|
||||
line-height: 1.5;
|
||||
font-size: 10pt;
|
||||
padding: 4px 2px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.supplier-row-1, .supplier-row-2, .supplier-row-3, .supplier-row-4 {
|
||||
text-align: left;
|
||||
font-size: 9pt;
|
||||
padding: 6px 10px;
|
||||
}
|
||||
|
||||
.supplier-inline {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.supplier-label-inline {
|
||||
font-weight: bold;
|
||||
margin-right: 8px;
|
||||
font-size: 8pt;
|
||||
}
|
||||
|
||||
.supply-text-cell {
|
||||
text-align: left;
|
||||
font-size: 9pt;
|
||||
padding: 8px 12px;
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
/* 합계 금액 */
|
||||
.amount-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 8px 15px;
|
||||
border-bottom: 2px solid #000;
|
||||
background-color: #f9f9f9;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.amount-label {
|
||||
font-size: 10pt;
|
||||
margin-right: 15px;
|
||||
}
|
||||
|
||||
.amount-text {
|
||||
font-size: 13pt;
|
||||
font-weight: bold;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.amount-won-symbol {
|
||||
font-size: 16pt;
|
||||
font-weight: bold;
|
||||
margin: 0 10px;
|
||||
}
|
||||
|
||||
.amount-number {
|
||||
font-size: 15pt;
|
||||
font-weight: bold;
|
||||
flex: 1;
|
||||
text-align: right;
|
||||
padding-right: 15px;
|
||||
}
|
||||
|
||||
/* 품목 테이블 */
|
||||
.items-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.items-table th,
|
||||
.items-table td {
|
||||
border: 1px solid #000;
|
||||
padding: 5px 8px;
|
||||
font-size: 9pt;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.items-table th {
|
||||
background-color: #e8e8e8;
|
||||
font-weight: bold;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.items-table td {
|
||||
height: 28px;
|
||||
}
|
||||
|
||||
.items-table td[contenteditable="true"] {
|
||||
background-color: #fffef0;
|
||||
cursor: text;
|
||||
}
|
||||
|
||||
.text-left {
|
||||
text-align: left !important;
|
||||
padding-left: 10px !important;
|
||||
}
|
||||
|
||||
.text-right {
|
||||
text-align: right !important;
|
||||
padding-right: 10px !important;
|
||||
}
|
||||
|
||||
.total-row {
|
||||
background-color: #e8e8e8;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* 비고 */
|
||||
.note-section {
|
||||
border-top: 1px solid #000;
|
||||
padding: 10px 15px;
|
||||
min-height: 90px;
|
||||
}
|
||||
|
||||
.note-title {
|
||||
font-weight: bold;
|
||||
font-size: 9pt;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.note-content {
|
||||
padding: 3px;
|
||||
min-height: 60px;
|
||||
font-size: 9pt;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.note-content[contenteditable="true"] {
|
||||
background-color: #fffef0;
|
||||
cursor: text;
|
||||
}
|
||||
|
||||
/* 하단 */
|
||||
.footer-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.footer-table td {
|
||||
border: 1px solid #000;
|
||||
padding: 12px 15px;
|
||||
width: 50%;
|
||||
vertical-align: top;
|
||||
height: 90px;
|
||||
}
|
||||
|
||||
.footer-label {
|
||||
font-weight: bold;
|
||||
font-size: 10pt;
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
|
||||
.footer-sign {
|
||||
text-align: right;
|
||||
font-size: 10pt;
|
||||
}
|
||||
|
||||
/* 버튼 */
|
||||
.button-area {
|
||||
text-align: center;
|
||||
margin: 15px 0;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 10px 30px;
|
||||
margin: 0 5px;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.btn-print {
|
||||
background-color: #2196F3;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-close {
|
||||
background-color: #f44336;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
var today = new Date();
|
||||
var days = ['일', '월', '화', '수', '목', '금', '토'];
|
||||
var dateStr = days[today.getDay()] + "요일, " + (today.getMonth() + 1) + "월 " + today.getDate() + ", " + today.getFullYear();
|
||||
$("#deliveryDate").text(dateStr);
|
||||
fn_loadData();
|
||||
});
|
||||
|
||||
function fn_loadData() {
|
||||
var projectNos = "${param.projectNos}";
|
||||
console.log("=== 거래명세서 데이터 로드 ===");
|
||||
console.log("프로젝트 번호:", projectNos);
|
||||
|
||||
if(!projectNos || projectNos === "") {
|
||||
alert("프로젝트 번호가 없습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "/salesMgmt/getTransactionStatementData.do",
|
||||
type: "POST",
|
||||
data: { projectNos: projectNos },
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
console.log("=== 서버 응답 데이터 ===");
|
||||
console.log("전체 데이터:", JSON.stringify(data, null, 2));
|
||||
console.log("success:", data.success);
|
||||
console.log("customerName:", data.customerName);
|
||||
console.log("items:", data.items);
|
||||
console.log("supplierName:", data.supplierName);
|
||||
|
||||
if(data && data.success) {
|
||||
fn_fillData(data);
|
||||
} else {
|
||||
alert("데이터 조회 실패: " + (data.message || "알 수 없는 오류"));
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.log("=== AJAX 에러 ===");
|
||||
console.log("status:", status);
|
||||
console.log("error:", error);
|
||||
console.log("responseText:", xhr.responseText);
|
||||
alert("데이터 조회 중 오류 발생");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function fn_fillData(data) {
|
||||
console.log("=== fn_fillData 호출 ===");
|
||||
console.log("customerName:", data.customerName);
|
||||
console.log("items:", data.items);
|
||||
|
||||
// 수신자 정보
|
||||
if(data.customerName) {
|
||||
$("#receiverName").text(data.customerName);
|
||||
}
|
||||
|
||||
// 공급자 정보
|
||||
if(data.supplierRegNo) {
|
||||
$("#registrationNo").text(data.supplierRegNo);
|
||||
}
|
||||
if(data.supplierName) {
|
||||
$("#supplierName").text(data.supplierName);
|
||||
}
|
||||
if(data.supplierAddress) {
|
||||
$("#supplierAddr").text(data.supplierAddress);
|
||||
}
|
||||
if(data.supplierBusiness) {
|
||||
$("#supplierBiz").text(data.supplierBusiness);
|
||||
}
|
||||
if(data.supplierType) {
|
||||
$("#supplierType").text(data.supplierType);
|
||||
}
|
||||
if(data.supplierContact) {
|
||||
$("#supplierTel").text(data.supplierContact);
|
||||
}
|
||||
|
||||
// 공급 텍스트
|
||||
if(data.note) {
|
||||
$("#supplyText").text(data.note);
|
||||
}
|
||||
|
||||
var totalSupply = 0;
|
||||
var totalVat = 0;
|
||||
var tbody = $("#itemsBody");
|
||||
tbody.empty();
|
||||
|
||||
if(data.items && data.items.length > 0) {
|
||||
console.log("품목 개수:", data.items.length);
|
||||
|
||||
$.each(data.items, function(i, item) {
|
||||
console.log("품목 " + (i+1) + ":", item);
|
||||
|
||||
var supply = parseInt(item.SUPPLYPRICE || item.supplyPrice || 0);
|
||||
var vat = parseInt(item.VAT || item.vat || 0);
|
||||
totalSupply += supply;
|
||||
totalVat += vat;
|
||||
|
||||
var row = $("<tr>");
|
||||
row.append($("<td contenteditable='true' class='text-left'>").text(item.PRODUCTNAME || item.productName || ""));
|
||||
row.append($("<td contenteditable='true'>").text(item.SPEC || item.spec || ""));
|
||||
row.append($("<td contenteditable='true'>").text(item.QUANTITY || item.quantity || ""));
|
||||
row.append($("<td contenteditable='true' class='text-right'>").text(fn_num(item.UNITPRICE || item.unitPrice || 0)));
|
||||
row.append($("<td contenteditable='true' class='text-right'>").text(fn_num(supply)));
|
||||
row.append($("<td contenteditable='true' class='text-right'>").text(fn_num(vat)));
|
||||
tbody.append(row);
|
||||
});
|
||||
|
||||
// 빈 행 추가 (최소 7개 행 유지)
|
||||
for(var i = data.items.length; i < 7; i++) {
|
||||
var row = $("<tr>");
|
||||
for(var j = 0; j < 6; j++) {
|
||||
row.append($("<td contenteditable='true'>").html(" "));
|
||||
}
|
||||
tbody.append(row);
|
||||
}
|
||||
} else {
|
||||
console.log("품목 데이터가 없습니다.");
|
||||
// 빈 행 7개 추가
|
||||
for(var i = 0; i < 7; i++) {
|
||||
var row = $("<tr>");
|
||||
for(var j = 0; j < 6; j++) {
|
||||
row.append($("<td contenteditable='true'>").html(" "));
|
||||
}
|
||||
tbody.append(row);
|
||||
}
|
||||
}
|
||||
|
||||
// 합계 행
|
||||
var totalRow = $("<tr class='total-row'>");
|
||||
totalRow.append($("<td colspan='2'>").text("계"));
|
||||
totalRow.append($("<td>").text(data.items ? data.items.length : 0));
|
||||
totalRow.append($("<td>").html(" "));
|
||||
totalRow.append($("<td class='text-right'>").text(fn_num(totalSupply)));
|
||||
totalRow.append($("<td class='text-right'>").text(fn_num(totalVat)));
|
||||
tbody.append(totalRow);
|
||||
|
||||
// 합계 금액
|
||||
var total = totalSupply + totalVat;
|
||||
console.log("총 공급가액:", totalSupply);
|
||||
console.log("총 세액:", totalVat);
|
||||
console.log("총 금액:", total);
|
||||
|
||||
$("#totalText").text(total.toString());
|
||||
$("#totalNum").text(fn_num(total));
|
||||
}
|
||||
|
||||
function fn_num(n) {
|
||||
return n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
||||
}
|
||||
|
||||
function fn_save() {
|
||||
if(!confirm("수정한 내용을 저장하시겠습니까?")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 수정된 데이터 수집
|
||||
var data = {
|
||||
projectNos: "${param.projectNos}",
|
||||
deliveryDate: $("#deliveryDate").text(),
|
||||
receiverName: $("#receiverName").text(),
|
||||
registrationNo: $("#registrationNo").text(),
|
||||
supplierName: $("#supplierName").text(),
|
||||
supplierAddr: $("#supplierAddr").text(),
|
||||
supplierBiz: $("#supplierBiz").text(),
|
||||
supplierType: $("#supplierType").text(),
|
||||
supplierTel: $("#supplierTel").text(),
|
||||
supplyText: $("#supplyText").text(),
|
||||
totalAmount: $("#totalText").text(),
|
||||
noteContent: $("#noteContent").text(),
|
||||
items: []
|
||||
};
|
||||
|
||||
// 품목 데이터 수집
|
||||
$("#itemsBody tr:not(.total-row)").each(function() {
|
||||
var cells = $(this).find("td");
|
||||
if(cells.length === 6) {
|
||||
var item = {
|
||||
productName: $(cells[0]).text().trim(),
|
||||
spec: $(cells[1]).text().trim(),
|
||||
quantity: $(cells[2]).text().trim(),
|
||||
unitPrice: $(cells[3]).text().trim(),
|
||||
supplyPrice: $(cells[4]).text().trim(),
|
||||
vat: $(cells[5]).text().trim()
|
||||
};
|
||||
// 빈 행이 아닌 경우만 추가
|
||||
if(item.productName || item.spec || item.quantity) {
|
||||
data.items.push(item);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: "/salesMgmt/saveTransactionStatement.do",
|
||||
type: "POST",
|
||||
data: JSON.stringify(data),
|
||||
contentType: "application/json",
|
||||
dataType: "json",
|
||||
success: function(response) {
|
||||
if(response && response.success) {
|
||||
alert("저장되었습니다.");
|
||||
} else {
|
||||
alert("저장 실패: " + (response.message || "알 수 없는 오류"));
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
alert("저장 중 오류가 발생했습니다.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function fn_print() {
|
||||
window.print();
|
||||
}
|
||||
|
||||
function fn_close() {
|
||||
window.close();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<!-- 제목 -->
|
||||
<div class="header">거래 명세서</div>
|
||||
|
||||
<!-- 상단 정보 테이블 -->
|
||||
<table class="info-table">
|
||||
<!-- 첫번째 행: 납품일 (왼쪽만) -->
|
||||
<tr class="row-1">
|
||||
<td class="date-cell" rowspan="2">
|
||||
<span class="date-label">납품일:</span>
|
||||
<span id="deliveryDate" contenteditable="true">수요일, 9월 24, 2025</span>
|
||||
</td>
|
||||
<td class="reg-label-cell">등록 번호</td>
|
||||
<td class="reg-value-cell">
|
||||
<span id="registrationNo" contenteditable="true">314-81-75146</span>
|
||||
</td>
|
||||
<td class="stamp-cell" rowspan="5">
|
||||
<div class="stamp-box">
|
||||
<div>성 명</div>
|
||||
<div contenteditable="true" style="margin-top: 3px;">이동현</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- 두번째 행 -->
|
||||
<tr class="row-2">
|
||||
<td class="supplier-label-cell" rowspan="4">공<br>급<br>자</td>
|
||||
<td class="supplier-row-1">
|
||||
<div class="supplier-inline">
|
||||
<span class="supplier-label-inline">상호(법인명)</span>
|
||||
<span contenteditable="true" id="supplierName">㈜알피에스</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- 세번째 행: 수신자 + 공급자 -->
|
||||
<tr class="row-3">
|
||||
<td class="receiver-cell" rowspan="2">
|
||||
<span class="receiver-name" contenteditable="true" id="receiverName">㈜OOO</span>
|
||||
<span class="receiver-suffix">귀하</span>
|
||||
</td>
|
||||
<td class="supplier-row-2">
|
||||
<div class="supplier-inline">
|
||||
<span class="supplier-label-inline">사업장주소</span>
|
||||
<span contenteditable="true" id="supplierAddr">대전광역시 유성구 국제과학10로 8</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- 네번째 행 -->
|
||||
<tr class="row-4">
|
||||
<td class="supplier-row-3">
|
||||
<div class="supplier-inline">
|
||||
<span class="supplier-label-inline">업 태</span>
|
||||
<span contenteditable="true" id="supplierBiz">제조</span>
|
||||
<span class="supplier-label-inline" style="margin-left: 15px;">종 목</span>
|
||||
<span contenteditable="true" id="supplierType">금속절삭가공기계의</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- 다섯번째 행 -->
|
||||
<tr class="row-5">
|
||||
<td class="supply-text-cell">
|
||||
<span contenteditable="true" id="supplyText">아래와 같이 공급합니다.</span>
|
||||
</td>
|
||||
<td class="supplier-row-4">
|
||||
<div class="supplier-inline">
|
||||
<span class="supplier-label-inline">전화 번호</span>
|
||||
<span contenteditable="true" id="supplierTel">TEL:042-602-3300/FAX:042-672</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<!-- 합계 금액 -->
|
||||
<div class="amount-row">
|
||||
<span class="amount-label">(공급가액+세액)</span>
|
||||
<span class="amount-text"><span id="totalText" contenteditable="true">3300000</span> 원정</span>
|
||||
<span class="amount-won-symbol">₩</span>
|
||||
<span class="amount-won-symbol">₩</span>
|
||||
<span class="amount-number"><span id="totalNum" contenteditable="true">3,300,000</span></span>
|
||||
</div>
|
||||
|
||||
<!-- 품목 테이블 -->
|
||||
<table class="items-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 25%;">품 명</th>
|
||||
<th style="width: 15%;">규 격</th>
|
||||
<th style="width: 10%;">수 량</th>
|
||||
<th style="width: 15%;">단 가</th>
|
||||
<th style="width: 17.5%;">공 급 가 액</th>
|
||||
<th style="width: 17.5%;">세 액</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="itemsBody">
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!-- 비고 -->
|
||||
<div class="note-section">
|
||||
<div class="note-title"><비고></div>
|
||||
<div class="note-content" contenteditable="true" id="noteContent">Spindle S/N : 187-1062, 1096, 1099</div>
|
||||
</div>
|
||||
|
||||
<!-- 하단 -->
|
||||
<table class="footer-table">
|
||||
<tr>
|
||||
<td>
|
||||
<div class="footer-label">인계확인 :</div>
|
||||
<div class="footer-sign">(인)</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="footer-label">인수확인 :</div>
|
||||
<div class="footer-sign">(인)</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- 버튼 -->
|
||||
<div class="button-area no-print">
|
||||
<button class="btn btn-print" onclick="fn_save()" style="background-color: #4CAF50;">저장</button>
|
||||
<button class="btn btn-print" onclick="fn_print()">인쇄</button>
|
||||
<button class="btn btn-close" onclick="fn_close()">닫기</button>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -269,7 +269,24 @@ public class ContractMgmtController {
|
||||
@ResponseBody
|
||||
@RequestMapping("/contractMgmt/contractGridList.do")
|
||||
public Map getProductKindSpecListPaging(HttpServletRequest request, @RequestParam Map<String, Object> paramMap){
|
||||
commonService.selectListPagingNew("contractMgmt.contractGridList", request, paramMap);
|
||||
try {
|
||||
// 페이징 데이터 조회
|
||||
commonService.selectListPagingNew("contractMgmt.contractGridList", request, paramMap);
|
||||
|
||||
// 조회된 데이터의 전체 합계 조회
|
||||
Map<String, Object> totalAmount = (Map<String, Object>) commonService.selectOne("contractMgmt.getContractGridTotalAmount", request, paramMap);
|
||||
|
||||
// 합계 데이터 추가
|
||||
if(totalAmount != null) {
|
||||
paramMap.put("TOTAL_AMOUNT_KRW", totalAmount.get("totalAmountKRW"));
|
||||
} else {
|
||||
paramMap.put("TOTAL_AMOUNT_KRW", 0);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
paramMap.put("TOTAL_AMOUNT_KRW", 0);
|
||||
}
|
||||
|
||||
return paramMap;
|
||||
}
|
||||
|
||||
@@ -2359,6 +2376,41 @@ public class ContractMgmtController {
|
||||
return paramMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 주문서관리 - Total 합계 조회
|
||||
* @param request
|
||||
* @param paramMap
|
||||
* @return
|
||||
*/
|
||||
@ResponseBody
|
||||
@RequestMapping("/contractMgmt/getOrderTotalAmount.do")
|
||||
public Map getOrderTotalAmount(HttpServletRequest request, @RequestParam Map<String, Object> paramMap){
|
||||
Map<String, Object> resultMap = new HashMap<String, Object>();
|
||||
|
||||
try {
|
||||
// Total 합계 조회
|
||||
Map<String, Object> totalData = contractMgmtService.getOrderTotalAmount(request, paramMap);
|
||||
|
||||
if(totalData != null) {
|
||||
resultMap.put("result", "success");
|
||||
resultMap.put("totalSupplyPrice", totalData.get("TOTAL_SUPPLY_PRICE"));
|
||||
resultMap.put("totalVat", totalData.get("TOTAL_VAT"));
|
||||
resultMap.put("totalAmount", totalData.get("TOTAL_AMOUNT"));
|
||||
} else {
|
||||
resultMap.put("result", "success");
|
||||
resultMap.put("totalSupplyPrice", 0);
|
||||
resultMap.put("totalVat", 0);
|
||||
resultMap.put("totalAmount", 0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
resultMap.put("result", "error");
|
||||
resultMap.put("message", e.getMessage());
|
||||
}
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 수주등록 팝업 페이지
|
||||
* @param session
|
||||
|
||||
@@ -282,11 +282,48 @@ public class SalesNcollectMgmtController {
|
||||
}
|
||||
// orderNo가 있으면 기존 판매 정보 조회
|
||||
else if(paramMap.get("orderNo") != null && !paramMap.get("orderNo").equals("")) {
|
||||
saleInfo = salesNcollectMgmtService.getSaleInfo(paramMap);
|
||||
salesCurrency = CommonUtils.nullToEmpty((String)saleInfo.get("SALES_CURRENCY"));
|
||||
System.out.println("=== salesRegForm.do 파라미터 확인 ===");
|
||||
System.out.println("orderNo: " + paramMap.get("orderNo"));
|
||||
System.out.println("salesQuantity: " + paramMap.get("salesQuantity"));
|
||||
System.out.println("salesUnitPrice: " + paramMap.get("salesUnitPrice"));
|
||||
System.out.println("salesSupplyPrice: " + paramMap.get("salesSupplyPrice"));
|
||||
System.out.println("salesVat: " + paramMap.get("salesVat"));
|
||||
System.out.println("salesTotalAmount: " + paramMap.get("salesTotalAmount"));
|
||||
System.out.println("salesCurrency: " + paramMap.get("salesCurrency"));
|
||||
System.out.println("salesExchangeRate: " + paramMap.get("salesExchangeRate"));
|
||||
|
||||
saleInfo = salesNcollectMgmtService.getSaleInfo(paramMap);
|
||||
salesCurrency = CommonUtils.nullToEmpty((String)saleInfo.get("SALES_CURRENCY"));
|
||||
|
||||
System.out.println("=== DB에서 조회한 saleInfo ===");
|
||||
System.out.println("ORDER_QUANTITY: " + saleInfo.get("ORDER_QUANTITY"));
|
||||
System.out.println("SALES_QUANTITY: " + saleInfo.get("SALES_QUANTITY"));
|
||||
System.out.println("SALES_UNIT_PRICE: " + saleInfo.get("SALES_UNIT_PRICE"));
|
||||
System.out.println("SALES_SUPPLY_PRICE: " + saleInfo.get("SALES_SUPPLY_PRICE"));
|
||||
|
||||
// URL 파라미터로 그리드 데이터가 전달된 경우 우선 사용
|
||||
if(paramMap.get("salesQuantity") != null && !paramMap.get("salesQuantity").equals("")) {
|
||||
System.out.println("=== URL 파라미터로 그리드 데이터 설정 ===");
|
||||
if(saleInfo == null) saleInfo = new HashMap<String, Object>();
|
||||
|
||||
saleInfo.put("SALES_UNIT_PRICE", paramMap.get("salesUnitPrice"));
|
||||
saleInfo.put("SALES_SUPPLY_PRICE", paramMap.get("salesSupplyPrice"));
|
||||
saleInfo.put("SALES_VAT", paramMap.get("salesVat"));
|
||||
saleInfo.put("SALES_TOTAL_AMOUNT", paramMap.get("salesTotalAmount"));
|
||||
if(paramMap.get("salesCurrency") != null) {
|
||||
saleInfo.put("SALES_CURRENCY", paramMap.get("salesCurrency"));
|
||||
salesCurrency = CommonUtils.nullToEmpty((String)paramMap.get("salesCurrency"));
|
||||
}
|
||||
if(paramMap.get("salesExchangeRate") != null) {
|
||||
saleInfo.put("SALES_EXCHANGE_RATE", paramMap.get("salesExchangeRate"));
|
||||
}
|
||||
System.out.println("설정 후 SALES_UNIT_PRICE: " + saleInfo.get("SALES_UNIT_PRICE"));
|
||||
System.out.println("설정 후 SALES_SUPPLY_PRICE: " + saleInfo.get("SALES_SUPPLY_PRICE"));
|
||||
System.out.println("설정 후 SALES_VAT: " + saleInfo.get("SALES_VAT"));
|
||||
System.out.println("설정 후 SALES_TOTAL_AMOUNT: " + saleInfo.get("SALES_TOTAL_AMOUNT"));
|
||||
}
|
||||
// 판매 정보가 비어있거나 금액이 0이면 수주 데이터로 채우기
|
||||
if(saleInfo == null ||
|
||||
else if(saleInfo == null ||
|
||||
(saleInfo.get("SALES_SUPPLY_PRICE") == null ||
|
||||
"0".equals(String.valueOf(saleInfo.get("SALES_SUPPLY_PRICE"))) ||
|
||||
Integer.parseInt(String.valueOf(saleInfo.get("SALES_SUPPLY_PRICE"))) == 0)) {
|
||||
@@ -298,7 +335,9 @@ public class SalesNcollectMgmtController {
|
||||
if(orderData != null && orderData.get("SALES_SUPPLY_PRICE") != null) {
|
||||
// 수주 데이터를 saleInfo에 병합 (기존 S/N 등은 유지)
|
||||
if(saleInfo == null) saleInfo = new HashMap<String, Object>();
|
||||
saleInfo.put("SALES_QUANTITY", orderData.get("SALES_QUANTITY"));
|
||||
// SALES_QUANTITY는 나중에 잔량으로 계산하므로 여기서는 설정하지 않음
|
||||
// saleInfo.put("SALES_QUANTITY", orderData.get("SALES_QUANTITY")); // 제거
|
||||
saleInfo.put("ORDER_QUANTITY", orderData.get("SALES_QUANTITY")); // 주문수량은 ORDER_QUANTITY로 저장
|
||||
saleInfo.put("SALES_UNIT_PRICE", orderData.get("SALES_UNIT_PRICE"));
|
||||
saleInfo.put("SALES_SUPPLY_PRICE", orderData.get("SALES_SUPPLY_PRICE"));
|
||||
saleInfo.put("SALES_VAT", orderData.get("SALES_VAT"));
|
||||
@@ -310,13 +349,54 @@ public class SalesNcollectMgmtController {
|
||||
saleInfo.put("SHIPPING_DATE", orderData.get("SHIPPING_DATE"));
|
||||
}
|
||||
salesCurrency = CommonUtils.nullToEmpty((String)orderData.get("SALES_CURRENCY"));
|
||||
}
|
||||
}
|
||||
|
||||
// 잔량 계산: ORDER_QUANTITY - 모든 분할 출하의 합계
|
||||
if(saleInfo != null && saleInfo.get("ORDER_QUANTITY") != null) {
|
||||
int orderQuantity = Integer.parseInt(String.valueOf(saleInfo.get("ORDER_QUANTITY")).split("\\.")[0]);
|
||||
|
||||
// 모든 분할 출하의 합계 조회
|
||||
int totalSoldQuantity = 0;
|
||||
try {
|
||||
Map<String, Object> totalResult = salesNcollectMgmtService.getTotalSalesQuantity(paramMap);
|
||||
System.out.println("getTotalSalesQuantity 결과: " + totalResult);
|
||||
if(totalResult != null && totalResult.get("total") != null) {
|
||||
System.out.println("total 값: " + totalResult.get("total"));
|
||||
totalSoldQuantity = Integer.parseInt(String.valueOf(totalResult.get("total")).split("\\.")[0]);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
System.out.println("getTotalSalesQuantity 에러 발생!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
request.setAttribute("saleInfo", saleInfo);
|
||||
int remainingQuantity = orderQuantity - totalSoldQuantity;
|
||||
|
||||
// orderInfo로 견적 정보 전달 (saleInfo가 이미 모든 필요한 정보를 포함)
|
||||
request.setAttribute("orderInfo", saleInfo);
|
||||
System.out.println("=== 잔량 계산 ===");
|
||||
System.out.println("주문수량 (ORDER_QUANTITY): " + orderQuantity);
|
||||
System.out.println("총 판매 수량 (모든 분할 출하 합계): " + totalSoldQuantity);
|
||||
System.out.println("잔량 (remainingQuantity): " + remainingQuantity);
|
||||
|
||||
// 잔량을 판매수량으로 설정 (정수)
|
||||
saleInfo.put("SALES_QUANTITY", remainingQuantity > 0 ? remainingQuantity : orderQuantity);
|
||||
System.out.println("설정 후 SALES_QUANTITY: " + saleInfo.get("SALES_QUANTITY"));
|
||||
}
|
||||
|
||||
// 프로젝트의 모든 품목 조회 (Phase 2) - 주석처리: 품목은 하나만 존재
|
||||
/*
|
||||
List<Map<String, Object>> projectItems = null;
|
||||
if(paramMap.get("orderNo") != null && !paramMap.get("orderNo").equals("")) {
|
||||
projectItems = salesNcollectMgmtService.getProjectItems(paramMap);
|
||||
System.out.println("=== 프로젝트 품목 조회 ===");
|
||||
System.out.println("품목 개수: " + (projectItems != null ? projectItems.size() : 0));
|
||||
request.setAttribute("projectItems", projectItems);
|
||||
}
|
||||
*/
|
||||
|
||||
request.setAttribute("saleInfo", saleInfo);
|
||||
|
||||
// orderInfo로 견적 정보 전달 (saleInfo가 이미 모든 필요한 정보를 포함)
|
||||
request.setAttribute("orderInfo", saleInfo);
|
||||
}
|
||||
|
||||
// 환종(통화) - 공통코드 0001533
|
||||
@@ -418,6 +498,96 @@ public class SalesNcollectMgmtController {
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 출하일 상세 내역 팝업
|
||||
* </pre>
|
||||
* @param request
|
||||
* @param paramMap - projectNo
|
||||
* @return String
|
||||
*/
|
||||
@RequestMapping(value = "/salesMgmt/shippingDetailPopup.do", method = RequestMethod.GET)
|
||||
public String showShippingDetailPopup(HttpServletRequest request, @RequestParam Map<String, Object> paramMap) {
|
||||
try {
|
||||
String projectNo = (String) paramMap.get("projectNo");
|
||||
List<Map<String, Object>> shippingList = salesNcollectMgmtService.getShippingDetailList(projectNo);
|
||||
request.setAttribute("shippingList", shippingList);
|
||||
request.setAttribute("projectNo", projectNo);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "/salesmgmt/salesMgmt/shippingDetailPopup";
|
||||
}
|
||||
|
||||
/**
|
||||
* 거래명세서 폼 표시
|
||||
*/
|
||||
@RequestMapping(value = "/salesMgmt/transactionStatementForm.do", method = RequestMethod.GET)
|
||||
public String showTransactionStatementForm(HttpServletRequest request, @RequestParam Map<String, Object> paramMap) {
|
||||
return "/salesmgmt/salesMgmt/transactionStatementForm";
|
||||
}
|
||||
|
||||
/**
|
||||
* 거래명세서 데이터 조회
|
||||
*/
|
||||
@RequestMapping(value = "/salesMgmt/getTransactionStatementData.do", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Map<String, Object> getTransactionStatementData(HttpServletRequest request, @RequestParam Map<String, Object> paramMap) {
|
||||
Map<String, Object> resultMap = new HashMap<String, Object>();
|
||||
|
||||
try {
|
||||
String projectNos = (String) paramMap.get("projectNos");
|
||||
|
||||
if(projectNos == null || projectNos.isEmpty()) {
|
||||
resultMap.put("success", false);
|
||||
resultMap.put("message", "프로젝트 번호가 없습니다.");
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
// 거래명세서 데이터 조회
|
||||
Map<String, Object> statementData = salesNcollectMgmtService.getTransactionStatementData(paramMap);
|
||||
|
||||
resultMap.put("success", true);
|
||||
resultMap.putAll(statementData);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
resultMap.put("success", false);
|
||||
resultMap.put("message", "데이터 조회 중 오류가 발생했습니다: " + e.getMessage());
|
||||
}
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 거래명세서 저장 (차수 관리 없음)
|
||||
*/
|
||||
@RequestMapping(value = "/salesMgmt/saveTransactionStatement.do", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Map<String, Object> saveTransactionStatement(HttpServletRequest request, @org.springframework.web.bind.annotation.RequestBody Map<String, Object> paramMap) {
|
||||
Map<String, Object> resultMap = new HashMap<String, Object>();
|
||||
|
||||
try {
|
||||
// 거래명세서는 차수 관리가 불필요하므로 단순히 성공 응답만 반환
|
||||
// 실제로는 PDF 생성 또는 로그 기록 등의 작업을 수행할 수 있음
|
||||
|
||||
System.out.println("=== 거래명세서 저장 ===");
|
||||
System.out.println("프로젝트 번호: " + paramMap.get("projectNos"));
|
||||
System.out.println("납품일: " + paramMap.get("deliveryDate"));
|
||||
System.out.println("비고: " + paramMap.get("noteContent"));
|
||||
|
||||
resultMap.put("success", true);
|
||||
resultMap.put("message", "저장되었습니다.");
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
resultMap.put("success", false);
|
||||
resultMap.put("message", "저장 중 오류가 발생했습니다: " + e.getMessage());
|
||||
}
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 계약관리 목록 조회
|
||||
|
||||
@@ -790,6 +790,102 @@
|
||||
ORDER BY REGDATE DESC
|
||||
</select>
|
||||
|
||||
<!-- 주문서관리 Total 합계 조회 (조회된 데이터 전체 합계) -->
|
||||
<select id="getContractGridTotalAmount" parameterType="map" resultType="map">
|
||||
/* contractMgmt.getContractGridTotalAmount */
|
||||
SELECT
|
||||
COALESCE(SUM(COALESCE(T.ORDER_TOTAL_AMOUNT_KRW, 0)), 0) AS "totalAmountKRW"
|
||||
FROM
|
||||
<include refid="contractBase"/> T
|
||||
WHERE 1=1
|
||||
<if test="Year !=null and Year != '' ">
|
||||
AND SUBSTR(CONTRACT_DATE,0,5) = #{Year}
|
||||
</if>
|
||||
|
||||
<if test="category_cd !=null and category_cd != '' ">
|
||||
AND category_cd = #{category_cd}
|
||||
</if>
|
||||
|
||||
<if test="customer_objid !=null and customer_objid != '' ">
|
||||
AND customer_objid = #{customer_objid}
|
||||
</if>
|
||||
|
||||
<if test="product != null and product !='' ">
|
||||
AND product = #{product}
|
||||
</if>
|
||||
|
||||
<if test="status_cd !=null and status_cd !=''">
|
||||
AND status_cd = #{status_cd}
|
||||
</if>
|
||||
|
||||
<if test="result_cd !=null and result_cd !=''">
|
||||
AND result_cd = #{result_cd}
|
||||
</if>
|
||||
<if test="contract_result !=null and contract_result !=''">
|
||||
AND contract_result = #{contract_result}
|
||||
</if>
|
||||
|
||||
<if test="contract_start_date != null and !''.equals(contract_start_date)">
|
||||
AND TO_DATE(CONTRACT_DATE,'YYYY-MM-DD') <![CDATA[ >= ]]> TO_DATE(#{contract_start_date}, 'YYYY-MM-DD')
|
||||
</if>
|
||||
<if test="contract_end_date != null and !''.equals(contract_end_date)">
|
||||
AND TO_DATE(CONTRACT_DATE,'YYYY-MM-DD') <![CDATA[ <= ]]> TO_DATE(#{contract_end_date}, 'YYYY-MM-DD')
|
||||
</if>
|
||||
|
||||
<if test="pm_user_id !=null and pm_user_id !=''">
|
||||
AND pm_user_id = #{pm_user_id}
|
||||
</if>
|
||||
<if test="contract_month != null and !''.equals(contract_month)">
|
||||
AND TO_DATE(TO_CHAR(TO_DATE(CONTRACT_DATE,'YYYY-MM-DD'),'YYYY-MM-DD'),'YYYY-MM') <![CDATA[ = ]]> TO_DATE(SUBSTRING(#{contract_month} FROM 1 FOR 4) || '-' || SUBSTRING(#{contract_month} FROM 5 FOR 2), 'YYYY-MM')
|
||||
</if>
|
||||
|
||||
<!-- 견적관리 추가 검색조건 -->
|
||||
<if test="appr_status !=null and appr_status != '' ">
|
||||
AND APPR_STATUS = #{appr_status}
|
||||
</if>
|
||||
|
||||
<if test="area_cd != null and area_cd !='' ">
|
||||
AND AREA_CD = #{area_cd}
|
||||
</if>
|
||||
|
||||
<if test="paid_type != null and paid_type !='' ">
|
||||
AND PAID_TYPE = #{paid_type}
|
||||
</if>
|
||||
|
||||
<!-- 품번/품명 검색: PART_OBJID로 정확하게 검색 -->
|
||||
<if test="search_partObjId != null and search_partObjId != ''">
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM CONTRACT_ITEM CI
|
||||
WHERE CI.CONTRACT_OBJID = T.OBJID
|
||||
AND CI.STATUS = 'ACTIVE'
|
||||
AND CI.PART_OBJID = #{search_partObjId}
|
||||
)
|
||||
</if>
|
||||
|
||||
<if test="search_serialNo != null and search_serialNo != ''">
|
||||
AND UPPER(SERIAL_NO) LIKE UPPER('%${search_serialNo}%')
|
||||
</if>
|
||||
|
||||
<if test="search_poNo != null and search_poNo != ''">
|
||||
AND UPPER(PO_NO) LIKE UPPER('%${search_poNo}%')
|
||||
</if>
|
||||
|
||||
<if test="order_start_date != null and !''.equals(order_start_date)">
|
||||
AND TO_DATE(ORDER_DATE,'YYYY-MM-DD') <![CDATA[ >= ]]> TO_DATE(#{order_start_date}, 'YYYY-MM-DD')
|
||||
</if>
|
||||
<if test="order_end_date != null and !''.equals(order_end_date)">
|
||||
AND TO_DATE(ORDER_DATE,'YYYY-MM-DD') <![CDATA[ <= ]]> TO_DATE(#{order_end_date}, 'YYYY-MM-DD')
|
||||
</if>
|
||||
|
||||
<if test="due_start_date != null and !''.equals(due_start_date)">
|
||||
AND TO_DATE(DUE_DATE,'YYYY-MM-DD') <![CDATA[ >= ]]> TO_DATE(#{due_start_date}, 'YYYY-MM-DD')
|
||||
</if>
|
||||
<if test="due_end_date != null and !''.equals(due_end_date)">
|
||||
AND TO_DATE(DUE_DATE,'YYYY-MM-DD') <![CDATA[ <= ]]> TO_DATE(#{due_end_date}, 'YYYY-MM-DD')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="contractList_bak" parameterType="map" resultType="map">
|
||||
SELECT *
|
||||
FROM (
|
||||
@@ -4474,6 +4570,103 @@ WHERE
|
||||
</if>
|
||||
ORDER BY REGDATE DESC
|
||||
</select>
|
||||
|
||||
<!-- 주문서관리 Total 합계 조회 -->
|
||||
<select id="getOrderTotalAmount" parameterType="map" resultType="map">
|
||||
SELECT
|
||||
COALESCE(SUM(COALESCE(T.ORDER_SUPPLY_PRICE_SUM, 0)), 0) AS TOTAL_SUPPLY_PRICE,
|
||||
COALESCE(SUM(COALESCE(T.ORDER_VAT_SUM, 0)), 0) AS TOTAL_VAT,
|
||||
COALESCE(SUM(COALESCE(T.ORDER_TOTAL_AMOUNT_SUM, 0)), 0) AS TOTAL_AMOUNT
|
||||
FROM
|
||||
<include refid="contractBase"/> T
|
||||
WHERE 1=1
|
||||
<if test="Year !=null and Year != '' ">
|
||||
AND SUBSTR(CONTRACT_DATE,0,5) = #{Year}
|
||||
</if>
|
||||
|
||||
<if test="category_cd !=null and category_cd != '' ">
|
||||
AND category_cd = #{category_cd}
|
||||
</if>
|
||||
|
||||
<if test="customer_objid !=null and customer_objid != '' ">
|
||||
AND customer_objid = #{customer_objid}
|
||||
</if>
|
||||
|
||||
<if test="product != null and product !='' ">
|
||||
AND product = #{product}
|
||||
</if>
|
||||
|
||||
<if test="status_cd !=null and status_cd !=''">
|
||||
AND status_cd = #{status_cd}
|
||||
</if>
|
||||
|
||||
<if test="result_cd !=null and result_cd !=''">
|
||||
AND result_cd = #{result_cd}
|
||||
</if>
|
||||
<if test="contract_result !=null and contract_result !=''">
|
||||
AND contract_result = #{contract_result}
|
||||
</if>
|
||||
|
||||
<if test="contract_start_date != null and !''.equals(contract_start_date)">
|
||||
AND TO_DATE(CONTRACT_DATE,'YYYY-MM-DD') <![CDATA[ >= ]]> TO_DATE(#{contract_start_date}, 'YYYY-MM-DD')
|
||||
</if>
|
||||
<if test="contract_end_date != null and !''.equals(contract_end_date)">
|
||||
AND TO_DATE(CONTRACT_DATE,'YYYY-MM-DD') <![CDATA[ <= ]]> TO_DATE(#{contract_end_date}, 'YYYY-MM-DD')
|
||||
</if>
|
||||
|
||||
<if test="pm_user_id !=null and pm_user_id !=''">
|
||||
AND pm_user_id = #{pm_user_id}
|
||||
</if>
|
||||
<if test="contract_month != null and !''.equals(contract_month)">
|
||||
AND TO_DATE(TO_CHAR(TO_DATE(CONTRACT_DATE,'YYYY-MM-DD'),'YYYY-MM-DD'),'YYYY-MM') <![CDATA[ = ]]> TO_DATE(SUBSTRING(#{contract_month} FROM 1 FOR 4) || '-' || SUBSTRING(#{contract_month} FROM 5 FOR 2), 'YYYY-MM')
|
||||
</if>
|
||||
|
||||
<!-- 견적관리 추가 검색조건 -->
|
||||
<if test="appr_status !=null and appr_status != '' ">
|
||||
AND APPR_STATUS = #{appr_status}
|
||||
</if>
|
||||
|
||||
<if test="area_cd != null and area_cd !='' ">
|
||||
AND AREA_CD = #{area_cd}
|
||||
</if>
|
||||
|
||||
<if test="paid_type != null and paid_type !='' ">
|
||||
AND PAID_TYPE = #{paid_type}
|
||||
</if>
|
||||
|
||||
<!-- 품번/품명 검색: PART_OBJID로 정확하게 검색 -->
|
||||
<if test="search_partObjId != null and search_partObjId != ''">
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM CONTRACT_ITEM CI
|
||||
WHERE CI.CONTRACT_OBJID = T.OBJID
|
||||
AND CI.STATUS = 'ACTIVE'
|
||||
AND CI.PART_OBJID = #{search_partObjId}
|
||||
)
|
||||
</if>
|
||||
|
||||
<if test="search_serialNo != null and search_serialNo != ''">
|
||||
AND UPPER(SERIAL_NO) LIKE UPPER('%${search_serialNo}%')
|
||||
</if>
|
||||
|
||||
<if test="search_poNo != null and search_poNo != ''">
|
||||
AND UPPER(PO_NO) LIKE UPPER('%${search_poNo}%')
|
||||
</if>
|
||||
|
||||
<if test="order_start_date != null and !''.equals(order_start_date)">
|
||||
AND TO_DATE(ORDER_DATE,'YYYY-MM-DD') <![CDATA[ >= ]]> TO_DATE(#{order_start_date}, 'YYYY-MM-DD')
|
||||
</if>
|
||||
<if test="order_end_date != null and !''.equals(order_end_date)">
|
||||
AND TO_DATE(ORDER_DATE,'YYYY-MM-DD') <![CDATA[ <= ]]> TO_DATE(#{order_end_date}, 'YYYY-MM-DD')
|
||||
</if>
|
||||
|
||||
<if test="due_start_date != null and !''.equals(due_start_date)">
|
||||
AND TO_DATE(DUE_DATE,'YYYY-MM-DD') <![CDATA[ >= ]]> TO_DATE(#{due_start_date}, 'YYYY-MM-DD')
|
||||
</if>
|
||||
<if test="due_end_date != null and !''.equals(due_end_date)">
|
||||
AND TO_DATE(DUE_DATE,'YYYY-MM-DD') <![CDATA[ <= ]]> TO_DATE(#{due_end_date}, 'YYYY-MM-DD')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 영업정보 조회 (수주등록용) -->
|
||||
<select id="getContractInfo" parameterType="map" resultType="map">
|
||||
|
||||
@@ -875,16 +875,32 @@
|
||||
(SELECT CM.PRODUCTION_STATUS FROM CONTRACT_MGMT CM WHERE CM.OBJID = T.CONTRACT_OBJID) AS PRODUCTION_STATUS,
|
||||
-- 판매 관련 필드들 (sales_registration 테이블에서 한 번에 가져오기)
|
||||
COALESCE(SR.shipping_order_status, '') AS SHIPPING_ORDER_STATUS,
|
||||
COALESCE(SR.sales_quantity, 0) AS SALES_QUANTITY,
|
||||
-- 판매수량: 모든 분할 출하의 합계
|
||||
COALESCE(
|
||||
(SELECT SUM(sales_quantity)
|
||||
FROM sales_registration
|
||||
WHERE project_no LIKE T.PROJECT_NO || '%'),
|
||||
0
|
||||
) AS SALES_QUANTITY,
|
||||
COALESCE(SR.sales_unit_price, 0) AS SALES_UNIT_PRICE,
|
||||
COALESCE(SR.sales_supply_price, 0) AS SALES_SUPPLY_PRICE,
|
||||
COALESCE(SR.sales_vat, 0) AS SALES_VAT,
|
||||
COALESCE(SR.sales_total_amount, 0) AS SALES_TOTAL_AMOUNT,
|
||||
COALESCE(SR.sales_total_amount, 0) AS SALES_TOTAL_AMOUNT_KRW,
|
||||
-- 잔량 계산: 수주수량 - 판매수량
|
||||
COALESCE(T.QUANTITY::numeric, 0) - COALESCE(SR.sales_quantity, 0) AS REMAINING_QUANTITY,
|
||||
-- 잔량원화총액 계산: (수주수량 - 판매수량) * 판매단가
|
||||
(COALESCE(T.QUANTITY::numeric, 0) - COALESCE(SR.sales_quantity, 0)) * COALESCE(SR.sales_unit_price, 0) AS REMAINING_AMOUNT_KRW,
|
||||
-- 잔량 계산: 수주수량 - 모든 분할 출하의 합계
|
||||
COALESCE(T.QUANTITY::numeric, 0) - COALESCE(
|
||||
(SELECT SUM(sales_quantity)
|
||||
FROM sales_registration
|
||||
WHERE project_no LIKE T.PROJECT_NO || '%'),
|
||||
0
|
||||
) AS REMAINING_QUANTITY,
|
||||
-- 잔량원화총액 계산: (수주수량 - 모든 분할 출하 합계) * 판매단가
|
||||
(COALESCE(T.QUANTITY::numeric, 0) - COALESCE(
|
||||
(SELECT SUM(sales_quantity)
|
||||
FROM sales_registration
|
||||
WHERE project_no LIKE T.PROJECT_NO || '%'),
|
||||
0
|
||||
)) * COALESCE(SR.sales_unit_price, 0) AS REMAINING_AMOUNT_KRW,
|
||||
COALESCE(SR.sales_currency, T.CONTRACT_CURRENCY) AS SALES_CURRENCY,
|
||||
CODE_NAME(COALESCE(SR.sales_currency, T.CONTRACT_CURRENCY)) AS SALES_CURRENCY_NAME,
|
||||
COALESCE(SR.sales_exchange_rate, T.CONTRACT_PRICE_CURRENCY::numeric, 0) AS SALES_EXCHANGE_RATE,
|
||||
@@ -1397,29 +1413,12 @@ ORDER BY T.REGDATE DESC, T.PROJECT_NO DESC
|
||||
NULL,
|
||||
</otherwise>
|
||||
</choose>
|
||||
#{shippingMethod},
|
||||
#{manager},
|
||||
#{incoterms},
|
||||
#{cretEmpNo}
|
||||
)
|
||||
ON CONFLICT (project_no)
|
||||
DO UPDATE SET
|
||||
shipping_order_status = EXCLUDED.shipping_order_status,
|
||||
serial_no = EXCLUDED.serial_no,
|
||||
sales_quantity = EXCLUDED.sales_quantity,
|
||||
sales_unit_price = EXCLUDED.sales_unit_price,
|
||||
sales_supply_price = EXCLUDED.sales_supply_price,
|
||||
sales_vat = EXCLUDED.sales_vat,
|
||||
sales_total_amount = EXCLUDED.sales_total_amount,
|
||||
sales_currency = EXCLUDED.sales_currency,
|
||||
sales_exchange_rate = EXCLUDED.sales_exchange_rate,
|
||||
shipping_date = EXCLUDED.shipping_date,
|
||||
shipping_method = EXCLUDED.shipping_method,
|
||||
manager_user_id = EXCLUDED.manager_user_id,
|
||||
incoterms = EXCLUDED.incoterms,
|
||||
upd_date = NOW(),
|
||||
upd_user_id = EXCLUDED.reg_user_id
|
||||
</insert>
|
||||
#{shippingMethod},
|
||||
#{manager},
|
||||
#{incoterms},
|
||||
#{cretEmpNo}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!--
|
||||
/**
|
||||
@@ -1488,9 +1487,15 @@ ORDER BY T.REGDATE DESC, T.PROJECT_NO DESC
|
||||
AND UPPER(STATUS) = 'ACTIVE'
|
||||
) THEN 'Y' ELSE 'N' END AS ORDER_ATTACH,
|
||||
(SELECT CM.PRODUCTION_STATUS FROM CONTRACT_MGMT CM WHERE CM.OBJID = T.CONTRACT_OBJID) AS PRODUCTION_STATUS,
|
||||
-- 판매 관련 필드들 (sales_registration 테이블에서 가져오기)
|
||||
COALESCE(SR.shipping_order_status, '') AS SHIPPING_ORDER_STATUS,
|
||||
COALESCE(SR.sales_quantity, 0) AS SALES_QUANTITY,
|
||||
-- 판매 관련 필드들 (sales_registration 테이블에서 가져오기)
|
||||
SR.sale_no AS SALE_NO,
|
||||
COALESCE(SR.shipping_order_status, '') AS SHIPPING_ORDER_STATUS,
|
||||
|
||||
-- 주문수량 (PROJECT_MGMT에서 가져오기) - 잔량 계산용
|
||||
COALESCE(T.QUANTITY::NUMERIC, 0) AS ORDER_QUANTITY,
|
||||
|
||||
-- 판매수량 (sales_registration에서 가져오기) - 이미 판매한 수량
|
||||
COALESCE(SR.sales_quantity, 0) AS SALES_QUANTITY,
|
||||
COALESCE(SR.sales_unit_price, 0) AS SALES_UNIT_PRICE,
|
||||
COALESCE(SR.sales_supply_price, 0) AS SALES_SUPPLY_PRICE,
|
||||
COALESCE(SR.sales_vat, 0) AS SALES_VAT,
|
||||
@@ -1498,7 +1503,7 @@ ORDER BY T.REGDATE DESC, T.PROJECT_NO DESC
|
||||
COALESCE(SR.sales_total_amount, 0) AS SALES_TOTAL_AMOUNT_KRW,
|
||||
COALESCE(NULLIF(SR.sales_currency, ''), CM.CONTRACT_CURRENCY) AS SALES_CURRENCY,
|
||||
CODE_NAME(COALESCE(NULLIF(SR.sales_currency, ''), CM.CONTRACT_CURRENCY)) AS SALES_CURRENCY_NAME,
|
||||
COALESCE(NULLIF(SR.sales_exchange_rate, 0), CM.EXCHANGE_RATE::numeric, 0) AS SALES_EXCHANGE_RATE,
|
||||
COALESCE(NULLIF(SR.sales_exchange_rate, 0), NULLIF(CM.EXCHANGE_RATE, '')::numeric, 0) AS SALES_EXCHANGE_RATE,
|
||||
COALESCE(TO_CHAR(SR.shipping_date, 'YYYY-MM-DD'), '') AS SHIPPING_DATE,
|
||||
COALESCE(SR.shipping_method, '') AS SHIPPING_METHOD,
|
||||
COALESCE(SR.manager_user_id, T.PM_USER_ID) AS MANAGER,
|
||||
@@ -1566,40 +1571,43 @@ ORDER BY T.REGDATE DESC, T.PROJECT_NO DESC
|
||||
-->
|
||||
<select id="getOrderDataByOrderNo" parameterType="map" resultType="map">
|
||||
/* salesNcollectMgmt.getOrderDataByOrderNo - orderNo로 판매등록용 수주 데이터 조회 */
|
||||
SELECT
|
||||
-- 기본 정보
|
||||
CM.CONTRACT_NO AS ORDER_NO,
|
||||
CM.OBJID AS CONTRACT_OBJID,
|
||||
|
||||
-- 수주 금액 정보 (CONTRACT_ITEM 테이블에서 합산) - VARCHAR 타입이므로 NUMERIC으로 캐스팅
|
||||
COALESCE(SUM(CI.ORDER_QUANTITY::NUMERIC), 0) AS SALES_QUANTITY,
|
||||
COALESCE(ROUND(AVG(CI.ORDER_UNIT_PRICE::NUMERIC), 2), 0) AS SALES_UNIT_PRICE,
|
||||
COALESCE(SUM(CI.ORDER_SUPPLY_PRICE::NUMERIC), 0) AS SALES_SUPPLY_PRICE,
|
||||
COALESCE(SUM(CI.ORDER_VAT::NUMERIC), 0) AS SALES_VAT,
|
||||
COALESCE(SUM(CI.ORDER_TOTAL_AMOUNT::NUMERIC), 0) AS SALES_TOTAL_AMOUNT,
|
||||
|
||||
-- 환종 정보
|
||||
CM.CONTRACT_CURRENCY AS SALES_CURRENCY,
|
||||
CODE_NAME(CM.CONTRACT_CURRENCY) AS SALES_CURRENCY_NAME,
|
||||
COALESCE(CM.EXCHANGE_RATE::NUMERIC, 0) AS SALES_EXCHANGE_RATE,
|
||||
|
||||
-- 수주 날짜 - VARCHAR 타입이므로 그대로 사용
|
||||
CM.ORDER_DATE AS SHIPPING_DATE,
|
||||
|
||||
-- 담당자
|
||||
CM.PM_USER_ID AS MANAGER
|
||||
|
||||
FROM PROJECT_MGMT PM
|
||||
INNER JOIN CONTRACT_MGMT CM ON PM.CONTRACT_OBJID = CM.OBJID
|
||||
LEFT JOIN CONTRACT_ITEM CI ON CM.OBJID::VARCHAR = CI.CONTRACT_OBJID AND UPPER(CI.STATUS) = 'ACTIVE'
|
||||
WHERE PM.PROJECT_NO = #{orderNo}
|
||||
GROUP BY
|
||||
CM.CONTRACT_NO,
|
||||
CM.OBJID,
|
||||
CM.CONTRACT_CURRENCY,
|
||||
CM.EXCHANGE_RATE,
|
||||
CM.ORDER_DATE,
|
||||
CM.PM_USER_ID
|
||||
SELECT
|
||||
-- 기본 정보
|
||||
CM.CONTRACT_NO AS ORDER_NO,
|
||||
CM.OBJID AS CONTRACT_OBJID,
|
||||
|
||||
-- 수주 수량 정보 (PROJECT_MGMT에서 직접 가져오기)
|
||||
COALESCE(PM.QUANTITY::NUMERIC, 0) AS SALES_QUANTITY,
|
||||
|
||||
-- 수주 금액 정보 (CONTRACT_ITEM 테이블에서 합산) - VARCHAR 타입이므로 NULLIF로 빈 문자열 제거 후 NUMERIC 캐스팅
|
||||
COALESCE(ROUND(AVG(NULLIF(CI.ORDER_UNIT_PRICE, '')::NUMERIC), 2), 0) AS SALES_UNIT_PRICE,
|
||||
COALESCE(SUM(NULLIF(CI.ORDER_SUPPLY_PRICE, '')::NUMERIC), 0) AS SALES_SUPPLY_PRICE,
|
||||
COALESCE(SUM(NULLIF(CI.ORDER_VAT, '')::NUMERIC), 0) AS SALES_VAT,
|
||||
COALESCE(SUM(NULLIF(CI.ORDER_TOTAL_AMOUNT, '')::NUMERIC), 0) AS SALES_TOTAL_AMOUNT,
|
||||
|
||||
-- 환종 정보
|
||||
CM.CONTRACT_CURRENCY AS SALES_CURRENCY,
|
||||
CODE_NAME(CM.CONTRACT_CURRENCY) AS SALES_CURRENCY_NAME,
|
||||
COALESCE(NULLIF(CM.EXCHANGE_RATE, '')::NUMERIC, 0) AS SALES_EXCHANGE_RATE,
|
||||
|
||||
-- 수주 날짜 - VARCHAR 타입이므로 그대로 사용
|
||||
CM.ORDER_DATE AS SHIPPING_DATE,
|
||||
|
||||
-- 담당자
|
||||
CM.PM_USER_ID AS MANAGER
|
||||
|
||||
FROM PROJECT_MGMT PM
|
||||
INNER JOIN CONTRACT_MGMT CM ON PM.CONTRACT_OBJID = CM.OBJID
|
||||
LEFT JOIN CONTRACT_ITEM CI ON CM.OBJID::VARCHAR = CI.CONTRACT_OBJID AND UPPER(CI.STATUS) = 'ACTIVE'
|
||||
WHERE PM.PROJECT_NO = #{orderNo}
|
||||
GROUP BY
|
||||
CM.CONTRACT_NO,
|
||||
CM.OBJID,
|
||||
CM.CONTRACT_CURRENCY,
|
||||
CM.EXCHANGE_RATE,
|
||||
CM.ORDER_DATE,
|
||||
CM.PM_USER_ID,
|
||||
PM.QUANTITY
|
||||
</select>
|
||||
|
||||
<!--
|
||||
@@ -1619,5 +1627,159 @@ ORDER BY T.REGDATE DESC, T.PROJECT_NO DESC
|
||||
WHERE OBJID::VARCHAR = #{OBJID}
|
||||
</update>
|
||||
|
||||
<!-- 모든 분할 출하의 총 판매 수량 조회 -->
|
||||
<select id="getTotalSalesQuantity" parameterType="map" resultType="map">
|
||||
/* salesNcollectMgmt.getTotalSalesQuantity - project_no로 시작하는 모든 레코드의 판매 수량 합계 */
|
||||
SELECT COALESCE(SUM(NULLIF(sales_quantity, '')::NUMERIC), 0) as total
|
||||
FROM sales_registration
|
||||
WHERE project_no LIKE #{orderNo} || '%'
|
||||
</select>
|
||||
|
||||
<!-- sales_registration 개수 조회 (분할 출하 순번용) -->
|
||||
<select id="getSaleRegistrationCount" parameterType="map" resultType="map">
|
||||
/* salesNcollectMgmt.getSaleRegistrationCount - project_no로 시작하는 레코드 개수 */
|
||||
SELECT COUNT(*) as count
|
||||
FROM sales_registration
|
||||
WHERE project_no LIKE #{orderNo} || '%'
|
||||
</select>
|
||||
|
||||
<!-- sales_registration DELETE (기존 데이터 삭제) -->
|
||||
<delete id="deleteSaleRegistration" parameterType="map">
|
||||
/* salesNcollectMgmt.deleteSaleRegistration - sales_registration 삭제 */
|
||||
DELETE FROM sales_registration
|
||||
WHERE project_no = #{orderNo}
|
||||
</delete>
|
||||
|
||||
<!-- sales_registration UPDATE (기존 데이터 수정) -->
|
||||
<update id="updateSaleRegistration" parameterType="map">
|
||||
/* salesNcollectMgmt.updateSaleRegistration - sales_registration 업데이트 */
|
||||
UPDATE sales_registration
|
||||
SET
|
||||
shipping_order_status = <choose>
|
||||
<when test="shippingOrderStatus != null and shippingOrderStatus != ''">
|
||||
#{shippingOrderStatus},
|
||||
</when>
|
||||
<otherwise>
|
||||
'',
|
||||
</otherwise>
|
||||
</choose>
|
||||
serial_no = #{serialNo},
|
||||
sales_quantity = #{salesQuantity}::integer,
|
||||
sales_unit_price = #{salesUnitPrice}::numeric,
|
||||
sales_supply_price = #{salesSupplyPrice}::numeric,
|
||||
sales_vat = #{salesVat}::numeric,
|
||||
sales_total_amount = #{salesTotalAmount}::numeric,
|
||||
sales_currency = #{salesCurrency},
|
||||
sales_exchange_rate = #{salesExchangeRate}::numeric,
|
||||
shipping_date = <choose>
|
||||
<when test="shippingDate != null and shippingDate != ''">
|
||||
TO_DATE(#{shippingDate}, 'YYYY-MM-DD'),
|
||||
</when>
|
||||
<otherwise>
|
||||
NULL,
|
||||
</otherwise>
|
||||
</choose>
|
||||
shipping_method = #{shippingMethod},
|
||||
manager_user_id = #{manager},
|
||||
incoterms = #{incoterms},
|
||||
upd_date = NOW(),
|
||||
upd_user_id = #{cretEmpNo}
|
||||
WHERE project_no = #{orderNo}
|
||||
</update>
|
||||
|
||||
<!-- ========================================
|
||||
분할 출하 관련 쿼리 (shipment_log 테이블 활용)
|
||||
======================================== -->
|
||||
|
||||
<!-- shipment_log의 split_quantity 합산 조회 -->
|
||||
<select id="getShipmentLogTotal" parameterType="map" resultType="map">
|
||||
/* salesNcollectMgmt.getShipmentLogTotal - shipment_log의 split_quantity 합산 */
|
||||
SELECT COALESCE(SUM(split_quantity), 0) as total
|
||||
FROM shipment_log SL
|
||||
INNER JOIN project_mgmt PM ON SL.target_objid = PM.OBJID::VARCHAR
|
||||
WHERE PM.PROJECT_NO = #{orderNo}
|
||||
</select>
|
||||
|
||||
<!-- shipment_log에 분할 출하 기록 저장 -->
|
||||
<insert id="insertShipmentLog" parameterType="map">
|
||||
/* salesNcollectMgmt.insertShipmentLog - 분할 출하 기록 저장 */
|
||||
INSERT INTO shipment_log (
|
||||
target_objid, log_type, log_message, split_quantity, original_quantity,
|
||||
remaining_quantity, shipping_status, shipping_date, shipping_method,
|
||||
sales_unit_price, sales_supply_price, sales_vat, sales_total_amount,
|
||||
sales_currency, sales_exchange_rate, manager_user_id, incoterms,
|
||||
serial_no, parent_sale_no, reg_user_id
|
||||
) VALUES (
|
||||
#{targetObjid}, 'SPLIT_SHIPMENT', '분할 출하',
|
||||
#{salesQuantity}::integer, #{originalQuantity}::integer, #{remainingQuantity}::integer,
|
||||
#{shippingOrderStatus},
|
||||
<choose>
|
||||
<when test="shippingDate != null and shippingDate != ''">
|
||||
TO_DATE(#{shippingDate}, 'YYYY-MM-DD'),
|
||||
</when>
|
||||
<otherwise>NULL,</otherwise>
|
||||
</choose>
|
||||
#{shippingMethod}, #{salesUnitPrice}::numeric, #{salesSupplyPrice}::numeric,
|
||||
#{salesVat}::numeric, #{salesTotalAmount}::numeric, #{salesCurrency},
|
||||
#{salesExchangeRate}::numeric, #{manager}, #{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>
|
||||
|
||||
<!-- 출하일 상세 내역 조회 (모든 분할 출하 포함) -->
|
||||
<select id="getShippingDetailList" parameterType="map" resultType="map">
|
||||
/* salesNcollectMgmt.getShippingDetailList - 모든 분할 출하 포함 */
|
||||
SELECT
|
||||
COALESCE(TO_CHAR(SR.shipping_date, 'YYYY-MM-DD'), '미등록') AS shipping_date,
|
||||
COALESCE(SR.sales_quantity, 0) AS shipping_quantity,
|
||||
COALESCE(SR.shipping_order_status, '미등록') AS shipping_order_status,
|
||||
COALESCE(SR.serial_no, '-') AS serial_no,
|
||||
SR.project_no,
|
||||
CASE
|
||||
WHEN SR.project_no = #{projectNo} THEN '최초 출하'
|
||||
ELSE '분할 출하 ' || SUBSTRING(SR.project_no FROM LENGTH(#{projectNo}) + 2)
|
||||
END AS source
|
||||
FROM sales_registration SR
|
||||
WHERE SR.project_no LIKE #{projectNo} || '%'
|
||||
|
||||
ORDER BY shipping_date DESC, project_no
|
||||
</select>
|
||||
|
||||
<!-- 거래명세서 - 고객 정보 조회 -->
|
||||
<select id="getCustomerInfoByProjectNo" parameterType="map" resultType="map">
|
||||
/* salesNcollectMgmt.getCustomerInfoByProjectNo - 프로젝트 번호로 고객 정보 조회 */
|
||||
SELECT
|
||||
SM.SUPPLY_NAME AS CUSTOMER_NAME,
|
||||
SM.BUSINESS_NO AS CUSTOMER_REG_NO,
|
||||
SM.ADDRESS AS CUSTOMER_ADDRESS,
|
||||
SM.BUSINESS_TYPE AS CUSTOMER_BUSINESS,
|
||||
SM.BUSINESS_ITEM AS CUSTOMER_TYPE,
|
||||
SM.TEL_NO AS CUSTOMER_CONTACT
|
||||
FROM PROJECT_MGMT PM
|
||||
INNER JOIN SUPPLY_MNG SM ON PM.CUSTOMER_OBJID::NUMERIC = SM.OBJID
|
||||
WHERE PM.PROJECT_NO = #{projectNo}
|
||||
</select>
|
||||
|
||||
<!-- 거래명세서 - 품목 정보 조회 -->
|
||||
<select id="getTransactionStatementItem" parameterType="map" resultType="map">
|
||||
/* salesNcollectMgmt.getTransactionStatementItem - 프로젝트 번호로 품목 정보 조회 */
|
||||
SELECT
|
||||
PM.PART_NAME AS productName,
|
||||
PM.PART_NO AS spec,
|
||||
COALESCE(SR.sales_quantity, PM.QUANTITY) AS quantity,
|
||||
COALESCE(SR.sales_unit_price, 0) AS unitPrice,
|
||||
COALESCE(SR.sales_supply_price, 0) AS supplyPrice,
|
||||
COALESCE(SR.sales_vat, 0) AS vat
|
||||
FROM PROJECT_MGMT PM
|
||||
LEFT JOIN sales_registration SR ON PM.PROJECT_NO = SR.project_no
|
||||
WHERE PM.PROJECT_NO = #{projectNo}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
|
||||
@@ -2423,6 +2423,41 @@ private String encodeImageToBase64(String imagePath) {
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* 주문서관리 Total 합계 조회
|
||||
* @param request
|
||||
* @param paramMap - 검색 조건
|
||||
* @return Map - TOTAL_SUPPLY_PRICE, TOTAL_VAT, TOTAL_AMOUNT
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public Map<String, Object> getOrderTotalAmount(HttpServletRequest request, Map<String, Object> paramMap){
|
||||
SqlSession sqlSession = null;
|
||||
Map<String, Object> resultMap = new HashMap<String, Object>();
|
||||
|
||||
try{
|
||||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||||
resultMap = sqlSession.selectOne("contractMgmt.getOrderTotalAmount", paramMap);
|
||||
|
||||
// 대문자 변환
|
||||
if(resultMap != null) {
|
||||
resultMap = CommonUtils.keyChangeUpperMap(resultMap);
|
||||
} else {
|
||||
// 데이터가 없을 경우 기본값 설정
|
||||
resultMap = new HashMap<String, Object>();
|
||||
resultMap.put("TOTAL_SUPPLY_PRICE", 0);
|
||||
resultMap.put("TOTAL_VAT", 0);
|
||||
resultMap.put("TOTAL_AMOUNT", 0);
|
||||
}
|
||||
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}finally{
|
||||
if(sqlSession != null) sqlSession.close();
|
||||
}
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 견적서 템플릿 품목 조회 (수주등록용)
|
||||
* 최종 견적서의 품목 정보를 수주등록 형식으로 변환하여 반환
|
||||
|
||||
@@ -308,10 +308,39 @@ public class SalesNcollectMgmtService {
|
||||
}
|
||||
}
|
||||
|
||||
return CommonUtils.toUpperCaseMapKey(resultMap);
|
||||
return CommonUtils.toUpperCaseMapKey(resultMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 프로젝트의 모든 품목 조회 - 주석처리: 품목은 하나만 존재
|
||||
*/
|
||||
/*
|
||||
public List<Map<String, Object>> getProjectItems(Map<String, Object> paramMap) {
|
||||
List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>();
|
||||
SqlSession sqlSession = null;
|
||||
|
||||
try {
|
||||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||||
resultList = sqlSession.selectList("salesNcollectMgmt.getProjectItems", paramMap);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if(sqlSession != null) {
|
||||
sqlSession.close();
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, Object> saveSaleRegistration(HttpServletRequest request, Map<String, Object> paramMap) {
|
||||
// 대문자 키로 변환
|
||||
List<Map<String, Object>> upperCaseList = new ArrayList<Map<String, Object>>();
|
||||
for(Map<String, Object> item : resultList) {
|
||||
upperCaseList.add(CommonUtils.toUpperCaseMapKey(item));
|
||||
}
|
||||
|
||||
return upperCaseList;
|
||||
}
|
||||
*/
|
||||
|
||||
public Map<String, Object> saveSaleRegistration(HttpServletRequest request, Map<String, Object> paramMap) {
|
||||
Map<String, Object> resultMap = new HashMap<String, Object>();
|
||||
SqlSession sqlSession = null;
|
||||
|
||||
@@ -321,18 +350,87 @@ public class SalesNcollectMgmtService {
|
||||
PersonBean person = (PersonBean) request.getSession().getAttribute(Constants.PERSON_BEAN);
|
||||
paramMap.put("cretEmpNo", person.getUserId());
|
||||
|
||||
// sales_registration 테이블에 판매 데이터 저장 (ON CONFLICT로 자동 UPDATE)
|
||||
String projectNo = (String) paramMap.get("orderNo");
|
||||
System.out.println("=== saveSaleRegistration 시작 ===");
|
||||
System.out.println("projectNo: " + projectNo);
|
||||
System.out.println("salesQuantity: " + paramMap.get("salesQuantity"));
|
||||
|
||||
// 기존 판매 데이터가 있는지 확인
|
||||
Map<String, Object> checkParam = new HashMap<String, Object>();
|
||||
checkParam.put("orderNo", projectNo);
|
||||
Map<String, Object> existingSale = sqlSession.selectOne("salesNcollectMgmt.getSaleInfo", checkParam);
|
||||
|
||||
System.out.println("existingSale: " + (existingSale != null ? "있음" : "없음"));
|
||||
|
||||
// SALE_NO가 null이면 첫 판매, 있으면 분할 출하
|
||||
Object saleNoObj = existingSale != null ? existingSale.get("SALE_NO") : null;
|
||||
if(saleNoObj == null) saleNoObj = existingSale != null ? existingSale.get("sale_no") : null;
|
||||
|
||||
System.out.println("SALE_NO 확인: " + saleNoObj);
|
||||
|
||||
if(saleNoObj == null) {
|
||||
// 첫 판매 등록: sales_registration에 INSERT
|
||||
System.out.println("첫 판매 등록 - sales_registration에 INSERT");
|
||||
sqlSession.insert("salesNcollectMgmt.insertSaleRegistration", paramMap);
|
||||
} else {
|
||||
// 분할 출하: shipment_log에 INSERT
|
||||
System.out.println("분할 출하 - shipment_log에 INSERT");
|
||||
|
||||
// existingSale은 이미 대문자 키로 변환되어 있음 (CommonUtils.toUpperCaseMapKey)
|
||||
// 하지만 getSaleInfo에서는 변환 안 함 - 직접 확인
|
||||
Object orderQtyObj = existingSale.get("ORDER_QUANTITY");
|
||||
if(orderQtyObj == null) orderQtyObj = existingSale.get("order_quantity");
|
||||
|
||||
// saleNoObj는 이미 위에서 선언됨 - 재사용
|
||||
// Object saleNoObj = existingSale.get("SALE_NO"); // 중복 제거
|
||||
// if(saleNoObj == null) saleNoObj = existingSale.get("sale_no"); // 이미 위에서 처리
|
||||
|
||||
System.out.println("ORDER_QUANTITY: " + orderQtyObj);
|
||||
System.out.println("SALE_NO: " + saleNoObj);
|
||||
|
||||
if(orderQtyObj == null || saleNoObj == null) {
|
||||
System.out.println("=== existingSale 전체 내용 ===");
|
||||
for(Object key : existingSale.keySet()) {
|
||||
System.out.println(key + ": " + existingSale.get(key));
|
||||
}
|
||||
throw new RuntimeException("ORDER_QUANTITY 또는 SALE_NO가 null입니다");
|
||||
}
|
||||
|
||||
paramMap.put("targetObjid", projectNo);
|
||||
paramMap.put("originalQuantity", orderQtyObj);
|
||||
|
||||
// 잔량 계산
|
||||
int orderQuantity = Integer.parseInt(String.valueOf(orderQtyObj).split("\\.")[0]);
|
||||
int salesQuantity = Integer.parseInt(String.valueOf(paramMap.get("salesQuantity")));
|
||||
int remainingQuantity = orderQuantity - salesQuantity;
|
||||
|
||||
System.out.println("orderQuantity: " + orderQuantity);
|
||||
System.out.println("salesQuantity: " + salesQuantity);
|
||||
System.out.println("remainingQuantity: " + remainingQuantity);
|
||||
|
||||
paramMap.put("remainingQuantity", remainingQuantity);
|
||||
paramMap.put("parentSaleNo", saleNoObj);
|
||||
|
||||
System.out.println("shipment_log INSERT 직전 파라미터:");
|
||||
System.out.println(" targetObjid: " + paramMap.get("targetObjid"));
|
||||
System.out.println(" parentSaleNo: " + paramMap.get("parentSaleNo"));
|
||||
System.out.println(" cretEmpNo: " + paramMap.get("cretEmpNo"));
|
||||
|
||||
sqlSession.insert("salesNcollectMgmt.insertShipmentLog", paramMap);
|
||||
}
|
||||
|
||||
sqlSession.commit();
|
||||
resultMap.put("result", true);
|
||||
resultMap.put("msg", "저장되었습니다.");
|
||||
System.out.println("=== 저장 성공 ===");
|
||||
} catch(Exception e) {
|
||||
if(sqlSession != null) {
|
||||
sqlSession.rollback();
|
||||
}
|
||||
resultMap.put("result", false);
|
||||
resultMap.put("msg", "저장 중 오류가 발생했습니다.");
|
||||
System.out.println("=== 저장 실패 ===");
|
||||
System.out.println("에러 메시지: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if(sqlSession != null) {
|
||||
@@ -918,4 +1016,133 @@ public class SalesNcollectMgmtService {
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 모든 분할 출하의 총 판매 수량 조회
|
||||
* @param paramMap
|
||||
* @return Map
|
||||
*/
|
||||
public Map<String, Object> getTotalSalesQuantity(Map<String, Object> paramMap) {
|
||||
SqlSession sqlSession = null;
|
||||
Map<String, Object> result = null;
|
||||
|
||||
try {
|
||||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||||
result = sqlSession.selectOne("salesNcollectMgmt.getTotalSalesQuantity", paramMap);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if(sqlSession != null) {
|
||||
sqlSession.close();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 출하일 상세 내역 조회
|
||||
* @param projectNo
|
||||
* @return List
|
||||
*/
|
||||
public List<Map<String, Object>> getShippingDetailList(String projectNo) {
|
||||
SqlSession sqlSession = null;
|
||||
List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>();
|
||||
try {
|
||||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||||
Map<String, Object> paramMap = new HashMap<String, Object>();
|
||||
paramMap.put("projectNo", projectNo);
|
||||
resultList = sqlSession.selectList("salesNcollectMgmt.getShippingDetailList", paramMap);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (sqlSession != null) {
|
||||
sqlSession.close();
|
||||
}
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 거래명세서 데이터 조회
|
||||
* @param paramMap - projectNos (쉼표로 구분된 프로젝트 번호들)
|
||||
* @return Map
|
||||
*/
|
||||
public Map<String, Object> getTransactionStatementData(Map<String, Object> paramMap) {
|
||||
SqlSession sqlSession = null;
|
||||
Map<String, Object> resultMap = new HashMap<String, Object>();
|
||||
|
||||
try {
|
||||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||||
|
||||
String projectNos = (String) paramMap.get("projectNos");
|
||||
System.out.println("=== getTransactionStatementData 시작 ===");
|
||||
System.out.println("projectNos: " + projectNos);
|
||||
|
||||
String[] projectNoArray = projectNos.split(",");
|
||||
|
||||
// 첫 번째 프로젝트의 고객 정보 조회
|
||||
Map<String, Object> firstProjectParam = new HashMap<String, Object>();
|
||||
firstProjectParam.put("projectNo", projectNoArray[0].trim());
|
||||
System.out.println("고객 정보 조회 - projectNo: " + projectNoArray[0].trim());
|
||||
|
||||
Map<String, Object> customerInfo = sqlSession.selectOne("salesNcollectMgmt.getCustomerInfoByProjectNo", firstProjectParam);
|
||||
System.out.println("고객 정보 조회 결과: " + customerInfo);
|
||||
|
||||
if(customerInfo != null) {
|
||||
resultMap.put("customerName", customerInfo.get("CUSTOMER_NAME"));
|
||||
resultMap.put("customerRegNo", customerInfo.get("CUSTOMER_REG_NO"));
|
||||
resultMap.put("customerAddress", customerInfo.get("CUSTOMER_ADDRESS"));
|
||||
resultMap.put("customerBusiness", customerInfo.get("CUSTOMER_BUSINESS"));
|
||||
resultMap.put("customerType", customerInfo.get("CUSTOMER_TYPE"));
|
||||
resultMap.put("customerContact", customerInfo.get("CUSTOMER_CONTACT"));
|
||||
System.out.println("고객명: " + customerInfo.get("CUSTOMER_NAME"));
|
||||
} else {
|
||||
System.out.println("고객 정보가 null입니다!");
|
||||
}
|
||||
|
||||
// 공급자 정보 (회사 정보)
|
||||
resultMap.put("supplierName", "㈜압피에스");
|
||||
resultMap.put("supplierRegNo", "314-81-75146");
|
||||
resultMap.put("supplierAddress", "대전광역시 유성구 국제과학10로 8");
|
||||
resultMap.put("supplierBusiness", "제조");
|
||||
resultMap.put("supplierType", "금속절삭가공기계의");
|
||||
resultMap.put("supplierContact", "TEL:042-602-3300/FAX:042-672");
|
||||
|
||||
// 품목 정보 조회
|
||||
List<Map<String, Object>> items = new ArrayList<Map<String, Object>>();
|
||||
for(String projectNo : projectNoArray) {
|
||||
Map<String, Object> itemParam = new HashMap<String, Object>();
|
||||
itemParam.put("projectNo", projectNo.trim());
|
||||
System.out.println("품목 정보 조회 - projectNo: " + projectNo.trim());
|
||||
|
||||
Map<String, Object> item = sqlSession.selectOne("salesNcollectMgmt.getTransactionStatementItem", itemParam);
|
||||
System.out.println("품목 정보 조회 결과: " + item);
|
||||
|
||||
if(item != null) {
|
||||
items.add(item);
|
||||
}
|
||||
}
|
||||
resultMap.put("items", items);
|
||||
System.out.println("총 품목 개수: " + items.size());
|
||||
|
||||
// 비고
|
||||
resultMap.put("note", "아래와 같이 공급합니다.");
|
||||
|
||||
System.out.println("=== resultMap 최종 ===");
|
||||
System.out.println("customerName: " + resultMap.get("customerName"));
|
||||
System.out.println("items size: " + ((List)resultMap.get("items")).size());
|
||||
System.out.println("supplierName: " + resultMap.get("supplierName"));
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println("=== 에러 발생 ===");
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (sqlSession != null) {
|
||||
sqlSession.close();
|
||||
}
|
||||
}
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user