Browse Source

1.12.0代码合并

zdm 6 years ago
parent
commit
553f5a36fa

+ 61 - 4
src/main/java/com/yihu/quota/controller/QuotaController.java

@ -3,6 +3,8 @@ package com.yihu.quota.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.solr.SolrUtil;
import com.yihu.ehr.util.datetime.DateUtil;
import com.yihu.ehr.util.rest.Envelop;
import com.yihu.ehr.util.rest.Envelop;
import com.yihu.quota.etl.model.EsConfig;
import com.yihu.quota.etl.model.EsConfig;
import com.yihu.quota.model.jpa.TjQuota;
import com.yihu.quota.model.jpa.TjQuota;
@ -27,12 +29,10 @@ import org.apache.hadoop.hdfs.server.namenode.Quota;
import org.slf4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
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 org.springframework.web.bind.annotation.*;
import java.net.URLDecoder;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.*;
@ -55,6 +55,8 @@ public class QuotaController extends BaseController {
    private BaseStatistsService baseStatistsService;
    private BaseStatistsService baseStatistsService;
    @Autowired
    @Autowired
    private TjDataSaveService dataSaveService;
    private TjDataSaveService dataSaveService;
    @Autowired
    private SolrUtil solrUtil;
    private static final Logger log = LoggerFactory.getLogger(QuotaController.class);
    private static final Logger log = LoggerFactory.getLogger(QuotaController.class);
    /**
    /**
@ -263,4 +265,59 @@ public class QuotaController extends BaseController {
        return envelop;
        return envelop;
    }
    }
    @ApiOperation("根据条件到solr中获取记录数")
    @RequestMapping(value = "/report/searchSolrByParam", method = RequestMethod.POST)
    public Envelop searchSolrByParam(
            @ApiParam(name = "core", value = "solr core名称")
            @RequestParam(value = "core") String core,
            @ApiParam(name = "eventType", value = "就诊类型")
            @RequestParam(value = "eventType") String eventType,
            @ApiParam(name = "time", value = "过滤时间")
            @RequestParam(value = "time", required = false) String time,
            @ApiParam(name = "month", value = "获取几个月数据", defaultValue = "0")
            @RequestParam(value = "month", defaultValue = "0", required = false) Integer month) throws Exception {
        Envelop envelop = new Envelop();
        List<String> xDate = new ArrayList<>(); // x轴坐标
        List<String> yDate = new ArrayList<>(); // x轴坐标对应的值
        Map<String, String> map = new HashMap();
        String q = "";
        SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM-dd'T'23:59:59'Z'");
        if (StringUtils.isEmpty(eventType)) {
            q = "*:*";
        } else {
            q = "event_type:" + eventType;
        }
        if (StringUtils.isNotEmpty(time)) {
            Date dateTime = DateUtil.strToDate(time);
            Calendar calendar = new GregorianCalendar();
            calendar.setTime(dateTime);
            for (int i = 0; i < month; i++) {
                calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
                String startDate = DateUtil.utcToDate(calendar.getTime());
                calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
                String endDate = dfs.format(calendar.getTime());
                StringBuffer sb = new StringBuffer();
                if ("1".equals(eventType)) { // 就诊类型为住院
                    sb.append("EHR_005130:[").append(startDate).append(" TO ").append(endDate).append("] AND event_date:[")
                            .append(startDate).append(" TO ").append(endDate).append("]");
                } else if ("0".equals(eventType) || "2".equals(eventType)) {  // 就诊类型为门急诊、体检
                    sb.append("event_date:[").append(startDate).append(" TO ").append(endDate).append("]");
                }
                log.info(q);
                log.info(sb.toString());
                long count = solrUtil.count(core, q, sb.toString());
                xDate.add(startDate.substring(0,7));
                yDate.add(count == 0 ? "0" : count + "");
                calendar.add(Calendar.MONTH, -1);
            }
            Collections.reverse(xDate);
            Collections.reverse(yDate);
            envelop.setSuccessFlg(true);
            envelop.setObj(xDate);
            envelop.setDetailModelList(yDate);
        }
        return envelop;
    }
}
}

+ 7 - 4
src/main/java/com/yihu/quota/service/quota/BaseStatistsService.java

@ -622,6 +622,9 @@ public class BaseStatistsService {
    //获取该节点下所有末节点的结果和
    //获取该节点下所有末节点的结果和
    public   Map<String,Object> getParentAllChildren(List<String> quotaCodes, Map<String,Object> mapCategory,Map<String,Object> returnMap, List<Map<String, Object>> dimenListResult, double parentResult ){
    public   Map<String,Object> getParentAllChildren(List<String> quotaCodes, Map<String,Object> mapCategory,Map<String,Object> returnMap, List<Map<String, Object>> dimenListResult, double parentResult ){
        try {
        try {
                NumberFormat df = NumberFormat.getInstance();
                df.setGroupingUsed(false);
                df.setMaximumFractionDigits(2);
                boolean childrenFlag = false;
                boolean childrenFlag = false;
                if(mapCategory.get("children") != null){
                if(mapCategory.get("children") != null){
                    List<Map<String,Object>> childrenOrgHealthCategoryList = (List<Map<String, Object>>) mapCategory.get("children");
                    List<Map<String,Object>> childrenOrgHealthCategoryList = (List<Map<String, Object>>) mapCategory.get("children");
@ -644,14 +647,14 @@ public class BaseStatistsService {
                                if(returnMap.get(resultField) != null){
                                if(returnMap.get(resultField) != null){
                                    oldResult = Double.parseDouble(returnMap.get(resultField).toString());
                                    oldResult = Double.parseDouble(returnMap.get(resultField).toString());
                                }
                                }
                                returnMap.put(resultField,result + oldResult);
                                returnMap.put(resultField,df.format(result + oldResult));
                                for(String quotaCode : quotaCodes){
                                for(String quotaCode : quotaCodes){
                                    double quotaResult = Double.parseDouble(dimenMap.get(quotaCode).toString());
                                    double quotaResult = Double.parseDouble(dimenMap.get(quotaCode).toString());
                                    double oldQuotaResult = 0;
                                    double oldQuotaResult = 0;
                                    if( returnMap.get(quotaCode) != null ){
                                    if( returnMap.get(quotaCode) != null ){
                                        oldQuotaResult = Double.parseDouble(returnMap.get(quotaCode).toString());
                                        oldQuotaResult = Double.parseDouble(returnMap.get(quotaCode).toString());
                                    }
                                    }
                                    returnMap.put(quotaCode,quotaResult + oldQuotaResult);
                                    returnMap.put(quotaCode,df.format(quotaResult + oldQuotaResult));
                                }
                                }
                                break;
                                break;
                            }
                            }
@ -1175,8 +1178,8 @@ public class BaseStatistsService {
                filters = getdateComparisonTypeFilter(esConfig,filters);
                filters = getdateComparisonTypeFilter(esConfig,filters);
            }
            }
            if( (StringUtils.isNotEmpty(esConfig.getEspecialType())) && esConfig.getEspecialType().equals(orgHealthCategory)){
            if( (StringUtils.isNotEmpty(esConfig.getEspecialType())) && esConfig.getEspecialType().equals(orgHealthCategory)){
                //特殊机构类型查询输出结果  只有查询条件没有维度 默认是 机构类型维度
                result = getOrgHealthCategory(code,filters,dateType,isTrunTree, top);
//                //特殊机构类型查询输出结果  只有查询条件没有维度 默认是 机构类型维度
//                result = getOrgHealthCategory(code,filters,dateType,isTrunTree, top);
            }else if( (StringUtils.isNotEmpty(esConfig.getMolecular())) && StringUtils.isNotEmpty(esConfig.getDenominator())){//除法
            }else if( (StringUtils.isNotEmpty(esConfig.getMolecular())) && StringUtils.isNotEmpty(esConfig.getDenominator())){//除法
                //除法指标查询输出结果
                //除法指标查询输出结果
                molecularFilter = handleFilter(esConfig.getMolecularFilter(), molecularFilter);
                molecularFilter = handleFilter(esConfig.getMolecularFilter(), molecularFilter);