Bladeren bron

统计28接口

trick9191 8 jaren geleden
bovenliggende
commit
4207bc0b68

+ 10 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java

@ -9,6 +9,7 @@ import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientDisease;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.SignFamilyRenew;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorPatientGroupInfoDao;
@ -17,6 +18,7 @@ import com.yihu.wlyy.repository.doctor.SignPatientLabelInfoDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDiseaseDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.SignFamilyRenewDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.util.DateUtil;
@ -74,6 +76,8 @@ public class SignPatientLabelInfoService extends BaseService {
    AdminTeamService adminTeamService;
    @Autowired
    SignPatientLabelDao labelDao;
    @Autowired
    SignFamilyRenewDao signFamilyRenewDao;
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
@ -209,7 +213,12 @@ public class SignPatientLabelInfoService extends BaseService {
        }else{
            json.put("isRemainRenew","0");
        }
        String sql = "SELECT t.czrq FROM wlyy_sign_family_renew t WHERE t.status>=0 AND t.is_valid =0";
        List<Map<String,Object>> renews =  jdbcTemplate.queryForList(sql);
        if(renews!=null&&renews.size()>0){
            Map<String,Object> renew = renews.get(0);
            json.put("renewTime",renew.get("czrq"));
        }
        return json;
    }

+ 36 - 8
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java

