瀏覽代碼

bug修改

chenweida 8 年之前
父節點
當前提交
a6bfec3244

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

@ -274,7 +274,7 @@ public class StatisticsAllService extends BaseService {
    public JSONObject getSignRate(String endDate, String area, int level, String year) throws Exception {
        JSONObject json = new JSONObject();
        long signAmount = getIndexTotal(endDate, area, level, "13");
        PopulationBase peopleNum = getPopulationBase(area,year);
        PopulationBase peopleNum = getPopulationBase(area, year);
        DecimalFormat df = new DecimalFormat("0.0000");
        if (peopleNum != null && peopleNum.getNum() > 0) {
@ -303,7 +303,7 @@ public class StatisticsAllService extends BaseService {
    public JSONObject getSignTaskRate(String endDate, String area, int level, String year) throws Exception {
        JSONObject json = new JSONObject();
        long signAmount = getIndexTotal(endDate, area, level, "13");
        PopulationBase peopleNum = getPopulationBase(area,year);
        PopulationBase peopleNum = getPopulationBase(area, year);
        DecimalFormat df = new DecimalFormat("0.0000");
        if (peopleNum != null && peopleNum.getTaskNum() > 0) {
@ -393,7 +393,7 @@ public class StatisticsAllService extends BaseService {
        int num = 0;
        int taskNum = 0;
        PopulationBase peopleNum = getPopulationBase(area,year);
        PopulationBase peopleNum = getPopulationBase(area, year);
        if (peopleNum != null) {
            if (lowCode.equals("3")) {
                num = peopleNum.getSixFiveNum();
@ -462,7 +462,7 @@ public class StatisticsAllService extends BaseService {
                map.put("amount", map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0L);
                if (!low_level.equals("1")) {
                    PopulationBase peopleNum = getPopulationBase(area,year);
                    PopulationBase peopleNum = getPopulationBase(area, year);
                    if (peopleNum != null) {
                        int num = 0;
                        int taskNum = 0;
@ -548,7 +548,7 @@ public class StatisticsAllService extends BaseService {
                map.put("amount", map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0L);
                if (!low_level.equals("1")) {
                    PopulationBase peopleNum = getPopulationBase(area,year);
                    PopulationBase peopleNum = getPopulationBase(area, year);
                    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));
@ -618,13 +618,13 @@ public class StatisticsAllService extends BaseService {
        if (resultList != null) {
            DecimalFormat df = new DecimalFormat("0.0000");
            for (int i=0;i<resultList.size();i++) {
                Map<String, Object> map=resultList.get(i);
            for (int i = 0; i < resultList.size(); i++) {
                Map<String, Object> map = resultList.get(i);
                map.put("amount", map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0L);
                if (!low_level.equals("1")) {
                    String code=map.get("code").toString();
                    PopulationBase peopleNum = getPopulationBase(code,year);
                    String code = map.get("code").toString();
                    PopulationBase peopleNum = getPopulationBase(code, year);
                    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));
@ -1779,13 +1779,13 @@ public class StatisticsAllService extends BaseService {
        if (level > 1 && StringUtils.isEmpty(lowCode)) {
            PopulationBase peopleNum = getPopulationBase(area,year);
            PopulationBase peopleNum = getPopulationBase(area, year);
            if (peopleNum != null) {
                taskNum = peopleNum.getTaskNum();
            }
        }
        if (!StringUtils.isEmpty(lowCode)) {
            PopulationBase peopleNum = getPopulationBase(area,year);
            PopulationBase peopleNum = getPopulationBase(area, year);
            if (peopleNum != null) {
                if (lowCode.equals("3")) {
                    taskNum = peopleNum.getSixFiveTaskNum();
@ -2614,7 +2614,7 @@ public class StatisticsAllService extends BaseService {
                map.put("amount", map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0L);
                if (!low_level.equals("1")) {
                    PopulationBase peopleNum = getPopulationBase(map.get("code").toString(),year);
                    PopulationBase peopleNum = getPopulationBase(map.get("code").toString(), year);
                    if (peopleNum != null) {
                        int num = 0;
                        int taskNum = 0;
@ -2718,28 +2718,32 @@ public class StatisticsAllService extends BaseService {
        if (resultList != null) {
            DecimalFormat df = new DecimalFormat("0.0000");
            //查询去年的签约转map
            List<WlyyQuotaResult> yearsYear = findQuotaResultList(lastDate, Integer.valueOf(low_level), "1");
            Map<String, WlyyQuotaResult> resultMap = new HashMap<>();
            yearsYear.stream().forEach(one -> {
                if ("1".equals(low_level)) {
                    resultMap.put(one.getQkdoctorCode(), one);
                } else if ("2".equals(low_level)) {
                    resultMap.put(one.getOrgCode(), one);
                } else if ("3".equals(low_level)) {
                    resultMap.put(one.getTown(), one);
                }
            });
            for (Map<String, Object> map : resultList) {
                map.put("amount", map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0L);
                //获取去年签约的人数 默认是上个年度的最后一天
                WlyyQuotaResult redisNum = findOneQuotaResult(lastDate, Integer.valueOf(low_level), "1", map.get("code").toString());
                if (redisNum == null) {
                    int signNum = 0;
                    int renewNum = renewMap.get(map.get("code").toString());
                    signNum = Integer.valueOf(0);
                    map.put("rate", getRange(renewNum, signNum, 2));//续签率是 续签量/去年的签约数
                    map.put("signNum", 0);
                    map.put("renewNum", renewNum);
                } else {
                    JSONObject peopleNum = new JSONObject(redisNum);
                    if (peopleNum != null) {
                        int signNum = 0;
                        int renewNum = renewMap.get(map.get("code").toString());
                        signNum = Integer.valueOf(redisNum.getResult());
                        map.put("rate", getRange(renewNum, signNum, 2));//续签率是 续签量/去年的签约数
                        map.put("signNum", signNum);
                        map.put("renewNum", renewNum);
                    }
                WlyyQuotaResult one=resultMap.get(map.get("code").toString());
                int signNum = 0;
                int renewNum = renewMap.get(map.get("code").toString());
                if(one!=null){
                    signNum=Integer.valueOf(one.getResult());
                }
                map.put("rate", getRange(renewNum, signNum, 2));//续签率是 续签量/去年的签约数
                map.put("signNum", signNum);
                map.put("renewNum", renewNum);
            }
            if ((level == 4 && "1".equals(lowLevel)) || (level == 2) || (level == 3 && "1".equals(lowLevel))) {
@ -2773,31 +2777,16 @@ public class StatisticsAllService extends BaseService {
     * @param date
     * @param level
     * @param index
     * @param area
     * @return
     */
    public WlyyQuotaResult findOneQuotaResult(String date, int level, String index, String area) {
        String sql = " select * from wlyy_quota_result w where w.quota_date ='" + date + "' and w.quato_code='" + index + "' and w.level1_type= " + level;
        if (level == 4) {
            // 市级别
            sql += " and city='" + area + "' ";
        } else if (level == 3) {
            // 区、城镇级别
            sql += " and town='" + area + "' ";
        } else if (level == 2) {
            // 机构级别
            sql += " and org_code='" + area + "' ";
        } else if (level == 1) {
            // 机构级别
            sql += " and qkdoctor_code ='" + area + "'";
        }
    public List<WlyyQuotaResult> findQuotaResultList(String date, int level, String index) {
        String sql = " select * from wlyy_quota_result w where " +
                " w.quota_date ='" + date + "' and " +
                " w.quato_code='" + index + "' and " +
                " w.level1_type= " + level;
        List<WlyyQuotaResult> results = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyyQuotaResult.class));
        if (results.size() > 0) {
            return results.get(0);
        }
        return null;
        return results;
    }
    //================================通用接口=============================
    /**
@ -2817,10 +2806,10 @@ public class StatisticsAllService extends BaseService {
        return switchJo;
    }
    public PopulationBase getPopulationBase(String code,String year){
    public PopulationBase getPopulationBase(String code, String year) {
        String sql="select * from wlyy_people_num where code=? and year=? ";
        List<PopulationBase> peopleNum = jdbcTemplate.query(sql,new BeanPropertyRowMapper(PopulationBase.class),code,year);
        String sql = "select * from wlyy_people_num where code=? and year=? ";
        List<PopulationBase> peopleNum = jdbcTemplate.query(sql, new BeanPropertyRowMapper(PopulationBase.class), code, year);
        return peopleNum.get(0);
    }
}