Procházet zdrojové kódy

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

# Conflicts:
#	common/common-entity/sql记录
yeshijie před 3 roky
rodič
revize
e1bc2bd317

+ 20 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/StatisticsEndpoint.java

@ -1,10 +1,12 @@
package com.yihu.jw.care.endpoint.statistics;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.service.statistics.StatisticsService;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@ -22,6 +24,24 @@ public class StatisticsEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private StatisticsService statisticsService;
    @GetMapping(value = "statisticsTotalAmount")
    @ApiOperation(value = "统计总数")
    public ObjEnvelop statisticsTotalAmount(
            @RequestParam(required = true) String endDate,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level,
            @RequestParam(required = true) String index,
            @ApiParam(name="type",value="类型:1本周,2本月",defaultValue = "")@RequestParam(required = false) String type) {
        try {
            JSONObject result = statisticsService.statisticsTotalAmount(endDate, area, level, index, type);
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    /**
     * 统计首页头部数据
     * @param startDate

+ 50 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsService.java

@ -2,7 +2,12 @@ package com.yihu.jw.care.service.statistics;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.util.ConstantUtil;
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.es.util.ElasticsearchUtil;
import com.yihu.jw.es.util.SaveModel;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
@ -26,14 +31,56 @@ public class StatisticsService {
    private ElasticsearchUtil elasticsearchUtil;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    @Autowired
    private DictHospitalDeptDao hospitalDeptDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private BaseOrgDao orgDao;
    @Autowired
    private StatisticsUtilService statisticsUtilService;
    /**
     * 统计首页头部数据
     * @param area
     * @param startDate
     * 统计总数
     * @param endDate
     * @param area
     * @param level 2 市  3区  4医院 5、科室 6医生
     * @param index
     * @param type
     * @return
     * @throws Exception
     */
    public JSONObject statisticsTotalAmount( String endDate, String area, int level, String index, String type) throws Exception {
        JSONObject res = new JSONObject();
        String[] indexes = index.split(",");
        for(String ind:indexes){
            //总量
            SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, ind, SaveModel.timeLevel_DDL);
            res.put("index_"+ind+"_total",saveModel.getResult2().longValue());
            if(StringUtils.isNotBlank(type)){
                //周/月 增量
                String start = statisticsUtilService.calStart(endDate,type);
                SaveModel saveModelAdd = elasticsearchUtil.findOneDateQuotaLevel0(start, endDate, area, level, ind, SaveModel.timeLevel_ZL);
                res.put("index_"+ind+"_add",saveModelAdd.getResult2().longValue());
            }
        }
        return res;
    }
        /**
         * 统计首页头部数据
         * @param area
         * @param startDate
         * @param endDate
         */
    public JSONObject indexTopNum(String area,String startDate,String endDate,Integer level){
        JSONObject re = new JSONObject();
        String signSql = " SELECT COUNT(sr.id) " +

+ 41 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsUtilService.java

@ -0,0 +1,41 @@
package com.yihu.jw.care.service.statistics;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Calendar;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/6/11
 * @Description:
 */
@Service
public class StatisticsUtilService {
    /**
     * 计算开始时间
     * @param endDate
     * @param type 1周,2月
     * @return
     */
    public String calStart(String endDate,String type){
        if(StringUtils.isEmpty(endDate)){
            return endDate;
        }
        Calendar cal = Calendar.getInstance();
        cal.setTime(DateUtil.strToDate(endDate));
        if("1".equals(type)){
            if(cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY){
                cal.add(Calendar.DAY_OF_WEEK,-1);
            }
            cal.set(Calendar.DAY_OF_WEEK,Calendar.MONDAY);
        }else{
            cal.set(Calendar.DAY_OF_MONTH,1);
        }
        return DateUtil.dateToStrShort(cal.getTime());
    }
}

+ 2 - 2
svr/svr-cloud-care/src/main/resources/application.yml

@ -245,8 +245,8 @@ es:
  type:
    Statistics: hlw_quota_test
    FollowUpContent: wlyy_followup_content
  host:  http://172.26.0.55:9000
  tHost: 172.26.0.55:9300
  host:  http://172.26.0.112:9000
  tHost: 172.26.0.112:9300
  clusterName: jkzl
  securityUser: lion:jkzlehr
  user: lion