Przeglądaj źródła

메인화면 구매요청

marseyes 2 lat temu
rodzic
commit
2f36ac5df9

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

@@ -0,0 +1,19 @@
1
+package com.oqpo.api.entity.oper;
2
+
3
+import lombok.Getter;
4
+import lombok.Setter;
5
+import lombok.ToString;
6
+
7
+import java.io.Serializable;
8
+import java.util.List;
9
+
10
+@Getter
11
+@Setter
12
+@ToString
13
+public class MainChartEntity implements Serializable {
14
+
15
+    private Integer pr20Val;
16
+    private Integer pr30Val;
17
+    private Integer pr40Val;
18
+
19
+}

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

@@ -0,0 +1,13 @@
1
+package com.oqpo.api.mapper.oper;
2
+
3
+
4
+import com.oqpo.api.entity.oper.MainChartEntity;
5
+import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+@Mapper
9
+public interface MainChartMapper {
10
+
11
+    MainChartEntity selectPchReqChart(@Param("brandId") String brandId, @Param("storeId") String storeId, @Param("prType") String prType) throws Exception;
12
+
13
+}

+ 49 - 0
src/main/java/com/oqpo/api/service/oper/MainChartService.java

@@ -0,0 +1,49 @@
1
+package com.oqpo.api.service.oper;
2
+
3
+
4
+import com.oqpo.api.entity.oper.FileEntity;
5
+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
+import com.oqpo.api.mapper.oper.MainChartMapper;
12
+import com.oqpo.api.mapper.oper.NticeMapper;
13
+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;
23
+import lombok.extern.slf4j.Slf4j;
24
+import org.springframework.beans.factory.annotation.Autowired;
25
+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
+
32
+@Service
33
+@Slf4j
34
+public class MainChartService extends CommonService {
35
+
36
+    @Autowired
37
+    private MainChartMapper mainChartMapper;
38
+
39
+    public PchReqChartResponse selectPchReqChart(String brandId, String storeId, String prType) throws Exception {
40
+        MainChartEntity entity = mainChartMapper.selectPchReqChart(brandId, storeId, prType);
41
+
42
+        String chartData = "[ [' ', '대기', '반려', '승인',], [' ', " + entity.getPr20Val() + " , " + entity.getPr30Val() + " , " + entity.getPr40Val() + "] ]";
43
+
44
+        PchReqChartResponse result = new PchReqChartResponse();
45
+        result.setChartData(chartData);
46
+        return result;
47
+    }
48
+
49
+}

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

@@ -0,0 +1,44 @@
1
+package com.oqpo.api.web.controller.oper;
2
+
3
+import com.oqpo.api.service.oper.MainChartService;
4
+import com.oqpo.api.web.dto.response.oper.mainchart.PchReqChartResponse;
5
+import io.swagger.annotations.Api;
6
+import io.swagger.annotations.ApiImplicitParam;
7
+import io.swagger.annotations.ApiImplicitParams;
8
+import io.swagger.annotations.ApiOperation;
9
+import lombok.extern.slf4j.Slf4j;
10
+import org.springframework.beans.factory.annotation.Autowired;
11
+import org.springframework.http.ResponseEntity;
12
+import org.springframework.web.bind.annotation.*;
13
+
14
+@Slf4j
15
+@RestController
16
+@RequestMapping("/api/main/chart")
17
+@Api(tags = {"메인차트 (MainChartController)"})
18
+public class MainChartController {
19
+
20
+    @Autowired
21
+    private MainChartService mainChartService;
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 = "prType", value = "구매요청타입", required = true, dataType = "String", paramType = "query")
35
+    })
36
+    @ApiOperation(value = "구매요청 차트")
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 {
41
+        return ResponseEntity.ok(mainChartService.selectPchReqChart(brandId, storeId, prType));
42
+    }
43
+
44
+}

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

@@ -0,0 +1,20 @@
1
+package com.oqpo.api.web.dto.response.oper.mainchart;
2
+
3
+import com.fasterxml.jackson.annotation.JsonInclude;
4
+import com.oqpo.api.entity.oper.FileEntity;
5
+import com.oqpo.api.entity.oper.NticeEntity;
6
+import io.swagger.annotations.ApiModelProperty;
7
+import lombok.*;
8
+
9
+import java.util.List;
10
+import java.util.stream.Collectors;
11
+
12
+@Getter
13
+@Setter
14
+public class PchReqChartResponse {
15
+
16
+    @ApiModelProperty(value = "차트 데이터")
17
+    private String chartData;
18
+
19
+}
20
+

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

@@ -0,0 +1,34 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+
4
+<mapper namespace="com.oqpo.api.mapper.oper.MainChartMapper">
5
+
6
+    <select id="selectPchReqChart" resultType="com.oqpo.api.entity.oper.MainChartEntity">
7
+        /* MainChartMapper.selectPchReqChart */
8
+        SELECT
9
+            COUNT(CASE WHEN A.pch_req_st_cd = 'PR20' THEN A.pch_req_unq_no END) AS pr20_val,
10
+            COUNT(CASE WHEN A.pch_req_st_cd = 'PR30' THEN A.pch_req_unq_no END) AS pr30_val,
11
+            COUNT(CASE WHEN A.pch_req_st_cd = 'PR40' THEN A.pch_req_unq_no END) AS pr40_val
12
+        FROM pch_req_base_info A
13
+        WHERE 1 = 1
14
+        <if test="brandId != null and brandId != '' ">
15
+        AND A.brand_id = #{brandId}
16
+        </if>
17
+        <if test="storeId != null and storeId != '' ">
18
+        AND A.store_id = #{storeId}
19
+        </if>
20
+        <if test='"A".equals(prType)'>
21
+        AND A.pch_req_dt = DATE_FORMAT(NOW(), '%Y%m%d')
22
+        </if>
23
+        <if test='"B".equals(prType)'>
24
+        AND A.pch_req_dt BETWEEN DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 7 DAY), '%Y%m%d') AND DATE_FORMAT(NOW(), '%Y%m%d')
25
+        </if>
26
+        <if test='"C".equals(prType)'>
27
+        AND A.pch_req_dt BETWEEN DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 15 DAY), '%Y%m%d') AND DATE_FORMAT(NOW(), '%Y%m%d')
28
+        </if>
29
+        <if test='"D".equals(prType)'>
30
+        AND A.pch_req_dt BETWEEN DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 MONTH), '%Y%m%d') AND DATE_FORMAT(NOW(), '%Y%m%d')
31
+        </if>
32
+    </select>
33
+
34
+</mapper>