Ver código fonte

구매발주 그래프

marseyes 2 anos atrás
pai
commit
517931f45f

+ 4 - 0
src/main/java/com/oqpo/api/entity/oper/MainChartEntity.java

@@ -16,4 +16,8 @@ public class MainChartEntity implements Serializable {
16 16
     private Integer pr30Val;
17 17
     private Integer pr40Val;
18 18
 
19
+    private Integer po20Val;
20
+    private Integer po30Val;
21
+    private Integer po99Val;
22
+
19 23
 }

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

@@ -10,4 +10,6 @@ public interface MainChartMapper {
10 10
 
11 11
     MainChartEntity selectPchReqChart(@Param("brandId") String brandId, @Param("storeId") String storeId, @Param("prType") String prType) throws Exception;
12 12
 
13
+    MainChartEntity selectPchOdrChart(@Param("brandId") String brandId, @Param("storeId") String storeId, @Param("poType") String poType) throws Exception;
14
+
13 15
 }

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

@@ -1,33 +1,13 @@
1 1
 package com.oqpo.api.service.oper;
2 2
 
3 3
 
4
-import com.oqpo.api.entity.oper.FileEntity;
5 4
 import com.oqpo.api.entity.oper.MainChartEntity;
6
-import com.oqpo.api.entity.oper.NticeEntity;
7
-import com.oqpo.api.entity.oper.NticeTargetEntity;
8
-import com.oqpo.api.enums.SystemMessageCode;
9
-import com.oqpo.api.exception.GlobalException;
10
-import com.oqpo.api.mapper.FileMapper;
11 5
 import com.oqpo.api.mapper.oper.MainChartMapper;
12
-import com.oqpo.api.mapper.oper.NticeMapper;
13 6
 import com.oqpo.api.service.CommonService;
14
-import com.oqpo.api.util.HtmlCharConverter;
15
-import com.oqpo.api.web.dto.request.GridRequest;
16
-import com.oqpo.api.web.dto.request.oper.ntice.SaveNticeRequest;
17
-import com.oqpo.api.web.dto.response.GridResponse;
18
-import com.oqpo.api.web.dto.response.oper.mainchart.PchReqChartResponse;
19
-import com.oqpo.api.web.dto.response.oper.ntice.MainNticeSearchResponse;
20
-import com.oqpo.api.web.dto.response.oper.ntice.NticeResponse;
21
-import com.oqpo.api.web.dto.response.oper.ntice.NticeSearchResponse;
22
-import com.oqpo.api.web.dto.response.oper.ntice.NticeTargetResponse;
7
+import com.oqpo.api.web.dto.response.oper.mainchart.ChartResponse;
23 8
 import lombok.extern.slf4j.Slf4j;
24 9
 import org.springframework.beans.factory.annotation.Autowired;
25 10
 import org.springframework.stereotype.Service;
26
-import org.springframework.transaction.annotation.Transactional;
27
-
28
-import java.util.ArrayList;
29
-import java.util.List;
30
-import java.util.stream.Collectors;
31 11
 
32 12
 @Service
33 13
 @Slf4j
