Sfoglia il codice sorgente

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

Conflicts:
	svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/CapacityAssessmentRecordService.java
yeshijie 4 anni fa
parent
commit
305e3690cc

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

@ -1,7 +1,14 @@
package com.yihu.jw.care.endpoint.statistics;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
@ -10,7 +17,57 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value = "statistics")
@Api(value = "统计相关", description = "统计相关", tags = {"统计相关"})
public class StatisticsEndpoint {
public class StatisticsEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private StatisticsService statisticsService;
    /**
     * 统计首页头部数据
     * @param startDate
     * @param endDate
     * @param area
     * @param level 2 市  3区  4医院 5、科室 6医生
     * @return
     */
    @GetMapping(value = "indexTopNum")
    @ApiOperation(value = "统计首页头部数据")
    public ObjEnvelop indexTopNum(
            @RequestParam(required = true) String startDate,
            @RequestParam(required = true) String endDate,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) Integer level) {
        try {
            return ObjEnvelop.getSuccess("查询成功",statisticsService.indexTopNum(area,startDate,endDate,level));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ObjEnvelop.getError("查询失败",-1);
    }
    /**
     * 首页 养护服务
     * @param startDate
     * @param endDate
     * @param area
     * @param level 2 市  3区  4医院 5、科室 6医生
     * @return
     */
    @GetMapping(value = "indexMaintenanceServices")
    @ApiOperation(value = "首页-养护服务")
    public ObjEnvelop indexMaintenanceServices(
            @RequestParam(required = true) String startDate,
            @RequestParam(required = true) String endDate,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int type,
            @RequestParam(required = true) Integer level) {
        try {
            return ObjEnvelop.getSuccess("查询成功",statisticsService.indexMaintenanceServices(area,startDate,endDate,level,type));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ObjEnvelop.getError("查询失败",-1);
    }
}

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

@ -3,12 +3,16 @@ package com.yihu.jw.care.service.statistics;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.util.ConstantUtil;
import com.yihu.jw.es.util.ElasticsearchUtil;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.Calendar;
/**
 *
 * Created by yeshijie on 2021/4/7.
@ -27,26 +31,111 @@ public class StatisticsService {
    /**
     * 统计首页头部数据
     * @param area
     * @param startTime
     * @param endTime
     * @param startDate
     * @param endDate
     */
    public JSONObject indexTopNum(String area,String startTime,String endTime,String level){
    public JSONObject indexTopNum(String area,String startDate,String endDate,Integer level){
        JSONObject re = new JSONObject();
        String signSql = "select count(s.id) from base_service_package_sign_record s";
        String capacitySql = "select count(c.id) from base_capacity_assessment_record c";
        String signSql = " SELECT COUNT(sr.id) " +
                " FROM " +
                "  base_service_package_sign_record sr, " +
                "  base_service_package_record r, " +
                "  base_service_package_item i, " +
                "   base_org o " +
                " WHERE " +
                "  sr.id = r.sign_id " +
                " AND sr. STATUS = 1 " +
                " AND r.service_package_id = i.service_package_id " +
                " AND i.del = 1 and i.org_code = o.code";
        String capacitySql = "select count(sr.id) from base_capacity_assessment_record sr, " +
                "   base_org o " +
                " WHERE " +
                " sr.org_code = o.code" ;
        String filters = "";
        if(ConstantUtil.cityLevel.equals(level)){
            filters = " and o.city_code = '"+area+"'";
        }else if(ConstantUtil.townLevel.equals(level)){
            filters = " and o.town_code = '"+area+"'";
        }else if(ConstantUtil.orgLevel.equals(level)){
            filters = " and o.code = '"+area+"'";
        }
        if(StringUtils.isNotBlank(startDate)){
            filters += " and sr.create_time >='"+startDate+"'";
        }
        if(StringUtils.isNotBlank(endDate)){
            filters += " and sr.create_time <='"+endDate+"'";
        }
        //签约数 能力评估
        if(ConstantUtil.CITY.equals(area)){
            signSql += " where s.status = 1";
        }else{
        Integer signNum = jdbcTemplate.queryForObject(signSql+filters,Integer.class);
        Integer capacityNum = jdbcTemplate.queryForObject(capacitySql+filters,Integer.class);
        re.put("signNum",signNum);
        re.put("capacityNum",capacityNum);
        return re;
    }
    /**
     * 首页 养护服务
     * @param area
     * @param startDate
     * @param endDate
     * @param level
     * @param type 类型:1本周,2本月
     */
    public JSONObject indexMaintenanceServices(String area,String startDate,String endDate,Integer level,int type){
        JSONObject re = new JSONObject();
        String sql = "select count(sr.id) from base_life_care_order sr, " +
                "   base_org o " +
                " WHERE " +
                " sr.hospital = o.code" ;
        if(ConstantUtil.cityLevel.equals(level)){
            sql += " and o.city_code = '"+area+"'";
        }else if(ConstantUtil.townLevel.equals(level)){
            sql += " and o.town_code = '"+area+"'";
        }else if(ConstantUtil.orgLevel.equals(level)){
            sql += " and o.code = '"+area+"'";
        }
        String filters = "";
        String timefilters = "";
        if(StringUtils.isNotBlank(startDate)){
            filters += " and sr.create_time >='"+startDate+"'";
        }
        if(StringUtils.isNotBlank(endDate)){
            filters += " and sr.create_time <='"+endDate+"'";
        }
        String start = calStart(endDate,type);
        timefilters += " and sr.create_time >='"+start+"'";
        timefilters += " and sr.create_time <='"+endDate+"'";
        Integer signNum = jdbcTemplate.queryForObject(signSql,Integer.class);
        Integer capacityNum = jdbcTemplate.queryForObject(capacitySql,Integer.class);
        re.put("signNum",signNum);
        re.put("capacityNum",capacityNum);
        //生活照料
        Integer lifeCareNum = jdbcTemplate.queryForObject(sql+filters,Integer.class);
        Integer lifeCareNumAdd = jdbcTemplate.queryForObject(sql+timefilters,Integer.class);
        re.put("lifeCareNum",lifeCareNum);
        re.put("lifeCareNumAdd",lifeCareNumAdd);
        return re;
    }
    /**
     * 计算开始时间
     * @param endDate
     * @param type 1周,2月
     * @return
     */
    public String calStart(String endDate,int type){
        if(StringUtils.isEmpty(endDate)){
            return endDate;
        }
        Calendar cal = Calendar.getInstance();
        cal.setTime(DateUtil.strToDate(endDate));
        if(1==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());
    }
}

+ 9 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/ConstantUtil.java

@ -11,6 +11,15 @@ public class ConstantUtil {
     */
    public static final String CITY = "330100";
    /**
     * 统计level
     */
    public final static Integer doctorLevel = 6;
    public final static Integer deptLevel = 5;
    public final static Integer orgLevel = 4;
    public final static Integer townLevel = 3;
    public final static Integer cityLevel = 2;
    /**
     * 字典项定义
     *