Explorar el Código

Merge branch 'dev' of chenweida/patient-co-management into dev

chenweida hace 8 años
padre
commit
7de1756f12

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

@ -5,6 +5,7 @@ import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.statistics.PopulationBase;
import com.yihu.wlyy.entity.statistics.WlyyQuotaResult;
import com.yihu.wlyy.job.Constant;
import com.yihu.wlyy.repository.address.CityDao;
import com.yihu.wlyy.repository.address.TownDao;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
@ -273,7 +274,7 @@ public class StatisticsAllService extends BaseService {
    public JSONObject getSignRate(String endDate, String area, int level) throws Exception {
        JSONObject json = new JSONObject();
        long signAmount = getIndexTotal(endDate, area, level, "13");
        PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(area, Calendar.getInstance().get(Calendar.YEAR));
        PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(area, Integer.valueOf(Constant.getNowYear()));
        DecimalFormat df = new DecimalFormat("0.0000");
        if (peopleNum != null && peopleNum.getNum() > 0) {
@ -302,7 +303,7 @@ public class StatisticsAllService extends BaseService {
    public JSONObject getSignTaskRate(String endDate, String area, int level) throws Exception {
        JSONObject json = new JSONObject();
        long signAmount = getIndexTotal(endDate, area, level, "13");
        PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(area, Calendar.getInstance().get(Calendar.YEAR));
        PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(area,Integer.valueOf( Constant.getNowYear()));
        DecimalFormat df = new DecimalFormat("0.0000");
        if (peopleNum != null && peopleNum.getTaskNum() > 0) {
@ -330,7 +331,7 @@ public class StatisticsAllService extends BaseService {
     * @param level
     * @return
     */
    public JSONObject getGroupInfo(String endDate, String lowCode, String area, int level) {
    public JSONObject getGroupInfo(String endDate, String lowCode, String area, int level) throws ParseException {
        JSONObject json = new JSONObject();
        long total = 0;
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
@ -399,7 +400,7 @@ public class StatisticsAllService extends BaseService {
            redisNum = "";
        }
        if (StringUtils.isEmpty(redisNum)) {
            PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(area, Calendar.getInstance().get(Calendar.YEAR));
            PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(area,Integer.valueOf( Constant.getNowYear()));
            if (peopleNum != null) {
                if (lowCode.equals("3")) {
                    num = peopleNum.getSixFiveNum();
@ -490,7 +491,7 @@ public class StatisticsAllService extends BaseService {
                        redisNum = "";
                    }
                    if (StringUtils.isEmpty(redisNum)) {
                        PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(), Calendar.getInstance().get(Calendar.YEAR));
                        PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(), Integer.valueOf( Constant.getNowYear()));
                        if (peopleNum != null) {
                            int num = 0;
                            int taskNum = 0;
@ -609,7 +610,7 @@ public class StatisticsAllService extends BaseService {
                        redisNum = "";
                    }
                    if (StringUtils.isEmpty(redisNum)) {
                        PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(), Calendar.getInstance().get(Calendar.YEAR));
                        PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(),Integer.valueOf( Constant.getNowYear()));
                        if (peopleNum != null) {
                            map.put("rate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getNum() * 100));
                            map.put("taskRate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getTaskNum() * 100));
@ -703,7 +704,7 @@ public class StatisticsAllService extends BaseService {
                        redisNum = "";
                    }
                    if (StringUtils.isEmpty(redisNum)) {
                        PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(), Calendar.getInstance().get(Calendar.YEAR));
                        PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(),Integer.valueOf( Constant.getNowYear()));
                        if (peopleNum != null) {
                            map.put("rate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getNum() * 100));
                            map.put("taskRate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getTaskNum() * 100));
@ -1878,7 +1879,7 @@ public class StatisticsAllService extends BaseService {
            }
            if (StringUtils.isEmpty(redisNum)) {
                PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(area, Calendar.getInstance().get(Calendar.YEAR));
                PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(area,Integer.valueOf( Constant.getNowYear()));
                if (peopleNum != null) {
                    taskNum = peopleNum.getTaskNum();
                }
@ -1897,7 +1898,7 @@ public class StatisticsAllService extends BaseService {
                redisNum = "";
            }
            if (StringUtils.isEmpty(redisNum)) {
                PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(area, Calendar.getInstance().get(Calendar.YEAR));
                PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(area, Integer.valueOf( Constant.getNowYear()));
                if (peopleNum != null) {
                    if (lowCode.equals("3")) {
                        taskNum = peopleNum.getSixFiveTaskNum();
@ -2514,7 +2515,7 @@ public class StatisticsAllService extends BaseService {
                        redisNum = "";
                    }
                    if (StringUtils.isEmpty(redisNum)) {
                        PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(), Calendar.getInstance().get(Calendar.YEAR));
                        PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(), Integer.valueOf( Constant.getNowYear()));
                        if (peopleNum != null) {
                            map.put("rate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getNum() * 100));
                            map.put("taskRate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getTaskNum() * 100));
@ -2774,7 +2775,7 @@ public class StatisticsAllService extends BaseService {
                        redisNum = "";
                    }
                    if (StringUtils.isEmpty(redisNum)) {
                        PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(), Calendar.getInstance().get(Calendar.YEAR));
                        PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(), Integer.valueOf( Constant.getNowYear()));
                        if (peopleNum != null) {
                            int num = 0;
                            int taskNum = 0;
@ -2850,11 +2851,12 @@ public class StatisticsAllService extends BaseService {
            return new JSONArray();
        }
    }
    public String getRange(int first, int second, int i) {
        if(second==0&&first>0){
        if (second == 0 && first > 0) {
            //如果分母为0 分子不为0 返回100%
            return "100%";
        }else if(second==0&&first==0){
        } else if (second == 0 && first == 0) {
            //如果分母为0 分子为0 返回0%
            return "0%";
        }
@ -2870,16 +2872,25 @@ public class StatisticsAllService extends BaseService {
        String lastDate = year + "-06-30";
        String low_level = String.valueOf(StringUtils.isEmpty(lowLevel) ? (level - 1) : lowLevel);
        List<Map<String, Object>> resultList = new ArrayList<>();
        if (date.compareTo(dateFormat.format(new Date())) >= 0) {
//            查询当天及以后的数据
            resultList = getLevelTwoTodayLowLevelTotal(area, level, index, sort, lowLevel, lowCode);
        List<Map<String, Object>> resultList = new ArrayList<>();//续签量
        List<Map<String, Object>> resultListSignIn = new ArrayList<>();//签入量
        resultList = getLevelTwoTodayLowLevelTotal(area, level, index, sort, lowLevel, lowCode);
        String indexTemp = "";
        if ("1".equals(lowLevel)) {
            indexTemp = "34";//团队的签入指标
        } else if ("2".equals(lowLevel)) {
            indexTemp = "38";//机构的签入指标
        } else {
//           查询当天以前的数据
            resultList = getLevelTwoTodayBeforeLowLevelTotal(date, area, level, index, sort, lowLevel, lowCode);
            indexTemp = "40";//区的签入指标
        }
        //根据等级得到签入量
        resultListSignIn = getLevelTwoTodayLowLevelTotal(area, level, indexTemp, sort, lowLevel, lowCode);
        Map<String, Integer> signInMap = new HashMap<>();
        if (resultListSignIn != null && resultListSignIn.size() > 0) {
            resultListSignIn.stream().forEach(one -> {
                signInMap.put(one.get("code").toString(), Integer.valueOf(one.get("amount").toString()));
            });
        }
        // 结果为空时,自建结果集
        if (resultList == null || resultList.size() < 1) {
            resultList = getLowLevelMapKey(level, low_level, area);
@ -2892,14 +2903,13 @@ public class StatisticsAllService extends BaseService {
                //获取去年签约的人数 默认是上个年度的最后一天
                WlyyQuotaResult redisNum = findOneQuotaResult(lastDate, Integer.valueOf(low_level), "1", map.get("code").toString());
                Integer signId = signInMap.get(map.get("code").toString()) == null ? 0 : signInMap.get(map.get("code").toString());
                if (redisNum == null) {
                    int signNum = 0;
                    int renewNum = 0;
                    signNum = Integer.valueOf(0);
                    renewNum = Integer.valueOf(map.get("amount").toString());
                    map.put("rate", getRange(renewNum,signNum,2));
                    renewNum = Integer.valueOf(map.get("amount").toString()) - signId; //续签量等于 续签量-签入量
                    map.put("rate", getRange(renewNum, signNum, 2));
                    map.put("signNum", 0);
                    map.put("renewNum", renewNum);
                } else {
@ -2909,8 +2919,8 @@ public class StatisticsAllService extends BaseService {
                        int renewNum = 0;
                        signNum = Integer.valueOf(redisNum.getResult());
                        renewNum = Integer.valueOf(map.get("amount").toString());
                        map.put("rate",getRange(renewNum,signNum,2));
                        renewNum = Integer.valueOf(map.get("amount").toString()) - signId; //续签量等于 续签量-签入量
                        map.put("rate", getRange(renewNum, signNum, 2));
                        map.put("signNum", signNum);
                        map.put("renewNum", renewNum);
                    }

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

@ -6,6 +6,7 @@ import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.statistics.PopulationBase;
import com.yihu.wlyy.entity.statistics.WlyyQuotaResult;
import com.yihu.wlyy.job.Constant;
import com.yihu.wlyy.repository.address.CityDao;
import com.yihu.wlyy.repository.address.TownDao;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
@ -407,7 +408,10 @@ public class StatisticsService extends BaseService {
                        redisNum = "";
                    }
                    if (StringUtils.isEmpty(redisNum)) {
                        PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(), Calendar.getInstance().get(Calendar.YEAR));
                        if(org.springframework.util.StringUtils.isEmpty(year)){
                            year= Constant.getNowYear();
                        }
                        PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(),Integer.valueOf(year));
                        if (peopleNum != null) {
                            map.put("rate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getNum() * 100));
                            map.put("rateString", map.get("amount") + "/" + peopleNum.getNum());
@ -4091,7 +4095,7 @@ public class StatisticsService extends BaseService {
    }
    public JSONObject getRenewAnalysis(String level, String code, String year) {
    public JSONObject getRenewAnalysis(String level, String code) {
        JSONObject jo = new JSONObject();
        String timeKey = redisTemplate.opsForValue().get("quota:timeKey");
        //获取签入人数
@ -4164,8 +4168,10 @@ public class StatisticsService extends BaseService {
     * @return
     */
    public String getRange(int first, int second, int i) {
        if(second==0){
            return "100&";
        if(second==0&&first>0){
            return "100%";
        }else if(second==0&&first==0){
            return "0%";
        }
        float size = (float) (first * 100) / second;
        DecimalFormat df = new DecimalFormat("0.00");//格式化小数,不足的补0

+ 8 - 10
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java

@ -346,7 +346,7 @@ public class StatisticsController extends BaseController {
    /**
     * 获取签约率、签约完成率
     *
     *t
     * @param endDate 截止日期
     * @param area    区域
     * @param level   区域级别 4:城市 3:区 2:社区 1:团队
@ -365,7 +365,7 @@ public class StatisticsController extends BaseController {
            if (StringUtils.isEmpty(lowCode)) {
                long sign = statisticsAllService.getIndexTotal(endDate, area, level, "13");
                long weiJf = statisticsAllService.getWeiJiaoFei(endDate, area, level);
                JSONObject jo = statisticsService.getRenewPercentAndChangePercent(level + "", area, Constant.getStartYear());
                JSONObject jo = statisticsService.getRenewPercentAndChangePercent(level + "", area, Constant.getNowYear());
                JSONObject signRate = statisticsAllService.getSignRate(endDate, area, level);
                JSONObject signTaskRate = statisticsAllService.getSignTaskRate(endDate, area, level);
@ -699,7 +699,7 @@ public class StatisticsController extends BaseController {
                                     @RequestParam(required = false) String year) {
        try {
            JSONObject data = null;
            if (Constant.getStartYear().equals(year)) {
            if (Constant.getNowYear().equals(year)) {
                //查今年的查找redis即可
                data = statisticsService.getConsultingTitle(level, area);
            } else if (org.springframework.util.StringUtils.isEmpty(year)) {
@ -734,7 +734,7 @@ public class StatisticsController extends BaseController {
            @RequestParam(required = true) String area,
            @RequestParam(required = false) String year) {
        try {
            if (Constant.getStartYear().equals(year)) {
            if (Constant.getNowYear().equals(year)) {
                return write(200, "查询成功", "data", statisticsService.getCoutListByTime(level, area));
            } else if (org.springframework.util.StringUtils.isEmpty(year)) {
                return write(200, "查询成功", "data", statisticsService.getCoutListByTimeAll(level, area));
@ -1430,17 +1430,15 @@ public class StatisticsController extends BaseController {
     *
     * @param level 等级  4 市  3区  2社区 1团队
     * @param code  市 默认是厦门市 350200  区 就是区的code  社区就是社区的code 团队就是团队的code
     * @param year  年份 非比传
     * @return
     */
    @RequestMapping(value = "/getRenewAnalysis", method = RequestMethod.GET)
    @ResponseBody
    public String getRenewAnalysis(
            @RequestParam(required = true) String level,
            @RequestParam(required = true) String code,
            @RequestParam(required = false) String year) {
            @RequestParam(required = true) String code) {
        try {
            return write(200, "查询成功", "data", statisticsService.getRenewAnalysis(level, code, year));
            return write(200, "查询成功", "data", statisticsService.getRenewAnalysis(level, code));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
@ -1462,13 +1460,13 @@ public class StatisticsController extends BaseController {
    }
    /**
     * 去年的签约量,续签量和续签率
     * 去年的签约量,续签量和续签率 列表
     *
     * @param date
     * @param area
     * @param level   level1_type等级 1:团队 2社区机构 3区级 4市级
     * @param sort    0:升序 1:降序
     * @param lowCode
     * @param lowLevel 只有可能是 1,2,3,
     * @return
     */
    @RequestMapping("/lowlevel_all_sign_renew")