@@ -36,12 +16,22 @@ public class MainChartService extends CommonService {
36 16
     @Autowired
37 17
     private MainChartMapper mainChartMapper;
38 18
 
39
-    public PchReqChartResponse selectPchReqChart(String brandId, String storeId, String prType) throws Exception {
19
+    public ChartResponse selectPchReqChart(String brandId, String storeId, String prType) throws Exception {
40 20
         MainChartEntity entity = mainChartMapper.selectPchReqChart(brandId, storeId, prType);
41 21
 
42 22
         String chartData = "[ [' ', '대기', '반려', '승인',], [' ', " + entity.getPr20Val() + " , " + entity.getPr30Val() + " , " + entity.getPr40Val() + "] ]";
43 23
 
44
-        PchReqChartResponse result = new PchReqChartResponse();
24
+        ChartResponse result = new ChartResponse();
25
+        result.setChartData(chartData);
26
+        return result;
27
+    }
28
+
29
+    public ChartResponse selectPchOdrChart(String brandId, String storeId, String poType) throws Exception {
30
+        MainChartEntity entity = mainChartMapper.selectPchOdrChart(brandId, storeId, poType);
31
+
32
+        String chartData = "[ [' ', '요청', '진행', '취소',], [' ', " + entity.getPo20Val() + " , " + entity.getPo30Val() + " , " + entity.getPo99Val() + "] ]";
33
+
34
+        ChartResponse result = new ChartResponse();
45 35
         result.setChartData(chartData);
46 36
         return result;
47 37
     }

+ 25 - 4
src/main/java/com/oqpo/api/web/controller/oper/MainChartController.java

@@ -1,7 +1,7 @@
1 1
 package com.oqpo.api.web.controller.oper;
2 2
 
3 3
 import com.oqpo.api.service.oper.MainChartService;
4
-import com.oqpo.api.web.dto.response.oper.mainchart.PchReqChartResponse;
4
+import com.oqpo.api.web.dto.response.oper.mainchart.ChartResponse;
5 5
 import io.swagger.annotations.Api;
6 6
 import io.swagger.annotations.ApiImplicitParam;
7 7
 import io.swagger.annotations.ApiImplicitParams;
@@ -35,10 +35,31 @@ public class MainChartController {
35 35
     })
36 36
     @ApiOperation(value = "구매요청 차트")
37 37
     @GetMapping("/pch-req-chart")
38
-    public ResponseEntity<PchReqChartResponse> pch_req_chart(@RequestParam(value = "brandId") String brandId,
39
-                                                             @RequestParam(value = "storeId") String storeId,
40
-                                                             @RequestParam(value = "prType") String prType) throws Exception {
38
+    public ResponseEntity<ChartResponse> pch_req_chart(@RequestParam(value = "brandId") String brandId,
39
+                                                       @RequestParam(value = "storeId") String storeId,
40
+                                                       @RequestParam(value = "prType") String prType) throws Exception {
41 41
         return ResponseEntity.ok(mainChartService.selectPchReqChart(brandId, storeId, prType));
42 42
     }
43 43
 
44
+    /**
45
+     * 설명 : 구매발주 차트
46
+     *
47
+     * @param brandId
48
+     * @return
49
+     * @throws Exception
50
+     */
51
+    @ApiImplicitParams({
52
+            @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header"),
53
+            @ApiImplicitParam(name = "brandId", value = "브랜드아이디", required = true, dataType = "String", paramType = "query"),
54
+            @ApiImplicitParam(name = "storeId", value = "매장아이디", required = true, dataType = "String", paramType = "query"),
55
+            @ApiImplicitParam(name = "poType", value = "구매발주타입", required = true, dataType = "String", paramType = "query")
56
+    })
57
+    @ApiOperation(value = "구매요청 차트")
58
+    @GetMapping("/pch-odr-chart")
59
+    public ResponseEntity<ChartResponse> pch_odr_chart(@RequestParam(value = "brandId") String brandId,
60
+                                                       @RequestParam(value = "storeId") String storeId,
61
+                                                       @RequestParam(value = "poType") String poType) throws Exception {
62
+        return ResponseEntity.ok(mainChartService.selectPchOdrChart(brandId, storeId, poType));
63
+    }
64
+
44 65
 }

+ 1 - 1
src/main/java/com/oqpo/api/web/dto/response/oper/mainchart/PchReqChartResponse.java

@@ -11,7 +11,7 @@ import java.util.stream.Collectors;
11 11
 
12 12
 @Getter
13 13
 @Setter
14
-public class PchReqChartResponse {
14
+public class ChartResponse {
15 15
 
16 16
     @ApiModelProperty(value = "차트 데이터")
17 17
     private String chartData;

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

@@ -31,4 +31,32 @@
31 31
         </if>
32 32
     </select>
33 33
 
34
+    <select id="selectPchOdrChart" resultType="com.oqpo.api.entity.oper.MainChartEntity">
35
+        /* MainChartMapper.selectPchOdrChart */
36
+        SELECT
37
+        COUNT(CASE WHEN A.pch_odr_st_cd = 'PO20' THEN A.pch_podr_unq_no END) AS po20_val,
38
+        COUNT(CASE WHEN A.pch_odr_st_cd = 'PO30' THEN A.pch_podr_unq_no END) AS po30_val,
39
+        COUNT(CASE WHEN A.pch_odr_st_cd = 'PO99' THEN A.pch_podr_unq_no END) AS po99_val
40
+        FROM pch_odr_base_info A
41
+        WHERE 1 = 1
42
+        <if test="brandId != null and brandId != '' ">
43
+            AND A.brand_id = #{brandId}
44
+        </if>
45
+        <if test="storeId != null and storeId != '' ">
46
+            AND A.store_id = #{storeId}
47
+        </if>
48
+        <if test='"A".equals(poType)'>
49
+            AND A.podr_dt = DATE_FORMAT(NOW(), '%Y%m%d')
50
+        </if>
51
+        <if test='"B".equals(poType)'>
52
+            AND A.podr_dt BETWEEN DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 7 DAY), '%Y%m%d') AND DATE_FORMAT(NOW(), '%Y%m%d')
53
+        </if>
54
+        <if test='"C".equals(poType)'>
55
+            AND A.podr_dt BETWEEN DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 15 DAY), '%Y%m%d') AND DATE_FORMAT(NOW(), '%Y%m%d')
56
+        </if>
57
+        <if test='"D".equals(poType)'>
58
+            AND A.podr_dt BETWEEN DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 MONTH), '%Y%m%d') AND DATE_FORMAT(NOW(), '%Y%m%d')
59
+        </if>
60
+    </select>
61
+
34 62
 </mapper>