@ -404,7 +404,7 @@ public class SignWebService extends BaseService {
            jsonObject.put("applyDate",renew.getApplyDate());
            jsonObject.put("createTime",renew.getCzrq());
            jsonObject.put("type",renew.getType());
            jsonObject.put("typeName",renew.getType()==1?"三师签约":"家庭签约");
            jsonObject.put("typeName",renew.getType()==1?"三师签约":"家庭签约续签");
            String statusName = "";
            switch (jsonObject.getInt("status")){
                case -4 : statusName = "已到期";break;
@ -748,8 +748,9 @@ public class SignWebService extends BaseService {
                "    ,b.street_name as streetName" +
                "    ,b.sex" +
                "    ,b.openid" +
                "    ,a.czrq" +
                " from " +
                " ( select code,patient,doctor,status,id,apply_date,patient_apply_date,expenses_time,reason,begin from wlyy_sign_family_renew where (doctor = ? or doctor_health = ?) and status = ? and type = 2" +
                " ( select czrq,code,patient,doctor,status,id,apply_date,patient_apply_date,expenses_time,reason,begin from wlyy_sign_family_renew where (doctor = ? or doctor_health = ?) and status = ? and type = 2" +
                " order by begin desc ) a " +
                " ,wlyy_patient b " +
                " where a.patient = b.code  order by a.begin desc limit " + page * pageSize + "," + pageSize;
@ -773,10 +774,37 @@ public class SignWebService extends BaseService {
                "    ,b.street_name as streetName" +
                "    ,b.sex" +
                "    ,b.openid" +
                "    ,a.czrq" +
                " from " +
                " ( select code,patient,doctor,status,id,apply_date,reason,begin,expenses_status,LENGTH(trim(ifnull(expenses_status,''))) len from wlyy_sign_family_renew where (doctor = ? or doctor_health = ?) and status > ? and type = 2 order by begin desc ) a " +
                " ( select czrq,code,patient,doctor,status,id,apply_date,reason,begin,expenses_status,LENGTH(trim(ifnull(expenses_status,''))) len from wlyy_sign_family_renew where (doctor = ? or doctor_health = ?) and status > ? and type = 2 order by begin desc ) a " +
                " ,wlyy_patient b " +
                " where a.patient = b.code and (a.expenses_status = '0' or a.len < 1) order by a.begin desc limit " + page * pageSize + "," + pageSize;
                " where a.patient = b.code and a.expenses_status = '0' order by a.begin desc limit " + page * pageSize + "," + pageSize;
        // 已签约
        String signedSql = "select " +
                "    a.code " +
                "    ,a.doctor " +
                "    ,b.code  as  patient" +
                "    ,b.idcard " +
                "    ,b.name " +
                "    ,b.province_name  as provinceName" +
                "    ,b.city_name  as cityName" +
                "    ,b.town_name  as townName" +
                "    ,b.address " +
                "    ,b.photo " +
                "    ,a.status " +
                "    ,a.id " +
                (status == 1 ? "    ,a.patient_apply_date as applyDate " : "    ,a.expenses_time as applyDate ") +
                "    ,a.reason " +
                "    ,b.street_name as streetName" +
                "    ,b.sex" +
                "    ,b.openid" +
                "    ,a.czrq" +
                " from " +
                " ( select expenses_status,czrq,code,patient,doctor,status,id,apply_date,patient_apply_date,expenses_time,reason,begin from wlyy_sign_family_renew where (doctor = ? or doctor_health = ?) and status = ? and type = 2" +
                " order by begin desc ) a " +
                " ,wlyy_patient b " +
                " where a.patient = b.code and a.expenses_status = '1' order by a.begin desc limit " + page * pageSize + "," + pageSize;
        //1:待签约 2, 待缴费 3 已签约
@ -787,10 +815,10 @@ public class SignWebService extends BaseService {
                patients = jdbcTemplate.queryForList(sql, new Object[]{doctor, doctor, 0});
                break;
            case 2:// 待缴费
                patients = jdbcTemplate.queryForList(sqlExpenses, new Object[]{doctor, doctor, 1});
                patients = jdbcTemplate.queryForList(sqlExpenses, new Object[]{doctor, doctor, 0});
                break;
            case 3:// 已签约
                patients = jdbcTemplate.queryForList(sql, new Object[]{doctor, doctor, 1});
                patients = jdbcTemplate.queryForList(signedSql, new Object[]{doctor, doctor, 1});
                break;
        }
@ -934,9 +962,9 @@ public class SignWebService extends BaseService {
     * 获取年度列表
     * @return
     */
    public JSONObject getRenewYearCount(String doctorCode){
    public JSONObject getRenewYearCount(Long teamCode){
        StringBuffer sql = new StringBuffer("SELECT t.sign_year labelCode,COUNT(1) amount " +
                "FROM  wlyy_sign_family t WHERE t.doctor ='"+doctorCode+"' AND t.end <=NOW() AND t.status=-4 AND sign_year IS NOT NULL GROUP BY t.sign_year DESC");
                "FROM  wlyy_sign_family t WHERE t.admin_team_code ='"+teamCode+"' AND t.end <=NOW() AND t.status=-4 AND sign_year IS NOT NULL GROUP BY t.sign_year DESC");
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql.toString());
        JSONObject json = new JSONObject();
        json.put("result",rs);

+ 1 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsAllService.java

@ -2518,4 +2518,5 @@ public class StatisticsAllService extends BaseService {
        return 0L;
    }
}

+ 87 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java

@ -17,6 +17,7 @@ import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.nativejdbc.OracleJdbc4NativeJdbcExtractor;
import org.springframework.stereotype.Service;
import org.apache.commons.lang3.StringUtils;
@ -1606,13 +1607,13 @@ public class StatisticsService extends BaseService {
            sql +=" AND d.city = ? ";
        //区级
        }else if("3".equals(level)){
            sql +=" AND d.towm = ? ";
            sql +=" AND d.town = ? ";
        //机构
        }else if("2".equals(level)){
            sql +=" AND d.hospital = ? ";
        }
        Map<String,Object> rs = jdbcTemplate.queryForMap(sql);
        Map<String,Object> rs = jdbcTemplate.queryForMap(sql,new Object[]{area});
        JSONObject json = new JSONObject();
@ -1620,4 +1621,88 @@ public class StatisticsService extends BaseService {
        return json;
    }
    public JSONObject getAVGSocreByMonth(String level ,String area,String statDate,String endDate)throws  Exception{
        List<String> times =  getMonthBetween(statDate,endDate);
        if(times==null||times.size()==0){
            throw new Exception("时间区间错误");
        }
        String sql = "SELECT DATE_FORMAT(t.czrq,'%Y-%m') mt,ifnull(ROUND(AVG(s.score),1),0)  as avgCount " +
                " FROM  wlyy_consult_team t " +
                "  LEFT JOIN wlyy_doctor d ON d.code = t.doctor" +
                "  LEFT JOIN wlyy_evaluate_score s ON s.doctor = t.doctor" +
                " WHERE t.czrq >=? AND t.czrq <=?";
        //市级
        if("4".equals(level)){
            sql +=" AND d.city = ? ";
            //区级
        }else if("3".equals(level)){
            sql +=" AND d.town = ? ";
            //机构
        }else if("2".equals(level)){
            sql +=" AND d.hospital = ? ";
        }
        sql +=" GROUP BY mt order by mt DESC ";
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql,new Object[]{statDate,endDate,area});
        Map<String,Object> map = new HashMap<>();
        if(rs!=null&&rs.size()>0){
            //降低循环层级
            for(Map<String,Object> m : rs){
                map.put((String)m.get("mt"),m);
            }
        }
        Map<String,Object> rsMap = new HashMap<>();
        for(String time : times){
            rsMap.put(time,map.get(time)==null?0:((Map<String,Object>)map.get(time)).get("avgCount"));
        }
        JSONObject data = new JSONObject();
        data.put("data",rsMap);
        return data;
    }
    private  List<String> getMonthBetween(String minDate, String maxDate) throws Exception {
        ArrayList<String> result = new ArrayList<String>();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");//格式化为年月
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");//格式化为年月
        Calendar min = Calendar.getInstance();
        Calendar max = Calendar.getInstance();
        min.setTime(sdf2.parse(minDate));
        min.set(min.get(Calendar.YEAR), min.get(Calendar.MONTH), 1);
        max.setTime(sdf2.parse(maxDate));
        max.set(max.get(Calendar.YEAR), max.get(Calendar.MONTH), 2);
        Calendar curr = min;
        while (curr.before(max)) {
            result.add(sdf.format(curr.getTime()));
            curr.add(Calendar.MONTH, 1);
        }
        return result;
    }
    public String getAvgAllInfo(int level ,String area,String lowLevel){
        String timeKey = redisTemplate.opsForValue().get("quota:timeKey");
        String rs = "";
        //市级
        if(level==4){
            if(StringUtils.isNotBlank(lowLevel)){
                rs = redisTemplate.opsForValue().get("quota:28:"+level+":"+area+":3:"+timeKey);
            }else{
                rs = redisTemplate.opsForValue().get("quota:28:"+level+":"+area+":2:"+timeKey);
            }
        } else if(level ==3){
            rs = redisTemplate.opsForValue().get("quota:28:"+level+":"+area+":2:"+timeKey);
        }else if(level ==2){
            rs = redisTemplate.opsForValue().get("quota:28:"+level+":"+area+":1:"+timeKey);
        }
        return rs;
    }
}

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java

@ -246,7 +246,7 @@ public class SignPatientLabelInfoController extends BaseController {
            //计算年度数目
            if(labelType.equals("9")){
                JSONObject r= signWebService.getRenewYearCount(getUID());
                JSONObject r= signWebService.getRenewYearCount(teamCode);
                return write(200, "查询成功", "data", r);
            }

+ 12 - 11
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java

@ -382,6 +382,7 @@ public class DoctorSignController extends WeixinBaseController {
                    json.put("photo", temp.get("photo"));
                    json.put("status", temp.get("status"));
                    json.put("openid", temp.get("openid"));
                    json.put("renewTime", temp.get("czrq"));
                    String statusName = "";
                    switch (Integer.parseInt(temp.get("status").toString())) {
                        case 0:
@ -484,17 +485,17 @@ public class DoctorSignController extends WeixinBaseController {
     * 获取去医生下年度分组列表
     * @return
     */
    @RequestMapping("/getRenewYearCount")
    @ApiOperation(value = "获取年度分组")
    public String getRenewYearCount(){
        try{
            JSONObject rs =signWebService.getRenewYearCount(getUID());
            //JSONObject rs =signWebService.getRenewYearCount("64de930c-5b15-11e6-8344-fa163e8aee56");
            return write(200, "操作成功!", "data", rs);
        }catch (Exception e){
            return error(-1, "请求失败");
        }
    }
//    @RequestMapping("/getRenewYearCount")
//    @ApiOperation(value = "获取年度分组")
//    public String getRenewYearCount(){
//        try{
//            JSONObject rs =signWebService.getRenewYearCount(getUID());
//            //JSONObject rs =signWebService.getRenewYearCount("64de930c-5b15-11e6-8344-fa163e8aee56");
//            return write(200, "操作成功!", "data", rs);
//        }catch (Exception e){
//            return error(-1, "请求失败");
//        }
//    }
    /**
     *

+ 23 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java

@ -440,7 +440,8 @@ public class StatisticsController extends BaseController {
                                            @RequestParam(required = true) String index,
                                            @RequestParam(required = true) int sort,
                                            @RequestParam(required = false) String lowLevel,
                                            @RequestParam(required = false) String lowCode) {
                                            @RequestParam(required = false) String lowCode,
                                            @RequestParam(required = false) String startDate) {
        try {
            String[] indexes = index.split(",");
            JSONObject result = new JSONObject();
@ -455,7 +456,9 @@ public class StatisticsController extends BaseController {
                        result.put("index_" + idx, statisticsAllService.getLowLevelTotalSpecial(date, area, level, idx, sort, lowLevel));
                    } else if (idx.equals("1") || index.equals("21")) {
                        result.put("index_" + idx, statisticsAllService.getLowLevelTotal2(date, area, level, idx, sort, lowLevel));
                    } else {
                    } else if (idx.equals("28")){
                        result.put("index_" + idx, statisticsService.getAvgAllInfo(level,area,lowLevel));
                    } else{
                        result.put("index_" + idx, statisticsAllService.getLowLevelTotal(date, area, level, idx, sort, lowLevel));
                    }
                }
@ -680,4 +683,22 @@ public class StatisticsController extends BaseController {
        }
    }
    /**
     * 获取得分平均数按月份
     * @return
     */
    @RequestMapping("/getAVGSocreByMonth")
    @ResponseBody
    public String getAVGSocreByMonth(@RequestParam(required = true)String level ,
                                     @RequestParam(required = true)String area,
                                     @RequestParam(required = true)String statDate,
                                     @RequestParam(required = true)String endDate){
        try {
            return write(200, "查询成功", "data", statisticsService.getAVGSocreByMonth(level,area,statDate,endDate));
        } catch (Exception e) {
            return error(-1, "查询失败");
        }
    }
}