Просмотр исходного кода

Merge branch 'dev-1.1.4' into 'dev-1.1.4'

医生首页接口优化

See merge request lihong/thmz_system!4
huangshuhua 2 лет назад
Родитель
Сommit
f1b48b7071

+ 0 - 5
src/main/java/cn/hnthyy/thmz/controller/bb/ReportStaticController.java

@@ -4,22 +4,17 @@ import cn.hnthyy.thmz.Utils.AssertUtil;
 import cn.hnthyy.thmz.Utils.R;
 import cn.hnthyy.thmz.Utils.TokenUtil;
 import cn.hnthyy.thmz.comment.UserLoginToken;
-import cn.hnthyy.thmz.entity.MzException;
 import cn.hnthyy.thmz.entity.thmz.User;
 import cn.hnthyy.thmz.service.his.bb.ReportStaticService;
 import cn.hnthyy.thmz.vo.ReportVo;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
-import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
 /**

+ 1 - 4
src/main/java/cn/hnthyy/thmz/mapper/his/bb/ReportStaticMapper.java

@@ -10,10 +10,7 @@ import java.util.Map;
 public interface ReportStaticMapper {
 
     @Select("<script> " +
-            " select * from report_base_info where flag = 'Y' " +
-            " <if test=\"reportId != null and reportId != '' \"> " +
-            " and report_id = #{reportId} " +
-            " </if> " +
+            " select * from report_base_info where flag = 'Y' and report_id = #{reportId} " +
             " <if test=\"reportType != null and reportType != '' \"> " +
             " and report_type = #{reportType} " +
             " </if> " +

+ 15 - 8
src/main/java/cn/hnthyy/thmz/service/impl/his/bb/ReportStaticServiceImpl.java

@@ -71,35 +71,42 @@ public class ReportStaticServiceImpl implements ReportStaticService {
 
         Map<String, Object> resultMap = new HashMap<>();
         String reportId = vo.getReportId();
-        String type = vo.getType();
         List<String> reportIds = vo.getReportIds();
+        String type = vo.getType();
+        List<Map<String, Object>> list = new ArrayList<>();
         if(reportIds != null && reportIds.size() > 0){
-            List<Map<String, Object>> list = new ArrayList<>();
             for (String id: reportIds) {
                 Map<String, Object> map = new HashMap<>();
                 ReportBaseInfo info = reportStaticMapper.selectReportBaseInfo(id, vo.getReportType(), null);
                 if("1".equals(type)){
                     String sql = callSqlFormat(vo, info.getBaseSql(), info.getGatherSql(), "", info.getReportSort());
                     String result = reportStaticMapper.selectReportTotal(sql);
-                    resultMap.put(info.getReportName(), result);
+                    map.put("label", info.getReportName());
+                    map.put("value", result);
+                    list.add(map);
+                    resultMap.put(info.getReportId(), list);
                 } else if("2".equals(type)) {
-                    String gatherSql = info.getGatherSql() + " as num,  t." + vo.getGroupColumn() + " ";
+                    String gatherSql = info.getGatherSql() + " as value,  t." + vo.getGroupColumn() + " ";
                     String sql = callSqlFormat(vo, info.getBaseSql(), gatherSql, vo.getGroupColumn(), info.getReportSort());
                     List<Map<String, Object>> l = reportStaticMapper.selectReportRegList(sql);
-                    resultMap.put(info.getReportName(), l);
+                    resultMap.put(info.getReportId(), l);
                 }
             }
         } else {
+            Map<String, Object> map = new HashMap<>();
             ReportBaseInfo info = reportStaticMapper.selectReportBaseInfo(reportId, vo.getReportType(), null);
             if("1".equals(type)) {
                 String sql = callSqlFormat(vo, info.getBaseSql(), info.getGatherSql(), "", info.getReportSort());
                 String result = reportStaticMapper.selectReportTotal(sql);
-                resultMap.put(info.getReportName(), result);
+                map.put("label", info.getReportName());
+                map.put("value", result);
+                list.add(map);
+                resultMap.put(reportId, list);
             } else if("2".equals(type)) {
-                String gatherSql = info.getGatherSql() + " as num,  t." + vo.getGroupColumn() + " ";
+                String gatherSql = info.getGatherSql() + " as value,  t." + vo.getGroupColumn() + " ";
                 String sql = callSqlFormat(vo, info.getBaseSql(), gatherSql, vo.getGroupColumn(), info.getReportSort());
                 List<Map<String, Object>> l = reportStaticMapper.selectReportRegList(sql);
-                resultMap.put(info.getReportName(), l);
+                resultMap.put(info.getReportId(), l);
             }
         }
         return resultMap;