Explorar o código

[task-1542] 【后端】涉及条款统计表的后端接口

Li Yuan %!s(int64=2) %!d(string=hai) anos
pai
achega
cb99135501

+ 39 - 0
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/business/controller/StatisticController.java

@@ -0,0 +1,39 @@
+package com.lc.ibps.business.controller;
+
+import com.lc.ibps.api.base.constants.StateEnum;
+import com.lc.ibps.base.core.util.I18nUtil;
+import com.lc.ibps.business.service.StatisticService;
+import com.lc.ibps.cloud.entity.APIResult;
+import com.lc.ibps.cloud.provider.GenericProvider;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.hibernate.validator.constraints.NotBlank;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.Map;
+
+@Api(tags = "获取统计报表数据")
+@RequestMapping("/report/statistic")
+@RestController
+public class StatisticController extends GenericProvider {
+
+    @Autowired
+    StatisticService statisticService;
+
+    @ApiOperation("获取风险控制报表")
+    @GetMapping("/risk")
+    APIResult<List<Map<String, Object>>> getRiskReport(@NotBlank(message = "{com.lc.ibps.cloud.file.attachmentId}")
+                                                       @RequestParam(name = "riskId", required = true) String riskId, @NotBlank(message = "{com.lc.ibps.cloud.file.attachmentId}")
+                                                       @RequestParam(name = "type", required = true) String type) {
+        APIResult<List<Map<String, Object>>> result = new APIResult<>();
+        try {
+            List<Map<String, Object>> riskReport = statisticService.getRiskReport(riskId, type);
+            result.setData(riskReport);
+        } catch (Exception e) {
+            setExceptionResult(result, StateEnum.ILLEGAL_REQUEST.getCode(), I18nUtil.getMessage(StateEnum.ILLEGAL_REQUEST.getCode() + ""), e);
+        }
+        return result;
+    }
+}

+ 10 - 0
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/business/service/StatisticService.java

@@ -0,0 +1,10 @@
+package com.lc.ibps.business.service;
+
+import com.lc.ibps.cloud.entity.APIResult;
+
+import java.util.List;
+import java.util.Map;
+
+public interface StatisticService {
+    List<Map<String, Object>> getRiskReport(String riskId, String type);
+}

+ 49 - 0
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/business/service/impl/StatisticServiceImpl.java

@@ -0,0 +1,49 @@
+package com.lc.ibps.business.service.impl;
+
+
+import com.lc.ibps.base.framework.table.ICommonDao;
+import com.lc.ibps.business.service.StatisticService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class StatisticServiceImpl implements StatisticService {
+
+    @Resource
+    private ICommonDao<?> commonDao;
+
+    @Override
+    public List<Map<String, Object>> getRiskReport(String riskId, String type) {
+
+        String typeSql = getFetchSqlForRiskReport(type);
+        return (List<Map<String, Object>>) commonDao.query(typeSql,new String[]{riskId});
+    }
+
+    private String getFetchSqlForRiskReport(String type){
+        String fetchSql = "";
+        if(type.equalsIgnoreCase("FXDJ")){
+            fetchSql =  "SELECT c.feng_xian_deng_ji,COUNT(1) AS total FROM t_fxssb a,t_fxsbpgb b,t_fxsbpgbzb c " +
+                    "   WHERE  a.shi_fou_guo_shen_ = '已完成'  AND  a.zong_id_=#{p0}" +
+                    "   AND a.zong_id_=b.zong_id_ AND b.id_=c.parent_id_ GROUP BY c.feng_xian_deng_ji";
+        } else if(type.equalsIgnoreCase("ZRBM")){
+            fetchSql = "SELECT d.name_,COUNT(1) AS total FROM t_fxssb a,t_fxsbpgb b,t_fxsbpgbzb c ,ibps_party_position d" +
+                    "   WHERE  a.shi_fou_guo_shen_ = '已完成'  AND  a.zong_id_=#{p0} AND b.bian_zhi_bu_men_ = d.id_" +
+                    "   AND a.zong_id_=b.zong_id_ AND b.id_=c.parent_id_ GROUP BY d.name_";
+        }else if(type.equalsIgnoreCase("SJTK")){
+            fetchSql = "SELECT c.yao_su_tiao_kuan_,COUNT(1) AS total FROM t_fxssb a,t_fxsbpgb b,t_fxsbpgbzb c " +
+                    "   WHERE  a.shi_fou_guo_shen_ = '已完成'  AND  a.zong_id_=#{p0}" +
+                    "   AND a.zong_id_=b.zong_id_ AND b.id_=c.parent_id_ GROUP BY c.yao_su_tiao_kuan_";
+        }else if(type.equalsIgnoreCase("YDCS")){
+            fetchSql = "SELECT c.feng_xian_ying_du,COUNT(1) AS total FROM t_fxssb a,t_fxsbpgb b,t_fxsbpgbzb c " +
+                    "   WHERE  a.shi_fou_guo_shen_ = '已完成'  AND  a.zong_id_=#{p0}" +
+                    "   AND a.zong_id_=b.zong_id_ AND b.id_=c.parent_id_ GROUP BY c.feng_xian_ying_du";
+        } else{
+            throw new IllegalArgumentException("type not match!");
+        }
+
+        return fetchSql;
+    }
+}