판매관리, 매출관리완성

This commit is contained in:
Johngreen
2025-10-20 23:04:30 +09:00
parent d9e06fe95d
commit 6af7fb6b6d
13 changed files with 1419 additions and 446 deletions

View File

@@ -58,7 +58,7 @@ public class SalesNcollectMgmtController {
/** 매출수금 Service */
@Autowired
private SalesNcollectMgmtService salseNcollectMgmtService;
private SalesNcollectMgmtService salesNcollectMgmtService;
/** 영업관리 공통 Service */
@Autowired
@@ -200,16 +200,33 @@ public class SalesNcollectMgmtController {
Map<String, Object> resultMap = new HashMap<String, Object>();
try {
List<Map<String, Object>> list = salseNcollectMgmtService.getSalesMgmtGridList(request, paramMap);
int totalCount = salseNcollectMgmtService.getSalesMgmtGridListCount(paramMap);
System.out.println("===== revenueGridList.do 파라미터 =====");
System.out.println("paramMap: " + paramMap);
List<Map<String, Object>> list = salesNcollectMgmtService.getSalesMgmtGridList(request, paramMap);
int totalCount = salesNcollectMgmtService.getSalesMgmtGridListCount(paramMap);
Map<String, Object> totals = salesNcollectMgmtService.getSalesMgmtTotals(paramMap);
System.out.println("list size: " + list.size());
System.out.println("totalCount: " + totalCount);
System.out.println("totals: " + totals);
resultMap.put("RESULTLIST", list);
resultMap.put("last_page", (int) Math.ceil((double)totalCount / Integer.parseInt(CommonUtils.checkNull(request.getParameter("size"), "10"))));
resultMap.put("TOTALS", totals); // Total 공급가액, 부가세, 총액
} catch(Exception e) {
e.printStackTrace();
// Tabulator는 에러 발생 시 빈 배열을 기대합니다.
resultMap.put("RESULTLIST", new java.util.ArrayList<>());
resultMap.put("last_page", 0);
// Total 초기화
Map<String, Object> emptyTotals = new HashMap<String, Object>();
emptyTotals.put("TOTAL_SUPPLY_PRICE", 0);
emptyTotals.put("TOTAL_VAT", 0);
emptyTotals.put("TOTAL_AMOUNT", 0);
resultMap.put("TOTALS", emptyTotals);
}
return resultMap;
@@ -232,6 +249,12 @@ public class SalesNcollectMgmtController {
codeMap.put("managerList",
salesMgmtCommonService.bizMakeOptionList("", "", "salesMgmtCommon.getSalesmanList"));
// 기존 판매 정보 조회
if(paramMap.get("orderNo") != null && !paramMap.get("orderNo").equals("")) {
Map<String, Object> saleInfo = salesNcollectMgmtService.getSaleInfo(paramMap);
request.setAttribute("saleInfo", saleInfo);
}
request.setAttribute("codeMap", codeMap);
} catch (Exception e) {
e.printStackTrace();
@@ -239,6 +262,87 @@ public class SalesNcollectMgmtController {
return "/salesmgmt/salesMgmt/salesRegForm";
}
@RequestMapping(value = "/salesMgmt/salesMgmtGridList.do", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> getSalesMgmtGridList(HttpServletRequest request, @RequestParam Map<String, Object> paramMap) {
Map<String, Object> resultMap = new HashMap<String, Object>();
try {
List<Map<String, Object>> list = salesNcollectMgmtService.getSalesMgmtGridList(request, paramMap);
int totalCount = salesNcollectMgmtService.getSalesMgmtGridListCount(paramMap);
resultMap.put("RESULTLIST", list);
resultMap.put("last_page", (int) Math.ceil((double)totalCount / Integer.parseInt(CommonUtils.checkNull(request.getParameter("size"), "10"))));
} catch(Exception e) {
e.printStackTrace();
// Tabulator는 에러 발생 시 빈 배열을 기대합니다.
resultMap.put("RESULTLIST", new java.util.ArrayList<>());
resultMap.put("last_page", 0);
}
return resultMap;
}
@RequestMapping(value = "/salesMgmt/saveSales.do", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> saveSales(HttpServletRequest request, @RequestParam Map<String, Object> paramMap) {
Map<String, Object> resultMap = new HashMap<String, Object>();
try {
resultMap = salesNcollectMgmtService.saveSaleRegistration(request, paramMap);
} catch (Exception e) {
resultMap.put("result", false);
resultMap.put("msg", "저장 중 오류가 발생했습니다.");
e.printStackTrace();
}
return resultMap;
}
/**
* <pre>
* 분할출하 팝업 폼
* </pre>
* @param request
* @param paramMap
* @return String
*/
@RequestMapping(value = "/salesMgmt/splitShipmentForm.do", method = RequestMethod.GET)
public String showSplitShipmentForm(HttpServletRequest request, @RequestParam Map<String, Object> paramMap) {
try {
Map<String, Object> codeMap = new HashMap<String, Object>();
// 담당자
codeMap.put("managerList",
salesMgmtCommonService.bizMakeOptionList("", "", "salesMgmtCommon.getSalesmanList"));
request.setAttribute("codeMap", codeMap);
} catch (Exception e) {
e.printStackTrace();
}
return "/salesmgmt/salesMgmt/splitShipmentForm";
}
/**
* <pre>
* 분할출하 저장 처리
* </pre>
* @param request
* @param paramMap - 분할출하 정보
* @return Map
*/
@RequestMapping(value = "/salesMgmt/saveSplitShipment.do", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> saveSplitShipment(HttpServletRequest request, @RequestParam Map<String, Object> paramMap) {
Map<String, Object> resultMap = new HashMap<String, Object>();
try {
resultMap = salesNcollectMgmtService.splitShipment(request, paramMap);
} catch (Exception e) {
resultMap.put("result", false);
resultMap.put("msg", "분할출하 처리 중 오류가 발생했습니다.");
e.printStackTrace();
}
return resultMap;
}
/**
* <pre>
* 계약관리 목록 조회
@@ -299,7 +403,7 @@ public class SalesNcollectMgmtController {
public String sales(HttpServletRequest request
, @RequestParam Map<String, Object> paramMap) {
try {
List<Map<String,Object>> list = salseNcollectMgmtService.getSalseAllByOrderNo(request, paramMap);
List<Map<String,Object>> list = salesNcollectMgmtService.getSalseAllByOrderNo(request, paramMap);
request.setAttribute("LIST", list);
} catch(Exception e) {
@@ -335,7 +439,7 @@ public class SalesNcollectMgmtController {
try {
if(StringUtils.isNotBlank(saleNo)) {
// 매출관리 조회
info = salseNcollectMgmtService.getSalesMgmt(paramMap);
info = salesNcollectMgmtService.getSalesMgmt(paramMap);
} else {
info = new HashMap<String, Object>();
}
@@ -388,7 +492,7 @@ public class SalesNcollectMgmtController {
Map<String, Object> resultMap = new HashMap<String, Object>();
try {
resultMap.put("RESULT", salseNcollectMgmtService.saveSalesMgmt(request, paramMap));
resultMap.put("RESULT", salesNcollectMgmtService.saveSalesMgmt(request, paramMap));
} catch(Exception e) {
e.printStackTrace();
}
@@ -409,7 +513,7 @@ public class SalesNcollectMgmtController {
Map<String, Object> resultMap = new HashMap<String, Object>();
try {
resultMap.put("RESULT", salseNcollectMgmtService.deleteSalesMgmt(request, paramMap));
resultMap.put("RESULT", salesNcollectMgmtService.deleteSalesMgmt(request, paramMap));
@@ -450,7 +554,7 @@ public class SalesNcollectMgmtController {
, @RequestParam Map<String, Object> paramMap) {
try {
List<Map<String,Object>> list = salseNcollectMgmtService.getCollectAllByOrderNo(request, paramMap);
List<Map<String,Object>> list = salesNcollectMgmtService.getCollectAllByOrderNo(request, paramMap);
request.setAttribute("LIST", list);
} catch(Exception e) {
@@ -491,7 +595,7 @@ public class SalesNcollectMgmtController {
System.out.println("paramMap##################### " + paramMap);
if(StringUtils.isNotBlank(saleNo)) {
// 수금관리 조회
info = salseNcollectMgmtService.getCollectMgmt(paramMap);
info = salesNcollectMgmtService.getCollectMgmt(paramMap);
} else {
info = new HashMap<String, Object>();
}
@@ -540,7 +644,7 @@ public class SalesNcollectMgmtController {
*/
//하단 그리드를 위한 수금 목록 조회
List<Map<String,Object>> list = salseNcollectMgmtService.getCollectAllByOrderNo(request, paramMap);
List<Map<String,Object>> list = salesNcollectMgmtService.getCollectAllByOrderNo(request, paramMap);
request.setAttribute("LIST", list);
request.setAttribute("info", info);
@@ -577,7 +681,7 @@ public class SalesNcollectMgmtController {
Map<String, Object> resultMap = new HashMap<String, Object>();
System.out.println("ctr::paramMap##################### " + paramMap);
try {
resultMap.put("RESULT", salseNcollectMgmtService.saveCollectMgmt(request, paramMap));
resultMap.put("RESULT", salesNcollectMgmtService.saveCollectMgmt(request, paramMap));
} catch(Exception e) {
e.printStackTrace();
@@ -599,7 +703,7 @@ public class SalesNcollectMgmtController {
Map<String, Object> resultMap = new HashMap<String, Object>();
try {
resultMap.put("RESULT", salseNcollectMgmtService.deleteCollectMgmt(request, paramMap));
resultMap.put("RESULT", salesNcollectMgmtService.deleteCollectMgmt(request, paramMap));
} catch(Exception e) {
e.printStackTrace();
}

View File

@@ -812,188 +812,332 @@
,editEmpNo = #{cretEmpNo} /* 수정자 */
</update>
<!-- 매출관리 그리드 목록 -->
<!-- 매출관리 그리드 목록 (SW 테이블 사용 안함) -->
<select id="getSalesMgmtGridList" parameterType="map" resultType="map">
/* salesNcollectMgmt.getSalesMgmtGridList */
/* salesNcollectMgmt.getSalesMgmtGridList - VIEW 기반 조회 (원본 + 분할출하 통합) */
SELECT
B.OrderNo AS PROJECT_NO, /* 프로젝트번호를 계약번호로 우선 사용 */
(SELECT CdNm FROM SWSA050A_TBL WHERE MajorCd = 'GE' AND MinorCd = B.SaleType) AS ORDER_TYPE,
CASE WHEN C.c_class IS NOT NULL THEN
CONCAT(
(SELECT ltrim(rtrim(DTL_NM)) from SWSA999A_TBL where COMM_CD = 'S110' AND SUBSTRING(DTL_CD,1,1) = SUBSTRING(C.c_class,1,1)),
'-',
(SELECT ltrim(rtrim(DTL_NM)) from SWSA999A_TBL where COMM_CD = 'S120' AND SUBSTRING(DTL_CD,1,3) = SUBSTRING(C.c_class,1,3)),
'-',
(SELECT ltrim(rtrim(DTL_NM)) from SWSA999A_TBL where COMM_CD = 'S130' AND DTL_CD = C.c_class )
)
ELSE '' END AS PRODUCT_TYPE,
(SELECT CdNm FROM SWSA050A_TBL WHERE MAjorCd = 'NA' AND MinorCd = B.nationGB) AS NATION,
COALESCE(A.WrtYmd, B.OrderDate) AS RECEIPT_DATE,
D.custNm AS CUSTOMER,
(CASE B.freeyn WHEN 'Y' THEN '무상' ELSE '유상' END) AS PAYMENT_TYPE,
C.GoodsCd AS PRODUCT_NO,
C.GoodsNm AS PRODUCT_NAME,
A.serialno AS SERIAL_NO,
COALESCE(A.SupplyQty, B.goodsqty) AS QUANTITY,
B.custreq AS REQUEST_DATE,
COALESCE(A.Remark, B.bigo) AS CUSTOMER_REQUEST,
(SELECT CdNm FROM SWSA050A_TBL WHERE MajorCd = 'SS' AND MinorCd = B.endsale) AS ORDER_STATUS,
B.OrderNo AS PO_NO,
B.OrderDate AS ORDER_DATE,
B.orderattachpath AS ORDER_ATTACH,
COALESCE(A.SupplyPrice, B.saleprice) AS UNIT_PRICE,
COALESCE(A.SupplyAmt, B.saleamt) AS SUPPLY_PRICE,
COALESCE(A.SupplyVat, B.vatamt) AS VAT,
COALESCE((A.SupplyAmt + A.SupplyVat), (B.saleamt + B.vatamt)) AS TOTAL_AMOUNT,
COALESCE(A.NoWonSymbol, B.nowonsymbol) AS CURRENCY,
COALESCE(A.NoWonExChange, B.nowonexchange) AS EXCHANGE_RATE,
B.shippingstatus AS SHIPPING_STATUS,
B.shippingdate AS SHIPPING_DATE,
B.shippingmethod AS SHIPPING_METHOD,
(SELECT user_name FROM USER_INFO WHERE user_id = D.SalesMan) AS MANAGER,
B.saleQty AS SALES_QUANTITY,
(SELECT CdNm FROM SWSA050A_TBL WHERE MajorCd = 'IT' AND MinorCd = B.incoterms) AS INCOTERMS,
B.salesstatus AS SALES_STATUS
FROM SWSC110A_TBL B
LEFT JOIN SWSD010A_TBL A ON A.orderNo = B.orderNo
INNER JOIN SWSB110A_TBL C ON B.goodsCd = C.goodsCd
INNER JOIN SWSB210A_TBL D ON B.custCd = D.custCd
PROJECT_NO,
ORDER_TYPE,
PRODUCT_TYPE,
NATION,
RECEIPT_DATE,
CUSTOMER,
PAYMENT_TYPE,
PRODUCT_NO,
PRODUCT_NAME,
SERIAL_NO,
COALESCE(ORDER_QUANTITY, 0) AS ORDER_QUANTITY,
REQUEST_DATE,
CUSTOMER_REQUEST,
ORDER_STATUS,
PO_NO,
ORDER_DATE,
ORDER_ATTACH,
PRODUCTION_STATUS,
SHIPPING_ORDER_STATUS,
COALESCE(SALES_QUANTITY, 0) AS SALES_QUANTITY,
COALESCE(SALES_UNIT_PRICE, 0) AS SALES_UNIT_PRICE,
COALESCE(SALES_SUPPLY_PRICE, 0) AS SALES_SUPPLY_PRICE,
COALESCE(SALES_VAT, 0) AS SALES_VAT,
COALESCE(SALES_TOTAL_AMOUNT, 0) AS SALES_TOTAL_AMOUNT,
COALESCE(SALES_TOTAL_AMOUNT_KRW, 0) AS SALES_TOTAL_AMOUNT_KRW,
SALES_CURRENCY,
COALESCE(SALES_EXCHANGE_RATE, 0) AS SALES_EXCHANGE_RATE,
SHIPPING_DATE,
SHIPPING_METHOD,
MANAGER,
INCOTERMS,
SALES_STATUS,
SALE_NO,
RECORD_TYPE,
SPLIT_LOG_ID
FROM v_sales_mgmt_with_splits
WHERE 1 = 1
<if test="orderType != null and orderType != ''">
AND B.SaleType = #{orderType}
AND CATEGORY_CD = #{orderType}
</if>
<if test="productType != null and productType != ''">
AND C.c_class = #{productType}
AND PRODUCT_TYPE = #{productType}
</if>
<if test="nation != null and nation != ''">
AND B.nationGB = #{nation}
AND AREA_CD = #{nation}
</if>
<if test="customer != null and customer != ''">
AND D.custNm LIKE CONCAT('%', #{customer}, '%')
AND CUSTOMER LIKE CONCAT('%', #{customer}, '%')
</if>
<if test="paymentType != null and paymentType != ''">
AND B.freeyn = #{paymentType}
AND PAID_TYPE = #{paymentType}
</if>
<if test="productNo != null and productNo != ''">
AND C.GoodsCd LIKE CONCAT('%', #{productNo}, '%')
AND PRODUCT_NO LIKE CONCAT('%', #{productNo}, '%')
</if>
<if test="productName != null and productName != ''">
AND C.GoodsNm LIKE CONCAT('%', #{productName}, '%')
AND PRODUCT_NAME LIKE CONCAT('%', #{productName}, '%')
</if>
<if test="serialNo != null and serialNo != ''">
AND A.serialno LIKE CONCAT('%', #{serialNo}, '%')
AND SERIAL_NO LIKE CONCAT('%', #{serialNo}, '%')
</if>
<if test="orderStatus != null and orderStatus != ''">
AND B.endsale = #{orderStatus}
AND STATUS_CD = #{orderStatus}
</if>
<if test="poNo != null and poNo != ''">
AND B.OrderNo LIKE CONCAT('%', #{poNo}, '%')
AND PO_NO LIKE CONCAT('%', #{poNo}, '%')
</if>
<if test="requestDateFrom != null and requestDateFrom != ''">
AND B.custreq <![CDATA[>=]]> #{requestDateFrom}
AND REQUEST_DATE <![CDATA[>=]]> #{requestDateFrom}
</if>
<if test="requestDateTo != null and requestDateTo != ''">
AND B.custreq <![CDATA[<=]]> #{requestDateTo}
AND REQUEST_DATE <![CDATA[<=]]> #{requestDateTo}
</if>
<if test="orderDateFrom != null and orderDateFrom != ''">
AND B.OrderDate <![CDATA[>=]]> #{orderDateFrom}
AND ORDER_DATE <![CDATA[>=]]> #{orderDateFrom}
</if>
<if test="orderDateTo != null and orderDateTo != ''">
AND B.OrderDate <![CDATA[<=]]> #{orderDateTo}
AND ORDER_DATE <![CDATA[<=]]> #{orderDateTo}
</if>
<if test="shippingStatus != null and shippingStatus != ''">
AND B.shippingstatus = #{shippingStatus}
AND SALES_STATUS = #{shippingStatus}
</if>
<if test="shippingDateFrom != null and shippingDateFrom != ''">
AND B.shippingdate <![CDATA[>=]]> #{shippingDateFrom}
AND SHIPPING_DATE <![CDATA[>=]]> #{shippingDateFrom}
</if>
<if test="shippingDateTo != null and shippingDateTo != ''">
AND B.shippingdate <![CDATA[<=]]> #{shippingDateTo}
AND SHIPPING_DATE <![CDATA[<=]]> #{shippingDateTo}
</if>
<if test="shippingMethod != null and shippingMethod != ''">
AND B.outGb = #{shippingMethod}
AND SHIPPING_METHOD = #{shippingMethod}
</if>
<if test="manager != null and manager != ''">
AND B.bEmpNo = #{manager}
AND PM_USER_ID = #{manager}
</if>
<if test="incoterms != null and incoterms != ''">
AND B.incoterms = #{incoterms}
AND INCOTERMS = #{incoterms}
</if>
ORDER BY B.CRET_DATE DESC
ORDER BY REGDATE DESC
LIMIT #{COUNT_PER_PAGE} OFFSET #{PAGE_START}
</select>
<!-- 매출관리 그리드 목록 개수 -->
<select id="getSalesMgmtGridListCount" parameterType="map" resultType="int">
/* salesNcollectMgmt.getSalesMgmtGridListCount */
<!-- 매출관리 그리드 목록 개수 (VIEW 기반) -->
<select id="getSalesMgmtGridListCount" parameterType="map" resultType="map">
/* salesNcollectMgmt.getSalesMgmtGridListCount - VIEW 기반 */
SELECT
COUNT(1)
FROM SWSC110A_TBL B
LEFT JOIN SWSD010A_TBL A ON A.orderNo = B.orderNo
INNER JOIN SWSB110A_TBL C ON B.goodsCd = C.goodsCd
INNER JOIN SWSB210A_TBL D ON B.custCd = D.custCd
CEIL(COUNT(1)::float / #{COUNT_PER_PAGE}::float)::numeric::integer AS MAX_PAGE_SIZE,
COUNT(1)::integer AS TOTAL_CNT
FROM v_sales_mgmt_with_splits
WHERE 1 = 1
<if test="orderType != null and orderType != ''">
AND B.SaleType = #{orderType}
AND CATEGORY_CD = #{orderType}
</if>
<if test="productType != null and productType != ''">
AND C.c_class = #{productType}
AND PRODUCT_TYPE = #{productType}
</if>
<if test="nation != null and nation != ''">
AND B.nationGB = #{nation}
AND AREA_CD = #{nation}
</if>
<if test="customer != null and customer != ''">
AND D.custNm LIKE CONCAT('%', #{customer}, '%')
AND CUSTOMER LIKE CONCAT('%', #{customer}, '%')
</if>
<if test="paymentType != null and paymentType != ''">
AND B.freeyn = #{paymentType}
AND PAID_TYPE = #{paymentType}
</if>
<if test="productNo != null and productNo != ''">
AND C.GoodsCd LIKE CONCAT('%', #{productNo}, '%')
AND PRODUCT_NO LIKE CONCAT('%', #{productNo}, '%')
</if>
<if test="productName != null and productName != ''">
AND C.GoodsNm LIKE CONCAT('%', #{productName}, '%')
AND PRODUCT_NAME LIKE CONCAT('%', #{productName}, '%')
</if>
<if test="serialNo != null and serialNo != ''">
AND A.serialno LIKE CONCAT('%', #{serialNo}, '%')
AND SERIAL_NO LIKE CONCAT('%', #{serialNo}, '%')
</if>
<if test="orderStatus != null and orderStatus != ''">
AND B.endsale = #{orderStatus}
AND STATUS_CD = #{orderStatus}
</if>
<if test="poNo != null and poNo != ''">
AND B.OrderNo LIKE CONCAT('%', #{poNo}, '%')
AND PO_NO LIKE CONCAT('%', #{poNo}, '%')
</if>
<if test="requestDateFrom != null and requestDateFrom != ''">
AND B.custreq <![CDATA[>=]]> #{requestDateFrom}
AND REQUEST_DATE <![CDATA[>=]]> #{requestDateFrom}
</if>
<if test="requestDateTo != null and requestDateTo != ''">
AND B.custreq <![CDATA[<=]]> #{requestDateTo}
AND REQUEST_DATE <![CDATA[<=]]> #{requestDateTo}
</if>
<if test="orderDateFrom != null and orderDateFrom != ''">
AND B.OrderDate <![CDATA[>=]]> #{orderDateFrom}
AND ORDER_DATE <![CDATA[>=]]> #{orderDateFrom}
</if>
<if test="orderDateTo != null and orderDateTo != ''">
AND B.OrderDate <![CDATA[<=]]> #{orderDateTo}
AND ORDER_DATE <![CDATA[<=]]> #{orderDateTo}
</if>
<if test="shippingStatus != null and shippingStatus != ''">
AND B.shippingstatus = #{shippingStatus}
AND SALES_STATUS = #{shippingStatus}
</if>
<if test="shippingDateFrom != null and shippingDateFrom != ''">
AND B.shippingdate <![CDATA[>=]]> #{shippingDateFrom}
AND SHIPPING_DATE <![CDATA[>=]]> #{shippingDateFrom}
</if>
<if test="shippingDateTo != null and shippingDateTo != ''">
AND B.shippingdate <![CDATA[<=]]> #{shippingDateTo}
AND SHIPPING_DATE <![CDATA[<=]]> #{shippingDateTo}
</if>
<if test="shippingMethod != null and shippingMethod != ''">
AND B.outGb = #{shippingMethod}
AND SHIPPING_METHOD = #{shippingMethod}
</if>
<if test="manager != null and manager != ''">
AND B.bEmpNo = #{manager}
AND PM_USER_ID = #{manager}
</if>
<if test="incoterms != null and incoterms != ''">
AND B.incoterms = #{incoterms}
AND INCOTERMS = #{incoterms}
</if>
</select>
<!-- 매출관리 합계 조회 (Total 공급가액, 부가세, 총액) -->
<select id="getSalesMgmtTotals" parameterType="map" resultType="map">
/* salesNcollectMgmt.getSalesMgmtTotals */
SELECT
COALESCE(SUM(COALESCE(A.order_supply_price, '0')::numeric), 0)::numeric AS TOTAL_SUPPLY_PRICE, /* Total 공급가액 */
COALESCE(SUM(COALESCE(A.order_vat, '0')::numeric), 0)::numeric AS TOTAL_VAT, /* Total 부가세 */
COALESCE(SUM(COALESCE(A.order_total_amount, '0')::numeric), 0)::numeric AS TOTAL_AMOUNT /* Total 총액 */
FROM contract_mgmt A
LEFT JOIN supply_mng SUP ON SUP.objid::varchar = A.customer_objid
WHERE 1 = 1
<if test="orderType != null and orderType != ''">
AND A.category_cd = #{orderType}
</if>
<if test="productType != null and productType != ''">
AND A.product = #{productType}
</if>
<if test="nation != null and nation != ''">
AND A.area_cd = #{nation}
</if>
<if test="customer != null and customer != ''">
AND SUP.supply_name LIKE CONCAT('%', #{customer}, '%')
</if>
<if test="paymentType != null and paymentType != ''">
AND A.paid_type = #{paymentType}
</if>
<if test="productNo != null and productNo != ''">
AND A.part_no LIKE CONCAT('%', #{productNo}, '%')
</if>
<if test="productName != null and productName != ''">
AND A.part_name LIKE CONCAT('%', #{productName}, '%')
</if>
<if test="serialNo != null and serialNo != ''">
AND A.serial_no LIKE CONCAT('%', #{serialNo}, '%')
</if>
<if test="orderStatus != null and orderStatus != ''">
AND A.status_cd = #{orderStatus}
</if>
<if test="poNo != null and poNo != ''">
AND A.po_no LIKE CONCAT('%', #{poNo}, '%')
</if>
<if test="requestDateFrom != null and requestDateFrom != ''">
AND A.req_del_date <![CDATA[>=]]> #{requestDateFrom}
</if>
<if test="requestDateTo != null and requestDateTo != ''">
AND A.req_del_date <![CDATA[<=]]> #{requestDateTo}
</if>
<if test="orderDateFrom != null and orderDateFrom != ''">
AND A.order_date <![CDATA[>=]]> #{orderDateFrom}
</if>
<if test="orderDateTo != null and orderDateTo != ''">
AND A.order_date <![CDATA[<=]]> #{orderDateTo}
</if>
<if test="shippingStatus != null and shippingStatus != ''">
/* shippingStatus 필드가 contract_mgmt에 없어서 주석 처리 */
</if>
<if test="shippingDateFrom != null and shippingDateFrom != ''">
/* shippingDate 조인 안됨 */
</if>
<if test="shippingDateTo != null and shippingDateTo != ''">
/* shippingDate 조인 안됨 */
</if>
<if test="shippingMethod != null and shippingMethod != ''">
/* shippingMethod 필드가 contract_mgmt에 없어서 주석 처리 */
</if>
<if test="manager != null and manager != ''">
AND A.pm_user_id = #{manager}
</if>
<if test="incoterms != null and incoterms != ''">
/* incoterms 필드가 contract_mgmt에 없어서 주석 처리 */
</if>
</select>
<!--
/**
* 분할출하 - 원본 데이터 조회
* @since 2025.10.20
* @author system
* @version 1.0
**/
-->
<select id="getContractByObjid" parameterType="map" resultType="map">
/* salesNcollectMgmt.getContractByObjid */
SELECT
*
FROM contract_mgmt
WHERE objid = #{objid}
</select>
<!--
/**
* 분할출하 로그 저장 (로그 기반 방식)
* @since 2025.10.20
* @author system
* @version 1.0
**/
-->
<insert id="insertSplitShipmentLog" parameterType="map">
/* salesNcollectMgmt.insertSplitShipmentLog */
INSERT INTO shipment_log (
target_objid,
log_type,
log_message,
split_quantity,
original_quantity,
shipping_status,
sales_unit_price,
sales_supply_price,
sales_vat,
sales_total_amount,
sales_currency,
sales_exchange_rate,
serial_no,
shipping_date,
shipping_method,
manager_user_id,
incoterms,
remark,
is_split_record,
reg_date,
reg_user_id
) VALUES (
#{objid},
#{logType},
#{logMessage},
#{splitQuantity}::integer,
#{originalQuantity}::integer,
'PENDING',
#{salesUnitPrice}::numeric,
#{salesSupplyPrice}::numeric,
#{salesVat}::numeric,
#{salesTotalAmount}::numeric,
#{salesCurrency},
#{salesExchangeRate}::numeric,
#{serialNo},
<choose>
<when test="shippingDate != null and shippingDate != ''">
TO_DATE(#{shippingDate}, 'YYYY-MM-DD'),
</when>
<otherwise>
NULL,
</otherwise>
</choose>
#{shippingMethod},
#{managerUserId},
#{incoterms},
#{remark},
true,
NOW(),
#{userId}
)
</insert>
</mapper>

View File

@@ -147,14 +147,18 @@ public class SalesNcollectMgmtService {
try {
sqlSession = SqlMapConfig.getInstance().getSqlSession();
// Tabulator는 page, size 파라미터를 사용
String page = CommonUtils.checkNull(request.getParameter("page"), "1");
String size = CommonUtils.checkNull(request.getParameter("size"), Constants.ADMIN_COUNT_PER_PAGE+"");
int pageNum = Integer.parseInt(page);
int sizeNum = Integer.parseInt(size);
// 페이징 HTML 생성을 위해 DB에서 총 카운트 조회
String countPerPage = CommonUtils.checkNull(request.getParameter("size"), Constants.ADMIN_COUNT_PER_PAGE+"");
paramMap.put("COUNT_PER_PAGE", Integer.parseInt(countPerPage));
Map pageMap = (HashMap) sqlSession.selectOne("salesNcollectMgmt.getSalesMgmtGridListCount", paramMap);
pageMap = (HashMap) CommonUtils.setPagingInfo(request, pageMap);
paramMap.put("PAGE_HTML", CommonUtils.checkNull(pageMap.get("PAGE_HTML")));
// 실제 쿼리에 사용할 LIMIT, OFFSET 값 계산 (정수 타입으로)
String page = CommonUtils.checkNull(request.getParameter("page"), "1");
int pageNum = Integer.parseInt(page);
int sizeNum = Integer.parseInt(countPerPage);
paramMap.put("PAGE_START", (pageNum - 1) * sizeNum);
paramMap.put("COUNT_PER_PAGE", sizeNum);
resultList = (ArrayList) sqlSession.selectList("salesNcollectMgmt.getSalesMgmtGridList", paramMap);
} catch(Exception e) {
@@ -181,7 +185,10 @@ public class SalesNcollectMgmtService {
try {
sqlSession = SqlMapConfig.getInstance().getSqlSession();
totalCount = sqlSession.selectOne("salesNcollectMgmt.getSalesMgmtGridListCount", paramMap);
Map<String, Object> resultMap = sqlSession.selectOne("salesNcollectMgmt.getSalesMgmtGridListCount", paramMap);
if(resultMap != null && resultMap.get("TOTAL_CNT") != null) {
totalCount = Integer.parseInt(resultMap.get("TOTAL_CNT").toString());
}
} catch(Exception e) {
e.printStackTrace();
} finally {
@@ -193,6 +200,190 @@ public class SalesNcollectMgmtService {
return totalCount;
}
/**
* 매출관리 합계 조회 (Total 공급가액, 부가세, 총액)
* @param paramMap - 검색 조건
* @return Map - TOTAL_SUPPLY_PRICE, TOTAL_VAT, TOTAL_AMOUNT
*/
public Map<String, Object> getSalesMgmtTotals(Map<String, Object> paramMap) {
SqlSession sqlSession = null;
Map<String, Object> totalsMap = new HashMap<String, Object>();
try {
sqlSession = SqlMapConfig.getInstance().getSqlSession();
totalsMap = sqlSession.selectOne("salesNcollectMgmt.getSalesMgmtTotals", paramMap);
if(totalsMap == null) {
totalsMap = new HashMap<String, Object>();
totalsMap.put("TOTAL_SUPPLY_PRICE", 0);
totalsMap.put("TOTAL_VAT", 0);
totalsMap.put("TOTAL_AMOUNT", 0);
}
} catch(Exception e) {
e.printStackTrace();
totalsMap.put("TOTAL_SUPPLY_PRICE", 0);
totalsMap.put("TOTAL_VAT", 0);
totalsMap.put("TOTAL_AMOUNT", 0);
} finally {
if(sqlSession != null) {
sqlSession.close();
}
}
return totalsMap;
}
/**
* <pre>
* 판매 정보 조회
* </pre>
* @param paramMap
* @return Map<String, Object>
*/
public Map<String, Object> getSaleInfo(Map<String, Object> paramMap) {
Map<String, Object> resultMap = new HashMap<String, Object>();
SqlSession sqlSession = null;
try {
sqlSession = SqlMapConfig.getInstance().getSqlSession();
resultMap = sqlSession.selectOne("salesNcollectMgmt.getSaleInfo", paramMap);
} catch(Exception e) {
e.printStackTrace();
} finally {
if(sqlSession != null) {
sqlSession.close();
}
}
return CommonUtils.toUpperCaseMapKey(resultMap);
}
public Map<String, Object> saveSaleRegistration(HttpServletRequest request, Map<String, Object> paramMap) {
Map<String, Object> resultMap = new HashMap<String, Object>();
SqlSession sqlSession = null;
try {
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
PersonBean person = (PersonBean) request.getSession().getAttribute(Constants.PERSON_BEAN);
paramMap.put("cretEmpNo", person.getUserId());
// SWSC110A_TBL 업데이트
sqlSession.update("salesNcollectMgmt.updateSaleRegistration_swsc110a", paramMap);
// SWSD010A_TBL 업데이트 (insert or update)
sqlSession.update("salesNcollectMgmt.upsertSaleRegistration_swsd010a", paramMap);
sqlSession.commit();
resultMap.put("result", true);
resultMap.put("msg", "저장되었습니다.");
} catch(Exception e) {
sqlSession.rollback();
resultMap.put("result", false);
resultMap.put("msg", "저장 중 오류가 발생했습니다.");
e.printStackTrace();
} finally {
if(sqlSession != null) {
sqlSession.close();
}
}
return resultMap;
}
/**
* <pre>
* 분할출하 처리 (로그 기반)
* - 원본 데이터는 그대로 유지
* - 분할출하 로그만 shipment_log에 저장
* - 화면에서는 VIEW를 통해 원본 + 로그를 합쳐서 표시
* </pre>
* @param request
* @param paramMap - 분할출하 정보
* @return Map
*/
public Map<String, Object> splitShipment(HttpServletRequest request, Map<String, Object> paramMap) {
Map<String, Object> resultMap = new HashMap<String, Object>();
SqlSession sqlSession = null;
try {
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
PersonBean person = (PersonBean) request.getSession().getAttribute(Constants.PERSON_BEAN);
String userId = person.getUserId();
// 원본 데이터 조회
Map<String, Object> originalData = sqlSession.selectOne("salesNcollectMgmt.getContractByObjid", paramMap);
if(originalData == null) {
resultMap.put("result", false);
resultMap.put("msg", "원본 데이터를 찾을 수 없습니다.");
return resultMap;
}
// 분할 수량
int splitQuantity = Integer.parseInt(paramMap.get("splitQuantity").toString());
int originalQuantity = Integer.parseInt(paramMap.get("originalQuantity").toString());
// 원본 데이터의 단가 정보 가져오기
BigDecimal unitPrice = new BigDecimal(originalData.get("order_unit_price").toString());
BigDecimal exchangeRate = new BigDecimal(originalData.get("exchange_rate").toString());
// 분할 금액 계산
BigDecimal splitSupplyPrice = unitPrice.multiply(new BigDecimal(splitQuantity));
BigDecimal splitVat = splitSupplyPrice.multiply(new BigDecimal("0.1"));
BigDecimal splitTotalAmount = splitSupplyPrice.add(splitVat);
// 분할출하 로그 저장
paramMap.put("logType", "SPLIT_SHIPMENT");
paramMap.put("logMessage", "분할출하 - 원본수량: " + originalQuantity + ", 분할수량: " + splitQuantity);
paramMap.put("userId", userId);
paramMap.put("splitQuantity", splitQuantity);
paramMap.put("originalQuantity", originalQuantity);
paramMap.put("salesUnitPrice", unitPrice);
paramMap.put("salesSupplyPrice", splitSupplyPrice);
paramMap.put("salesVat", splitVat);
paramMap.put("salesTotalAmount", splitTotalAmount);
paramMap.put("salesCurrency", originalData.get("contract_currency"));
paramMap.put("salesExchangeRate", exchangeRate);
// 팝업에서 입력한 데이터 우선, 없으면 원본 데이터 사용
paramMap.put("shippingMethod",
StringUtils.isNotBlank((String)paramMap.get("shippingMethod")) ?
paramMap.get("shippingMethod") : originalData.get("shipping_method"));
paramMap.put("incoterms",
StringUtils.isNotBlank((String)paramMap.get("incoterms")) ?
paramMap.get("incoterms") : originalData.get("incoterms"));
paramMap.put("managerUserId",
StringUtils.isNotBlank((String)paramMap.get("manager")) ?
paramMap.get("manager") : originalData.get("pm_user_id"));
// 팝업에서 입력한 추가 정보
// serialNo, shippingDate, remark는 팝업에서만 입력 가능
sqlSession.insert("salesNcollectMgmt.insertSplitShipmentLog", paramMap);
sqlSession.commit();
resultMap.put("result", true);
resultMap.put("msg", "분할출하가 완료되었습니다.");
} catch(Exception e) {
if(sqlSession != null) {
sqlSession.rollback();
}
resultMap.put("result", false);
resultMap.put("msg", "분할출하 처리 중 오류가 발생했습니다: " + e.getMessage());
e.printStackTrace();
} finally {
if(sqlSession != null) {
sqlSession.close();
}
}
return resultMap;
}
/**
* <pre>
* 매출관리 등록