marseyes преди 2 години
родител
ревизия
ffe0a14707

+ 12 - 5
src/main/java/com/oqpo/api/entity/oper/MainChartEntity.java

@@ -5,20 +5,19 @@ import lombok.Setter;
5 5
 import lombok.ToString;
6 6
 
7 7
 import java.io.Serializable;
8
-import java.util.List;
9 8
 
10 9
 @Getter
11 10
 @Setter
12 11
 @ToString
13 12
 public class MainChartEntity implements Serializable {
14 13
 
15
-    private Integer pr20Val;
14
+    private Integer pr20Val;        /* 구매요청 */
16 15
     private Integer pr30Val;
17 16
     private Integer pr40Val;
18 17
 
19
-    private Integer po20Val;
20
-    private Integer po30Val;
21
-    private Integer po99Val;
18
+    private Integer po20Val;        /* 발주요청 */
19
+    private Integer po30Val;        /* 발주접수 */
20
+    private Integer po99Val;        /* 발주취소 */
22 21
 
23 22
     private String itemNm;          /* 품목명 */
24 23
     private Integer itemCnt;
@@ -30,4 +29,12 @@ public class MainChartEntity implements Serializable {
30 29
     private Integer st30Val;
31 30
 
32 31
     private Integer dlvVal;
32
+
33
+    private Long dp02Val;           /* 입금승인금액 */
34
+    private Long unpaidAmt;         /* 미납금액 */
35
+    private Long poPsblAmt;         /* 구매가능금액 */
36
+    private Integer ordersCount;    /* 수주건수 */
37
+    private Long ordersAmt;         /* 수주금액 */
38
+    private Long sttlReqAmt;        /* 정산요청금액 */
39
+
33 40
 }

+ 6 - 0
src/main/java/com/oqpo/api/mapper/oper/MainChartMapper.java

@@ -10,6 +10,12 @@ import java.util.List;
10 10
 @Mapper
11 11
 public interface MainChartMapper {
12 12
 
13
+    MainChartEntity selectBrandMainCount(@Param("brandId") String brandId) throws Exception;
14
+
15
+    MainChartEntity selectStoreMainCount(@Param("storeId") String storeId) throws Exception;
16
+
17
+    MainChartEntity selectSpplyMainCount(@Param("spplyId") String spplyId) throws Exception;
18
+
13 19
     MainChartEntity selectPchReqChart(@Param("brandId") String brandId, @Param("storeId") String storeId, @Param("prType") String prType) throws Exception;
14 20
 
15 21
     MainChartEntity selectPchOdrChart(@Param("brandId") String brandId, @Param("storeId") String storeId, @Param("spplyId") String spplyId,

+ 23 - 1
src/main/java/com/oqpo/api/service/oper/MainChartService.java

@@ -8,7 +8,6 @@ import com.oqpo.api.util.StringUtil;
8 8
 import com.oqpo.api.web.dto.response.oper.mainchart.ChartResponse;
9 9
 import lombok.extern.slf4j.Slf4j;
10 10
 import org.springframework.beans.factory.annotation.Autowired;
11
-import org.springframework.security.core.parameters.P;
12 11
 import org.springframework.stereotype.Service;
13 12
 
14 13
 import java.util.List;
@@ -20,6 +19,29 @@ public class MainChartService extends CommonService {
20 19
     @Autowired
21 20
     private MainChartMapper mainChartMapper;
22 21
 
22
+    public ChartResponse selectMainCount(String brandId, String storeId, String spplyId) throws Exception {
23
+        MainChartEntity entity = null;
24
+        if (!StringUtil.isEmpty(spplyId)) {
25
+            entity = mainChartMapper.selectSpplyMainCount(spplyId);
26
+        } else if (!StringUtil.isEmpty(storeId)) {
27
+            entity = mainChartMapper.selectStoreMainCount(storeId);
28
+        } else if (!StringUtil.isEmpty(brandId)) {
29
+            entity = mainChartMapper.selectBrandMainCount(brandId);
30
+        }
31
+
32
+        ChartResponse result = new ChartResponse();
33
+        result.setPr20Count(entity.getPr20Val());       // 구매요청 건수 : 당일 구매요청 대기 건수
34
+        result.setDp02Amt(entity.getDp02Val());         // 입금승인금액
35
+        result.setUnpaidAmt(entity.getUnpaidAmt());     // 미납금액
36
+        result.setPo30Count(entity.getPo30Val());       // 발주진행
37
+        result.setPoEndCount(entity.getDlvVal());       // 발주완료
38
+        result.setPoPsblAmt(entity.getPoPsblAmt());     // 구매가능금액
39
+        result.setOrdersCount(entity.getOrdersCount());     // 수주건수
40
+        result.setOrdersAmt(entity.getOrdersAmt());         // 수주금액
41
+        result.setSttlReqAmt(entity.getSttlReqAmt());       // 정산요청금액
42
+        return result;
43
+    }
44
+
23 45
     public ChartResponse selectPchReqChart(String brandId, String storeId, String prType) throws Exception {
24 46
         MainChartEntity entity = mainChartMapper.selectPchReqChart(brandId, storeId, prType);
25 47
 

+ 21 - 0
src/main/java/com/oqpo/api/web/controller/oper/MainChartController.java

@@ -20,6 +20,27 @@ public class MainChartController {
20 20
     @Autowired
21 21
     private MainChartService mainChartService;
22 22
 
23
+    /**
24
+     * 설명 : 메인화면 카운트
25
+     *
26
+     * @param brandId
27
+     * @return
28
+     * @throws Exception
29
+     */
30
+    @ApiImplicitParams({
31
+            @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header"),
32
+            @ApiImplicitParam(name = "brandId", value = "브랜드아이디", required = true, dataType = "String", paramType = "query"),
33
+            @ApiImplicitParam(name = "storeId", value = "매장아이디", required = true, dataType = "String", paramType = "query"),
34
+            @ApiImplicitParam(name = "spplyId", value = "공급사아이디", required = true, dataType = "String", paramType = "query")
35
+    })
36
+    @ApiOperation(value = "메인화면 카운트")
37
+    @GetMapping("/count")
38
+    public ResponseEntity<ChartResponse> count(@RequestParam(value = "brandId") String brandId,
39
+                                               @RequestParam(value = "storeId") String storeId,
40
+                                               @RequestParam(value = "spplyId") String spplyId) throws Exception {
41
+        return ResponseEntity.ok(mainChartService.selectMainCount(brandId, storeId, spplyId));
42
+    }
43
+
23 44
     /**
24 45
      * 설명 : 구매요청 차트
25 46
      *

+ 27 - 0
src/main/java/com/oqpo/api/web/dto/response/oper/mainchart/ChartResponse.java

@@ -16,5 +16,32 @@ public class ChartResponse {
16 16
     @ApiModelProperty(value = "차트 데이터")
17 17
     private String chartData;
18 18
 
19
+    @ApiModelProperty(value = "구매요청 건수")
20
+    private Integer pr20Count;
21
+
22
+    @ApiModelProperty(value = "입금액 (입금승인금액)")
23
+    private Long dp02Amt;
24
+
25
+    @ApiModelProperty(value = "미납금액")
26
+    private Long unpaidAmt;
27
+
28
+    @ApiModelProperty(value = "발주진행 건수")
29
+    private Integer po30Count;
30
+
31
+    @ApiModelProperty(value = "발주완료 건수")
32
+    private Integer poEndCount;
33
+
34
+    @ApiModelProperty(value = "구매가능금액")
35
+    private Long poPsblAmt;
36
+
37
+    @ApiModelProperty(value = "수주건수")
38
+    private Integer ordersCount;
39
+
40
+    @ApiModelProperty(value = "수주금액")
41
+    private Long ordersAmt;
42
+
43
+    @ApiModelProperty(value = "정산요청금액")
44
+    private Long sttlReqAmt;
45
+
19 46
 }
20 47
 

+ 81 - 0
src/main/resources/mybatis/sqlmaps/oper/MainChart.xml

@@ -3,6 +3,87 @@
3 3
 
4 4
 <mapper namespace="com.oqpo.api.mapper.oper.MainChartMapper">
5 5
 
6
+    <select id="selectBrandMainCount" resultType="com.oqpo.api.entity.oper.MainChartEntity">
7
+        /* MainChartMapper.selectBrandMainCount */
8
+        SELECT *
9
+        FROM (
10
+            SELECT COUNT(*) AS PR20_VAL
11
+            FROM pch_req_base_info A
12
+            WHERE 1 = 1
13
+            AND A.PCH_REQ_ST_CD = 'PR20'
14
+            /*AND A.PCH_REQ_DT = DATE_FORMAT(NOW(), '%Y%m%d')*/
15
+            AND A.BRAND_ID = #{brandId}
16
+        ) T1, (
17
+            SELECT IFNULL(SUM(A.DPST_AMT), 0) AS DP02_VAL
18
+            FROM loan_mgnt_dspt_proc A
19
+            WHERE 1 = 1
20
+            AND A.DPST_ST_CD = 'DP02'
21
+            AND A.DPST_AUTH_DT = DATE_FORMAT(NOW(), '%Y%m%d')
22
+            AND A.BRAND_ID = #{brandId}
23
+        ) T2, (
24
+            SELECT IFNULL(SUM(IFNULL(A.STTL_AMT, A.STTL_REQ_AMT) - IFNULL(A.RCPT_AMT, 0)), 0) AS UNPAID_AMT
25
+            FROM stl_mgnt_base_info A               /* 정산관리기본정보 */
26
+            INNER JOIN store_base_info B ON A.STORE_ID = B.STORE_ID     /* 매장 미납금액 */
27
+            WHERE 1 = 1
28
+            AND A.STTL_ST_CD IN ('ST10','ST20')                 /* 정산요청,정산확정 */
29
+            AND IFNULL(A.RCPT_YN,'N') = 'N'                     /* 수납완료여부 */
30
+            AND A.BRAND_ID = #{brandId}
31
+        ) T3
32
+    </select>
33
+
34
+    <select id="selectStoreMainCount" resultType="com.oqpo.api.entity.oper.MainChartEntity">
35
+        /* MainChartMapper.selectStoreMainCount */
36
+        SELECT *
37
+        FROM (
38
+            SELECT COUNT(*) AS PR20_VAL
39
+            FROM pch_req_base_info A                /* 구매요청기본정보 */
40
+            WHERE 1 = 1
41
+            AND A.PCH_REQ_ST_CD = 'PR20'
42
+            /*AND A.PCH_REQ_DT = DATE_FORMAT(NOW(), '%Y%m%d')*/
43
+            AND A.STORE_ID = #{storeId}
44
+        ) T1, (
45
+            SELECT COUNT(*) AS PO30_VAL
46
+            FROM pch_odr_base_info A                /* 구매발주기본정보 */
47
+            WHERE 1 = 1
48
+            AND A.PCH_ODR_ST_CD = 'PO30'            /* 발주접수 */
49
+            /*AND A.PODR_DT = DATE_FORMAT(NOW(), '%Y%m%d')     발주일자 */
50
+            AND A.STORE_ID = #{storeId}
51
+        ) T2, (
52
+            SELECT COUNT(*) AS DLV_VAL
53
+            FROM deli_info_mgnt A               /* 납품정보관리 */
54
+            WHERE A.DLV_ST_CD = 'DLV1'          /* 완료 */
55
+            AND A.DLV_CMPLT_DT = DATE_FORMAT(NOW(), '%Y%m%d')
56
+            AND A.STORE_ID = #{storeId}
57
+        ) T3, (
58
+            SELECT
59
+                CASE
60
+                WHEN B.LOAN_DVSN = 'LD01' THEN B.ACCT_BAL + IFNULL(B.TMP_RCV_ACCT_TOTAL, 0)		/* 선불 */
61
+                WHEN B.LOAN_DVSN = 'LD02' THEN B.CREDT_LIMIT_AMT + IFNULL(B.TMP_RCV_ACCT_TOTAL, 0) - IFNULL(B.USE_AMT_TOTAL,0)		/* 후불 */
62
+                END PO_PSBL_AMT
63
+            FROM store_base_info A
64
+            INNER JOIN loan_mgnt_base_info B ON A.LOAN_MGNT_UNQ_NO = B.LOAN_MGNT_UNQ_NO
65
+            WHERE A.STORE_ID = #{storeId}
66
+        ) T4
67
+    </select>
68
+
69
+    <select id="selectSpplyMainCount" resultType="com.oqpo.api.entity.oper.MainChartEntity">
70
+        /* MainChartMapper.selectSpplyMainCount */
71
+        SELECT *
72
+        FROM (
73
+            SELECT COUNT(*) AS ORDERS_COUNT     /* 수주건수 : 납품서생성 */
74
+                , IFNULL(SUM(A.DLV_AMT),0) AS ORDERS_AMT  /* 수주금액 */
75
+            FROM deli_info_mgnt A               /* 납품정보관리 */
76
+            WHERE A.DLV_ST_CD = 'DLV0'          /* 생성 */
77
+            AND A.DLV_REG_DT = DATE_FORMAT(NOW(), '%Y%m%d')     /* 납품생성일자 */
78
+            AND A.SPPLY_ID = #{spplyId}
79
+        ) T1, (
80
+            SELECT SUM(A.STTL_REQ_AMT) AS STTL_REQ_AMT  /* 정산요청금액 */
81
+            FROM stl_mgnt_base_info A                   /* 정산관리기본정보 */
82
+            WHERE A.STTL_ST_CD = 'ST10'          /* 정산요청 */
83
+            AND A.SPPLY_ID = #{spplyId}
84
+        ) T2
85
+    </select>
86
+
6 87
     <select id="selectPchReqChart" resultType="com.oqpo.api.entity.oper.MainChartEntity">
7 88
         /* MainChartMapper.selectPchReqChart */
8 89
         SELECT